:root {
  --bg: #0c0f24;
  --bg-soft: #10142c;
  --panel: #191f42d9;
  --panel-solid: #191f42;
  --border: #22274a;
  --text: #f1f2fb;
  --muted: #8890b8;
  --primary: #ff6b81;
  --primary-dark: #e6495f;
  --secondary: #2fd6c0;
  --secondary-dark: #1fa896;
  --accent: #ffd166;
  --accent-blue: #4f7cff;
  --accent-blue-dark: #3960e0;
  --success: #6bcb77;
  --radius: 18px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 50% 40%, #142354 0%, #0a1338 65%, #081130 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.bg-blob { position: absolute; height: auto; }
.bg-blob-tl { top: 0; left: 0; width: 34vw; min-width: 280px; max-width: 520px; }
.bg-blob-bl { bottom: 0; left: 0; width: 26vw; min-width: 220px; max-width: 400px; }
.bg-blob-br { bottom: 0; right: 0; width: 34vw; min-width: 280px; max-width: 520px; }

.doodle { position: absolute; }
.doodle-burst { top: 3vh; left: 15vw; width: 34px; }
.doodle-arc-yellow { top: 5vh; right: 15vw; width: 56px; }
.doodle-arc-dashed { top: 0; right: 0; width: 200px; }
.doodle-crown { top: 14vh; right: 3vw; width: 46px; }
.doodle-note-yellow { bottom: 15vh; left: 1vw; width: 28px; }
.doodle-note-purple { bottom: 7vh; left: 10vw; width: 22px; }

@media (max-width: 768px) {
  .doodle-arc-dashed, .doodle-arc-yellow, .doodle-crown { display: none; }
  .bg-blob-tl { width: 48vw; }
  .bg-blob-bl { width: 40vw; }
  .bg-blob-br { width: 50vw; }
}

.screen {
  position: relative;
  z-index: 1;
  display: none;
  min-height: 100vh;
  padding: 24px;
}
.screen.active { display: block; }
@media (max-width: 640px) {
  .screen { padding: 14px; }
}

.muted { color: var(--muted); font-size: 0.9em; }

/* ---------- Botões / campos ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; }
.btn-purple { background: linear-gradient(135deg, #8a5bff, #6a2ee0); color: white; }
.btn-secondary { background: linear-gradient(135deg, var(--secondary), var(--secondary-dark)); color: #06201d; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-small { padding: 8px 14px; font-size: 0.85rem; }
.btn-icon { background: var(--panel-solid); border: 1px solid var(--border); color: var(--text); width: 38px; height: 38px; padding: 0; font-size: 1.1rem; border-radius: 10px; }
.btn-icon.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(255,107,129,0.35) inset; }

.btn-hint {
  border-radius: 999px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  color: #06201d;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-hint[hidden] {
  display: none;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 0.82rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 1rem;
}
.field input:focus, .field select:focus { outline: 2px solid var(--primary); }

/* ---------- Home ---------- */
.home-wrap {
  max-width: 760px;
  margin: 4vh auto 0;
  text-align: center;
}
.home-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 32px; }
.home-logo { height: 72px; width: auto; max-width: 100%; }

.home-wrap > .field { max-width: 360px; margin: 0 auto 28px; text-align: left; }

.nickname-row {
  display: flex; align-items: center; gap: 14px;
  max-width: 360px; margin: 0 auto 28px; text-align: left;
}
.nickname-row .field { flex: 1; margin-bottom: 0; }
.avatar-picker-btn {
  width: 72px; height: 72px; border-radius: 50%; padding: 0; flex: none;
  border: 2px solid var(--border); background: var(--bg-soft); cursor: pointer; overflow: visible;
  position: relative;
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.avatar-picker-btn:hover { border-color: var(--primary); }
.avatar-picker-btn:active { transform: scale(0.96); }
.avatar-picker-btn img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 50%; }
.avatar-edit-badge {
  position: absolute; right: -4px; bottom: -4px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-blue); border: 3px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 34, 0.85);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay[hidden] { display: none; }

.avatar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px;
  margin: 18px 0; max-height: 60vh; overflow-y: auto; padding: 4px;
}
@media (max-width: 640px) {
  .avatar-grid { grid-template-columns: repeat(5, 1fr); }
}
.avatar-option {
  width: 100%; aspect-ratio: 1; border-radius: 50%; padding: 0; cursor: pointer;
  border: 3px solid transparent; background: var(--bg-soft); overflow: hidden;
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.avatar-option:hover { transform: scale(1.06); }
.avatar-option.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(255,107,129,0.35); }
.avatar-option img { width: 100%; height: 100%; object-fit: cover; display: block; }

.home-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  text-align: left;
}
@media (max-width: 640px) {
  .home-cards { grid-template-columns: 1fr; }
  .home-logo { height: 52px; }
}

.card {
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.card h2 { margin-top: 0; font-size: 1.15rem; }
.card .btn { width: 100%; margin-top: 6px; }

/* ---------- Lobby ---------- */
.lobby-wrap { max-width: 800px; margin: 4vh auto 0; }
.lobby-header {
  display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px;
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px;
}
.lobby-label { margin: 0 0 4px; color: var(--muted); font-size: 0.85rem; }
.room-code-row { display: flex; align-items: center; gap: 10px; }
.room-code { font-size: 2rem; font-weight: 800; letter-spacing: 0.12em; color: var(--accent); }
.lobby-settings { text-align: right; color: var(--muted); font-size: 0.9rem; line-height: 1.6; }

.lobby-body {
  display: grid; grid-template-columns: 1fr 260px; gap: 18px;
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px;
}
@media (max-width: 640px) {
  .lobby-body { grid-template-columns: 1fr; padding: 16px; }
  .lobby-header { padding: 16px; }
  .lobby-settings { text-align: left; }
  .room-code { font-size: 1.5rem; }
}

.player-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player-list li {
  display: flex; align-items: center; gap: 8px;
  background: #19264E; border: 1px solid #182A5A; border-radius: 12px; padding: 8px 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}
.player-role { width: 16px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; }
.player-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 800; color: #10142b;
  border: 2px solid transparent; overflow: hidden;
}
.player-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.player-avatar.guessed { border-color: var(--secondary); }
.player-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-score { flex: none; font-weight: 700; color: var(--text); background: var(--panel-solid); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: 0.85rem; }
.player-list li.is-drawing { background: var(--bg-soft); box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.35) inset, 0 10px 24px rgba(0, 0, 0, 0.45); }
.player-list li.disconnected { opacity: 0.45; }
.crown { color: var(--accent); }
.pencil { color: var(--text); }
.guessed-check { color: var(--secondary); font-weight: 800; }

.lobby-actions { display: flex; flex-direction: column; gap: 10px; justify-content: center; }

/* ---------- Jogo ---------- */
.game-wrap {
  max-width: 1520px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto minmax(280px, 1fr);
  gap: 14px;
}
.game-topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: center;
  background: rgba(17, 30, 65, 0.82);
  border: 1px solid rgba(65, 85, 140, 0.35);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.20);
  padding: 12px 0;
}
.topbar-col { display: flex; align-items: center; min-width: 0; }
.topbar-col-left { padding-left: 20px; }
.topbar-col-right { justify-content: flex-end; padding-right: 20px; gap: 14px; }
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 52px; width: auto; flex: none; }

.topbar-stats { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stat-card {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 14px;
  padding: 8px 18px; display: flex; align-items: center; gap: 16px;
}
.stat-col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 56px; }
.stat-divider { align-self: stretch; width: 1px; background: var(--border); }
.stat-label { font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; display: flex; align-items: center; gap: 4px; }
.clock-icon { color: var(--accent); flex: none; }
.stat-col strong { font-size: 1.25rem; font-weight: 800; }
.stat-timer { color: var(--accent); font-variant-numeric: tabular-nums; }

.topbar-turn {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px;
  padding: 10px 18px; min-height: 54px;
}
.turn-people-icon { flex: none; color: var(--text); }
.turn-pencil-icon { flex: none; color: var(--accent); transform: rotate(-8deg); }

#btn-leave-game { background: var(--bg-soft); border-radius: 999px; }
.turn-divider { align-self: stretch; width: 1px; background: #182A5A; }
.turn-badge-text { font-weight: 700; font-size: 0.92rem; white-space: nowrap; color: var(--text); }
.turn-badge-text:empty { display: none; }
.topbar-turn:has(.turn-badge-text:empty) { display: none; }

.game-body {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  align-items: start;
}
@media (max-width: 980px) {
  .game-wrap { grid-template-columns: 1fr; }
  .players-panel { order: 2; }
  .canvas-panel { order: 1; }
  .chat-panel { order: 3; }
  .topbar-col-left, .topbar-col-right { padding-left: 20px; padding-right: 20px; }
  .topbar-col-center { justify-content: center; }
  .topbar-col-right { justify-content: flex-start; }
}
@media (max-width: 640px) {
  .game-topbar { padding: 10px 0; gap: 8px; }
  .brand-logo { height: 34px; }
}

.side-panel {
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}
.side-panel h3 { margin-top: 0; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; color: #FFFFFF; display: flex; align-items: center; gap: 8px; }

.players-panel {
  height: 100%; background: #152247;
  border-color: #182A5A;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

.side-panel.chat-panel {
  background: #0E1832;
  border-color: #182A5A;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}
.chat-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  background: #152247;
  margin: -20px -20px 16px -20px;
  padding: 14px 20px;
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 1px solid #182A5A;
}
.chat-panel-header h3 { margin: 0; color: #FFFFFF; display: flex; align-items: center; gap: 8px; }
.chat-icon { flex: none; }
@media (max-width: 980px) {
  .players-panel .player-list { max-height: 160px; overflow-y: auto; }
}

.canvas-panel { position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.canvas-holder {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 940 / 480;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #182A5A;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  touch-action: none;
}
#draw-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.overlay { z-index: 2; }

.drawer-word-box {
  position: absolute; top: 0; left: 50%; transform: translate(-50%, -50%);
  z-index: 3;
  background: #152247; border: 2px solid #ffffff; border-radius: 12px;
  padding: 8px 18px;
  font-size: clamp(1.1rem, 3.4vw, 1.5rem); font-weight: 800; letter-spacing: 0.18em; color: var(--text); text-transform: uppercase;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  max-width: 90%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer-word-box[hidden] { display: none; }
.drawer-word-box .hint-revealed { color: var(--success); }

.canvas-float-tools { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; }
.float-icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: #ffffff; border: 1px solid #e2e2ec; color: #2b2b3a;
  display: flex; align-items: center; justify-content: center; font-size: 1.05rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18); cursor: pointer;
}
.float-icon-btn:hover:not(:disabled) { background: #f2f2f7; }
.float-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---------- Painel de ferramentas ---------- */
.toolbox {
  display: flex; align-items: center; justify-content: center;
  background: #101D40; border: 1px solid #182A5A; border-radius: var(--radius);
  padding: 10px 20px;
  color: var(--text);
  margin: 0 auto;
  max-width: 100%;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}
.toolbox-inner {
  display: flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 20px;
  flex: none;
}
.toolbox-inner > * + * { border-left: 1px solid var(--border); padding-left: 20px; }
.toolbox-colors + .toolbox-grid { border-left-color: #182A5A; }
.toolbox-grid + .toolbox-extra { border-left: none; padding-left: 0; }
.toolbox-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.tool-btn {
  background: #19264E; border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; cursor: pointer; line-height: 1;
}
.tool-btn:hover { filter: brightness(1.25); }
.tool-btn.active { background: var(--accent-blue); border-color: var(--accent-blue); color: #fff; }
.tool-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.tool-btn:disabled:hover { filter: none; }

.toolbox-extra { display: flex; align-items: center; gap: 10px; }
.toolbox-extra .size-row { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.toolbox-extra input[type="range"] { width: 120px; }

.toolbox-colors { display: flex; align-items: center; gap: 14px; }
.color-grid {
  display: grid; grid-template-columns: repeat(9, 1fr); grid-auto-rows: 30px; gap: 8px; width: auto;
  background: #19264E; border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}
.color-grid .swatch { width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer; padding: 0; box-shadow: 0 1px 3px rgba(0,0,0,0.35); }
.color-grid .swatch.active { box-shadow: 0 0 0 2px #19264E, 0 0 0 4px var(--text); }
.current-color-swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--border); background: #1f1f1f; flex: none; }
.color-wheel-btn {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer; position: relative; overflow: hidden;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); border: 2px solid var(--border);
  flex: none;
}
.color-wheel-btn input[type="color"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; border: none; padding: 0; width: 100%; height: 100%; }

@media (max-width: 640px) {
  .toolbox { padding: 8px 10px; gap: 10px; }
  .toolbox > * + * { border-left: none; padding-left: 0; }
  .tool-btn { width: 30px; height: 30px; }
  .color-grid { grid-auto-rows: 20px; gap: 5px; }
  .color-grid .swatch { width: 20px; height: 20px; }
  .current-color-swatch, .color-wheel-btn { width: 28px; height: 28px; }
  .toolbox-extra input[type="range"] { width: 70px; }
}

/* Overlays */
.overlay {
  position: absolute; inset: 0; background: rgba(10, 14, 34, 0.85);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.overlay[hidden] { display: none; }
.overlay-box { background: var(--panel-solid); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; text-align: center; max-width: 420px; width: 100%; }
@media (max-width: 480px) {
  .overlay { padding: 12px; }
  .overlay-box { padding: 18px; }
}
.overlay-box-wide { max-width: 480px; }
#game-end-overlay { position: fixed; inset: 0; z-index: 100; }
.overlay-box h2 { margin-top: 0; }

/* ---------- Ranking (fim de jogo) — vidro ---------- */
.ranking-panel {
  position: relative; z-index: 1; overflow: hidden; width: 100%; max-width: 700px; text-align: center;
  font-family: 'Sora', 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 32px;
  padding: 44px 36px 36px;
  backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.ranking-panel::before, .ranking-panel::after {
  content: ''; position: absolute; z-index: -1; border-radius: 50%; filter: blur(70px); pointer-events: none;
}
.ranking-panel::before {
  width: 420px; height: 420px; top: -180px; left: 50%; transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 209, 102, 0.4), transparent 65%);
}
.ranking-panel::after {
  width: 600px; height: 380px; bottom: -220px; left: 50%; transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(94, 82, 230, 0.6), rgba(18, 48, 94, 0.45) 50%, transparent 75%);
}
.ranking-panel h2 { margin: 0 0 40px; font-size: 2rem; font-weight: 800; letter-spacing: -0.01em; color: #fff; }

.podium { position: relative; z-index: 1; display: grid; grid-template-columns: 1fr 1.15fr 1fr; align-items: end; gap: 14px; max-width: 540px; margin: 0 auto 36px; }
.podium-place { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.podium-place-1 { --c: var(--accent); }
.podium-place-2 { --c: #b9c6ee; }
.podium-place-3 { --c: #f0a877; }

.podium-info { animation: podiumPop 0.5s cubic-bezier(.2,.8,.2,1) both; }
.podium-avatar-wrap { position: relative; margin-bottom: 16px; }
.podium-avatar {
  width: 78px; height: 78px; border-radius: 50%; overflow: hidden; position: relative;
  border: 3px solid var(--c); background: linear-gradient(135deg, #3a2f8f, #1f4a8a);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
  display: grid; place-items: center;
}
.podium-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.podium-avatar-initial { font-weight: 800; font-size: 1.8rem; color: rgba(255, 255, 255, 0.9); }
.podium-avatar img + .podium-avatar-initial { display: none; }

.podium-place-1 .podium-avatar {
  width: 108px; height: 108px;
  box-shadow: 0 0 0 6px rgba(255, 209, 102, 0.12), 0 0 40px rgba(255, 209, 102, 0.45), 0 12px 30px rgba(0, 0, 0, 0.4);
}
.podium-place-1 .podium-avatar-initial { font-size: 2.4rem; }

.podium-crown {
  position: absolute; top: -30px; left: 50%; transform: translateX(-50%) rotate(-8deg);
  width: 40px; filter: drop-shadow(0 4px 10px rgba(255, 209, 102, 0.6));
  animation: podiumDrop 0.5s cubic-bezier(.3,1.6,.5,1) 1.7s both;
}

.podium-rank-pill {
  position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; font-size: 0.8rem; color: #1a1440; background: var(--c);
  border: 2px solid #1d1650; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}
.podium-place-1 .podium-rank-pill { width: 32px; height: 32px; font-size: 0.9rem; }

.podium-name {
  font-weight: 700; font-size: 0.95rem; max-width: 100%; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px;
}
.podium-place-1 .podium-name { font-size: 1.05rem; }
.podium-score { font-weight: 600; font-size: 0.85rem; color: var(--c); margin: 2px 0 12px; font-variant-numeric: tabular-nums; }
.podium-score b { font-size: 1.15rem; font-weight: 800; }
.podium-place-1 .podium-score b { font-size: 1.4rem; }

.podium-block {
  width: 100%; position: relative; overflow: hidden;
  border-radius: 18px 18px 6px 6px;
  border: 1px solid color-mix(in srgb, var(--c) 70%, black);
  border-bottom: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 0 rgba(0, 0, 0, 0.18);
  display: flex; justify-content: center; padding-top: 10px;
  transform-origin: bottom;
  animation: podiumRise 0.6s cubic-bezier(.2,.8,.2,1) both;
}
.podium-place-1 .podium-block { background: linear-gradient(180deg, #ffe27a, #f5b301 60%, #c98600); }
.podium-place-2 .podium-block { background: linear-gradient(180deg, #eef2fb, #b7c1de 60%, #838fb8); }
.podium-place-3 .podium-block { background: linear-gradient(180deg, #ffc48a, #e08a45 60%, #a85f28); }
.podium-block::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.28) 45%, transparent 60%);
}
.podium-block span {
  font-size: 3rem; font-weight: 800; line-height: 1;
  color: #fff; -webkit-text-stroke: 1.25px rgba(0, 0, 0, 0.55); paint-order: stroke fill;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35), 0 3px 6px rgba(0, 0, 0, 0.3);
}
.podium-place-1 .podium-block { height: 130px; }
.podium-place-1 .podium-block span { font-size: 4rem; }
.podium-place-2 .podium-block { height: 92px; }
.podium-place-3 .podium-block { height: 66px; }

.podium-base {
  position: relative; z-index: 1; max-width: 560px; height: 10px; margin: -36px auto 36px; border-radius: 6px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
}

.podium-place-3 .podium-block { animation-delay: .1s; } .podium-place-3 .podium-info { animation-delay: .5s; }
.podium-place-2 .podium-block { animation-delay: .4s; } .podium-place-2 .podium-info { animation-delay: .8s; }
.podium-place-1 .podium-block { animation-delay: .8s; } .podium-place-1 .podium-info { animation-delay: 1.25s; }

@keyframes podiumRise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes podiumPop  { 0% { opacity: 0; transform: translateY(14px) scale(.85); } 70% { transform: translateY(-3px) scale(1.03); } 100% { opacity: 1; transform: none; } }
@keyframes podiumDrop { 0% { opacity: 0; transform: translate(-50%, -24px) rotate(-30deg); } 100% { opacity: 1; transform: translateX(-50%) rotate(-8deg); } }
@media (prefers-reduced-motion: reduce) {
  .podium-block, .podium-info, .podium-crown { animation: none; }
}

.btn-ranking-back {
  position: relative; z-index: 1; cursor: pointer; padding: 14px 34px; border-radius: 999px;
  font-family: inherit; font-weight: 700; font-size: 0.95rem; color: #1a1440;
  background: linear-gradient(180deg, #fff, #dcd6ff);
  border: none; box-shadow: 0 10px 30px rgba(120, 100, 255, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-ranking-back:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(120, 100, 255, 0.5), inset 0 -2px 0 rgba(0, 0, 0, 0.08); }
.btn-ranking-back:active { transform: translateY(0); }
.btn-ranking-back[hidden] { display: none; }

@media (max-width: 480px) {
  .ranking-panel { padding: 36px 16px 28px; border-radius: 24px; }
  .ranking-panel h2 { font-size: 1.6rem; }
  .podium { gap: 8px; }
  .podium-avatar { width: 60px; height: 60px; }
  .podium-place-1 .podium-avatar { width: 82px; height: 82px; }
  .podium-crown { width: 32px; top: -24px; }
  .podium-name { font-size: 0.8rem; }
  .podium-place-1 .podium-name { font-size: 0.9rem; }
  .podium-block span { font-size: 2.2rem; }
  .podium-place-1 .podium-block span { font-size: 3rem; }
  .podium-place-1 .podium-block { height: 104px; } .podium-place-2 .podium-block { height: 74px; } .podium-place-3 .podium-block { height: 52px; }
}
.word-choices { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.word-choices .btn { width: 100%; }
.overlay-timer { color: var(--muted); font-size: 0.9rem; }
.choosing-progress {
  width: 100%; height: 12px; background: var(--bg-soft); border-radius: 999px;
  overflow: hidden; margin-top: 16px; border: 1px solid var(--border);
}
.choosing-progress-fill {
  height: 100%; width: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
}
.round-end-word { font-size: 1.8rem; font-weight: 800; color: var(--accent); text-transform: capitalize; }

/* Chat */
.chat-panel { display: flex; flex-direction: column; height: 100%; }
.chat-messages {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px;
  min-height: 260px; max-height: 420px; padding-right: 4px; margin-bottom: 10px;
}
@media (max-width: 980px) {
  .chat-messages { min-height: 160px; max-height: 260px; }
}
.chat-msg { font-size: 0.9rem; line-height: 1.35; word-break: break-word; }
.chat-msg .author { font-weight: 700; color: var(--secondary); }
.chat-msg.system { color: var(--muted); font-style: italic; }
.chat-msg.correct { color: var(--success); font-weight: 700; }
.chat-msg.close { color: #ff8a3d; font-weight: 700; }
.chat-msg.close .close-word { text-decoration: underline; }
.chat-form {
  display: flex; gap: 8px;
  margin: 0 -20px -20px -20px;
  padding: 14px 20px 20px 20px;
  border-top: 1px solid #182A5A;
}
.chat-form[hidden] { display: none; }
.chat-input-wrap {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px;
  background: #172653; border-radius: 999px;
  padding: 4px 4px 4px 16px;
}
.chat-input-wrap input {
  flex: 1; min-width: 0; background: transparent; border: none; color: var(--text);
  padding: 8px 4px; font-size: 0.95rem;
}
.chat-input-wrap input:focus { outline: none; }
.chat-input-wrap input::placeholder { color: #AAB7D5; }
.btn-send {
  width: 36px; height: 36px; flex: none; border: none; border-radius: 50%;
  background: var(--accent-blue); color: #ffffff;
  font-size: 1.1rem; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn-send:hover { filter: brightness(1.08); }
.btn-send:active { transform: scale(0.93); }

/* Toasts */
.toast-container { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel-solid); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  animation: fade-in 0.15s ease;
}
.toast.error { border-color: var(--primary); color: #ffb4b4; }
@keyframes fade-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
