/* Family Game Hub — big, high-contrast, festive. Sized for grandparents and 6-year-olds. */

/* Christmas colours until the room's theme arrives. Each holiday's colours live in
   server/themes/<holiday>.js and are applied by applyTheme() in common.js. Use these
   variables instead of fixed colours so every holiday looks right. */
:root {
  --bg1: #0d3b2e;
  --bg2: #071f19;
  --card: #fffaf0;
  --ink: #1f2a24;
  --muted: #5d6b63;
  --line: #e6dcc8;
  --chip: #f3ecdd;
  --chip-2: #efe6d4;
  --red: #c8102e;
  --red-dark: #9b0c23;
  --green: #1f7a4d;
  --green-dark: #145236;
  --green-soft: #e3f1e8;
  --gold: #f4c542;
  --gold-dark: #b38b1d;
  --gold-ink: #3b2a00;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-size: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Nunito", "Segoe UI Rounded", "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--card);
  background: radial-gradient(ellipse at top, var(--bg1), var(--bg2) 70%) fixed;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0 0 0.4em; line-height: 1.15; }
p { line-height: 1.45; }

.card {
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.muted { color: var(--muted); }
.center { text-align: center; }
.stack > * + * { margin-top: 0.85rem; }

/* ---------- Buttons ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  width: 100%;
  min-height: 60px;
  padding: 0.8rem 1.1rem;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
  background: var(--red);
  color: #fff;
  box-shadow: 0 4px 0 var(--red-dark);
  transition: transform 0.06s, filter 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-dark); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.green { background: var(--green); box-shadow: 0 4px 0 var(--green-dark); }
.btn.gold { background: var(--gold); color: var(--gold-ink); box-shadow: 0 4px 0 var(--gold-dark); }
.btn.ghost { background: transparent; color: inherit; box-shadow: none; border: 2px solid currentColor; opacity: 0.85; }
.btn.small { min-height: 44px; font-size: 1rem; width: auto; }
.btn.armed { background: #ff8c1a; box-shadow: 0 4px 0 #b35f0a; color: #fff; animation: pulse 0.6s infinite alternate; }
.btn .wait { font-weight: 600; font-size: 0.9rem; opacity: 0.9; }
@keyframes pulse { to { filter: brightness(1.15); } }

input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 1.4rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 3px solid var(--line);
  color: var(--ink);
  background: #fff;
}
input[type="text"]:focus { outline: none; border-color: var(--green); }
input.code { text-transform: uppercase; letter-spacing: 0.4em; text-align: center; font-weight: 900; }

/* ---------- Toasts ---------- */
#toasts {
  position: fixed;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  width: min(94vw, 520px);
  z-index: 50;
  display: grid;
  gap: 8px;
}
.toast {
  padding: 0.9rem 1.1rem;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1.1rem;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow);
  border-left: 8px solid var(--gold);
  animation: drop 0.25s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast.good { border-left-color: var(--green); }
.toast.bad { border-left-color: var(--red); }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } }

/* ---------- Ambient background (snow, leaves, bats…) ---------- */
/* The theme picks the glyphs and the motion; see setAmbient() in common.js. */
.ambient { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.ambient span { position: absolute; color: #fff; animation-iteration-count: infinite; animation-timing-function: linear; }
.ambient.fall span { top: -5vh; animation-name: fall; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); } }
.ambient.sway span { top: -5vh; animation-name: sway; }
@keyframes sway {
  25% { transform: translate(5vw, 27vh) rotate(80deg); }
  50% { transform: translate(-3vw, 55vh) rotate(160deg); }
  75% { transform: translate(4vw, 82vh) rotate(250deg); }
  100% { transform: translate(0, 110vh) rotate(340deg); }
}
.ambient.flutter span { left: -8vw; animation-name: flutter; }
.ambient.flutter span.rev { left: auto; right: -8vw; animation-name: flutter-rev; }
@keyframes flutter {
  20% { transform: translate(24vw, -5vh); } 40% { transform: translate(48vw, 3vh); }
  60% { transform: translate(72vw, -4vh); } 80% { transform: translate(96vw, 2vh); }
  100% { transform: translate(120vw, 0); }
}
@keyframes flutter-rev {
  20% { transform: translate(-24vw, 4vh); } 40% { transform: translate(-48vw, -3vh); }
  60% { transform: translate(-72vw, 5vh); } 80% { transform: translate(-96vw, -2vh); }
  100% { transform: translate(-120vw, 0); }
}

/* =========================================================
   TV / HOST
   ========================================================= */
body.host { font-size: clamp(16px, 1.35vw, 26px); }
body.host #app { position: relative; z-index: 1; padding: 2.2vw 3vw; min-height: 100vh; }

.hub-title { font-size: 1.8em; font-weight: 900; text-align: center; margin-bottom: 0.5em; text-shadow: 0 4px 0 rgba(0,0,0,0.3); }
.hub-title small { display: block; font-size: 0.35em; font-weight: 700; opacity: 0.8; letter-spacing: 0.05em; }

.lobby { font-size: 0.94em; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 2vw; align-items: start; }
.join-panel { text-align: center; }
.join-panel .qr { width: min(100%, 13em); aspect-ratio: 1; background: #fff; border-radius: 12px; padding: 0.5em; }
.join-panel .url { font-size: 1.15em; font-weight: 800; word-break: break-all; }
.phones-blocked { background: #fde2e4; color: var(--red-dark); border-radius: 12px; padding: 0.6em 0.8em; font-weight: 700; font-size: 0.85em; margin: 0 0 0.6em; }
.locked-note { background: #fde2e4; color: var(--red-dark); border-radius: 10px; padding: 0.45em 0.7em; font-weight: 800; font-size: 0.85em; margin: 0.5em 0 0; }
.room-code { font-size: 4em; font-weight: 900; letter-spacing: 0.15em; color: var(--red); line-height: 1; margin: 0.15em 0; }

.player-grid { display: flex; flex-wrap: wrap; gap: 0.5em; }
.player-chip {
  position: relative;
  text-align: center;
  background: var(--chip);
  border-radius: 14px;
  padding: 0.6em 0.4em;
}
.player-chip { display: flex; align-items: center; gap: 0.35em; padding: 0.15em 1.6em 0.15em 0.5em !important; border-radius: 99px !important; }
.player-chip .av { font-size: 1.3em; line-height: 1.1; }
.player-chip .nm { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-chip.away { opacity: 0.45; }
.player-chip .kick {
  position: absolute; top: 4px; right: 4px; border: 0; background: transparent; color: var(--muted);
  font-size: 0.85em; cursor: pointer; padding: 4px 6px; border-radius: 8px; opacity: 0; transition: opacity 0.2s;
}
.player-chip:hover .kick, .player-chip .kick.armed { opacity: 1; }
.player-chip .kick.armed { background: var(--red); color: #fff; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.empty-players { padding: 1.5em; text-align: center; color: var(--muted); font-size: 1.1em; }

.pick-title { margin: 0.6em 0 0; }
.games { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7em; }
.game-card {
  font: inherit;
  text-align: left;
  border: 0;
  cursor: pointer;
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 0.6em 0.9em;
  box-shadow: var(--shadow);
  transition: transform 0.15s;
  outline: 4px solid transparent;
}
.game-card:hover:not(:disabled), .game-card:focus-visible { transform: translateY(-4px); outline-color: var(--gold); }
.game-card .emoji { font-size: 1.5em; vertical-align: -0.15em; }
.game-card h3 { font-size: 1.1em; margin: 0 0 0.1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-card p { margin: 0.15em 0 0; font-size: 0.85em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lobby-side-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6em; }
.lobby-side-btns .btn { width: auto; }
.game-card .tag { display: inline-block; margin-right: 0.3em; font-size: 0.85em; font-weight: 800; padding: 0.2em 0.7em; border-radius: 99px; background: var(--green-soft); color: var(--green); }
.game-card .tag.pro { background: #fef3c7; color: var(--gold-ink); }
.game-card.locked { opacity: 0.82; }
.game-card:disabled { cursor: default; opacity: 0.6; }
.game-card.elsewhere { opacity: 0.4; }

/* Holiday picker in the TV lobby */
.theme-picker { text-align: center; }
.theme-picker h3 { margin: 0 0 0.4em; font-size: 1em; }
.theme-picker .option-row .btn { min-height: 44px; font-size: 0.9em; padding: 0.3em 0.6em; }
.theme-picker .option-row .btn.theme-locked { opacity: 0.65; }
.game-card:disabled .tag { background: #eee; color: var(--muted); }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: grid; place-items: center; z-index: 20; padding: 2vw; }
.overlay .card { width: min(58em, 100%); max-height: 92vh; overflow: auto; }
.howto { padding-left: 1.2em; }
.howto li { margin: 0.35em 0; }
.overlay .howto li { margin: 0.2em 0; }
.overlay .stack > * + * { margin-top: 0.65rem; }
.option-row { display: flex; flex-wrap: wrap; gap: 0.5em; }
.option-row .btn { width: auto; flex: 1 1 auto; min-height: 50px; font-size: 1em; background: var(--chip-2); color: var(--ink); box-shadow: none; }
.option-row .btn.selected { background: var(--green); color: #fff; }
.option-row.many { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4em; }
.option-row.many .btn { min-height: 40px; font-size: 0.85em; padding: 0.4em 0.6em; line-height: 1.15; }
.row { display: flex; gap: 0.8em; }
.row > * { flex: 1; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1em; margin-bottom: 1.2em; }
.topbar .room { font-weight: 800; opacity: 0.85; }
.topbar .btn { width: auto; }

/* =========================================================
   PHONE / PLAYER
   ========================================================= */
body.player #app { max-width: 540px; margin: 0 auto; padding: 16px 16px 40px; }
.me-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; font-weight: 800; }
.me-bar .who { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; }
.me-bar .who .av { font-size: 1.8rem; }
.me-bar .code { opacity: 0.7; font-size: 0.9rem; }
/* The room code is also the room switcher (see play.js). */
.me-bar .room-btn {
  font: inherit; font-size: 0.9rem; font-weight: 800; color: inherit; cursor: pointer; opacity: 0.85;
  background: rgba(255,255,255,0.12); border: 0; border-radius: 99px; padding: 6px 12px; text-align: right;
}
.me-bar .room-count { font-size: 0.8rem; opacity: 0.8; margin-left: 2px; white-space: nowrap; }

.room-row {
  font: inherit; width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  text-align: left; border: 0; border-radius: 12px; padding: 10px 12px; background: var(--chip); color: var(--ink); cursor: pointer;
}
.room-row .rc { font-weight: 900; letter-spacing: 0.12em; font-size: 1.1rem; color: var(--red); }
.room-row .rw b { display: block; line-height: 1.2; }
.room-row .rw small { display: block; color: var(--muted); font-weight: 700; line-height: 1.25; }
.room-row .go { font-weight: 900; color: var(--green); }
.room-row.here { background: var(--green-soft); cursor: default; }
.rooms-sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.6); display: flex; align-items: flex-end; padding: 12px; }
.rooms-sheet .card { width: 100%; max-width: 520px; margin: 0 auto; max-height: 90vh; overflow: auto; }
.join-rooms { margin-top: 16px; }
.join-rooms:empty { display: none; }

/* The TV's rooms (host.js): rooms this screen has opened. */
.tv-rooms { display: grid; gap: 0.5em; }
.tv-rooms .room-row { font-size: 0.95em; }
.tv-rooms .room-row .rc { font-size: 1.2em; }

.join-title { text-align: center; font-size: 2.1rem; font-weight: 900; margin: 10px 0 18px; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.avatar-grid button {
  font-size: 1.9rem; aspect-ratio: 1; border-radius: 12px; border: 3px solid transparent; background: var(--chip); cursor: pointer; padding: 0;
}
.avatar-grid button.selected { border-color: var(--green); background: var(--green-soft); transform: scale(1.06); }
label.lbl { display: block; font-weight: 800; margin-bottom: 6px; }
.error { color: var(--red); font-weight: 800; min-height: 1.4em; }

.waiting { text-align: center; padding: 30px 10px; }
.waiting .big { font-size: 4rem; }
.tiny-players { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.tiny-players span { background: rgba(255,255,255,0.12); padding: 4px 10px; border-radius: 99px; font-weight: 700; }

/* ---------- Four answer choices (Emoji Puzzles, Trivia) ----------
   The same colour and letter on the TV and every phone: A red, B blue, C yellow, D green.
   .ch-tiles/.ch-tile on the TV, .ch-btns/.ch-btn on phones, plus .ch-c0 … .ch-c3. */
.ch-c0 { --ch: #d93b3b; --ch-dark: #9e2424; --ch-ink: #fff; }
.ch-c1 { --ch: #2f74d9; --ch-dark: #1f4f99; --ch-ink: #fff; }
.ch-c2 { --ch: #f2b705; --ch-dark: #b38800; --ch-ink: #2e2300; }
.ch-c3 { --ch: #24a157; --ch-dark: #17703b; --ch-ink: #fff; }

.ch-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6em; }
.ch-tile {
  position: relative; display: flex; align-items: center; gap: 0.6em; min-height: 3.2em; padding: 0.5em 0.9em;
  background: var(--ch); color: var(--ch-ink); border-radius: 14px; box-shadow: 0 5px 0 var(--ch-dark);
  font-size: 1.45em; font-weight: 900; transition: opacity 0.4s, transform 0.4s;
}
.ch-tile .ltr, .ch-btn .ltr {
  flex: none; display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%;
  background: rgba(255,255,255,0.28); font-weight: 900;
}
.ch-tile .txt { flex: 1; line-height: 1.15; }
.ch-tile .votes { font-size: 0.85em; letter-spacing: 0.05em; }
.ch-tile .tick { position: absolute; right: -0.4em; top: -0.6em; font-size: 1.4em; }
.ch-tile.struck { opacity: 0.25; }
.ch-tile.struck .txt { text-decoration: line-through; }
.ch-tile.wrong { opacity: 0.4; transform: scale(0.97); }
.ch-tile.right { outline: 6px solid var(--gold); transform: scale(1.03); animation: ch-pop 0.5s ease-out; }
.ch-btns { display: grid; gap: 10px; }
.ch-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 14px; border: 0; border-radius: 14px;
  background: var(--ch); color: var(--ch-ink); box-shadow: 0 5px 0 var(--ch-dark);
  font: inherit; font-size: 1.2rem; font-weight: 900; text-align: left; cursor: pointer; line-height: 1.15;
}
.ch-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--ch-dark); }
.ch-btn.struck { opacity: 0.25; text-decoration: line-through; }
.ch-btn.picked { cursor: default; justify-content: flex-start; }
@keyframes ch-pop { from { transform: scale(0.8); opacity: 0; } }

/* ---------- Story Book (lobby) ---------- */
.book-btn { margin: 0.8em auto 0; }
.book-list { display: grid; gap: 0.5em; max-height: 60vh; overflow: auto; }
.book-row { font: inherit; display: flex; justify-content: space-between; gap: 1em; align-items: center; text-align: left; padding: 0.7em 1em; border: 0; border-radius: 12px; background: var(--chip); color: var(--ink); cursor: pointer; }
.book-row b { font-size: 1.1em; }
.book-story { font-size: 1.15em; line-height: 1.55; max-height: 60vh; overflow: auto; }
.book-story p { margin: 0 0 0.5em; }
.book-word { background: #ffe48a; color: var(--ink); padding: 0 0.2em; border-radius: 0.25em; font-weight: 800; }
.book-cast { color: var(--muted); font-weight: 700; }

/* Printing a story from the Story Book: just the story, black on white. */
@media print {
  body { background: #fff !important; }
  body * { visibility: hidden; }
  .printable, .printable * { visibility: visible; }
  .printable { position: absolute; left: 0; top: 0; width: 100%; max-height: none !important; box-shadow: none; background: #fff; color: #000; }
  .printable .book-story { max-height: none; overflow: visible; }
  .printable .book-word { background: none; padding: 0; text-decoration: underline; }
  .no-print, .ambient { display: none !important; }
}
