:root {
  --bg: #0D0820;
  --surface: #1A1234;
  --surface-2: #241A45;
  --well: #150E2C;
  --line: #3A2E66;
  --line-dim: #2A2050;
  --text: #F5F0FF;
  --text-2: #D9D0F2;
  --muted: #A99BD1;
  --past: #B9AEDB;
  --ghost: #8E80BE;
  --pink: #FF3EA5;
  --pink-ink: #1A0614;
  --pink-deep: #A81A68;
  --pink-soft: #FF7CC2;
  --cyan: #34E4F2;
  --cyan-ink: #04262A;
  --gold: #FFD84D;
  --pixel: 'Silkscreen', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rubik', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: 0.45; cursor: default; }
input::placeholder { color: #7E70A8; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
svg { display: block; flex: 0 0 auto; }

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; position: relative; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 14px) 24px calc(env(safe-area-inset-bottom) + 24px);
  overflow: hidden;
}
.screen.enter { animation: fade-in 0.25s ease-out; }
.glow-pink { background: radial-gradient(420px 320px at 50% 26%, rgba(255,62,165,0.22), transparent 70%), radial-gradient(300px 260px at 85% 72%, rgba(52,228,242,0.10), transparent 70%), var(--bg); }
.glow-violet { background: radial-gradient(360px 240px at 50% 0%, rgba(139,92,246,0.18), transparent 70%), var(--bg); }
.glow-reveal { background: radial-gradient(340px 340px at 50% 30%, rgba(255,62,165,0.20), transparent 70%), var(--bg); }
.glow-gold { background: radial-gradient(420px 340px at 50% 20%, rgba(255,216,77,0.14), transparent 70%), radial-gradient(360px 300px at 50% 30%, rgba(255,62,165,0.16), transparent 75%), var(--bg); }

.pixel { font-family: var(--pixel); }
.p0 { --pc: var(--pink); --pc-ink: var(--pink-ink); --pc-soft: var(--pink-soft); }
.p1 { --pc: var(--cyan); --pc-ink: var(--cyan-ink); --pc-soft: var(--cyan); }

/* ---------- splash ---------- */
.splash { align-items: center; justify-content: center; gap: 48px; background: radial-gradient(360px 360px at 50% 44%, rgba(255,62,165,0.30), transparent 70%), radial-gradient(280px 280px at 50% 56%, rgba(52,228,242,0.14), transparent 70%), var(--bg); }
.splash img { width: min(330px, 80vw); aspect-ratio: 1; object-fit: contain; animation: pop-in 0.6s cubic-bezier(.2,1.4,.4,1); }
.eq { display: flex; align-items: flex-end; gap: 6px; height: 36px; }
.eq i { width: 8px; height: 36px; background: var(--pink); transform-origin: bottom; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(even) { background: var(--cyan); }
.eq i:nth-child(2) { animation-delay: .15s } .eq i:nth-child(3) { animation-delay: .3s }
.eq i:nth-child(4) { animation-delay: .45s } .eq i:nth-child(5) { animation-delay: .6s }

/* ---------- shared bits ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.chip { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid rgba(255,255,255,0.08); border-radius: 999px; padding: 8px 14px; }
.tile-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--surface); border: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: center; color: var(--muted); }
.score { display: flex; align-items: center; gap: 6px; font-family: var(--pixel); font-size: 17px; }
.progress { display: flex; align-items: center; gap: 8px; font-family: var(--pixel); font-size: 15px; color: var(--muted); }
.dir-tag { font-family: var(--pixel); font-size: 11px; color: var(--cyan); border: 1px solid rgba(52,228,242,0.4); border-radius: 6px; padding: 2px 6px; }
.spacer { flex-grow: 1; }

.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 64px; border-radius: 20px; background: var(--pink); color: var(--pink-ink);
  font-size: 22px; font-weight: 900; box-shadow: 0 6px 0 var(--pink-deep), 0 14px 30px rgba(255,62,165,0.35);
  transition: transform .08s, box-shadow .08s;
}
.btn-primary:active, .btn-pill:active, .btn-pill-pink:active, .send:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--pink-deep); }
.btn-pill {
  height: 52px; padding: 0 22px 0 26px; border-radius: 999px; background: var(--surface-2); color: var(--text);
  font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 10px; box-shadow: 0 4px 0 #120B26;
  transition: transform .08s, box-shadow .08s;
}
.btn-pill svg { color: var(--cyan); }
.btn-pill-pink {
  height: 56px; padding: 0 28px 0 30px; border-radius: 999px; background: var(--pink); color: var(--pink-ink);
  font-size: 19px; font-weight: 900; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 5px 0 var(--pink-deep), 0 0 22px rgba(255,62,165,0.35); transition: transform .08s, box-shadow .08s;
}
.btn-ghost { height: 52px; border-radius: 18px; background: var(--surface); border: 1px solid rgba(255,255,255,0.08); color: var(--text-2); font-size: 16px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.round-btn { width: 52px; height: 52px; border-radius: 50%; background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--muted); }

/* ---------- home ---------- */
.home { gap: 18px; }
.home .logo { flex-grow: 1; display: flex; align-items: center; justify-content: center; margin: -8px -24px 0; }
.home .logo img { width: min(350px, 88vw); aspect-ratio: 1; object-fit: contain; }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mode {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  height: 92px; border-radius: 18px; background: var(--surface); border: 2px solid rgba(255,255,255,0.06); color: var(--text-2);
  font-size: 15px; font-weight: 800; transition: border-color .15s, background .15s;
}
.mode[aria-pressed="true"] { background: #2A1640; border-color: var(--pink); color: var(--pink-soft); box-shadow: 0 0 0 4px rgba(255,62,165,0.15); }
.segmented { display: flex; gap: 6px; background: var(--surface); border: 1px solid rgba(255,255,255,0.08); border-radius: 16px; padding: 5px; }
.segmented button { flex: 1 1 0; height: 44px; border-radius: 12px; font-size: 15px; font-weight: 700; color: var(--text-2); transition: background .15s; }
.segmented button[aria-pressed="true"] { background: var(--cyan); color: var(--cyan-ink); }

/* ---------- round ---------- */
.lines { display: flex; flex-direction: column; gap: 18px; padding: 36px 4px 24px; flex-grow: 1; overflow-y: auto; }
.line { display: flex; align-items: flex-start; gap: 10px; font-size: 21px; line-height: 1.4; font-weight: 500; color: var(--past); }
.line > span:first-child { flex: 1 1 0; }
.line.current { font-size: 27px; line-height: 1.35; font-weight: 800; color: #fff; }
.line.fresh { animation: rise .35s ease-out; }
.line.ghost { color: var(--ghost); filter: blur(7px); user-select: none; pointer-events: none; }
.badge { flex: 0 0 auto; margin-top: 6px; font-family: var(--pixel); font-size: 12px; color: var(--pc-ink, var(--pink-ink)); background: var(--pc, var(--pink)); border-radius: 8px; padding: 3px 7px; box-shadow: 0 0 14px color-mix(in srgb, var(--pc, var(--pink)) 55%, transparent); font-weight: 400; }
.mark { flex: 0 0 auto; margin-top: 6px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--pc); color: var(--pc); display: flex; align-items: center; justify-content: center; }
.chorus-divider { display: flex; align-items: center; gap: 10px; color: #6E62A0; }
.chorus-divider::before, .chorus-divider::after { content: ''; flex: 1; height: 1px; background: var(--line-dim); }

.controls { display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 24px; }

.stepper { display: flex; align-items: center; justify-content: center; margin-bottom: 26px; }
.step { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); color: var(--ghost); display: flex; align-items: center; justify-content: center; font-family: var(--pixel); font-size: 13px; transition: background .2s; }
.step.small { width: 24px; height: 24px; border-color: var(--line-dim); font-size: 0; }
.step.done, .step.now { background: var(--pc); border-color: var(--pc); color: var(--pc-ink); }
.step.now { box-shadow: 0 0 0 4px color-mix(in srgb, var(--pc) 25%, transparent); }
.bar { width: 10px; height: 3px; background: var(--line); }
.bar.small { width: 8px; background: var(--line-dim); }
.bar.done { background: var(--pc); }
.step-note { width: 34px; display: flex; justify-content: center; color: #6E62A0; }

.guess-card { display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 8px; border-radius: 30px; border: 2px solid var(--line); background: var(--well); transition: border-color .2s; }
.guess-card.active { border-color: var(--pc, var(--pink)); box-shadow: 0 0 20px color-mix(in srgb, var(--pc, var(--pink)) 18%, transparent); }
.guess-rows { flex: 1 1 0; display: flex; flex-direction: column; min-width: 0; }
.guess-row { display: flex; align-items: center; gap: 10px; height: 50px; color: var(--muted); }
.guess-row + .guess-row { border-top: 1px solid var(--line-dim); }
.guess-row input { flex: 1 1 0; min-width: 0; height: 100%; background: transparent; border: 0; outline: none; color: var(--text); font-size: 17px; text-align: right; }
.guess-row.locked { color: var(--lc, var(--cyan)); }
.guess-row.locked .answer { flex: 1 1 0; min-width: 0; font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guess-row.miss { animation: shake .4s; color: var(--pink-soft); }
.guess-row.hit { animation: pop .45s; }
.send { width: 60px; height: 60px; flex: 0 0 auto; border-radius: 50%; background: var(--pink); color: var(--pink-ink); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 0 var(--pink-deep), 0 0 18px rgba(255,62,165,0.4); transition: transform .08s, box-shadow .08s; }
.shake { animation: shake .4s; }

.vs-pill { display: flex; align-items: center; gap: 4px; background: var(--well); border-radius: 999px; padding: 4px; }
.vs-pill > div { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 999px; color: var(--pc); font-size: 15px; font-weight: 800; max-width: 150px; }
.vs-pill > div .pixel { font-size: 14px; color: var(--text-2); font-weight: 400; }
.vs-pill > div.on { background: var(--pc); color: var(--pc-ink); box-shadow: 0 0 16px color-mix(in srgb, var(--pc) 45%, transparent); }
.vs-pill > div.on .pixel { color: var(--pc-ink); }
.vs-pill .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.float-points { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font-family: var(--pixel); font-size: 56px; color: var(--gold); text-shadow: 0 0 24px rgba(255,216,77,0.6); pointer-events: none; animation: float-up 1s ease-out forwards; z-index: 5; }
.float-points.miss { color: var(--pink-soft); text-shadow: 0 0 24px rgba(255,62,165,0.6); font-family: 'Rubik', sans-serif; font-weight: 900; font-size: 44px; }

/* ---------- handoff ---------- */
.handoff { align-items: center; justify-content: center; gap: 14px; text-align: center; background: radial-gradient(360px 360px at 50% 45%, color-mix(in srgb, var(--pc) 28%, transparent), transparent 70%), var(--bg); width: 100%; }
.handoff .who { font-size: 64px; font-weight: 900; color: var(--pc); text-shadow: 0 0 30px color-mix(in srgb, var(--pc) 60%, transparent); line-height: 1.05; word-break: break-word; }
.handoff .small { color: var(--muted); font-size: 17px; }
.handoff .tap { margin-top: 40px; color: var(--muted); animation: pulse 1.4s ease-in-out infinite; }

/* ---------- reveal ---------- */
.reveal { align-items: center; }
.reveal .topbar { align-self: stretch; }
.vinyl { margin-top: 36px; width: 200px; height: 200px; border-radius: 50%; background: repeating-radial-gradient(circle at 50% 50%, #0E0E12 0 2px, #1B1A22 2px 4px); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 3px rgba(255,62,165,0.35), 0 0 60px rgba(255,62,165,0.35); animation: spin 6s linear infinite, pop-in .5s cubic-bezier(.2,1.4,.4,1); flex: 0 0 auto; }
.vinyl::before { content: ''; width: 70px; height: 70px; border-radius: 50%; background: radial-gradient(circle, var(--bg) 0 6px, var(--pink) 7px); }
.vinyl.missed { box-shadow: 0 0 0 3px rgba(169,155,209,0.25); }
.vinyl.missed::before { background: radial-gradient(circle, var(--bg) 0 6px, #6E62A0 7px); }
.big-points { margin-top: 24px; font-family: var(--pixel); font-size: 40px; color: var(--gold); text-shadow: 0 0 20px rgba(255,216,77,0.5); animation: pop .5s .2s both; }
.big-points.zero { color: var(--muted); text-shadow: none; }
.gains { margin-top: 22px; display: flex; gap: 10px; animation: pop .5s .2s both; }
.gain { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; background: color-mix(in srgb, var(--pc) 14%, transparent); color: var(--pc); font-weight: 800; }
.gain .pixel { font-weight: 400; }
.song-id { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.song-id .title { font-size: 28px; font-weight: 900; line-height: 1.15; }
.song-id .artist { font-size: 17px; font-weight: 500; color: var(--muted); }
.originals { margin-top: 26px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font-size: 15px; line-height: 1.4; color: var(--ghost); font-style: italic; overflow-y: auto; min-height: 0; flex: 0 1 auto; }

/* ---------- results ---------- */
.results { gap: 22px; padding-top: calc(env(safe-area-inset-top) + 48px); }
.hero { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.hero .label { font-family: var(--pixel); font-size: 14px; color: var(--gold); letter-spacing: 0.1em; }
.hero .name { font-size: 52px; font-weight: 900; color: var(--pc); text-shadow: 0 0 26px color-mix(in srgb, var(--pc) 60%, transparent); line-height: 1; word-break: break-word; }
.hero .total { font-family: var(--pixel); font-size: 64px; color: var(--gold); text-shadow: 0 0 26px rgba(255,216,77,0.45); line-height: 1; }
.hero .sub { font-size: 15px; color: var(--muted); }
.new-best { font-size: 14px; font-weight: 800; color: var(--pink-ink); background: var(--gold); border-radius: 999px; padding: 4px 12px; animation: pop .5s .3s both; }
.board { display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 22px; background: var(--surface); border: 1px solid rgba(255,255,255,0.08); }
.board-row { display: flex; flex-direction: column; gap: 6px; }
.board-row .top { display: flex; justify-content: space-between; align-items: baseline; }
.board-row .top span:first-child { font-size: 16px; font-weight: 800; color: var(--pc-soft); }
.board-row .pixel { font-size: 22px; }
.board-row .track { height: 12px; border-radius: 6px; background: var(--line-dim); overflow: hidden; }
.board-row .fill { height: 100%; border-radius: 6px; background: var(--pc); animation: grow .8s ease-out; transform-origin: right; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; border-radius: 18px; background: var(--well); text-align: center; }
.stat .pixel { font-size: 22px; color: var(--gold); }
.stat span:last-child { font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-direction: column; gap: 12px; }

/* ---------- sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(5,3,14,0.7); display: flex; align-items: flex-end; justify-content: center; z-index: 20; animation: fade-in .2s; }
.sheet { width: 100%; max-width: 480px; background: var(--surface); border-radius: 28px 28px 0 0; padding: 22px 24px calc(env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 14px; animation: slide-up .25s ease-out; }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 800; }
.sheet .head { display: flex; justify-content: space-between; align-items: center; }
.field { display: flex; align-items: center; gap: 12px; height: 54px; padding: 0 16px; border-radius: 16px; background: var(--well); border: 2px solid var(--line-dim); }
.field:focus-within { border-color: var(--pc); }
.field input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 17px; }
.field .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--pc); flex: 0 0 auto; }
.sheet .meta { font-size: 13px; color: var(--muted); text-align: center; }
.sheet .row { display: flex; gap: 10px; }
.sheet .row > * { flex: 1; height: 56px; border-radius: 999px; }
.link-btn { color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; align-self: center; padding: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 110px); transform: translateX(-50%); background: var(--surface-2); color: var(--text); padding: 12px 18px; border-radius: 14px; font-weight: 700; z-index: 30; animation: fade-in .2s; }

/* ---------- motion ---------- */
@keyframes fade-in { from { opacity: 0 } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) } }
@keyframes slide-up { from { transform: translateY(100%) } }
@keyframes pop-in { from { opacity: 0; transform: scale(.7) } }
@keyframes pop { 0% { transform: scale(1) } 40% { transform: scale(1.12) } 100% { transform: scale(1) } }
@keyframes shake { 0%,100% { transform: translateX(0) } 20%,60% { transform: translateX(-7px) } 40%,80% { transform: translateX(7px) } }
@keyframes eq { 0%,100% { transform: scaleY(.35) } 50% { transform: scaleY(1) } }
@keyframes spin { to { transform: rotate(360deg) } }
@keyframes pulse { 50% { opacity: .4 } }
@keyframes grow { from { transform: scaleX(0) } }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6) } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) } 100% { opacity: 0; transform: translate(-50%, -110%) scale(1) } }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
