:root {
  --bg: #0f1220;
  --panel: #1b1f33;
  --border: #32374f;
  --text: #e6e9f5;
  --muted: #8b91ad;
  --accent: #6ea8ff;
  --green: #4fc07a;
  --red: #e05a5a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-size: 20px; }
.quiz-picker { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.quiz-picker select {
  padding: 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #12152a;
  color: var(--text);
  font-size: 14px;
}

main { max-width: 640px; margin: 0 auto; padding: 20px; }
.muted { color: var(--muted); }
#progress { color: var(--muted); font-size: 13px; min-height: 18px; }

.prompt { font-size: 20px; margin: 10px 0 16px; }
.q-image { max-width: 100%; border-radius: 8px; margin-bottom: 12px; }

.opt {
  display: block;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.opt:hover { border-color: var(--accent); }

#q-text {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #12152a;
  color: var(--text);
  font-size: 16px;
}

.sel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.sel-label { flex: 1; }
.sel {
  padding: 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #12152a;
  color: var(--text);
  font-size: 14px;
  min-width: 140px;
}

.nav { margin-top: 16px; }
.nav button, .results + button {
  background: var(--accent);
  color: #0b0e1c;
  border: 0;
  border-radius: 8px;
  padding: 11px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.results { padding-left: 24px; }
.results li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.q-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.pts { color: var(--muted); font-size: 13px; white-space: nowrap; }
.detail { margin-top: 4px; }
.detail.ok { color: var(--green); }
.detail.bad { color: var(--red); }
.rt { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.rt th, .rt td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.rt th { color: var(--muted); font-weight: 600; }
.rt td.ok { color: var(--green); }
.rt td.bad { color: var(--red); }
.mini { color: var(--muted); font-size: 13px; margin-top: 6px; }
.norms { margin: 12px 0 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; background: rgba(0,0,0,0.18); }
.norm-rank { font-size: 15px; margin: 0 0 4px; }
.norm-rank strong { color: var(--green); }
.norm-sub { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.curve { display: flex; gap: 3px; height: 90px; align-items: stretch; }
.bin { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.bar-area { flex: 1; display: flex; align-items: flex-end; }
.bar { width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
.bin.you .bar { background: var(--green); }
.bin-label { font-size: 9px; color: var(--muted); text-align: center; line-height: 1; margin-top: 3px; }

/* ---------- Multiplayer ---------- */
.hidden { display: none !important; }
.header-right { display: flex; align-items: center; gap: 16px; }
.tag { font-size: 12px; font-weight: 600; color: var(--accent); background: rgba(110,168,255,0.12); padding: 2px 8px; border-radius: 999px; margin-left: 6px; }
header a { color: var(--accent); text-decoration: none; font-size: 13px; }
.mp-main { max-width: 760px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-top: 20px; }
.panel h2 { margin: 0 0 12px; font-size: 18px; }
.panel h3 { margin: 18px 0 6px; font-size: 14px; color: var(--muted); }
.landing-grid { max-width: 900px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
#content-body .landing-grid .panel { max-width: none; margin: 0; }
@media (max-width: 600px) { .landing-grid { grid-template-columns: 1fr; } }
.room-form > label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.room-form input[type="text"], .room-form select {
  width: 100%; margin-top: 4px; padding: 9px; border-radius: 8px;
  border: 1px solid var(--border); background: #12152a; color: var(--text); font-size: 15px;
}
.cat-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cat-item { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; cursor: pointer; color: var(--text); }
.cat-item:hover { border-color: var(--accent); }
.cat-item input { accent-color: var(--accent); margin: 0; }
.primary { background: var(--accent); color: #0b0e1c; border: 0; border-radius: 8px; padding: 11px 22px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 4px; }
.room-code { font-size: 20px; }
.room-code strong { letter-spacing: 2px; color: var(--accent); }
#lobby-players li, #reveal-results li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.res-ok { color: var(--green); }
.res-bad { color: var(--red); }
.timerbar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 10px 0 4px; }
#game-timer-fill { height: 100%; width: 100%; background: var(--accent); transition: width 0.2s linear; }
#game-status { margin-left: 12px; font-size: 14px; }
.nav { display: flex; align-items: center; }

/* ---------- Chat sidebar + voice (like Daddy's Rules) ---------- */
#layout { display: flex; height: 100vh; overflow: hidden; }
#content { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
#content-body { flex: 1; overflow-y: auto; padding: 20px; }
#content-body .panel { max-width: 760px; margin-left: auto; margin-right: auto; }

#chat-panel {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--panel);
  min-height: 100vh;
}
#chat-panel.hidden { display: none; }
.chat-title { margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--border); }
#chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { align-self: flex-start; max-width: 82%; line-height: 1.4; font-size: 14px; background: #22263e; border-radius: 10px; padding: 6px 10px; }
.chat-msg .who { color: var(--accent); font-weight: 600; }
.chat-msg.mine { align-self: flex-end; background: #1f3a2c; }
.chat-msg.mine .who { color: var(--green); }
.chat-msg .when { color: var(--muted); font-size: 11px; margin-left: 6px; }
.chat-msg .body { word-wrap: break-word; overflow-wrap: anywhere; }
#chat-input-row { display: flex; border-top: 1px solid var(--border); padding: 8px; gap: 8px; }
#chat-input { flex: 1; min-width: 0; padding: 9px; border-radius: 6px; border: 1px solid var(--border); background: #12152a; color: var(--text); font-size: 14px; }
#chat-send { background: var(--accent); color: #0b0e1c; border: 0; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }

#voice-panel { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--panel); }
#voice-panel button { flex: 1; position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; font-size: 12px; line-height: 1.2; border: 0; border-radius: 8px; cursor: pointer; }
#voice-panel button.on { background: #3dbb6d; color: #0b0e1c; }
#voice-panel button.off { background: #e57373; color: #0b0e1c; }
#voice-panel button:disabled { opacity: .5; cursor: not-allowed; }
#voice-panel .btn-line1 { font-weight: 700; }
#voice-panel .btn-line2 { font-size: 11px; opacity: 0.85; }
.meter { position: absolute; left: 0; bottom: 0; height: 5px; width: 0%; background: #0a5a2a; transition: width 0.08s linear; }

@media (max-width: 720px) {
  #layout { flex-direction: column; }
  #chat-panel { position: fixed; left: 0; right: 0; bottom: 0; width: auto; height: 45vh; min-height: 0; border-right: 0; border-top: 1px solid var(--border); z-index: 20; }
  #content { padding-bottom: 46vh; }
}

/* ---------- Phase 2: fun layer ---------- */
#reveal.anim { animation: reveal-pop 0.35s ease; }
@keyframes reveal-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.reveal-item { opacity: 0; animation: reveal-item 0.4s ease forwards; }
@keyframes reveal-item {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: none; }
}
.timerbar.warn #game-timer-fill { background: #e0a63a; }
.timerbar.low #game-timer-fill { background: var(--red); }
.lb-row { margin: 10px 0; }
.lb-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; margin-bottom: 4px; }
.lb-score { font-weight: 700; }
.lb-bar { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.lb-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 5px; transition: width 0.6s cubic-bezier(.22,1,.36,1); }
.lb-row.lead .lb-fill { background: var(--green); }
.lb-row.lead .lb-name { color: var(--green); font-weight: 700; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 9999; }
.tidbit { margin: 10px 0; padding: 12px 14px; border-left: 3px solid var(--accent); background: rgba(0,0,0,0.18); border-radius: 0 8px 8px 0; }
.tidbit-text { font-size: 14px; line-height: 1.5; }
.tidbit-media { display: flex; gap: 16px; align-items: flex-start; }
.tidbit-media .tidbit-text { flex: 1; }
.tidbit-media-right { display: flex; flex-direction: column; align-items: center; gap: 6px; flex-shrink: 0; }
.tidbit-gallery { display: flex; align-items: center; gap: 8px; }
.tidbit-gallery img { max-width: 220px; max-height: 160px; border-radius: 8px; border: 1px solid var(--border); }
.tidbit-arrow { background: var(--panel); border: 1px solid var(--border); color: var(--text); width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1; padding: 0; }
.tidbit-arrow:hover { border-color: var(--accent); color: var(--accent); }
.tidbit-counter { font-size: 12px; color: var(--muted); }
.reveal-you { font-size: 15px; margin: 8px 0; padding: 8px 12px; border-radius: 8px; background: rgba(0,0,0,0.18); }
.reveal-you .ry-you { font-weight: 700; margin-right: 6px; }
#reveal-ready-row { margin-top: 16px; display: flex; align-items: center; gap: 12px; }
.ready-btn { border: 0; border-radius: 8px; padding: 12px 20px; font-size: 15px; font-weight: 600; cursor: pointer; }
.ready-btn.not-ready { background: #e57373; color: #0b0e1c; }
.ready-btn.ready { background: #3dbb6d; color: #0b0e1c; }
.ready-btn:disabled { opacity: .7; cursor: default; }
