:root {
  --bg: #07080d;
  --surface: #1b1c2f;
  --surface-2: #262839;
  --text: #f8fafe;
  --muted: #a4a7bd;
  --accent: #c21c22;
  --gold: #c9a96e;
  --amber: #f4b860;
  --cream: #fff3dd;
  --perfect: #4cc9a4;
  --great: #4fa8e8;
  --good: #e8c26a;
  --miss: #c21c22;
  --sans: "Lato", system-ui, sans-serif;
  --serif: "Libre Baskerville", Georgia, serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1440px;
  height: 900px;
  transform-origin: 50% 50%;
  overflow: hidden;
  background: var(--bg);
}

.bg-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 40% 35% at 50% 80%, #f4b8601c 0%, #f4b86000 100%);
  transition: opacity 1.2s ease;
}

.caps {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted);
}

/* ───────── Top bar ───────── */
.topbar {
  position: absolute;
  left: 0;
  top: 0;
  width: 1440px;
  height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #1b1c2fcc 0%, #1b1c2f00 100%);
  z-index: 80;
}

.brand {
  width: 300px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  display: flex;
  align-items: flex-end;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  line-height: 1.2;
}

.logo .dot {
  color: var(--accent);
}

.logo .tv {
  font-size: 18px;
}

.sep {
  width: 1px;
  height: 22px;
  background: #ffffff33;
}

.game-name {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 3px;
}

.now-playing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.np-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 18px;
}

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

#barLabel {
  min-width: 83px;
  text-align: right;
}

.beat-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 10px;
}

.beat-dots i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff40;
  transition: width 0.12s var(--ease-out), height 0.12s var(--ease-out), background-color 0.12s, box-shadow 0.25s;
}

.beat-dots i.on {
  width: 10px;
  height: 10px;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.controls {
  width: 300px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.round-btn {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: #ffffff14;
  display: grid;
  place-items: center;
  transition: background-color 0.2s, transform 0.15s var(--ease-out);
}

.round-btn:hover {
  background: #ffffff26;
}

.round-btn:active {
  transform: scale(0.92);
}

.round-btn svg {
  width: 18px;
  height: 18px;
  grid-area: 1 / 1;
  transition: opacity 0.2s, transform 0.25s var(--ease-out);
}

.round-btn .i-mute,
.round-btn .i-play {
  opacity: 0;
  transform: scale(0.6);
}

.round-btn.alt .i-vol,
.round-btn.alt .i-pause {
  opacity: 0;
  transform: scale(0.6);
}

.round-btn.alt .i-mute,
.round-btn.alt .i-play {
  opacity: 1;
  transform: none;
}

/* ───────── Score ribbon ───────── */
.ribbon {
  position: absolute;
  left: 72px;
  top: 88px;
  width: 1296px;
  height: 80px;
  overflow: hidden;
  z-index: 75;
}

#ribbonCanvas {
  position: absolute;
  inset: 0;
  width: 1296px;
  height: 80px;
}

.ribbon-playhead {
  position: absolute;
  left: 647px;
  top: 6px;
  width: 2px;
  height: 68px;
  background: linear-gradient(180deg, #fff3dd00 0%, #fff3dd 25%, #fff3dd 75%, #fff3dd00 100%);
  box-shadow: 0 0 12px var(--amber);
}

.ribbon-playhead.pulse {
  animation: playhead-pulse 0.4s var(--ease-out);
}

@keyframes playhead-pulse {
  0% {
    box-shadow: 0 0 22px 2px var(--amber);
  }
  100% {
    box-shadow: 0 0 12px var(--amber);
  }
}

.ribbon-fade {
  position: absolute;
  top: 0;
  width: 160px;
  height: 80px;
  pointer-events: none;
}

.ribbon-fade.l {
  left: 0;
  background: linear-gradient(90deg, var(--bg) 0%, #07080d00 100%);
}

.ribbon-fade.r {
  right: 0;
  background: linear-gradient(-90deg, var(--bg) 0%, #07080d00 100%);
}

.ribbon-label {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted);
}

/* ───────── Playfield ───────── */
.lane-guide {
  position: absolute;
  top: 170px;
  width: 1px;
  height: 550px;
  background: linear-gradient(180deg, #ffffff00 0%, #ffffff14 100%);
  z-index: 2;
  transition: background 0.5s;
}

#laneBeams {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.lane-beam {
  position: absolute;
  top: 300px;
  width: 132px;
  height: 420px;
  background: linear-gradient(180deg, #f4b86000 0%, #f4b86014 70%, #f4b86030 100%);
  opacity: 0;
  transition: opacity 0.35s ease-out;
}

.lane-beam.on {
  opacity: 1;
  transition-duration: 0.05s;
}

.line-glow {
  position: absolute;
  left: 330px;
  top: 570px;
  width: 780px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, #f4b86030 0%, #f4b86000 100%);
  z-index: 6;
  pointer-events: none;
}

#flares {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
}

.flare {
  position: absolute;
  top: 660px;
  width: 220px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, #f4b860aa 0%, #f4b86000 100%);
  opacity: 0;
  transform: scale(0.6);
}

.flare.hold {
  animation: flare-breathe 0.5s ease-in-out infinite alternate;
}

@keyframes flare-breathe {
  from {
    opacity: 0.55;
    transform: scale(0.85, 0.9);
  }
  to {
    opacity: 0.85;
    transform: scale(1, 1.05);
  }
}

#notesLayer {
  position: absolute;
  left: 380px;
  top: 150px;
  width: 680px;
  height: 572px;
  overflow: hidden;
  z-index: 10;
  pointer-events: none;
}

.note {
  position: absolute;
  left: 0;
  top: 0;
  width: 64px;
  height: 24px;
  border-radius: 12px;
  background: var(--c);
  box-shadow: 0 0 18px color-mix(in srgb, var(--c) 53%, transparent);
  will-change: transform;
  transition: box-shadow 0.18s ease-out, filter 0.25s, opacity 0.3s;
}

.note.near {
  box-shadow: 0 0 22px color-mix(in srgb, var(--c) 80%, transparent), 0 0 4px var(--c);
}

.note.hold {
  box-shadow: 0 0 18px color-mix(in srgb, var(--c) 60%, transparent);
}

.note.hold::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  bottom: 10px;
  width: 2px;
  transform: translateX(-50%);
  border-radius: 1px;
  background: #07080d22;
}

.note.holding {
  background: linear-gradient(180deg, #ffe6b855 0%, #ffe6b8 100%);
  box-shadow: 0 0 30px #ffe6b899;
  transition: none;
}

.note.holding::after {
  display: none;
}

.note.broken {
  filter: saturate(0.25) brightness(0.55);
  opacity: 0.55;
}

.note.missed {
  filter: saturate(0.15) brightness(0.45);
  opacity: 0.5;
  box-shadow: none;
}

.light-line {
  position: absolute;
  left: 350px;
  top: 719px;
  width: 740px;
  height: 2px;
  background: linear-gradient(90deg, #fff3dd00 0%, #fff3dd 8%, #fff3dd 92%, #fff3dd00 100%);
  box-shadow: 0 0 10px var(--amber), 0 0 36px #f4b86099;
  z-index: 22;
}

/* ───────── Keyboard ───────── */
.keyboard {
  position: absolute;
  left: 390px;
  top: 722px;
  width: 660px;
  height: 72px;
  background: #0b0c12;
  overflow: hidden;
  z-index: 23;
}

.white-key {
  position: absolute;
  top: 0;
  width: 17.857px;
  height: 72px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(180deg, #b9bbc6 0%, #e6e7ec 100%);
  transition: filter 0.35s ease-out;
}

.white-key::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, #f4b860 0%, #fff3dd 100%);
  opacity: 0;
  transition: opacity 0.35s ease-out;
}

.octave.lit .white-key::after {
  opacity: 0.92;
  transition-duration: 0.04s;
}

.octave.lit .white-key {
  filter: drop-shadow(0 0 6px #f4b86066);
  transition-duration: 0.04s;
}

.black-key {
  position: absolute;
  top: 0;
  width: 11px;
  height: 44px;
  border-radius: 0 0 2px 2px;
  background: #14151c;
  z-index: 2;
}

.octave-divider {
  position: absolute;
  top: 0;
  width: 2px;
  height: 72px;
  background: var(--bg);
  z-index: 3;
}

.key-badge {
  position: absolute;
  top: 44px;
  width: 26px;
  height: 22px;
  border-radius: 5px;
  background: #07080dcc;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  z-index: 4;
  transition: background-color 0.3s, color 0.3s, box-shadow 0.3s, transform 0.2s var(--ease-out);
}

.octave.lit .key-badge {
  background: var(--c);
  color: var(--bg);
  box-shadow: 0 0 12px var(--c);
  transform: translateY(1px) scale(1.06);
  transition-duration: 0.04s;
}

.keyboard-shade {
  position: absolute;
  left: 390px;
  top: 722px;
  width: 660px;
  height: 10px;
  background: linear-gradient(180deg, #07080daa 0%, #07080d00 100%);
  z-index: 24;
}

.legend {
  position: absolute;
  top: 748px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted);
  z-index: 25;
}

.legend svg {
  width: 14px;
  height: 14px;
}

.legend.low {
  left: 318px;
}

.legend.high {
  left: 1070px;
}

#fxCanvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 1440px;
  height: 900px;
  z-index: 27;
  pointer-events: none;
}

/* ───────── Hit feedback ───────── */
#feedbackLayer {
  position: absolute;
  inset: 0;
  z-index: 71;
  pointer-events: none;
}

.feedback {
  position: absolute;
  top: 624px;
  width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0;
}

.feedback .grade {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--gc);
  filter: drop-shadow(0 0 8px var(--gg));
}

.feedback .points {
  font-size: 13px;
  font-weight: 700;
  color: #ffffffcc;
  font-variant-numeric: tabular-nums;
}

.section-banner {
  position: absolute;
  left: 420px;
  width: 600px;
  top: 262px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 70;
  pointer-events: none;
  opacity: 0;
}

.sb-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--gold);
}

.sb-name {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 24px #f4b86055;
}

.countin {
  position: absolute;
  left: 570px;
  width: 300px;
  top: 330px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 70;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}

.countin.show {
  opacity: 1;
}

.countin span {
  font-family: var(--serif);
  font-size: 96px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  text-shadow: 0 0 40px #c21c2288;
}

.countin small {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.5px;
}

/* ───────── Score panel ───────── */
.score-panel {
  position: absolute;
  left: 72px;
  top: 200px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  z-index: 72;
}

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

.score-value {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  transform-origin: left center;
}

.multiplier {
  display: flex;
  align-items: center;
  gap: 18px;
}

.ring {
  position: relative;
  width: 84px;
  height: 84px;
  flex: none;
}

.ring svg {
  position: absolute;
  inset: 0;
  width: 84px;
  height: 84px;
  transform: rotate(-90deg);
  overflow: visible;
}

.ring circle {
  fill: none;
  stroke-width: 5.88;
  stroke-linecap: butt;
}

.ring .track {
  stroke: #ffffff1a;
}

.ring .progress {
  stroke: var(--gold);
  stroke-dasharray: 245.42;
  stroke-dashoffset: 245.42;
  transition: stroke-dashoffset 0.45s var(--ease-out), stroke 0.3s;
}

.multiplier.broken .ring .progress {
  stroke: var(--accent);
}

.mult {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 900;
  color: var(--gold);
  transition: color 0.3s;
}

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

.streak-value {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.streak-hint {
  font-size: 14px;
  color: var(--muted);
}

.accuracy {
  border-top: 1px solid #ffffff1a;
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.acc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.acc-value {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.split-bar {
  display: flex;
  gap: 2px;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: #ffffff0f;
}

.split-bar i {
  display: block;
  height: 6px;
  width: 0;
  flex: none;
  transition: width 0.4s var(--ease-out);
}

.split-bar .perfect {
  background: var(--perfect);
}
.split-bar .great {
  background: var(--great);
}
.split-bar .good {
  background: var(--good);
}
.split-bar .miss {
  background: var(--miss);
}

.acc-legend {
  display: flex;
  justify-content: space-between;
}

.acc-legend div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.acc-legend span {
  font-size: 12px;
  font-weight: 700;
}

.acc-legend b {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.acc-legend .perfect span {
  color: var(--perfect);
}
.acc-legend .great span {
  color: var(--great);
}
.acc-legend .good span {
  color: var(--good);
}
.acc-legend .miss span {
  color: var(--miss);
}

/* ───────── Personal best panel ───────── */
.best-panel {
  position: absolute;
  left: 1088px;
  top: 200px;
  width: 280px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  z-index: 73;
}

.best-value {
  margin-top: 10px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.best-meta {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.pace {
  margin-top: 24px;
  padding-top: 20px;
  width: 100%;
  border-top: 1px solid #ffffff1a;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pace-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
}

.pace-row b {
  color: var(--text);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.pace-row b.you {
  color: var(--text);
}

.pace-delta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}

.pace-delta svg {
  width: 18px;
  height: 18px;
  display: none;
}

.pace-delta.ahead {
  color: var(--perfect);
}

.pace-delta.behind {
  color: #e0575c;
}

.pace-delta.ahead .up,
.pace-delta.behind .down {
  display: block;
}

.pace-badge {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 4px;
  background: #c9a96e22;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s var(--ease-out), transform 0.4s var(--ease-out);
}

.pace-badge.show {
  opacity: 1;
  transform: none;
}

.pace-badge svg {
  width: 14px;
  height: 14px;
}

.attempt {
  margin-top: 18px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ffffff55;
  text-transform: uppercase;
}

.top-fade {
  position: absolute;
  left: 380px;
  top: 150px;
  width: 680px;
  height: 90px;
  background: linear-gradient(180deg, var(--bg) 0%, #07080d00 100%);
  z-index: 74;
  pointer-events: none;
}

/* ───────── Piece progress ───────── */
.piece-progress {
  position: absolute;
  left: 72px;
  top: 836px;
  width: 1296px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
}

.pp-head {
  position: relative;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pp-head .elapsed {
  color: var(--text);
  font-weight: 700;
}

.pp-head .section {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  transition: opacity 0.25s;
}

.segments,
.segment-labels {
  display: flex;
  gap: 4px;
}

.segments > div {
  position: relative;
  flex: 1 1 0;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background: #ffffff1f;
}

.segments > div > i {
  position: absolute;
  left: 0;
  top: 0;
  height: 6px;
  width: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
}

.segments > div.current > i {
  box-shadow: 0 0 8px var(--accent);
}

.segment-labels > span {
  flex: 1 1 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ffffff55;
  transition: color 0.4s;
}

.segment-labels > span.current {
  color: var(--text);
}

#touchLayer {
  position: absolute;
  left: 390px;
  top: 170px;
  width: 660px;
  height: 624px;
  z-index: 76;
  touch-action: none;
}

/* ───────── Overlays ───────── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse 60% 60% at 50% 45%, #07080d99 0%, #07080de6 100%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s var(--ease-out), visibility 0s linear 0.45s;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.45s var(--ease-out), visibility 0s;
}

.card {
  grid-area: 1 / 1;
  width: 520px;
  padding: 40px 44px 36px;
  border-radius: 14px;
  background: linear-gradient(180deg, #1b1c2ff2 0%, #12131ff2 100%);
  border: 1px solid #ffffff14;
  box-shadow: 0 30px 80px #00000080, 0 0 0 1px #00000040;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px) scale(0.98);
  transition: opacity 0.4s var(--ease-out), transform 0.5s var(--ease-out), visibility 0s linear 0.4s;
}

.card.show {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.4s var(--ease-out) 0.08s, transform 0.5s var(--ease-out) 0.08s, visibility 0s;
}

.kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.5px;
  color: var(--gold);
}

.card h1 {
  margin: 14px 0 0;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
}

.card .lead {
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 380px;
}

.key-row {
  margin-top: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-row .hint {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 6px;
}

kbd {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 900;
  color: var(--bg);
  background: var(--c, var(--amber));
  box-shadow: 0 0 14px color-mix(in srgb, var(--c, var(--amber)) 50%, transparent), inset 0 -3px 0 #00000030;
}

.key-row kbd:nth-of-type(1) {
  --c: #e8743b;
}
.key-row kbd:nth-of-type(2) {
  --c: #f09a4a;
}
.key-row kbd:nth-of-type(3) {
  --c: #f4b860;
}
.key-row kbd:nth-of-type(4) {
  --c: #f7cf85;
}
.key-row kbd:nth-of-type(5) {
  --c: #ffe6b8;
}

.cta,
.ghost {
  margin-top: 30px;
  height: 48px;
  padding: 0 26px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.3px;
  transition: transform 0.15s var(--ease-out), background-color 0.2s, box-shadow 0.3s;
}

.cta {
  background: var(--accent);
  box-shadow: 0 8px 30px #c21c2255;
}

.cta:hover {
  background: #d4252b;
  box-shadow: 0 10px 36px #c21c2277;
}

.ghost {
  background: #ffffff14;
}

.ghost:hover {
  background: #ffffff22;
}

.cta:active,
.ghost:active {
  transform: scale(0.96);
}

.cta span,
.ghost span {
  opacity: 0.6;
  font-weight: 700;
}

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

.card-foot {
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
}

.card-foot b {
  color: var(--gold);
  font-weight: 900;
}

.end-score {
  margin-top: 10px;
  font-size: 72px;
  font-weight: 900;
  letter-spacing: -1.5px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.end-badge {
  margin-top: 10px;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 4px;
  background: #c9a96e22;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
}

.end-badge.show {
  display: flex;
  animation: badge-in 0.7s var(--ease-out) 0.5s both;
}

@keyframes badge-in {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  60% {
    transform: scale(1.08);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.end-badge svg {
  width: 14px;
  height: 14px;
}

.end-compare {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
  min-height: 20px;
}

.end-stats {
  margin-top: 24px;
  width: 100%;
  padding-top: 20px;
  border-top: 1px solid #ffffff1a;
  display: flex;
  justify-content: space-between;
}

.end-stats div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  flex: 1;
}

.end-stats span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.end-stats b {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.end-rank {
  margin-top: 14px;
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.end-rank.show {
  display: flex;
  animation: badge-in 0.7s var(--ease-out) 0.7s both;
}

.end-rank b {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--text);
}

.end-rank .up {
  color: var(--perfect);
  font-weight: 700;
}

/* ───────── Player name ───────── */
.overlay-row {
  display: flex;
  align-items: center;
  gap: 28px;
}

.cards {
  display: grid;
  place-items: center;
}

.player {
  margin-top: 26px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.player-known {
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.player-known b {
  color: var(--text);
}

.player.known .player-known {
  display: flex;
}

.player.known .player-field {
  display: none;
}

.link {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: #c9a96e66;
}

.link:hover {
  text-decoration-color: var(--gold);
}

.player-field {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.player-field .label {
  font-size: 11px;
}

.player-field input {
  height: 46px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid #ffffff24;
  background: #07080d99;
  color: var(--text);
  font: 700 16px var(--sans);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.25s;
}

.player-field input::placeholder {
  color: #a4a7bd80;
  font-weight: 400;
}

.player-field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px #c9a96e2e;
}

.player.invalid input {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px #c21c2233;
  animation: shake 0.35s var(--ease-out);
}

@keyframes shake {
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(4px);
  }
  75% {
    transform: translateX(-2px);
  }
}

.player-error {
  min-height: 18px;
  margin-top: 8px;
  font-size: 13px;
  color: #f0757a;
}

.player + .cta {
  margin-top: 8px;
}

.cta:disabled {
  opacity: 0.6;
  cursor: progress;
}

.avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
  background: var(--av, var(--surface-2));
}

.avatar.me {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.player-known .avatar {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

/* ───────── Leaderboard ───────── */
.board {
  width: 580px;
  display: none;
  flex-direction: column;
}

.overlay.board-on .board {
  display: flex;
  animation: board-in 0.6s var(--ease-out) 0.12s both;
}

@keyframes board-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.board h2 {
  margin: 10px 0 18px;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
}

.board-table {
  border-radius: 6px;
  background: #0f1121f2;
  border: 1px solid #ffffff14;
  box-shadow: 0 30px 80px #00000080;
  overflow: hidden;
}

.board-head,
.board-row {
  display: grid;
  grid-template-columns: 56px 1fr 86px 70px 96px;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid #ffffff12;
}

.board-head {
  height: 40px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--muted);
}

.board-head span:nth-child(n + 3),
.board-row > :nth-child(n + 3) {
  text-align: right;
}

.board-row {
  height: 54px;
  font-size: 15px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  animation: row-in 0.5s var(--ease-out) both;
  animation-delay: calc(0.15s + var(--i, 0) * 0.05s);
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.board-row:last-child {
  border-bottom: 0;
}

.board-row .who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.board-row .name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-row .score {
  font-weight: 900;
  color: var(--text);
}

.rank {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
}

.medal {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  color: #0f1121;
  background: var(--m);
}

.board-row.you {
  height: 62px;
  background: #c21c221f;
}

.board-row.you .rank {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
}

.board-row .tag {
  margin-left: -4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
}

.board-gap {
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 1px solid #ffffff12;
}

.board-empty {
  padding: 38px 24px;
  text-align: center;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}

.board-foot {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .flare.hold {
    animation: none;
    opacity: 0.7;
  }
}
