/* ============================================================
   Berk Games - game night on every phone
   Palette: ink navy felt, dice red, cream, bonus gold
   ============================================================ */
:root {
  --bg: #101728;
  --bg-deep: #0B101D;
  --surface: #1B2436;
  --surface-2: #232F47;
  --line: #2E3B57;
  --text: #F2EFE6;
  --text-dim: #9AA5BC;
  --red: #E5484D;
  --red-press: #C93A3F;
  --accent: #E5484D;
  --accent-press: #C93A3F;
  --gold: #EFB54B;
  --green: #3FBF7F;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --tap: 48px;
  --shield: rgba(13, 17, 29, 0.97);
  --dim-hex: #3A4763;
  --row-line: #212C42;
  --row-press: #202B42;
  --track: #4A5878;
  --sel-bg: #2C3852;
}

/* ============================================================
   Light mode - saved per device, applied before first paint
   ============================================================ */
html.light {
  --bg: #FAF6EC;
  --bg-deep: #F1EBDD;
  --surface: #FFFFFF;
  --surface-2: #F3EEE2;
  --line: #DDD5C2;
  --text: #212940;
  --text-dim: #6E7891;
  --shadow: 0 8px 24px rgba(80, 70, 40, 0.18);
  --shield: rgba(241, 235, 221, 0.98);
  --dim-hex: #A8A08A;
  --row-line: #E7E0CE;
  --row-press: #EFE9D9;
  --track: #CFC7B2;
  --sel-bg: #EFE4C8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 50% -200px, #1A2540 0%, var(--bg) 60%),
    var(--bg);
  color: var(--text);
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

/* ---------- typography ---------- */
h1, h2, h3, .logo, .sub-title, .modal-title, .sheet-title, .game-name {
  font-family: 'Titan One', 'Nunito', sans-serif;
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* ---------- home ---------- */
.home-header { text-align: center; padding: 28px 0 20px; }

.logo {
  font-size: 44px;
  margin: 10px 0 4px;
  color: var(--text);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
.logo::first-letter { color: var(--red); }

.tagline { color: var(--text-dim); margin: 0; font-weight: 600; }

/* animated die in header */
.logo-dice { display: flex; justify-content: center; }
.die {
  width: 56px; height: 56px;
  background: linear-gradient(160deg, #FCF9F0, #E8E2D2);
  border-radius: 14px;
  box-shadow: var(--shadow), inset 0 -4px 0 rgba(0,0,0,0.12);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  padding: 9px;
  animation: dieWiggle 4s ease-in-out infinite;
}
.die i {
  width: 9px; height: 9px;
  background: var(--red);
  border-radius: 50%;
  align-self: center; justify-self: center;
}
.die i:nth-child(1) { grid-area: 1 / 1; }
.die i:nth-child(2) { grid-area: 2 / 2; }
.die i:nth-child(3) { grid-area: 3 / 3; }

@keyframes dieWiggle {
  0%, 88%, 100% { transform: rotate(-4deg); }
  92% { transform: rotate(6deg) translateY(-4px); }
  96% { transform: rotate(-6deg); }
}
@media (prefers-reduced-motion: reduce) {
  .die { animation: none; }
}

.home-actions { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-title { font-size: 18px; margin: 0 0 14px; color: var(--text); }

.game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.game-tile {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 16px;
  min-height: 92px;
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.game-tile:active { transform: scale(0.96); border-color: var(--red); }
.game-tile .gt-icon { font-size: 34px; display: block; margin-bottom: 6px; }
.game-tile .gt-sub { display: block; color: var(--text-dim); font-size: 12px; font-weight: 600; margin-top: 2px; }

.game-tile.coming-soon { opacity: 0.45; cursor: default; }
.game-tile.coming-soon:active { transform: none; border-color: var(--line); }

/* code entry */
.code-entry { display: flex; gap: 10px; }
.code-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-deep);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Titan One', sans-serif;
  font-size: 26px;
  letter-spacing: 10px;
  text-align: center;
  text-transform: uppercase;
  padding: 10px 4px 10px 14px;
  height: 60px;
}
.code-input:focus { outline: none; border-color: var(--red); }
.code-input::placeholder { color: var(--dim-hex); letter-spacing: 6px; }

.rejoin-card { border-color: var(--gold); }

.home-footer { text-align: center; color: var(--dim-hex); font-weight: 700; padding-top: 26px; font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }

/* ---------- buttons ---------- */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 16px;
  min-height: var(--tap);
  padding: 0 20px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #FFF6F0;
  box-shadow: 0 4px 0 var(--accent-press);
}
.btn-primary:active { box-shadow: 0 1px 0 var(--accent-press); transform: translateY(3px); }

.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.btn-block { display: block; width: 100%; margin-top: 12px; }
.btn-small { min-height: 40px; font-size: 14px; }

.btn-back, .btn-trophy {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  width: 44px; height: 44px;
  border-radius: 12px;
  font-size: 20px;
  cursor: pointer;
  flex: 0 0 auto;
}

.error-text { color: var(--red); font-weight: 700; min-height: 20px; margin: 8px 0 0; font-size: 14px; }

/* ---------- join view ---------- */
.sub-header { display: flex; align-items: center; gap: 14px; padding: 8px 0 18px; }
.sub-title { font-size: 24px; margin: 0; }

.field-label {
  display: block;
  color: var(--text-dim);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 16px 0 8px;
}
.field-label:first-child { margin-top: 0; }

.text-input {
  width: 100%;
  background: var(--bg-deep);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  padding: 14px;
}
.text-input:focus { outline: none; border-color: var(--red); }

.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.emoji-btn {
  font-size: 26px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  min-height: 52px;
  cursor: pointer;
}
.emoji-btn.selected { border-color: var(--gold); background: #2C3852; }

.color-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.color-btn {
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
}
.color-btn.selected { border-color: var(--text); transform: scale(1.1); }

/* ---------- game view ---------- */
.game-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 12px;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--bg) 82%, transparent);
  z-index: 5;
}
.game-header-mid { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.game-name { font-size: 20px; white-space: nowrap; }

.code-pill {
  background: var(--surface-2);
  border: 1px dashed var(--gold);
  color: var(--gold);
  font-family: 'Titan One', sans-serif;
  font-size: 15px;
  letter-spacing: 3px;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

/* player tabs */
.player-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  scrollbar-width: none;
}
.player-tabs::-webkit-scrollbar { display: none; }

.ptab {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
  padding: 8px 14px 8px 10px;
  cursor: pointer;
  position: relative;
}
.ptab.active { border-color: var(--ptab-color, var(--red)); background: var(--surface-2); }
.ptab .pt-emoji { font-size: 18px; }
.ptab .pt-total { color: var(--text-dim); font-size: 13px; }
.ptab .pt-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--track);
  position: absolute; top: 2px; right: 4px;
}
.ptab .pt-dot.online { background: var(--green); }
.ptab .pt-host { font-size: 11px; }

/* ---------- scorecard ---------- */
.scorecard { display: flex; flex-direction: column; gap: 14px; padding-bottom: 90px; }

.sc-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.sc-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}
.sc-section-head .sec-total { color: var(--text); font-size: 15px; }

.sc-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  min-height: 56px;
  border-bottom: 1px solid var(--row-line);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.sc-row:last-child { border-bottom: none; }
.sc-row:active { background: var(--row-press); }
.sc-row.readonly { cursor: default; }
.sc-row.readonly:active { background: transparent; }

.sc-row .row-icon { font-size: 20px; width: 26px; text-align: center; flex: 0 0 auto; }
.sc-row .row-label { flex: 1; font-weight: 700; }
.sc-row .row-sub { display: block; color: var(--text-dim); font-size: 11.5px; font-weight: 600; }
.sc-row .row-value {
  font-family: 'Titan One', sans-serif;
  font-size: 20px;
  min-width: 44px;
  text-align: right;
  color: var(--text-dim);
}
.sc-row.filled .row-value { color: var(--text); }
.sc-row.filled.zeroed .row-value { color: var(--red); }
.sc-row.filled { background: rgba(63, 191, 127, 0.05); }

.sc-row.bonus-row { background: rgba(239, 181, 75, 0.06); cursor: default; }
.sc-row.bonus-row .row-value { color: var(--gold); }
.bonus-progress { color: var(--gold); font-size: 11.5px; font-weight: 700; }

/* yahtzee bonus checkboxes */
.yb-checks { display: flex; gap: 10px; }
.yb-check {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--bg-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: transparent;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.yb-check:active { transform: scale(0.92); }
.yb-check.checked { border-color: var(--gold); background: rgba(239, 181, 75, 0.15); color: var(--gold); }
.yb-check.disabled { opacity: 0.35; cursor: default; }

/* grand total bar */
.grand-total {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: min(528px, calc(100% - 32px));
  background: linear-gradient(160deg, #FCF9F0, #EFE8D6);
  color: #1A2030;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  z-index: 6;
}
.grand-total .gt-label { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: #6B6350; }
.grand-total .gt-value { font-family: 'Titan One', sans-serif; font-size: 30px; }
.grand-total .gt-value.pop { animation: pop 0.3s ease; }
@keyframes pop { 50% { transform: scale(1.18); color: var(--accent-press); } }

.host-bar { position: fixed; bottom: calc(84px + env(safe-area-inset-bottom)); right: 16px; z-index: 6; }

/* ---------- modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(6, 9, 16, 0.72);
  z-index: 20;
  backdrop-filter: blur(3px);
}

.modal {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 36px));
  max-height: 82dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  z-index: 21;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal-title { margin: 0 0 16px; font-size: 22px; text-align: center; }

/* share modal: the code as dice tiles */
.share-code-dice { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
.code-die {
  width: 62px; height: 62px;
  background: linear-gradient(160deg, #FCF9F0, #E8E2D2);
  color: var(--red);
  border-radius: 14px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.12), 0 6px 16px rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Titan One', sans-serif;
  font-size: 30px;
}

.qr-box { display: flex; justify-content: center; margin: 6px 0 6px; }
.qr-box img, .qr-box canvas { border-radius: 12px; border: 8px solid #FCF9F0; }

/* leaderboard */
.leaderboard-list { display: flex; flex-direction: column; gap: 10px; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.lb-row.me { border-color: var(--gold); }
.lb-rank { font-family: 'Titan One', sans-serif; font-size: 18px; width: 30px; color: var(--text-dim); }
.lb-row:first-child .lb-rank { color: var(--gold); }
.lb-emoji { font-size: 22px; }
.lb-name { flex: 1; font-weight: 800; }
.lb-name .lb-crown { margin-left: 4px; }
.lb-score { font-family: 'Titan One', sans-serif; font-size: 22px; }
.lb-done { font-size: 11px; color: var(--green); font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }

/* winner */
.winner-box { text-align: center; }
.winner-box .win-emoji { font-size: 56px; }
.winner-box .win-name { font-family: 'Titan One', sans-serif; font-size: 28px; margin: 6px 0 2px; }
.winner-box .win-score { color: var(--gold); font-family: 'Titan One', sans-serif; font-size: 40px; }
.winner-box .win-rest { margin-top: 14px; color: var(--text-dim); font-weight: 700; font-size: 14px; line-height: 1.9; }

/* ---------- entry bottom sheet ---------- */
.entry-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  z-index: 22;
  box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.55);
  animation: sheetUp 0.22s ease;
  max-width: 560px;
  margin: 0 auto;
}
@keyframes sheetUp { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .entry-sheet { animation: none; } }

.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 14px; }
.sheet-title { margin: 0; font-size: 22px; text-align: center; }
.sheet-hint { text-align: center; color: var(--text-dim); font-weight: 600; margin: 6px 0 16px; font-size: 14px; }

.entry-options { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  min-width: 64px;
  min-height: 54px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-family: 'Titan One', sans-serif;
  font-size: 20px;
  cursor: pointer;
  padding: 0 14px;
}
.chip:active { transform: scale(0.94); border-color: var(--red); }
.chip.chip-zero { color: var(--red); }
.chip.chip-wide { flex-basis: 100%; font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 15px; min-height: 46px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #FCF9F0;
  color: #1A2030;
  font-weight: 800;
  border-radius: 999px;
  padding: 10px 20px;
  z-index: 40;
  box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

/* focus visibility */
button:focus-visible, input:focus-visible, .sc-row:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ============================================================
   Balderdash
   ============================================================ */
.bd-center { text-align: center; }
.bd-center-text { text-align: center; }
.bd-emoji-big { font-size: 52px; }
.bd-sub { color: var(--text-dim); font-weight: 600; line-height: 1.6; margin: 8px 0 0; }
.bd-round-tag {
  text-align: center;
  color: var(--text-dim);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.bd-word-card {
  background: linear-gradient(160deg, #FCF9F0, #EFE8D6);
  color: #1A2030;
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.bd-word-label { font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: #6B6350; }
.bd-word { font-family: 'Titan One', sans-serif; font-size: 36px; color: var(--accent-press); word-break: break-word; }

.bd-textarea { min-height: 100px; resize: vertical; line-height: 1.5; }

.bd-waitlist { display: flex; flex-wrap: wrap; gap: 8px; }
.bd-wait {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-dim);
}
.bd-wait.ok { color: var(--green); border-color: var(--green); }

.bd-lineup { display: flex; flex-direction: column; gap: 10px; }
.bd-def {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: left;
  color: var(--text);
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  flex-wrap: wrap;
}
.bd-def-current { border-color: var(--gold); animation: defIn 0.35s ease; }
@keyframes defIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
.bd-def-num {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Titan One', sans-serif;
  font-size: 15px;
  color: var(--gold);
}
.bd-def-text { flex: 1; min-width: 200px; }
.bd-def-btn { cursor: pointer; width: 100%; }
.bd-def-btn:active { transform: scale(0.98); border-color: var(--red); }
.bd-def-mine { opacity: 0.45; }
.bd-def-real { border-color: var(--green); background: rgba(63, 191, 127, 0.08); }
.bd-def-real .bd-def-num { color: var(--green); border-color: var(--green); }
.bd-def-ai { border-color: #B476E5; }
.bd-def-author { display: block; margin-top: 6px; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--text-dim); }
.bd-def-real .bd-def-author { color: var(--green); }
.bd-def-ai .bd-def-author { color: #B476E5; }
.bd-def-fooled { display: block; margin-top: 3px; font-size: 12.5px; font-weight: 700; color: var(--gold); }
.bd-close-tag { font-size: 12px; font-weight: 800; color: var(--green); }

.bd-settings { display: flex; gap: 10px; align-items: center; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }
.bd-target { font-family: 'Titan One', sans-serif; font-size: 20px; min-width: 130px; text-align: center; }
.bd-scoreboard { margin-top: 4px; }

/* ============================================================
   Doodlit
   ============================================================ */
.dd-head { display: flex; align-items: center; gap: 12px; }
.dd-hint { flex: 1; font-weight: 700; font-size: 16px; min-width: 0; }
.dd-hint-blanks { font-family: 'Titan One', sans-serif; font-size: 22px; letter-spacing: 3px; color: var(--gold); word-break: break-all; }
.dd-the-word { color: var(--gold); font-size: 20px; }
.dd-diff { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; padding: 3px 8px; border-radius: 999px; margin-left: 6px; }
.dd-easy { background: rgba(63,191,127,0.18); color: var(--green); }
.dd-medium { background: rgba(239,181,75,0.18); color: var(--gold); }
.dd-hard { background: rgba(229,72,77,0.18); color: var(--red); }
.dd-timer { font-family: 'Titan One', sans-serif; font-size: 26px; min-width: 48px; text-align: right; }
.dd-timerbar { height: 6px; border-radius: 3px; background: var(--surface-2); margin: 8px 0 12px; overflow: hidden; }
.dd-timerfill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--gold), var(--red)); transition: width 0.2s linear; }

.dd-canvas-wrap { position: relative; }
.dd-canvas {
  width: 100%;
  display: block;
  background: #FCF9F0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  touch-action: none;
}
.dd-countdown {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Titan One', sans-serif;
  font-size: 110px;
  color: var(--red);
  background: var(--shield);
  border-radius: var(--radius);
}

.dd-tools { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.dd-tool-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dd-color {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  color: #1A2030;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.dd-color.sel { border-color: var(--text); transform: scale(1.12); }
.dd-eraser { border: 2px dashed var(--line) !important; }
.dd-eraser.sel { border: 3px solid var(--text) !important; }
.dd-size.sel { border-color: var(--gold); color: var(--gold); }

.dd-guessrow { display: flex; gap: 10px; margin-top: 12px; }
.dd-guess-input { flex: 1; min-width: 0; }
.dd-gotit { margin-top: 12px; font-weight: 800; font-size: 17px; border-color: var(--green); }

.dd-feed {
  margin-top: 12px;
  max-height: 160px;
  overflow-y: auto;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.dd-feed-item { font-size: 14px; font-weight: 600; color: var(--text-dim); }
.dd-feed-item b { color: var(--text); }
.dd-feed-ok { color: var(--green); }
.dd-feed-ok b { color: var(--green); }
.dd-feed-close { color: var(--gold); }
.dd-feed-dim { opacity: 0.5; }

.dd-pick { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.dd-pick-btn {
  display: flex; flex-direction: column; gap: 3px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  color: var(--text);
  text-align: center;
}
.dd-pick-btn:active { transform: scale(0.97); border-color: var(--gold); }
.dd-pick-diff { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-dim); }
.dd-pick-btn.dd-easy .dd-pick-diff { color: var(--green); }
.dd-pick-btn.dd-medium .dd-pick-diff { color: var(--gold); }
.dd-pick-btn.dd-hard .dd-pick-diff { color: var(--red); }
.dd-pick-word { font-family: 'Titan One', sans-serif; font-size: 22px; }
.dd-scoreboard { margin-top: 14px; }

/* ============================================================
   PicPhrase
   ============================================================ */
.pp-pics {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.pp-pic {
  flex: 1;
  aspect-ratio: 1;
  min-width: 0;
  background: #FCF9F0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pp-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pp-emoji { font-size: clamp(64px, 22vw, 120px); line-height: 1; }
.pp-plus {
  font-family: 'Titan One', sans-serif;
  font-size: 34px;
  color: var(--gold);
  flex: 0 0 auto;
}
.pp-pics-small { margin: 4px 0 2px; }
.pp-pics-small .pp-pic { max-width: 120px; }
.pp-pics-small .pp-emoji { font-size: 56px; }
.pp-plus { text-shadow: 0 2px 8px rgba(0,0,0,0.4); }
.pp-scoreboard { margin-top: 14px; }

/* ============================================================
   Quipit
   ============================================================ */
.qp-prompt { font-weight: 800; font-size: 17px; margin: 0 0 4px; line-height: 1.45; }
.qp-prompt-big { font-family: 'Titan One', sans-serif; font-size: 22px; line-height: 1.35; color: #1A2030; }
.qp-ta { min-height: 76px; }
.qp-answer .bd-def-text { font-size: 17px; font-weight: 700; }
.qp-picked { border-color: var(--gold) !important; }
.qp-quiplash {
  text-align: center;
  font-family: 'Titan One', sans-serif;
  font-size: 34px;
  color: var(--gold);
  text-shadow: 0 3px 0 rgba(0,0,0,0.35);
  animation: pop 0.5s ease;
  margin-bottom: 6px;
}
.qp-scoreboard { margin-top: 14px; }

/* ============================================================
   Quizzit + Spellit
   ============================================================ */
.qz-wrong { border-color: var(--red); }

.sp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 380px;
  margin: 4px auto;
}
.sp-cell {
  aspect-ratio: 1;
  background: linear-gradient(160deg, #FCF9F0, #E8E2D2);
  color: #1A2030;
  border: none;
  border-radius: 14px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.12), 0 4px 10px rgba(0,0,0,0.3);
  font-family: 'Titan One', sans-serif;
  font-size: clamp(24px, 8vw, 36px);
  cursor: pointer;
  transition: transform 0.06s ease;
}
.sp-cell:active { transform: scale(0.93); }
.sp-cell.on {
  background: linear-gradient(160deg, #F6D588, var(--gold));
  color: #4A3208;
}
.sp-cell.head { outline: 3px solid var(--red); transform: scale(1.05); }
.sp-cell.readonly { cursor: default; }
.sp-grid-small { max-width: 220px; }
.sp-grid-small .sp-cell { font-size: 20px; border-radius: 10px; }

.sp-current {
  font-family: 'Titan One', sans-serif;
  font-size: 24px;
  letter-spacing: 2px;
  color: var(--gold);
  min-height: 28px;
  display: inline-block;
}
.sp-invalid { color: var(--red) !important; border-color: var(--red) !important; text-decoration: line-through; }
.sp-dup { color: var(--text-dim) !important; text-decoration: line-through; }
.sp-missed { color: var(--gold) !important; border-color: var(--gold) !important; }
.sp-scoreboard { margin-top: 14px; }

/* ============================================================
   FessUp
   ============================================================ */
.fu-mode {
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 2px solid;
}
.fu-mode-truth { background: rgba(63,191,127,0.12); border-color: var(--green); color: var(--green); }
.fu-mode-lie { background: rgba(229,72,77,0.12); border-color: var(--red); color: var(--red); }

.fu-faces { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fu-face {
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
  padding: 10px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.fu-face:active { transform: scale(0.95); }
.fu-face.sel { border-color: var(--gold); background: var(--sel-bg); }
.fu-face-emoji { font-size: 26px; }

.fu-tl { flex: 1; font-size: 17px; }
.fu-tl-sel-t { border-color: var(--green) !important; color: var(--green) !important; background: rgba(63,191,127,0.12) !important; }
.fu-tl-sel-l { border-color: var(--red) !important; color: var(--red) !important; background: rgba(229,72,77,0.12) !important; }
.fu-scoreboard { margin-top: 14px; }

/* ============================================================
   TV screen mode
   ============================================================ */
body.tv-mode .view { max-width: 1100px; padding-bottom: 150px; }
body.tv-mode .btn, body.tv-mode .btn-trophy, body.tv-mode .code-pill { display: none !important; }
body.tv-mode .btn-back { display: block !important; opacity: 0.4; }
body.tv-mode .game-name { font-size: 32px; }
body.tv-mode .bd-word-card { padding: 30px; }
body.tv-mode .bd-word { font-size: 72px; }
body.tv-mode .bd-word-label { font-size: 16px; }
body.tv-mode .qp-prompt-big { font-size: 40px; }
body.tv-mode .bd-round-tag { font-size: 18px; }
body.tv-mode .bd-def { padding: 20px; }
body.tv-mode .bd-def-text { font-size: 26px; }
body.tv-mode .bd-def-num { width: 44px; height: 44px; font-size: 20px; }
body.tv-mode .bd-def-author { font-size: 16px; }
body.tv-mode .bd-def-fooled { font-size: 17px; }
body.tv-mode .bd-sub { font-size: 22px; }
body.tv-mode .card-title { font-size: 26px; }
body.tv-mode .sc-row { min-height: 68px; }
body.tv-mode .sc-row .row-label { font-size: 22px; }
body.tv-mode .sc-row .row-value { font-size: 30px; }
body.tv-mode .sc-row .row-icon { font-size: 28px; width: 40px; }
body.tv-mode .bd-wait { font-size: 19px; padding: 10px 18px; }
body.tv-mode .dd-hint-blanks { font-size: 40px; letter-spacing: 6px; }
body.tv-mode .dd-timer { font-size: 44px; min-width: 80px; }
body.tv-mode .dd-feed { max-height: 220px; }
body.tv-mode .dd-feed-item { font-size: 20px; }
body.tv-mode .pp-emoji { font-size: 180px; }
body.tv-mode .pp-plus { font-size: 56px; }
body.tv-mode .sp-grid { max-width: 560px; }
body.tv-mode .sp-cell { font-size: 52px; }
body.tv-mode .fu-mode { font-size: 24px; padding: 18px; }
body.tv-mode .qp-quiplash { font-size: 64px; }
body.tv-mode .dd-timerbar { height: 10px; }

.tv-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg-deep) 26%);
  z-index: 30;
}
.tv-footer-code { display: flex; gap: 8px; }
.tv-die { width: 54px; height: 54px; font-size: 26px; }
.tv-footer-join { color: var(--text); font-weight: 800; font-size: 17px; line-height: 1.5; text-align: right; }
.tv-footer-join b { color: var(--gold); }
.tv-footer-qr canvas, .tv-footer-qr img { border-radius: 8px; border: 5px solid #FCF9F0; display: block; }

/* shuffle tile in the avatar picker */
.emoji-shuffle {
  border-style: dashed !important;
  border-color: var(--gold) !important;
  background: rgba(239, 181, 75, 0.08) !important;
}

/* skeleton tiles while the app module loads */
.game-tile.skeleton {
  cursor: default;
  animation: skelPulse 1.3s ease-in-out infinite;
}
@keyframes skelPulse { 50% { opacity: 0.45; } }

/* fair-start shield */
.staged-hidden { visibility: hidden !important; }

/* ============================================================
   Team play
   ============================================================ */
.team-edit-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.team-name-input { flex: 1; padding: 10px 12px; font-size: 16px; }
.team-dot { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; }
.team-del { min-width: 44px; }

.team-assign-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 800;
  font-size: 15px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
}
.team-assign-row:active { transform: scale(0.98); }
.team-pill {
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 800;
}

.lb-team-row { background: var(--bg-deep); border-width: 2px; }
.lb-team-members { display: block; font-size: 14px; margin-top: 2px; }
.lb-team-tag { display: block; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }
.lb-divider {
  text-align: center;
  color: var(--text-dim);
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 4px 0 0;
}

/* ============================================================
   Hall of Fame
   ============================================================ */
.fame-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.fame-tab {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 800;
  font-family: inherit;
  font-size: 14px;
  padding: 10px;
  cursor: pointer;
}
.fame-tab.active { color: var(--gold); border-color: var(--gold); background: rgba(239, 181, 75, 0.08); }
.fame-body { max-height: 55vh; overflow-y: auto; margin-bottom: 12px; }
.fame-row {
  display: grid;
  grid-template-columns: 36px 1fr 56px 56px;
  align-items: center;
  gap: 8px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  font-size: 15px;
}
.fame-row:last-child { border-bottom: none; }
.fame-head { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; border-bottom: 2px solid var(--line); }
.fame-rank { text-align: center; color: var(--text-dim); }
.fame-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fame-num { text-align: right; color: var(--text-dim); }
.fame-wins { color: var(--gold); }
#winner-actions .btn { margin-bottom: 10px; }
#btn-fame { margin-top: 8px; }


/* ============================================================
   Theme popover + custom theme studio
   ============================================================ */
.theme-wrap { position: relative; }
.theme-pop {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  z-index: 40;
}
.theme-pop.hidden { display: none; }
.theme-pop-row { display: flex; gap: 8px; }
.theme-mode-btn {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  padding: 12px 6px;
  cursor: pointer;
}
.theme-mode-btn.active { border-color: var(--gold); color: var(--gold); background: rgba(239, 181, 75, 0.08); }

.theme-studio { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.theme-studio.hidden { display: none; }
.theme-swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 10px; }
.theme-swatch {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  padding: 0;
}
.theme-swatch.sel { border-color: var(--text); }
.theme-swatch-any {
  position: relative;
  overflow: hidden;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
}
.theme-swatch-any input[type="color"] {
  position: absolute; inset: -8px;
  opacity: 0; cursor: pointer;
  width: 200%; height: 200%;
}
.theme-base-row { display: flex; gap: 8px; }

/* ============================================================
   Turn order + whose-turn indicators
   ============================================================ */
.order-circle {
  position: relative;
  width: min(78vw, 300px);
  aspect-ratio: 1;
  margin: 6px auto 14px;
}
.order-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 74px;
  background: var(--surface-2);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-weight: 800;
  padding: 8px 4px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.order-node.picked { border-color: var(--green); }
.order-node:active { transform: translate(-50%, -50%) scale(0.94); }
.order-emoji { font-size: 24px; }
.order-name { font-size: 11px; max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-badge {
  position: absolute;
  top: -10px; right: -10px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--green);
  color: #08130C;
  font-size: 14px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

/* obnoxiously green, as requested */
.ptab.turn {
  border-color: var(--green) !important;
  animation: turnPulse 1.3s ease-in-out infinite;
}
@keyframes turnPulse {
  50% { box-shadow: 0 0 0 5px rgba(63, 191, 127, 0.28); }
}

.turn-banner {
  background: linear-gradient(135deg, var(--green), #2E9E66);
  color: #08130C;
  font-weight: 800;
  font-size: 18px;
  text-align: center;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  animation: turnPulse 1.3s ease-in-out infinite;
}
.turn-wait {
  color: var(--text-dim);
  font-weight: 700;
  font-size: 13.5px;
  text-align: center;
  padding: 4px 0 10px;
}
.sc-row.turn-row {
  background: rgba(63, 191, 127, 0.12);
  border-left: 4px solid var(--green);
}
body.tv-mode .sc-row.turn-row .row-label { color: var(--green); }
#turn-banner.hidden { display: none; }

/* Hall of Fame: top-3 record book */
.fame-score-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 14px 8px;
  border-bottom: 1px solid var(--line);
}
.fame-score-row:first-child { background: rgba(239, 181, 75, 0.07); border-radius: var(--radius-sm); }
.fame-medal { font-size: 30px; text-align: center; }
.fame-score-name { font-weight: 800; font-size: 16px; }
.fame-score-sub { display: block; color: var(--text-dim); font-size: 12px; font-weight: 700; margin-top: 2px; }
.fame-score-val { font-family: 'Titan One', sans-serif; font-size: 26px; color: var(--gold); }
.fame-note { text-align: center; color: var(--text-dim); font-size: 11.5px; font-weight: 700; margin-top: 10px; }

/* ============================================================
   Da Flo
   ============================================================ */
.fl-board {
  display: grid;
  gap: 0;
  margin: 4px 0;
}
.fl-cell {
  position: relative;
  aspect-ratio: 1;
  background: color-mix(in srgb, var(--cellc, var(--surface-2)) 45%, var(--surface));
  border-radius: 10px;
  cursor: pointer;
  padding: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  font-family: inherit;
}
.fl-cell:active { transform: scale(0.95); }
.fl-dead { background: transparent !important; cursor: default; }
.fl-cell-emoji { font-size: clamp(16px, 5vw, 26px); line-height: 1; }
.fl-cell-cat {
  color: var(--text);
  font-weight: 800;
  font-size: clamp(7.5px, 2.3vw, 11px);
  line-height: 1.15;
  text-align: center;
  word-break: break-word;
}
.fl-eligible {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(63, 191, 127, 0.35);
  animation: turnPulse 1.3s ease-in-out infinite;
}
.fl-sel { border-width: 3px; border-color: var(--gold) !important; box-shadow: 0 0 0 3px rgba(239, 181, 75, 0.4); }
@keyframes flFlash { 0%, 100% { filter: none; } 50% { filter: brightness(1.8); } }
.fl-flash { animation: flFlash 0.5s 3; }

.fl-clocks { display: flex; gap: 10px; margin-bottom: 10px; }
.fl-clock {
  flex: 1;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  opacity: 0.65;
}
.fl-clock-active { border-color: var(--green); opacity: 1; animation: turnPulse 1.2s ease-in-out infinite; }
.fl-clock-name { display: block; font-weight: 800; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-clock-time { font-family: 'Titan One', sans-serif; font-size: 26px; }
.fl-clock-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.fl-clock-fill { height: 100%; width: 100%; transition: width 0.12s linear; }

.fl-pic {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}
.fl-pic img { width: 100%; max-height: 300px; object-fit: contain; display: block; }
.fl-pic-emoji { font-size: 120px; }
.fl-answer {
  text-align: center;
  font-weight: 800;
  color: var(--gold);
  background: rgba(239, 181, 75, 0.08);
  border: 1px dashed var(--gold);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 10px;
}

body.tv-mode .fl-cell-cat { font-size: 14px; }
body.tv-mode .fl-cell-emoji { font-size: 34px; }
body.tv-mode .fl-clock-time { font-size: 48px; }
body.tv-mode .fl-pic { min-height: 380px; }
body.tv-mode .fl-pic img { max-height: 440px; }
body.tv-mode .fl-pic-emoji { font-size: 220px; }

/* Da Flo spotlight: dim world, green picker, yellow targets */
.fl-dim { opacity: 0.28; filter: grayscale(0.6); }
.fl-picker-cell {
  border-color: var(--green) !important;
  box-shadow: 0 0 0 3px rgba(63, 191, 127, 0.45);
}
.fl-target {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 3px rgba(239, 181, 75, 0.5);
  animation: flTargetPulse 1.1s ease-in-out infinite;
}
@keyframes flTargetPulse {
  50% { box-shadow: 0 0 0 6px rgba(239, 181, 75, 0.25); }
}

/* Da Flo clue mode: riddle cards for unphotographable categories */
.fl-clue {
  padding: 22px 20px;
  font-weight: 800;
  font-size: 19px;
  line-height: 1.45;
  text-align: center;
  color: var(--text);
}
.fl-clue-emoji { display: block; font-size: 44px; margin-bottom: 10px; }
body.tv-mode .fl-clue { font-size: 34px; padding: 34px; }
body.tv-mode .fl-clue-emoji { font-size: 72px; }

/* avatar picker: taken characters + pager */
.emoji-taken {
  opacity: 0.28;
  filter: grayscale(1);
  cursor: not-allowed;
}
.emoji-pager {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
}
.emoji-pager .emoji-btn { flex: 1; aspect-ratio: auto; height: 44px; }
.emoji-page-btn { font-size: 15px; color: var(--text-dim); }
.emoji-page-num {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dim);
  margin-left: 6px;
  font-family: 'Nunito', sans-serif;
}
