:root {
  --bg: #0f1220;
  --panel: #1b1f33;
  --border: #32374f;
  --text: #e6e9f5;
  --muted: #8b91ad;
  --accent: #6ea8ff;
  --gold: #f5c518;
  --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;
}

.hidden { display: none !important; }

/* ---------- layout ---------- */
#layout { display: flex; height: 100vh; overflow: hidden; }
#content { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; max-width: none; margin: 0; padding: 0; }

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; }

#content-body { flex: 1; overflow-y: auto; padding: 20px; }

/* ---------- panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-top: 20px; max-width: none; }
.panel h2 { margin: 0 0 12px; font-size: 18px; }
.panel h3 { margin: 18px 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"] {
  width: 100%; margin-top: 4px; padding: 9px; border-radius: 8px;
  border: 1px solid var(--border); background: #12152a; color: var(--text); font-size: 15px;
}

.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;
}

.muted { color: var(--muted); }
.room-code { font-size: 20px; }
.room-code strong { letter-spacing: 2px; color: var(--accent); }
#lobby-players li { padding: 8px 0; border-bottom: 1px solid var(--border); }

/* ---------- puzzle board ---------- */
.wof-board {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  margin: 16px 0;
}
.wof-board .tile {
  min-width: 34px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: #12152a;
  color: var(--text);
}
.wof-board .tile.shown { color: var(--gold); border-color: var(--accent); }
.wof-board .gap { width: 20px; }

.category { font-size: 15px; color: var(--accent); font-weight: 700; }
.message { min-height: 22px; font-size: 16px; color: var(--gold); }
#turn-info { font-size: 14px; margin: 8px 0; }

/* ---------- scores ---------- */
#scores { margin: 10px 0; }
.score-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.score-row.turn { color: var(--accent); font-weight: 700; }
.score-name { flex: 1; }
.score-banked { min-width: 110px; text-align: right; color: var(--green); }
.score-round { min-width: 90px; text-align: right; color: var(--muted); }

/* ---------- actions / input ---------- */
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
#input-row { display: flex; gap: 8px; margin-top: 12px; }
#input-row input, #bonus-solve input {
  flex: 1; padding: 9px; border-radius: 8px; border: 1px solid var(--border);
  background: #12152a; color: var(--text); font-size: 15px;
}

/* ---------- bonus picker ---------- */
.pick-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-buttons button {
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-weight: 700; cursor: pointer; font-size: 15px;
}
.pick-buttons button.picked { background: var(--accent); color: #0b0e1c; border-color: var(--accent); }

/* ---------- 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; }
}

/* ---------- hub auth gate ---------- */
#auth-gate { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 10000; }
#auth-gate.hidden { display: none; }
.auth-gate-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 24px; text-align: center; max-width: 420px; }
.auth-gate-box h2 { margin: 0 0 8px; }
.auth-gate-box p { color: var(--muted); margin: 0 0 12px; }
.auth-gate-box .btn { display: inline-block; padding: 10px 18px; border-radius: 8px; background: var(--accent); color: #0b0e1c; text-decoration: none; font-weight: 600; }
