/* Layout: home is a one-column party menu; every game screen is a full-bleed slab
   of the deck's colour holding one giant word. Single dark look by choice. */
:root {
  --ink: #170F1F; --panel: #241931; --line: #3b2d4b; --cream: #FFF4E6; --muted: #b9a8c8;
  --frost: #FF5C8A; --sprinkle: #FFD23F; --ok: #2BD67B; --late: #ff6b5e; --hurry: #b3001b;
  --silver: #d9d2e3; --bronze: #e0915a;
  --deck: var(--frost); /* set per deck by main.js */
  --display: "Bagel Fat One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { height: 100% }
body {
  margin: 0; background: var(--ink); color: var(--cream);
  font-family: var(--body); font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
body.in-game { overflow: hidden; overscroll-behavior: none }
button, input { font: inherit; color: inherit }
button { cursor: pointer }
:focus-visible { outline: 3px solid var(--sprinkle); outline-offset: 3px }
h1, h2, h3 { margin: 0; text-wrap: balance }

/* ---------- pages (home, results) ---------- */
.page {
  max-width: 820px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: calc(env(safe-area-inset-top, 0px) + 28px) calc(env(safe-area-inset-bottom, 0px) + 56px);
  display: flex; flex-direction: column; gap: 32px;
}
.label { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted) }
.fine { margin: 0; color: var(--muted); font-size: 14px }
.section { display: flex; flex-direction: column; gap: 14px }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center }
.row.spread { justify-content: space-between }

.logo { font-family: var(--display); font-weight: 400; font-size: clamp(56px, 16vw, 120px); line-height: .9; display: flex }
.logo span { display: inline-block; animation: drop .7s cubic-bezier(.3, 1.6, .5, 1) both }
.logo span:nth-child(1) { color: var(--frost) }
.logo span:nth-child(2) { color: var(--sprinkle); animation-delay: .05s }
.logo span:nth-child(3) { color: #6EC1FF; animation-delay: .1s }
.logo span:nth-child(4) { color: #A8E05F; animation-delay: .15s }
.logo span:nth-child(5) { color: #B79CFF; animation-delay: .2s }
.logo span:nth-child(6) { color: #FF9B54; animation-delay: .25s }
@keyframes drop { from { transform: translateY(-28px) rotate(-8deg) } to { transform: none } }
.logo { padding-bottom: .14em } /* room for the g descenders */
.tagline { font-size: clamp(17px, 4.4vw, 21px); max-width: 34ch; margin: 0 }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px }
.steps li { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1.5px solid var(--line); border-radius: 16px; min-width: 0 }
.steps b { font-family: var(--display); font-weight: 400; font-size: 24px; line-height: 1; color: var(--sprinkle) }
.steps p { margin: 0; font-size: clamp(13px, 3.6vw, 16px); line-height: 1.3; font-weight: 600 }
#home { gap: 24px }

/* 12 decks: fills evenly at 2, 3 or 4 columns */
.decks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px }
@media (min-width: 560px) { .decks { grid-template-columns: repeat(3, 1fr) } }
@media (min-width: 760px) { .decks { grid-template-columns: repeat(4, 1fr) } }
.deck {
  border: 0; border-radius: 20px; padding: 16px 14px 14px; min-height: 136px; min-width: 0;
  text-align: left; display: flex; flex-direction: column; gap: 4px;
  background: var(--c); color: var(--ink); transition: transform .15s ease;
}
.deck:active { transform: scale(.96) rotate(-1deg) }
.deck h3 { font-family: var(--display); font-weight: 400; font-size: clamp(20px, 5.6vw, 24px); line-height: 1.02; overflow-wrap: anywhere }
.deck .count { margin: 0; font-size: 13px; font-weight: 700; opacity: .7; font-variant-numeric: tabular-nums }
.chip {
  border: 1.5px solid currentColor; border-radius: 99px; padding: 3px 9px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.deck .chip { margin-top: auto; align-self: flex-start }

.settings { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 99px; padding: 3px }
.seg input { position: absolute; opacity: 0; pointer-events: none }
.seg label { padding: 7px 16px; border-radius: 99px; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums }
.seg input:checked + label { background: var(--cream); color: var(--ink) }
.seg input:focus-visible + label { outline: 3px solid var(--sprinkle); outline-offset: 2px }
.toggle { display: inline-flex; gap: 10px; align-items: center; font-weight: 700; cursor: pointer }
.toggle input { width: 20px; height: 20px; accent-color: var(--frost) }

.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-top: 1.5px solid var(--line) }
.board li { display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: center; padding: 10px 2px; border-bottom: 1.5px solid var(--line) }
.board .rank { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums }
.board li:nth-child(1) .rank { background: var(--sprinkle); color: var(--ink) }
.board li:nth-child(2) .rank { background: var(--silver); color: var(--ink) }
.board li:nth-child(3) .rank { background: var(--bronze); color: var(--ink) }
.board li:nth-child(1) .who > span { font-size: 19px; font-weight: 800 }
.board li:nth-child(1) .pts { font-size: 30px }
.board .who { min-width: 0; overflow-wrap: anywhere }
.board .who small { color: var(--muted); font-size: 13px; margin-left: 6px }
.board .pts { font-family: var(--display); font-size: 22px; font-variant-numeric: tabular-nums; color: var(--sprinkle) }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; font-size: 14px }

.btn { border: 0; border-radius: 99px; padding: 15px 26px; font-weight: 800; font-size: 17px; background: var(--cream); color: var(--ink); transition: transform .12s ease }
.btn:active { transform: scale(.96) }
.btn:disabled { opacity: .55 }
.btn.hot { background: var(--frost) }
.btn.ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 2px currentColor }

/* ---------- full-bleed game slabs ---------- */
.slab {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  position: fixed; inset: 0; z-index: 5; background: var(--deck); color: var(--ink); overflow: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) max(20px, env(safe-area-inset-right, 0px))
           calc(env(safe-area-inset-bottom, 0px) + 18px) max(20px, env(safe-area-inset-left, 0px));
}
.quit {
  position: absolute; z-index: 2; width: 44px; height: 44px; border-radius: 50%; border: 0;
  top: calc(env(safe-area-inset-top, 0px) + 12px); right: max(12px, env(safe-area-inset-right, 0px));
  background: rgba(23, 15, 31, .14); color: var(--ink); font-size: 22px; font-weight: 800; line-height: 1;
}

.btn.small { padding: 10px 18px; font-size: 15px }

#spin { background: var(--ink); color: var(--cream); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; text-align: center }
.wheel-wrap { position: relative; width: min(84vw, 56vh, 440px); aspect-ratio: 1; max-width: 100%; flex: none }
#wheel { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 5px var(--cream); will-change: transform; overflow: hidden }
#wheel span {
  position: absolute; left: 50%; top: 50%; width: 50%; height: 0; transform-origin: 0 0;
  display: flex; align-items: center; justify-content: flex-end; padding-right: 12px;
  font-weight: 800; font-size: clamp(10px, 2.8vw, 14px); color: var(--ink); white-space: nowrap;
}
#wheelHub {
  position: absolute; left: 50%; top: 50%; width: 22%; aspect-ratio: 1; translate: -50% -50%; border-radius: 50%;
  border: 4px solid var(--ink); background: var(--cream); color: var(--ink);
  font-family: var(--display); font-size: clamp(14px, 4vw, 20px);
}
#pointer {
  position: absolute; z-index: 2; left: 50%; top: -14px; width: 30px; height: 38px; translate: -50% 0;
  background: var(--cream); clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: 50% 0;
}
#pointer.bump { animation: bump .12s ease-out }
@keyframes bump { 50% { transform: rotate(-14deg) } }
.spin-hint { margin: 0; color: var(--muted); font-weight: 700; min-height: 1.5em }
.spin-result { display: flex; flex-direction: column; align-items: center; gap: 10px }
.spin-result h2 { font-family: var(--display); font-weight: 400; font-size: clamp(36px, 9vw, 60px); line-height: 1 }
@media (orientation: landscape) and (max-height: 520px) {
  #spin { flex-direction: row; justify-content: center; gap: 32px }
  .wheel-wrap { width: min(78vh, 48vw) }
}

#ready { display: flex; flex-direction: column; justify-content: center }
#ready .inner { max-width: 640px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 20px }
#ready .chip { align-self: flex-start; font-size: 12px }
#ready h2 { font-family: var(--display); font-weight: 400; font-size: clamp(44px, 12vw, 88px); line-height: .95 }
#ready .tip { font-size: 19px; font-weight: 600; margin: 0; max-width: 36ch }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px }
.controls div { background: rgba(23, 15, 31, .1); border-radius: 16px; padding: 12px 14px; font-weight: 600; font-size: 15px }
.controls strong { display: block; font-family: var(--display); font-weight: 400; font-size: 26px; line-height: 1.1 }
#ready .btn { background: var(--ink); color: var(--cream); align-self: flex-start; font-size: 19px; padding: 17px 34px }

#count { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px }
#countNum { font-family: var(--display); font-size: min(52vh, 52vw); line-height: .9 }
#countNum.pop { animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) }
@keyframes pop { from { transform: scale(.4) } to { transform: none } }
#count p { margin: 0; font-size: clamp(18px, 4vw, 26px); font-weight: 700 }
#count .count-mode { font-size: 15px; opacity: .7; min-height: 1.4em }

#play { display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none }
.hud { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-right: 56px; font-weight: 800 }
.hud .deckname { font-size: 15px; letter-spacing: .08em; text-transform: uppercase; opacity: .75; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.hud .nums { display: flex; gap: 18px; align-items: baseline; font-variant-numeric: tabular-nums }
#tally { white-space: nowrap }
#tally::after { content: " ✓"; font-size: .7em }
#clock { font-family: var(--display); font-size: 42px; line-height: 1; min-width: 2ch; text-align: right }
#play.hurry #clock { color: var(--hurry); animation: beat 1s infinite }
@keyframes beat { 0%, 100% { transform: none } 15% { transform: scale(1.18) } }
.stage { min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden }
#word {
  width: 100%; text-align: center; font-weight: 800; font-variation-settings: "opsz" 96; line-height: 1;
  letter-spacing: -.025em; overflow-wrap: normal; word-break: normal; hyphens: none; text-wrap: balance;
}
.zone { text-align: center; font-size: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .6 }
.track { position: absolute; left: 0; right: 0; bottom: 0; height: calc(env(safe-area-inset-bottom, 0px) + 10px); background: rgba(23, 15, 31, .15) }
#bar { height: 100%; background: var(--ink); transform-origin: left; will-change: transform }
#play.hurry #bar { background: var(--hurry) }

#flash { position: fixed; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; pointer-events: none }
#flash.is-ok { background: var(--ok); color: var(--ink) }
#flash.is-pass { background: var(--ink); color: var(--cream) }
#flash span { font-family: var(--display); font-size: min(26vw, 40vh); line-height: 1; animation: pop .45s cubic-bezier(.3, 1.6, .5, 1) }

/* ---------- results ---------- */
.score { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap }
.score b { font-family: var(--display); font-weight: 400; font-size: clamp(110px, 32vw, 180px); line-height: .8; color: var(--sprinkle); font-variant-numeric: tabular-nums }
.score h1 { font-family: var(--display); font-weight: 400; font-size: clamp(34px, 8vw, 52px); line-height: 1 }
.score p { margin: 6px 0 0; font-size: 19px }
.score .fine { margin-top: 4px }
.record { display: inline-block; margin-bottom: 10px; padding: 4px 12px; border-radius: 99px; background: var(--sprinkle); color: var(--ink); font-weight: 800; font-size: 14px; animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) .9s both }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20 }
.words { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px }
.words li { padding: 7px 13px; border-radius: 99px; font-weight: 700; font-size: 15px; max-width: 100% }
.words .ok { background: var(--ok); color: var(--ink) }
.words .pass { box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted); text-decoration: line-through }
.words .late { box-shadow: inset 0 0 0 1.5px var(--late); color: var(--late) }
.save { display: flex; gap: 10px; flex-wrap: wrap }
.save input { flex: 1 1 200px; min-width: 0; background: var(--panel); border: 1.5px solid var(--line); border-radius: 99px; padding: 13px 18px; font-size: 16px }

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