/* ============================================================
   Read Trainer — sight-reading companion to the Chord Trainer.
   Base tokens, header and buttons mirror scoretrainer.css; the
   achievement modal mirrors /styles.css. Keep them in sync.
   ============================================================ */

:root {
  --ink: #0a0908;
  --ivory: #f2e9dc;
  --ivory-dim: #c9bfae;
  --gold: #c8a464;
  --gold-bright: #e4c584;
  --crimson: #a03b3b;
  --sage: #6b8e6b;
  --paper: #1a1614;
  --line: #2a2420;
  --gold-rgb: 200, 164, 100;
  --gold-bright-rgb: 228, 197, 132;

  --font-display: 'Playfair Display', 'Cormorant Garamond', serif;
  --font-body: 'Cormorant Garamond', serif;
  --font-mono: 'JetBrains Mono', monospace;

  --ease-fast: 0.15s ease;
  --ease: 0.2s ease;
  --ease-medium: 0.3s ease;
  --ease-slow: 0.4s ease;

  --radius-sm: 2px;
  --radius-md: 3px;
  --radius-lg: 4px;
  --radius-xl: 6px;
  --z-modal: 1000;
  --z-ach-toast: 2100;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

@media (min-width: 900px) {
  html { font-size: 110.5%; zoom: 0.9; }
}

html, body {
  background: var(--ink);
  color: var(--ivory);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-x: clip;    /* clip, not hidden alone: hidden breaks the sticky play dock */
}

body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(var(--gold-rgb), 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(160, 59, 59, 0.05), transparent 50%),
    var(--ink);
  background-attachment: fixed;
}

.app {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}

@media (max-width: 600px) {
  .app { padding: 1.5rem 0.75rem 4rem; }
}

/* ---------- generic buttons ---------- */

button {
  font-family: var(--font-body);
  font-size: 1rem;
  letter-spacing: 0.04em;
  background: transparent;
  color: var(--ivory);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--ease);
  padding: 0.7rem 1.2rem;
}
button:hover { background: var(--gold); color: var(--ink); }
button:disabled { opacity: 0.3; cursor: not-allowed; }
button:disabled:hover { background: transparent; color: var(--ivory); }

.primary-btn {
  background: var(--gold);
  color: var(--ink);
  font-weight: 500;
}
.primary-btn:hover { background: var(--gold-bright); }
.primary-btn.big {
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.95rem 2.4rem;
}

.ghost-btn {
  border: 1px solid var(--line);
  color: var(--ivory-dim);
  font-size: 0.92rem;
  padding: 0.55rem 1rem;
}
.ghost-btn:hover { border-color: var(--gold); background: transparent; color: var(--gold); }
.ghost-btn.small { font-size: 0.78rem; padding: 0.35rem 0.7rem; }
.ghost-btn.danger { border-color: rgba(160, 59, 59, 0.45); color: rgba(242, 233, 220, 0.7); }
.ghost-btn.danger:hover { border-color: var(--crimson); color: var(--crimson); background: transparent; }

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--gold);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(var(--gold-rgb), 0.4);
  transition: color var(--ease-fast);
}
.link-btn:hover { color: var(--gold-bright); background: transparent; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ivory-dim);
  background: transparent;
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold); background: transparent; }

/* ---------- views ---------- */

/* `.is-entering` is toggled by main.js right after a view becomes visible,
   so the fade restarts on every view switch (CSS animations only fire on
   class change, not on the [hidden]→visible transition). */
.view.is-entering {
  animation: viewFade var(--ease-medium);
}
@keyframes viewFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- achievements (mirrors /styles.css) ---------- */

.prog-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 8, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: 1rem;
}

.prog-modal-box {
  background: var(--paper);
  border: 1px solid var(--gold);
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.prog-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem 0.8rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.prog-modal-title {
  font-family: var(--font-body);
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--ivory);
}

.prog-modal-close {
  background: none;
  border: none;
  color: var(--ivory-dim);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.1rem;
}

.prog-modal-close:hover { color: var(--gold-bright); }

.prog-modal-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.ach-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--ivory-dim);
  margin-left: 0.5rem;
  font-weight: 400;
}

.ach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.6rem;
  padding: 0.5rem 1.2rem 1rem;
}

/* Section grouping (Common / Rare / Ultra-rare) */
.ach-section + .ach-section {
  border-top: 1px solid var(--line);
  margin-top: 0.4rem;
}

.ach-section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.9rem 1.2rem 0.15rem;
}

.ach-section-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

.ach-section-secret .ach-section-label { color: var(--gold); }
.ach-section-ultra  .ach-section-label {
  background: linear-gradient(90deg, var(--gold-bright), #fff, var(--gold-bright));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 4s linear infinite;
}

.ach-section-count {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--ivory-dim);
  letter-spacing: 0.06em;
}

.ach-section-blurb {
  padding: 0 1.2rem 0.4rem;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.78rem;
  color: var(--ivory-dim);
  opacity: 0.7;
  line-height: 1.3;
}

/* Sections list: stacked vertically (one column always). The wrapping into
   multiple per-row tiles happens inside each section's own .ach-grid. */
.ach-sections { display: block; }

.ach-tile {
  display: flex;
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(var(--gold-rgb), 0.02);
  align-items: center;
}

.ach-tile { position: relative; overflow: hidden; }

.ach-tile-locked { opacity: 0.45; }
.ach-tile-locked .ach-tile-icon { filter: grayscale(1); }

/* Secret (rare) — slight gold tint, opacity nudged up so it's enticing
   rather than dismissed. Light pulse on the icon to hint at the mystery. */
.ach-tile-secret {
  opacity: 0.75;
  border-color: rgba(var(--gold-rgb), 0.25);
  background: linear-gradient(135deg, rgba(var(--gold-rgb), 0.04), rgba(var(--gold-rgb), 0.01));
}
.ach-tile-secret .ach-tile-icon {
  font-family: var(--font-mono);
  color: var(--gold);
  font-weight: 600;
  filter: none;
  text-shadow: 0 0 8px rgba(var(--gold-rgb), 0.3);
  animation: secretPulse 3.2s ease-in-out infinite;
}
@keyframes secretPulse {
  0%, 100% { opacity: 0.7; text-shadow: 0 0 8px rgba(var(--gold-rgb), 0.3); }
  50%      { opacity: 1;   text-shadow: 0 0 14px rgba(var(--gold-rgb), 0.55); }
}
.ach-tile-secret .ach-tile-name {
  font-style: italic;
  color: var(--ivory-dim);
  letter-spacing: 0.15em;
}
.ach-tile-secret .ach-tile-desc {
  font-style: italic;
  color: var(--gold);
  opacity: 0.75;
}

/* Ultra-rare locked — deep aurora gradient, brighter shimmer, lock icon.
   Higher opacity than secrets so it visibly stands out as the prized tier.
   No name/desc revealed; the only honest signal is "Ultra-rare" + a lock. */
.ach-tile-ultra {
  opacity: 0.92;
  border-color: rgba(var(--gold-bright-rgb), 0.45);
  background:
    linear-gradient(135deg,
      rgba(var(--gold-bright-rgb), 0.10) 0%,
      rgba(160, 59, 59, 0.06) 50%,
      rgba(107, 142, 107, 0.08) 100%),
    rgba(10, 9, 8, 0.7);
  box-shadow: inset 0 0 20px rgba(var(--gold-bright-rgb), 0.06);
}
.ach-tile-ultra .ach-tile-icon {
  filter: none;
  color: var(--gold-bright);
  text-shadow: 0 0 14px rgba(var(--gold-bright-rgb), 0.5);
  animation: ultraFloat 3.2s ease-in-out infinite;
}
.ach-tile-ultra .ach-tile-name {
  font-family: var(--font-body);
  color: var(--ivory-dim);
}
.ach-tile-ultra .ach-tile-desc {
  font-style: italic;
  color: var(--gold);
  opacity: 0.85;
}
.ach-tile-tag {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.55rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--gold-bright), #fff, var(--gold-bright));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3.5s linear infinite;
  margin-bottom: 0.15rem;
}

@keyframes ultraFloat {
  0%, 100% { transform: translateY(0)    rotate(0);     }
  50%      { transform: translateY(-2px) rotate(-2deg); }
}

/* Sweep shimmer overlay used by both secret and ultra locked tiles */
.ach-tile-shimmer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    115deg,
    transparent 30%,
    rgba(var(--gold-bright-rgb), 0.10) 48%,
    rgba(255, 255, 255, 0.18) 50%,
    rgba(var(--gold-bright-rgb), 0.10) 52%,
    transparent 70%
  );
  background-size: 250% 100%;
  background-position: 100% 0;
  animation: tileShimmer 4.5s ease-in-out infinite;
  mix-blend-mode: screen;
}
.ach-tile-ultra .ach-tile-shimmer { animation-duration: 3.2s; opacity: 1.2; }

@keyframes tileShimmer {
  0%        { background-position: 120% 0; }
  60%, 100% { background-position: -40% 0; }
}

.ach-tile-unlocked {
  border-color: rgba(var(--gold-rgb), 0.4);
  background: rgba(var(--gold-rgb), 0.06);
}

.ach-tile-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
  width: 1.8rem;
  text-align: center;
}

.ach-tile-body { flex: 1; min-width: 0; }

.ach-tile-name {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ivory);
  font-weight: 500;
  line-height: 1.2;
}

.ach-tile-desc {
  font-size: 0.72rem;
  color: var(--ivory-dim);
  margin-top: 0.15rem;
  line-height: 1.3;
}

.ach-tile-progress {
  margin-top: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ach-tile-bar {
  flex: 1;
  height: 3px;
  background: var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ach-tile-fill {
  height: 100%;
  background: var(--gold);
  transition: width var(--ease-slow);
}

.ach-tile-progress-text {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--ivory-dim);
  letter-spacing: 0.04em;
}

.ach-mystery {
  text-align: center;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--ivory-dim);
  padding: 0.8rem 1.2rem 1rem;
  border-top: 1px solid var(--line);
  opacity: 0.7;
}

/* Desktop: nudge achievement typography up so the modal reads more comfortably
   on a wide monitor without changing the tile grid. */
@media (min-width: 900px) {
  .ach-tile-name          { font-size: 1.2rem; }
  .ach-tile-desc          { font-size: 0.86rem; }
  .ach-tile-icon          { font-size: 1.9rem; width: 2.1rem; }
  .ach-tile-progress-text { font-size: 0.74rem; }
  .ach-section-label      { font-size: 0.85rem; }
  .ach-section-blurb      { font-size: 0.92rem; }
  .ach-section-count      { font-size: 0.74rem; }
  .ach-count              { font-size: 0.85rem; }
}

.ach-modal-footer {
  padding: 0.7rem 1.2rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
}

.ach-reset-btn {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  padding: 0.32rem 0.8rem;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ivory-dim);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.ach-reset-btn:hover {
  color: var(--crimson);
  border-color: var(--crimson);
}

.ach-reset-btn.armed {
  color: var(--ink);
  background: var(--crimson);
  border-color: var(--crimson);
  font-weight: 500;
}

/* ---- Achievement unlock toast ---- */

.ach-toast {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  z-index: var(--z-ach-toast);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 1rem;
  background: var(--ink);
  border: 1px solid rgba(var(--gold-rgb), 0.45);
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6), 0 0 18px rgba(var(--gold-rgb), 0.12);
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
  max-width: 320px;
}

.ach-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.ach-toast-icon {
  font-size: 1.8rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(var(--gold-bright-rgb), 0.5));
}

.ach-toast-tier {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.ach-toast-name {
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--ivory);
  line-height: 1.2;
}

/* ---------- page footer ---------- */

.page-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}
.page-footer a { color: var(--gold); text-decoration: none; }
.page-footer a:hover { color: var(--gold-bright); }

/* ---------- toast / errors ---------- */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.8rem 1.4rem;
  background: var(--paper);
  border: 1px solid var(--crimson);
  border-radius: var(--radius-md);
  color: var(--ivory);
  font-size: 0.95rem;
  z-index: 2000;
  animation: toastIn 0.25s ease, toastOut 0.4s ease 3.5s forwards;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translate(-50%, 12px); }
}

/* ==================== READ TRAINER ==================== */

:root {
  --ink-paper: #fbf8f1;
  --note-current: #b07d1f;
  --note-hit: #2f7d4a;
  --note-good: #c9821a;
  --note-miss: #b3322f;
}

[hidden] { display: none !important; }

/* ---------- hero + level map ---------- */

.hero { text-align: center; max-width: 660px; margin: 0 auto 2.6rem; }
.hero-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 2.5rem;
  line-height: 1.15;
  margin-bottom: 1rem;
}
.hero-title em { color: var(--gold); }
.hero-sub { font-size: 1.15rem; line-height: 1.55; color: var(--ivory-dim); }
.hero-sub a { color: var(--gold); }
.hero-sub strong { color: var(--ivory); font-weight: 500; }
.hero-stats {
  margin-top: 1.3rem;
  display: inline-flex;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ivory-dim);
}
.hero-stats strong { color: var(--gold); font-weight: 500; }

.level-grid {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.8rem;
}
.level-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 60%, transparent);
  color: var(--ivory);
}
.level-card:hover { background: rgba(var(--gold-rgb), 0.07); border-color: var(--gold); color: var(--ivory); }
.level-card.is-rep { border-color: rgba(var(--gold-rgb), 0.45); background: rgba(var(--gold-rgb), 0.05); }
.level-card.is-gold { box-shadow: inset 0 0 0 1px rgba(var(--gold-bright-rgb), 0.35); }
.level-card.is-locked { opacity: 0.42; cursor: not-allowed; }
.level-card.is-locked:hover { background: color-mix(in srgb, var(--paper) 60%, transparent); border-color: var(--line); }
.level-card.shake { animation: shake 0.35s; }
@keyframes shake {
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}
.lc-num {
  flex: 0 0 2.2rem;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  font-family: var(--font-display);
  color: var(--gold);
}
.lc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.lc-name { font-family: var(--font-display); font-size: 1.02rem; }
.lc-blurb { font-size: 0.95rem; color: var(--ivory-dim); line-height: 1.3; }
.lc-stars { flex: 0 0 auto; white-space: nowrap; }
.lc-lock { font-size: 1rem; filter: grayscale(1); }

.star { color: rgba(242, 233, 220, 0.18); font-size: 1rem; }
.star.on { color: var(--gold-bright); text-shadow: 0 0 10px rgba(var(--gold-bright-rgb), 0.35); }

/* ---------- play view ---------- */

.play-head { display: flex; align-items: center; gap: 1.2rem; margin-bottom: 1.2rem; }
.play-title { flex: 1; min-width: 0; }
.play-eyebrow {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}
.play-name { font-size: 1.5rem; font-family: var(--font-display); margin-top: 0.15rem; }
.play-sub { font-family: var(--font-body); font-style: italic; font-size: 1.05rem; color: var(--ivory-dim); margin-left: 0.4rem; }
.play-stars .star { font-size: 1.25rem; }

.play-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.8rem 1.6rem; margin-bottom: 1rem; }
.mode-toggle { display: inline-flex; border: 1px solid var(--gold); border-radius: var(--radius-md); overflow: hidden; }
.mode-btn {
  border: none;
  border-right: 1px solid var(--line);
  border-radius: 0;
  padding: 0.5rem 1.2rem;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}
.mode-btn:last-child { border-right: none; }
.mode-btn:hover { background: rgba(var(--gold-bright-rgb), 0.06); color: var(--ivory); }
.mode-btn.active { background: rgba(var(--gold-bright-rgb), 0.14); color: var(--gold); box-shadow: inset 0 -2px 0 var(--gold); }

.tempo-ctl, .check-ctl { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.ctl-label { font-family: var(--font-display); font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ivory-dim); }
.tempo-target { font-family: var(--font-mono); font-size: 0.72rem; color: var(--gold); opacity: 0.8; }
.bpm-unit { font-size: 0.8em; color: var(--ivory-dim); }
.check-ctl input { accent-color: var(--gold); width: 1rem; height: 1rem; }
.check-ctl span { font-size: 1rem; color: var(--ivory-dim); }

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  height: 2px;
  background: var(--line);
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--gold); cursor: pointer; border: none;
}
.slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--gold); cursor: pointer; border: none; }
.slider-val { font-family: var(--font-mono); font-size: 0.85rem; min-width: 5.5em; }

/* ---------- score ---------- */

.score-stage { position: relative; margin-bottom: 1rem; }
.score-paper {
  position: relative;
  background: var(--ink-paper);
  border-radius: var(--radius-md);
  padding: 1.2rem 1rem 0.6rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  min-height: 220px;
  transition: box-shadow 0.2s;
}
.score-render { width: 100%; }
.score-render svg { display: block; }
.flash-wrong .score-paper { animation: flashWrong 0.35s; }
@keyframes flashWrong {
  0% { box-shadow: 0 0 0 3px var(--note-miss), 0 18px 50px rgba(0, 0, 0, 0.45); }
  100% { box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45); }
}

.score-render .vf-stavenote { transition: opacity 0.25s; }
.score-render .is-current * { fill: var(--note-current); stroke: var(--note-current); }
.score-render .is-hit * { fill: var(--note-hit); stroke: var(--note-hit); }
.score-render .is-good * { fill: var(--note-good); stroke: var(--note-good); }
.score-render .is-miss * { fill: var(--note-miss); stroke: var(--note-miss); }
.score-render .is-hidden { opacity: 0.04; }

.cursor {
  position: absolute;
  width: 3px;
  margin-left: -1.5px;
  background: rgba(176, 125, 31, 0.55);
  border-radius: 2px;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(176, 125, 31, 0.35);
  transition: left 0.12s ease, top 0.2s ease;
}
.is-running .cursor { transition: none; }

.countin {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 6rem;
  color: rgba(176, 125, 31, 0.5);
  pointer-events: none;
}

.status-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; min-height: 2rem; }
.status { font-size: 1.1rem; color: var(--ivory-dim); }
.status .wrong { color: #e06c69; font-family: var(--font-mono); }
.status .good { color: var(--sage); }
.status kbd, .results kbd {
  font-family: var(--font-mono);
  font-size: 0.75em;
  border: 1px solid var(--line);
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
}
.heard { font-family: var(--font-mono); font-size: 0.85rem; color: var(--gold); white-space: nowrap; }

/* Status and Start / Restart stick to the bottom of the screen. */
.play-dock {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin: 0 -0.5rem;
  padding: 0.5rem 0.5rem calc(0.6rem + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--ink) 0.8rem);
}
.play-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 0.8rem; margin-top: 0.4rem; }
.restart-hint { flex: 1; min-width: 12rem; font-size: 0.95rem; font-style: italic; color: var(--ivory-dim); }

/* ---------- results ---------- */

.results {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 9, 8, 0.72);
  backdrop-filter: blur(2px);
  border-radius: var(--radius-md);
  padding: 1rem;
  animation: viewFade 0.3s ease;
}
.results-card {
  background: var(--paper);
  border: 1px solid var(--gold);
  padding: 1.6rem 1.8rem;
  max-width: 560px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.results-stars .star { font-size: 2.6rem; margin: 0 0.15rem; display: inline-block; }
.results-stars .star.on { animation: starPop 0.45s backwards; }
@keyframes starPop {
  0% { transform: scale(0.2) rotate(-30deg); opacity: 0; }
  70% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); }
}
.results-headline { font-family: var(--font-display); font-size: 1.3rem; margin: 0.4rem 0 1.1rem; }
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.rg-cell { border: 1px solid var(--line); padding: 0.55rem 0.4rem; }
.rg-val { font-family: var(--font-mono); font-size: 1.05rem; color: var(--ivory); }
.rg-key { font-family: var(--font-display); font-size: 0.6rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ivory-dim); margin-top: 0.2rem; }
.results-weak { font-size: 1.02rem; color: var(--ivory-dim); margin-bottom: 1.2rem; }
.results-weak strong { color: var(--gold); font-weight: 500; }
.unlock-msg { margin-top: 0.5rem; color: var(--gold-bright); font-family: var(--font-display); }
.results-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; }

@media (max-width: 600px) {
  .hero-title { font-size: 1.9rem; }
  .level-grid { grid-template-columns: 1fr; }
  .play-head { flex-wrap: wrap; gap: 0.6rem; }
  .play-name { font-size: 1.2rem; }
  .score-paper { padding: 0.8rem 0.3rem 0.4rem; }
  .results { position: fixed; z-index: 500; border-radius: 0; }
  .results-card { padding: 1.2rem 1rem; }
  .slider { width: 110px; }
  .play-actions { justify-content: stretch; gap: 0.5rem; margin-top: 0.2rem; }
  .play-actions button { flex: 1; }
  .play-actions .primary-btn.big { padding: 0.8rem 1rem; }
  .restart-hint { flex-basis: 100%; min-width: 0; font-size: 0.85rem; }
  .status-row { min-height: 1.6rem; }
  .status { font-size: 0.98rem; }
}

.load-error { color: var(--note-miss); text-align: center; padding: 3rem 1rem; font-size: 1.1rem; }
