
:root {
  --green-950: #051c14;
  --green-900: #08291e;
  --green-800: #0d3d2d;
  --green-700: #14543e;
  --green-600: #1c6e52;
  --green-500: #298d6a;
  --gold-500: #f0b429;
  --gold-400: #ffd166;
  --gold-300: #ffe49c;
  --pumpkin: #e07a32;
  --cranberry: #c93b4b;
  --cream: #fbf6ec;
  --cream-dim: rgba(251, 246, 236, 0.72);
  --card-bg: rgba(8, 41, 30, 0.86);
  --card-border: rgba(255, 209, 102, 0.22);
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  --radius: 20px;
  --font-display: 'Fredoka', system-ui, -apple-system, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background:
    repeating-linear-gradient(
      115deg,
      rgba(255, 255, 255, 0.018) 0px,
      rgba(255, 255, 255, 0.018) 44px,
      transparent 44px,
      transparent 88px
    ),
    radial-gradient(circle at 20% 0%, #14543e 0%, #08291e 48%, #041610 100%);
  color: var(--cream);
  font-family: var(--font-body);
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  touch-action: manipulation;
  transition: transform 0.12s ease, filter 0.15s ease, background 0.15s ease;
}
button:active { transform: scale(0.96); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

input, select {
  font-family: inherit;
  font-size: 16px; /* Prevents iOS Safari auto-zoom */
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  margin: 0;
}

/* === LANDING SCREEN === */
.landing-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 18px 40px;
  gap: 24px;
}

.brand-hero {
  text-align: center;
  max-width: 680px;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(240, 180, 41, 0.16);
  border: 1px solid rgba(255, 209, 102, 0.4);
  color: var(--gold-400);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.brand-title {
  font-size: clamp(44px, 8vw, 76px);
  line-height: 1;
  background: linear-gradient(180deg, #fff6dc 0%, #ffd166 60%, #e07a32 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
}

.brand-sub {
  margin-top: 10px;
  color: var(--cream-dim);
  font-size: clamp(15px, 2.2vw, 18px);
  line-height: 1.45;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 18px;
  width: 100%;
  max-width: 820px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.role-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.role-icon {
  font-size: 42px;
  line-height: 1;
}

.role-card h2 {
  font-size: 26px;
  color: var(--gold-400);
}

.role-card p {
  margin: 0;
  color: var(--cream-dim);
  font-size: 14px;
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold-300);
}

.input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1.5px solid rgba(255, 209, 102, 0.25);
  background: rgba(4, 22, 16, 0.8);
  color: var(--cream);
  outline: none;
}
.input:focus {
  border-color: var(--gold-400);
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.18);
}

.input-code {
  text-transform: uppercase;
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.14em;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 16px;
  color: #051c14;
  background: linear-gradient(180deg, #ffd166 0%, #e5a31d 100%);
  box-shadow: 0 5px 0 #9c6a08, 0 10px 24px rgba(0, 0, 0, 0.35);
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #9c6a08; }

.btn-secondary {
  color: var(--cream);
  background: linear-gradient(180deg, #1b694e 0%, #124b37 100%);
  box-shadow: 0 4px 0 #07261c;
  border: 1px solid rgba(255, 209, 102, 0.22);
}

.btn-cranberry {
  color: var(--cream);
  background: linear-gradient(180deg, #dc4a5b 0%, #a82838 100%);
  box-shadow: 0 4px 0 #69141f;
}

.btn-ghost {
  color: var(--cream);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.btn-sm {
  padding: 8px 13px;
  font-size: 13px;
  border-radius: 10px;
}

.btn-xl {
  padding: 18px 26px;
  font-size: 22px;
  font-family: var(--font-display);
  border-radius: 18px;
}

/* === HOST TV LAYOUT === */
.tv-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  gap: 12px;
}

.tv-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 18px;
  border-radius: 18px;
  background: rgba(5, 28, 20, 0.9);
  border: 1px solid var(--card-border);
  flex-wrap: wrap;
}

.tv-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tv-brand h1 {
  font-size: 26px;
  color: var(--gold-400);
}

.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 14px;
  background: rgba(255, 209, 102, 0.14);
  border: 1.5px solid var(--gold-400);
}
.room-badge .code {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.12em;
  color: var(--gold-400);
}

.tv-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 14px;
  min-height: 0;
}
@media (max-width: 1060px) {
  .tv-main { grid-template-columns: 1fr; }
}

.board-stage {
  position: relative;
  background: radial-gradient(circle at 50% 45%, #165e45 0%, #0a3627 65%, #062118 100%);
  border: 2px solid rgba(255, 209, 102, 0.28);
  border-radius: 24px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.35), var(--shadow);
}

.board-svg {
  width: 100%;
  height: auto;
  max-height: 68dvh;
  display: block;
}

.event-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: linear-gradient(135deg, rgba(7, 38, 28, 0.96), rgba(19, 78, 58, 0.96));
  border: 2px solid var(--gold-400);
  border-radius: 18px;
  padding: 10px 22px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  max-width: 90%;
  animation: popIn 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
}
.event-banner .ev-title {
  font-family: var(--font-display);
  font-size: clamp(18px, 2.4vw, 26px);
  color: var(--gold-400);
}
.event-banner .ev-sub {
  font-size: 13px;
  color: var(--cream);
  margin-top: 2px;
}

.dice-popup {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}
.dice-cube {
  width: 112px;
  height: 112px;
  border-radius: 24px;
  background: linear-gradient(145deg, #fff9ea, #ffd166);
  color: #062118;
  font-family: var(--font-display);
  font-size: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.55), inset 0 -6px 0 rgba(0,0,0,0.16);
  border: 4px solid #fff;
  animation: diceSpin 0.8s cubic-bezier(0.2, 1.4, 0.4, 1);
}

@keyframes diceSpin {
  0% { transform: scale(0.3) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.18) rotate(12deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes popIn {
  0% { transform: translateX(-50%) scale(0.8); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes floatUp {
  0% { transform: translateY(0) scale(0.7); opacity: 0; }
  15% { opacity: 1; transform: translateY(-25px) scale(1.15); }
  100% { transform: translateY(-280px) scale(0.95); opacity: 0; }
}

@keyframes pulseGlow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 209, 102, 0.65)); }
  50% { filter: drop-shadow(0 0 18px rgba(255, 209, 102, 1)); }
}

.wishbone-pulse {
  animation: pulseGlow 1.5s infinite ease-in-out;
}

.tv-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 44dvh;
  overflow-y: auto;
  padding-right: 4px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 13px;
  background: rgba(4, 22, 16, 0.65);
  border: 1.5px solid transparent;
}
.lb-row.is-turn {
  border-color: var(--gold-400);
  background: rgba(240, 180, 41, 0.16);
}

.avatar-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.75);
  position: relative;
}
.online-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #38e58c;
  border: 2px solid #051c14;
  position: absolute;
  bottom: -2px;
  right: -2px;
}

.lb-name {
  flex: 1;
  min-width: 0;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 13px;
}

/* === TV LOBBY === */
.lobby-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  flex: 1;
}
@media (max-width: 960px) {
  .lobby-grid { grid-template-columns: 1fr; }
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.roster-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 15px;
  background: rgba(4, 22, 16, 0.72);
  border: 1.5px solid rgba(255, 209, 102, 0.22);
  color: var(--cream);
  text-align: left;
}
.roster-chip.inactive {
  opacity: 0.42;
  filter: grayscale(0.6);
}
.roster-chip.online {
  border-color: #38e58c;
  background: rgba(56, 229, 140, 0.12);
}

.qr-box {
  background: #fff;
  padding: 12px;
  border-radius: 18px;
  display: inline-block;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

/* === SIDEPOT TICKER (TV BOTTOM) === */
.sidepot-ticker {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 16px;
  background: rgba(5, 28, 20, 0.9);
  border: 1px solid var(--card-border);
  overflow-x: auto;
}
.ticker-pill {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-radius: 12px;
  background: rgba(255, 209, 102, 0.1);
  border: 1px solid rgba(255, 209, 102, 0.26);
  font-size: 13px;
}

/* === PHONE / IOS CONTROLLER === */
.phone-shell {
  min-height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(74px + env(safe-area-inset-bottom));
}

.phone-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(5, 28, 20, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
}

.phone-content {
  flex: 1;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.phone-tabs {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 540px;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(5, 24, 18, 0.97);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--card-border);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  gap: 6px;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 4px;
  border-radius: 12px;
  background: transparent;
  color: var(--cream-dim);
  font-size: 12px;
  font-weight: 700;
}
.tab-btn.active {
  background: rgba(240, 180, 41, 0.18);
  color: var(--gold-400);
}
.tab-btn .t-ico { font-size: 20px; }

.reaction-bar {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 16px;
  background: rgba(4, 22, 16, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.reaction-btn {
  flex: 1;
  font-size: 22px;
  padding: 6px 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

/* === MINI-GAMES === */
.minigame-overlay {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #fffdf7;
  border-radius: 18px;
  border: 3px solid var(--gold-400);
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.draw-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.4);
}
.swatch.selected {
  border-color: var(--gold-400);
  transform: scale(1.16);
}

.dash-button {
  width: 100%;
  min-height: 210px;
  border-radius: 28px;
  background: radial-gradient(circle at 30% 25%, #ffd166, #e07a32 70%, #b5451b 100%);
  color: #062118;
  font-family: var(--font-display);
  font-size: 36px;
  box-shadow: 0 10px 0 #78270a, 0 18px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.dash-button:active {
  transform: translateY(5px) scale(0.97);
  box-shadow: 0 4px 0 #78270a;
}

.race-lane {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(4, 22, 16, 0.7);
}
.race-track {
  flex: 1;
  height: 26px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}
.race-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.12s linear;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-size: 18px;
}

.trivia-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 460px) {
  .trivia-grid { grid-template-columns: 1fr; }
}
.trivia-opt {
  padding: 16px 14px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}
.trivia-opt.opt-0 { background: #c93b4b; }
.trivia-opt.opt-1 { background: #1e6f9f; }
.trivia-opt.opt-2 { background: #d4821c; }
.trivia-opt.opt-3 { background: #26825d; }
.trivia-opt.selected { outline: 4px solid #fff; }
.trivia-opt.correct { outline: 4px solid #38e58c; filter: brightness(1.15); }
.trivia-opt.wrong { opacity: 0.45; }

/* === SIDEPOT BET CARDS === */
.bet-card {
  background: rgba(4, 22, 16, 0.78);
  border: 1.5px solid rgba(255, 209, 102, 0.24);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.odds-bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(201, 59, 75, 0.85);
  overflow: hidden;
  display: flex;
}
.odds-yes {
  height: 100%;
  background: linear-gradient(90deg, #2ec486, #38e58c);
  transition: width 0.25s ease;
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.09);
  color: var(--cream);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.chip.active {
  background: var(--gold-400);
  color: #051c14;
  border-color: var(--gold-400);
}

/* === FLOATING REACTIONS & TOASTS === */
#reactions-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}
.floating-reaction {
  position: absolute;
  bottom: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: floatUp 2.6s ease-out forwards;
}
.floating-reaction .fr-emoji { font-size: 42px; }
.floating-reaction .fr-name {
  font-size: 11px;
  font-weight: 800;
  background: rgba(5, 28, 20, 0.85);
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--gold-400);
}

#toast-layer {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(5, 28, 20, 0.96);
  border: 1.5px solid var(--gold-400);
  color: var(--cream);
  padding: 10px 16px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

.family-pick-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.family-pick-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(4, 22, 16, 0.78);
  border: 1.5px solid rgba(255, 209, 102, 0.25);
  color: var(--cream);
  text-align: left;
  font-weight: 700;
}
.family-pick-btn:hover {
  border-color: var(--gold-400);
  background: rgba(240, 180, 41, 0.14);
}
