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

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

/* ---------- Header / status bar ---------- */
header.site-head {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.head-inner {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}
.head-brand .brand { font-size: 20px; font-weight: 700; color: var(--text); }
#status-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--border);
  font-size: 15px;
}
#header-right { display: flex; align-items: center; gap: 8px; }
.header-btn {
  font-size: 14px; font-weight: 700; padding: 5px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer;
}

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

.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); }
.muted { color: var(--muted); }
.room-code { font-size: 20px; }
.room-code strong { letter-spacing: 2px; color: var(--accent); }

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

/* ---------- Lobby ---------- */
.lobby-options { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; align-items: flex-end; }
.lobby-options > label { display: block; color: var(--muted); font-size: 13px; }
.lobby-options select, .lobby-options input[type="text"] {
  width: 100%; margin-top: 4px; padding: 8px; border-radius: 8px;
  border: 1px solid var(--border); background: #12152a; color: var(--text); font-size: 14px;
}
.lobby-options input[type="text"] { max-width: 130px; }
#lobby-players li { padding: 8px 0; border-bottom: 1px solid var(--border); }
#lobby-players ul { padding-left: 20px; margin: 4px 0; }
#team-area { margin-top: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: rgba(0,0,0,0.18); }
#team-action { margin-top: 10px; width: 100%; max-width: 280px; padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: #12152a; color: var(--text); font-size: 14px; }
#team-action option:disabled { color: var(--muted); }

/* ---------- Buttons ---------- */
.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;
}
.pass-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 11px 22px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 4px;
}
.pass-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Timer bar ---------- */
.timer-limit-row { display: flex; justify-content: flex-end; margin-bottom: 2px; }
.timer-limit { font-size: 12px; color: var(--muted); }
.timerbar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 0 0 4px; }
#game-timer-fill { height: 100%; width: 100%; background: var(--accent); transition: width 0.2s linear; }
.timerbar.warn #game-timer-fill { background: var(--amber); }
.timerbar.low #game-timer-fill { background: var(--red); }

/* ---------- Game ---------- */
#game-progress { color: var(--muted); font-size: 14px; min-height: 18px; }
#game-role { font-size: 18px; margin: 10px 0 6px; }
#game-role .role-guesser { color: var(--green); font-weight: 700; }
#game-role .role-clue { color: var(--accent); font-weight: 700; }
#game-role .role-spectator { color: var(--muted); font-weight: 600; }

.word-box {
  text-align: center; font-size: 40px; font-weight: 800; letter-spacing: 1px;
  padding: 20px 12px; margin: 14px 0; border: 1px solid var(--accent); border-radius: 12px;
  background: rgba(110,168,255,0.08); color: var(--text);
}
.word-box .word-label { display: block; font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: 1px; margin-bottom: 6px; text-transform: uppercase; }

.turn-result { margin: 12px 0; padding: 14px 16px; border-radius: 10px; font-size: 16px; font-weight: 600; }
.turn-result.correct { background: #1f3a2c; color: var(--green); border: 1px solid var(--green); }
.turn-result.penalty { background: #3a1f1f; color: var(--red); border: 1px solid var(--red); }
.turn-result.timeout { background: #332d18; color: var(--amber); border: 1px solid var(--amber); }

.score-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; margin-bottom: 4px; }
.score-row .score { font-weight: 700; }

/* ---------- Chat / transcript sidebar ---------- */
#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 .body { word-wrap: break-word; overflow-wrap: anywhere; }
.chat-msg .kind-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; margin-right: 2px; }
.chat-msg.guess { border: 1px solid rgba(79,192,122,0.5); }
.chat-msg.guess .kind-tag { color: var(--green); }
.chat-msg.hint { border: 1px solid rgba(110,168,255,0.4); }
.chat-msg.hint .kind-tag { color: var(--accent); }
.chat-system { align-self: center; font-size: 12px; color: var(--muted); font-style: italic; padding: 4px 0; text-align: center; }
#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; }

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

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

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