/* Trivia Night — quiz-show styling shared by every page */

:root {
  --bg: #120d2b;
  --bg-2: #1d1546;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f4f1ff;
  --muted: #a99fd6;
  --accent: #ffcc33;
  --accent-ink: #2a1d00;
  --good: #2ecc71;
  --bad: #ff5468;
  --info: #5aa9ff;

  --opt-0: #e5484d; /* A ▲ */
  --opt-1: #3e7bfa; /* B ◆ */
  --opt-2: #f0a020; /* C ● */
  --opt-3: #2fb26a; /* D ■ */

  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --display: 'Fredoka', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, rgba(120, 80, 255, 0.35), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(255, 70, 160, 0.22), transparent 45%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: 0.01em; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 0.82rem; }
.center { text-align: center; }

/* ---- layout ------------------------------------------------------------ */
.wrap { max-width: 1240px; margin: 0 auto; padding: 18px 16px 40px; }
.wrap-narrow { max-width: 560px; }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.center-box { width: 100%; max-width: 440px; text-align: center; }

.logo {
  font-size: clamp(2.2rem, 7vw, 3.4rem);
  line-height: 1;
  background: linear-gradient(90deg, #ffd84d, #ff7eb6 55%, #8f7bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-sm { font-size: clamp(1.5rem, 4vw, 2rem); }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.topbar-left, .topbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.panel + .panel { margin-top: 16px; }
.panel h3 { font-size: 1.15rem; margin-bottom: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h3 { margin: 0; }

.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 960px) { .live-grid { grid-template-columns: 1fr; } }

/* ---- controls ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 12px 20px;
  font: 600 1rem var(--display);
  letter-spacing: 0.02em;
  cursor: pointer;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 26px; font-size: 1.2rem; }
.btn-sm { padding: 7px 12px; font-size: 0.88rem; border-radius: 10px; }
.btn-ghost { background: rgba(255, 255, 255, 0.1); color: var(--text); box-shadow: none; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-good { background: var(--good); color: #062b16; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.icon-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.18); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

.field { margin-bottom: 14px; text-align: left; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
input[type='text'], input[type='password'], input[type='number'], textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
textarea { resize: vertical; min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 0.88rem; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.code-input { text-transform: uppercase; letter-spacing: 0.35em; text-align: center; font: 600 1.6rem var(--display) !important; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.95rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.badge {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--panel-border);
  white-space: nowrap;
}
.badge-accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }

.alert { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: 0.92rem; text-align: left; }
.alert-bad { background: rgba(255, 84, 104, 0.16); border: 1px solid rgba(255, 84, 104, 0.5); }
.alert-ok { background: rgba(46, 204, 113, 0.15); border: 1px solid rgba(46, 204, 113, 0.5); }
.alert-info { background: rgba(90, 169, 255, 0.15); border: 1px solid rgba(90, 169, 255, 0.5); }

.tabs { display: inline-flex; background: rgba(0, 0, 0, 0.25); border-radius: 12px; padding: 4px; gap: 4px; }
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 16px;
  border-radius: 9px;
  font: 600 0.95rem var(--display);
  cursor: pointer;
}
.tab.active { background: rgba(255, 255, 255, 0.14); color: var(--text); }

/* ---- landing ----------------------------------------------------------- */
.choices { display: grid; gap: 14px; margin-top: 28px; }
.choice {
  display: block;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.choice:hover { transform: translateY(-2px); border-color: var(--accent); }
.choice strong { display: block; font: 600 1.3rem var(--display); margin-bottom: 4px; }

/* ---- the join code ----------------------------------------------------- */
.code-big {
  font: 700 clamp(2.4rem, 6vw, 3.6rem) var(--display);
  letter-spacing: 0.18em;
  color: var(--accent);
  text-align: center;
  line-height: 1.1;
}
.join-url { word-break: break-all; text-align: center; font-size: 0.9rem; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat { background: rgba(0, 0, 0, 0.22); border-radius: 10px; padding: 8px; text-align: center; }
.stat b { display: block; font: 600 1.25rem var(--display); }
.stat span { font-size: 0.75rem; color: var(--muted); }

/* ---- stage (moderator's big screen) ----------------------------------- */
.stage { min-height: 520px; display: flex; flex-direction: column; gap: 18px; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stage-title { font-size: clamp(1.5rem, 3.2vw, 2.4rem); line-height: 1.25; }
.stage-sub { color: var(--muted); font-size: 1rem; }
.lobby-hero { text-align: center; padding: 18px 0 6px; }
.lobby-hero .code-big { font-size: clamp(3rem, 9vw, 5.5rem); }
.lobby-hero p { font-size: 1.2rem; margin: 6px 0; }

.name-cloud { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.name-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.95rem;
  animation: pop-in 0.3s ease;
}

/* ---- answers (shared by stage and phone) ------------------------------ */
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 14px 16px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  font: 600 1.15rem var(--display);
  text-align: left;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.answer .shape { font-size: 1.4rem; flex: 0 0 auto; opacity: 0.9; }
.answer .text { flex: 1 1 auto; position: relative; z-index: 1; word-break: break-word; }
.answer .count { position: relative; z-index: 1; font-size: 1.3rem; }
.answer .bar { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255, 255, 255, 0.18); transition: width 0.6s ease; }
.opt-0 { background: var(--opt-0); }
.opt-1 { background: var(--opt-1); }
.opt-2 { background: var(--opt-2); }
.opt-3 { background: var(--opt-3); }
.answer.dim { filter: grayscale(0.75) brightness(0.55); }
.answer.correct { outline: 4px solid #fff; outline-offset: -4px; }
.answer.correct::after { content: '✓'; position: relative; z-index: 1; font-size: 1.6rem; }

button.answer { cursor: pointer; width: 100%; }
button.answer:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
button.answer:disabled { cursor: default; }
button.answer.picked { outline: 4px solid #fff; outline-offset: -4px; }

/* ---- timer ------------------------------------------------------------- */
.timer-wrap { display: flex; align-items: center; gap: 14px; }
.timer-num {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.3);
  border: 3px solid var(--accent);
  font: 700 1.6rem var(--display);
}
.timer-num.urgent { border-color: var(--bad); color: var(--bad); animation: pulse 0.8s ease infinite; }
.timer-bar { flex: 1 1 auto; height: 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--good), var(--accent)); transition: width 0.25s linear; }
.timer-fill.urgent { background: var(--bad); }

.progress { height: 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); overflow: hidden; }
.progress > div { height: 100%; background: var(--info); transition: width 0.3s ease; }

/* ---- leaderboard ------------------------------------------------------- */
.board { display: flex; flex-direction: column; gap: 8px; }
.board-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  animation: slide-in 0.35s ease both;
}
.board-row .pos { font: 700 1.2rem var(--display); color: var(--muted); }
.board-row .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board-row .pts { font: 600 1.1rem var(--display); }
.board-row.top1 { background: linear-gradient(90deg, rgba(255, 204, 51, 0.35), rgba(255, 204, 51, 0.08)); }
.board-row.top1 .pos { color: var(--accent); }
.board-row.me { outline: 2px solid var(--accent); }

.podium { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end; gap: 12px; margin: 10px 0 6px; }
.step {
  text-align: center;
  border-radius: 14px 14px 6px 6px;
  padding: 14px 8px;
  background: rgba(255, 255, 255, 0.1);
  animation: rise 0.6s ease both;
}
.step .medal { font-size: 2.2rem; }
.step .who { font: 600 1.1rem var(--display); overflow-wrap: anywhere; }
.step .pts { color: var(--muted); }
.step-1 { min-height: 210px; background: linear-gradient(180deg, rgba(255, 204, 51, 0.4), rgba(255, 204, 51, 0.1)); }
.step-2 { min-height: 170px; animation-delay: 0.15s; }
.step-3 { min-height: 140px; animation-delay: 0.3s; }

/* ---- player list (moderator side) -------------------------------------- */
.list { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 0.92rem;
}
.list-row .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- question bank ----------------------------------------------------- */
.bank-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .bank-grid { grid-template-columns: 1fr; } }
.q-item { padding: 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.22); display: flex; gap: 10px; }
.q-item + .q-item { margin-top: 8px; }
.q-num { font: 700 1rem var(--display); color: var(--muted); min-width: 28px; }
.q-body { flex: 1 1 auto; min-width: 0; }
.q-text { font-weight: 600; margin-bottom: 6px; overflow-wrap: anywhere; }
.q-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.q-opt { font-size: 0.82rem; padding: 3px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.q-opt.right { background: rgba(46, 204, 113, 0.3); }
.q-actions { display: flex; flex-direction: column; gap: 4px; }
.opt-input { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.opt-input .tag { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; color: #fff; }
.opt-input label { font-size: 0.82rem; color: var(--muted); display: flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.opt-input input[type='radio'] { accent-color: var(--good); width: 18px; height: 18px; }
pre.help {
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.8rem;
  overflow-x: auto;
  margin: 8px 0 12px;
}

/* ---- question types & media ------------------------------------------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.type-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
@media (max-width: 560px) { .type-picker { grid-template-columns: 1fr 1fr; } }
.type-btn {
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 6px;
  font: 600 0.92rem var(--display);
  cursor: pointer;
}
.type-btn.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.media-fields {
  border: 1px dashed var(--panel-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
  background: rgba(0, 0, 0, 0.15);
}
.media-fields input[type='file'] { color: var(--muted); font-size: 0.88rem; max-width: 100%; }
.media-preview { margin: 0 0 12px; text-align: center; }
.media-preview img, .media-preview video { max-width: 100%; max-height: 220px; border-radius: 10px; }
.media-preview audio { width: 100%; }
.clip-fields { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.clip-fields .btn { margin-bottom: 14px; }
@media (max-width: 560px) { .clip-fields { grid-template-columns: 1fr 1fr; } }

.stage-media { text-align: center; }
.stage-media img, .stage-media video {
  max-width: 100%;
  max-height: 46vh;
  border-radius: 14px;
  box-shadow: var(--shadow);
  background: #000;
}
.stage-media-sm img, .stage-media-sm video { max-height: 24vh; }
.stage-media audio { width: min(520px, 100%); }

.q-media { text-align: center; }
.q-media img, .q-media video {
  max-width: 100%;
  max-height: 34vh;
  border-radius: 12px;
  background: #000;
}
.q-media audio { width: 100%; }
.q-media-sm img { max-height: 18vh; margin-bottom: 8px; }
.tap-play { margin-top: 10px; }
.host-only {
  padding: 18px 14px;
  border-radius: 12px;
  background: rgba(90, 169, 255, 0.15);
  border: 1px solid rgba(90, 169, 255, 0.45);
  font-size: 1.05rem;
}

.q-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.media-badge { font-size: 0.95rem; }

.file-preview { margin-top: 14px; padding: 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.2); }
.file-list { max-height: 260px; overflow: auto; margin: 6px 0 0; padding-left: 26px; font-size: 0.9rem; }
.file-list li { margin-bottom: 6px; }
.file-list .q-text { display: inline; margin: 0; }
.help-box { margin-top: 12px; }
.help-box summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; }
.help-box[open] summary { margin-bottom: 6px; }
label.btn { user-select: none; }

/* ---- phone screens ----------------------------------------------------- */
.player-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(18, 13, 43, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--panel-border);
}
.player-bar .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen { max-width: 640px; margin: 0 auto; padding: 18px 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.q-counter { color: var(--muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.12em; }
.q-big { font-size: clamp(1.3rem, 5vw, 1.8rem); line-height: 1.3; }
.screen .answers { grid-template-columns: 1fr; }
@media (min-width: 560px) { .screen .answers { grid-template-columns: 1fr 1fr; } }
.screen .answer { min-height: 72px; font-size: 1.1rem; }

.result-hero { text-align: center; padding: 26px 16px; border-radius: var(--radius); animation: pop-in 0.35s ease; }
.result-hero .big { font: 700 clamp(2.2rem, 10vw, 3.4rem) var(--display); line-height: 1.1; }
.result-hero .pts { font: 600 1.5rem var(--display); margin-top: 6px; }
.result-good { background: linear-gradient(160deg, rgba(46, 204, 113, 0.5), rgba(46, 204, 113, 0.15)); }
.result-bad { background: linear-gradient(160deg, rgba(255, 84, 104, 0.5), rgba(255, 84, 104, 0.15)); }
.result-wait { background: linear-gradient(160deg, rgba(90, 169, 255, 0.4), rgba(90, 169, 255, 0.12)); }

.spinner {
  width: 46px;
  height: 46px;
  margin: 10px auto;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

.footer-note { text-align: center; color: var(--muted); font-size: 0.82rem; margin-top: 20px; }

/* ---- motion ------------------------------------------------------------ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes pop-in { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide-in { from { transform: translateX(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 560px) {
  .answers { grid-template-columns: 1fr; }
  .stage { min-height: 0; }
  .podium { gap: 6px; }
  .step .who { font-size: 0.95rem; }
}
