/* Etude — Manuscript theme. Mobile-first; tablet/desktop layered on with min-width. */

:root {
  --app-max-width: 1080px;
  --viewport-height: 100vh;
  --viewport-width: 100vw;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: var(--viewport-height, 100vh);
  display: flex;
  flex-direction: column;
  align-items: center;
  --page-pad: clamp(14px, 4vw, 40px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  padding:
    calc(var(--page-pad) + var(--safe-top))
    calc(var(--page-pad) + var(--safe-right))
    calc(var(--page-pad) + var(--safe-bottom))
    calc(var(--page-pad) + var(--safe-left));
  background:
    radial-gradient(120% 80% at 50% -10%, var(--paper-glow) 0%, transparent 60%),
    var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0;
  line-height: 1.12;
  font-weight: 500;
}

/* ----- Shell ----------------------------------------------------------- */

.app-shell {
  width: min(var(--app-max-width), 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(var(--space-md), 3vw, var(--space-xl));
}

/* ----- Buttons --------------------------------------------------------- */

.button {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 13px 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.button:active {
  transform: translateY(0);
}

.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button--start {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-accent);
}

.button--start:hover {
  background: var(--accent-strong);
}

.button.ghost {
  background: transparent;
  box-shadow: none;
  border-color: var(--line-strong);
  font-weight: 500;
}

.button[disabled],
.button[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ----- Mic sensitivity slider ----------------------------------------- */

.slider {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  flex: 1 1 260px;
  min-width: min(260px, 100%);
}

.slider__heading {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.slider__heading > span:first-child {
  font-weight: 600;
}

/* The dBFS readout is engineer-facing noise — hide it from the clean UI. */
.mic-meter {
  display: none;
}

.mic-calibration {
  flex: 1 1 80px;
  min-width: 80px;
  height: 8px;
  display: block;
}

.mic-calibration__track {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
  border: 1px solid var(--line);
}

.mic-calibration__fill {
  display: block;
  height: 100%;
  width: calc(var(--mic-calibration-level, 0.03) * 100%);
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.12s ease, background 0.2s ease;
}

.mic-calibration[data-below='true'] .mic-calibration__fill {
  background: var(--line-strong);
}

.mic-calibration[data-clipping='true'] .mic-calibration__fill {
  background: var(--error);
}

.mic-calibration[data-pulse='true'] .mic-calibration__fill {
  animation: micPulse 1.1s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.slider-track {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.slider input[type='range'] {
  --slider-value: 60;
  appearance: none;
  flex: 1 1 auto;
  min-width: 0;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) calc(var(--slider-value, 0) * 1%),
    var(--surface-sunken) calc(var(--slider-value, 0) * 1%),
    var(--surface-sunken) 100%
  );
  cursor: pointer;
}

.slider input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.slider input[type='range']::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 2px solid var(--accent);
}

.slider input[type='range'][disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.slider[data-disabled='true'] {
  opacity: 0.7;
}

#micSensitivityValue {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink-soft);
  min-width: 3ch;
  text-align: right;
}

/* ----- Mic indicator --------------------------------------------------- */

.mic-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.mic-indicator__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
}

.mic-indicator[data-state='listening'] .mic-indicator__dot { background: var(--accent); }
.mic-indicator[data-state='listening'] { color: var(--accent); border-color: var(--accent-tint); }
.mic-indicator[data-state='too-quiet'] .mic-indicator__dot { background: var(--gold); }
.mic-indicator[data-state='clipping'] .mic-indicator__dot { background: var(--error); }
.mic-indicator[data-state='requesting'] .mic-indicator__dot { background: var(--gold); animation: micPulse 1s ease-in-out infinite; }

/* ----- Switches (accidentals + sound) --------------------------------- */

.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-visual {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--line-strong);
  position: relative;
  flex: 0 0 auto;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-visual {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch-visual .switch-thumb {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-visual {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.switch-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.switch-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

.switch-sub {
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.switch--sound {
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
}

/* ----- View stack ------------------------------------------------------ */

.app-main {
  width: 100%;
}

.view-stack {
  position: relative;
  width: 100%;
  isolation: isolate;
}

/* Views are hidden by default; only the active one renders. This makes the
   3D flip's end-state correct no matter when its finalize callback fires. */
.view {
  display: none;
  width: 100%;
  transform-origin: center;
  backface-visibility: hidden;
}

.view.is-active {
  display: block;
}

.view--session.is-active {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.view[hidden] {
  display: none !important;
}

/* Directional screen transition: going deeper enters from the right, coming
   back from the left. Collapses to an instant cut under reduced motion. */
.view.is-active {
  animation: viewEnterFwd 320ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.view.is-active[data-nav-dir='back'] {
  animation-name: viewEnterBack;
}

@keyframes viewEnterFwd {
  from { opacity: 0; transform: translateX(26px); }
  to { opacity: 1; transform: none; }
}

@keyframes viewEnterBack {
  from { opacity: 0; transform: translateX(-26px); }
  to { opacity: 1; transform: none; }
}

/* Settings fades up gently — barely any travel, mostly a soft fade, so the
   change of place feels calm rather than jolty. Reduced motion cuts it. */
.view--setup.is-active {
  animation-name: viewSheetUp;
  animation-duration: 480ms;
  animation-timing-function: cubic-bezier(0.3, 0.6, 0.2, 1);
}

.view--home.is-active[data-nav-dir='back'] {
  animation-name: viewSettleDown;
  animation-duration: 420ms;
  animation-timing-function: cubic-bezier(0.3, 0.6, 0.2, 1);
}

@keyframes viewSheetUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes viewSettleDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ----- Cards / panels -------------------------------------------------- */

.session-stage,
.session-sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.field-helper {
  color: var(--ink-faint);
  font-size: 0.9rem;
  margin: 6px 0 0;
}

/* ----- Form ------------------------------------------------------------ */

.session-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.field-label,
legend.field-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0;
  padding: 0;
}

.field-helper {
  margin: 0;
}

.choice-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.choice-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  cursor: pointer;
  font-weight: 600;
  color: var(--ink-soft);
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
  flex: 1 1 auto;
  justify-content: center;
}

.choice-pill input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.choice-pill .clef-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.choice-pill[data-checked='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choice-pill:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.difficulty-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.choice-pills[data-choice-group='difficulty'] {
  gap: var(--space-xs);
}

.choice-pill--difficulty {
  flex: 1 1 0;
  min-width: 56px;
  padding: 12px;
  justify-content: center;
}

.choice-pill__glyph {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}

.description-output {
  color: var(--ink-faint);
  font-size: 0.88rem;
  margin: 0;
  min-height: 1.2em;
}

/* ----- Stepper --------------------------------------------------------- */

.stepper[data-disabled='true'] {
  opacity: 0.45;
}

.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-raised);
  overflow: hidden;
  width: fit-content;
  max-width: 100%;
}

.stepper__button {
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 1.3rem;
  width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.stepper__button:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.stepper__button[data-pressed='true'] {
  background: var(--accent-tint);
}

.stepper input[type='number'] {
  width: 64px;
  border: none;
  background: transparent;
  text-align: center;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  -moz-appearance: textfield;
}

.stepper input[type='number']::-webkit-inner-spin-button,
.stepper input[type='number']::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper input[type='number']:focus {
  outline: none;
}

.select-input {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background-color: var(--surface-raised);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.72rem 2.4rem 0.72rem 1rem;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23262119' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 0.7rem;
}

.select-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ----- Session view ---------------------------------------------------- */

.session-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.session-stage {
  padding: clamp(var(--space-md), 3vw, var(--space-xl));
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.staff-viewport {
  position: relative;
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  aspect-ratio: 16 / 7;
  min-height: 240px;
  max-height: 360px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

#staffCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ----- Play overlay ---------------------------------------------------- */

.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  background: var(--scrim);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.28s ease;
  z-index: 3;
}

.play-overlay[data-visible='true'] {
  opacity: 1;
}

.play-overlay[hidden] {
  display: none;
}

.play-overlay__button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 34px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  box-shadow: var(--shadow-accent);
  transition: transform 0.15s ease, background 0.2s ease;
}

.play-overlay__button:hover {
  transform: translateY(-1px);
  background: var(--accent-strong);
}

.play-overlay__icon {
  font-size: 1.8rem;
}

.play-overlay__label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
}

.play-overlay__status {
  color: var(--ink-soft);
  font-size: 0.85rem;
  min-height: 1em;
}

.play-overlay__status[data-empty='true'] {
  display: none;
}

/* ----- Note readouts --------------------------------------------------- */

/* The Target/Heard row ALWAYS occupies its space — content appearing here
   must never shove the keyboard down under a mid-tap finger. The chips sit
   as empty slots; only the values fade in. While hidden they must be fully
   invisible, not just dimmed: the Target chip holds the live answer. */
.note-readouts {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.note-readouts[data-visible='false'] .value {
  opacity: 0;
}

.note-readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  min-width: 92px;
}

.note-readout .label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.note-readout .value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--ink);
  min-height: 1.3em;
  transition: opacity 0.15s ease;
}

.heard-readout[data-visible='false'] .value {
  opacity: 0;
}

.heard-readout[data-status='success'] .value { color: var(--success); }
.heard-readout[data-status='error'] .value { color: var(--error); }

/* ----- Feedback splashes ---------------------------------------------- */

.feedback-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.feedback {
  position: absolute;
  width: 38%;
  max-width: 180px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.18s ease, transform 0.24s ease;
}

.feedback.is-active {
  opacity: 1;
  transform: scale(1);
}

/* ----- Session finale -------------------------------------------------- */

.session-finale {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: var(--scrim);
  backdrop-filter: blur(3px);
  z-index: 40;
}

.session-finale[hidden] {
  display: none;
}

.session-finale__card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(var(--space-xl), 5vw, var(--space-2xl));
  text-align: center;
  max-width: 420px;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
}

.session-finale__card.is-animating {
  animation: finalePop 0.4s ease;
}

@keyframes finalePop {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.session-finale__glyph {
  display: block;
  font-family: 'Noto Music', var(--font-display), serif;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.session-finale__title {
  text-transform: uppercase;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin: 0;
}

#sessionResultPrimary {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.25;
  color: var(--ink);
  margin: 10px 0 0;
}

.finale-correct {
  color: var(--accent);
}

#sessionResultSecondary {
  color: var(--ink-faint);
  font-size: 0.9rem;
  margin: 12px 0 0;
  font-variant-numeric: tabular-nums;
}

.session-finale__note {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 16px 0 0;
}

/* ----- Sidebar: scoreboard + review ----------------------------------- */

.session-sidebar {
  padding: clamp(var(--space-md), 3vw, var(--space-lg));
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: var(--space-sm);
}

.score-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}

.score-item .label {
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.score-item .value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

#scoreCorrect {
  color: var(--accent);
}

.review[hidden] {
  display: none;
}

.review-header h3 {
  font-size: 1.15rem;
}

.review-header p {
  color: var(--ink-faint);
  font-size: 0.85rem;
  margin: 4px 0 var(--space-sm);
}

.review-list {
  list-style: none;
  margin: 0 0 var(--space-md);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.review-list button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 11px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-raised);
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.review-list button:hover {
  border-color: var(--accent);
}

.review-list button[data-active='true'] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.review-count {
  font-size: 0.78rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.review-empty {
  color: var(--ink-faint);
  font-size: 0.88rem;
  padding: var(--space-sm) 0;
}

/* ----- Tuner ----------------------------------------------------------- */

.tuner {
  margin-top: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: clamp(var(--space-lg), 4vw, var(--space-2xl));
}

.tuner__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.tuner__intro h3 {
  font-size: 1.25rem;
}

.tuner__hint {
  color: var(--ink-faint);
  font-size: 0.88rem;
  margin: 4px 0 0;
  max-width: 46ch;
}

.tuner__hint[data-state='error'] {
  color: var(--error);
}

.tuner__body {
  display: none;
  margin-top: var(--space-lg);
  flex-direction: column;
  gap: var(--space-md);
}

.tuner__body[data-active='true'] {
  display: flex;
}

.tuner__display {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
}

.tuner__note {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 3.2rem;
  line-height: 0.9;
  color: var(--ink);
}

.tuner__octave {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

.tuner__readout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-left: 8px;
  margin-bottom: 5px;
}

.tuner__cents {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.tuner__status {
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.tuner__readout[data-state='in'] .tuner__cents,
.tuner__readout[data-state='in'] .tuner__status {
  color: var(--accent);
}

.tuner__readout[data-state='off'] .tuner__cents,
.tuner__readout[data-state='off'] .tuner__status {
  color: var(--gold-text);
}

.tuner__gauge {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
}

.tuner__gauge-center {
  position: absolute;
  left: 50%;
  top: -5px;
  bottom: -5px;
  width: 2px;
  background: var(--line-strong);
  transform: translateX(-50%);
}

.tuner__needle {
  position: absolute;
  top: 50%;
  left: calc(50% + (var(--cents, 0) * 1%));
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink-faint);
  transform: translate(-50%, -50%);
  transition: left 0.08s linear, background 0.15s ease;
}

.tuner__gauge[data-state='in'] .tuner__needle {
  background: var(--accent);
}

.tuner__gauge[data-state='off'] .tuner__needle {
  background: var(--gold);
}

.tuner__scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
}

.tuner__ref {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.tuner__ref-label {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.tuner__ref .stepper input {
  width: 56px;
}

.tuner__ref-unit {
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.tuner__match {
  margin-left: auto;
}

/* ----- Input mode toggle ---------------------------------------------- */

.input-mode {
  display: flex;
  width: 100%;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-raised);
}

.input-mode__option {
  flex: 1 1 0;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.input-mode__option[data-active='true'] {
  background: var(--accent);
  color: var(--on-accent);
}

.input-mode__option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ----- On-screen keyboard --------------------------------------------- */

.keyboard {
  position: relative;
  display: none;
  margin-top: var(--space-md);
  max-width: 560px;
  margin-inline: auto;
  width: 100%;
}

.keyboard[data-visible='true'] {
  display: block;
}

.keyboard__whites {
  display: flex;
  gap: 4px;
}

.key {
  cursor: pointer;
  font-family: var(--font-body);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.key--white {
  flex: 1 1 0;
  min-width: 0;
  height: 132px;
  background: var(--key-white);
  border: 1px solid var(--key-white-edge);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--key-label);
  transition: background 0.1s ease, color 0.1s ease;
}

.key--white[data-pressed='true'],
.key--white:active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.keyboard__blacks {
  position: absolute;
  inset: 0 0 auto 0;
  height: 82px;
  pointer-events: none;
}

.key--black {
  position: absolute;
  top: 0;
  width: 9%;
  height: 82px;
  background: var(--key-black);
  border: 1px solid #15110b;
  border-top: none;
  border-radius: 0 0 6px 6px;
  pointer-events: auto;
  box-shadow: 0 3px 6px rgba(43, 38, 32, 0.3);
}

.key--black[data-pressed='true'],
.key--black:active {
  background: var(--accent-strong);
}

/* ----- Tablet ---------------------------------------------------------- */

/* ----- Desktop --------------------------------------------------------- */

/* Two-column session (staff + scoreboard side by side). The stage needs
   ~650px before the fixed sidebar fits alongside it, so this must not kick
   in below ~1000px — at 680px it used to overflow the viewport by ~240px
   (iPad portrait, small laptop windows). min-width: 0 lets the stage shrink
   inside the row instead of forcing the layout wider than the screen. */
@media (min-width: 1000px) {
  .session-layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .session-stage {
    flex: 1 1 auto;
    min-width: 0;
  }

  .session-sidebar {
    flex: 0 0 300px;
  }
}

/* ======================================================================= */
/* Note Invaders game mode                                                 */
/* ======================================================================= */

/* While the game is open it takes over the screen: hide the app header and
   the practice views, leaving only #gameView. */
body[data-game-active='true'] #homeView,
body[data-game-active='true'] #setupView,
body[data-game-active='true'] #sessionView {
  display: none !important;
}

.view--game.is-active {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
}

.ni {
  width: 100%;
}

.ni-screen[hidden] {
  display: none !important;
}

/* ----- Intro + game-over (shared centring) ---------------------------- */

.ni-intro,
.ni-over {
  width: min(560px, 100%);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
  min-height: calc(var(--viewport-height, 100dvh) - clamp(40px, 12vw, 120px));
  padding: 24px 0;
}

.ni-intro {
  gap: 22px;
}

.ni-eyebrow {
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.68rem;
  color: var(--accent);
}

.ni-sample {
  position: relative;
  width: 150px;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0;
}

.ni-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.4rem, 9vw, 3.4rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}

.ni-howto {
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.6;
  max-width: 34ch;
  margin: 0;
  text-wrap: pretty;
}

/* Circular home icon replacing the "Back to home" text buttons. */
.ni-home {
  appearance: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-top: 4px;
  transition: color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.ni-home:hover {
  color: var(--ink);
  border-color: var(--ink-faint);
}

.ni-home:active {
  transform: translateY(1px);
}

.ni-error {
  color: var(--error);
  font-size: 0.9rem;
  margin: 0;
}

.ni-error[hidden] {
  display: none;
}

.ni-start {
  margin-top: 8px;
}

.ni-ghost {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9rem;
  min-height: 40px;
  padding: 8px 12px;
  cursor: pointer;
}

/* ----- In-play layout ------------------------------------------------- */

.ni-play {
  width: min(760px, 100%);
  margin-inline: auto;
  height: calc(var(--viewport-height, 100dvh) - clamp(28px, 8vw, 80px));
  max-height: 820px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* HUD */
.ni-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ni-hud__left {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ni-hud__mode {
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.62rem;
  color: var(--ink-faint);
}

.ni-wave {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: capitalize;
}

.ni-wave__glyph {
  font-family: 'Noto Music', serif;
  font-size: 1.05rem;
  color: var(--accent);
  line-height: 1;
}

.ni-hud__right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ni-score {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 16px;
  border-radius: 16px;
  background: var(--surface-sunken);
  min-width: 84px;
}

.ni-score__label {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ni-score__value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ni-lives {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
}

.ni-lives__label {
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ni-lives__row {
  display: flex;
  gap: 5px;
}

.ni-heart {
  font-size: 1.05rem;
  line-height: 1;
  color: var(--error);
  transition: color 0.3s ease, opacity 0.3s ease;
}

.ni-heart.is-lost {
  color: var(--line-strong);
  opacity: 0.45;
}

/* ----- Stage ---------------------------------------------------------- */

.ni-stage {
  position: relative;
  flex: 1 1 0;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background-color: var(--surface-raised);
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(43, 38, 32, 0.045) 0 1px,
    transparent 1px 60px
  );
}

.ni-danger {
  position: absolute;
  left: 0;
  right: 0;
  top: 80%;
  border-top: 1.5px dashed rgba(168, 65, 47, 0.5);
  z-index: 1;
}

.ni-danger[hidden] {
  display: none;
}

.ni-danger span {
  position: absolute;
  right: 14px;
  top: -9px;
  background: var(--surface-raised);
  padding: 0 8px;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--error);
}

.ni-quit {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  min-height: 40px;
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.ni-quit:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.ni-invaders {
  position: absolute;
  inset: 0;
}

.ni-beams {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.ni-beam {
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  animation: ni-beam-fade 0.34s ease forwards;
  filter: drop-shadow(0 0 3px rgba(28, 107, 96, 0.6));
}

.ni-splashes {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.ni-launcher {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  z-index: 4;
  pointer-events: none;
}

.ni-launcher__nib {
  width: 34px;
  height: 50px;
  color: var(--play);
  transform: rotate(var(--ni-tilt, 0deg));
  transition: transform 0.18s ease, filter 0.18s ease;
}

.ni-launcher__nib svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ni-launcher__nib.is-firing {
  filter: drop-shadow(0 0 8px rgba(176, 125, 39, 0.55));
}

.ni-launcher__base {
  width: 96px;
  height: 11px;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--line-strong);
}

/* ----- Invaders ------------------------------------------------------- */

.ni-invader {
  position: absolute;
  transform: translate(-50%, -50%);
  transition: top 0.18s linear; /* kept in sync with TICK_MS via inline style */
  z-index: 2;
  cursor: pointer;
}

.ni-invader.is-target {
  z-index: 3;
}

.ni-invader__inner {
  animation: ni-float 4.6s ease-in-out infinite;
  animation-delay: var(--ni-delay, 0s);
}

.ni-invader.is-flicker .ni-invader__inner {
  animation: ni-shake 0.42s ease;
}

.ni-invader__stack {
  position: relative;
  width: 112px;
  height: 108px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ni-invader__motif {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Noto Music', serif;
  font-size: 26px;
  color: var(--accent);
  z-index: 2;
}

.ni-creature {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.ni-creature--origami {
  width: 140px;
  height: 140px;
  clip-path: polygon(50% 2%, 98% 50%, 50% 98%, 2% 50%);
  background: linear-gradient(135deg, #6fa39a 0 50%, var(--accent) 50% 100%);
}

.ni-creature--inkblot {
  width: 150px;
  height: 138px;
  border-radius: 62% 38% 47% 53% / 58% 49% 51% 42%;
  background: var(--accent);
}

.ni-creature--motif {
  width: 142px;
  height: 142px;
  border-radius: 50%;
  background: var(--surface);
  border: 2.5px solid var(--accent);
}

.ni-invader.is-target .ni-creature {
  box-shadow: 0 0 0 3px rgba(28, 107, 96, 0.16), 0 10px 22px rgba(28, 107, 96, 0.2);
}

/* ----- Note badge ----------------------------------------------------- */

.ni-badge {
  position: relative;
  z-index: 1;
  width: 112px;
  height: 108px;
  /* A note badge is a little card of daylight paper in BOTH themes — its
     staff lines and note keep daytime ink so it reads like sheet music
     against a dark stage. Pinned values, not theme tokens. */
  --badge-note: #1c6b60;
  --badge-note-strong: #15564d;
  background: #fffdf6;
  border-radius: 14px;
  box-shadow: 0 4px 13px rgba(43, 38, 32, 0.24);
}

.ni-badge__clef {
  position: absolute;
  left: 8px;
  top: 45px; /* staff-region centre (staff top 10 + region centre 35) */
  transform: translateY(-50%);
  font-family: 'Noto Music', serif;
  font-size: 48px;
  line-height: 1;
  color: var(--badge-note-strong);
}

.ni-badge__staff {
  position: absolute;
  left: 38px;
  right: 13px;
  top: 10px;
  height: 70px;
}

.ni-badge__line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1.6px;
  background: rgba(43, 38, 32, 0.85);
}

.ni-badge__ledger {
  position: absolute;
  left: calc(48% - 5px);
  width: 29px;
  height: 1.8px;
  background: rgba(43, 38, 32, 0.85);
}

.ni-badge__band {
  position: absolute;
  left: -4px;
  right: -4px;
  height: 14px;
  border-radius: 5px;
  background: rgba(28, 107, 96, 0.16);
}

.ni-badge__head {
  position: absolute;
  left: 48%;
  width: 19px;
  height: 14px;
  border-radius: 50%;
  background: var(--badge-note);
  transform: rotate(-18deg);
}

.ni-badge__stem {
  position: absolute;
  left: 58%;
  width: 2.6px;
  height: 30px;
  background: var(--badge-note);
}

.ni-badge__acc {
  position: absolute;
  left: calc(48% - 17px);
  font-family: 'Noto Music', serif;
  font-size: 20px;
  line-height: 1;
  color: var(--badge-note-strong);
}

/* ----- Splash --------------------------------------------------------- */

.ni-splash {
  position: absolute;
  transform: translate(-50%, -50%);
}

.ni-splash__bloom {
  position: relative;
  width: 0;
  height: 0;
  animation: ni-splash-bloom 0.72s ease forwards;
}

.ni-splash__blob {
  position: absolute;
}

.ni-splash__blob--a {
  left: -31px;
  top: -27px;
  width: 62px;
  height: 54px;
  border-radius: 58% 42% 49% 51% / 55% 50% 50% 45%;
  background: var(--accent);
  opacity: 0.92;
}

.ni-splash__blob--b {
  left: 18px;
  top: -22px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.8;
}

.ni-splash__blob--c {
  left: -30px;
  top: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-strong);
  opacity: 0.75;
}

.ni-splash__blob--d {
  left: 24px;
  top: 16px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
}

.ni-splash__blob--e {
  left: -2px;
  top: -34px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-strong);
  opacity: 0.7;
}

.ni-splash__note {
  position: absolute;
  font-family: 'Noto Music', serif;
  color: var(--gold);
  animation: ni-note-drift 0.72s ease forwards;
}

.ni-splash__note--l {
  left: -26px;
  top: -30px;
  font-size: 16px;
  --dx: -16px;
  --dr: -25deg;
}

.ni-splash__note--r {
  left: 18px;
  top: -28px;
  font-size: 14px;
  --dx: 14px;
  --dr: 22deg;
}

/* ----- Input region (mode toggle + mic panel + keyboard) -------------- */

.ni-input {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ni-modes {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-raised);
  align-self: center;
}

.ni-modes__note {
  margin: 6px 0 0;
  align-self: center;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--error);
}

.ni-mode {
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.ni-mode[data-active='true'] {
  background: var(--accent);
  color: var(--on-accent);
}

.ni-mic {
  max-width: 560px;
  margin-inline: auto;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ni-mic[hidden] {
  display: none;
}

.ni-mic__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ni-mic__listening {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.ni-mic__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: ni-mic-pulse 1.1s ease-in-out infinite;
}

.ni-mic__heard {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}

.ni-mic__heard-label {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ni-mic__heard-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--ink);
}

.ni-mic__heard-value[data-status='success'] {
  color: var(--accent);
}

.ni-mic__heard-value[data-status='error'] {
  color: var(--error);
}

.ni-mic__bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--line);
  overflow: hidden;
}

.ni-mic__bar-fill {
  height: 100%;
  width: 46%;
  background: var(--accent);
  border-radius: 999px;
  animation: ni-mic-pulse 1.4s ease-in-out infinite;
}

.ni-mic__hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-faint);
}

.ni-keyboard {
  position: relative;
  max-width: 560px;
  margin-inline: auto;
  width: 100%;
}

.ni-keyboard[hidden] {
  display: none;
}

.ni-keyboard__whites {
  display: flex;
  gap: 4px;
}

.ni-key {
  font-family: var(--font-body);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ni-key--white {
  flex: 1 1 0;
  min-width: 0;
  height: 104px;
  border: 1px solid var(--line-strong);
  border-top: none;
  border-radius: 0 0 10px 10px;
  background: var(--key-white);
  border-color: var(--key-white-edge);
  color: var(--key-label);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}

.ni-key--white[data-pressed='true'],
.ni-key--white:active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.ni-keyboard__blacks {
  position: absolute;
  inset: 0 0 auto 0;
  height: 64px;
  pointer-events: none;
}

.ni-key--black {
  position: absolute;
  top: 0;
  width: 9%;
  height: 64px;
  background: var(--key-black);
  border: 1px solid #15110b;
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 3px 6px rgba(43, 38, 32, 0.3);
  pointer-events: auto;
  transition: background 0.1s ease;
}

.ni-key--black[data-pressed='true'],
.ni-key--black:active {
  background: var(--accent-strong);
}

/* ----- Game over card ------------------------------------------------- */

.ni-over__card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(32px, 6vw, 44px);
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.ni-over__glyph {
  display: block;
  font-family: 'Noto Music', serif;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 12px;
}

.ni-over__eyebrow {
  text-transform: uppercase;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  margin: 0;
}

.ni-over__score {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  line-height: 1.2;
  color: var(--ink);
  margin: 10px 0 0;
}

.ni-over__score span {
  color: var(--accent);
}

.ni-over__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 22px 0 0;
}

.ni-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface-sunken);
}

.ni-stat__label {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ni-stat__value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.ni-stat__value--accent {
  color: var(--accent);
}

.ni-over__note {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 22px 0 0;
  text-wrap: pretty;
}

.ni-over__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.ni-over__again,
.ni-over__back {
  width: 100%;
  justify-content: center;
}

/* ----- Game keyframes ------------------------------------------------- */

@keyframes ni-float {
  0%, 100% { transform: translateY(-5px); }
  50% { transform: translateY(5px); }
}

@keyframes ni-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@keyframes ni-beam-fade {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes ni-splash-bloom {
  0% { transform: scale(0.35); opacity: 0; }
  28% { opacity: 1; }
  100% { transform: scale(1.18); opacity: 0; }
}

@keyframes ni-note-drift {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translate(var(--dx), -34px) rotate(var(--dr)); opacity: 0; }
}

@keyframes ni-mic-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@media (min-width: 680px) {
  .ni-howto {
    font-size: 1.05rem;
  }
}

/* ======================================================================= */
/* Overhaul shell — Home hub, configuring setup, contextual session bar    */
/* ======================================================================= */

/* Per-screen page tone. Setup gets a deeper "configuring" paper + teal wash. */
body[data-screen='setup'] {
  background:
    radial-gradient(140% 60% at 50% 0%, rgba(28, 107, 96, 0.06) 0%, transparent 58%),
    var(--paper-deep);
}

.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.icon-button--back {
  width: 40px;
  height: 40px;
  background: var(--surface);
}

/* ----- Home hub -------------------------------------------------------- */

.view--home.is-active,
.view--setup.is-active {
  display: flex;
  justify-content: center;
}

.home {
  position: relative;
  width: min(440px, 100%);
  margin-inline: auto;
  min-height: calc(var(--viewport-height, 100dvh) - clamp(40px, 12vw, 110px));
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 14px 0 20px;
}

/* One enormous engraved clef bleeding off the edge — quiet, but not timid. */
.view--home {
  position: relative;
  overflow: hidden;
}

.view--home::before {
  content: '𝄞';
  position: absolute;
  right: -120px;
  top: -40px;
  font-family: 'Noto Music', serif;
  font-size: 470px;
  line-height: 1;
  color: var(--ink);
  opacity: 0.05;
  pointer-events: none;
}

.home__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

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


/* [hidden] has no UA default for SVG-namespace elements. */
[data-theme-icon][hidden] {
  display: none;
}

/* .switch sets display:flex, which would defeat the hidden attribute the
   ledger-drill switch relies on. */
.switch[hidden] {
  display: none;
}

.wordmark {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

/* The mark itself (design/logo/etude-logo.svg): off-white letters for dark,
   ink letters for light; the teal swash is shared. */
.wordmark {
  --logo-w: min(272px, 82%);
}

.wordmark__logo {
  display: block;
  width: var(--logo-w);
  height: auto;
}

.wordmark__logo--dark {
  display: none;
}

:root[data-theme='dark'] .wordmark__logo--light {
  display: none;
}

:root[data-theme='dark'] .wordmark__logo--dark {
  display: block;
}

.wordmark__sub {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  /* Right-aligned under the mark, ending flush with the final E — as in
     the reference lockup. */
  width: var(--logo-w);
  text-align: right;
  white-space: nowrap;
}

.home__doors {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.door {
  position: relative;
  overflow: hidden;
  text-align: left;
  border-radius: 26px;
  padding: 24px;
  cursor: pointer;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.door:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.door--practice {
  border: 1px solid var(--accent-tint);
}

/* The Play door is the warm one: gold-washed beige by day, a lifted ink
   card with gold by night. */
.door--play {
  border: 1px solid rgba(176, 125, 39, 0.45);
  background-color: #eee2c3;
  /* Depth instead of stripes: a soft gold light pooling in the top corner. */
  background-image: radial-gradient(130% 90% at 85% -10%, rgba(217, 168, 84, 0.3) 0%, transparent 55%);
}

.door--play .door__eyebrow {
  color: var(--gold-text);
}

:root[data-theme='dark'] .door--play {
  background-color: #352c1d;
  border-color: rgba(217, 168, 84, 0.45);
  box-shadow: 0 0 0 1px rgba(217, 168, 84, 0.12), 0 10px 30px rgba(0, 0, 0, 0.45);
}

:root[data-theme='dark'] .door--play .door__title {
  color: #f1e9d7;
}

:root[data-theme='dark'] .door--play .door__title-sub {
  color: #cfc5ad;
}

:root[data-theme='dark'] .door--play .door__desc {
  color: #b3a98f;
}

:root[data-theme='dark'] .door--play .door__eyebrow {
  color: #d9a854;
}

.door__bg-glyph {
  position: absolute;
  right: -18px;
  top: -30px;
  font-family: 'Noto Music', serif;
  font-size: 170px;
  line-height: 1;
  color: var(--accent);
  opacity: 0.12;
  pointer-events: none;
}

.door__motifs {
  position: absolute;
  right: 16px;
  top: 8px;
  display: flex;
  gap: 3px;
  align-items: flex-start;
}

.door__motif {
  font-family: 'Noto Music', serif;
  line-height: 1;
  color: var(--gold);
}

.door__motif--1 { font-size: 2.3rem; opacity: 0.75; }
.door__motif--2 { font-size: 3.3rem; opacity: 0.4; }

.door__eyebrow {
  font-family: var(--font-body);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.door--practice .door__eyebrow { color: var(--accent); }
.door--play .door__eyebrow { color: var(--gold-text); }

.door__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--ink);
  margin-top: 2px;
}

/* Small caps in the body face — the small serif was hard to read. */
.door__title-sub {
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  vertical-align: 0.28em;
}

.door__desc {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink-faint);
  max-width: 26ch;
}

/* "Last: 7/10 · Treble · Medium" — proof the Practice door remembers. */
.door__last {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--accent-strong);
  margin-top: 6px;
}

/* The CTA is a real pill — filled, glowing, tactile — not a text link. */
.door__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  margin-top: 14px;
  padding: 9px 26px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background-color: var(--accent);
  background-image: linear-gradient(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 55%);
  color: var(--on-accent);
  box-shadow: var(--shadow-accent), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 0.14s ease, box-shadow 0.18s ease;
}

.door:hover .door__cta {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(28, 107, 96, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.door:active .door__cta {
  transform: translateY(1px);
}

.door--play .door__cta {
  background-color: var(--gold-deep);
  color: var(--on-gold);
  box-shadow: 0 10px 26px rgba(217, 168, 84, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.door--play:hover .door__cta {
  box-shadow: 0 14px 32px rgba(217, 168, 84, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}



.home-tuner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 18px;
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.home-tuner:hover { border-color: var(--line-strong); }

.home-tuner__left {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.home-tuner__glyph {
  font-family: 'Noto Music', serif;
  font-size: 1.3rem;
  color: var(--ink-soft);
}

.home-tuner__ref {
  font-size: 0.8rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ----- Setup / configuring -------------------------------------------- */

.setup {
  width: min(460px, 100%);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 8px 0 28px;
}

.setup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setup__done {
  border-radius: 999px;
  padding: 9px 22px;
  font-weight: 600;
  flex: 0 0 auto;
}

.setup__eyebrow {
  font-family: var(--font-body);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.setup__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  color: var(--ink);
  line-height: 1.1;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field-group {
  flex: 1 1 0;
}

.setup__extras:empty {
  display: none;
}

.setup__extras {
  display: flex;
}

/* Tuner drops below "Begin practice" so the primary action is reachable
   without scrolling past it. */
.setup .tuner {
  margin-top: 0;
  order: 1;
}

.setup__footer {
  order: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.setup__begin {
  width: 100%;
  justify-content: center;
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.setup__summary {
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-faint);
  margin: 0;
}

/* ----- Contextual session bar ----------------------------------------- */

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.session-bar__mode {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.session-bar__glyph {
  font-family: 'Noto Music', serif;
  font-size: 1.3rem;
  color: var(--accent);
  flex: 0 0 auto;
}

.session-bar__label {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-bar__actions {
  display: flex;
  gap: 7px;
  flex: 0 0 auto;
}

.chip-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.chip-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chip-button--end {
  border-color: rgba(168, 65, 47, 0.4);
  background: var(--error-soft);
  color: var(--error);
}

.chip-button--end:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ----- Relocated mic panel (session, mic mode only) ------------------- */

.mic-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  margin-top: var(--space-sm);
  max-width: 560px;
  margin-inline: auto;
  width: 100%;
}

[data-input-mode='keyboard'] .mic-panel,
[data-input-mode='midi'] .mic-panel {
  display: none;
}

/* Mic problem line (permission denied, no device, dropped mid-session). */
.mic-status {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--error);
}

/* The slider was a flex item in the old horizontal header (flex-basis 260px);
   in the vertical mic panel that basis became 260px of dead height. Reset it
   and drop the now-redundant nested card chrome. */
.mic-panel .slider {
  width: 100%;
  flex: 0 0 auto;
  border: none;
  background: transparent;
  padding: 0;
}

.session-finale__actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

.session-finale__actions .button {
  width: 100%;
  justify-content: center;
}

/* ----- Note Invaders — play mode (gold secondary accent) -------------- */

.view--game {
  --play: var(--gold);
  --play-soft: var(--gold-soft);
}

.ni-eyebrow {
  color: var(--gold-text);
}

.ni-start {
  background: var(--gold-deep);
  border-color: var(--gold-deep);
  color: var(--on-gold);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 16px 44px;
  box-shadow: 0 12px 30px rgba(217, 168, 84, 0.4), 0 0 22px rgba(217, 168, 84, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.ni-start:hover {
  background: var(--gold-deep-hover);
  border-color: var(--gold-deep-hover);
}

/* The arcade plays at night in BOTH themes: an ink stage with faint staff
   rules and a gold glow rising from the launcher. The paper badges pop
   against it like sheet music under lamplight. */
.ni-stage {
  border-color: rgba(217, 168, 84, 0.28);
  background-color: #1d1710;
  background-image:
    radial-gradient(120% 85% at 50% 104%, rgba(217, 168, 84, 0.16) 0%, transparent 56%),
    repeating-linear-gradient(to bottom, rgba(232, 224, 203, 0.06) 0 1px, transparent 1px 56px);
}

.ni-stage.is-shaking {
  animation: ni-shake 0.32s ease;
}

.ni-stage.is-shaking-hard {
  animation: ni-shake-hard 0.42s ease;
}

@keyframes ni-shake {
  0%, 100% { transform: none; }
  25% { transform: translate(-4px, 1px); }
  50% { transform: translate(3px, -1px); }
  75% { transform: translate(-2px, 1px); }
}

@keyframes ni-shake-hard {
  0%, 100% { transform: none; }
  15% { transform: translate(-8px, 3px) rotate(-0.4deg); }
  35% { transform: translate(7px, -3px) rotate(0.4deg); }
  55% { transform: translate(-5px, 2px); }
  75% { transform: translate(3px, -1px); }
}

/* On the ink stage the quit chip and danger tag need night colours. */
.ni-quit {
  background: rgba(29, 23, 16, 0.85);
  border-color: rgba(232, 224, 203, 0.22);
  color: #cfc5ad;
}

.ni-quit:hover {
  color: #f1e9d7;
  border-color: rgba(232, 224, 203, 0.45);
}

.ni-danger {
  border-top-color: rgba(224, 122, 99, 0.65);
}

.ni-danger span {
  background: #1d1710;
  color: #e07a63;
}

/* Gold beam + hotter glows for the night stage. */
.ni-beam {
  stroke: #d9a854;
  filter: drop-shadow(0 0 6px rgba(217, 168, 84, 0.8));
}

.ni-launcher__nib {
  filter: drop-shadow(0 0 7px rgba(217, 168, 84, 0.4));
}

.ni-launcher__nib.is-firing {
  filter: drop-shadow(0 0 14px rgba(217, 168, 84, 0.9));
}

.ni-splash__note {
  color: #d9a854;
}

/* ×N streak chip in the HUD. */
.ni-streak {
  align-self: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(217, 168, 84, 0.5);
  background: var(--gold-soft);
  color: var(--gold-text);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.ni-streak.is-pulsing {
  animation: ni-streak-pulse 0.32s ease;
}

@keyframes ni-streak-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* "Wave N" splash between waves. */
.ni-wave-banner {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 5;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.9rem, 7vw, 2.8rem);
  color: #f1e9d7;
  text-shadow: 0 0 22px rgba(217, 168, 84, 0.55);
  pointer-events: none;
}

.ni-wave-banner[hidden] {
  display: none;
}

.ni-wave-banner.is-showing {
  animation: ni-wave-banner 1.1s ease forwards;
}

@keyframes ni-wave-banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  30% { transform: translate(-50%, -50%) scale(1); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(1.02); }
}

/* Floating "+120" score pop. */
.ni-score-pop {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 6;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  color: #d9a854;
  text-shadow: 0 0 10px rgba(217, 168, 84, 0.6);
  animation: ni-score-pop 0.8s ease forwards;
  pointer-events: none;
}

@keyframes ni-score-pop {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.8); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

.ni-score {
  background: var(--play-soft);
}

/* The inkblot invader carries the warm play accent; origami stays teal. */
.ni-creature--inkblot {
  background: var(--play);
}

.ni-invader.is-target .ni-creature {
  box-shadow: 0 0 0 3px rgba(176, 125, 39, 0.18), 0 10px 22px rgba(176, 125, 39, 0.2);
}

.ni-beam {
  stroke: var(--play);
  filter: drop-shadow(0 0 3px rgba(176, 125, 39, 0.6));
}

.ni-splash__blob--a,
.ni-splash__blob--b,
.ni-splash__blob--d {
  background: var(--play);
}

.ni-over__glyph,
.ni-over__score span {
  color: var(--play);
}

.ni-over__again {
  background: var(--gold-deep);
  border-color: var(--gold-deep);
  color: var(--on-gold);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(217, 168, 84, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.ni-over__again:hover {
  background: var(--gold-deep-hover);
  border-color: var(--gold-deep-hover);
}

/* Intro clef / speed selectors */
.ni-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 330px;
}

.ni-options__group {
  display: flex;
  gap: 6px;
}

.ni-option {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ni-option__glyph {
  font-family: 'Noto Music', serif;
  font-size: 1rem;
}

.ni-option[data-active='true'] {
  background: var(--play);
  border-color: var(--play);
  color: var(--on-gold);
}

/* Game-over "worth another look" review chips */
.ni-over__review {
  margin-top: 18px;
}

.ni-over__review[hidden] {
  display: none;
}

.ni-over__review-label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}

.ni-over__review-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* Treble clef reads teal, bass clef gold — so the clef is obvious at a glance. */
.ni-badge__clef--bass {
  color: #8a5f1a; /* pinned like the rest of the badge palette */
}

/* Mini staff badge for the game-over review (a scaled-down note card). */
.ni-review-badge {
  width: 69px;
  height: 67px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 9px;
}

.ni-review-badge .ni-badge {
  transform: scale(0.62);
  transform-origin: top left;
  box-shadow: none;
}

.ni-review-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ni-review-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ----- Reduced motion -------------------------------------------------- */

/* ----- Tactile pass ----------------------------------------------------
   Everything pressable presses: a subtle top-light gradient, a firmer
   shadow, and a 1px sink on :active. Selection states glow instead of just
   recolouring — more so at night. */

.button,
.icon-button,
.chip-button,
.stepper__button,
.choice-pill,
.input-mode__option,
.ni-option,
.ni-mode {
  transition: transform 0.12s ease, box-shadow 0.18s ease, background-color 0.15s ease,
    border-color 0.15s ease, color 0.15s ease;
}

.button:active,
.icon-button:active,
.chip-button:active,
.stepper__button:active,
.input-mode__option:active,
.ni-option:active,
.ni-mode:active {
  transform: translateY(1px);
}

.button--start,
.ni-start,
.ni-over__again {
  background-image: linear-gradient(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 55%);
  box-shadow: var(--shadow-accent), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.ni-start,
.ni-over__again {
  box-shadow: 0 10px 26px rgba(217, 168, 84, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.icon-button {
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

:root[data-theme='dark'] .icon-button {
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.choice-pill[data-checked='true'],
.input-mode__option[data-active='true'] {
  box-shadow: 0 0 0 3px var(--accent-soft), 0 4px 14px rgba(28, 107, 96, 0.16);
}

:root[data-theme='dark'] .choice-pill[data-checked='true'],
:root[data-theme='dark'] .input-mode__option[data-active='true'] {
  box-shadow: 0 0 0 3px var(--accent-soft), 0 0 18px rgba(87, 184, 165, 0.35);
}

.ni-option[data-active='true'] {
  box-shadow: 0 0 0 3px var(--gold-soft), 0 0 16px rgba(217, 168, 84, 0.3);
}

.door {
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.door:hover {
  border-color: var(--accent-tint);
}

.door--play:hover {
  border-color: rgba(217, 168, 84, 0.6);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.3), 0 0 26px rgba(217, 168, 84, 0.16);
}

/* Fraunces at its display optical size — high contrast, closer to the
   logo's Didone voice — where the type is big enough to carry it. */
.door__title {
  font-variation-settings: 'opsz' 144;
}

/* The game title wants clarity over flourish: solid weight, calmer cut. */
.ni-title {
  font-variation-settings: 'opsz' 60;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.setup__title,
.session-finale__title {
  font-variation-settings: 'opsz' 90;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    /* Without this, infinite loops (mic pulse, floating invaders) keep
       re-running at 0.01ms — a flicker, not a reduction. */
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
