:root {
  --bg: #FAF6F0;
  --bg-subtle: #F2EBE0;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #FFFFFF;
  --surface-hover: #FFFDF9;
  --border: rgba(45, 35, 25, 0.10);
  --border-strong: rgba(45, 35, 25, 0.18);
  --text: #1F1D1A;
  --text-muted: #6E655A;
  --primary: #FF5A5F;
  --primary-hover: #E8484D;
  --primary-soft: rgba(255, 90, 95, 0.12);
  --secondary: #3B6EF6;
  --secondary-soft: rgba(59, 110, 246, 0.12);
  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.14);
  --amber: #F59E0B;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --shadow-sm: 0 2px 8px rgba(35, 25, 15, 0.05);
  --shadow-md: 0 10px 30px rgba(35, 25, 15, 0.08);
  --shadow-lg: 0 20px 50px rgba(35, 25, 15, 0.14);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --font: "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #13151D;
  --bg-subtle: #1B1E2A;
  --surface: rgba(28, 32, 46, 0.86);
  --surface-solid: #1E2230;
  --surface-hover: #252A3B;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #F4F5F7;
  --text-muted: #9CA3AF;
  --primary: #FF6B70;
  --primary-hover: #FF5258;
  --primary-soft: rgba(255, 107, 112, 0.16);
  --secondary: #5B8AF9;
  --secondary-soft: rgba(91, 138, 249, 0.18);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.50);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.25s ease, color 0.25s ease;
}

/* Ambient paint blobs */
.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.32;
}
[data-theme="dark"] .blob { opacity: 0.18; }
.blob-1 { width: 460px; height: 460px; background: #FF8A7A; top: -140px; left: -100px; }
.blob-2 { width: 520px; height: 520px; background: #FCD34D; bottom: -180px; right: -120px; }
.blob-3 { width: 380px; height: 380px; background: #60A5FA; top: 40%; left: 55%; }

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 900;
}

/* Views */
.view {
  position: relative;
  z-index: 1;
  display: none;
  min-height: 100vh;
}
.view.active {
  display: flex;
  flex-direction: column;
}
.hidden { display: none !important; }

/* Cards & Buttons */
.card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.card-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.muted-sm {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.18s ease, background 0.18s ease;
  padding: 10px 18px;
  font-size: 0.94rem;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #FF7A59);
  color: #fff;
  box-shadow: 0 6px 18px rgba(255, 90, 95, 0.30);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(255, 90, 95, 0.38);
}

.btn-secondary {
  background: var(--secondary-soft);
  color: var(--secondary);
  border: 1px solid rgba(59, 110, 246, 0.22);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--secondary);
  color: #fff;
}

.btn-outline-sm {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 7px 13px;
  font-size: 0.84rem;
  border-radius: 10px;
}
.btn-outline-sm:hover { background: var(--bg-subtle); }

.btn-ghost-sm {
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-ghost-sm:hover { background: var(--border); }

.btn-lg { padding: 12px 22px; font-size: 0.98rem; }
.btn-xl { padding: 14px 28px; font-size: 1.05rem; width: 100%; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 1.05rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, background 0.15s ease;
}
.icon-btn:hover { background: var(--bg-subtle); transform: translateY(-1px); }

/* Inputs */
input[type="text"], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--text);
  font-family: inherit;
  font-size: 0.94rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
input[type="text"]:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ==================== HOME VIEW ==================== */
.home-header {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 24px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-logo {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  filter: drop-shadow(0 6px 14px rgba(255, 90, 95, 0.28));
}
.brand-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.brand-sub {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.conn-badge {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 99px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.round-pill.guess-progress {
  background: var(--success-soft);
  color: #047857;
}
[data-theme="dark"] .round-pill.guess-progress { color: #34D399; }
.act-btn.accent {
  border-color: rgba(245, 158, 11, 0.45);
  background: var(--amber-soft);
  color: #B45309;
}
[data-theme="dark"] .act-btn.accent { color: #FBBF24; }
.act-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.home-grid {
  max-width: 1180px;
  width: 100%;
  margin: 12px auto 32px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: start;
}

.profile-card, .rooms-card { padding: 24px; }

.avatar-studio {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 22px;
  align-items: center;
}
.avatar-preview-lg {
  width: 148px;
  height: 148px;
  border-radius: 28px;
  background: var(--bg-subtle);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1);
}
.avatar-preview-lg:hover { transform: scale(1.04) rotate(-2deg); }
.avatar-preview-lg svg { width: 120px; height: 120px; }

.avatar-controls { display: flex; flex-direction: column; gap: 11px; }
.control-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 5px 10px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}
.chip:hover { border-color: var(--primary); }
.chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}
.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.14s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.12);
}
.swatch:hover { transform: scale(1.15); }
.swatch.active {
  border-color: var(--text);
  transform: scale(1.18);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0 18px;
}

.entry-tabs {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 13px;
  margin-bottom: 16px;
}
.entry-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.entry-tab.active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.cta-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
}
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 800;
  text-align: center;
}

/* Public Rooms */
.public-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 260px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}
.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-radius: 14px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  transition: transform 0.14s ease, border-color 0.15s ease;
}
.room-item:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.room-item-title {
  font-weight: 700;
  font-size: 0.96rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.room-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.status-dot.playing { background: var(--amber); }

.empty-state {
  margin: auto;
  text-align: center;
  padding: 36px 12px;
  color: var(--text-muted);
}
.empty-icon { font-size: 2.4rem; margin-bottom: 8px; }
.empty-state p { margin: 0 0 4px; font-weight: 700; color: var(--text); }
.empty-state span { font-size: 0.84rem; }

.feature-highlights {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.highlight-pill {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 7px 10px;
  border-radius: 10px;
}

/* ==================== ROOM LOBBY VIEW ==================== */
.topbar {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 24px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.room-badge-group { display: flex; align-items: center; gap: 10px; }
.room-title-sm { font-weight: 800; font-size: 1.1rem; }
.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1.5px dashed var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-family: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.code-chip.sm { padding: 4px 10px; font-size: 0.82rem; }
.copy-tag {
  font-size: 0.72rem;
  letter-spacing: 0;
  background: var(--primary);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
}

.lobby-grid {
  max-width: 1120px;
  width: 100%;
  margin: 12px auto 32px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}
.lobby-players-card, .lobby-settings-card { padding: 24px; }
.count-pill {
  font-size: 0.82rem;
  background: var(--bg-subtle);
  padding: 2px 9px;
  border-radius: 99px;
  margin-left: 6px;
}
.badge-soft {
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--secondary-soft);
  color: var(--secondary);
  padding: 4px 10px;
  border-radius: 99px;
}

.lobby-players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  min-height: 220px;
}
.lobby-player-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px 14px;
  border-radius: 16px;
  background: var(--surface-solid);
  border: 1.5px solid var(--border);
  text-align: center;
  animation: popIn 0.22s ease;
}
.lobby-player-tile.is-me { border-color: var(--primary); }
.lobby-player-tile .av-wrap { width: 62px; height: 62px; margin-bottom: 8px; }
.lobby-player-tile .p-name { font-weight: 700; font-size: 0.92rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-player-tile .p-tags { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; justify-content: center; }
.tag-mini {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}
.tag-mini.host { background: var(--amber-soft); color: #B45309; }
.tag-mini.bot { background: var(--secondary-soft); color: var(--secondary); }
.btn-kick-bot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
}
.btn-kick-bot:hover { background: var(--primary); color: #fff; }

.lobby-tip {
  margin-top: 16px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--bg-subtle);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.settings-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.setting-item label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.setting-full { grid-column: 1 / -1; }
.setting-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-solid);
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 8px 14px;
}
.setting-toggle label { margin: 0; color: var(--text); }
.lobby-footer { margin-top: 20px; }
.waiting-note {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 8px 0 0;
}

/* ==================== GAME ARENA VIEW ==================== */
.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.gh-left { display: flex; align-items: center; gap: 10px; }
.gh-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.round-pill {
  padding: 5px 12px;
  border-radius: 99px;
  background: var(--bg-subtle);
  font-weight: 800;
  font-size: 0.84rem;
}

.word-banner {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 7px 20px;
  border-radius: 16px;
  background: var(--surface-solid);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.word-cat-tag {
  font-size: 0.74rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--secondary-soft);
  color: var(--secondary);
}
.word-display {
  font-size: 1.32rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--text);
}
.word-len-tag {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Circular Timer */
.timer-ring-wrap {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timer-svg {
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}
.timer-bg {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 4;
}
.timer-fg {
  fill: none;
  stroke: var(--success);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.35s linear, stroke 0.25s ease;
}
.timer-text {
  position: absolute;
  font-size: 0.84rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.timer-ring-wrap.warn .timer-fg { stroke: var(--amber); }
.timer-ring-wrap.danger .timer-fg { stroke: var(--primary); }
.timer-ring-wrap.danger { animation: pulseWarn 0.9s infinite; }

/* 3-Column Arena */
.arena-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 235px minmax(0, 1fr) 295px;
  gap: 14px;
  padding: 14px 16px 16px;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  min-height: calc(100vh - 68px);
}

.arena-sidebar-left, .arena-sidebar-right {
  display: flex;
  flex-direction: column;
  padding: 14px;
  max-height: calc(100vh - 96px);
  overflow: hidden;
}
.panel-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.game-players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}
.gp-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 13px;
  background: var(--surface-solid);
  border: 1.5px solid var(--border);
  transition: all 0.2s ease;
}
.gp-row.is-drawer {
  border-color: var(--secondary);
  background: var(--secondary-soft);
}
.gp-row.is-guessed {
  border-color: var(--success);
  background: var(--success-soft);
}
.gp-rank {
  width: 20px;
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}
.gp-avatar { width: 36px; height: 36px; flex-shrink: 0; }
.gp-info { flex: 1; min-width: 0; }
.gp-name {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gp-score {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.gp-badge { font-size: 0.95rem; }

/* Center Stage & Canvas */
.arena-center {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.canvas-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

#draw-canvas, #preview-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#preview-canvas { pointer-events: none; }

.brush-cursor {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  border: 1.5px solid rgba(20, 20, 20, 0.75);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.85);
  transform: translate(-50%, -50%);
  display: none;
  z-index: 12;
}

/* Floating Reactions */
.reactions-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 15;
}
.float-emoji {
  position: absolute;
  bottom: 44px;
  font-size: 1.9rem;
  animation: floatUp 1.9s cubic-bezier(.22,.61,.36,1) forwards;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.16));
}

.reaction-dock {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: var(--shadow-sm);
  z-index: 18;
}
[data-theme="dark"] .reaction-dock {
  background: rgba(30, 34, 48, 0.90);
  border-color: rgba(255,255,255,0.12);
}
.react-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease;
}
.react-btn:hover { transform: scale(1.25); background: var(--bg-subtle); }

/* Stage Overlays */
.stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  background: rgba(18, 20, 28, 0.52);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.overlay-card {
  background: var(--surface-solid);
  color: var(--text);
  border-radius: 22px;
  padding: 26px 28px;
  max-width: 560px;
  width: 100%;
  max-height: 92%;
  overflow-y: auto;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: popIn 0.24s cubic-bezier(.34,1.56,.64,1);
}
.podium-card { max-width: 680px; }
.overlay-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 800;
  margin-bottom: 10px;
}
.overlay-card h3, .overlay-card h2 { margin: 0 0 16px; }

.word-choices-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.word-choice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  border-radius: 16px;
  border: 2px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.16s ease;
}
.word-choice-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-3px);
}
.word-choice-btn strong { font-size: 1.15rem; }
.word-choice-btn .wc-meta { font-size: 0.74rem; color: var(--text-muted); }

.wait-avatar { width: 84px; height: 84px; margin: 0 auto 12px; }

.answer-reveal {
  display: inline-flex;
  flex-direction: column;
  padding: 10px 26px;
  border-radius: 14px;
  background: var(--bg-subtle);
  margin-bottom: 16px;
}
.answer-reveal span { font-size: 0.76rem; color: var(--text-muted); }
.answer-reveal strong { font-size: 1.55rem; color: var(--primary); letter-spacing: 0.08em; }

.summary-scores-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
  text-align: left;
}
.sum-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 11px;
  background: var(--bg);
  font-size: 0.9rem;
}
.sum-pts { font-weight: 800; color: var(--success); }

/* Podium & Gallery */
.podium-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 14px;
  margin: 18px 0 20px;
}
.podium-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 136px;
}
.podium-av { width: 58px; height: 58px; margin-bottom: 6px; }
.podium-name { font-weight: 800; font-size: 0.9rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-score { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); margin-bottom: 6px; }
.podium-bar {
  width: 100%;
  border-radius: 14px 14px 6px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  color: #fff;
}
.podium-bar.rank-1 { height: 92px; background: linear-gradient(180deg, #FBBF24, #D97706); }
.podium-bar.rank-2 { height: 68px; background: linear-gradient(180deg, #94A3B8, #64748B); }
.podium-bar.rank-3 { height: 50px; background: linear-gradient(180deg, #FB923C, #C2410C); }

.awards-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}
.award-chip {
  padding: 7px 12px;
  border-radius: 12px;
  background: var(--bg-subtle);
  font-size: 0.8rem;
  text-align: left;
}
.award-chip strong { display: block; color: var(--primary); }

.gallery-section { margin: 14px 0 18px; text-align: left; }
.gallery-section h4 { margin: 0 0 10px; font-size: 0.9rem; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.gallery-card {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: transform 0.14s ease;
}
.gallery-card:hover { transform: scale(1.03); }
.gallery-card img { width: 100%; aspect-ratio: 16/10; object-fit: cover; display: block; background: #fff; }
.gallery-card .g-cap { padding: 6px 8px; font-size: 0.75rem; }
.gallery-card .g-cap strong { display: block; }

.podium-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Pro Drawing Toolbar */
.draw-toolbar {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tool-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  border: 1.5px solid transparent;
  background: var(--bg-subtle);
  color: var(--text);
  cursor: pointer;
  padding: 2px;
  transition: all 0.14s ease;
}
.tool-btn span { font-size: 1rem; line-height: 1.1; }
.tool-btn small { font-size: 0.64rem; font-weight: 700; color: var(--text-muted); }
.tool-btn:hover { border-color: var(--primary); }
.tool-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.tool-btn.active small { color: var(--primary); }

.tool-divider {
  width: 1px;
  height: 30px;
  background: var(--border-strong);
  margin: 0 2px;
}

.size-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.size-presets { display: flex; gap: 4px; align-items: center; }
.size-dot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1.5px solid transparent;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.size-dot i {
  display: block;
  border-radius: 50%;
  background: var(--text);
}
.size-dot.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}
#brush-size-slider { width: 76px; accent-color: var(--primary); }

.action-group {
  display: flex;
  gap: 5px;
  margin-left: auto;
}
.act-btn {
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-solid);
  color: var(--text);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.act-btn:hover { background: var(--bg-subtle); }
.act-btn.danger:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

.toolbar-colors { justify-content: space-between; }
.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.pal-swatch {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.pal-swatch:hover { transform: scale(1.16); }
.pal-swatch.active {
  transform: scale(1.18);
  box-shadow: 0 0 0 2px var(--surface-solid), 0 0 0 4px var(--primary);
}
.custom-color-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9px;
  background: var(--bg-subtle);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}
.custom-color-wrap input {
  width: 22px;
  height: 22px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}

.guesser-bar {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.guesser-status { font-size: 0.9rem; font-weight: 700; }

/* Chat Panel */
.chat-feed {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-right: 4px;
  margin-bottom: 10px;
}
.chat-item {
  padding: 7px 10px;
  border-radius: 11px;
  background: var(--bg);
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
  animation: fadeIn 0.15s ease;
}
.chat-item .c-name { font-weight: 800; margin-right: 6px; }
.chat-item.sys {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 4px 8px;
}
.chat-item.sys.accent { color: var(--primary); font-weight: 700; }
.chat-item.sys.warn { color: #D97706; font-weight: 700; }
.chat-item.correct {
  background: var(--success-soft);
  color: #047857;
  font-weight: 800;
  border: 1px solid rgba(16, 185, 129, 0.28);
}
[data-theme="dark"] .chat-item.correct { color: #34D399; }
.chat-item.close {
  background: var(--amber-soft);
  color: #B45309;
  font-weight: 700;
}
[data-theme="dark"] .chat-item.close { color: #FBBF24; }
.chat-item.guessed-chat {
  border-left: 3px solid var(--success);
}

.chat-form {
  display: flex;
  gap: 7px;
}
.chat-form input { flex: 1; padding: 9px 12px; }
.chat-form button { padding: 9px 14px; white-space: nowrap; }

/* Toasts */
.toast-container {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1F1D1A;
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.2s ease;
}
.toast.error { background: #DC2626; }
.toast.success { background: #059669; }

/* Animations */
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes floatUp {
  0% { opacity: 0; transform: translateY(10px) scale(0.7); }
  15% { opacity: 1; transform: translateY(-10px) scale(1.1); }
  100% { opacity: 0; transform: translateY(-190px) scale(1.25) rotate(8deg); }
}
@keyframes pulseWarn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.09); }
}

/* Responsive */
@media (max-width: 1120px) {
  .arena-grid {
    grid-template-columns: 1fr 270px;
  }
  .arena-sidebar-left {
    grid-column: 1 / -1;
    max-height: none;
    order: 3;
  }
  .game-players-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .gp-row { flex: 1 1 160px; }
}

@media (max-width: 860px) {
  .home-grid, .lobby-grid { grid-template-columns: 1fr; }
  .avatar-studio { grid-template-columns: 1fr; justify-items: center; }
  .arena-grid { grid-template-columns: 1fr; }
  .arena-sidebar-right { max-height: 300px; }
  .game-header { grid-template-columns: auto 1fr auto; padding: 8px 12px; }
  .word-display { font-size: 1.02rem; letter-spacing: 0.08em; }
  .word-choices-grid { grid-template-columns: 1fr; }
  .cta-row { grid-template-columns: 1fr; }
}
