:root {
  --tile-size: 106px;
  --gap: 10px;
  --dock-height: clamp(196px, 30vh, 238px);
  --dock-bg-height: clamp(74px, 12vh, 98px);
  --bank-note-size: 96px;
  --bank-note-gap: 8px;
  --bg1: #eef1f5;
  --bg2: #eef1f5;
  --ink: #1b233e;
  --panel: #ffffff;
  --panel-border: #e4edff;
  --teal: #099695;
  --teal-dark: #007777;
  --green: #6abb4a;
  --green-soft: #a8d58c;
  --line: #d7e2f2;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: "Nunito", "Avenir Next Rounded", "Trebuchet MS", "Verdana", sans-serif;
  color: var(--ink);
  background: #eef1f5;
  padding: 0;
  overflow-x: hidden;
}

.app {
  width: min(1020px, 100%);
  margin: 0 auto;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  position: relative;
}

.screen {
  min-height: 100vh;
  min-height: 100svh;
  padding: calc(20px + env(safe-area-inset-top)) 14px calc(var(--dock-height) + env(safe-area-inset-bottom) + 24px);
  position: relative;
  background: #eef1f5;
}



.boot-loader {
  position: absolute;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  gap: 10px;
  background: rgba(249, 252, 255, 0.9);
  transition: opacity 0.18s ease;
}

.boot-loader.done {
  opacity: 0;
}

.boot-loader-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid #c8d7f6;
  border-top-color: #099695;
  animation: bootSpin 0.82s linear infinite;
}

.boot-loader-text {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 800;
  color: #446196;
}

@keyframes bootSpin {
  to { transform: rotate(360deg); }
}

button {
  border: 0;
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

.app-title {
  margin: 0;
  text-align: center;
  font-size: clamp(1.52rem, 7vw, 2.2rem);
  font-weight: 900;
  color: var(--ink);
  line-height: 1.1;
  white-space: nowrap;
}

.top-ui {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 76px;
  margin-bottom: 8px;
  position: relative;
}

.play-center {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-height) + env(safe-area-inset-bottom) + 8px);
  z-index: 69;
  width: min(1020px, calc(100% - 28px));
  display: grid;
  place-items: center;
  gap: 6px;
  margin: 0;
  transform: translateX(-50%);
}

.settings-btn {
  position: absolute;
  right: 0;
  top: 0;
  transform: none;
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
}

.settings-glyph {
  display: inline-block;
  font-size: 1.5rem;
  line-height: 1;
  transform: translateY(1px);
}

.settings-btn.active {
  background: #099695;
  color: #fff;
  border-color: #007d7d;
  box-shadow: none;
}

.settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(760px, calc(100vw - 44px));
  z-index: 34;
}

.settings {
  width: 100%;
  margin: 0;
  padding: 7px 9px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  display: grid;
  gap: 6px;
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(88px, 118px) 1fr;
  align-items: center;
  gap: 8px;
}

.setting-row-slider {
  grid-template-columns: minmax(88px, 118px) 1fr minmax(42px, 50px);
}

.setting-label {
  font-weight: 900;
  color: #2a4478;
  font-size: 0.81rem;
}

.setting-value {
  text-align: center;
  font-weight: 900;
  color: #0f4474;
  background: #ffffff;
  border: 2px solid #d8e6ff;
  border-radius: 999px;
  padding: 1px 4px;
  font-size: 0.74rem;
}

.settings input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.mode-toggle {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mode-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.mode-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-group-label {
  font-size: 0.78rem;
  font-weight: 900;
  color: #2a4478;
  min-width: 42px;
}

.single-note-game .settings-btn,
.single-note-game .settings-panel {
  display: none;
}

.mode-btn {
  color: #23416e;
  background: #f2f6ff;
  border: 2px solid #d3e1ff;
  min-height: 30px;
  min-width: 72px;
  padding: 5px 9px;
  font-size: 0.76rem;
  border-radius: 10px;
}

.mode-btn.active {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal-dark);
  box-shadow: none;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 250px);
  justify-content: center;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.transport-btn {
  /* Solid green with white type, matching Melody Memory (and Major or Minor):
     the outlined white version read as a quiet secondary control next to the
     bells, when it is the thing you press first. */
  min-height: 56px;
  border: none;
  border-radius: 16px;
  padding: 15px 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  color: #fff;
  background: var(--green);
  box-shadow: 0 4px 0 #4e9636, 0 6px 16px rgba(26, 35, 61, 0.18);
  font-size: 1.06rem;
  font-weight: 900;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.transport-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #4e9636, 0 8px 18px rgba(26, 35, 61, 0.2);
}

.transport-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #4e9636, 0 3px 10px rgba(26, 35, 61, 0.18);
}

.play-circle {
  width: 100%;
  height: auto;
}

.play-triangle {
  width: 0;
  height: 0;
  /* White, because the button is green now — a green triangle on green is a
     triangle nobody can see. */
  border-left: 15px solid #fff;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  margin-left: 0;
}

.transport-label {
  color: inherit;
  font-size: inherit;
  line-height: 1;
  font-weight: 900;
}

.replay-btn {
  position: relative;
}

.tool-icon-btn,
.score-skip-btn {
  width: 52px;
  height: 52px;
  min-width: 52px;
  min-height: 52px;
  border-radius: 15px;
  padding: 0;
  background: #fff;
  border: 2px solid var(--line);
  color: #4f6796;
  box-shadow: none;
}

.tool-icon-btn svg,
.score-skip-btn svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.score-skip-btn {
  width: auto;
  min-width: 0;
  display: inline-grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  font: inherit;
}

.score-skip-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.replay-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* One capped scoreboard, matching Melody Memory: the stats used to be pill
   boxes stretched across the whole window, which read as chrome rather than
   score. Capped and centred, they sit above the cards as a strip. */
.hud-panel {
  width: 100%;
  max-width: 640px;
  margin: 2px auto 6px;
  padding: 8px 14px 7px;
  border: 1px solid var(--line, #e2e9f4);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.round-chip,
.last-chip {
  display: none;
}

.score-chip,
.score-skip-btn {
  /* Bare columns inside the panel — the panel is the container now, so a box
     around each stat is one border too many. */
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  text-align: center;
  box-shadow: none;
}

/* Hairline dividers between the stats, like Melody Memory's hud-divider. */
.score-row > * + * {
  border-left: 1px solid var(--line, #e6ecf7);
}

/* ...but only BETWEEN them. Round is always hidden and sits first in the row, so `* + *` gave
   Score a line too: a stray rule at the far left, over "Progress" (Rob, 2026-10-21: "its only 3
   columns so 2 dividers not 3"). */
.score-row > .score-total-chip {
  border-left: 0;
}

.chip-label {
  display: block;
  font-size: 0.56rem;
  font-weight: 900;
  color: #5e6780;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.chip-value {
  display: block;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1.2;
  color: var(--ink);
}

.tries-value {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 2px;
}

.try-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #c8d7f7;
  background: #eef1f5;
}

.try-dot.is-available {
  border-color: var(--green);
  background: var(--green);
}

.outcome-track {
  margin: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.outcome-track-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.outcome-track-label {
  font-size: 0.7rem;
  font-weight: 900;
  color: #5e6780;
  text-transform: uppercase;
  letter-spacing: 0;
}

.outcome-track-value {
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--ink);
}

.outcome-track-rail {
  position: relative;
  padding: 2px 0;
}

.outcome-track-rail::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  border-radius: 999px;
  background: #dde7fb;
}

.outcome-track-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6ec4ff, #57a8ef);
  transition: width 260ms ease;
}

.outcome-dots {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.outcome-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #c8d7f7;
  background: #eef1f5;
  transition: transform 0.18s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.outcome-dot.is-correct {
  background: #58d36f;
  border-color: #2ea448;
}

.outcome-dot.is-half {
  background: #ffd95b;
  border-color: #e3b62f;
}

.outcome-dot.is-wrong {
  background: #ff7171;
  border-color: #d74f4f;
}

.outcome-dot.is-filled {
  transform: scale(1.03);
}

.message {
  min-height: 30px;
  margin: 4px 0 8px;
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
  color: #1d7b45;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.message.show {
  opacity: 1;
  transform: translateY(0);
}

.question-wrap {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 8px 0 0;
  box-shadow: none;
}

.question-prompt {
  display: none;
  margin: 0;
  text-align: center;
  font-size: clamp(1rem, 2.8vw, 1.2rem);
  font-weight: 900;
  color: #22457f;
}

.question-grid {
  width: max-content;
  margin: 0 auto;
  display: grid;
  gap: var(--gap);
}

.question-grid.slots-3 {
  --tile-size: clamp(88px, 24vw, 116px);
  --gap: 10px;
}

/* The card IS the question, so it takes the room Melody Memory's deck takes —
   capped by height or width, whichever runs out first. */
.question-grid.slots-1 {
  --tile-size: clamp(142px, min(29vh, 30vw), 248px);
  --gap: 0;
}

.single-note-game .question-wrap {
  padding-top: 4px;
}

.single-note-game .question-grid {
  width: var(--tile-size);
}

.single-note-game .question-card {
  border-radius: 20px;
  border-width: 2px;
}

.single-note-game .question-face-front {
  font-size: clamp(4rem, 18vw, 5.9rem);
}

.question-grid.slots-4 {
  --tile-size: clamp(76px, 18vw, 94px);
  --gap: 9px;
}

.question-grid.slots-5 {
  --tile-size: clamp(62px, 14vw, 76px);
  --gap: 8px;
}

.question-slot {
  width: var(--tile-size);
  height: var(--tile-size);
  perspective: 1000px;
  position: relative;
}

.question-card {
  width: 100%;
  height: 100%;
  border-radius: 20px;
  /* A solid card, like Melody Memory's: the dashed outline read as an empty
     drop zone rather than the card holding the answer. */
  border: 2px solid #e3ebfc;
  background: #ffffff;
  box-shadow: none;
  transform-style: preserve-3d;
  transition: transform 0.36s ease;
  position: relative;
}

.question-slot.revealed .question-card {
  transform: rotateY(180deg);
}

.question-slot.playing .question-card {
  border-color: #cfd9f6;
  box-shadow: none;
}

.question-slot.playing .question-face-front {
  animation: questionJiggle 280ms ease;
  color: #40639f;
}

.question-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  backface-visibility: hidden;
}

.question-face-front {
  font-size: 2.1rem;
  font-weight: 900;
  color: #5e75a5;
}

/* THE REVEALED BELL HAD NO BOX AT ALL (Rob: "they turn over and nothing is
   revealed"). The only rule that ever gave `.bell-composite` a width or height
   was scoped to `.bank-grid.c-major-strip .bank-note` — so the identical markup
   inside a question slot matched nothing but `position: relative` and collapsed
   to 0x0, taking both `inset:0` images down with it. Measured: composite 0x0,
   images 0x0, while fully loaded at naturalWidth 285. The art was always there;
   it just had nowhere to paint.

   Absolute, not a grid row: the note is `display:grid` with auto rows, so a
   percentage height would resolve against the row's own content and stay 0.
   Against the card (position:relative, a known size) it resolves properly. The
   aspect ratio is the bank's 74x118, so the bell keeps its proportions, and the
   label stays in normal flow underneath. Not phone-specific — this was broken
   at every width; Rob just met it on the iPhone. */
.question-face-back .bell-composite {
  position: absolute;
  left: 50%;
  bottom: 22%;
  transform: translateX(-50%);
  height: 66%;
  width: auto;
  aspect-ratio: 74 / 118;
}

.question-face-back {
  transform: rotateY(180deg);
}

.question-face-back .question-note {
  width: calc(var(--tile-size) - 8px);
  height: calc(var(--tile-size) - 8px);
  border-radius: 16px;
  pointer-events: none;
}

.question-slot.first-note-hint .question-note-hint {
  opacity: 0.5;
  filter: saturate(0.82);
}

.bank-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: calc(var(--dock-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: transparent;
  padding: 8px 10px 10px;
  z-index: 70;
}

.bank-dock::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--dock-bg-height) + env(safe-area-inset-bottom));
  background: #eef1f5;
  box-shadow: none;
  pointer-events: none;
}

.bank-dock-inner,
.bank-area {
  height: 100%;
}

.bank-dock-inner {
  width: min(1020px, 100%);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.bank-area {
  border-radius: 0;
  border: 0;
  background: transparent;
  max-height: calc(var(--dock-height) - 8px);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.bank-area.chromatic-bank-area {
  border-radius: 14px;
  border: 1px solid #cfdcf3;
  background: #ffffff;
  padding: 0 2px 10px;
}

.bank-grid {
  width: max-content;
  margin: 0 auto;
}

.bank-grid.bank-strip {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: var(--bank-note-gap);
  padding: 2px 6px 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   THE BELL INSTRUMENT — ported from Melody Memory, 2026-08-27 (Rob: the two
   games should feel identical).

   Eight bells in bordered white boxes read as icons in a picker. The same art,
   given a stage card and room to tower above it, reads as an instrument. The
   stage card (44px) is the hit zone; the bell body overflows above it and is
   pointer-transparent, with a ::before stretching the pressable area back over
   the whole bell — the lesson from Melody Memory's tap testing, where taps on
   a bell's face registered nowhere.

   Kept in step with melody-memory-v1.css by hand; both games draw from the
   same bells/ and stages/ art.
   ═══════════════════════════════════════════════════════════════════════════ */
.bank-grid.c-major-strip {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  width: min(100%, 406px);
  overflow: visible;
  margin: 0 auto;
  padding: 0;
  gap: 0;
}

/* flex:1 0 0 — every bell grows from a zero basis, so they share the row with
   no overlap; min-width:0 stops the base --bank-note-size fighting it. */
.bank-grid.c-major-strip .bank-note {
  flex: 1 0 0;
  height: 44px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  overflow: visible;
}

/* The whole drawn bell is pressable, not just the stage card at its feet. */
.bank-grid.c-major-strip .bank-note::before {
  content: "";
  position: absolute;
  inset: -74px 0 0 0;
  background: transparent;
}

.bank-grid.c-major-strip .bank-note .bell-composite {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 74px;
  height: 118px;
  margin-top: 0;
  pointer-events: none;
}

/* Stage: a landscape card anchored to the button floor. */
.bank-grid.c-major-strip .bank-note .note-art-stage {
  position: absolute;
  inset: auto;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 44px;
  object-fit: fill;
  filter: drop-shadow(0 3px 3px rgba(26, 35, 61, 0.16));
}

/* Bell: fills the composite and towers above the stage. */
.bank-grid.c-major-strip .bank-note .note-art-bell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 5px 4px rgba(26, 35, 61, 0.22));
}

/* Label floats under the stage rather than inside a box. */
.bank-grid.c-major-strip .bank-note .note-label {
  position: absolute;
  top: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  bottom: auto;
  font-size: 0.72rem;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

/* The dock has to clear the bell that towers over its stage: a 118px composite
   on a 44px card overflows 74px, plus breathing room. */
#gameScreen {
  --dock-height: 236px;
  --dock-bg-height: 80px;
}

#gameScreen .bank-dock {
  padding-top: 96px;
}

/* The bell body towers above its stage card, and the bank area clips by default
   (overflow-y:hidden, there to stop the chromatic piano scrolling vertically).
   For the c-major row that hid everything above the pedestals, so it opts out —
   exactly as Melody Memory does. */
#gameScreen .bank-area:not(.chromatic-bank-area) {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  max-height: none;
  padding-top: 4px;
}

/* iPad and desktop: the row takes the width it is given and the bells grow to
   match, the same trade Melody Memory makes above 900px. */
@media (min-width: 900px) {
  .bank-grid.c-major-strip {
    width: min(100%, 1120px);
    gap: 2px;
  }

  .bank-grid.c-major-strip .bank-note .bell-composite {
    width: 128px;
    height: 128px;
    margin-top: -10px;
  }

  #gameScreen .bank-dock {
    padding-top: 128px;
  }

  #gameScreen {
    --dock-height: 252px;
  }
}

.bank-grid.chromatic-piano {
  width: max-content;
  padding: 10px 4px 12px;
  margin-bottom: 4px;
}

.chromatic-piano-strip {
  position: relative;
  width: calc((var(--white-count) * var(--bank-note-size)) + ((var(--white-count) - 1) * var(--bank-note-gap)));
  padding-top: calc(var(--bank-note-size) * 0.72);
}

.chromatic-white-row {
  display: flex;
  gap: var(--bank-note-gap);
  align-items: flex-end;
}

.chromatic-black-row {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(var(--bank-note-size) * 0.86);
  pointer-events: none;
}

.chromatic-black-wrap {
  position: absolute;
  top: -10px;
  transform: translateX(-50%);
  pointer-events: auto;
  z-index: 4;
}

.chromatic-black-wrap .bank-note {
  width: calc(var(--bank-note-size) * 0.9);
  height: calc(var(--bank-note-size) * 1.18);
  min-width: calc(var(--bank-note-size) * 0.9);
  min-height: calc(var(--bank-note-size) * 1.18);
}

.note {
  width: var(--tile-size);
  height: var(--tile-size);
  border-radius: 22px;
  border: 3px solid transparent;
  margin: 0;
  padding: 0;
  background: var(--note-color, #ff7a7a);
  color: #fff;
  font-size: clamp(1.75rem, 4.8vw, 2.2rem);
  font-weight: 900;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  box-shadow: none;
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  position: relative;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.note.has-image {
  background: #ffffff;
  border-color: var(--note-color, #8fa3d8);
  color: #20315f;
  text-shadow: none;
}

.bank-note {
  width: var(--bank-note-size);
  height: calc(var(--bank-note-size) * 1.22);
  min-width: var(--bank-note-size);
  min-height: calc(var(--bank-note-size) * 1.22);
  border: 3px solid var(--note-color, #c9d7f5);
  border-radius: 22px;
  background: #ffffff;
  box-shadow: none;
  color: #1f3668;
  font-size: 0.98rem;
  font-weight: 900;
  text-shadow: none;
}

.bank-note .note-art {
  width: 88%;
  height: 82%;
  margin-top: -6px;
  filter: none;
}

.chromatic-white-note .note-art {
  margin-top: -5px;
}

.bank-note .note-label {
  bottom: 8px;
  min-width: 0;
  padding: 0;
  font-size: 0.7rem;
  line-height: 1.2;
  color: #223e75;
  background: transparent;
  border: 0;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.66);
  box-shadow: none;
}

.bank-grid.c-major-strip .bank-note .note-label {
  font-size: 0.82rem;
}

.chromatic-white-note .note-label {
  bottom: 5px;
}

.chromatic-black-note {
  border: 0;
  background: #35425b;
  box-shadow: none;
  color: #eef2ff;
}

.chromatic-black-note .note-label {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.38);
}

.bank-note.chromatic-black-note.has-image {
  border: 0;
  background: #35425b;
  color: #eef2ff;
  box-shadow: none;
}

.bank-note.chromatic-black-note.has-image .note-label,
.bank-note.chromatic-black-note .note-label {
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.38);
}

.note-art {
  width: 74%;
  height: 74%;
  object-fit: contain;
  margin-top: -8px;
  pointer-events: none;
  filter: none;
}

/* Two-layer bell, shared with Melody Memory: the stage card sits behind and
   the bell body on top, both stacked inside .bell-composite. */
.bell-composite {
  position: relative;
}

.note-art-stage,
.note-art-bell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin-top: 0;
  object-fit: contain;
}

/* With no stageBaseUrl the stage img never gets a src — hide it rather than
   render a broken-image box. */
.note-art-stage:not([src]),
.note-art-stage[src=""] {
  display: none;
}

.note-art-bell {
  z-index: 1;
}

.note-label {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  min-width: 36px;
  padding: 1px 4px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #173065;
  background: transparent;
  text-shadow:
    0 1px 1px rgba(255, 255, 255, 0.8),
    0 0 2px rgba(255, 255, 255, 0.6);
  pointer-events: none;
  white-space: nowrap;
}

.note.note-playing,
.bank-note.note-playing {
  transform: translateY(1px) scale(1.03);
  filter: brightness(1.04);
}

.bank-note.first-note-hint-key {
  border-color: #8bcfef;
  box-shadow: 0 0 0 3px rgba(71, 177, 230, 0.2);
}

.bank-note.chromatic-black-note.first-note-hint-key {
  border: 0;
  box-shadow: 0 0 0 3px rgba(71, 177, 230, 0.28);
}

.bank-note.next-hint-key {
  animation: nextHintPulse 680ms ease;
}

.question-slot.hinting .question-card {
  animation: nextHintGlow 680ms ease;
}

.confetti-layer {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiDrop 900ms ease forwards;
}

.firework-flash {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.96) 0%, rgba(255, 247, 191, 0.82) 36%, rgba(255, 152, 86, 0.35) 66%, rgba(255, 152, 86, 0) 100%);
  box-shadow:
    0 0 0 2px rgba(255, 213, 136, 0.34),
    0 0 28px rgba(255, 226, 166, 0.7);
  opacity: 0;
  animation: fireworkFlash 820ms ease-out forwards;
}

@keyframes confettiDrop {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--dx, 0px), var(--dy, 120px), 0) rotate(var(--rot, 240deg));
  }
}

@keyframes fireworkFlash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.9);
  }
}

@keyframes questionJiggle {
  0% { transform: translateX(0) rotate(0deg); }
  22% { transform: translateX(-5px) rotate(-4deg); }
  48% { transform: translateX(4px) rotate(3deg); }
  72% { transform: translateX(-2px) rotate(-2deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

@keyframes nextHintPulse {
  0% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(1.06); filter: brightness(1.08); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes nextHintGlow {
  0% { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.85); }
  35% {
    box-shadow:
      inset 0 2px 0 rgba(255, 255, 255, 0.9),
      0 0 0 4px rgba(87, 168, 239, 0.25);
  }
  100% { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.85); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  :root {
    --tile-size: clamp(58px, 15vw, 76px);
    --bank-note-size: 84px;
    --bank-note-gap: 6px;
  }

  .top-ui {
    justify-content: center;
  }

  .toolbar {
    justify-content: center;
  }

  .score-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .outcome-dot {
    width: 16px;
    height: 16px;
  }

  .question-wrap {
    padding-inline: 4px;
  }
}

@media (max-width: 640px) {
  :root {
    --tile-size: clamp(54px, 17vw, 66px);
    --gap: 8px;
    --bank-note-size: clamp(64px, 19vw, 76px);
    --bank-note-gap: 8px;
    --dock-height: clamp(204px, 31vh, 226px);
    --dock-bg-height: clamp(72px, 12vh, 92px);
  }

  body {
    padding: 0;
  }

  .app {
    border-radius: 20px;
  }

  .screen {
    padding: calc(20px + env(safe-area-inset-top)) 14px calc(var(--dock-height) + env(safe-area-inset-bottom) + 12px);
  }

  .app-title {
    max-width: 100%;
    margin: 0 auto;
  }

  .settings-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    top: calc(66px + env(safe-area-inset-top));
    width: auto;
  }

  .play-center {
    margin: 0;
  }

  .play-circle {
    width: 100%;
    min-height: 64px;
  }

  .score-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .score-chip {
    min-width: 0;
    padding: 6px 4px;
  }

  .score-skip-btn {
    min-height: 52px;
    padding: 6px 4px;
  }

  .chip-label {
    font-size: 0.58rem;
  }

  .chip-value {
    font-size: 0.96rem;
  }

  .outcome-track {
    margin-bottom: 7px;
  }

  .outcome-track-head {
    margin-bottom: 7px;
  }

  .outcome-dot {
    width: 14px;
    height: 14px;
  }

  .message {
    min-height: 26px;
    margin: 3px 0 7px;
    font-size: 0.92rem;
  }

  .question-wrap {
    padding: 8px 0 0;
  }

  .question-grid.slots-3 {
    --tile-size: clamp(82px, 25vw, 92px);
    --gap: 9px;
  }

  .question-grid.slots-1 {
    --tile-size: clamp(138px, 46vw, 164px);
    --gap: 0;
  }

  .question-grid.slots-4 {
    --tile-size: clamp(64px, 19vw, 76px);
    --gap: 7px;
  }

  .question-grid.slots-5 {
    --tile-size: clamp(50px, 15vw, 62px);
    --gap: 6px;
  }

  .question-card {
    border-radius: 15px;
  }

  .question-face-front {
    font-size: 1.7rem;
  }

  .setting-row {
    grid-template-columns: 74px 1fr;
    gap: 6px;
  }

  .setting-row-slider {
    grid-template-columns: 74px 1fr 42px;
  }

  .mode-btn {
    min-width: 64px;
    padding-inline: 7px;
    font-size: 0.72rem;
  }

  .bank-grid.c-major-strip .bank-note .note-label {
    font-size: 0.66rem;
  }

  .bank-grid.c-major-strip {
    width: min(100%, calc((4 * var(--bank-note-size)) + (3 * var(--bank-note-gap))));
    margin-top: 0;
    display: grid;
    grid-template-columns: repeat(4, var(--bank-note-size));
    gap: var(--bank-note-gap);
    /* The name label is absolutely positioned at `top: 100%`, i.e. BELOW its
       own bell, so on a phone - where eight bells wrap to 4x2 - the first row's
       labels had only the 8px column gap to live in and struck the second row's
       bells. Row gap alone, so the columns stay as tight as they were.

       This gap ALONE never fixed it and could not: a bell stands 74px proud of
       its own cell, so clearing the label needs ~85px of gap, and the bank
       already ends 17px from the bottom of an iPhone. The gap is kept at this
       value because it is what keeps the pill below off the next bell's face -
       the actual fix is the reversed paint order in buildBank() plus that
       pill. Measured: 22px is the largest gap that still fits every label on a
       375x812 screen. */
    row-gap: calc(var(--bank-note-gap) + 15px);
    align-items: end;
    justify-content: center;
    padding: 0;
  }

  /* The label sits OVER the next row's bell head (there is nowhere else for it
     to go on a phone), so it carries its own backdrop and stops depending on
     whatever colour happens to be behind it. Pairs with the reversed paint
     order in buildBank(); without that this pill would still be buried. */
  .bank-grid.c-major-strip .bank-note .note-label {
    background: rgba(255, 255, 255, 0.94);
    border-radius: 999px;
    padding: 1px 7px;
    box-shadow: 0 1px 4px rgba(20, 28, 60, 0.22);
  }

  .bank-area:not(.chromatic-bank-area) {
    display: grid;
    place-items: center;
    overflow: visible;
    padding-top: 4px;
  }

  .bank-note {
    border-radius: 17px;
  }

  .bank-note .note-art {
    width: 90%;
    height: 84%;
    margin-top: -4px;
  }

  .bank-note .note-label {
    bottom: 4px;
  }

  .bank-area.chromatic-bank-area {
    overflow-x: auto;
    overflow-y: hidden;
  }

  .bank-grid.chromatic-piano {
    padding-top: 8px;
  }
}

@media (max-width: 360px) {
  :root {
    --tile-size: 51px;
    --gap: 6px;
    --bank-note-size: 68px;
    --bank-note-gap: 8px;
  }

  .question-grid.slots-3 {
    --tile-size: 82px;
    --gap: 9px;
  }

  .question-grid.slots-1 {
    --tile-size: 144px;
    --gap: 0;
  }

  .question-grid.slots-4 {
    --tile-size: 64px;
    --gap: 7px;
  }

  .question-grid.slots-5 {
    --tile-size: 50px;
    --gap: 6px;
  }

  .app-title {
    font-size: 1.42rem;
  }

  .settings-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  :root {
    --tile-size: clamp(48px, 11vh, 62px);
    --bank-note-size: clamp(52px, 15vh, 68px);
    --dock-height: clamp(132px, 34vh, 166px);
    --dock-bg-height: 52px;
  }

  .screen {
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  .score-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .question-wrap {
    max-width: 520px;
    margin: 0 auto;
  }
}

/* Free tier: a locked setting reads as "not yet", never as broken.
   It stays tappable (it opens the unlock wall). */
.mode-btn.is-locked { opacity: .72; }
.mode-btn .pmg-lock { margin-left: 4px; vertical-align: middle; }

/* Note names (1.0.2): a Do Re Mi label longer than its letters ("Lo Sol♯", "Hi Do/8")
   shrinks a little rather than overflow the bell. Never set in letters mode. */
.note-label.nn-long { scale: 0.84; }
