:root {
  --bg: #120f1a;
  --panel: #1c1827;
  --panel-2: #262036;
  --line: #352d4a;
  --text: #f4efe6;
  --muted: #a49cb8;
  --accent: #ff5c8a;
  --accent-2: #ffb347;
  --good: #3ddc97;
  --bad: #ff6b6b;
  --card: #f4efe6;
  --card-text: #1b1626;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
h3 { font-size: 15px; letter-spacing: .02em; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
code { background: var(--panel-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }

.screen {
  max-width: 520px; margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
.warn { color: var(--accent-2); }
.error { color: var(--bad); text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row + .row { margin-top: 8px; }

.btn {
  border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 650;
  background: var(--panel-2); transition: transform .08s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #1b0f16; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.big { width: 100%; padding: 16px; font-size: 17px; }
.panel .btn { margin-top: 10px; }
.panel .btn + .btn { margin-left: 6px; }
.icon {
  border: 1px solid var(--line); background: var(--panel); border-radius: 12px;
  min-width: 40px; height: 40px; flex: none;
}

input {
  width: 100%; background: var(--bg); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; outline: none;
}
input:focus { border-color: var(--accent); }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.bar { display: flex; align-items: center; gap: 12px; }
.bar h2 { font-size: 20px; }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  max-width: 520px; margin: 0 auto; display: flex; gap: 10px;
}
.dock .btn { flex: 1; }

/* Home */
.brand { text-align: center; padding: 24px 0 8px; display: grid; justify-items: center; gap: 10px; }
.brand h1 { font-size: 34px; letter-spacing: -.02em; }
.tag { color: var(--muted); margin: 0; }
.rules summary { cursor: pointer; font-weight: 600; }
.rules ol, .rules ul { padding-left: 20px; margin: 8px 0; }
.rules li { margin: 4px 0; }
.rules h4 { margin-top: 12px; }

/* The record */
.disc {
  width: 72px; height: 72px; border-radius: 50%; flex: none;
  background:
    radial-gradient(circle, var(--accent-2) 0 14%, var(--bg) 15% 18%, transparent 19%),
    repeating-radial-gradient(circle, #1a1524 0 2px, #2a2238 3px 4px);
  border: 2px solid var(--accent);
  box-shadow: 0 6px 24px rgba(255, 92, 138, .25);
}
.disc.big { width: 120px; height: 120px; }
.disc.spin { animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Setup */
.modes { display: grid; gap: 8px; }
.mode, .item {
  text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: grid; gap: 2px;
}
.mode span, .item span { color: var(--muted); font-size: 13px; }
.mode.on, .item.on { border-color: var(--accent); background: rgba(255, 92, 138, .08); }
.list { display: grid; gap: 8px; max-height: 320px; overflow: auto; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 8px 14px; font-weight: 600; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #1b0f16; }

/* Game */
.scores { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; align-items: stretch; }
.score {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px 10px; display: grid; min-width: 96px; flex: none;
}
.score b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.score span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.score.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.scores .icon { margin-left: auto; }

.stage { display: grid; gap: 12px; }
.turn { margin: 0; color: var(--muted); text-align: center; font-size: 14px; }
.turn b { color: var(--text); }

.mystery {
  display: flex; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.mq { display: grid; gap: 4px; }
.q { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
.hintline { margin: 0; color: var(--accent-2); font-weight: 600; }
.demo { margin: 0; font-size: 13px; color: var(--muted); }
.controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.guess { display: grid; gap: 8px; }
.guess h3 { margin-bottom: 2px; }

.gems { display: grid; grid-template-columns: auto repeat(4, 1fr); gap: 6px; align-items: stretch; }
.wallet {
  display: grid; place-items: center; padding: 0 10px; border-radius: 12px;
  background: var(--panel-2); font-size: 14px;
}
.wallet b { font-size: 20px; }
.gem-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 12px;
  padding: 8px 4px; display: grid; gap: 2px; justify-items: center;
}
.gem-btn span { font-size: 13px; font-weight: 650; }
.gem-btn small { font-size: 11px; color: var(--muted); }
.gem-btn.on { border-color: var(--accent-2); background: rgba(255, 179, 71, .12); }

.timeline h3 { margin-bottom: 8px; }
.tl { display: grid; gap: 6px; }
.card {
  background: var(--card); color: var(--card-text); border-radius: 12px; padding: 10px 14px;
  display: grid; grid-template-columns: 64px 1fr; column-gap: 12px; align-items: center;
  position: relative;
}
.card .yr, .reveal .yr { font-weight: 800; font-size: 22px; grid-row: span 2; }
.card .tt { font-weight: 650; font-size: 15px; }
.card .ar { font-size: 13px; opacity: .7; }
.card.new { box-shadow: 0 0 0 3px var(--good); animation: pop .35s ease; }
.card.miss { background: transparent; color: var(--text); border: 2px dashed var(--bad); }
.card.miss em { position: absolute; right: 10px; top: 8px; font-size: 11px; color: var(--bad); font-style: normal; }
@keyframes pop { from { transform: scale(.94); } }
.slot {
  border: 1.5px dashed var(--line); background: transparent; border-radius: 12px;
  padding: 10px; color: var(--muted); font-size: 13px; min-height: 42px;
}
.slot.on { border-color: var(--accent); color: var(--text); background: rgba(255, 92, 138, .1); font-weight: 650; }
.answer { color: var(--good); font-size: 13px; font-weight: 650; padding: 2px 6px; }

.reveal {
  background: var(--card); color: var(--card-text); border-radius: var(--radius); padding: 18px;
  display: grid; justify-items: center; text-align: center; gap: 2px;
  animation: flip .45s ease;
}
.reveal .yr { font-size: 48px; letter-spacing: -.02em; }
.reveal .tt { font-weight: 700; font-size: 18px; }
.reveal .ar { opacity: .7; }
.reveal a { margin-top: 8px; font-size: 13px; color: #1db954; font-weight: 650; text-decoration: none; }
.reveal.good { box-shadow: 0 0 0 3px var(--good); }
.reveal.bad { box-shadow: 0 0 0 3px var(--bad); }
@keyframes flip { from { transform: perspective(600px) rotateY(90deg); opacity: .3; } }

.result { border-radius: var(--radius); padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); }
.result .headline { margin: 0 0 4px; font-weight: 750; font-size: 17px; }
.result.good .headline { color: var(--good); }
.result.bad .headline { color: var(--bad); }
.result ul { margin: 4px 0 0; padding-left: 18px; font-size: 14px; }
.result .btn { margin-top: 8px; }

.mini { display: flex; flex-wrap: wrap; gap: 6px; }
.mini span { background: var(--card); color: var(--card-text); border-radius: 8px; padding: 4px 8px; font-weight: 700; font-size: 13px; }

.overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(18, 15, 26, .85);
  display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 16px;
}
.toast {
  position: fixed; z-index: 30; left: 16px; right: 16px; bottom: calc(90px + env(safe-area-inset-bottom));
  max-width: 488px; margin: 0 auto; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .disc.spin, .reveal, .card.new { animation: none; }
}

/* Rooms */
.screen.center { min-height: 100dvh; display: grid; place-content: center; justify-items: center; }
.stack { display: grid; gap: 12px; }
.panel.stack .btn { margin: 0; }
.or { margin: 0; text-align: center; color: var(--muted); font-size: 13px; }
.code { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; }
.row .code { flex: 1; min-width: 0; }
.panel .row .btn { margin: 0; flex: none; }
.credit { text-align: center; color: var(--muted); font-size: 12px; margin: 0; }
.roomcode { text-align: center; }
.roomcode .hint { margin: 0; }
.big-code { font-size: 48px; font-weight: 800; letter-spacing: .14em; margin: 4px 0 2px; color: var(--accent-2); }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--good); }
.waiting { margin: 0; flex: 1; text-align: center; color: var(--muted); padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; }
.pill {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: var(--accent-2); color: #1b0f16; font-size: 13px; font-weight: 650; padding: 4px 12px; border-radius: 999px;
}
button.score { text-align: left; color: inherit; font: inherit; }
.mq .btn { justify-self: start; margin-top: 4px; }
.mode:disabled, .chip:disabled { opacity: .75; cursor: default; }
.columns { display: grid; gap: 14px; }
.col { display: grid; gap: 12px; align-content: start; min-width: 0; }

/* Desktop: use the width instead of a phone column in the middle of the screen. */
@media (min-width: 900px) {
  .screen.wide { max-width: 1040px; padding-left: 24px; padding-right: 24px; }
  .columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .dock { max-width: 1040px; padding-left: 24px; padding-right: 24px; }
  .screen.wide .dock { justify-content: center; }
  .screen.wide .dock > * { max-width: 420px; }
  .timeline { position: sticky; top: 16px; max-height: calc(100dvh - 120px); overflow: auto; }
}
