/* app.css — the Family Game Show look. Colors come from the skin via CSS
 * variables (--bg, --panel, --primary, …) applied by app.js applySkin().
 * Warm, sitcom-y, kind-funny: soft plums, gold light, big rounded buttons.
 */

:root {
  --bg: #1b1035;
  --panel: #2a1a4e;
  --panel2: #35205f;
  --ink: #f7f0ff;
  --muted: #cbb8ec;
  --primary: #f5b83d;
  --primaryInk: #3a2400;
  --accent: #5ee6c8;
  --good: #7ee787;
  --bad: #ff7b72;
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(94, 230, 200, 0.14), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(245, 184, 61, 0.12), transparent 55%),
    var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

h1, h2, h3 { margin: 0 0 0.4em; font-weight: 800; letter-spacing: 0.2px; }
button { font-family: inherit; }

.hidden { display: none !important; }

/* ---------- shared bits ---------- */

.brand {
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 0.3px;
}
.brand .tag { color: var(--accent); font-weight: 600; font-size: 0.8rem; display: block; }

.dot {
  display: inline-block;
  width: 0.8em; height: 0.8em;
  border-radius: 50%;
  vertical-align: -0.05em;
  margin-right: 0.35em;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  padding: 0.7em 1.2em;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--panel2);
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.12s ease, box-shadow 0.12s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }

.btn-primary { background: var(--primary); color: var(--primaryInk); box-shadow: 0 6px 18px rgba(245, 184, 61, 0.35); }
.btn-good { background: var(--good); color: #0c2a10; }
.btn-bad { background: var(--bad); color: #3a0a08; }
.btn-ghost { background: transparent; border: 2px solid var(--panel2); }
.btn-big { font-size: 1.15rem; padding: 0.9em 1.8em; border-radius: 18px; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.narration {
  margin-top: 1rem;
  padding: 0.8rem 1.1rem;
  border-radius: 14px;
  background: rgba(94, 230, 200, 0.12);
  border: 1px solid rgba(94, 230, 200, 0.35);
  font-weight: 600;
  animation: pop 0.35s ease;
}
.narration.wrong { background: rgba(255, 123, 114, 0.12); border-color: rgba(255, 123, 114, 0.4); }

@keyframes pop {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.6rem;
  background: rgba(20, 10, 45, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(6px);
}
.topbar .showmeta { color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.topbar .top-actions { display: flex; gap: 0.6rem; }

main { max-width: 1200px; margin: 0 auto; padding: 1.6rem; }

/* lobby */
.lobby-card { text-align: center; max-width: 720px; margin: 4vh auto 0; }
.lobby-card h1 { font-size: 2.2rem; }
.lobby-card .sub { color: var(--muted); font-size: 1.05rem; max-width: 34em; margin: 0 auto 1.6rem; }

.pin-big {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  color: var(--primary);
  text-shadow: 0 0 30px rgba(245, 184, 61, 0.45);
  background: rgba(245, 184, 61, 0.08);
  border: 2px dashed rgba(245, 184, 61, 0.5);
  border-radius: 24px;
  padding: 0.3em 0;
  margin: 0.6rem auto 0.4rem;
  max-width: 16em;
}
.join-hint { color: var(--muted); margin-bottom: 1.6rem; }

.player-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
  margin: 1.4rem 0 2rem;
  min-height: 3.4rem;
}
.tile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--panel2);
  border-radius: 999px;
  padding: 0.35rem 0.9rem 0.35rem 0.4rem;
  font-weight: 700;
  animation: pop 0.3s ease;
}
.tile .avatar, .avatar {
  width: 2.1em; height: 2.1em;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  font-size: 0.95rem;
}
.tile.offline { opacity: 0.55; }
.tile.offline::after { content: "· away"; color: var(--muted); font-weight: 600; font-size: 0.8rem; }

.waiting { color: var(--muted); font-weight: 600; }

/* stage */
.stage-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.4rem; align-items: start; }

.round-banner {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.round-banner .kind {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primaryInk);
  background: var(--primary);
  border-radius: 999px;
  padding: 0.2em 0.8em;
}
.round-banner h2 { font-size: 1.7rem; }
.round-banner .sub { color: var(--muted); font-weight: 600; }
.round-banner .pts { margin-left: auto; color: var(--accent); font-weight: 800; }

.question-card .prompt {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.3;
  min-height: 2.6em;
  display: flex;
  align-items: center;
}
.question-card .clue { color: var(--muted); font-size: 1.05rem; font-weight: 600; }

.audio-row { margin-top: 1rem; }

.answer-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin-top: 1.2rem; }
.answer-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--panel2);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 0.8rem 1rem;
  font-weight: 700;
  font-size: 1.05rem;
}
.answer-item .key {
  flex: 0 0 auto;
  width: 1.7em; height: 1.7em;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}
.answer-item.picked { border-color: var(--accent); background: rgba(94, 230, 200, 0.14); }
.answer-item.correct { border-color: var(--good); background: rgba(126, 231, 135, 0.16); }
.answer-item.wrongpick { border-color: var(--bad); background: rgba(255, 123, 114, 0.12); }

.buzz-feed {
  margin-top: 1.2rem;
  min-height: 3rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.feed-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--panel2);
  border-radius: 999px;
  padding: 0.3rem 0.8rem 0.3rem 0.35rem;
  font-weight: 700;
  animation: pop 0.3s ease;
}
.feed-item.winner { background: var(--primary); color: var(--primaryInk); }
.feed-item .pos { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.feed-item.winner .pos { color: rgba(58, 36, 0, 0.6); }

.controls {
  margin-top: 1.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.controls .spacer { flex: 1 1 100%; height: 0; }
.controls .label { color: var(--muted); font-weight: 700; }

/* scoreboard rail */
.rail .card h3 { font-size: 1.05rem; color: var(--primary); text-transform: uppercase; letter-spacing: 0.08em; }
.score-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.score-row:last-child { border-bottom: none; }
.score-row .rank { width: 1.6em; font-weight: 900; color: var(--muted); }
.score-row .name { font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row .pts { font-weight: 900; color: var(--accent); }
.score-row.top1 { background: rgba(245, 184, 61, 0.12); border-radius: 10px; }
.score-row .buzz-count { color: var(--muted); font-size: 0.8rem; }

.rail .flags-note { margin-top: 1rem; color: var(--muted); font-size: 0.9rem; }

/* finale */
.finale h1 { text-align: center; font-size: 2.4rem; margin-bottom: 1.8rem; }
.board-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
.board-card h2 { color: var(--primary); }

.podium-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-weight: 700;
}
.podium-row.top1 { background: rgba(245, 184, 61, 0.16); border-radius: 12px; font-size: 1.2rem; }
.podium-row .rank { font-size: 1.1rem; font-weight: 900; color: var(--muted); width: 1.8em; }
.podium-row.top1 .rank { color: var(--primary); }
.podium-row .pts { margin-left: auto; font-weight: 900; color: var(--accent); }

.record-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.record-table th {
  text-align: left;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.record-table td { padding: 0.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.06); font-weight: 600; }
.record-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.record-table tr.top1 td { background: rgba(245, 184, 61, 0.1); }

.finale-close { text-align: center; color: var(--muted); font-size: 1.1rem; margin-top: 2rem; font-style: italic; }
.finale-actions { text-align: center; margin-top: 1.4rem; }

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 5, 25, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal { width: min(720px, 100%); max-height: 86vh; overflow: auto; }
.modal h3 { font-size: 1.4rem; }
.modal .row-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.modal .btn { font-size: 0.85rem; padding: 0.4em 0.8em; border-radius: 10px; }
.rename-input { width: 8.5em; background: var(--bg); color: var(--ink); border: 1px solid var(--panel2); border-radius: 10px; padding: 0.4em 0.6em; font-size: 0.9rem; }

/* ---------- phone ---------- */

body.phone main { max-width: 480px; padding: 1rem; }
.phone .topbar { padding: 0.8rem 1rem; position: static; }
.phone .topbar .you-chip { font-weight: 800; color: var(--accent); }

.screen { animation: pop 0.3s ease; }
.screen h1 { font-size: 1.6rem; }
.screen .sub { color: var(--muted); margin-bottom: 1.2rem; }

.pin-input {
  font-size: 2.6rem;
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  text-align: center;
  width: 100%;
  padding: 0.5em 0;
  border-radius: 18px;
  border: 2px solid var(--panel2);
  background: var(--panel);
  color: var(--ink);
  font-weight: 900;
  outline: none;
}
.pin-input:focus { border-color: var(--primary); }

.field-label { font-weight: 700; color: var(--muted); font-size: 0.9rem; margin: 1rem 0 0.4rem; }
.name-input {
  width: 100%;
  font-size: 1.3rem;
  font-weight: 800;
  padding: 0.5em 0.8em;
  border-radius: 14px;
  border: 2px solid var(--panel2);
  background: var(--panel);
  color: var(--ink);
  outline: none;
}
.name-input:focus { border-color: var(--primary); }

.color-picker { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.color-swatch {
  width: 2.2em; height: 2.2em;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease;
}
.color-swatch.sel { border-color: #fff; transform: scale(1.12); }

.family-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
.family-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  background: var(--panel2);
  border: none;
  border-radius: 999px;
  padding: 0.35em 0.9em 0.35em 0.4em;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
}
.family-chip:hover { filter: brightness(1.15); }

.error-line { color: var(--bad); font-weight: 700; margin-top: 0.8rem; min-height: 1.4em; }

.welcome-card { text-align: center; padding: 1.6rem; }
.welcome-card .avatar { width: 4.2em; height: 4.2em; font-size: 1.6rem; }
.welcome-card h2 { margin-top: 0.8rem; }

.buzz-wrap { text-align: center; padding: 2.5rem 0 1rem; }
.buzz-btn {
  width: 11rem; height: 11rem;
  border-radius: 50%;
  border: none;
  font-size: 2.1rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--primaryInk);
  background: radial-gradient(circle at 35% 30%, #ffe3a1, var(--primary) 60%, #d99a1e);
  box-shadow: 0 0 0 10px rgba(245, 184, 61, 0.25), 0 18px 40px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.05s ease;
  animation: buzzPulse 1.6s ease-in-out infinite;
}
.buzz-btn:active { transform: scale(0.94); }
@keyframes buzzPulse {
  0%, 100% { box-shadow: 0 0 0 8px rgba(245, 184, 61, 0.22), 0 18px 40px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 0 0 18px rgba(245, 184, 61, 0.34), 0 18px 40px rgba(0, 0, 0, 0.4); }
}

.status-line { text-align: center; font-weight: 800; font-size: 1.35rem; margin: 0.6rem 0; min-height: 2em; }
.status-sub { text-align: center; color: var(--muted); font-weight: 600; min-height: 1.4em; }

.answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 1rem; }
.answer-btn {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--panel2);
  border: 3px solid transparent;
  border-radius: 16px;
  padding: 1rem 0.9rem;
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
  min-height: 4.6rem;
}
.answer-btn .key {
  flex: 0 0 auto;
  width: 1.8em; height: 1.8em;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}
.answer-btn.mine { border-color: var(--primary); background: rgba(245, 184, 61, 0.16); }
.answer-btn.correct { border-color: var(--good); background: rgba(126, 231, 135, 0.18); }
.answer-btn.wrongpick { border-color: var(--bad); background: rgba(255, 123, 114, 0.16); }
.answer-btn:disabled { cursor: default; }

.verdict { text-align: center; font-size: 1.5rem; font-weight: 900; margin-top: 1.2rem; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }

.my-points { text-align: center; font-weight: 800; color: var(--accent); margin-top: 1.2rem; font-size: 1.05rem; }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 100; }
.confetti span {
  position: absolute;
  top: -12px;
  width: 10px; height: 16px;
  border-radius: 3px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-5vh) rotate(0deg); opacity: 1; }
  100% { transform: translateY(108vh) rotate(720deg); opacity: 0.7; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .stage-grid { grid-template-columns: 1fr; }
  .board-cols { grid-template-columns: 1fr; }
  .question-card .prompt { font-size: 1.5rem; }
  .pin-big { font-size: 3.4rem; }
}
