:root {
  --bg: #12101f;
  --card: #1c1930;
  --line: #2e2a4a;
  --ink: #f2eee6;
  --muted: #a39fbf;
  --red: #d7263d;
  --blue: #1e6fd9;
  --rose: #f28fad;
  --gold: #f2c14e;
  --green: #3fb27f;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, #2a1631 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #13254a 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--rose); }

.top, main { max-width: 520px; margin: 0 auto; padding: 0 14px; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  padding-bottom: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.stealie { width: 40px; height: 40px; color: var(--ink); }
h1 { font: 700 1.35rem/1.1 Georgia, "Times New Roman", serif; margin: 0; letter-spacing: 0.02em; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.icons { display: flex; gap: 6px; }
.icons button {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); font-size: 1rem;
}

.card {
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  margin: 12px 0;
}
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 10px; }
h3 { font-size: 0.95rem; margin: 16px 0 8px; }

/* player */
.player { text-align: center; }
.play {
  width: 120px; height: 120px; border: 0; padding: 0; background: none;
  border-radius: 50%; margin: 4px auto 0; display: block;
}
.play svg { width: 100%; height: 100%; }
.ring-bg { fill: #241f3d; stroke: var(--line); stroke-width: 6; }
.ring {
  fill: none; stroke: var(--rose); stroke-width: 6; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
  transform: rotate(-90deg); transform-origin: 60px 60px;
}
.play path { fill: var(--ink); }
.play.busy .ring-bg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { stroke: var(--rose); } }
.clip-label { color: var(--muted); margin: 8px 0 10px; font-size: 0.9rem; }
.clips { display: flex; gap: 8px; justify-content: center; }
.pill {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: #241f3d; font-weight: 600;
}
.pill.active { background: var(--rose); color: #1a0f1a; border-color: var(--rose); }
.pill.locked { opacity: 0.35; }
.err { color: var(--gold); font-size: 0.9rem; margin: 10px 0 0; }

/* hints */
.hints { list-style: none; margin: 0; padding: 0; }
.hints li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.hints li:first-child { border-top: 0; }
.hints .k { color: var(--muted); }
.hints .v { text-align: right; font-weight: 600; }
.hints li.locked .v { font-weight: 400; color: #6d6890; font-size: 0.9rem; }
.hints li.open .v { animation: reveal 0.5s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(4px); } }

/* guess */
.years { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.chip {
  padding: 8px 0; border-radius: 10px;
  border: 1px solid var(--line); background: #241f3d; font-variant-numeric: tabular-nums;
}
.chip.sel { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip.tried { text-decoration: line-through; opacity: 0.35; }
.opt-label { color: var(--muted); font-size: 0.82rem; margin: 14px 0 8px; }
.day-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); }
.day-row select {
  font: inherit; color: var(--ink); background: #241f3d;
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
.primary {
  display: block; width: 100%; margin-top: 14px; padding: 12px;
  border: 0; border-radius: 12px; background: var(--red); color: #fff; font-weight: 700;
}
.primary:disabled { background: #3a3456; color: var(--muted); }
.ghost {
  width: 100%; margin-top: 14px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: transparent; font-weight: 600;
}

/* history */
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }

/* result */
.result { text-align: center; }
.headline { font: 700 1.5rem/1.2 Georgia, serif; margin: 4px 0; }
.score { margin: 0 0 10px; color: var(--muted); }
.score b { font-size: 2.2rem; color: var(--gold); }
.answer { background: #241f3d; border-radius: 12px; padding: 10px 12px; }
.answer p { margin: 2px 0; }
.answer .song { font-weight: 700; font-size: 1.1rem; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.listen { display: inline-block; margin-top: 14px; }
.countdown { color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }

.foot { text-align: center; color: var(--muted); font-size: 0.8rem; margin: 18px 0 30px; line-height: 1.8; }
.link { background: none; border: 0; padding: 0; color: var(--rose); text-decoration: underline; }

/* modal */
dialog {
  width: min(460px, calc(100vw - 28px)); max-height: 85vh;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px; padding: 18px;
}
dialog::backdrop { background: rgb(0 0 0 / 0.6); }
dialog h2 { font: 700 1.2rem Georgia, serif; text-transform: none; letter-spacing: 0; color: var(--ink); }
dialog ul { padding-left: 18px; }
dialog li { margin: 6px 0; }
.close { float: right; border: 0; background: none; font-size: 1.1rem; color: var(--muted); }
.muted { color: var(--muted); font-size: 0.85rem; }
.stat-row { display: flex; justify-content: space-between; text-align: center; }
.stat-row div { display: flex; flex-direction: column; }
.stat-row b { font-size: 1.5rem; }
.stat-row span { font-size: 0.75rem; color: var(--muted); }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.bar-row > span { width: 14px; text-align: center; }
.bar { background: var(--blue); border-radius: 4px; padding: 1px 6px; text-align: right; font-size: 0.8rem; }
.arch-list { display: flex; flex-direction: column; gap: 6px; }
.arch {
  display: grid; grid-template-columns: 50px 1fr auto; text-align: left;
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: #241f3d;
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 8px 14px; border-radius: 999px; font-weight: 600; z-index: 10;
}

[hidden] { display: none !important; }
