/* Puzlr – Quiz Night, phone controller. Direction A · Spotlight.
   Token names match app/Sources/Shared/Design/Tokens.swift. */

@font-face { font-family: "Space Grotesk"; src: url("/fonts/SpaceGrotesk.ttf") format("truetype"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("/fonts/Manrope.ttf") format("truetype"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/JetBrainsMono.ttf") format("truetype"); font-weight: 100 800; font-display: swap; }

:root {
  --red: #d6362c;
  --red-deep: #a32820;
  --ink: #0e0e10;
  --surface: #1d1d21;
  --surface-dim: #202024;
  --paper: #f6f4ef;

  --answer-1: #e23b2e; --answer-2: #2e62f0; --answer-3: #ffc21a;
  --answer-4: #2ed47a; --answer-5: #7b45f0; --answer-6: #ff8a1f;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --muted: rgba(246, 244, 239, 0.72);
  --hairline: rgba(246, 244, 239, 0.14);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); }
body {
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--paper); outline-offset: 3px; }
.sg { font-family: var(--font-display); font-weight: 700; }
.mn { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(28px + env(safe-area-inset-bottom));
  gap: 18px;
  background: radial-gradient(ellipse 90% 40% at 50% -6%, rgba(214, 54, 44, 0.30), rgba(214, 54, 44, 0) 70%), var(--ink);
}
#app.warm { background: radial-gradient(ellipse 90% 40% at 50% -6%, rgba(255, 138, 31, 0.30), rgba(255, 138, 31, 0) 70%), var(--ink); }
#app.gold { background: radial-gradient(ellipse 90% 30% at 30% -6%, rgba(255, 194, 26, 0.22), rgba(255, 194, 26, 0) 70%), var(--ink); }
#app.plain { background: radial-gradient(ellipse 80% 40% at 50% 20%, rgba(246, 244, 239, 0.08), rgba(246, 244, 239, 0) 70%), var(--ink); }
#app.fill { background: radial-gradient(ellipse 80% 30% at 50% 0%, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 70%), var(--player); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; min-height: 40px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .name, .host-toggle .name { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  position: relative; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 20px;
  background: var(--player); color: var(--on-player);
}
.avatar.crowned::before {
  content: ""; position: absolute; top: -13px; left: 50%; transform: translateX(-50%);
  width: 22px; height: 14px; background: #ffc21a;
  clip-path: polygon(0 100%, 0 20%, 27% 55%, 50% 0, 73% 55%, 100% 20%, 100% 100%);
}
.tag-host { font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: .06em; padding: 5px 10px; border-radius: 999px; background: #ffc21a; color: var(--ink); }
.pill { font-size: 16px; padding: 6px 14px; border-radius: 999px; background: rgba(246, 244, 239, 0.1); white-space: nowrap; }
.pill.lg { font-size: 20px; }
.meta { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--muted); }

.wordmark { display: flex; align-items: center; gap: 8px; }
.wordmark .puzlr { font-family: var(--font-display); font-weight: 700; font-size: 30px; letter-spacing: -0.05em; line-height: 1; }
.wordmark .qn { font-family: var(--font-display); font-weight: 600; font-size: 14px; line-height: 1; padding: 6px 10px; border-radius: 999px; background: var(--red); color: #fff; }

h1.title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 32px; letter-spacing: -0.02em; line-height: 1.1; }
.label { font-family: var(--font-display); font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.label .mn { font-size: 14px; color: var(--muted); }

/* ---------- join ---------- */
.field {
  width: 100%; height: 58px; padding: 0 20px;
  border-radius: 16px; border: 3px solid var(--hairline); background: var(--surface);
  color: var(--paper); font-family: var(--font-display); font-weight: 700; font-size: 22px;
}
.field:focus { outline: none; border-color: var(--player, var(--paper)); }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 11px; }
.swatch {
  height: 64px; border-radius: 18px; background: var(--c);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--on-c);
}
.swatch:disabled { opacity: .38; cursor: not-allowed; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--paper); }
.sounds { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.sound {
  height: 52px; border-radius: 999px; border: 2px solid rgba(246, 244, 239, 0.18); background: var(--surface);
  display: flex; align-items: center; gap: 12px; padding: 0 18px;
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
}
.sound svg { width: 16px; height: 16px; flex: none; }
.sound[aria-pressed="true"] { background: var(--player, var(--paper)); color: var(--on-player, var(--ink)); border-color: transparent; }
.grow { flex: 1; }
.cta {
  height: 72px; width: 100%; border-radius: 999px;
  background: var(--player, var(--red)); color: var(--on-player, #fff);
  font-family: var(--font-display); font-weight: 700; font-size: 26px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .2);
  transition: transform .12s ease-out, filter .12s;
}
.cta:active { transform: scale(.97) translateY(2px); }
.cta:disabled { filter: saturate(.3) brightness(.6); cursor: not-allowed; }
.error { color: #ffb4ae; font-weight: 600; font-size: 15px; min-height: 20px; margin: 0; }

/* ---------- answer pad ---------- */
.heading-row { display: flex; justify-content: space-between; align-items: baseline; }
.heading-row h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 28px; letter-spacing: -0.02em; }
.heading-row .mn { font-size: 18px; color: var(--muted); }
.bar { height: 8px; border-radius: 999px; background: rgba(246, 244, 239, .14); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--red); transform-origin: left; }

.pad { flex: 1; display: grid; gap: 12px; }
.pad.four { grid-template-rows: repeat(4, minmax(0, 1fr)); }
.pad.six { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, minmax(0, 1fr)); }
.answer {
  position: relative; min-height: 64px; border-radius: 999px;
  display: flex; align-items: center; gap: 18px; padding: 0 24px 0 14px;
  background: var(--c); color: var(--on-c);
  font-family: var(--font-display); font-weight: 700; font-size: 32px; text-align: left; line-height: 1.05;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, var(--shade, .2));
  animation: pop .32s var(--spring) both;
  animation-delay: calc(var(--i) * 60ms);
  transition: transform .1s ease-out;
}
.answer:active { transform: scale(.97); }
.answer .badge { flex: none; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; background: rgba(14, 14, 16, var(--badge, .22)); }
.answer .badge svg { width: 44px; height: 44px; }
.answer .text { overflow-wrap: anywhere; }
.pad.six .answer { border-radius: 28px; flex-direction: column; justify-content: center; gap: 10px; padding: 12px; text-align: center; font-size: 26px; }
.pad.six .answer .badge { width: 64px; height: 64px; }
.pad.six .answer .badge svg { width: 34px; height: 34px; }
.pad[aria-disabled="true"] .answer { pointer-events: none; }
@keyframes pop {
  from { opacity: 0; transform: translateY(24px) scale(.6); }
  60% { opacity: 1; transform: translateY(0) scale(1.08); }
  to { opacity: 1; transform: none; }
}

/* ---------- centred states ---------- */
.centre { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 20px; }
.centre h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 48px; letter-spacing: -0.03em; line-height: 1.02; }
.centre p { margin: 0; font-size: 18px; font-weight: 500; color: var(--muted); max-width: 30ch; }
.fill .centre p, .fill .meta { color: color-mix(in srgb, var(--on-player) 88%, transparent); }
.icon-disc { width: 96px; height: 96px; border-radius: 50%; background: var(--paper); color: var(--ink); display: grid; place-items: center; }
.icon-disc svg { width: 44px; height: 44px; }
.result-disc { width: 150px; height: 150px; border-radius: 50%; background: var(--paper); color: var(--ink); display: grid; place-items: center; box-shadow: 0 0 0 14px rgba(246, 244, 239, .16); animation: pop .32s var(--spring) both; }
.result-disc.wrong { background: var(--surface); color: var(--paper); }
.result-disc svg { width: 64px; height: 64px; }
.points { font-family: var(--font-display); font-weight: 700; font-size: 64px; line-height: 1; }

.locked-answer { width: 100%; box-shadow: 0 0 0 5px var(--paper), 0 0 40px rgba(214, 54, 44, .5); animation: none; min-height: 116px; pointer-events: none; }
#app.glow { background: radial-gradient(circle at 50% 50%, rgba(214, 54, 44, .32), rgba(214, 54, 44, 0) 55%), var(--ink); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { border-radius: 24px; padding: 16px 18px; background: var(--surface); text-align: left; }
.tile.hot { background: var(--red); }
.tile .k { font-size: 14px; font-weight: 600; color: var(--muted); }
.tile.hot .k { color: rgba(255, 255, 255, .85); }
.tile .v { font-size: 34px; line-height: 1.05; margin-top: 4px; }
.scorebar { display: flex; justify-content: space-between; align-items: end; border-radius: 24px; padding: 18px 22px; background: rgba(0, 0, 0, .22); }
.scorebar .k { font-size: 14px; font-weight: 600; }
.scorebar .v { font-size: 34px; line-height: 1.1; }

/* ---------- host controls ---------- */
.card { border-radius: 24px; background: var(--surface); padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; }
.card .k { font-size: 14px; font-weight: 600; color: var(--muted); }
.card .v { font-family: var(--font-display); font-weight: 700; font-size: 20px; margin-top: 2px; }
.card .count { font-size: 24px; }
.ctl {
  width: 100%; border-radius: 28px; min-height: 96px;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  font-family: var(--font-display); font-weight: 700; font-size: 26px;
  background: #151517; border: 3px solid #25252a; color: var(--paper);
}
.ctl svg { width: 22px; height: 22px; }
.ctl.primary { background: var(--red); border-color: transparent; min-height: 150px; font-size: 30px; box-shadow: inset 0 -10px 0 rgba(0, 0, 0, .2); }
.ctl.danger { border-color: #4a1f1d; color: #f0908a; }
.ctl:disabled { opacity: .4; cursor: not-allowed; }
.footnote { text-align: center; font-size: 14px; font-weight: 500; color: var(--muted); margin: 0; }
.host-toggle { display: flex; align-items: center; gap: 8px; }
.sheet { position: fixed; inset: 0; z-index: 10; overflow: auto; }

/* ---------- picture answers (P05) ---------- */
.pad.pictures .answer { border-radius: 30px; flex-direction: column; justify-content: center; align-items: stretch; padding: 16px; gap: 0; position: relative; }
.pic-frame { flex: 1; display: grid; place-items: center; margin: 8px 0 58px; border-radius: 12px; background: repeating-linear-gradient(135deg, #e8e4da 0 10px, #f6f4ef 10px 20px); box-shadow: 0 0 0 4px #fff; }
.pic-label { color: var(--ink); font-size: 12px; padding: 6px; text-align: center; overflow-wrap: anywhere; }
.pad.pictures .answer .badge { position: absolute; left: 12px; bottom: 12px; width: 58px; height: 58px; }
.pad.pictures .answer .badge svg { width: 28px; height: 28px; }

/* ---------- buzzer (P07, P08) ---------- */
#app.buzz { background: radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--player) 30%, transparent), transparent 55%), var(--ink); }
.buzz-head { text-align: center; }
.buzz-head .live { color: color-mix(in srgb, var(--player) 60%, white); letter-spacing: .14em; text-transform: uppercase; font-size: 18px; }
.buzz-head p { margin: 8px 0 0; color: var(--muted); font-weight: 500; }
.buzz-btn {
  width: min(84vw, 330px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, color-mix(in srgb, var(--player) 70%, white), var(--player) 60%);
  color: var(--on-player); display: grid; place-items: center;
  box-shadow: 0 0 0 16px color-mix(in srgb, var(--player) 30%, transparent), 0 0 0 32px color-mix(in srgb, var(--player) 12%, transparent), inset 0 -12px 0 rgba(0,0,0,.2);
  transition: transform .08s ease-out;
}
.buzz-btn .mn { font-size: 58px; font-weight: 800; letter-spacing: .04em; }
.buzz-btn:active, .buzz-btn.pressed { transform: scale(.95); box-shadow: 0 0 0 10px color-mix(in srgb, var(--player) 30%, transparent), inset 0 8px 0 rgba(0,0,0,.2); }
.buzz-btn.locked { filter: grayscale(.8) brightness(.6); }
.buzz-btn.lost { background: var(--surface); color: rgba(246,244,239,.4); box-shadow: none; border: 5px dashed rgba(246,244,239,.25); }
.lost-pill { align-self: center; display: flex; align-items: center; gap: 12px; padding: 8px 24px 8px 8px; border-radius: 999px; background: var(--pc); color: var(--on-pc); font-size: 24px; }
.lost-initial { width: 44px; height: 44px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 22px; }

/* ---------- category pick (P10) ---------- */
#app.fill-soft { background: radial-gradient(ellipse 90% 30% at 50% -6%, color-mix(in srgb, var(--player) 35%, transparent), transparent 70%), var(--ink); }
.cats { flex: 1; display: grid; grid-template-rows: repeat(3, 1fr); gap: 14px; }
.cat-card { display: flex; align-items: center; gap: 20px; padding: 0 24px; border-radius: 28px; background: var(--surface); border: 3px solid rgba(246,244,239,.16); font-size: 28px; text-align: left; }
.cat-card:active { transform: scale(.98); border-color: var(--player); }
.cat-icon { width: 70px; height: 70px; border-radius: 20px; display: grid; place-items: center; background: var(--player); color: var(--on-player); flex: none; }
.cat-icon svg { width: 36px; height: 36px; }

/* ---------- code entry ---------- */
.code-field { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-family: var(--font-mono); font-size: 32px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 150ms !important; animation-delay: 0ms !important; transition-duration: 150ms !important; }
  @keyframes pop { from { opacity: 0; } to { opacity: 1; } }
}
