@property --twin-float-lift {
  syntax: "<length>";
  inherits: true;
  initial-value: 5px;
}

:root {
  --row-space: 12px;
  --row-space-small: 8px;
  --row-gap: 6px;
  --row-tight-offset: -12px;
  --bg: #10131a;
  --panel: rgba(11, 16, 23, 0.86);
  --panel-border: rgba(255, 255, 255, 0.08);
  --card: rgba(255, 255, 255, 0.08);
  --accent: #f0b429;
  --accent-2: #6ee7b7;
  --danger: #ff6b6b;
  --text: #f7f4ea;
  --muted: #b8c0cc;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --font: "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 196, 94, 0.18), transparent 35%),
    linear-gradient(180deg, #1a2230, #0b0e14 60%);
  color: var(--text);
  font-family: var(--font);
}

body {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 860px);
  justify-content: center;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  gap: 12px;
  padding: 12px;
}

.panel,
.stage-shell {
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  transition: width 180ms ease, min-width 180ms ease, padding 180ms ease, opacity 180ms ease;
}

.panel-header,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 10px;
}

.panel-header h2,
.topbar h1 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.stage-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  order: 1;
}

.panel-left {
  order: 2;
}

.panel-right {
  order: 3;
}

.topbar-actions,
.item-popup-actions {
  display: flex;
  gap: 10px;
}

.topbar-actions {
  align-items: flex-start;
}

.audio-controls {
  display: grid;
  gap: 8px;
  min-width: 210px;
}

.audio-toggle-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.audio-toggle {
  position: relative;
  overflow: hidden;
  transition: background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.audio-toggle.audio-on {
  background: linear-gradient(135deg, rgba(90, 220, 140, 0.95), rgba(135, 255, 190, 0.78));
  color: #09210f;
  box-shadow: 0 0 18px rgba(96, 255, 156, 0.22);
}

.audio-toggle.audio-off {
  background: linear-gradient(135deg, rgba(80, 87, 101, 0.9), rgba(32, 40, 54, 0.9));
  color: #d6dce8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.volume-control {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.85rem;
}

.volume-control span {
  min-width: 44px;
}

.volume-control input {
  width: 100%;
}

.preplay-panel {
  display: grid;
  gap: var(--row-space-small);
}

.preplay-panel-content {
  display: grid;
  gap: var(--row-space-small);
  overflow: hidden;
  transition: max-height 220ms ease, opacity 160ms ease, transform 180ms ease;
}

.mobile-data-toggle {
  display: none;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 18px;
}

.hud > div {
  border-radius: 16px;
  background: var(--card);
  padding: 12px 14px;
}

.hud span,
.progress-label,
.shop-meta,
.item-popup-stats {
  color: var(--muted);
}

.hud strong {
  display: block;
  margin-top: 4px;
  font-size: 1.3rem;
}

.progress-shell {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
}

.progress-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffe27a, #ff944d);
  box-shadow: 0 0 22px rgba(255, 194, 77, 0.35);
  transition: width 120ms linear, background 200ms ease;
}

.canvas-shell {
  position: relative;
  justify-self: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto;
  aspect-ratio: 9 / 16;
  margin: 0 auto var(--row-space);
  border-radius: 22px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 255, 255, 0.42), transparent 32%),
    linear-gradient(180deg, #bfeaff 0%, #6cbdea 42%, #17334f 100%);
  min-height: 0;
  touch-action: none;
}

.egg-health-hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  z-index: 35;
  display: grid;
  grid-template-columns: auto minmax(86px, 15vw);
  align-items: center;
  gap: 7px;
  padding: 5px 7px 5px 6px;
  border: 2px solid rgba(9, 18, 24, 0.72);
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(238, 248, 235, 0.82), rgba(56, 72, 70, 0.48)),
    rgba(7, 17, 25, 0.48);
  box-shadow:
    0 2px 0 rgba(0, 0, 0, 0.35),
    0 0 16px rgba(96, 255, 128, 0.14);
  pointer-events: none;
  transition: filter 120ms ease, transform 120ms ease;
}

.egg-health-label {
  color: #ecfff0;
  font-size: clamp(0.58rem, 1.6vw, 0.72rem);
  font-weight: 1000;
  letter-spacing: 0;
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.72),
    0 0 8px rgba(118, 255, 156, 0.32);
}

.egg-health-frame {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(10px, 2.1vw, 15px);
  min-width: 86px;
  overflow: hidden;
  border: 2px solid rgba(9, 16, 18, 0.92);
  border-radius: 3px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, rgba(20, 28, 29, 0.96), rgba(4, 9, 11, 0.96));
}

.egg-health-fill {
  display: block;
  width: 100%;
  height: 100%;
  background:
    linear-gradient(180deg, rgba(242, 255, 214, 0.96) 0 16%, rgba(90, 232, 88, 0.98) 18% 62%, rgba(18, 145, 46, 1) 64%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.24) 0 2px, transparent 2px 10px);
  box-shadow:
    0 0 10px rgba(89, 255, 104, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.46);
  transition: width 150ms ease;
}

.egg-health-hud.egg-health-hit {
  filter: brightness(1.35) saturate(1.25);
  transform: translateX(2px);
}

.egg-health-hud.egg-health-hit .egg-health-fill {
  background:
    linear-gradient(180deg, rgba(255, 245, 211, 1) 0 16%, rgba(255, 102, 86, 0.98) 18% 58%, rgba(179, 27, 45, 1) 60%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.28) 0 2px, transparent 2px 10px);
  box-shadow:
    0 0 14px rgba(255, 91, 91, 0.68),
    inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.egg-health-hud.egg-health-low {
  box-shadow:
    0 2px 0 rgba(0, 0, 0, 0.35),
    0 0 18px rgba(255, 80, 104, 0.3);
}

.fps-counter {
  position: absolute;
  top: max(4px, calc(env(safe-area-inset-top) + 4px));
  right: max(12px, env(safe-area-inset-right));
  z-index: 36;
  min-width: 38px;
  padding: 2px 4px 3px;
  border-radius: 3px;
  background: rgba(5, 13, 22, 0.28);
  color: rgba(226, 252, 255, 0.76);
  font-size: 0.56rem;
  font-weight: 900;
  line-height: 0.92;
  text-align: right;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
  white-space: pre-line;
  pointer-events: none;
}

.fps-counter.fps-drop {
  background: rgba(62, 8, 15, 0.48);
  color: rgba(255, 214, 214, 0.95);
  box-shadow: 0 0 10px rgba(255, 52, 82, 0.42);
}

.viewport-controls,
.keyboard-sound-controls,
.instrument-style-controls {
  justify-self: center;
  min-width: 0;
  display: grid;
  grid-template-columns: 42px 72px 42px;
  align-items: center;
  gap: 8px;
  margin: calc(var(--row-tight-offset) / 2) 18px var(--row-space);
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(9, 14, 22, 0.72);
}

.viewport-controls {
  grid-template-columns: 42px 72px 42px;
  margin: calc(var(--row-tight-offset) / 3) 18px var(--row-space);
}

.keyboard-sound-controls {
  grid-template-columns: 42px 120px 42px;
  margin-top: calc(var(--row-tight-offset) / 3);
}

.instrument-style-controls {
  grid-template-columns: 42px 156px 42px;
  margin-top: var(--row-tight-offset);
}

.instrument-style-controls.hidden {
  display: none;
}

.instrument-eq-controls {
  justify-self: center;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(38px, 1fr));
  gap: var(--row-gap);
  width: min(440px, calc(100vw - 24px));
  margin: var(--row-tight-offset) 18px var(--row-space);
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(9, 14, 22, 0.72);
  overscroll-behavior: contain;
}

.instrument-eq-controls label,
.eq-fx-control {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 4px;
  color: #dfffea;
  font-size: 0.62rem;
  font-weight: 900;
  text-transform: uppercase;
}

.instrument-eq-controls input[type="range"] {
  width: 42px;
  height: 42px;
  margin: 0;
  accent-color: #6ee7b7;
  transform: rotate(-90deg);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.instrument-eq-controls strong {
  color: #f8fafc;
  font-size: 0.58rem;
  font-variant-numeric: tabular-nums;
}

.mobile-boost-btn {
  grid-column: 1 / -1;
  height: 34px;
  border: 1px solid rgba(110, 231, 183, 0.32);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.86);
  color: #dfffea;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.mobile-boost-btn.active {
  border-color: rgba(250, 204, 21, 0.8);
  background: rgba(146, 64, 14, 0.82);
  color: #fff7ad;
}

.viewport-controls button,
.keyboard-sound-controls button,
.instrument-style-controls button {
  height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
}

.viewport-controls strong,
.keyboard-sound-controls strong,
.instrument-style-controls strong {
  color: #dfffea;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sound-play-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  width: auto;
  transform: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  justify-items: stretch;
  padding: 10px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.sound-play-panel::before {
  display: none;
}

.nugget-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  overflow: hidden;
}

.foreground-nugget {
  position: absolute;
  width: 16px;
  height: 13px;
  border: 2px solid rgba(71, 42, 0, 0.58);
  border-radius: 5px;
  background: linear-gradient(135deg, #fff0a8, #f6b72d 58%, #b97813);
  box-shadow: 0 0 10px rgba(255, 211, 74, 0.28);
}

.foreground-energy {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, #ffe1da 0 14%, #ff5a48 24% 58%, #a91422 70% 100%);
  box-shadow:
    0 0 14px rgba(255, 36, 36, 0.58),
    0 0 30px rgba(255, 70, 40, 0.22);
  pointer-events: none;
}

.foreground-twin-spark {
  position: absolute;
  z-index: 1;
  width: var(--spark-size, 7px);
  height: var(--spark-size, 7px);
  border-radius: 999px;
  background:
    radial-gradient(circle at 34% 28%, var(--spark-core, #fff) 0 16%, var(--spark-color, #f6c8ff) 34% 66%, transparent 78%);
  box-shadow:
    0 0 8px var(--spark-color, rgba(230, 170, 255, 0.8)),
    0 0 18px var(--spark-glow, rgba(210, 110, 255, 0.42));
  pointer-events: none;
  animation: twinDischargeSpark var(--spark-duration, 980ms) cubic-bezier(0.18, 0.62, 0.24, 1) forwards;
  will-change: transform, opacity;
}

.falling-music-note {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 7;
  display: block;
  height: var(--falling-note-height, 64px);
  border: 2px solid rgba(238, 253, 255, 0.9);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(200, 244, 255, 0.88) 42%, rgba(124, 218, 255, 0.58)),
    radial-gradient(circle at 50% 12%, #ffffff, transparent 22%);
  box-shadow:
    0 0 18px rgba(202, 248, 255, 0.68),
    0 0 32px rgba(124, 218, 255, 0.3),
    inset 0 0 16px rgba(255, 255, 255, 0.56);
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  contain: layout paint style;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.falling-music-note::before,
.falling-music-note::after,
.falling-music-note span {
  position: absolute;
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 0 12px rgba(218, 248, 255, 0.9);
  content: "";
}

.falling-music-note::before {
  left: 50%;
  top: 7px;
  transform: translateX(-50%);
}

.falling-music-note::after {
  left: 45%;
  bottom: 8px;
}

.falling-music-note span:nth-child(1) {
  left: 18%;
  top: 24%;
  width: 5px;
  height: 5px;
}

.falling-music-note span:nth-child(2) {
  right: 20%;
  top: 36%;
  width: 6px;
  height: 6px;
}

.falling-music-note span:nth-child(3) {
  left: 32%;
  top: 52%;
  width: 4px;
  height: 4px;
}

.falling-music-note span:nth-child(4) {
  right: 28%;
  top: 68%;
  width: 5px;
  height: 5px;
}

.falling-music-note span:nth-child(5) {
  left: 56%;
  top: 82%;
  width: 4px;
  height: 4px;
}

.falling-music-note.hit {
  filter: brightness(1.3);
  box-shadow:
    0 0 18px rgba(255, 255, 255, 0.64),
    0 0 34px rgba(125, 222, 255, 0.42),
    inset 0 0 14px rgba(255, 255, 255, 0.48);
}

.falling-music-note.correct {
  border-color: rgba(155, 255, 164, 0.82);
  background:
    linear-gradient(180deg, rgba(244, 255, 236, 0.98), rgba(128, 255, 142, 0.68) 42%, rgba(31, 185, 88, 0.36)),
    radial-gradient(circle at 50% 12%, rgba(255, 255, 255, 0.98), transparent 20%);
  box-shadow:
    0 0 18px rgba(127, 255, 146, 0.78),
    0 0 34px rgba(49, 222, 104, 0.42),
    inset 0 0 16px rgba(255, 255, 255, 0.5);
  animation: fallingNoteCorrectFlash 420ms ease-out;
}

.falling-music-note.ice-note {
  border-color: rgba(210, 246, 255, 0.98);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(163, 232, 255, 0.82) 42%, rgba(62, 154, 226, 0.52)),
    radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 1), transparent 24%);
  box-shadow:
    0 0 22px rgba(185, 240, 255, 0.86),
    0 0 44px rgba(91, 192, 255, 0.46),
    inset 0 0 16px rgba(255, 255, 255, 0.62);
}

.falling-music-note.hit.correct {
  outline: 2px solid rgba(234, 255, 238, 0.78);
  outline-offset: 2px;
  animation:
    fallingNoteHitConfirm 760ms ease-out,
    fallingNoteCorrectFlash 480ms ease-out;
}

.falling-music-note.score-good {
  border-color: rgba(172, 255, 116, 0.95);
  box-shadow:
    0 0 22px rgba(162, 255, 126, 0.82),
    0 0 46px rgba(49, 222, 104, 0.52),
    inset 0 0 18px rgba(255, 255, 255, 0.58);
}

.falling-music-note.score-early {
  border-color: rgba(255, 205, 102, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 242, 0.98), rgba(255, 214, 128, 0.7) 42%, rgba(255, 139, 63, 0.34)),
    radial-gradient(circle at 50% 12%, #ffffff, transparent 22%);
  box-shadow:
    0 0 18px rgba(255, 207, 102, 0.68),
    0 0 34px rgba(255, 142, 68, 0.32),
    inset 0 0 16px rgba(255, 255, 255, 0.48);
}

.falling-music-note.score-perfect {
  border-color: rgba(252, 255, 171, 1);
  background:
    linear-gradient(180deg, rgba(255, 255, 236, 1), rgba(178, 255, 122, 0.82) 36%, rgba(22, 214, 116, 0.52)),
    radial-gradient(circle at 50% 12%, #ffffff, transparent 22%);
  box-shadow:
    0 0 34px rgba(255, 249, 142, 1),
    0 0 72px rgba(92, 255, 132, 0.76),
    0 0 104px rgba(255, 255, 255, 0.32),
    inset 0 0 22px rgba(255, 255, 255, 0.68);
}

.falling-music-note.correct::before,
.falling-music-note.correct::after,
.falling-music-note.correct span {
  background: rgba(235, 255, 232, 0.98);
  box-shadow: 0 0 10px rgba(156, 255, 164, 0.78);
}

.falling-music-note.released-early {
  border-color: rgba(255, 192, 92, 0.68);
  filter: saturate(0.72) brightness(0.9);
  box-shadow:
    0 0 12px rgba(255, 173, 71, 0.3),
    inset 0 0 12px rgba(255, 255, 255, 0.22);
}

.falling-music-note.released-long {
  border-color: rgba(255, 141, 70, 0.92);
  filter: saturate(0.9) brightness(0.96);
  box-shadow:
    0 0 16px rgba(255, 137, 76, 0.52),
    0 0 30px rgba(255, 88, 84, 0.26),
    inset 0 0 14px rgba(255, 244, 220, 0.34);
}

.falling-music-note.missed {
  border-color: rgba(255, 120, 140, 0.42);
  filter: saturate(0.45) brightness(0.82);
}

.falling-score-popup {
  position: absolute;
  z-index: 9;
  color: #f8fff1;
  font-size: 0.78rem;
  font-weight: 1000;
  letter-spacing: 0;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.45),
    0 0 12px rgba(255, 255, 255, 0.36);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: fallingScorePopup 720ms cubic-bezier(0.18, 0.72, 0.24, 1) forwards;
}

.falling-score-popup.score-ok {
  color: #dfffea;
}

.falling-score-popup.score-early {
  color: #ffc966;
  font-size: 0.9rem;
}

.falling-score-popup.score-good {
  color: #b9ff7a;
}

.falling-score-popup.score-perfect {
  color: #fff68f;
  font-size: 1.02rem;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.54),
    0 0 16px rgba(255, 248, 137, 0.78),
    0 0 30px rgba(126, 255, 142, 0.42);
}

.falling-score-popup.score-long {
  color: #ffad61;
  font-size: 0.96rem;
}

.falling-score-popup.score-miss {
  color: #ff8a9a;
  font-size: 0.98rem;
}

.falling-score-popup.score-popup-hidden {
  opacity: 0;
}

html.touch-playfield .falling-music-note {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(166, 231, 255, 0.78) 46%, rgba(77, 172, 230, 0.5));
  box-shadow:
    0 0 10px rgba(202, 248, 255, 0.48),
    inset 0 0 10px rgba(255, 255, 255, 0.48);
}

html.touch-playfield .falling-music-note.hit,
html.touch-playfield .falling-music-note.correct,
html.touch-playfield .falling-music-note.hit.correct,
html.touch-playfield .falling-music-note.mobile-hit {
  outline: 0;
  animation: none;
  filter: brightness(1.08) saturate(1.08);
  background: linear-gradient(180deg, rgba(246, 255, 239, 0.98), rgba(142, 255, 151, 0.72) 46%, rgba(35, 181, 94, 0.38));
  box-shadow:
    0 0 12px rgba(142, 255, 158, 0.62),
    inset 0 0 10px rgba(255, 255, 255, 0.48);
}

html.touch-playfield .falling-music-note.score-perfect,
html.touch-playfield .falling-music-note.score-good,
html.touch-playfield .falling-music-note.mobile-hit.score-perfect,
html.touch-playfield .falling-music-note.mobile-hit.score-good {
  animation: none;
  filter: brightness(1.12) saturate(1.12);
  background: linear-gradient(180deg, rgba(255, 255, 221, 0.98), rgba(179, 255, 122, 0.76) 44%, rgba(26, 200, 106, 0.44));
  box-shadow:
    0 0 16px rgba(183, 255, 126, 0.68),
    0 0 28px rgba(49, 222, 104, 0.34),
    inset 0 0 12px rgba(255, 255, 255, 0.52);
}

html.touch-playfield .falling-music-note::before,
html.touch-playfield .falling-music-note::after,
html.touch-playfield .falling-music-note span {
  box-shadow: 0 0 7px rgba(218, 248, 255, 0.72);
}

html.touch-playfield .falling-score-popup {
  animation: none;
  opacity: 1;
  transform: translate(-50%, -86%) scale(1);
  transition: opacity 180ms ease-out;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.42),
    0 0 10px rgba(255, 255, 255, 0.28);
}

@keyframes fallingScorePopup {
  0% {
    opacity: 0;
    transform: translate(-50%, -35%) scale(0.82);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -62%) scale(1.08);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -130%) scale(0.95);
  }
}

@keyframes fallingNoteCorrectFlash {
  0% {
    filter: brightness(2.1) saturate(1.35);
  }

  100% {
    filter: brightness(1) saturate(1);
  }
}

@keyframes fallingNoteHitConfirm {
  0% {
    outline-color: rgba(255, 255, 255, 0.98);
    outline-offset: 8px;
    filter: brightness(2.35) saturate(1.55);
  }

  45% {
    outline-color: rgba(185, 255, 193, 0.86);
    outline-offset: 3px;
    filter: brightness(1.55) saturate(1.28);
  }

  100% {
    outline-color: rgba(185, 255, 193, 0);
    outline-offset: 0;
    filter: brightness(1.08) saturate(1.08);
  }
}

.pixel-bird-button {
  position: absolute;
  top: max(30px, calc(env(safe-area-inset-top) + 30px));
  right: max(12px, env(safe-area-inset-right));
  z-index: 34;
  width: 42px;
  height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pixel-bird {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: 28px;
  height: 22px;
  image-rendering: pixelated;
  transform: translate(-50%, -50%);
  filter:
    drop-shadow(0 2px 0 rgba(13, 26, 38, 0.5))
    drop-shadow(0 0 4px rgba(173, 232, 255, 0.36));
}

.pixel-bird i {
  position: absolute;
  display: block;
  pointer-events: none;
}

.bird-body {
  left: 4px;
  top: 7px;
  width: 17px;
  height: 11px;
  background:
    linear-gradient(180deg, #7bd6ff 0 36%, #2b93d1 37% 72%, #17608f 73% 100%);
  box-shadow:
    0 -4px 0 -1px #b8f1ff,
    4px -5px 0 -2px #7bd6ff,
    -2px 4px 0 -1px #0d3f63;
}

.bird-wing {
  left: 7px;
  top: 12px;
  width: 9px;
  height: 7px;
  background:
    linear-gradient(180deg, #2f7db6 0 45%, #0d4f7c 46% 100%);
  box-shadow: -2px 2px 0 #083650;
}

.bird-eye {
  left: 17px;
  top: 6px;
  width: 4px;
  height: 4px;
  background: #111827;
  box-shadow: 1px 1px 0 #e9fbff;
}

.bird-beak {
  left: 22px;
  width: 7px;
  height: 4px;
  background: #facc15;
  transform-origin: 0 50%;
  transition: transform 80ms steps(2, end), top 80ms steps(2, end);
}

.bird-beak-top {
  top: 10px;
  box-shadow: 2px 0 0 #d97706;
}

.bird-beak-bottom {
  top: 14px;
  background: #f59e0b;
  box-shadow: 2px 0 0 #92400e;
}

.pixel-bird-button.beak-open .bird-beak-top,
.pixel-bird-button:active .bird-beak-top {
  top: 8px;
  transform: rotate(-18deg);
}

.pixel-bird-button.beak-open .bird-beak-bottom,
.pixel-bird-button:active .bird-beak-bottom {
  top: 16px;
  transform: rotate(18deg);
}

.pixel-bird-button.beak-open .pixel-bird,
.pixel-bird-button:active .pixel-bird {
  transform: translate(-50%, -50%) translateY(1px);
}

.drum-energy-branch {
  --branch-energy-fill: 0;
  --branch-excite-glow: 0;
  position: relative;
  z-index: 18;
  justify-self: stretch;
  width: 100%;
  height: 32px;
  margin: 2px 0 0;
  pointer-events: none;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.24));
}

.drum-energy-branch::before,
.drum-energy-branch::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  top: 0;
  height: 36px;
  border: 1px solid rgba(35, 17, 7, 0.86);
  border-radius: 10px 10px 2px 2px;
  background:
    radial-gradient(circle at 14% 52%, rgba(92, 49, 19, 0.36) 0 6%, transparent 7%),
    radial-gradient(circle at 84% 44%, rgba(78, 38, 14, 0.3) 0 5%, transparent 6%),
    linear-gradient(90deg, rgba(34, 15, 6, 0.38), transparent 18% 82%, rgba(25, 11, 5, 0.34)),
    linear-gradient(180deg, #8a542a 0 17%, #643117 18% 64%, #341607 65% 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 214, 130, 0.2),
    inset 0 -4px 0 rgba(20, 8, 4, 0.34),
    0 1px 0 rgba(18, 9, 5, 0.52);
}

.drum-energy-branch::after {
  left: 16px;
  right: 16px;
  top: 16px;
  height: 2px;
  border: 0;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 211, 118, 0.2) 0 18px, rgba(43, 18, 7, 0.16) 18px 28px);
  box-shadow: none;
  opacity: 0.72;
}

.branch-knot {
  position: absolute;
  top: 10px;
  z-index: 2;
  width: 14px;
  height: 10px;
  border: 2px solid rgba(49, 23, 8, 0.76);
  border-radius: 50%;
  background:
    radial-gradient(circle at 44% 44%, #40200d 0 24%, #7a3e1a 25% 46%, #c27a37 47% 100%);
  box-shadow:
    inset 1px 2px 0 rgba(255, 210, 120, 0.24),
    0 0 0 1px rgba(20, 9, 4, 0.22);
}

.branch-knot-left {
  left: 7%;
  transform: rotate(-8deg);
}

.branch-knot-right {
  right: 7%;
  transform: rotate(10deg) scale(0.88);
}

.branch-energy-meter {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  display: block;
  width: min(430px, 76%);
  height: 20px;
  overflow: hidden;
  border: 1px solid rgba(32, 15, 6, 0.9);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(29, 13, 5, 0.92), rgba(8, 5, 3, 0.92));
  box-shadow:
    inset 0 0 5px rgba(0, 0, 0, 0.72),
    0 0 calc(4px + var(--branch-excite-glow) * 14px) rgba(215, 122, 255, calc(0.07 + var(--branch-excite-glow) * 0.36));
  transform: translate(-50%, -50%);
}

.branch-energy-fill {
  position: absolute;
  inset: -1px;
  display: block;
  width: calc(100% + 2px);
  border-radius: 999px;
  background:
    linear-gradient(90deg, #ff3d28 0%, #ff9d30 38%, #ffe25a 72%, #fff7c9 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.38),
    0 0 8px rgba(255, 91, 38, 0.62),
    0 0 14px rgba(255, 205, 76, 0.38);
  transform: scaleX(var(--branch-energy-fill, 0));
  transform-origin: 0 50%;
  transition: transform 150ms ease-out, background 520ms ease, box-shadow 520ms ease;
}

.branch-combo-label {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: rgba(255, 249, 216, 0.96);
  font-family: "Segoe UI Black", "Arial Black", "Trebuchet MS", system-ui, sans-serif;
  font-size: clamp(0.68rem, 2.35vw, 0.86rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  letter-spacing: 0.035em;
  text-shadow:
    0 1px 0 rgba(45, 17, 7, 0.98),
    0 0 4px rgba(0, 0, 0, 0.88),
    0 0 8px rgba(255, 202, 82, 0.34);
  white-space: nowrap;
}

.drum-energy-branch.branch-energy-full .branch-energy-fill {
  background:
    linear-gradient(90deg, #8f4dff 0%, #cf72ff 40%, #f3c8ff 74%, #ffffff 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.58),
    0 0 11px rgba(186, 105, 255, 0.78),
    0 0 20px rgba(231, 178, 255, 0.62);
}

.drum-energy-branch.branch-energy-neon .branch-energy-meter {
  box-shadow:
    inset 0 0 5px rgba(255, 255, 255, 0.34),
    0 0 16px rgba(255, 250, 255, 0.82),
    0 0 30px rgba(212, 103, 255, 0.68);
}

.drum-energy-branch.branch-energy-neon .branch-energy-fill {
  animation: branchEnergyNeonPulse 420ms ease-in-out infinite alternate;
  background:
    radial-gradient(circle at 86% 50%, #ffffff 0 13%, rgba(255, 255, 255, 0) 31%),
    linear-gradient(90deg, #8f4dff 0%, #d075ff 46%, #fff9ff 100%);
}

.drum-energy-branch.branch-energy-neon .branch-combo-label {
  color: #ffffff;
  text-shadow:
    0 1px 0 rgba(45, 17, 7, 0.98),
    0 0 5px rgba(255, 255, 255, 0.94),
    0 0 12px rgba(219, 119, 255, 0.72);
}

.pixel-drums {
  position: relative;
  z-index: auto;
  justify-self: center;
  display: grid;
  grid-template-columns: 70px 104px 70px 70px;
  align-items: end;
  justify-content: space-between;
  gap: 0;
  width: min(340px, 92%);
  min-height: 186px;
  margin-bottom: -18px;
  padding-top: 2px;
  transform: none;
}

.drum-pad {
  position: relative;
  display: grid;
  place-items: center;
  justify-self: center;
  border: 3px solid #101721;
  border-radius: 0;
  background:
    linear-gradient(180deg, #fbf0c0 0 18%, #d2934e 18% 70%, #8f5336 70% 100%);
  box-shadow:
    inset 0 0 0 4px rgba(255, 255, 255, 0.12),
    0 3px 0 rgba(74, 44, 37, 0.42);
  cursor: pointer;
  touch-action: manipulation;
  overflow: hidden;
}

.drum-pad::before {
  content: "";
  position: absolute;
  inset: -14px;
  background: transparent;
}

.drum-pad span {
  width: 52%;
  height: 38%;
  border: 3px solid rgba(69, 40, 34, 0.78);
  background: rgba(255, 246, 205, 0.7);
}

.drum-large::before {
  inset: -8px -12px -10px;
}

.drum-medium::before {
  inset: -16px -8px -16px -4px;
}

.drum-twin::before {
  inset: -10px -8px -12px;
}

.drum-pad span {
  position: relative;
  z-index: 1;
}

.drum-large {
  z-index: 12;
  width: 143px;
  height: 145px;
  margin: 0 -34px 0 7px;
  border: 0;
  background: transparent;
  box-shadow: none;
  image-rendering: pixelated;
  overflow: hidden;
  transform: translateY(-8px);
}

.drum-large span {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background-color: transparent;
  background-image: url("./assets/SpriteBruderImpact.png");
  background-size: 400% 100%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
  transition: transform 44ms ease-out;
  will-change: opacity, transform;
}

.drum-large .bruder-idle {
  background-position: 0 50%;
  opacity: 1;
}

.drum-large .bruder-pre-frame {
  background-position: 33.333% 50%;
  opacity: 0;
  transform: scale(0.995);
}

.drum-large .bruder-hit {
  background-position: 66.666% 50%;
  opacity: 0;
  transform: scale(1.015);
}

.drum-large .bruder-after-frame {
  background-position: 100% 50%;
  opacity: 0;
  transform: scale(1);
}

.drum-large::after {
  display: none;
}

.drum-large.bruder-pre .bruder-idle,
.drum-large.bruder-hit-peak .bruder-idle,
.drum-large.bruder-after .bruder-idle {
  opacity: 0;
}

.drum-large.bruder-pre .bruder-pre-frame {
  opacity: 1;
  transform: scale(1);
}

.drum-large.bruder-hit-peak .bruder-hit {
  opacity: 1;
  transform: scale(1.02);
}

.drum-large.bruder-after .bruder-after-frame {
  opacity: 1;
  transform: scale(1);
}

.drum-twin {
  --twin-direction: -1;
  --twin-y: -10px;
  --twin-meter-x: 51%;
  --twin-float-lift: 5px;
  --twin-float-duration: 2.9s;
  --twin-excite-glow: 0;
  --twin-charge-scale: 1;
  z-index: 32;
  width: 77px;
  height: 167px;
  margin: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  image-rendering: pixelated;
  overflow: visible;
  scale: var(--twin-charge-scale);
  transform-origin: 50% 62%;
  animation: twinIdleFloat var(--twin-float-duration) cubic-bezier(0.45, 0, 0.2, 1) infinite;
  transition: scale 260ms ease-out, filter 120ms ease-out, --twin-float-lift 320ms ease-out;
  will-change: transform;
}

.drum-twin-left {
  justify-self: start;
  margin-right: -8px;
}

.drum-twin-right {
  --twin-direction: 1;
  --twin-meter-x: 49%;
  justify-self: end;
  margin-left: -8px;
  animation-delay: -1.65s;
}

.twin-energy-meter {
  position: absolute;
  left: var(--twin-meter-x);
  top: 52%;
  z-index: 0;
  display: block;
  width: 16px;
  height: 54px;
  box-sizing: border-box;
  overflow: hidden;
  border: 2px solid rgba(62, 35, 12, 0.72);
  border-radius: 4px 4px 3px 3px;
  background:
    linear-gradient(180deg, rgba(24, 12, 4, 0.72), rgba(8, 5, 3, 0.82));
  box-shadow:
    inset 0 0 5px rgba(0, 0, 0, 0.58),
    0 0 7px rgba(255, 215, 96, 0.24);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.twin-energy-fill {
  position: absolute;
  inset: -1px 0 -1px;
  display: block;
  height: calc(100% + 2px);
  border-radius: 2px 2px 2px 2px;
  background:
    linear-gradient(180deg, #fff7c9 0%, #ffe25a 22%, #ff9d30 58%, #ff3d28 100%);
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.34),
    0 0 7px rgba(255, 91, 38, 0.76),
    0 0 13px rgba(255, 180, 44, 0.52);
  transform: scaleY(var(--twin-energy-fill, 0));
  transform-origin: 50% 100%;
  transition: transform 150ms ease-out, background 520ms ease, box-shadow 520ms ease;
}

.twin-energy-meter::after {
  content: "";
  position: absolute;
  inset: 4px 2px 7px;
  z-index: 2;
  display: block;
  border-radius: 2px;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 43%, rgba(255, 255, 255, 0.98), rgba(255, 244, 255, 0.72) 24%, rgba(216, 120, 255, 0.22) 54%, transparent 72%);
  mix-blend-mode: screen;
  transition: opacity 260ms ease;
}

.drum-twin.twin-energy-full .twin-energy-fill {
  background:
    linear-gradient(180deg, #ffffff 0%, #f7d7ff 28%, #d89dff 62%, #9c5cff 100%);
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.48),
    0 0 10px rgba(185, 104, 255, 0.74),
    0 0 18px rgba(225, 160, 255, 0.78);
}

.drum-twin.twin-energy-neon .twin-energy-fill {
  animation: twinEnergyNeonPulse 420ms ease-in-out infinite alternate;
  background:
    radial-gradient(circle at 50% 34%, #ffffff 0%, #ffffff 17%, rgba(255, 255, 255, 0) 38%),
    linear-gradient(180deg, #ffffff 0%, #fff9ff 22%, #f3c8ff 47%, #cf72ff 78%, #8f4dff 100%);
}

.drum-twin.twin-energy-neon .twin-energy-meter {
  background:
    linear-gradient(180deg, rgba(70, 42, 82, 0.72), rgba(16, 6, 24, 0.82));
  box-shadow:
    inset 0 0 4px rgba(255, 255, 255, 0.38),
    inset 0 0 12px rgba(255, 248, 255, 0.58),
    0 0 18px rgba(255, 250, 255, 0.98),
    0 0 34px rgba(214, 112, 255, 0.84),
    0 0 52px rgba(255, 218, 87, 0.5);
}

.drum-twin.twin-energy-neon .twin-energy-meter::after {
  opacity: 0.95;
  animation: twinEnergyCorePulse 420ms ease-in-out infinite alternate;
}

.drum-twin.twin-energy-full span {
  filter:
    drop-shadow(0 0 5px rgba(248, 211, 255, 0.58))
    drop-shadow(0 0 12px rgba(180, 112, 255, 0.34));
}

.drum-twin.twin-energy-neon span {
  filter:
    brightness(1.08)
    drop-shadow(0 0 8px rgba(255, 250, 255, 0.82))
    drop-shadow(0 0 18px rgba(202, 103, 255, 0.62))
    drop-shadow(0 0 28px rgba(255, 218, 90, 0.34));
}

.drum-twin.twin-energy-active::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 49%;
  z-index: 0;
  width: 5px;
  height: 5px;
  border-radius: 1px;
  pointer-events: none;
  opacity: calc(0.34 + var(--twin-excite-glow) * 0.66);
  background: rgba(255, 247, 196, 0.96);
  box-shadow:
    -23px -24px 0 rgba(255, 226, 96, 0.72),
    24px -21px 0 rgba(248, 210, 255, 0.68),
    -20px 26px 0 rgba(255, 149, 58, 0.58),
    20px 28px 0 rgba(215, 132, 255, 0.62),
    -4px -34px 0 rgba(255, 255, 255, 0.68),
    4px 36px 0 rgba(255, 225, 95, 0.54),
    0 0 18px rgba(255, 235, 125, 0.88),
    0 0 32px rgba(205, 112, 255, 0.38);
  transform: translate(-50%, -50%) scale(calc(0.85 + var(--twin-excite-glow) * 0.95));
  animation: twinSparkFlicker 700ms steps(2, end) infinite;
}

.drum-twin span {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background-color: transparent;
  background-image: url("./assets/SpriteTwinImpact.png");
  background-size: 400% 100%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
  translate: 0 0;
  scale: 1;
  transition: transform 44ms ease-out;
  transform-origin: center bottom;
  will-change: opacity, transform;
}

.drum-twin.twin-input-hit span {
  animation: twinInputHit 150ms cubic-bezier(0.2, 0.85, 0.25, 1);
}

.drum-twin .twin-idle {
  background-position: 0 50%;
  opacity: 1;
  transform: scaleX(var(--twin-direction)) scale(1);
}

.drum-twin .twin-pre-frame {
  background-position: 33.333% 50%;
  opacity: 0;
  transform: scaleX(var(--twin-direction)) scale(0.995);
}

.drum-twin .twin-hit {
  background-position: 66.666% 50%;
  opacity: 0;
  transform: scaleX(var(--twin-direction)) scale(1.015);
}

.drum-twin .twin-after-frame {
  background-position: 100% 50%;
  opacity: 0;
  transform: scaleX(var(--twin-direction)) scale(1);
}

.drum-twin.twin-pre .twin-idle,
.drum-twin.twin-hit-peak .twin-idle,
.drum-twin.twin-after .twin-idle {
  opacity: 0;
}

.drum-twin.twin-pre .twin-pre-frame {
  opacity: 1;
  transform: scaleX(var(--twin-direction)) scale(1);
}

.drum-twin.twin-hit-peak .twin-hit {
  opacity: 1;
  transform: scaleX(var(--twin-direction)) scale(1.025);
}

.drum-twin.twin-after .twin-after-frame {
  opacity: 1;
  transform: scaleX(var(--twin-direction)) scale(1);
}

.drum-medium {
  z-index: 13;
  width: 74px;
  height: 103px;
  margin: 0 0 0 -54px;
  border: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  transform: translate(-8px, -8px);
}

.drum-medium span {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100px;
  height: 100%;
  border: 0;
  background-color: transparent;
  background-image: url("./assets/SpriteSisterImpact.png");
  background-size: 400% 100%;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
  transition: transform 44ms ease-out;
  will-change: opacity, transform;
}

.drum-medium .sister-idle {
  background-position: 0 50%;
  opacity: 1;
}

.drum-medium .sister-pre-frame {
  background-position: 33.333% 50%;
  opacity: 0;
  transform: scale(0.995);
}

.drum-medium .sister-hit {
  background-position: 66.666% 50%;
  opacity: 0;
  transform: scale(1.015);
}

.drum-medium .sister-after-frame {
  background-position: 100% 50%;
  opacity: 0;
  transform: scale(1);
}

.drum-medium.sister-pre .sister-idle,
.drum-medium.sister-hit-peak .sister-idle,
.drum-medium.sister-after .sister-idle {
  opacity: 0;
}

.drum-medium.sister-pre .sister-pre-frame {
  opacity: 1;
  transform: scale(1);
}

.drum-medium.sister-hit-peak .sister-hit {
  opacity: 1;
  transform: scale(1.025);
}

.drum-medium.sister-after .sister-after-frame {
  opacity: 1;
  transform: scale(1);
}

.drum-medium::after {
  display: none;
}

.drum-pad:not(.drum-twin):not(.drum-large):not(.drum-medium):active,
.drum-pad:not(.drum-twin):not(.drum-large):not(.drum-medium).playing {
  transform: translateY(4px);
  box-shadow:
    inset 0 0 0 4px rgba(255, 255, 255, 0.18),
    0 1px 0 rgba(74, 44, 37, 0.32);
}

.drum-medium.playing {
  transform: translate(-8px, -8px);
  filter: brightness(1.15) saturate(1.12);
  box-shadow: none;
  outline: 0;
}

.drum-twin:active,
.drum-twin.playing {
  filter: brightness(1.15) saturate(1.12);
  box-shadow: none;
  outline: 0;
}

@keyframes twinIdleFloat {
  0% {
    transform: translate(0, var(--twin-y)) rotate(0deg);
  }

  16% {
    transform: translate(1px, calc(var(--twin-y) - var(--twin-float-lift) * 0.45)) rotate(-0.35deg);
  }

  33% {
    transform: translate(-1px, calc(var(--twin-y) - var(--twin-float-lift) * 1.08)) rotate(0.28deg);
  }

  52% {
    transform: translate(2px, calc(var(--twin-y) - var(--twin-float-lift) * 0.62)) rotate(-0.18deg);
  }

  72% {
    transform: translate(-2px, calc(var(--twin-y) - var(--twin-float-lift) * 1.22)) rotate(0.42deg);
  }

  100% {
    transform: translate(0, var(--twin-y)) rotate(0deg);
  }
}

@keyframes twinInputHit {
  0% {
    translate: 0 0;
    scale: 1;
  }

  34% {
    translate: 0 1.25px;
    scale: 1.018 0.992;
  }

  68% {
    translate: 0 -0.5px;
    scale: 0.996 1.008;
  }

  100% {
    translate: 0 0;
    scale: 1;
  }
}

@keyframes twinSparkFlicker {
  0%,
  100% {
    opacity: calc(0.18 + var(--twin-excite-glow) * 0.58);
  }

  50% {
    opacity: calc(0.32 + var(--twin-excite-glow) * 0.68);
  }
}

@keyframes twinEnergyNeonPulse {
  0% {
    filter: brightness(1.22) saturate(1.18);
    box-shadow:
      inset 0 4px 0 rgba(255, 255, 255, 0.62),
      0 0 18px rgba(255, 255, 255, 0.82),
      0 0 26px rgba(225, 160, 255, 0.86);
  }

  100% {
    filter: brightness(2.05) saturate(1.55);
    box-shadow:
      inset 0 4px 0 rgba(255, 255, 255, 0.9),
      inset 0 0 10px rgba(255, 255, 255, 0.82),
      0 0 24px rgba(255, 245, 255, 0.95),
      0 0 42px rgba(220, 118, 255, 0.86);
  }
}

@keyframes twinEnergyCorePulse {
  0% {
    transform: scale(0.88);
    opacity: 0.72;
  }

  100% {
    transform: scale(1.12);
    opacity: 1;
  }
}

@keyframes branchEnergyNeonPulse {
  from {
    filter: brightness(1.08) saturate(1.12);
  }
  to {
    filter: brightness(1.48) saturate(1.35);
  }
}

@keyframes twinDischargeSpark {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(0, 0) scale(0.45);
  }

  12% {
    opacity: 1;
    transform: translate(-50%, -50%) translate(var(--spark-mid-x), var(--spark-mid-y)) scale(1);
  }

  64% {
    opacity: 0.82;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--spark-dx), var(--spark-dy)) scale(0.18);
  }
}

.drum-large.playing {
  transform: translateY(-8px);
  filter: brightness(1.15) saturate(1.12);
  box-shadow: none;
  outline: 0;
}

.drum-large:focus,
.drum-large:focus-visible,
.drum-medium:focus,
.drum-medium:focus-visible,
.drum-twin:focus,
.drum-twin:focus-visible {
  outline: 0;
  box-shadow: none;
}

.pixel-piano {
  --white-key-width: calc(100% / 7);
  --black-key-width: clamp(18px, 7.4vw, 28px);
  position: relative;
  z-index: 24;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: 100%;
  gap: 0;
  margin: 0;
  touch-action: none;
}

.piano-black-key {
  display: none;
}

.piano-black-key-cs {
  --black-key-index: 1;
}

.piano-black-key-ds {
  --black-key-index: 2;
}

.piano-black-key-fs {
  --black-key-index: 4;
}

.piano-black-key-gs {
  --black-key-index: 5;
}

.piano-black-key-as {
  --black-key-index: 6;
}

.piano-key {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: end center;
  width: 100%;
  min-width: 0;
  height: 78px;
  padding: 0 0 12px;
  border: 2px solid #0b0f17;
  border-left-width: 1px;
  border-right-width: 1px;
  border-radius: 12px 12px 4px 4px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0 12%, #fff8df 13% 58%, #ebdfb7 59% 78%, #c9b778 79% 100%);
  color: #222013;
  font-weight: 900;
  box-shadow:
    inset 0 7px 0 rgba(255, 255, 255, 0.62),
    inset -4px 0 rgba(0, 0, 0, 0.08),
    inset 0 -8px 0 rgba(89, 63, 21, 0.1),
    0 5px 0 rgba(0, 0, 0, 0.24);
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.piano-key::before {
  position: absolute;
  left: clamp(5px, 12%, 10px);
  right: clamp(5px, 12%, 10px);
  top: 6px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px 10px 7px 7px;
  background:
    radial-gradient(circle at 50% 50%, rgba(218, 248, 255, 0.16) 0 16%, transparent 30%),
    linear-gradient(180deg, #253041 0 18%, #111823 19% 72%, #06090f 73% 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.1),
    inset 0 -4px 0 rgba(0, 0, 0, 0.3),
    0 2px 0 rgba(0, 0, 0, 0.22);
  content: "";
  pointer-events: none;
}

.piano-key::after {
  position: absolute;
  top: 12px;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, #ffffff 0 16%, #bdefff 28% 54%, #5ba6c5 72% 100%);
  box-shadow:
    0 0 9px rgba(190, 242, 255, 0.58),
    0 0 18px rgba(96, 184, 220, 0.22);
  transform: translateX(-50%);
  content: "";
  pointer-events: none;
}

.piano-key.playing {
  background:
    linear-gradient(180deg, #fff1bc 0 12%, #ffe08a 13% 62%, #d4b45c 63% 100%);
  box-shadow:
    inset 0 4px 0 rgba(255, 255, 255, 0.38),
    inset -4px 0 rgba(0, 0, 0, 0.1),
    inset 0 -6px 0 rgba(94, 61, 12, 0.14),
    0 1px 0 rgba(0, 0, 0, 0.2);
}

.piano-key.playing::before {
  border-color: rgba(157, 255, 168, 0.7);
  background:
    radial-gradient(circle at 50% 50%, rgba(204, 255, 186, 0.32) 0 22%, transparent 36%),
    linear-gradient(180deg, #32492a 0 18%, #17301d 19% 72%, #07120c 73% 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.14),
    0 0 16px rgba(123, 255, 145, 0.38);
}

.piano-key.playing::after {
  background:
    radial-gradient(circle at 35% 30%, #ffffff 0 18%, #caff9f 30% 58%, #31d969 74% 100%);
  box-shadow:
    0 0 12px rgba(155, 255, 164, 0.88),
    0 0 24px rgba(49, 222, 104, 0.42);
}

.debug-path-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 12;
  width: min(280px, calc(100% - 28px));
  padding: 12px;
  border: 1px solid rgba(117, 233, 255, 0.32);
  border-radius: 14px;
  background: rgba(8, 12, 20, 0.88);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(12px);
}

.debug-path-title {
  color: #d9fbff;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.debug-path-status {
  margin: 7px 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.3;
}

.debug-path-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.debug-path-actions button {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  cursor: pointer;
}

.debug-path-actions button.active {
  border-color: rgba(110, 231, 183, 0.78);
  background: rgba(110, 231, 183, 0.24);
  color: #effff8;
}

.music-maker-panel {
  display: none;
  width: min(860px, 100%);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(20, 25, 35, 0.95), rgba(8, 11, 18, 0.96)),
    radial-gradient(circle at 24% 0%, rgba(176, 233, 21, 0.14), transparent 38%);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.32);
}

.app-shell.debug-open .music-maker-panel {
  order: 6;
  display: block;
  justify-self: center;
}

.music-maker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.music-maker-header h2 {
  margin: 0;
  color: #f8ffe8;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
}

.music-maker-summary,
.music-maker-rpm {
  color: #ff5d66;
  font-size: 0.9rem;
  font-weight: 900;
}

.music-maker-body {
  display: grid;
  grid-template-columns: 134px minmax(0, 1fr);
  gap: 12px;
}

.music-maker-side-controls {
  display: grid;
  align-content: start;
  gap: 8px;
  padding-top: 58px;
}

.music-maker-red-btn,
.music-maker-remove-note,
.music-maker-add-note {
  min-width: 0;
  border: 0;
  border-radius: 7px;
  color: #160c0c;
  font-weight: 900;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.music-maker-red-btn,
.music-maker-remove-note {
  min-height: 42px;
  background: linear-gradient(180deg, #ff2a31, #d3121a);
  color: #fff2f2;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.24), 0 8px 18px rgba(132, 13, 20, 0.2);
}

.music-maker-red-btn:active,
.music-maker-remove-note:active {
  transform: translateY(1px);
}

.music-maker-workbench {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.music-maker-tool-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.82fr) minmax(120px, 1fr);
  gap: 12px;
}

.music-maker-add-note {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 28px;
  align-items: center;
  min-height: 52px;
  padding: 0 14px;
  background: linear-gradient(180deg, #c7ff18, #96e300);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.34), 0 10px 22px rgba(151, 227, 0, 0.12);
  touch-action: none;
}

.music-maker-add-note i {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #a83db8;
  box-shadow: 0 0 0 4px rgba(168, 61, 184, 0.16);
}

.music-maker-remove-note {
  min-height: 52px;
  touch-action: none;
}

.music-maker-remove-note.remove-hover {
  filter: brightness(1.18);
  box-shadow: 0 0 0 3px rgba(255, 87, 95, 0.28), 0 0 24px rgba(255, 38, 48, 0.28);
}

.music-maker-grid {
  position: relative;
  height: clamp(250px, 38vh, 342px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(250, 252, 255, 0.98), rgba(232, 236, 240, 0.96));
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.music-maker-grid-lines,
.music-maker-note-layer,
.music-maker-playhead {
  position: absolute;
  inset: 0;
}

.music-maker-grid-line {
  position: absolute;
  pointer-events: none;
}

.music-maker-grid-line.pitch {
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 999px;
  background: #050505;
  transform: translateY(-50%);
}

.music-maker-grid-line.beat {
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(85, 90, 96, 0.22);
  transform: translateX(-50%);
}

.music-maker-grid-line.bar {
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 999px;
  background: rgba(82, 86, 92, 0.38);
  transform: translateX(-50%);
}

.music-maker-note {
  position: absolute;
  display: block;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: linear-gradient(180deg, #c5ff19, #a7ef03);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.28), 0 6px 14px rgba(0, 0, 0, 0.12);
  cursor: grab;
  touch-action: none;
  transform: translateY(-50%);
}

.music-maker-note:focus,
.music-maker-note:focus-visible {
  outline: 0;
}

.music-maker-note.dragging,
.music-maker-note.draft {
  opacity: 0.78;
  filter: brightness(1.08);
}

.music-maker-note.selected {
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.34),
    0 0 0 3px rgba(168, 61, 184, 0.5),
    0 0 18px rgba(168, 61, 184, 0.42),
    0 6px 14px rgba(0, 0, 0, 0.12);
}

.music-maker-note.draft {
  pointer-events: none;
}

.music-maker-note-handle {
  position: absolute;
  top: 50%;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #a83db8;
  box-shadow: 0 0 0 3px rgba(168, 61, 184, 0.12);
  transform: translate(-50%, -50%);
  cursor: ew-resize;
}

.music-maker-note-handle.end {
  left: 100%;
}

.music-maker-note-handle.start {
  left: 0;
}

.music-maker-playhead {
  width: 3px;
  right: auto;
  background: linear-gradient(180deg, rgba(255, 45, 58, 0), rgba(255, 45, 58, 0.95) 15% 85%, rgba(255, 45, 58, 0));
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
}

.music-maker-panel.playing .music-maker-playhead {
  opacity: 1;
}

.music-maker-length-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: #ff8326;
  font-size: 0.82rem;
  font-weight: 900;
}

.music-maker-length-track {
  position: relative;
  height: 36px;
  border-radius: 999px;
  touch-action: none;
}

.music-maker-length-fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 7px;
  border-radius: 999px;
  background: #ff8228;
  transform: translateY(-50%);
}

.music-maker-length-handle {
  position: absolute;
  top: 50%;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: #a83db8;
  box-shadow: 0 0 0 4px rgba(168, 61, 184, 0.14);
  transform: translate(-50%, -50%);
}

.music-maker-length-start {
  left: 0;
}

.music-maker-length-end {
  cursor: ew-resize;
  touch-action: none;
}

.music-maker-output {
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  border-radius: 8px;
  background: rgba(210, 214, 214, 0.8);
  color: #151515;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.build-hint,
.item-popup {
  position: absolute;
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(11, 16, 23, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
}

.build-hint {
  left: 16px;
  bottom: 104px;
  max-width: 340px;
}

.item-popup {
  min-width: 220px;
}

.item-popup-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 14px 16px;
  overflow: auto;
}

.shop-item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 10px;
  color: var(--text);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.shop-item:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.2);
}

.shop-item.selected {
  background: rgba(255, 180, 0, 0.18);
  border-color: rgba(255, 205, 92, 0.65);
}

.shop-item.locked {
  background: rgba(255, 90, 90, 0.16);
}

.shop-item.affordable {
  background: rgba(80, 200, 120, 0.16);
}

.shop-icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background: rgba(255, 255, 255, 0.12);
}

.shop-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.sound-play-panel button:focus {
  outline: none;
}

.sound-play-panel button:focus-visible {
  outline: 2px solid rgba(110, 231, 183, 0.65);
  outline-offset: -2px;
}

.sound-play-panel .drum-pad:focus,
.sound-play-panel .drum-pad:focus-visible {
  outline: 0;
  box-shadow: none;
}

.toggle-btn,
.ghost-btn,
.item-popup-actions button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text);
}

.toggle-btn {
  background: rgba(255, 255, 255, 0.08);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.1);
}

#sellItem {
  background: rgba(255, 107, 107, 0.18);
}

#upgradeItem {
  background: rgba(110, 231, 183, 0.2);
}

.hidden {
  display: none;
}

.panel.collapsed .shop-list {
  display: none;
}

.panel.collapsed {
  min-width: 78px;
}

.panel.collapsed .panel-header {
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 16px 8px;
}

.panel.collapsed .panel-header h2 {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
}

.panel.collapsed .toggle-btn {
  width: 100%;
  padding: 10px 6px;
  border-radius: 14px;
  font-size: 0.82rem;
}

.panel.collapsed .toggle-btn::after {
  content: " >";
}

.panel-left.collapsed .toggle-btn::after {
  content: " >";
}

.panel-right.collapsed .toggle-btn::after {
  content: " <";
}

.panel:not(.collapsed) .toggle-btn::after {
  content: "";
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 0;
  }

  .stage-shell {
    min-height: 100svh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-rows: auto auto auto auto;
  }

  .panel {
    min-height: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .preplay-panel {
    gap: 0;
    min-height: 0;
    padding: 0;
    border-bottom: 0;
    background: transparent;
  }

  .preplay-panel.open {
    padding: 34px 8px var(--row-space-small);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(7, 10, 16, 0.42);
  }

  .preplay-panel-content {
    max-height: 360px;
    opacity: 1;
    transform: translateY(0);
  }

  .preplay-panel:not(.open) .preplay-panel-content {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
  }

  .mobile-data-toggle {
    display: block;
    position: fixed;
    top: max(0px, env(safe-area-inset-top));
    left: 50%;
    z-index: 80;
    width: min(180px, 58vw);
    height: 28px;
    margin: 0;
    border: 1px solid rgba(110, 231, 183, 0.28);
    border-radius: 0 0 10px 10px;
    background: rgba(15, 23, 42, 0.92);
    color: #dfffea;
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -30px);
    transition: opacity 140ms ease, transform 160ms ease;
  }

  .preplay-panel.show-toggle .mobile-data-toggle,
  .preplay-panel.open .mobile-data-toggle {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
  }

  .hud {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    padding: 0;
  }

  .hud > div {
    padding: 7px 8px;
    border-radius: 8px;
  }

  .hud span {
    display: block;
    overflow: hidden;
    font-size: 0.54rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .hud strong {
    margin-top: 2px;
    overflow: hidden;
    font-size: 0.92rem;
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 8px;
    padding: 4px 0 var(--row-space-small);
  }

  .topbar h1 {
    font-size: 1.45rem;
  }

  .eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: auto minmax(132px, 1fr);
    gap: 6px;
    justify-content: end;
    min-width: 0;
  }

  .audio-controls {
    min-width: 0;
    gap: 4px;
  }

  .audio-toggle-row {
    gap: 4px;
  }

  .volume-control {
    gap: 6px;
    padding: 4px 6px;
    border-radius: 8px;
    font-size: 0.68rem;
  }

  .volume-control span {
    min-width: 32px;
  }

  .ghost-btn {
    min-height: 34px;
    padding: 7px 9px;
  }

  .progress-shell {
    gap: 8px;
    padding: var(--row-space-small) 0;
  }

  .progress-track {
    height: 14px;
  }

  .viewport-controls {
    width: min(210px, 100%);
    margin: calc(var(--row-tight-offset) / 4) auto var(--row-space-small);
    padding: 6px;
  }

  .canvas-shell {
    width: calc(100% - 2px);
    max-width: calc(100% - 2px);
    height: var(--mobile-playfield-height, calc(100svh - 40px));
    min-height: 0;
    aspect-ratio: auto;
    margin: 0 auto var(--row-space);
    border-radius: 0;
  }

  .keyboard-sound-controls,
  .instrument-style-controls {
    max-width: calc(100% - 16px);
  }

  .instrument-eq-controls {
    width: min(440px, calc(100% - 16px));
    margin: var(--row-tight-offset) auto var(--row-space);
  }

}

/* Clean play mode: the default view is only the portrait game surface. */
html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  gap: 0;
  height: 100vh;
  min-height: 100vh;
  padding: 0;
  overflow: hidden;
}

.stage-shell {
  width: min(100vw, calc(100vh * 9 / 16));
  height: 100vh;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  grid-template-rows: 1fr;
}

.canvas-shell {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  margin: 0;
  border-radius: 0;
}

.preplay-panel {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 90;
  display: block;
  pointer-events: none;
}

.preplay-panel.open {
  padding: 0;
  border: 0;
  background: transparent;
}

.mobile-data-toggle {
  display: block;
  position: fixed;
  top: max(0px, env(safe-area-inset-top));
  left: 50%;
  z-index: 96;
  width: min(178px, 54vw);
  height: 30px;
  margin: 0;
  border: 1px solid rgba(110, 231, 183, 0.32);
  border-radius: 0 0 10px 10px;
  background: rgba(15, 23, 42, 0.94);
  color: #dfffea;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -34px);
  transition: opacity 140ms ease, transform 160ms ease;
}

.app-shell.debug-toggle-visible .mobile-data-toggle,
.app-shell.debug-open .mobile-data-toggle {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.preplay-panel-content {
  position: fixed;
  top: calc(max(0px, env(safe-area-inset-top)) + 36px);
  left: 50%;
  z-index: 94;
  display: grid;
  gap: var(--row-space-small);
  width: min(860px, calc(100vw - 16px));
  max-height: min(68svh, 640px);
  padding: 10px;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(7, 10, 16, 0.93);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.46);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: opacity 160ms ease, transform 180ms ease;
}

.preplay-panel.open .preplay-panel-content {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.app-shell:not(.debug-open) > .panel,
.app-shell:not(.debug-open) .keyboard-sound-controls,
.app-shell:not(.debug-open) .instrument-style-controls,
.app-shell:not(.debug-open) .instrument-eq-controls {
  display: none;
}

.app-shell.debug-open > .panel {
  position: fixed;
  z-index: 88;
  overflow: hidden;
  border-radius: 14px;
}

.app-shell.debug-open .keyboard-sound-controls,
.app-shell.debug-open .instrument-style-controls,
.app-shell.debug-open .instrument-eq-controls {
  position: fixed;
  z-index: 92;
}

.app-shell.debug-open .keyboard-sound-controls {
  right: 12px;
  bottom: 12px;
}

.app-shell.debug-open .instrument-style-controls {
  right: 12px;
  bottom: 72px;
}

.app-shell.debug-open .instrument-eq-controls {
  right: 12px;
  bottom: 132px;
}

@media (min-width: 981px) {
  .app-shell.debug-open > .panel {
    top: 48px;
    bottom: 12px;
    width: clamp(160px, calc((100vw - min(100vw, 56.25vh)) / 2 - 24px), 280px);
  }

  .app-shell.debug-open .panel-left {
    left: 12px;
  }

  .app-shell.debug-open .panel-right {
    right: 12px;
  }
}

/* Debug mode lays tools out below the field instead of over the play area. */
html.debug-open-page,
body.debug-open-page {
  height: auto;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.app-shell.debug-open {
  grid-template-columns: repeat(2, minmax(0, 420px));
  place-items: start stretch;
  align-content: start;
  justify-content: center;
  gap: 12px;
  height: auto;
  min-height: 100vh;
  padding: 0 12px 18px;
  overflow: visible;
}

.app-shell.debug-open .stage-shell {
  grid-column: 1 / -1;
  justify-self: center;
  display: grid;
  grid-template-rows: auto auto auto auto auto;
  gap: 10px;
  width: min(860px, calc(100vw - 24px));
  height: auto;
  min-height: 0;
  overflow: visible;
}

.app-shell.debug-open .canvas-shell {
  order: 1;
  justify-self: center;
  width: min(100%, calc(100vh * 9 / 16));
  height: 100vh;
  margin: 0;
}

.app-shell.debug-open .preplay-panel {
  order: 2;
  position: static;
  width: 100%;
  pointer-events: auto;
}

.app-shell.debug-open .preplay-panel-content {
  position: static;
  width: 100%;
  max-height: none;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.app-shell.debug-open .keyboard-sound-controls,
.app-shell.debug-open .instrument-style-controls,
.app-shell.debug-open .instrument-eq-controls {
  position: static;
  z-index: auto;
  justify-self: center;
  margin: 0;
}

.app-shell.debug-open .keyboard-sound-controls {
  order: 3;
}

.app-shell.debug-open .instrument-style-controls {
  order: 4;
}

.app-shell.debug-open .instrument-eq-controls {
  order: 5;
  width: min(640px, 100%);
  grid-template-columns: repeat(6, minmax(54px, 1fr));
}

.app-shell.debug-open > .panel {
  position: static;
  z-index: auto;
  width: auto;
  min-height: 280px;
  max-height: 58vh;
  border-radius: 14px;
}

.app-shell.debug-open .panel-left,
.app-shell.debug-open .panel-right {
  align-self: stretch;
}

@media (max-width: 980px) {
  .app-shell.debug-open {
    grid-template-columns: minmax(0, 1fr);
    width: 100vw;
    gap: 10px;
    padding: 0 8px 14px;
  }

  .app-shell.debug-open .stage-shell {
    width: 100%;
  }

  .app-shell.debug-open .canvas-shell {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    height: var(--mobile-playfield-height, 100vh);
  }

  .app-shell.debug-open .preplay-panel-content {
    width: 100%;
    max-height: none;
  }

  .app-shell.debug-open .instrument-eq-controls {
    width: 100%;
    grid-template-columns: repeat(3, minmax(54px, 1fr));
  }

  .music-maker-panel {
    padding: 10px;
  }

  .music-maker-body {
    grid-template-columns: 1fr;
  }

  .music-maker-side-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-top: 0;
  }

  .music-maker-rpm {
    grid-column: 1 / -1;
  }

  .music-maker-tool-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .music-maker-grid {
    height: 300px;
  }

  .app-shell.debug-open > .panel {
    width: 100%;
    height: auto;
    min-height: 220px;
    max-height: none;
  }
}

@media (max-width: 980px) {
  .app-shell,
  .stage-shell {
    width: 100vw;
    height: var(--mobile-playfield-height, 100vh);
    min-height: var(--mobile-playfield-height, 100vh);
  }

  .stage-shell {
    grid-template-rows: 1fr;
  }

  .canvas-shell {
    width: 100%;
    max-width: 100%;
    height: 100%;
    margin: 0;
  }

  .preplay-panel-content {
    top: calc(max(0px, env(safe-area-inset-top)) + 34px);
    width: calc(100vw - 12px);
    max-height: 50svh;
    padding: 8px;
  }

  .app-shell.debug-open > .panel {
    top: auto;
    bottom: 0;
    width: 50vw;
    height: 30svh;
    min-height: 0;
    border-radius: 12px 12px 0 0;
  }

  .app-shell.debug-open .panel-left {
    left: 0;
  }

  .app-shell.debug-open .panel-right {
    right: 0;
  }

  .app-shell.debug-open .keyboard-sound-controls {
    right: auto;
    left: 8px;
    bottom: calc(30svh + 8px);
  }

  .app-shell.debug-open .instrument-style-controls {
    right: auto;
    left: 8px;
    bottom: calc(30svh + 62px);
  }

  .app-shell.debug-open .instrument-eq-controls {
    right: 8px;
    bottom: calc(30svh + 8px);
    width: min(440px, calc(100vw - 16px));
  }
}

@media (max-width: 980px) {
  .app-shell.debug-open .instrument-eq-controls {
    width: 100%;
  }

  .app-shell.debug-open > .panel {
    width: 100%;
    height: auto;
    min-height: 220px;
    max-height: none;
  }
}

/* Swipe side drawers for Gold and Energie. */
.side-panel-button {
  position: fixed;
  top: 50%;
  z-index: 86;
  min-width: 58px;
  height: 42px;
  padding: 0 10px;
  border: 1px solid rgba(110, 231, 183, 0.34);
  background: rgba(15, 23, 42, 0.94);
  color: #dfffea;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 180ms ease, left 180ms ease, right 180ms ease;
}

.side-panel-button-left {
  left: 0;
  border-left: 0;
  border-radius: 0 10px 10px 0;
  transform: translate(-100%, -50%);
}

.side-panel-button-right {
  right: 0;
  border-right: 0;
  border-radius: 10px 0 0 10px;
  transform: translate(100%, -50%);
}

.app-shell.side-panel-hint-left .side-panel-button-left,
.app-shell.side-panel-open-left .side-panel-button-left,
.app-shell.side-panel-hint-right .side-panel-button-right,
.app-shell.side-panel-open-right .side-panel-button-right {
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, -50%);
}

.app-shell.side-panel-open-left:not(.debug-open) > .panel-left,
.app-shell.side-panel-open-right:not(.debug-open) > .panel-right {
  display: flex;
  position: fixed;
  top: 12px;
  bottom: 12px;
  z-index: 84;
  width: clamp(178px, calc((100vw - min(100vw, 56.25vh)) / 2 - 20px), 300px);
  min-height: 0;
  max-height: none;
  border-radius: 12px;
  overflow: hidden;
}

.app-shell.side-panel-open-left:not(.debug-open) > .panel-left {
  left: 12px;
}

.app-shell.side-panel-open-right:not(.debug-open) > .panel-right {
  right: 12px;
}

.app-shell.side-panel-open-left:not(.debug-open) > .panel-right,
.app-shell.side-panel-open-right:not(.debug-open) > .panel-left {
  display: none;
}

.app-shell.side-panel-open:not(.debug-open) .toggle-btn {
  min-width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  font-size: 1.1rem;
  line-height: 1;
}

.app-shell.side-panel-portrait-open:not(.debug-open) > .panel-left,
.app-shell.side-panel-portrait-open:not(.debug-open) > .panel-right {
  top: max(40px, env(safe-area-inset-top));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(67vw, 380px);
  border-radius: 0 14px 14px 0;
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.56);
  touch-action: pan-y;
}

.app-shell.side-panel-portrait-open:not(.debug-open) > .panel-left *,
.app-shell.side-panel-portrait-open:not(.debug-open) > .panel-right * {
  touch-action: pan-y;
}

.app-shell.side-panel-portrait-open.side-panel-open-right:not(.debug-open) > .panel-right {
  border-radius: 14px 0 0 14px;
}

.app-shell.side-panel-portrait-open.side-panel-open-left .side-panel-button-left {
  left: min(67vw, 380px);
  transform: translate(-1px, -50%);
}

.app-shell.side-panel-portrait-open.side-panel-open-right .side-panel-button-right {
  right: min(67vw, 380px);
  transform: translate(1px, -50%);
}

.app-shell.side-panel-open-left.side-panel-open-right:not(.debug-open) > .panel-left,
.app-shell.side-panel-open-left.side-panel-open-right:not(.debug-open) > .panel-right {
  display: flex;
}

/* Final mobile/debug and in-field drawer polish. */
.canvas-shell .side-panel-button {
  position: fixed;
  top: clamp(76px, 17vh, 128px);
  z-index: 75;
  display: grid;
  place-items: center;
  min-width: 0;
  width: 20px;
  height: 54px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255, 247, 205, 0.88);
  font-size: 0;
  line-height: 1;
  letter-spacing: 0;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%);
  touch-action: none;
}

.canvas-shell .side-panel-button::after {
  display: grid;
  place-items: center;
  width: 14px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0 7px 7px 0;
  background:
    linear-gradient(135deg, rgba(250, 204, 21, 0.28), rgba(176, 92, 32, 0.2));
  font-size: 0.58rem;
  font-weight: 900;
  opacity: 0.42;
  backdrop-filter: blur(8px);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.canvas-shell .side-panel-button-left {
  left: max(0px, calc(50vw - min(100vw, 56.25vh) / 2));
  justify-items: start;
}

.canvas-shell .side-panel-button-left::after {
  content: "G";
}

.canvas-shell .side-panel-button-right {
  right: max(0px, calc(50vw - min(100vw, 56.25vh) / 2));
  justify-items: end;
  color: rgba(211, 247, 255, 0.9);
}

.canvas-shell .side-panel-button-right::after {
  border-radius: 7px 0 0 7px;
  background:
    linear-gradient(135deg, rgba(96, 224, 255, 0.26), rgba(31, 110, 180, 0.2));
}

.canvas-shell .side-panel-button-right::after {
  content: "E";
}

.app-shell.side-panel-hint-left .canvas-shell .side-panel-button-left,
.app-shell.side-panel-open-left .canvas-shell .side-panel-button-left,
.app-shell.side-panel-hint-right .canvas-shell .side-panel-button-right,
.app-shell.side-panel-open-right .canvas-shell .side-panel-button-right {
  width: 28px;
}

.app-shell.side-panel-hint-left .canvas-shell .side-panel-button-left::after,
.app-shell.side-panel-open-left .canvas-shell .side-panel-button-left::after,
.app-shell.side-panel-hint-right .canvas-shell .side-panel-button-right::after,
.app-shell.side-panel-open-right .canvas-shell .side-panel-button-right::after {
  width: 22px;
  opacity: 0.76;
}

.app-shell.side-panel-hint-left .canvas-shell .side-panel-button-left::after,
.app-shell.side-panel-open-left .canvas-shell .side-panel-button-left::after {
  content: "G";
  font-size: 0.72rem;
  writing-mode: horizontal-tb;
}

.app-shell.side-panel-hint-right .canvas-shell .side-panel-button-right::after,
.app-shell.side-panel-open-right .canvas-shell .side-panel-button-right::after {
  content: "E";
  font-size: 0.72rem;
  writing-mode: horizontal-tb;
}

.app-shell.debug-open .canvas-shell .side-panel-button {
  display: none;
}

@media (max-width: 980px) {
  html.debug-open-page,
  body.debug-open-page {
    height: auto !important;
    min-height: 100% !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
  }

  body.debug-open-page .app-shell.debug-open {
    height: auto !important;
    min-height: 100vh !important;
    overflow: visible !important;
    align-content: start;
    touch-action: pan-y;
  }

  body.debug-open-page .app-shell.debug-open .stage-shell {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  body.debug-open-page .app-shell.debug-open .canvas-shell {
    height: var(--mobile-playfield-height, 100vh) !important;
    min-height: 0 !important;
  }

  body.debug-open-page .app-shell.debug-open .preplay-panel,
  body.debug-open-page .app-shell.debug-open .preplay-panel-content {
    position: static !important;
    max-height: none !important;
    overflow: visible !important;
    touch-action: pan-y;
  }

  body.debug-open-page .app-shell.debug-open .keyboard-sound-controls,
  body.debug-open-page .app-shell.debug-open .instrument-style-controls,
  body.debug-open-page .app-shell.debug-open .instrument-eq-controls,
  body.debug-open-page .app-shell.debug-open > .panel {
    position: static !important;
    inset: auto !important;
  }

  .canvas-shell .side-panel-button {
    width: 20px;
    height: 54px;
  }

  .app-shell.side-panel-hint-left .canvas-shell .side-panel-button-left,
  .app-shell.side-panel-open-left .canvas-shell .side-panel-button-left,
  .app-shell.side-panel-hint-right .canvas-shell .side-panel-button-right,
  .app-shell.side-panel-open-right .canvas-shell .side-panel-button-right {
    width: 28px;
  }
}

@media (min-width: 700px) {
  html.touch-playfield:not(.debug-open-page),
  body.touch-playfield:not(.debug-open-page) {
    width: 100%;
    height: var(--mobile-playfield-height, 100dvh);
    min-height: var(--mobile-playfield-height, 100dvh);
    overflow: hidden;
    background: #071426;
  }

  html.touch-playfield:not(.debug-open-page) .app-shell {
    width: 100vw;
    max-width: none;
    height: var(--mobile-playfield-height, 100dvh);
    min-height: var(--mobile-playfield-height, 100dvh);
    padding: 0;
    overflow: hidden;
  }

  html.touch-playfield:not(.debug-open-page) .stage-shell {
    width: 100vw;
    max-width: none;
    height: var(--mobile-playfield-height, 100dvh);
    min-height: 0;
  }

  html.touch-playfield:not(.debug-open-page) .canvas-shell {
    width: 100vw;
    max-width: none;
    height: 100%;
    margin: 0;
  }

  html.touch-playfield:not(.debug-open-page) .sound-play-panel {
    bottom: 0;
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }

  html.touch-playfield:not(.debug-open-page) .piano-key {
    height: clamp(94px, 8.8dvh, 126px);
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }

  html.touch-playfield:not(.debug-open-page) .canvas-shell .side-panel-button-left {
    left: 0;
  }

  html.touch-playfield:not(.debug-open-page) .canvas-shell .side-panel-button-right {
    right: 0;
  }
}

@media (min-width: 1000px) and (pointer: coarse) {
  html.touch-playfield:not(.debug-open-page) .pixel-drums {
    grid-template-columns: 84px 125px 84px 84px;
    width: min(462px, 76vw);
    min-height: 226px;
    margin-bottom: -22px;
  }

  html.touch-playfield:not(.debug-open-page) .drum-large {
    width: 172px;
    height: 174px;
    margin: 0 -41px 0 8px;
  }

  html.touch-playfield:not(.debug-open-page) .drum-medium {
    width: 89px;
    height: 124px;
    margin-left: -65px;
  }

  html.touch-playfield:not(.debug-open-page) .drum-medium span {
    width: 120px;
  }

  html.touch-playfield:not(.debug-open-page) .drum-twin {
    width: 92px;
    height: 200px;
    scale: 1;
    transition: none;
    filter: none;
  }

  html.touch-playfield:not(.debug-open-page) .twin-energy-meter {
    width: 18px;
    height: 64px;
    box-shadow:
      inset 0 0 4px rgba(0, 0, 0, 0.56),
      0 0 5px rgba(255, 215, 96, 0.18);
  }

  html.touch-playfield:not(.debug-open-page) .drum-twin.twin-energy-active::after {
    display: none;
  }

  html.touch-playfield:not(.debug-open-page) .drum-twin.twin-energy-full span,
  html.touch-playfield:not(.debug-open-page) .drum-twin.twin-energy-neon span {
    filter: none;
  }

  html.touch-playfield:not(.debug-open-page) .drum-twin.twin-energy-full .twin-energy-fill,
  html.touch-playfield:not(.debug-open-page) .drum-twin.twin-energy-neon .twin-energy-fill {
    animation: none;
    box-shadow:
      inset 0 3px 0 rgba(255, 255, 255, 0.38),
      0 0 8px rgba(185, 104, 255, 0.42);
  }

  html.touch-playfield:not(.debug-open-page) .drum-twin.twin-energy-neon .twin-energy-meter {
    box-shadow:
      inset 0 0 5px rgba(255, 255, 255, 0.28),
      0 0 12px rgba(214, 112, 255, 0.42);
  }

  html.touch-playfield:not(.debug-open-page) .drum-twin.twin-energy-neon .twin-energy-meter::after {
    animation: none;
    opacity: 0.72;
  }

  html.touch-playfield:not(.debug-open-page) .drum-energy-branch {
    height: 42px;
    margin-top: 0;
    filter: none;
  }

  html.touch-playfield:not(.debug-open-page) .drum-energy-branch::before {
    height: 44px;
  }

  html.touch-playfield:not(.debug-open-page) .drum-energy-branch::after {
    top: 21px;
  }

  html.touch-playfield:not(.debug-open-page) .branch-knot {
    top: 14px;
    width: 17px;
    height: 12px;
  }

  html.touch-playfield:not(.debug-open-page) .branch-energy-meter {
    width: min(570px, 82%);
    height: 27px;
    box-shadow:
      inset 0 0 5px rgba(0, 0, 0, 0.66),
      0 0 8px rgba(215, 122, 255, 0.12);
  }

  html.touch-playfield:not(.debug-open-page) .branch-energy-fill {
    transition: transform 90ms linear;
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.32),
      0 0 7px rgba(255, 142, 50, 0.34);
  }

  html.touch-playfield:not(.debug-open-page) .drum-energy-branch.branch-energy-full .branch-energy-fill,
  html.touch-playfield:not(.debug-open-page) .drum-energy-branch.branch-energy-neon .branch-energy-fill {
    animation: none;
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.42),
      0 0 9px rgba(186, 105, 255, 0.36);
  }

  html.touch-playfield:not(.debug-open-page) .drum-energy-branch.branch-energy-neon .branch-energy-meter {
    box-shadow:
      inset 0 0 5px rgba(255, 255, 255, 0.24),
      0 0 12px rgba(212, 103, 255, 0.34);
  }

  html.touch-playfield:not(.debug-open-page) .branch-combo-label {
    font-size: clamp(0.86rem, 1.45vw, 1.08rem);
  }
}

@media (pointer: coarse), (max-width: 980px) {
  .drum-twin {
    scale: 1;
    transition: none;
    filter: none;
  }

  .drum-twin.twin-energy-active::after {
    display: none;
  }

  .drum-twin.twin-energy-full span,
  .drum-twin.twin-energy-neon span {
    filter: none;
  }

  .drum-twin.twin-energy-full .twin-energy-fill,
  .drum-twin.twin-energy-neon .twin-energy-fill,
  .drum-energy-branch.branch-energy-full .branch-energy-fill,
  .drum-energy-branch.branch-energy-neon .branch-energy-fill {
    animation: none;
  }

  .drum-twin.twin-energy-neon .twin-energy-meter::after {
    animation: none;
    opacity: 0.72;
  }

  .drum-energy-branch {
    filter: none;
  }

  .branch-energy-meter {
    box-shadow:
      inset 0 0 5px rgba(0, 0, 0, 0.66),
      0 0 8px rgba(215, 122, 255, 0.12);
  }

  .branch-energy-fill,
  .twin-energy-fill {
    transition: transform 90ms linear;
  }
}

.app-shell.debug-open > .panel {
  display: none !important;
}
