:root {
  --bg: #f6f3fb;
  --surface: #ffffff;
  --surface-2: #ece7f5;
  --text: #1a1033;
  --muted: #6c6283;
  --border: #ddd5ea;
  --primary: #6495ed;        /* cornflower blue for filled highlights */
  --primary-text: #0a1633;   /* dark navy reads well on the blue */
  --link: #2f5fc4;           /* deeper blue so text is readable on white */
  --accent: #f59e0b;         /* amber for years */
  --good: #16a34a;
  --bad: #dc2626;
  --danger: #dc2626;
  --vinyl: #17112a;
  --radius: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #120a24;
    --surface: #1d1335;
    --surface-2: #2a1f47;
    --text: #f5f0ff;
    --muted: #a99cc6;
    --border: #33285a;
    --link: #8fb0f3;
    --accent: #fbbf24;
    --good: #4ade80;
    --bad: #f87171;
    --danger: #f05252;
    --vinyl: #07040f;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, input, select { font: inherit; color: inherit; }

button {
  touch-action: manipulation;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  background: var(--surface-2);
  user-select: none;
  -webkit-user-select: none;
}
button:active:not(:disabled) { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: default; }
[hidden] { display: none !important; }

.primary { background: var(--primary); color: var(--primary-text); }
.secondary { background: var(--surface-2); }
.danger { background: var(--danger); color: #fff; }
.ghost { background: transparent; color: var(--link); }
.wide { width: 100%; }
.big { padding: 16px; font-size: 1.1rem; }
.center { text-align: center; }

main { padding: 0 16px 24px; max-width: 560px; margin: 0 auto; display: grid; gap: 14px; }

/* Setup */
.hero { text-align: center; padding: 28px 16px 18px; }
.hero h1 { margin: 10px 0 2px; font-size: 2.2rem; letter-spacing: -0.02em; }
.tagline { margin: 0; color: var(--muted); }

.logo { display: inline-grid; place-items: center; }
.disc {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--bg) 0 6%, var(--primary) 7% 30%, transparent 31%),
    repeating-radial-gradient(circle, var(--vinyl) 0 2px, #2c2346 3px 4px);
  box-shadow: 0 6px 20px rgb(100 149 237 / 0.35);
  animation: spin 6s linear infinite;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 12px;
}
.card h2 { margin: 0; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.help { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.4; }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.player-list:empty::before { content: "Add at least one player."; color: var(--muted); font-size: 0.9rem; }
.player-list li {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 600;
}
.player-list button { padding: 8px 12px; background: transparent; color: var(--muted); border-radius: 999px; }

.add-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input[type="text"], input[type="number"], select {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 16px; /* prevents iOS zoom on focus */
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
}
.segmented.wide { display: flex; }
.segmented button {
  flex: 1;
  padding: 9px 6px;
  border-radius: 9px;
  white-space: nowrap;
  background: transparent;
  color: var(--muted);
}
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); }

.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-label { font-weight: 600; }
.field .segmented button { padding: 9px 14px; }

.era { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.era label { display: grid; gap: 6px; font-weight: 600; font-size: 0.9rem; color: var(--muted); }
.era select { color: var(--text); font-weight: 600; }

/* Turn */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0; }
.topbar .ghost { width: 48px; font-size: 1.2rem; color: var(--muted); }
.topbar-spacer { width: 48px; }
.round-label { margin: 0; font-weight: 700; color: var(--muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.06em; }

.scoreboard {
  list-style: none;
  margin: 0;
  padding: 2px 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.scoreboard li {
  flex: none;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
  font-size: 0.9rem;
  border: 2px solid transparent;
}
.scoreboard li.current { border-color: var(--primary); }
.scoreboard .pts { color: var(--accent); font-variant-numeric: tabular-nums; }

.turn-label { margin: 0; text-align: center; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }

.song-card {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface);
}
.record {
  position: relative;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--primary) 0 30%, transparent 31%),
    repeating-radial-gradient(circle, var(--vinyl) 0 2px, #2c2346 3px 4px);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.record img {
  width: 62%;
  height: 62%;
  border-radius: 50%;
  object-fit: cover;
}
.label-hole { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); }
.record.playing { animation: spin 3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.song-info { min-width: 0; }
.song-info p { margin: 0; }
.song-year { font-size: 2.6rem; font-weight: 800; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }
.song-title { margin-top: 6px !important; font-weight: 700; font-size: 1.1rem; }
.song-artist { color: var(--muted); }
.song-card.revealed .song-year { animation: pop 0.4s ease-out; }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }

.player { display: grid; gap: 10px; justify-items: center; }
.play-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgb(100 149 237 / 0.35);
}
.icon-play {
  width: 0;
  height: 0;
  margin-left: 6px;
  border-style: solid;
  border-width: 14px 0 14px 22px;
  border-color: transparent transparent transparent var(--primary-text);
}
.play-btn.playing .icon-play {
  width: 22px;
  height: 26px;
  margin: 0;
  border: none;
  border-left: 7px solid var(--primary-text);
  border-right: 7px solid var(--primary-text);
}
.play-btn.loading { opacity: 0.6; }
.progress { width: 100%; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--primary); transition: width 0.25s linear; }

.panel-title { margin: 4px 0 8px; font-weight: 700; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }

/* Timeline: cards in year order with a slot between each */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tl-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
}
.tl-card .y { font-weight: 800; font-size: 1.2rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.tl-card .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-card .a { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-card.new { outline: 2px solid var(--good); animation: pop 0.4s ease-out; }
.tl-card.wrong { outline: 2px solid var(--bad); opacity: 0.8; }
.slot {
  width: 100%;
  padding: 10px;
  border-radius: 12px;
  border: 2px dashed var(--border);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}
.slot[aria-pressed="true"] { border-style: solid; border-color: var(--primary); background: rgb(100 149 237 / 0.12); color: var(--text); }
.timeline.locked .slot { display: none; }

/* Guess the year */
.guess-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.guess-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  background: var(--surface);
}
.guess-list .name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 40px; padding: 10px 0; }
.stepper input {
  width: 76px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.guess-list .verdict { font-weight: 700; font-variant-numeric: tabular-nums; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--muted); }

.result { margin: 0; text-align: center; font-size: 1.2rem; font-weight: 800; }
.result.good { color: var(--good); }
.result.bad { color: var(--bad); }

.actions { display: grid; gap: 10px; }

/* Winner */
.win { text-align: center; padding-top: 48px; }
.trophy { font-size: 4.5rem; margin: 0; animation: pop 0.6s ease-out; }
.win h1 { margin: 0; font-size: 2rem; }
.standings { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.standings li { display: flex; justify-content: space-between; padding: 12px 16px; border-radius: 12px; background: var(--surface); font-weight: 600; }
.standings li:first-child { outline: 2px solid var(--accent); }
.standings .pts { color: var(--accent); }

/* Bottom sheet */
.sheet {
  width: 100%;
  max-width: 560px;
  margin: auto auto 0;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
  border: none;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--text);
}
.sheet::backdrop { background: rgb(0 0 0 / 0.5); }
.sheet form { display: grid; gap: 12px; }
.sheet-title { margin: 0; font-size: 1.15rem; font-weight: 700; text-align: center; }
.sheet-message { margin: 0 0 4px; text-align: center; color: var(--muted); line-height: 1.4; }
.sheet-body p { margin: 0 0 10px; line-height: 1.45; }
.sheet-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
