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

* { 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;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- layout ---------- */
#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 > * { max-width: 760px; margin-left: auto; margin-right: auto; }

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-size: 20px; }

/* ---------- chat sidebar + voice ---------- */
#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; }
}

/* ---------- panels + forms ---------- */
.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: 16px 0 6px; font-size: 14px; color: var(--muted); }
.landing-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@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;
}
.team-radio { display: flex; gap: 16px; margin-top: 4px; }
.team-radio .inline { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 14px; }
.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; }
#lobby-code { color: var(--accent); letter-spacing: 2px; }
.t1 { color: var(--accent); }
.t2 { color: var(--orange); }
#team1-list li, #team2-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }

/* ---------- game ---------- */
#scoreboard { display: flex; gap: 12px; }
.score { flex: 1; text-align: center; padding: 10px; border-radius: 10px; border: 1px solid var(--border); }
.score strong { font-size: 28px; }
.score.team1 { color: var(--accent); border-color: var(--accent); }
.score.team2 { color: var(--orange); border-color: var(--orange); }
#round-info { font-size: 13px; }
.prompt { font-size: 20px; margin: 10px 0 16px; }

#board { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.slot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; }
.slot.revealed { border-color: var(--green); }
.slot-ans { font-size: 15px; font-weight: 600; }
.slot-pnt { font-size: 13px; color: var(--muted); white-space: nowrap; }

#strikes { display: flex; gap: 8px; margin: 8px 0; }
.strike { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-weight: 700; }
.strike.bad { color: #0b0e1c; background: var(--red); border-color: var(--red); }

#answer-row { display: flex; gap: 10px; margin-top: 14px; }
#answer-input { flex: 1; padding: 12px; border-radius: 8px; border: 1px solid var(--border); background: #12152a; color: var(--text); font-size: 16px; }
#result-box { min-height: 24px; margin: 10px 0; font-size: 15px; }
.res-ok { color: var(--green); }
.res-bad { color: var(--red); }
