:root,
[data-theme="dark"] {
  --bg-void: #0b0e14;
  --bg-panel: #131826;
  --bg-panel-raised: #1b2233;
  --border: #232b3d;
  --fuse-amber: #ffa23a;
  --danger-red: #ff4d4d;
  --safe-green: #6bffb8;
  --text-primary: #edeff4;
  --text-muted: #7a8296;
  --shadow-color: 0, 0, 0;
  --shadow-strength: 0.4;
  --grid-line: rgba(255, 255, 255, 0.025);
  --panel-sheen: rgba(255, 255, 255, 0.03);
  --font-display: "Oswald", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

[data-theme="light"] {
  --bg-void: #eef1f6;
  --bg-panel: #ffffff;
  --bg-panel-raised: #f3f5fa;
  --border: #d9dee8;
  --fuse-amber: #e08014;
  --danger-red: #d5312f;
  --safe-green: #128a5e;
  --text-primary: #1a2030;
  --text-muted: #616b80;
  --shadow-color: 30, 40, 60;
  --shadow-strength: 0.12;
  --grid-line: rgba(20, 30, 50, 0.035);
  --panel-sheen: rgba(255, 255, 255, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-body);
}

body {
  transition: background-color 0.25s ease, color 0.25s ease;
  background-image:
    radial-gradient(circle at 15% 10%, rgba(255, 162, 58, 0.07), transparent 42%),
    radial-gradient(circle at 85% 90%, rgba(255, 77, 77, 0.06), transparent 42%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px, 28px 28px;
  background-position: 0 0, 0 0, 0 0, 0 0;
}

h1, h2, h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 12px;
}

p { margin: 0 0 12px; line-height: 1.5; }
.muted { color: var(--text-muted); }
.hint { color: var(--text-muted); font-size: 0.85rem; }

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid var(--fuse-amber);
  outline-offset: 2px;
}

/* ---------- Ambient embers ---------- */

.embers {
  position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
}
.embers span {
  position: absolute;
  bottom: -10px;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--fuse-amber);
  opacity: 0;
  filter: drop-shadow(0 0 3px var(--fuse-amber));
  animation: emberDrift linear infinite;
}
[data-theme="light"] .embers span { opacity: 0; }
.embers span:nth-child(1) { left: 8%;  animation-duration: 14s; animation-delay: 0s; }
.embers span:nth-child(2) { left: 22%; animation-duration: 18s; animation-delay: 3s; }
.embers span:nth-child(3) { left: 41%; animation-duration: 12s; animation-delay: 6s; }
.embers span:nth-child(4) { left: 63%; animation-duration: 20s; animation-delay: 1s; }
.embers span:nth-child(5) { left: 80%; animation-duration: 15s; animation-delay: 8s; }
.embers span:nth-child(6) { left: 92%; animation-duration: 17s; animation-delay: 4s; }

@keyframes emberDrift {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  8%   { opacity: 0.55; }
  50%  { transform: translateY(-50vh) translateX(12px); }
  92%  { opacity: 0.3; }
  100% { transform: translateY(-100vh) translateX(-8px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .embers { display: none; }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(var(--shadow-color), 0.04);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.hazard-stripe {
  height: 4px;
  background: repeating-linear-gradient(
    -45deg,
    var(--fuse-amber) 0 10px,
    #171d2c 10px 20px
  );
  opacity: 0.7;
}
[data-theme="light"] .hazard-stripe {
  background: repeating-linear-gradient(
    -45deg,
    var(--fuse-amber) 0 10px,
    #2a2118 10px 20px
  );
  opacity: 0.55;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.05em;
}

.brand-icon { width: 22px; height: 22px; flex-shrink: 0; }
.brand-icon .bi-body { fill: #171d2c; stroke: var(--border); stroke-width: 2; }
.brand-icon .bi-fuse { stroke: #8a6a3f; stroke-width: 4; fill: none; }
.brand-icon .bi-spark { fill: var(--fuse-amber); }

.brand-accent { color: var(--fuse-amber); }

#topbarRight {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-muted);
}

#topbarRight .rating-badge {
  color: var(--fuse-amber);
  font-weight: 700;
}

.topbar-right { display: flex; align-items: center; gap: 16px; }

.theme-toggle {
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.theme-toggle:hover { color: var(--fuse-amber); border-color: var(--fuse-amber); }
.theme-toggle svg { width: 18px; height: 18px; position: absolute; transition: opacity 0.2s ease, transform 0.3s ease; }

[data-theme="dark"] .icon-sun { opacity: 0; transform: rotate(-90deg) scale(0.5); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="light"] .icon-sun { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="light"] .icon-moon { opacity: 0; transform: rotate(90deg) scale(0.5); }

/* ---------- Layout / screens ---------- */

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px 80px;
  position: relative;
  z-index: 1;
}

.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 8px 24px rgba(var(--shadow-color), var(--shadow-strength)), inset 0 1px 0 var(--panel-sheen);
}

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 12px 20px;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 0 rgba(var(--shadow-color), calc(var(--shadow-strength) * 0.6));
}

.btn:hover { filter: brightness(1.12); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(var(--shadow-color), calc(var(--shadow-strength) * 0.7)); }
.btn:active { transform: scale(0.98) translateY(0); box-shadow: 0 1px 0 rgba(var(--shadow-color), calc(var(--shadow-strength) * 0.6)); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; transform: none; animation: none; }

.btn-primary { background: var(--fuse-amber); color: #201400; }
.btn-danger { background: var(--danger-red); color: #2a0000; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-primary); box-shadow: none; }
.btn-small { padding: 8px 14px; font-size: 0.85rem; }

.btn-pulse { animation: btnPulse 2.6s ease-in-out infinite; }
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 2px 0 rgba(var(--shadow-color), calc(var(--shadow-strength) * 0.6)), 0 0 0 0 rgba(255, 77, 77, 0.35); }
  50% { box-shadow: 0 2px 0 rgba(var(--shadow-color), calc(var(--shadow-strength) * 0.6)), 0 0 0 8px rgba(255, 77, 77, 0); }
}
@media (prefers-reduced-motion: reduce) { .btn-pulse { animation: none; } }

.row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.row-space { justify-content: space-between; align-items: baseline; }

/* ---------- Auth ---------- */

.auth-panel { max-width: 380px; margin: 40px auto; }
.auth-icon { display: flex; justify-content: center; margin-bottom: 8px; }
.auth-icon svg { width: 56px; height: 56px; }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; background: none; border: none; color: var(--text-muted);
  padding: 10px; font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: 0.04em; cursor: pointer; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--fuse-amber); border-bottom-color: var(--fuse-amber); }

.tab-panel { display: none; flex-direction: column; gap: 14px; }
.tab-panel.active { display: flex; }

label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 0.85rem; color: var(--text-muted);
}

input[type="text"], input[type="password"] {
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 1rem;
}

.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--text-muted); font-size: 0.8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.form-error { color: var(--danger-red); font-size: 0.85rem; min-height: 1em; }

#guestForm { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Hub ---------- */

.hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.hub-card {
  display: flex; flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: cardIn 0.4s ease backwards;
}
.hub-card:nth-child(1) { animation-delay: 0.05s; }
.hub-card:nth-child(2) { animation-delay: 0.12s; }
.hub-card:nth-child(3) { animation-delay: 0.19s; }
.hub-card:nth-child(4) { animation-delay: 0.26s; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.hub-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(var(--shadow-color), calc(var(--shadow-strength) * 1.1)); }
.hub-card .btn { margin-top: auto; }

.hub-icon {
  width: 40px; height: 40px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px; background: var(--bg-panel-raised);
}
.hub-icon svg { width: 22px; height: 22px; }

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-family: var(--font-mono);
  width: 130px;
}

/* ---------- Queue ---------- */

.queue-panel { max-width: 380px; margin: 60px auto; text-align: center; }

.pulse-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger-red); margin: 0 auto 20px;
  box-shadow: 0 0 0 0 rgba(255,77,77,0.6);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,77,77,0.55); }
  70% { box-shadow: 0 0 0 18px rgba(255,77,77,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,77,77,0); }
}

/* ---------- Lobby ---------- */

.lobby-panel { max-width: 460px; margin: 0 auto; }

.room-code-block {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px; background: var(--bg-panel-raised); border-radius: 8px; margin-bottom: 20px;
}
.room-code-block .label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.room-code { font-family: var(--font-mono); font-size: 2rem; letter-spacing: 0.15em; color: var(--fuse-amber); }

.player-list { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 8px; }
.player-list li {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-panel-raised); border-radius: 6px; padding: 10px 14px;
}
.player-list .host-tag { color: var(--fuse-amber); font-size: 0.75rem; text-transform: uppercase; }

/* ---------- Game arena ---------- */

.arena {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 420px;
}

.blast-ring-wrap { position: relative; width: 220px; height: 220px; }

.blast-ring { width: 100%; height: 100%; transform: rotate(-90deg); position: relative; z-index: 2; }
.blast-ring-track { fill: none; stroke: var(--border); stroke-width: 8; }
.blast-ring-fill {
  fill: none; stroke: var(--fuse-amber); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 565.48; stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s ease;
}

.bomb-graphic {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1;
}

.bomb-shadow { fill: rgba(0, 0, 0, 0.45); filter: blur(2px); }

.bomb-body {
  fill: #171d2c;
  stroke: #2a3348;
  stroke-width: 2;
  transition: fill 0.3s ease, stroke 0.3s ease, filter 0.3s ease;
}

.bomb-highlight { fill: rgba(255, 255, 255, 0.06); }

.bomb-rivet { fill: #0e1220; }

.bomb-fuse {
  stroke: #8a6a3f;
  stroke-width: 5;
  stroke-linecap: round;
}

.bomb-spark .spark-outer {
  fill: var(--fuse-amber);
  filter: drop-shadow(0 0 6px rgba(255, 162, 58, 0.7));
  animation: sparkFlicker 0.5s infinite alternate ease-in-out;
}

.bomb-spark .spark-inner {
  fill: #fff3d6;
  animation: sparkFlicker 0.35s infinite alternate-reverse ease-in-out;
}

@keyframes sparkFlicker {
  from { opacity: 0.65; transform: scale(0.85); transform-origin: 124px 18px; }
  to   { opacity: 1; transform: scale(1.15); transform-origin: 124px 18px; }
}

/* applied via JS when the turn timer is running low */
.blast-ring-wrap.critical .bomb-body {
  stroke: var(--danger-red);
  filter: drop-shadow(0 0 10px rgba(255, 77, 77, 0.45));
}
.blast-ring-wrap.critical .bomb-spark .spark-outer {
  fill: var(--danger-red);
  filter: drop-shadow(0 0 8px rgba(255, 77, 77, 0.8));
  animation-duration: 0.18s;
}
.blast-ring-wrap.critical .bomb-spark .spark-inner {
  animation-duration: 0.14s;
}

.bomb-core {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px;
  z-index: 3;
}

.prompt-chunk {
  font-family: var(--font-mono); font-size: 2.4rem; font-weight: 700;
  letter-spacing: 0.08em; color: var(--text-primary);
  text-shadow: 0 0 18px rgba(255, 162, 58, 0.35);
}

.typing-preview {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--safe-green);
  min-height: 1.2em;
  letter-spacing: 0.02em;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.player-ring {
  position: absolute; inset: 0;
  pointer-events: none;
}

.player-token {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 12px;
  background: linear-gradient(180deg, var(--bg-panel-raised), var(--bg-panel));
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 90px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(var(--shadow-color), calc(var(--shadow-strength) * 0.8));
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.player-token.active-turn {
  border-color: var(--fuse-amber);
  box-shadow: 0 0 0 2px rgba(255,162,58,0.25), 0 4px 16px rgba(255, 162, 58, 0.2);
}

.player-token.eliminated { opacity: 0.35; }

.player-token .name { font-weight: 600; font-size: 0.85rem; }
.player-token .lives { display: flex; gap: 3px; justify-content: center; }
.player-token .life-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--safe-green);
}
.player-token .life-dot.spent { background: var(--border); }

.hint-display {
  text-align: center; min-height: 1.2em; font-family: var(--font-mono); font-size: 1rem;
  letter-spacing: 0.1em; color: var(--fuse-amber); max-width: 420px; margin: 0 auto;
  white-space: pre-line; line-height: 1.5;
}
.hint-display:not(:empty) { font-size: 0.95rem; }

.word-form { display: flex; gap: 10px; max-width: 420px; margin: 12px auto 8px; }
.word-form input {
  flex: 1;
  background: var(--bg-panel-raised); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 6px; padding: 14px 16px; font-size: 1.1rem; font-family: var(--font-body);
}

.word-feedback {
  text-align: center; min-height: 1.4em; font-family: var(--font-mono); font-size: 0.9rem;
}
.word-feedback.error { color: var(--danger-red); }
.word-feedback.success { color: var(--safe-green); }

/* ---------- Results ---------- */

.results-panel { max-width: 460px; margin: 40px auto; }
.results-list { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 8px; }
.results-list li {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-panel-raised); border-radius: 6px; padding: 12px 16px;
  border: 1px solid transparent;
}
.results-list li.winner {
  border-color: var(--fuse-amber);
  box-shadow: 0 0 0 1px rgba(255, 162, 58, 0.2), 0 4px 14px rgba(255, 162, 58, 0.12);
}
.results-list .placement { font-family: var(--font-mono); color: var(--fuse-amber); width: 28px; }
.results-list .rating-delta.positive { color: var(--safe-green); }
.results-list .rating-delta.negative { color: var(--danger-red); }

/* ---------- Leaderboard ---------- */

.leaderboard-panel { max-width: 560px; margin: 0 auto; }
.leaderboard-table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 0.9rem; }
.leaderboard-table th {
  text-align: left; color: var(--text-muted); font-weight: 500; padding: 8px;
  border-bottom: 1px solid var(--border); text-transform: uppercase; font-size: 0.75rem;
}
.leaderboard-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.leaderboard-table tr:hover td { background: rgba(255, 255, 255, 0.02); }
.rank-medal { font-size: 1.1rem; }

/* ---------- Profile / persona ---------- */

.profile-panel { max-width: 640px; margin: 0 auto; }

.profile-layout { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 8px; }

.persona-preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: 0 0 160px; }
.persona-preview {
  width: 150px; height: 180px;
  background: var(--bg-panel-raised); border: 1px solid var(--border); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.persona-preview svg { width: 100%; height: 100%; }

.persona-controls { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 16px; }
.control-group { display: flex; flex-direction: column; gap: 8px; }
.control-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected { border-color: var(--text-primary); box-shadow: 0 0 0 2px var(--bg-panel), 0 0 0 4px var(--fuse-amber); }

.style-row { display: flex; gap: 8px; flex-wrap: wrap; }
.style-btn {
  background: var(--bg-panel-raised); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 6px; padding: 8px 12px; font-size: 0.85rem; cursor: pointer;
}
.style-btn.selected { border-color: var(--fuse-amber); color: var(--fuse-amber); }

.mini-persona {
  width: 26px; height: 26px; border-radius: 50%; overflow: hidden;
  background: var(--bg-panel-raised); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  cursor: pointer;
}
.mini-persona svg { width: 140%; height: 140%; }

.player-token .mini-persona { width: 36px; height: 36px; margin-bottom: 2px; cursor: default; }
.player-list .mini-persona { cursor: default; }
.player-list li { display: flex; align-items: center; gap: 10px; justify-content: flex-start; }
.player-list li .player-name-block { flex: 1; display: flex; justify-content: space-between; align-items: center; }

/* ---------- Emotes ---------- */

.emote-row {
  display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.emote-btn {
  background: none; border: none; font-size: 1.2rem; cursor: pointer;
  padding: 4px 6px; border-radius: 6px; line-height: 1; flex-shrink: 0;
  transition: background 0.12s ease, transform 0.12s ease;
}
.emote-btn:hover { background: var(--bg-panel-raised); transform: scale(1.15); }

.player-token, .player-list li { position: relative; overflow: visible; }

.emote-bubble {
  position: absolute;
  top: -6px; left: 50%;
  transform: translate(-50%, 0);
  font-size: 1.4rem;
  pointer-events: none;
  animation: emotePop 1.4s ease forwards;
  z-index: 5;
}

@keyframes emotePop {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.5); }
  15%  { opacity: 1; transform: translate(-50%, -14px) scale(1.15); }
  30%  { transform: translate(-50%, -18px) scale(1); }
  80%  { opacity: 1; transform: translate(-50%, -38px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -52px) scale(0.9); }
}

/* ---------- Chat ---------- */

.chat-toggle {
  display: none;
  position: fixed; bottom: 24px; right: 24px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--fuse-amber); color: #201400;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(var(--shadow-color), calc(var(--shadow-strength) * 1.4));
  z-index: 60;
  transition: transform 0.15s ease;
}
.chat-toggle:hover { transform: scale(1.06); }
.chat-toggle svg { width: 24px; height: 24px; }
.chat-toggle.hidden-when-no-room { display: none; }

.chat-badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--danger-red); color: #2a0000;
  font-size: 0.7rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

.chat-drawer {
  position: fixed; bottom: 24px; right: 24px;
  width: 300px; max-height: 420px;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(var(--shadow-color), calc(var(--shadow-strength) * 1.6));
  display: flex; flex-direction: column;
  z-index: 61;
  opacity: 0; transform: translateY(12px) scale(0.98); pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.chat-drawer.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.85rem;
}
.chat-close {
  background: none; border: none; color: var(--text-muted); font-size: 1.3rem;
  cursor: pointer; line-height: 1; padding: 0 4px;
}
.chat-close:hover { color: var(--text-primary); }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 10px 14px;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 120px; max-height: 300px;
}
.chat-message { font-size: 0.85rem; line-height: 1.4; }
.chat-message .who { color: var(--fuse-amber); font-weight: 600; margin-right: 4px; }
.chat-message.system { color: var(--text-muted); font-style: italic; }

.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-form input {
  flex: 1; background: var(--bg-panel-raised); border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 6px; padding: 8px 10px; font-size: 0.85rem; font-family: var(--font-body);
}

@media (max-width: 480px) {
  .chat-drawer { width: calc(100vw - 32px); right: 16px; bottom: 16px; }
  .chat-toggle { right: 16px; bottom: 16px; }
}

/* ---------- Game feel animations ---------- */

.shake { animation: shakeInput 0.4s ease; }
@keyframes shakeInput {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(3px); }
}

.hit-shake { animation: hitShake 0.45s ease; }
@keyframes hitShake {
  0%, 100% { transform: translate(-50%, -50%); }
  20% { transform: translate(calc(-50% - 4px), -50%); border-color: var(--danger-red); }
  40% { transform: translate(calc(-50% + 4px), -50%); }
  60% { transform: translate(calc(-50% - 3px), -50%); }
  80% { transform: translate(calc(-50% + 2px), -50%); }
}

.elimination-flash { animation: elimFlash 0.7s ease; }
@keyframes elimFlash {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0.8); }
  50% { box-shadow: 0 0 24px 8px rgba(255, 77, 77, 0.6); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 77, 0); }
}

.player-token.active-turn { animation: turnGlow 1.8s ease-in-out infinite; }
@keyframes turnGlow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255,162,58,0.25), 0 4px 16px rgba(255, 162, 58, 0.2); }
  50% { box-shadow: 0 0 0 3px rgba(255,162,58,0.4), 0 4px 20px rgba(255, 162, 58, 0.35); }
}
@media (prefers-reduced-motion: reduce) {
  .player-token.active-turn { animation: none; }
}

.results-panel.celebrate { animation: celebratePulse 1.6s ease 2; }
@keyframes celebratePulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(var(--shadow-color), var(--shadow-strength)); }
  50% { box-shadow: 0 8px 36px rgba(255, 162, 58, 0.35); }
}

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg-panel-raised); border: 1px solid var(--border); color: var(--text-primary);
  padding: 12px 20px; border-radius: 8px; font-size: 0.9rem;
  opacity: 0; pointer-events: none; transition: all 0.25s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .arena { min-height: 340px; }
  .blast-ring-wrap { width: 170px; height: 170px; }
  .prompt-chunk { font-size: 1.8rem; }
}
