/* Christmas trivia — shared styles. Mobile first; phones are the main target. */

:root {
  --pine: #0b2e1e;
  --pine-deep: #061a11;
  --pine-soft: #14432c;
  --card: rgba(255, 255, 255, 0.06);
  --card-solid: #123c28;
  --line: rgba(255, 255, 255, 0.14);
  --cream: #f6f1e7;
  --muted: #a9bfb2;
  --red: #c1272d;
  --red-bright: #e63946;
  --gold: #e9b949;
  --green: #2f9e58;
  --radius: 14px;
  --gap: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--pine-deep);
  color: var(--cream);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 50% -10%, #17503380, transparent 70%),
    linear-gradient(180deg, var(--pine) 0%, var(--pine-deep) 100%);
  background-attachment: fixed;
  padding:
    max(12px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
}

/* Stop iOS double-tap zoom on anything interactive. */
button, input, select, textarea, .tap {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.wrap { max-width: 640px; margin: 0 auto; }
.wrap-wide { max-width: 1100px; margin: 0 auto; }

h1, h2, h3 { margin: 0 0 8px; line-height: 1.15; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
p { margin: 0 0 10px; line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(6px);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.badge.gold { background: rgba(233, 185, 73, 0.18); color: var(--gold); border-color: rgba(233, 185, 73, 0.4); }
.badge.red { background: rgba(230, 57, 70, 0.2); color: #ffb3b8; border-color: rgba(230, 57, 70, 0.45); }

/* ------------------------------------------------------------------ inputs */

input[type="text"], input[type="number"], input[type="password"], textarea, select {
  width: 100%;
  /* 16px minimum or iOS Safari zooms the whole page on focus. */
  font-size: 16px;
  font-family: inherit;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--cream);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
input::placeholder { color: #7e9488; }

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 16px;
  cursor: pointer;
  min-height: 46px;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--red); border-color: var(--red-bright); }
button.go { background: var(--green); border-color: #3fbf6f; }
button.ghost { background: transparent; }
button.wide { width: 100%; }
button.tiny { min-height: 34px; padding: 6px 10px; font-size: 0.8rem; }

/* ------------------------------------------------------------- answer types */

.choices { display: grid; gap: 10px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 16px;
  font-size: 1.05rem;
  line-height: 1.3;
  background: var(--card-solid);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}
.choice .key {
  flex: 0 0 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.3);
  font-weight: 700;
}
.choice[aria-pressed="true"] { border-color: var(--gold); background: #1c5636; }
.choice[aria-pressed="true"] .key { background: var(--gold); color: #20160a; }
.choice.correct { background: #175c37; border-color: #55d98a; }
.choice.wrong { border-color: var(--red-bright); background: #4a1a1e; }

.blanks { display: grid; gap: 10px; }
.blank-line { display: flex; align-items: center; gap: 10px; }
.blank-line .n {
  flex: 0 0 28px; height: 28px; display: grid; place-items: center;
  border-radius: 8px; background: rgba(255,255,255,0.1); font-size: 0.8rem; font-weight: 700;
}

.order-list { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.order-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px; border-radius: 12px;
  background: var(--card-solid); border: 1px solid var(--line);
}
.order-item .pos {
  flex: 0 0 30px; height: 30px; display: grid; place-items: center;
  border-radius: 8px; background: var(--gold); color: #20160a; font-weight: 800;
}
.order-item .label { flex: 1 1 auto; min-width: 0; }
.order-item .moves { display: flex; gap: 6px; }
.order-item .moves button { min-height: 38px; padding: 4px 12px; font-size: 1.1rem; line-height: 1; }

/* -------------------------------------------------------------------- timer */

.timer-bar {
  height: 10px; width: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 0.25s linear;
}
.timer-fill.low { background: linear-gradient(90deg, var(--gold), var(--red-bright)); }

/* --------------------------------------------------------------- leaderboard */

.board { display: grid; gap: 8px; }
.board-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
}
.board-row .rank { font-weight: 800; color: var(--muted); }
.board-row.me { border-color: var(--gold); background: rgba(233, 185, 73, 0.14); }
.board-row.top1 .rank { color: var(--gold); }
.board-row .pts { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ------------------------------------------------------------------- misc */

.media img { width: 100%; border-radius: 12px; display: block; }
.media audio { width: 100%; margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #1d1d1d;
  border: 1px solid var(--line);
  color: var(--cream);
  padding: 11px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 50;
  max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.toast.err { background: #5c1a1e; border-color: var(--red-bright); }

.conn {
  position: fixed; top: calc(6px + env(safe-area-inset-top)); right: 10px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); z-index: 40;
}
.conn.off { background: var(--red-bright); }

.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.5; }

/* -------------------------------------------------------- big screen / TV */

.screen-mode { font-size: clamp(16px, 1.6vw, 22px); }
.screen-mode h1 { font-size: clamp(28px, 4.6vw, 64px); }
.screen-mode .prompt { font-size: clamp(24px, 3.6vw, 52px); font-weight: 700; line-height: 1.2; }
.screen-mode .choice { font-size: clamp(18px, 2vw, 30px); }
.screen-mode .board-row { font-size: clamp(18px, 2vw, 30px); padding: 14px 18px; }
.screen-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
@media (max-width: 900px) { .screen-grid { grid-template-columns: 1fr; } }
.qr-card { background: #fff; padding: 14px; border-radius: 16px; }
.qr-card svg { width: 100%; height: auto; display: block; }
.joincode {
  font-size: clamp(40px, 8vw, 110px);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--gold);
  line-height: 1;
}

/* ------------------------------------------------------------------- host */

.host-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .host-grid { grid-template-columns: 1fr; } }
.qlist { max-height: 60vh; overflow: auto; display: grid; gap: 4px; }
.qlist button {
  text-align: left; font-weight: 500; font-size: 0.85rem;
  padding: 8px 10px; min-height: 0; border-radius: 9px;
}
.qlist button.current { border-color: var(--gold); background: rgba(233, 185, 73, 0.18); }
.grade-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.grade-table th, .grade-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grade-table td.answer { font-weight: 600; }
.pill-ok { color: #7ee2a8; }
.pill-no { color: #ff9aa2; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }
.controls button { flex: 1 1 120px; }

/* ------------------------------------------------------------- shot wheel */

.wheel-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.wheel-canvas { display: block; max-width: 100%; }
.wheel-title {
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  font-size: clamp(22px, 5vw, 40px);
  color: var(--gold);
  overflow-wrap: anywhere;
}
.screen-mode .wheel-title { font-size: clamp(28px, 4.5vw, 62px); }
.wheel-title.everyone {
  color: #fff;
  text-shadow: 0 0 22px rgba(230, 57, 70, 0.85);
  animation: wheel-pop 0.6s ease-out;
}
@keyframes wheel-pop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.wheel-names {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.wheel-you {
  border: 2px solid var(--gold);
  background: rgba(233, 185, 73, 0.16);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  font-weight: 800;
  font-size: 1.15rem;
}
@media (prefers-reduced-motion: reduce) {
  .wheel-title.everyone { animation: none; }
}

/* ---------------------------------------------------------- host: guests */

.guest-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.guest-table th, .guest-table td { text-align: left; padding: 6px; border-bottom: 1px solid var(--line); }
.guest-table td.when { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wheel-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.wheel-controls input[type="number"] { width: 72px; }

/* Winner chips are names, not labels — keep their real capitalisation. */
.wheel-names .badge {
  text-transform: none;
  letter-spacing: 0;
  color: var(--gold);
}

/* Keep your own pick readable once answers are locked. */
.choice[aria-pressed="true"]:disabled { opacity: 0.85; }

/* ------------------------------------------------------------- MC panel */

.mc-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: calc(-1 * max(12px, env(safe-area-inset-top))) -14px 14px;
  padding: calc(max(12px, env(safe-area-inset-top)) + 4px) 14px 12px;
  background: rgba(6, 26, 17, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
}
.mc-where { font-weight: 800; font-size: 1.15rem; }
.mc-count { display: flex; align-items: center; gap: 10px; }
.mc-tally {
  font-weight: 900; font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1;
}
.mc-tally.all { color: #7ee2a8; }
.mc-timer { font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; }
.mc-timer.low { color: var(--red-bright); }
.mc-next {
  width: 100%;
  min-height: 64px;
  font-size: 1.25rem;
  font-weight: 800;
  border-radius: 16px;
}
.mc-row { display: flex; gap: 6px; flex-wrap: wrap; }
.mc-row button { flex: 1 1 0; min-height: 40px; }

.mc-grid { display: grid; gap: 14px; }
@media (min-width: 980px) {
  .mc-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
}

.who { display: flex; flex-wrap: wrap; gap: 6px; }
.who-chip {
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  font-size: 0.95rem;
}
.who-chip.in { background: rgba(47, 158, 88, 0.28); border-color: #3fbf6f; }
.who-chip.away { opacity: 0.45; }

.fold { padding: 0; }
.fold > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: '+'; color: var(--muted); font-weight: 700; padding-left: 4px; }
.fold[open] > summary::after { content: '−'; }
.fold > summary .badge { margin-left: auto; }
.fold-body { padding: 0 16px 16px; }

.mc-prompt { font-size: 1.3rem; font-weight: 700; line-height: 1.3; margin: 0; }
.key-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.key-row.right { color: #7ee2a8; font-weight: 800; }
.key-letter {
  flex: 0 0 28px; height: 28px; display: grid; place-items: center;
  border-radius: 8px; background: rgba(255, 255, 255, 0.1); font-weight: 700; font-size: 0.85rem;
}
.key-row.right .key-letter { background: #2f9e58; color: #fff; }
.key-answer {
  display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px;
  background: rgba(233, 185, 73, 0.12); border: 1px solid rgba(233, 185, 73, 0.35);
}
.key-answer strong { color: var(--gold); font-size: 1.15rem; }

.answers { display: grid; }
.answer-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.answer-row:last-child { border-bottom: 0; }
.answer-text { font-weight: 700; overflow-wrap: anywhere; }

.link { color: var(--gold); font-size: 0.9rem; }

/* ---------------------------------------------------------- presenter */

.present-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(6, 26, 17, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 16px;
  transition: opacity 0.3s;
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}
.present-bar.dim { opacity: 0; pointer-events: none; }
.present-bar .mc-next { width: auto; min-height: 52px; font-size: 1.1rem; padding: 0 22px; }
.present-bar .tally { font-weight: 900; font-variant-numeric: tabular-nums; padding: 0 6px; }
.present-bar .tally.all { color: #7ee2a8; }
.present-bar .keys { color: var(--muted); font-size: 0.75rem; }
.screen-mode.presenting #app { padding-bottom: 96px; }
