/* ═══════════════════ RESET & VARS ═══════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #0d0d14;
  --surface: #16162a;
  --card:    #1e1e36;
  --border:  #2e2e52;
  --accent:  #7c3aed;
  --accent2: #0ea5e9;
  --green:   #10b981;
  --red:     #ef4444;
  --orange:  #f97316;
  --yellow:  #eab308;
  --text:    #e2e8f0;
  --muted:   #64748b;
  --radius:  12px;
  --shadow:  0 4px 24px rgba(0,0,0,0.5);
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.5;
}

/* ─── Global thin scrollbars ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }

a { color: var(--accent2); text-decoration: none; }
h1,h2,h3,h4 { line-height: 1.25; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
p.muted, .muted { color: var(--muted); font-size: 0.875rem; }
.hidden { display: none !important; }

/* ═══════════════════ VIEWS ═══════════════════ */
.view { display: none; min-height: 100vh; }
.view.active { display: flex; flex-direction: column; }

/* ═══════════════════ BUTTONS ═══════════════════ */
button { cursor: pointer; border: none; border-radius: 8px; font-size: 0.95rem; font-weight: 600; transition: all .15s; }
.btn-primary { background: var(--accent); color: #fff; padding: 10px 22px; }
.btn-primary:hover { background: #6d28d9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); padding: 8px 18px; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--red); color: #fff; padding: 8px 16px; }
.btn-danger:hover { background: #dc2626; }
.btn-icon { background: transparent; color: var(--muted); border: 1px solid var(--border); padding: 4px 10px; font-size: 1rem; }
.btn-icon:hover { color: var(--text); border-color: var(--text); }
.btn-sm { font-size: 0.8rem; padding: 5px 12px; }
.btn-lg { padding: 13px 32px; font-size: 1.05rem; }

/* ═══════════════════ INPUTS ═══════════════════ */
input[type="text"], input[type="color"] {
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 14px; font-size: 0.95rem;
  outline: none; width: 100%; transition: border .15s;
}
input[type="text"]:focus { border-color: var(--accent); }
input[type="text"]::placeholder { color: var(--muted); }
input[type="range"] { accent-color: var(--accent); width: 100%; cursor: pointer; }

/* ═══════════════════ HOME ═══════════════════ */
#view-home {
  align-items: center; padding: 40px 20px 60px;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,58,237,.18) 0%, transparent 70%), var(--bg);
}
.home-header { text-align: center; margin-bottom: 40px; }
.logo { font-size: 2.5rem; font-weight: 800; letter-spacing: -.02em;
  background: linear-gradient(135deg, #c084fc, #818cf8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.tagline { color: var(--muted); margin-top: 6px; font-size: 1rem; }

.game-selector { text-align: center; margin-bottom: 36px; }
.game-selector h2 { margin-bottom: 20px; color: var(--muted); font-size: 1rem; text-transform: uppercase; letter-spacing: .1em; }
.game-cards { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.game-card {
  width: 180px; padding: 24px 16px; border-radius: var(--radius);
  background: var(--card); border: 2px solid var(--border);
  cursor: pointer; transition: all .2s; text-align: center;
}
.game-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 8px 24px rgba(124,58,237,.25); }
.game-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,58,237,.3); }
.game-card.game-card-locked { pointer-events: none; cursor: default; }
.game-icon { font-size: 2.2rem; margin-bottom: 10px; }
.game-card h3 { font-size: 1rem; margin-bottom: 6px; }
.game-card p { color: var(--muted); font-size: 0.8rem; margin-bottom: 10px; }
.badge { background: rgba(124,58,237,.25); color: #c084fc; font-size: 0.75rem; padding: 3px 10px; border-radius: 20px; font-weight: 600; }

.join-box { width: 100%; max-width: 420px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); padding: 28px; }
.form-row { margin-bottom: 14px; }
.avatar-section { margin: 0 0 16px; }
.avatar-preview-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px;
}
.avatar-preview-emoji { font-size: 1.8rem; line-height: 1; }
.avatar-preview-name { flex: 1; font-weight: 600; font-size: 0.95rem; color: var(--text); }
.btn-change-avatar {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; padding: 5px 12px; font-size: 0.8rem; cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-change-avatar:hover { border-color: var(--accent); color: var(--accent); }

.avatar-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.avatar-modal.hidden { display: none; }
.avatar-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.65); }
.avatar-modal-box {
  position: relative; background: var(--bg); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; width: 98%; max-width: 720px;
  max-height: 92vh; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); overflow-x: hidden;
}
.avatar-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700; font-size: 1rem; color: var(--text);
}
.avatar-modal-close {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 1.1rem; padding: 4px 8px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.avatar-modal-close:hover { color: var(--text); background: var(--card); }
.avatar-modal .avatar-grid {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px;
  overflow-y: auto; overflow-x: hidden; max-height: calc(92vh - 70px);
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.avatar-modal .avatar-opt { font-size: 1.4rem; padding: 6px; }


.avatar-opt {
  background: var(--card); border: 2px solid var(--border); border-radius: 8px;
  font-size: 1.2rem; padding: 5px; cursor: pointer; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s, box-shadow .15s,
              transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative; z-index: 0;
}
.avatar-opt:not(.selected):hover {
  border-color: var(--accent2); background: rgba(14,165,233,.12);
  transform: scale(1.3) rotate(-8deg); z-index: 2;
}
.avatar-opt.selected {
  border-color: var(--accent); background: rgba(124,58,237,.2);
  animation: avatarGlow 2s ease-in-out infinite;
}
.avatar-opt.selected:hover { animation: none; transform: scale(1.3) rotate(-8deg); }
.avatar-opt.avatar-reserved { opacity: 0.2; cursor: not-allowed; filter: grayscale(1); }
@keyframes avatarGlow {
  0%,100% { box-shadow: 0 0 0 2px var(--accent), 0 0 8px rgba(124,58,237,.4); transform: scale(1.1); }
  50%      { box-shadow: 0 0 0 3px var(--accent), 0 0 16px rgba(124,58,237,.6); transform: scale(1.14); }
}
@keyframes avatarEnter {
  from { opacity: 0; transform: scale(0.4) rotate(-20deg); }
  to   { opacity: 1; transform: scale(1); }
}
.avatar-opt-enter { animation: avatarEnter 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

.row-inline { display: flex; gap: 10px; }
.row-inline input { flex: 1; min-width: 0; }

/* ─── Home action cards ─── */
.home-actions { display: flex; flex-direction: column; gap: 0; margin: 14px 0 10px; }
.home-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; transition: border-color .15s;
}
.home-card:hover { border-color: rgba(124,58,237,.4); }
.home-card-icon { font-size: 1.6rem; flex-shrink: 0; line-height: 1; }
.home-card-text { flex: 1; min-width: 0; }
.home-card-title { font-weight: 600; font-size: 0.95rem; margin-bottom: 1px; }
.home-card-sub { font-size: 0.78rem; color: var(--muted); }
.home-card > .btn-primary { flex-shrink: 0; }
.home-or {
  text-align: center; color: var(--muted); font-size: 0.8rem; font-weight: 500;
  padding: 6px 0; position: relative;
}
.home-or::before, .home-or::after {
  content: ''; position: absolute; top: 50%; width: 35%; height: 1px;
  background: var(--border);
}
.home-or::before { left: 0; }
.home-or::after { right: 0; }

.error-msg { color: var(--red); font-size: 0.875rem; margin-top: 10px; }

/* ═══════════════════ LOBBY ═══════════════════ */
#view-lobby { background: var(--bg); }
.lobby-container { max-width: 680px; margin: 0 auto; padding: 40px 20px; width: 100%; }
.lobby-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.lobby-header h2 { font-size: 1.6rem; margin-bottom: 6px; }
.room-code-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.room-code-row span { color: var(--muted); font-size: 0.875rem; }
.code-display { font-size: 1.4rem; letter-spacing: .15em; color: var(--accent2); font-family: monospace; font-weight: 800; }

.lobby-players-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 12px; margin-bottom: 28px; }
.lobby-player-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 12px; text-align: center;
}
.lobby-player-card.is-host { border-color: var(--accent); }
.player-avatar { width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; color: #fff; }
.lobby-player-emoji { font-size: 2.2rem; margin-bottom: 6px; line-height: 1; }
.lobby-player-name { font-size: 0.875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.host-crown { font-size: 0.75rem; color: var(--yellow); margin-top: 4px; }

.lobby-footer { display: flex; flex-direction: column; align-items: center; gap: 14px; }
#lobby-status { text-align: center; }
.lobby-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ═══════════════════ TOASTS & LOADING ═══════════════════ */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px;
  font-size: 0.875rem; animation: slideIn .25s ease; box-shadow: var(--shadow); max-width: 280px; }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

#loading-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 9998; display: flex; align-items: center; justify-content: center; }
.spinner { width: 48px; height: 48px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════ AVATARS ═══════════════════ */
.avatar-colors { --a0:#7c3aed;--a1:#0ea5e9;--a2:#10b981;--a3:#f97316;--a4:#ef4444;--a5:#ec4899;--a6:#8b5cf6;--a7:#14b8a6; }

/* ═══════════════════ PHASE SPLASHES ═══════════════════ */
.phase-splash { display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 60px 32px; gap: 14px; min-height: 400px; }
.phase-icon { font-size: 4rem; }
.phase-splash h2 { font-size: 2rem; }
.result-message { font-size: 1.1rem; max-width: 480px; }

.anim-pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.anim-pop { animation: pop .4s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ═══════════════════ EXIT BUTTON ═══════════════════ */
.btn-exit {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px; font-size: 0.8rem; cursor: pointer; transition: all .15s;
}
.btn-exit:hover { color: var(--red); border-color: var(--red); }
.btn-exit-kd { width: 100%; margin-bottom: 4px; text-align: left; }

/* ═══════════════════ TIC TAC TOE ═══════════════════ */
#view-tictactoe { background: var(--bg); }
.ttt-container { max-width: 540px; margin: 0 auto; padding: 32px 20px; display: flex; flex-direction: column; }
.ttt-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.ttt-scoreboard { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; justify-content: center; }
.ttt-score-card { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; max-width: 160px; transition: border-color .3s; }
.ttt-score-card.active-turn { border-color: var(--accent); box-shadow: 0 0 12px rgba(124,58,237,.3); }
.ttt-symbol { font-size: 2rem; font-weight: 900; margin-bottom: 4px; }
.x-sym { color: #60a5fa; }
.o-sym { color: #f472b6; }
.score-pts { font-size: 1.6rem; font-weight: 800; margin-top: 6px; color: var(--accent2); }
.ttt-vs { font-size: 1.2rem; font-weight: 800; color: var(--muted); flex-shrink: 0; }

.ttt-status-bar { text-align: center; padding: 10px; font-size: 1rem; color: var(--muted); margin-bottom: 16px; min-height: 36px; }

.ttt-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 24px; }
.ttt-cell {
  aspect-ratio: 1; background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 2.8rem; font-weight: 900;
  cursor: pointer; transition: all .15s; user-select: none;
}
.ttt-cell:hover:not(.taken) { background: var(--surface); border-color: var(--accent); transform: scale(1.03); }
.ttt-cell.taken { cursor: default; }
.ttt-cell.x-cell { color: #60a5fa; }
.ttt-cell.o-cell { color: #f472b6; }
.ttt-cell.win-cell { background: rgba(124,58,237,.25); border-color: var(--accent); }

/* Tournament bracket */
.ttt-tournament-info { margin-bottom: 16px; }
.ttt-tournament-badge { display: inline-block; background: rgba(124,58,237,.2); border: 1px solid var(--accent); color: var(--accent); font-size: 0.8rem; font-weight: 700; padding: 3px 12px; border-radius: 20px; margin-bottom: 8px; letter-spacing: .05em; }
.ttt-match-info { font-size: 0.95rem; font-weight: 600; color: var(--muted); margin-bottom: 12px; text-align: center; }
.ttt-bracket { display: flex; gap: 12px; overflow-x: auto; padding: 4px 0 12px; }
.bracket-round { display: flex; flex-direction: column; gap: 8px; min-width: 140px; flex-shrink: 0; }
.bracket-round-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; text-align: center; padding: 2px 0; font-weight: 700; }
.bracket-match { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.bracket-match.active { border-color: var(--accent); box-shadow: 0 0 8px rgba(124,58,237,.3); }
.bm-player { font-size: 0.8rem; font-weight: 600; padding: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-player.winner { color: var(--green); }
.bm-player.tbd { color: var(--muted); font-style: italic; font-weight: 400; }
.bm-you { font-size: 0.7rem; color: var(--accent2); }
.bm-vs { font-size: 0.7rem; color: var(--muted); text-align: center; padding: 2px 0; }

.ttt-match-label { text-align: center; font-size: 0.8rem; color: var(--accent2); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; padding: 4px 12px; background: rgba(14,165,233,.1); border-radius: 20px; display: inline-block; align-self: center; }
.ttt-result { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; text-align: center; }
#ttt-result-text { font-size: 1.3rem; font-weight: 700; margin-bottom: 20px; }
.ttt-result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.spectator-badge { background: rgba(100,116,139,.15); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px; font-size: 0.85rem; color: var(--muted); text-align: center; margin-top: 8px; }

/* ═══════════════════ KILLER DOCTOR ═══════════════════ */
#view-killerdoctor { background: var(--bg); }
.kd-layout { display: flex; height: 100%; }

.kd-sidebar {
  width: 240px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto;
}
.kd-role-card { background: var(--card); border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.role-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 4px; }
.role-character { font-size: 1.1rem; margin-bottom: 6px; color: var(--text); font-weight: 700; }
.role-name { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
.role-desc { font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; }
.kd-role-card[data-role="killer"] { border-color: var(--red); }
.kd-role-card[data-role="doctor"] { border-color: var(--green); }
.kd-role-card[data-role="villager"] { border-color: var(--border); }
.kd-role-card.hidden-role { border-color: var(--border) !important; }
.kd-role-card.hidden-role .role-name { color: var(--muted); }

.kd-you-status { text-align: center; font-size: 0.9rem; font-weight: 600; }
.kd-player-list-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.kd-player-list { flex: 1; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; min-height: 0; }
.kd-player-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 0.85rem; }
.kd-player-item.dead { opacity: .4; text-decoration: line-through; }
.kd-player-item .player-char-icon { font-size: 1.2rem; flex-shrink: 0; line-height: 1; }
.kd-player-item .player-name-wrap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.kd-player-item .you-tag { font-size: 0.7rem; color: var(--accent2); }

.kd-history-wrap { min-height: 0; }
.kd-history { display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--muted); overflow-y: auto; max-height: 160px; }
.history-item { padding: 4px 0; border-bottom: 1px solid var(--border); }

.kd-main { flex: 1; min-width: 0; overflow-y: auto; }
.kd-phase { display: none; flex-direction: column; height: 100%; overflow-y: auto; }
.kd-phase.active { display: flex; }

.night-bg { background: linear-gradient(180deg, #030307 0%, #0d0d1f 100%); flex: 1; display: flex; flex-direction: column; }
.night-splash { background: transparent; }

.kd-action-panel {
  margin: 0 auto; padding: 28px; max-width: 600px; width: 100%;
  background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: var(--radius);
  text-align: center; margin-top: 0; margin-bottom: 28px;
}
.action-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.action-desc { color: var(--muted); font-size: 0.9rem; margin-bottom: 20px; }
.target-grid { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.target-btn {
  background: var(--card); border: 2px solid var(--border); border-radius: 10px;
  padding: 14px 20px; color: var(--text); font-size: 0.9rem; font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; transition: all .15s; min-width: 90px;
}
.target-btn:hover { border-color: var(--accent); background: rgba(124,58,237,.15); transform: translateY(-2px); }
.target-btn.selected { border-color: var(--accent); background: rgba(124,58,237,.25); }
.target-char { font-size: 2rem; line-height: 1; }
.action-done { color: var(--green); font-weight: 700; font-size: 1rem; margin-top: 16px; }
.kd-villager-awake-btn { margin-top: 20px; padding: 14px 32px; font-size: 1.1rem; font-weight: 700; background: rgba(255,255,255,.08); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); cursor: pointer; }
.kd-villager-awake-btn:disabled { opacity: 0.5; cursor: default; color: var(--green); border-color: var(--green); }
.kd-night-progress { margin-top: 14px; font-size: 0.85rem; color: var(--muted); letter-spacing: .05em; }
.night-timer-wrap { text-align: center; padding: 16px; }
.countdown { font-size: 2rem; font-weight: 800; color: var(--yellow); }
.countdown.danger { color: var(--red); animation: blink .5s step-end infinite; }
@keyframes blink { 50% { opacity: .4; } }

.dawn-splash { background: linear-gradient(180deg, #1a0a00 0%, #0d0d14 100%); min-height: 100vh; }

/* Night victim display */
.night-victim-display { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 20px; border-radius: 12px; font-size: 1rem; font-weight: 600; }
.night-victim-display:empty { display: none; }
.night-victim-display .victim-char { font-size: 2rem; }
.night-victim-display.victim-dead { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; }
.night-victim-display.victim-saved { background: rgba(16,185,129,.15); border: 1px solid rgba(16,185,129,.4); color: #6ee7b7; }

/* ═══ Killer Doctor Night Animations ═══ */

/* Particle keyframes */
@keyframes kdFall {
  0%   { transform: translateY(-60px) rotate(0deg)   scale(1); opacity: 1; }
  85%  { opacity: 0.6; }
  100% { transform: translateY(105vh) rotate(540deg) scale(0.4); opacity: 0; }
}
@keyframes kdRise {
  0%   { transform: translateY(60px)  rotate(0deg)   scale(1); opacity: 1; }
  85%  { opacity: 0.6; }
  100% { transform: translateY(-105vh) rotate(-540deg) scale(0.4); opacity: 0; }
}
@keyframes kdMainDrop {
  0%   { transform: translateY(-100px) scale(0.3) rotate(-15deg); opacity: 0; }
  45%  { transform: translateY(0)      scale(1.3) rotate(5deg);   opacity: 1; }
  60%  { transform: translateY(0)      scale(1)   rotate(0deg);   opacity: 1; }
  100% { transform: translateY(0)      scale(1)   rotate(0deg);   opacity: 1; }
}
@keyframes kdTextSlide {
  0%   { opacity: 0; transform: translateY(20px) scale(0.9); }
  40%  { opacity: 1; transform: translateY(0)    scale(1); }
  100% { opacity: 1; transform: translateY(0)    scale(1); }
}
@keyframes kdPulse {
  0%,100% { box-shadow: 0 0 0   0px  currentColor; }
  50%      { box-shadow: 0 0 60px 20px currentColor; }
}

.kd-anim-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  pointer-events: none;
  backdrop-filter: blur(2px);
}
.kd-anim-main { display: flex; flex-direction: column; align-items: center; gap: 16px; z-index: 1; }
.kd-anim-icon {
  font-size: 8rem; line-height: 1;
  animation: kdMainDrop 0.6s cubic-bezier(.34,1.56,.64,1) both;
  filter: drop-shadow(0 0 20px rgba(255,255,255,0.4));
}
.kd-anim-text {
  font-size: 1.8rem; font-weight: 900; color: #fff;
  text-shadow: 0 3px 16px rgba(0,0,0,0.9), 0 1px 4px rgba(0,0,0,1);
  animation: kdTextSlide 0.5s ease 0.3s both;
  letter-spacing: -.01em;
}
.kd-particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.kd-particle { position: absolute; pointer-events: none; user-select: none; line-height: 1; }
.kd-particle-fall { top: -60px; animation: kdFall linear both; }
.kd-particle-rise { bottom: -60px; animation: kdRise linear both; }

/* Role card reveal flip */
@keyframes kdCardFlip {
  0%   { transform: perspective(700px) rotateY(-90deg) scale(0.85); opacity: 0; }
  55%  { transform: perspective(700px) rotateY(10deg)  scale(1.04); opacity: 1; }
  100% { transform: perspective(700px) rotateY(0deg)   scale(1);    opacity: 1; }
}
.kd-card-flip { animation: kdCardFlip 0.65s cubic-bezier(0.34,1.4,0.64,1) both; }

/* Vote drop particle */
@keyframes kdVoteFloat {
  0%   { transform: translateX(-50%) translateY(0)     scale(1);   opacity: 1; }
  100% { transform: translateX(-50%) translateY(-70px) scale(1.6); opacity: 0; }
}
.kd-vote-drop {
  position: fixed; font-size: 1.5rem; pointer-events: none; z-index: 9999;
  animation: kdVoteFloat 0.85s ease-out forwards;
}

/* Tension pulse on player list when 3 alive */
@keyframes kdTensionPulse {
  0%,100% { box-shadow: inset 0 0 0 1px rgba(239,68,68,0);    background: transparent; }
  50%      { box-shadow: inset 0 0 0 2px rgba(239,68,68,0.6); background: rgba(239,68,68,0.06); }
}
.kd-tension { border-radius: 10px; animation: kdTensionPulse 1.8s ease-in-out infinite; }

/* Timer urgency shake */
@keyframes kdTimerShake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-3px); }
  40%      { transform: translateX(3px); }
  60%      { transform: translateX(-2px); }
  80%      { transform: translateX(2px); }
}
.timer-display.danger { color: var(--red); animation: kdTimerShake 0.35s ease-in-out infinite; }
.countdown.danger { animation: blink 0.5s step-end infinite, kdTimerShake 0.35s ease-in-out infinite; }

/* KD phase slide-in */
@keyframes kdPhaseIn {
  from { opacity: 0; transform: translateX(22px); }
  to   { opacity: 1; transform: translateX(0); }
}
.kd-phase.active { animation: kdPhaseIn 0.3s ease both; }

/* Ambient night stars */
@keyframes kdAmbientDrift {
  0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
  8%   { opacity: 0.55; }
  90%  { opacity: 0.35; }
  100% { transform: translateY(-105vh) rotate(360deg); opacity: 0; }
}
.kd-ambient-star {
  position: fixed; bottom: -10px; font-size: 0.75rem; pointer-events: none;
  z-index: 1; animation: kdAmbientDrift linear forwards; user-select: none;
}

/* Action confirmation burst */
@keyframes kdBurstOut {
  0%   { transform: translate(-50%,-50%) translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(-50%,-50%) translate(var(--dx),var(--dy)) scale(0.4); opacity: 0; }
}
.kd-action-burst-particle {
  position: fixed; font-size: 1.3rem; pointer-events: none; z-index: 9999;
  animation: kdBurstOut 0.8s ease-out forwards;
}

/* Vote reveal stagger */
@keyframes kdVoteReveal {
  from { opacity: 0; transform: translateX(-16px) scale(0.92); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
.vote-reveal-stagger { opacity: 0; animation: kdVoteReveal 0.38s ease both; }

/* Killer spotlight */
@keyframes kdSpotlight {
  0%,100% { box-shadow: 0 0 0  0   rgba(239,68,68,0);   border-color: var(--border); }
  50%      { box-shadow: 0 0 28px 8px rgba(239,68,68,0.55); border-color: #ef4444; }
}
.kd-killer-spotlight { animation: kdSpotlight 1.2s ease-in-out 4; }

/* ═══ Tic Tac Toe animations ═══ */
@keyframes tttCellPop {
  0%   { transform: scale(0) rotate(-8deg); opacity: 0; }
  60%  { transform: scale(1.22) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.ttt-cell-pop { animation: tttCellPop 0.28s cubic-bezier(0.34,1.56,0.64,1) both; }

@keyframes tttWinGlow {
  0%,100% { box-shadow: 0 0 0  0   rgba(124,58,237,0.3); transform: scale(1); }
  50%      { box-shadow: 0 0 18px 6px rgba(124,58,237,0.55); transform: scale(1.07); }
}
.ttt-cell.win-cell { animation: tttWinGlow 0.75s ease-in-out infinite; }

@keyframes tttBoardShake {
  0%,100% { transform: translateX(0); }
  15%     { transform: translateX(-7px); }
  30%     { transform: translateX(7px); }
  45%     { transform: translateX(-5px); }
  60%     { transform: translateX(5px); }
  75%     { transform: translateX(-3px); }
  90%     { transform: translateX(3px); }
}
.ttt-shake { animation: tttBoardShake 0.5s ease both; }

@keyframes bracketSlideIn {
  from { opacity: 0; transform: translateX(35px); }
  to   { opacity: 1; transform: translateX(0); }
}
.bracket-round-slide { animation: bracketSlideIn 0.38s ease both; }

/* ═══ Scribble animations ═══ */
@keyframes scbGuessPop {
  0%   { transform: scale(0.5) translateY(10px); opacity: 0; }
  60%  { transform: scale(1.12) translateY(-4px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.scb-guess-pop { animation: scbGuessPop 0.45s cubic-bezier(0.34,1.56,0.64,1) both; }

@keyframes scbBurstOut {
  0%   { transform: translate(-50%,-50%) translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(-50%,-50%) translate(var(--dx),var(--dy)) scale(0.3); opacity: 0; }
}
.scb-burst-particle {
  position: fixed; font-size: 1.4rem; pointer-events: none; z-index: 9999;
  animation: scbBurstOut 0.9s ease-out forwards;
}

@keyframes scbLetterFlip {
  0%   { opacity: 0; transform: rotateX(-90deg) translateY(8px); }
  60%  { opacity: 1; transform: rotateX(8deg)   translateY(-2px); }
  100% { opacity: 1; transform: rotateX(0deg)   translateY(0); }
}
.scb-letter-flip {
  display: inline-block; animation: scbLetterFlip 0.35s ease both;
  transform-origin: bottom center;
}

@keyframes scbCanvasUrgent {
  0%,100% { box-shadow: 0 0 0  0   rgba(239,68,68,0); }
  50%      { box-shadow: 0 0 0 4px rgba(239,68,68,0.7); }
}
.scb-canvas-urgent { animation: scbCanvasUrgent 0.6s ease-in-out infinite; border-radius: 4px; }

/* ═══ Game countdown overlay ═══ */
.countdown-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
}
@keyframes countdownPop {
  0%   { transform: scale(0.4) rotate(-6deg); opacity: 0; }
  50%  { transform: scale(1.15) rotate(2deg); opacity: 1; }
  80%  { transform: scale(0.95) rotate(0deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.countdown-num {
  font-size: 9rem; font-weight: 900; color: #fff; line-height: 1;
  text-shadow: 0 4px 32px rgba(0,0,0,0.8);
  animation: countdownPop 0.45s cubic-bezier(0.34,1.56,0.64,1) both;
}
.countdown-num.go { font-size: 6rem; color: var(--accent2); }

/* ═══ Lobby card entrance ═══ */
@keyframes lobbyCardEnter {
  from { opacity: 0; transform: scale(0.82) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.lobby-card-enter { animation: lobbyCardEnter 0.28s ease both; }

/* ═══ Toast types ═══ */
.toast-warning { background: #92400e; border-left: 3px solid var(--yellow); }
.toast-success { background: #065f46; border-left: 3px solid #10b981; }
.toast-error   { background: #7f1d1d; border-left: 3px solid var(--red); }

.day-layout { padding: 24px; max-width: 700px; margin: 0 auto; width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; }
.day-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.timer-badge { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px; text-align: center; min-width: 80px; }
.timer-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.timer-display { font-size: 1.5rem; font-weight: 800; color: var(--accent2); font-family: monospace; }
.timer-display.danger { color: var(--red); }

.chat-box { display: flex; flex-direction: column; flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-height: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; max-height: 350px; min-height: 0; }
.chat-msg { display: flex; gap: 8px; }
.chat-msg .msg-name { font-weight: 700; font-size: 0.85rem; flex-shrink: 0; }
.chat-msg .msg-text { font-size: 0.9rem; color: var(--text); word-break: break-word; }
.chat-msg.system { color: var(--muted); font-size: 0.8rem; }
.chat-msg.correct .msg-text { color: var(--green); font-weight: 700; }
.chat-input-row { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); flex-shrink: 0; }
.chat-input-row input { flex: 1; }
.day-layout .chat-messages { max-height: none; }

.vote-progress-bar { background: var(--surface); border-radius: 6px; padding: 8px 12px; font-size: 0.875rem; color: var(--muted); }
.vote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 10px; }
.vote-btn {
  background: var(--card); border: 2px solid var(--border); border-radius: 10px;
  padding: 14px 12px; color: var(--text); font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px; transition: all .15s;
}
.vote-char { font-size: 2rem; line-height: 1; }
.vote-btn:hover:not(:disabled) { border-color: var(--red); background: rgba(239,68,68,.12); }
.vote-btn.voted { border-color: var(--red); background: rgba(239,68,68,.2); }
.vote-btn:disabled { opacity: .4; cursor: not-allowed; }
.voted-notice { color: var(--green); font-weight: 700; text-align: center; padding: 10px; }

.role-reveal-card { background: var(--card); border: 2px solid var(--border); border-radius: 14px; padding: 20px 28px; text-align: center; margin: 12px auto; max-width: 300px; }
.role-reveal-card.killer { border-color: var(--red); background: rgba(239,68,68,.1); }
.role-reveal-card.doctor { border-color: var(--green); background: rgba(16,185,129,.1); }
.role-reveal-card.villager { border-color: var(--border); }
.role-reveal-card .reveal-char { font-size: 2.5rem; margin-bottom: 4px; }
.role-reveal-card .reveal-role { font-size: 1.5rem; font-weight: 900; margin-bottom: 4px; }
.vote-detail { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.vote-detail-item { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 8px 16px; font-size: 0.875rem; }
.vote-detail-item .vote-count { font-weight: 800; color: var(--accent2); }

.final-player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 10px; margin: 12px 0; width: 100%; max-width: 640px; }
.final-player-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px; text-align: center; }
.final-player-card.dead { opacity: .6; }
.final-player-card .fp-char { font-size: 2rem; margin-bottom: 4px; }
.final-player-card .fp-name { font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
.final-player-card .fp-role { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.fp-role.killer { color: var(--red); }
.fp-role.doctor { color: var(--green); }
.fp-role.villager { color: var(--muted); }
.final-history { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; font-size: 0.85rem; color: var(--muted); text-align: left; max-width: 400px; width: 100%; }
.gameover-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }

.gameover-splash { background: radial-gradient(circle at 50% 40%, rgba(124,58,237,.25) 0%, transparent 70%), var(--bg); }
.night-splash { background: radial-gradient(circle at 50% 30%, rgba(100,100,200,.12) 0%, transparent 70%); }

/* ═══════════════════ SCRIBBLE ═══════════════════ */
#view-scribble { background: var(--bg); }
.scribble-layout { display: flex; height: 100vh; overflow: hidden; }
.scribble-sidebar { width: 180px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.scribble-round-info { font-size: 0.8rem; color: var(--muted); text-align: center; padding: 6px; background: var(--card); border-radius: 6px; font-weight: 600; }
.scb-player-list { display: flex; flex-direction: column; gap: 6px; }
.scb-player-item { display: flex; align-items: center; gap: 8px; padding: 8px 8px; background: var(--card); border-radius: 8px; border: 1px solid var(--border); }
.scb-player-item.drawing { border-color: var(--accent); background: rgba(124,58,237,.15); }
.scb-player-item.guessed { border-color: var(--green); }
.scb-player-item .scb-mini-av { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.scb-player-item .scb-pname { font-size: 0.8rem; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scb-player-item .scb-score { font-size: 0.8rem; color: var(--accent2); font-weight: 700; }

.scribble-center { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.scribble-top-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.scb-drawer-label { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.scb-word-display { flex: 1; text-align: center; font-size: 1.3rem; font-weight: 800; letter-spacing: .15em; font-family: monospace; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.scb-word-chooser { position: absolute; inset: 0; background: rgba(13,13,20,.92); z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; }
.scb-word-options { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.scb-word-opt { background: var(--card); border: 2px solid var(--border); border-radius: 12px; padding: 18px 32px; font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: all .15s; }
.scb-word-opt:hover { border-color: var(--accent); background: rgba(124,58,237,.2); transform: translateY(-3px); }

#scb-canvas { display: block; max-width: 100%; cursor: crosshair; background: #ffffff; flex: 1; object-fit: contain; }
#scb-canvas.not-drawing { cursor: default; }

.scb-tools { display: flex; align-items: center; gap: 14px; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--border); flex-wrap: wrap; }
.tool-group { display: flex; align-items: center; gap: 8px; }
.tool-btn { background: var(--card); border: 2px solid var(--border); border-radius: 8px; width: 38px; height: 38px; font-size: 1.1rem; padding: 0; display: flex; align-items: center; justify-content: center; }
.tool-btn.active { border-color: var(--accent); background: rgba(124,58,237,.2); }
.tool-btn:hover:not(.active) { border-color: var(--muted); }
.color-swatch-wrap input[type="color"] { width: 38px; height: 38px; padding: 2px; border-radius: 8px; cursor: pointer; border: 2px solid var(--border); }
.color-presets { display: flex; gap: 4px; flex-wrap: wrap; max-width: 140px; }
.color-dot { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform .1s; }
.color-dot:hover { transform: scale(1.2); }
.color-dot.active { border-color: #fff; }
#scb-size { width: 80px; }
#scb-size-label { font-size: 0.8rem; color: var(--muted); width: 30px; }

.scribble-chat { width: 220px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.scribble-chat .chat-messages { flex: 1; max-height: none; }
.scribble-chat .chat-input-row { flex-shrink: 0; }
.scribble-chat .chat-input-row input { font-size: 0.85rem; padding: 8px 10px; }
.scribble-chat .btn-primary { padding: 8px 12px; font-size: 0.85rem; }

.scb-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.8); z-index: 100; display: flex; align-items: center; justify-content: center; }
.overlay-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 36px; text-align: center; max-width: 500px; width: 90%; }
.overlay-card h2 { margin-bottom: 12px; }
#scb-overlay-word strong { color: var(--yellow); font-size: 1.2rem; }
.overlay-scores { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; text-align: left; }
.overlay-score-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-radius: 8px; }
.overlay-score-item .osi-rank { width: 24px; font-weight: 800; color: var(--muted); }
.overlay-score-item .osi-name { flex: 1; font-weight: 600; }
.overlay-score-item .osi-pts { font-weight: 800; color: var(--accent2); }
.overlay-score-item.rank-1 .osi-rank { color: var(--yellow); }
.overlay-score-item.rank-2 .osi-rank { color: var(--muted); }

.scb-overlay-banner { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); background: var(--green); color: #fff; font-weight: 700; padding: 10px 24px; border-radius: 24px; z-index: 50; font-size: 1rem; animation: popBanner .3s ease; }
@keyframes popBanner { from { transform: translateX(-50%) scale(.8); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }

/* Game views fill viewport directly — override default flex-column */
#view-killerdoctor.active, #view-scribble.active { display: block; min-height: 0; }
#view-killerdoctor.active { height: 100vh; overflow: hidden; }
#view-scribble.active { height: 100vh; overflow: hidden; }
.scribble-center { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
#scb-canvas { flex: 1; display: block; width: 100%; height: auto; min-height: 0; background: #ffffff; }

/* ═══════════════════ HOME RULES BUTTON ═══════════════════ */
.btn-rules-link {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 8px; font-size: 0.85rem; padding: 8px 16px; margin-bottom: 8px;
  cursor: pointer; display: block; width: 100%; text-align: center;
  transition: border-color .15s, color .15s;
}
.btn-rules-link:hover { border-color: var(--accent); color: var(--accent); }

/* ═══════════════════ LOBBY SETTINGS ═══════════════════ */
.lobby-header-actions { display: flex; gap: 10px; align-items: center; }
.settings-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.settings-toggle { width: 100%; background: transparent; color: var(--text); border: none; border-radius: 0; padding: 14px 18px; text-align: left; display: flex; justify-content: space-between; align-items: center; font-size: 0.95rem; font-weight: 600; cursor: pointer; }
.settings-toggle:hover { background: rgba(255,255,255,.04); }
.settings-chevron { font-size: 1.1rem; transition: transform .2s; display: inline-block; }
.settings-chevron.open { transform: rotate(180deg); }
.settings-body { padding: 16px 18px 18px; border-top: 1px solid var(--border); }
.settings-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 14px; margin-bottom: 14px; }
.settings-field { display: flex; flex-direction: column; gap: 6px; }
.settings-field label { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.settings-field select { background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 9px 12px; font-size: 0.9rem; outline: none; cursor: pointer; }
.settings-field select:focus { border-color: var(--accent); }
.settings-field select:disabled { opacity: .6; cursor: default; }
.settings-field .settings-val { font-size: 0.9rem; color: var(--text); padding: 9px 0; }
.settings-host-actions { display: flex; align-items: center; gap: 12px; }
.settings-saved { color: var(--green); font-size: 0.875rem; font-weight: 600; }
.time-setting-wrap { display: flex; flex-direction: column; gap: 6px; }
.custom-time-input { background: var(--card); border: 1px solid var(--accent); color: var(--text); border-radius: 8px; padding: 8px 12px; font-size: 0.9rem; outline: none; width: 100%; }
.custom-time-input:focus { border-color: var(--accent2); }
.custom-time-input::placeholder { color: var(--muted); }

/* ═══════════════════ RULES MODAL ═══════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(4px); }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  width: 100%; max-width: 680px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 24px 64px rgba(0,0,0,.6); overflow: hidden; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-header h2 { font-size: 1.3rem; }
.modal-close { font-size: 1.1rem; }
.rules-game-tabs { display: flex; gap: 2px; padding: 12px 16px 0; border-bottom: 1px solid var(--border); flex-shrink: 0; overflow-x: auto; }
.rules-tab { background: transparent; color: var(--muted); border: none; border-radius: 0; padding: 8px 14px; font-size: 0.9rem; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.rules-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.rules-tab:hover:not(.active) { color: var(--text); }
.rules-content { display: none; overflow-y: auto; padding: 24px; flex: 1; }
.rules-content.active { display: block; }
.rules-intro { color: var(--muted); font-size: 1rem; margin-bottom: 20px; line-height: 1.6; }
.rules-content h3 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 10px; }
.rules-content p { font-size: 0.95rem; line-height: 1.6; margin-bottom: 12px; color: var(--text); }

/* Role cards */
.rules-role-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.rules-role-card { flex: 1; min-width: 160px; background: var(--card); border: 2px solid var(--border); border-radius: 12px; padding: 16px; text-align: center; }
.rules-role-card.killer { border-color: var(--red); background: rgba(239,68,68,.07); }
.rules-role-card.doctor { border-color: var(--green); background: rgba(16,185,129,.07); }
.rules-role-card.villager { border-color: var(--border); }
.rules-role-icon { font-size: 2rem; margin-bottom: 6px; }
.rules-role-name { font-weight: 800; font-size: 1rem; margin-bottom: 6px; }
.rules-role-desc { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }

/* Steps */
.rules-steps { display: flex; flex-direction: column; gap: 10px; }
.rules-step { display: flex; gap: 12px; align-items: flex-start; }
.step-num { background: var(--accent); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 800; flex-shrink: 0; margin-top: 2px; }
.rules-step > div { font-size: 0.9rem; line-height: 1.6; color: var(--text); flex: 1; }
.rules-step strong { color: var(--text); }

/* Win cards */
.rules-wins { display: flex; gap: 10px; flex-wrap: wrap; }
.rules-win-card { flex: 1; min-width: 200px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 0.875rem; line-height: 1.5; display: flex; gap: 10px; align-items: flex-start; }
.win-icon { font-size: 1.3rem; flex-shrink: 0; }

/* Tools grid */
.rules-tools-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rules-tool { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; display: flex; gap: 10px; align-items: flex-start; font-size: 0.875rem; }
.rules-tool span { font-size: 1.3rem; flex-shrink: 0; }
.rules-tool strong { display: block; margin-bottom: 2px; }

/* Tip box */
.rules-tip { background: rgba(14,165,233,.1); border: 1px solid rgba(14,165,233,.3); border-radius: 8px; padding: 10px 14px; font-size: 0.875rem; margin-top: 16px; color: var(--text); line-height: 1.5; }

/* Color helpers */
.x-col { color: #60a5fa; }
.o-col { color: #f472b6; }

/* ═══════════════════ HOST CONTROLS ═══════════════════ */
.lobby-player-card { position: relative; }
.host-controls { display: flex; gap: 4px; justify-content: center; margin-top: 6px; opacity: 0; transition: opacity 0.2s; }
.lobby-player-card:hover .host-controls { opacity: 1; }
.btn-host-ctrl {
  border: none; cursor: pointer; border-radius: 6px; padding: 3px 7px;
  font-size: 0.85rem; background: rgba(255,255,255,0.08); color: var(--text);
  transition: background 0.15s, transform 0.1s;
}
.btn-host-ctrl:hover { background: rgba(255,255,255,0.18); transform: scale(1.1); }
.btn-kick-ctrl:hover { background: rgba(239,68,68,0.25); }

/* ═══════════════════ IN-GAME KICK BUTTONS ═══════════════════ */
.kd-kick-btn, .scb-kick-btn {
  font-size: 0.7rem; padding: 1px 5px; flex-shrink: 0; opacity: 0.45;
  transition: opacity .15s, background .15s;
}
.kd-kick-btn:hover, .scb-kick-btn:hover { opacity: 1; }
.ttt-kick-btn {
  font-size: 0.72rem; padding: 2px 8px; margin-top: 6px;
  display: block; width: 100%; opacity: 0.45;
  transition: opacity .15s, background .15s;
}
.ttt-kick-btn:hover { opacity: 1; }

/* ═══════════════════ SESSION STATS ═══════════════════ */
.session-stats {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin: 0 0 12px;
}
.session-stats-header {
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); margin-bottom: 10px;
}
.stats-body { display: flex; flex-direction: column; gap: 6px; }
.stats-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.9rem; padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.stats-row:last-child { border-bottom: none; }
.stats-rank { font-size: 1.1rem; width: 24px; flex-shrink: 0; text-align: center; }
.stats-name { flex: 1; font-weight: 500; }
.stats-record { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

/* ═══════════════════ CONFIRM MODAL ═══════════════════ */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  animation: confirmFadeIn 0.15s ease;
}
@keyframes confirmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.confirm-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px 28px;
  min-width: 280px; max-width: 360px; width: 90%;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  animation: confirmPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes confirmPop {
  from { transform: scale(0.82); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
.confirm-msg { font-size: 1rem; line-height: 1.55; margin-bottom: 22px; color: var(--text); }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ═══════════════════ RESPONSIVE ═══════════════════ */
@media (max-width: 800px) {
  .kd-sidebar { width: 200px; }
  .scribble-layout { flex-direction: column; }
  .scribble-sidebar { width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; }
  .scb-player-list { flex-direction: row; flex-wrap: wrap; }
  .scribble-chat { width: 100%; height: 220px; border-left: none; border-top: 1px solid var(--border); }
  .avatar-modal .avatar-grid { grid-template-columns: repeat(8, 1fr); }
}

@media (max-width: 600px) {
  /* Home */
  #view-home { padding: 20px 14px 36px; }
  .home-header { margin-bottom: 20px; }
  .logo { font-size: 2rem; }
  .tagline { font-size: 0.9rem; }
  .game-selector { margin-bottom: 20px; }
  .game-selector h2 { margin-bottom: 12px; font-size: 0.85rem; }
  .game-cards { flex-direction: column; align-items: stretch; gap: 10px; }
  .game-card { width: 100%; padding: 14px 16px; }
  .game-icon { font-size: 1.6rem; margin-bottom: 6px; }
  .game-card h3 { font-size: 0.95rem; margin-bottom: 2px; }
  .game-card p { font-size: 0.75rem; margin-bottom: 6px; }
  .join-box { padding: 16px; border-radius: 12px; }

  /* Avatar modal */
  .avatar-modal .avatar-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .avatar-modal .avatar-opt { font-size: 1.5rem; padding: 8px; }
  .avatar-modal-box { padding: 14px; max-height: 90vh; }

  /* Lobby */
  .lobby-container { padding: 20px 14px; }
  .lobby-header { margin-bottom: 18px; }
  .lobby-header h2 { font-size: 1.3rem; }

  /* KD layout */
  .kd-layout { flex-direction: column; }
  .kd-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; flex-wrap: wrap; gap: 8px; max-height: 160px; padding: 10px 12px; overflow: hidden; flex-shrink: 0; }
  .kd-role-card { padding: 8px 10px; }
  .kd-player-list-wrap { min-width: 0; min-height: 0; }
  .kd-player-list { max-height: 80px; }
  .kd-history-wrap { display: none; }
  .day-layout { padding: 12px; gap: 10px; }

  /* TicTacToe */
  .ttt-container { padding: 20px 14px; }
  .ttt-cell { font-size: 2.2rem; }
  .ttt-score-card { padding: 10px; }
  .score-pts { font-size: 1.3rem; }

  /* Phase splash */
  .phase-splash { padding: 36px 16px; gap: 10px; min-height: 300px; }
  .phase-icon { font-size: 3rem; }
  .phase-splash h2 { font-size: 1.5rem; }

  /* Countdown */
  .countdown-num { font-size: 6rem; }

  /* Toast */
  #toast-container { bottom: 12px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }
}

/* ═══════════════════ UNO ═══════════════════ */

#view-uno { background: radial-gradient(ellipse at 50% -10%, rgba(124,58,237,.18) 0%, transparent 60%), var(--bg); }

.uno-layout {
  display: flex; flex-direction: column; height: 100%;
  min-height: 100vh; user-select: none;
}

/* ── Player identity chip (shared: UNO + Quiz) ── */
.player-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 12px 4px 4px;
  flex-shrink: 0;
}
.chip-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; line-height: 1;
}
.chip-name {
  font-size: 0.85rem; font-weight: 600; color: var(--text); white-space: nowrap;
}

.uno-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.uno-header h2 { font-size: 1.2rem; }

/* Opponents */
.uno-opponents {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px;
  justify-content: center; flex-shrink: 0;
}
.uno-opponent {
  background: var(--card); border: 2px solid var(--border); border-radius: 10px;
  padding: 8px 12px; min-width: 90px; text-align: center; transition: border-color .2s, box-shadow .2s;
}
.uno-opponent.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,58,237,.3); }
.uno-opp-name { font-size: 0.78rem; font-weight: 700; margin-bottom: 5px; }
.uno-opp-cards { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; min-height: 20px; margin-bottom: 3px; }
.uno-mini-card { width: 10px; height: 16px; background: var(--border); border-radius: 2px; flex-shrink: 0; }
.uno-mini-more { font-size: 0.65rem; color: var(--muted); align-self: center; }
.uno-opp-count { font-size: 0.7rem; color: var(--muted); }
.uno-uno-badge {
  display: inline-block; background: var(--red); color: #fff;
  font-size: 0.6rem; font-weight: 800; padding: 1px 5px; border-radius: 4px;
  margin-left: 4px; vertical-align: middle; letter-spacing: .04em;
}

/* Game area */
.uno-game-area {
  display: flex; align-items: center; justify-content: center;
  gap: 36px; padding: 16px 20px; flex-shrink: 0;
}
.uno-pile-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.uno-area-label { font-size: 0.75rem; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.uno-color-row { display: flex; align-items: center; gap: 5px; }

/* UNO Cards */
.uno-card {
  width: 54px; height: 82px; border-radius: 8px;
  border: 2px solid rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 900; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.6);
  flex-shrink: 0; transition: all .15s; cursor: default;
  letter-spacing: -.01em;
}
.uno-card.val-text { font-size: 0.75rem; letter-spacing: .02em; }
.uno-card-big { width: 76px; height: 114px; border-radius: 12px; font-size: 1.6rem; border-width: 3px; }
.uno-card-big.val-text { font-size: 1rem; }

.card-back {
  background: repeating-linear-gradient(45deg, #1e1e36, #1e1e36 5px, #2a2a4a 5px, #2a2a4a 10px);
  font-size: 0.75rem; color: var(--muted); cursor: pointer;
}
.card-back.deck-drawable { cursor: pointer; box-shadow: 0 0 0 2px var(--accent2), 0 0 10px rgba(14,165,233,.3); }
.card-back.deck-drawable:hover { transform: translateY(-4px); }

.card-red    { background: #dc2626; }
.card-yellow { background: #d97706; }
.card-green  { background: #16a34a; }
.card-blue   { background: #2563eb; }
.card-wild   {
  background: conic-gradient(#dc2626 0deg 90deg, #d97706 90deg 180deg, #16a34a 180deg 270deg, #2563eb 270deg 360deg);
  border-color: rgba(255,255,255,.4);
}

.uno-card.playable {
  cursor: pointer;
  box-shadow: 0 0 0 2px #fff, 0 0 14px rgba(255,255,255,.35);
  transform: translateY(-5px);
}
.uno-card.playable:hover {
  transform: translateY(-10px);
  box-shadow: 0 0 0 3px #fff, 0 0 22px rgba(255,255,255,.5);
}
.uno-card.just-drawn {
  box-shadow: 0 0 0 2px var(--green), 0 0 12px rgba(16,185,129,.4);
}
.uno-card.dimmed { opacity: .55; }

/* Color indicator dot */
.uno-color-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.25); flex-shrink: 0;
}
.dot-red    { background: #dc2626; }
.dot-yellow { background: #d97706; }
.dot-green  { background: #16a34a; }
.dot-blue   { background: #2563eb; }

/* Status */
.uno-status {
  text-align: center; font-size: 0.95rem; font-weight: 700;
  padding: 4px 16px; min-height: 28px; flex-shrink: 0;
}

/* Hand section */
.uno-hand-section {
  flex: 1; display: flex; flex-direction: column;
  background: rgba(30,30,54,.5); border-top: 1px solid var(--border);
  padding: 10px 14px 16px; min-height: 0;
}
.uno-hand {
  display: flex; gap: 6px; overflow-x: auto; padding: 6px 2px 10px;
  flex: 1; align-items: flex-end; min-height: 90px;
}
.uno-action-bar {
  display: flex; gap: 10px; justify-content: center; margin-top: 6px; flex-shrink: 0;
}

/* Color chooser overlay */
.uno-overlay-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  backdrop-filter: blur(3px);
}
.uno-overlay-modal.hidden { display: none !important; }

.uno-modal-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.uno-modal-box h3 { margin-bottom: 20px; font-size: 1.1rem; }

.uno-color-grid { display: flex; gap: 12px; }
.uno-color-btn {
  width: 72px; height: 72px; border-radius: 12px; border: 3px solid transparent;
  font-weight: 800; font-size: 0.85rem; color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,.5); transition: all .15s; cursor: pointer;
}
.uno-color-btn:hover { border-color: #fff; transform: scale(1.1); }
.uno-cb-red    { background: #dc2626; }
.uno-cb-yellow { background: #d97706; }
.uno-cb-green  { background: #16a34a; }
.uno-cb-blue   { background: #2563eb; }

/* Game over */
.uno-gameover-box { max-width: 420px; width: 92%; }
.uno-gameover-scores { margin: 18px 0; display: flex; flex-direction: column; gap: 6px; }
.uno-score-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px; background: var(--surface);
}
.uno-score-row.winner { background: rgba(124,58,237,.2); border: 1px solid var(--accent); }
.uno-score-rank { width: 28px; text-align: center; font-size: 1rem; }
.uno-score-name { flex: 1; font-weight: 600; font-size: 0.9rem; text-align: left; }
.uno-score-val { color: var(--accent2); font-weight: 700; font-size: 0.85rem; }

@media (max-width: 600px) {
  .uno-game-area { gap: 20px; padding: 12px; }
  .uno-card-big { width: 64px; height: 96px; font-size: 1.3rem; }
  .uno-card-big.val-text { font-size: 0.85rem; }
  .uno-card { width: 48px; height: 72px; font-size: 1rem; }
  .uno-color-grid { gap: 8px; }
  .uno-color-btn { width: 60px; height: 60px; }
}

@media (max-width: 390px) {
  .join-box { padding: 12px; }
  .avatar-modal .avatar-grid { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .avatar-modal .avatar-opt { font-size: 1.3rem; padding: 6px; }
  .ttt-cell { font-size: 1.8rem; }
  .ttt-scoreboard { gap: 8px; }
  .ttt-score-card { padding: 8px; }
}

/* ═══════════════════ QUIZ ═══════════════════ */

@keyframes quizQIn {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes quizOptIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes deltaPop {
  0%   { opacity: 0; transform: scale(0.7) translateY(8px); }
  60%  { opacity: 1; transform: scale(1.1) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes rowSlideIn {
  from { opacity: 0; transform: translateX(-18px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes correctPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,.6); }
  50%     { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
}
@keyframes wrongShake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

.quiz-layout {
  display: flex; flex-direction: row;
  min-height: 100vh; width: 100%;
}

/* ── Quiz sidebar ── */
.quiz-sidebar {
  width: 210px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 16px 14px; display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto;
}

.quiz-sidebar-section { display: flex; flex-direction: column; gap: 6px; }

.quiz-sidebar-title {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted);
}

.quiz-sidebar-list { display: flex; flex-direction: column; gap: 3px; }

.quiz-sidebar-row {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 7px; border-radius: 8px;
}
.quiz-sidebar-row.sidebar-me {
  background: rgba(124,58,237,.18); border: 1px solid rgba(124,58,237,.3);
}

.quiz-sidebar-rank  { width: 18px; text-align: center; font-size: 0.75rem; color: var(--muted); font-weight: 700; flex-shrink: 0; }
.quiz-sidebar-avatar { font-size: 1rem; width: 22px; text-align: center; flex-shrink: 0; }
.quiz-sidebar-name  { flex: 1; font-size: 0.78rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiz-sidebar-score { font-size: 0.78rem; color: var(--accent2); font-weight: 700; flex-shrink: 0; }
.quiz-sidebar-delta { font-size: 0.72rem; color: var(--green); font-weight: 700; flex-shrink: 0; }

/* ── Quiz content column ── */
.quiz-content {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: 16px 20px 24px; overflow-y: auto; min-width: 0;
}

.quiz-header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

.quiz-progress {
  display: flex; align-items: center; gap: 8px; flex: 1;
}

#quiz-q-num {
  font-weight: 700; font-size: 0.95rem; color: var(--muted);
}

.quiz-diff-badge {
  font-size: 0.75rem; font-weight: 700; padding: 2px 10px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.04em;
}
.diff-easy   { background: rgba(16,185,129,.2);  color: var(--green); }
.diff-medium { background: rgba(249,115,22,.2);  color: var(--orange); }
.diff-hard   { background: rgba(239,68,68,.2);   color: var(--red); }

.quiz-timer-wrap {
  display: flex; align-items: center; gap: 8px;
}

.quiz-timer-track {
  width: 120px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}

.quiz-timer-bar {
  height: 100%; background: var(--accent2); border-radius: 3px;
  transition: width 0.1s linear, background 0.3s;
  width: 100%;
}
.quiz-timer-bar.timer-bar-danger { background: var(--red); }

.quiz-timer-num {
  font-weight: 800; font-size: 1.1rem; color: var(--accent2);
  min-width: 24px; text-align: right;
  transition: color 0.2s;
}
.quiz-timer-num.timer-danger { color: var(--red); }

/* ── centred question + options ── */
.quiz-main {
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; width: 100%;
}

.quiz-question {
  font-size: 1.3rem; font-weight: 700; line-height: 1.45;
  text-align: center; padding: 20px 8px;
  min-height: 90px; display: flex; align-items: center; justify-content: center;
  width: 100%;
}
.quiz-question.quiz-q-in {
  animation: quizQIn 0.35s cubic-bezier(.22,1,.36,1) both;
}

.quiz-answer-status {
  text-align: center; font-size: 0.85rem; color: var(--muted); min-height: 20px;
}
.quiz-answer-status.waiting { color: var(--accent2); }

.quiz-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  width: 100%;
}

.quiz-opt {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  background: var(--card); border: 2px solid var(--border);
  cursor: pointer; transition: all .15s; text-align: left;
  min-height: 64px; line-height: 1.3;
}
.quiz-opt:hover:not(:disabled) {
  border-color: var(--accent); background: rgba(124,58,237,.12);
  transform: translateY(-2px);
}
.quiz-opt:disabled { cursor: default; }

.quiz-opt.quiz-opt-in {
  animation: quizOptIn 0.4s cubic-bezier(.22,1,.36,1) both;
}

.quiz-opt-letter {
  flex-shrink: 0; width: 28px; height: 28px;
  border-radius: 50%; background: var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 800; color: var(--muted);
  transition: background .15s, color .15s;
}
.quiz-opt-text { flex: 1; }

.quiz-opt.opt-correct {
  border-color: var(--green); background: rgba(16,185,129,.15);
  animation: correctPulse 0.6s ease-out;
}
.quiz-opt.opt-correct .quiz-opt-letter { background: var(--green); color: #fff; }

.quiz-opt.opt-wrong {
  border-color: var(--red); background: rgba(239,68,68,.12);
  animation: wrongShake 0.4s ease-out;
}
.quiz-opt.opt-wrong .quiz-opt-letter { background: var(--red); color: #fff; }

.quiz-opt.opt-dimmed { opacity: 0.35; }

.quiz-opt.opt-selected {
  border-color: var(--accent2); background: rgba(14,165,233,.12);
}
.quiz-opt.opt-selected .quiz-opt-letter { background: var(--accent2); color: #fff; }

.quiz-first-badge {
  position: absolute; top: -8px; right: 8px;
  background: #f59e0b; color: #000;
  font-size: 0.7rem; font-weight: 800;
  padding: 2px 8px; border-radius: 20px;
}

.quiz-score-delta {
  text-align: center; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em;
  padding: 6px 0;
}
.quiz-score-delta.delta-pop { animation: deltaPop 0.45s cubic-bezier(.22,1,.36,1) both; }
.delta-correct { color: var(--green); }
.delta-wrong   { color: var(--red); }
.delta-timeout { color: var(--muted); }


.quiz-score-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  transition: background .15s;
}
.quiz-score-row:not(:last-child) { margin-bottom: 4px; }
.quiz-score-row.quiz-score-me { background: rgba(124,58,237,.18); border: 1px solid rgba(124,58,237,.35); }
.quiz-score-row.score-row-in { animation: rowSlideIn 0.35s cubic-bezier(.22,1,.36,1) both; }

.quiz-rank { width: 28px; text-align: center; font-size: 0.9rem; color: var(--muted); font-weight: 700; }
.quiz-player-name { flex: 1; font-weight: 600; font-size: 0.9rem; }
.quiz-pts-gained { color: var(--green); font-weight: 700; font-size: 0.85rem; min-width: 56px; text-align: right; }
.quiz-pts-miss { color: var(--muted); font-size: 0.85rem; min-width: 56px; text-align: right; }
.quiz-total-score { color: var(--accent2); font-weight: 700; font-size: 0.9rem; min-width: 56px; text-align: right; }
.quiz-pts-label { font-size: 0.7rem; font-weight: 500; color: var(--muted); }
.quiz-correct-count { font-size: 0.8rem; color: var(--muted); min-width: 36px; text-align: right; }

.quiz-gameover-box { max-width: 460px; width: 92%; }
.quiz-gameover-scores { margin: 18px 0; display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 700px) {
  .quiz-layout { flex-direction: column; }
  .quiz-sidebar {
    width: 100%; border-right: none; border-bottom: 1px solid var(--border);
    flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 12px; overflow-x: auto; flex-wrap: nowrap;
  }
  .quiz-sidebar-section { flex-direction: row; align-items: center; gap: 10px; flex-shrink: 0; }
  .quiz-sidebar-title { display: none; }
  .quiz-sidebar-list { flex-direction: row; gap: 6px; }
  .quiz-sidebar-row { padding: 4px 8px; }
  .quiz-content { padding: 12px 14px 20px; }
}

@media (max-width: 480px) {
  .quiz-options { grid-template-columns: 1fr; }
  .quiz-opt { min-height: 52px; padding: 12px 12px; }
  .quiz-question { font-size: 1.1rem; padding: 14px 4px; }
  .quiz-timer-track { width: 80px; }
}
