/* Game Night. Dark on purpose: it's played in living rooms at night, phones in hand. */
:root {
  color-scheme: dark;
  --bg: #13111c;
  --surface: #1d1a2b;
  --surface-2: #272339;
  --line: #36304f;
  --text: #f4f2fb;
  --muted: #a49fbf;
  --accent: #ffcf4a;          /* default; each game sets its own */
  --good: #4fd69c;
  --bad: #ff6b6b;
  --warn: #ffb057;
  --red-team: #ff6b7d;
  --blue-team: #5aa9ff;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --display: "Bricolage Grotesque", -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; min-height: 100dvh; }
#app { max-width: 600px; margin: 0 auto; padding-inline: 16px; padding-block: 0 calc(32px + var(--safe-b)); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, textarea, select { font: inherit; color: inherit; width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border-radius: 14px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.btn-primary { background: var(--accent); color: #17131f; border: 0; }
.btn-ghost { background: none; }
.btn-small { width: auto; padding: 9px 13px; font-size: 14px; border-radius: 11px; }
.btn:active:not(:disabled) { transform: scale(.98); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.label { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.big { font-family: var(--display); font-size: 30px; font-weight: 800; line-height: 1.15; text-wrap: balance; word-break: break-word; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.bad { color: var(--bad); border-color: var(--bad); }
.pill.accent { color: var(--accent); border-color: var(--accent); }

/* top bar */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; display: flex; align-items: center; gap: 10px; padding: 12px 0 10px; background: rgba(19,17,28,.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.topbar .title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code { font-family: var(--display); font-weight: 800; letter-spacing: .14em; }

/* home */
.hero { text-align: center; padding: 40px 0 20px; }
.hero h1 { font-size: 40px; line-height: 1.05; }
.hero p { color: var(--muted); max-width: 34ch; margin: 10px auto 0; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; text-align: center; }

/* game menu */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.game-card { text-align: left; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 4px; align-content: start; }
.game-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.game-card.cant { opacity: .5; }
.game-card .emoji { font-size: 28px; line-height: 1; }
.game-card .name { font-weight: 800; font-family: var(--display); font-size: 17px; }
.game-card .meta { font-size: 12px; color: var(--muted); }
.chosen { display: grid; gap: 12px; }
.choices { display: flex; gap: 6px; flex-wrap: wrap; }
.choice { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 600; font-size: 14px; }
.choice.on { background: var(--accent); color: #17131f; border-color: var(--accent); }

/* people */
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.people li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.people .name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.dot.away { background: var(--line); }
.score { font-weight: 800; }

/* game screens */
.game { display: grid; gap: 14px; }
.round-bar { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.timer { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.timer.low { color: var(--bad); }
.answers { display: grid; gap: 8px; }
.answer { text-align: left; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 600; display: flex; justify-content: space-between; gap: 10px; }
.answer.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--surface-2)); }
.answer.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 22%, var(--surface-2)); }
.answer.wrong { border-color: var(--bad); }
.waiting { text-align: center; color: var(--muted); padding: 8px; }
.standings { display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
.standings .line { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 10px; }
.standings .line.you { background: var(--surface-2); }
.feed { display: grid; gap: 4px; font-size: 14px; max-height: 180px; overflow-y: auto; }
.toast { position: fixed; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: calc(100% - 32px); }
.error { background: color-mix(in srgb, var(--bad) 14%, transparent); border: 1px solid var(--bad); border-radius: 12px; padding: 12px 14px; }

/* boards and grids used by several games */
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.grid5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.tile { min-height: 52px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; text-align: center; padding: 5px 3px; font-size: 13px; font-weight: 700; line-height: 1.15; word-break: break-word; hyphens: auto; }
.tile.hl { background: var(--accent); color: #17131f; border-color: transparent; }
.letters .tile { font-size: 26px; font-family: var(--display); min-height: 0; aspect-ratio: 1; }
.letters .tile.sel { background: var(--accent); color: #17131f; }

/* wordle */
.wrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.wcell { aspect-ratio: 1; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; font-family: var(--display); font-size: 24px; font-weight: 800; text-transform: uppercase; }
.m0 { background: #3a3550; border-color: #3a3550; }
.m1 { background: #c9a227; border-color: #c9a227; color: #17131f; }
.m2 { background: #3fa66b; border-color: #3fa66b; }
.mini { display: grid; grid-template-columns: repeat(5, 10px); gap: 2px; }
.mini span { width: 10px; height: 10px; border-radius: 2px; }
.kb { display: grid; gap: 6px; }
.kb .krow { display: flex; gap: 4px; justify-content: center; }
.kb button { flex: 1; max-width: 42px; padding: 13px 0; border-radius: 7px; background: #4a4566; font-weight: 700; text-transform: uppercase; font-size: 14px; }
.kb button.wide { max-width: 68px; flex: 1.6; font-size: 12px; }

/* reaction */
.pad { min-height: 46vh; border-radius: 22px; display: grid; place-items: center; text-align: center; font-family: var(--display); font-size: 32px; font-weight: 800; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.pad.wait { background: #b8323f; }
.pad.go { background: #2f9e5f; }
.pad.done { background: var(--surface-2); font-size: 22px; }

/* sketch */
.canvas-wrap { background: #fff; border-radius: 14px; overflow: hidden; touch-action: none; aspect-ratio: 1; }
.canvas-wrap canvas { width: 100%; height: 100%; display: block; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); }
.swatch.on { outline: 3px solid var(--text); outline-offset: 1px; }

/* wavelength */
.dial { position: relative; height: 54px; border-radius: 12px; background: linear-gradient(90deg, #5aa9ff, #a37bff 50%, #ff6b7d); }
.dial .mark { position: absolute; top: -6px; bottom: -6px; width: 4px; margin-left: -2px; border-radius: 3px; background: #fff; }
.dial .mark.target { background: var(--accent); width: 10px; margin-left: -5px; opacity: .9; }
.dial .mark small { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); font-size: 11px; white-space: nowrap; margin-top: 8px; color: var(--muted); }
.ends { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; }
input[type=range] { padding: 0; background: none; border: 0; accent-color: var(--accent); height: 36px; }

/* teams */
.team0 { color: var(--red-team); }
.team1 { color: var(--blue-team); }
.tile.k0 { background: var(--red-team); color: #1b0d10; border-color: transparent; }
.tile.k1 { background: var(--blue-team); color: #0b1522; border-color: transparent; }
.tile.kn { background: #d9cfb4; color: #2a2617; border-color: transparent; }
.tile.kx { background: #000; color: #fff; border-color: #fff; }
.tile.hint0 { box-shadow: inset 0 -5px 0 var(--red-team); }
.tile.hint1 { box-shadow: inset 0 -5px 0 var(--blue-team); }
.tile.hintn { box-shadow: inset 0 -5px 0 #d9cfb4; }
.tile.hintx { box-shadow: inset 0 0 0 3px #000, inset 0 -5px 0 #000; }
.tile.revealed { opacity: .9; }

@media (max-width: 380px) { .tile { font-size: 11px; min-height: 46px; } .big { font-size: 26px; } }
@media (prefers-reduced-motion: no-preference) { .answer, .tile, .choice { transition: background .15s, border-color .15s; } }

/* After answers lock, keep the right/picked answers bright and dim the rest. */
.answers .answer:disabled { opacity: .55; cursor: default; }
.answers .answer.right:disabled, .answers .answer.on:disabled, .answers .answer.wrong:disabled { opacity: 1; }
.tile:disabled { opacity: 1; cursor: default; }
.kb button.m0 { background: #24202f; color: #6f6a88; }
.kb button.m1 { background: #c9a227; color: #17131f; }
.kb button.m2 { background: #3fa66b; color: #fff; }
