/* ── reset ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* `hidden` is only a UA stylesheet rule, so any author rule that sets display
   beats it and the element stays painted while el.hidden reads true. */
[hidden] {
  display: none !important;
}

:root {
  color-scheme: dark;

  --bg: #06070d;
  --bg-soft: #0b0f1c;
  --panel: rgba(20, 26, 44, 0.72);
  --panel-solid: #111726;
  --line: rgba(130, 152, 200, 0.22);
  --line-strong: rgba(150, 175, 230, 0.45);

  --text: #e8eefc;
  --text-dim: #9aa8c6;
  --text-faint: #6c7a99;

  --accent: #ff8a3d;
  --accent-2: #3ddaff;
  --good: #4ade80;
  --warn: #ffd23d;
  --bad: #ff4d5e;

  --fret-1: #3fd94d;
  --fret-2: #ff4d5e;
  --fret-3: #ffd23d;
  --fret-4: #3d9bff;
  --fret-5: #ff8a2b;

  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  font: 600 11px/1.5 var(--mono);
  text-align: center;
  color: var(--text-dim);
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.hint {
  margin: 0;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.5;
}

.label {
  margin: 0 0 8px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ── buttons ────────────────────────────────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: 600 14px/1 var(--font);
  padding: 11px 20px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.08s ease;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-dim);
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
.btn--primary {
  background: linear-gradient(180deg, #ff9d55, #f0701d);
  border-color: #ffb37a;
  color: #1d0c02;
  padding-inline: 30px;
  font-size: 15px;
}
.btn--primary:hover {
  background: linear-gradient(180deg, #ffae6e, #ff7f2c);
}

/* ── title screen ───────────────────────────────────────────────────── */
.screen--title {
  overflow-y: auto;
  padding: clamp(16px, 3.2vh, 34px) clamp(16px, 4vw, 44px) 28px;
  gap: clamp(14px, 2.4vh, 26px);
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255, 138, 61, 0.16), transparent 60%),
    radial-gradient(90% 70% at 12% 110%, rgba(61, 218, 255, 0.1), transparent 60%),
    var(--bg);
}

.brand {
  text-align: center;
  display: grid;
  gap: 8px;
}
.brand__title {
  font-size: clamp(30px, 6.4vw, 58px);
  font-weight: 800;
  letter-spacing: -0.03em;
}
.brand__title span {
  background: linear-gradient(93deg, var(--accent), #ffd23d 55%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-left: 0.28em;
}
.brand__tag {
  margin: 0 auto;
  max-width: 56ch;
  color: var(--text-dim);
  font-size: 14px;
}

.picker {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.95fr);
  gap: clamp(14px, 2.4vw, 30px);
  width: min(1060px, 100%);
  margin-inline: auto;
}
.picker__col {
  min-width: 0;
}

.songs {
  display: grid;
  gap: 10px;
}
.song {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.song:hover {
  border-color: var(--line-strong);
  background: rgba(30, 38, 62, 0.8);
}
.song[aria-checked="true"] {
  border-color: var(--song-accent, var(--accent));
  background: rgba(34, 42, 68, 0.9);
  box-shadow: inset 3px 0 0 var(--song-accent, var(--accent));
}
.song:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
.song__num {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--song-accent, var(--accent));
  color: #0a0c14;
  font: 800 13px/1 var(--mono);
}
/* These sit inside a grid item, not as grid items themselves. Blockification
   stops at the item, so without an explicit display they stay inline and the
   title, metadata and blurb render as one run-on paragraph. */
.song__name,
.song__meta,
.song__blurb {
  display: block;
}
.song__name {
  font-weight: 700;
  font-size: 15.5px;
}
.song__meta {
  color: var(--text-faint);
  font-size: 12px;
}
.song__blurb {
  color: var(--text-dim);
  font-size: 12.5px;
  margin-top: 2px;
}
.song__stats {
  text-align: right;
  font: 600 11px/1.45 var(--mono);
  color: var(--text-faint);
  white-space: nowrap;
}
.song__stats b {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 16px;
}
.pill {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  font: 600 13px/1 var(--font);
  cursor: pointer;
  transition: all 0.14s ease;
}
.pill:hover {
  color: var(--text);
  border-color: var(--line-strong);
}
.pill[aria-checked="true"] {
  background: var(--text);
  border-color: var(--text);
  color: #0a0c14;
}
.pill:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.settings {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 0 14px;
}
.settings summary {
  padding: 11px 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-dim);
}
.settings[open] summary {
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.settings > *:last-child {
  margin-bottom: 14px;
}
.setting {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}
.setting > span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.setting output {
  color: var(--text);
  font: 600 12px/1.4 var(--mono);
}
.setting--check {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
}
.setting--inline {
  grid-template-columns: auto auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
select {
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  font: 600 12.5px/1 var(--font);
}

.start-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 18px;
  padding-top: 4px;
}
.keys-hint {
  margin: 0;
  color: var(--text-faint);
  font-size: 12px;
}

/* ── play screen ────────────────────────────────────────────────────── */
.screen--play {
  padding: 0;
  gap: 0;
}

/* The canvas fills the stage rather than holding a fixed ratio: a flex item
   that grows has both axes definite, which makes aspect-ratio inert and would
   stretch the drawing instead of letterboxing it. */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  container-type: size;
}
#highway {
  display: block;
  width: 100%;
  height: 100%;
}

/* HUD units come from the stage, never from the viewport: on a phone, vh would
   measure a box the stage does not occupy. */
.hud {
  position: absolute;
  inset: 0;
  padding: clamp(8px, 2.4cqh, 20px) clamp(10px, 2.2cqw, 26px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.hud__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.hud__song strong {
  display: block;
  font-size: clamp(13px, 2.5cqh, 19px);
  font-weight: 700;
}
.hud__song span {
  color: var(--text-faint);
  font-size: clamp(10px, 1.7cqh, 12.5px);
}
.hud__score {
  text-align: right;
}
.hud__score strong {
  display: block;
  font-size: clamp(20px, 4.6cqh, 38px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hud__score span {
  color: var(--accent);
  font-size: clamp(12px, 2.2cqh, 17px);
  font-weight: 700;
}
.hud__score span.od {
  color: var(--accent-2);
}

.hud__bars {
  display: flex;
  gap: 10px;
  max-width: min(420px, 60cqw);
}
.bar {
  position: relative;
  flex: 1 1 0;
  height: clamp(9px, 1.8cqh, 14px);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 10, 18, 0.6);
  overflow: hidden;
}
.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-radius: inherit;
  transition: width 0.12s linear, background 0.2s ease;
}
.bar span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 700 8px/1 var(--mono);
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.7);
}
.bar--overdrive i {
  background: linear-gradient(90deg, #1c7fb0, #7fe8ff);
}
.bar--overdrive.ready {
  border-color: var(--accent-2);
  box-shadow: 0 0 12px rgba(61, 218, 255, 0.45);
}
.bar--meter i {
  background: linear-gradient(90deg, var(--good), #86efac);
}
.bar--meter.low i {
  background: linear-gradient(90deg, var(--bad), #ff8c96);
}
.bar--meter.mid i {
  background: linear-gradient(90deg, var(--warn), #ffe484);
}

.hud__progress {
  margin-top: auto;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.hud__progress i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.16s linear;
}

/* ── touch frets ────────────────────────────────────────────────────── */
.fretbar {
  display: none;
  gap: 8px;
  padding: 10px clamp(8px, 3vw, 22px) max(10px, env(safe-area-inset-bottom));
  background: #05060b;
  border-top: 1px solid var(--line);
}
body.touch .fretbar {
  display: flex;
}
.fretbar button {
  flex: 1 1 0;
  height: 62px;
  border: 2px solid var(--fb, #666);
  border-radius: 12px;
  background: color-mix(in srgb, var(--fb) 16%, #0b0f1c);
  color: var(--text);
  font: 800 13px/1 var(--mono);
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.fretbar button.down {
  background: var(--fb);
  color: #0a0c14;
}
.fretbar button.strum {
  flex: 1.5 1 0;
  --fb: #9fb0d4;
}

/* ── overlays ───────────────────────────────────────────────────────── */
.overlay,
.gate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 6, 12, 0.82);
  backdrop-filter: blur(6px);
  z-index: 20;
}
.gate {
  position: fixed;
}
.overlay__card {
  width: min(420px, calc(100vw - 36px));
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-solid);
  text-align: center;
  display: grid;
  gap: 12px;
}
.overlay__card h2 {
  font-size: 22px;
}
.overlay__row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

/* ── results ────────────────────────────────────────────────────────── */
.screen--results {
  display: grid;
  place-items: center;
  padding: 22px;
  overflow-y: auto;
}
.results__card {
  width: min(520px, 100%);
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  text-align: center;
  display: grid;
  gap: 12px;
}
.results__verdict {
  margin: 0;
  font: 700 11px/1 var(--mono);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--good);
}
.results__verdict.failed {
  color: var(--bad);
}
.results__card h2 {
  font-size: clamp(24px, 5vw, 34px);
  font-weight: 800;
}
.stars {
  display: flex;
  justify-content: center;
  gap: 7px;
  font-size: 26px;
  line-height: 1;
}
.stars span {
  color: #2b3350;
}
.stars span.on {
  color: var(--warn);
  text-shadow: 0 0 14px rgba(255, 210, 61, 0.5);
}
.results__score {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}
.results__score strong {
  font-size: clamp(32px, 7vw, 48px);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.results__score span {
  color: var(--text-faint);
  font-size: 13px;
}
.stats {
  margin: 4px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 9px;
}
.stats div {
  padding: 9px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 10, 18, 0.5);
}
.stats dt {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.stats dd {
  margin: 3px 0 0;
  font: 700 16px/1 var(--mono);
}
.stats dd.good {
  color: var(--good);
}
.stats dd.bad {
  color: var(--bad);
}

/* ── jam room ───────────────────────────────────────────────────────── */
.screen--jam {
  padding: clamp(14px, 3vh, 28px) clamp(14px, 4vw, 40px);
  gap: 16px;
  overflow-y: auto;
}
.jam__head {
  display: grid;
  gap: 10px;
  max-width: 900px;
  margin-inline: auto;
  width: 100%;
  text-align: center;
  justify-items: center;
}
.jam__head h2 {
  font-size: clamp(22px, 4vw, 30px);
}
.jam__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  justify-content: center;
}
.fretboard {
  width: min(900px, 100%);
  margin-inline: auto;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #2a1c12, #170f09);
}
.fret-row {
  display: grid;
  grid-template-columns: repeat(var(--frets, 6), minmax(0, 1fr));
  gap: 5px;
}
.fret-cell {
  position: relative;
  padding: 12px 4px 10px;
  border: 1px solid rgba(190, 160, 120, 0.28);
  border-radius: 7px;
  background: rgba(255, 235, 210, 0.05);
  color: var(--text-dim);
  font: 700 11px/1.2 var(--mono);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.fret-cell b {
  display: block;
  font-size: 12.5px;
  color: var(--text);
}
.fret-cell:hover {
  background: rgba(255, 235, 210, 0.12);
}
.fret-cell.lit {
  background: var(--accent);
  color: #1d0c02;
}
.fret-cell.lit b {
  color: #1d0c02;
}
.jam__hint {
  text-align: center;
}

/* ── narrow screens ─────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .picker {
    grid-template-columns: minmax(0, 1fr);
  }
  .song {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .song__stats {
    grid-column: 2;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
