/* ============================================================
   TOP 100 — tight modern build
   ============================================================ */

:root {
  --bg-0: #07021a;
  --bg-1: #0f0529;
  --bg-2: #1a0b3d;
  --ink: #f5f3ff;
  --ink-muted: #9a93c0;
  --ink-dim: #6b6395;

  --magenta: #ff2e88;
  --cyan: #06d6f9;
  --lime: #b8ff5c;
  --amber: #ffb627;
  --violet: #8b5cf6;

  --good: #b8ff5c;
  --bad: #ff5470;

  --surface: rgba(20, 12, 48, 0.55);
  --surface-strong: rgba(28, 15, 60, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-bright: rgba(255, 255, 255, 0.18);

  --shadow-card: 0 12px 32px -16px rgba(0, 0, 0, 0.6);

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 12px;
  --radius-lg: 16px;

  --easing: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100vh;
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { background: var(--bg-0); overflow-x: hidden; }

/* ---------- Background ---------- */

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(at 0% 100%, rgba(139, 92, 246, 0.18) 0%, transparent 50%),
    radial-gradient(at 100% 0%, rgba(255, 46, 136, 0.15) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 60%, var(--bg-2) 100%);
  overflow: hidden;
}
.blob {
  position: absolute;
  width: 50vmax;
  height: 50vmax;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  mix-blend-mode: screen;
  pointer-events: none;
}
.blob-1 { top: -20vmax; left: -20vmax; background: radial-gradient(circle, var(--magenta) 0%, transparent 65%); animation: drift-1 22s var(--easing) infinite alternate; }
.blob-2 { bottom: -20vmax; right: -15vmax; background: radial-gradient(circle, var(--cyan) 0%, transparent 65%); animation: drift-2 28s var(--easing) infinite alternate; }
.blob-3 { top: 30vh; left: 50vw; width: 40vmax; height: 40vmax; background: radial-gradient(circle, var(--violet) 0%, transparent 65%); animation: drift-3 35s var(--easing) infinite alternate; }

@keyframes drift-1 { 0% { transform: translate(0,0) scale(1); } 100% { transform: translate(18vw,14vh) scale(1.15); } }
@keyframes drift-2 { 0% { transform: translate(0,0) scale(1.1); } 100% { transform: translate(-14vw,-10vh) scale(0.9); } }
@keyframes drift-3 { 0% { transform: translate(0,0) scale(0.95); } 100% { transform: translate(-12vw,18vh) scale(1.2); } }

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,0.022) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
  opacity: 0.5;
}

/* ---------- Reset ---------- */

button, input, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.app {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 20px 20px 48px;
}
@media (max-width: 640px) { .app { padding: 14px 12px 60px; } }

.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 999; }

/* ---------- Type ---------- */

.muted { color: var(--ink-muted); font-size: 0.92em; }
.empty {
  text-align: center;
  color: var(--ink-muted);
  padding: 22px;
  font-style: italic;
  font-size: 0.92em;
}

/* ---------- Avatar ---------- */

.avatar {
  width: var(--size, 24px);
  height: var(--size, 24px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 50%, #1a0a30));
  color: #fff;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-size: calc(var(--size, 24px) * 0.46);
  letter-spacing: -0.02em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 6px color-mix(in srgb, var(--c) 30%, transparent);
  flex-shrink: 0;
  transition: transform 0.15s var(--easing);
}

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

.btn {
  padding: 8px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.92em;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: transform 0.12s var(--easing), background 0.18s var(--easing), border-color 0.18s var(--easing), box-shadow 0.2s var(--easing);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }

.btn-primary {
  background: linear-gradient(135deg, var(--magenta) 0%, var(--amber) 100%);
  background-clip: padding-box;
  -webkit-background-clip: padding-box;
  color: #1a0a30;
  font-weight: 700;
  border-color: transparent;
  box-shadow: 0 2px 10px -4px rgba(0, 0, 0, 0.4);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -4px rgba(0, 0, 0, 0.5);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-bright);
  color: var(--ink);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.28);
}

.btn-small { padding: 6px 12px; font-size: 0.86em; }
.btn-large { padding: 12px 22px; font-size: 1em; }

.btn-glow { position: relative; overflow: hidden; }
.btn-glow::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  transform: translateX(-100%);
  animation: shimmer 3.5s var(--easing) infinite;
}
@keyframes shimmer {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
  100% { transform: translateX(100%); }
}

.btn-arrow { transition: transform 0.2s var(--easing); }
.btn:hover .btn-arrow { transform: translateX(3px); }

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  transition: all 0.15s var(--easing);
  font-size: 0.92em;
}
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-bright);
}
.icon-btn-danger {
  background: rgba(255, 84, 112, 0.08);
  border-color: rgba(255, 84, 112, 0.3);
  color: var(--bad);
}
.icon-btn-danger:hover { background: rgba(255, 84, 112, 0.2); }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.card-header,
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.card-header h2,
.panel-header h2 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.badge-selected {
  background: linear-gradient(135deg, rgba(255, 46, 136, 0.15), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(255, 46, 136, 0.3);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75em;
  font-weight: 600;
  color: var(--ink);
}

/* ---------- Start screen ---------- */

.start-screen {
  max-width: 940px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.start-header {
  text-align: center;
  padding: 12px 0 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  width: 50px;
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--magenta), var(--amber));
  color: #1a0a30;
  letter-spacing: -0.04em;
  box-shadow: 0 8px 24px -8px rgba(255, 46, 136, 0.55);
}

.brand-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.95;
}
.brand-accent {
  background: linear-gradient(135deg, var(--magenta), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}


.start-card { padding: 16px; }
.start-card h2 { font-size: 0.82em; margin-bottom: 0; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}

.category-tile {
  position: relative;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: all 0.18s var(--easing);
  overflow: hidden;
  font-size: 0.92em;
}
.category-tile.fresh {
  opacity: 0;
  animation: tile-in 0.32s var(--easing) forwards;
  animation-delay: calc(var(--i, 0) * 14ms);
}
@keyframes tile-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.category-tile:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
}
.category-tile.selected {
  background: linear-gradient(135deg, rgba(255, 46, 136, 0.12), rgba(139, 92, 246, 0.12));
  border-color: var(--magenta);
  box-shadow: inset 0 0 0 1px var(--magenta), 0 6px 16px -8px rgba(255, 46, 136, 0.4);
}
.category-tile-name { font-weight: 500; }
.category-tile-arrow {
  color: var(--ink-muted);
  opacity: 0.35;
  transition: transform 0.2s var(--easing), opacity 0.2s var(--easing);
}
.category-tile:hover .category-tile-arrow,
.category-tile.selected .category-tile-arrow {
  opacity: 1;
  transform: translateX(3px);
  color: var(--ink);
}

.teams-editor { display: flex; flex-direction: column; gap: 6px; }

.team-edit-row {
  display: grid;
  grid-template-columns: 36px 1fr 32px;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  transition: border-color 0.18s var(--easing);
}
.team-edit-row:focus-within { border-color: var(--team-color, var(--magenta)); }

.team-color-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: transform 0.15s var(--easing), background 0.15s var(--easing);
}
.team-color-btn:hover { background: rgba(255, 255, 255, 0.06); }
.team-color-btn:hover .avatar { transform: rotate(8deg) scale(1.05); }

.team-name-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-weight: 600;
  font-size: 0.95em;
  width: 100%;
  transition: border-color 0.15s var(--easing), background 0.15s var(--easing);
}
.team-name-input:focus {
  outline: none;
  border-color: var(--team-color, var(--magenta));
  background: rgba(0, 0, 0, 0.22);
}

.start-actions { display: flex; justify-content: center; padding: 4px; }

/* ---------- Game screen layout ---------- */

.game-screen { display: grid; gap: 12px; }

.game-main {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 12px;
  align-items: start;
}

@media (max-width: 920px) {
  .game-main { grid-template-columns: 1fr; }
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
}

.logo-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 3px;
  border-radius: 10px;
  transition: background 0.15s var(--easing);
  flex-shrink: 0;
}
.logo-btn:hover { background: rgba(255, 255, 255, 0.06); }

.logo-mark {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--magenta), var(--amber));
  color: #1a0a30;
  letter-spacing: -0.04em;
}

.logo-text {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 0.92em;
}
@media (max-width: 640px) { .logo-text { display: none; } }

.topbar-title {
  flex: 1;
  min-width: 0;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 0.95em;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}

.topbar-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ---------- Teams panel (leaderboard) ---------- */

.teams-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 12px;
}

.teams-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
}
.team-row-wrap { list-style: none; }

.team-card {
  --team-color: var(--violet);
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s var(--easing), border-color 0.18s var(--easing), background 0.18s var(--easing), box-shadow 0.25s var(--easing);
  text-align: left;
  overflow: hidden;
  isolation: isolate;
}
.team-card:hover {
  border-color: var(--team-color);
  background: rgba(255, 255, 255, 0.05);
}
.team-card.selected {
  border-color: var(--team-color);
  background: color-mix(in srgb, var(--team-color) 10%, transparent);
  box-shadow: inset 0 0 0 1px var(--team-color), 0 8px 24px -12px var(--team-color);
}

.team-card-glow {
  position: absolute;
  top: -50%;
  right: -40%;
  width: 90%;
  height: 200%;
  background: radial-gradient(ellipse at center, var(--team-color), transparent 60%);
  filter: blur(36px);
  opacity: 0;
  transition: opacity 0.3s var(--easing);
  pointer-events: none;
  z-index: -1;
}
.team-card.selected .team-card-glow { opacity: 0.4; }

.team-card-name {
  font-weight: 600;
  font-size: 0.92em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-card-score {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.25em;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.04em;
}

.score-bump { animation: score-bump 0.5s var(--easing); }
@keyframes score-bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.22); filter: brightness(1.4); }
  100% { transform: scale(1); }
}

.team-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background: transparent;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 0.88em;
  transition: all 0.18s var(--easing);
}
.team-add-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(6, 214, 249, 0.05);
}
.team-add-plus { font-size: 1.1em; line-height: 1; }

/* ---------- Stage ---------- */

.stage {
  --active-color: var(--violet);
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px 18px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px) saturate(140%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.3s var(--easing), box-shadow 0.3s var(--easing);
  overflow: hidden;
  min-height: 280px;
}
.stage.team-active {
  border-color: color-mix(in srgb, var(--active-color) 50%, transparent);
  box-shadow: var(--shadow-card), 0 0 60px -16px var(--active-color);
}
.stage::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--active-color), transparent);
  opacity: 0;
  transition: opacity 0.4s var(--easing);
}
.stage.team-active::before { opacity: 0.7; }

.stage-status {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  min-height: 36px;
  justify-content: center;
}
.stage-status .muted {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
}
.stage-team {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.2em;
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1;
}
.stage-hint {
  color: var(--ink-muted);
  font-style: italic;
  font-size: 0.95em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.stage-hint-arrow {
  display: inline-block;
  animation: nudge 1.6s var(--easing) infinite;
  color: var(--cyan);
  font-style: normal;
}
@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-5px); }
}

.answer-form {
  display: flex;
  gap: 8px;
  width: 100%;
}

.answer-input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 0.98em;
  font-weight: 500;
  transition: border-color 0.18s var(--easing), background 0.18s var(--easing), box-shadow 0.2s var(--easing);
}
.answer-input::placeholder { color: var(--ink-dim); }
.answer-input:focus {
  outline: none;
  border-color: var(--active-color);
  background: rgba(0, 0, 0, 0.42);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--active-color) 18%, transparent);
}
.answer-input:disabled { opacity: 0.4; }

.answer-form .btn { padding: 11px 20px; font-size: 0.94em; }

/* result */

.result-slot {
  display: flex;
  align-items: stretch;
  min-height: 56px;
}

.result-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.95em;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.result-banner.fresh { animation: result-pop 0.4s var(--easing); }
@keyframes result-pop {
  0% { transform: scale(0.94); opacity: 0; }
  60% { transform: scale(1.02); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.result-banner.placeholder {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border);
  color: var(--ink-dim);
  justify-content: center;
  font-style: italic;
  font-size: 0.88em;
  animation: none;
}

.result-banner.hit {
  background: linear-gradient(135deg, rgba(184, 255, 92, 0.1), color-mix(in srgb, var(--team-color, var(--lime)) 18%, transparent));
  border: 1px solid color-mix(in srgb, var(--team-color, var(--lime)) 45%, transparent);
}
.result-banner.miss {
  background: linear-gradient(135deg, rgba(255, 84, 112, 0.12), rgba(255, 84, 112, 0.03));
  border: 1px solid rgba(255, 84, 112, 0.4);
}

.result-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}
.result-icon svg { display: block; }
.result-banner.hit .result-icon { color: #0a1a05; background: var(--good); }
.result-banner.miss .result-icon { color: #2a0510; background: var(--bad); }

.result-text { flex: 1; min-width: 0; }
.result-main { font-size: 1em; font-weight: 600; line-height: 1.25; }
.result-main .rank {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 1.05em;
  background: linear-gradient(135deg, var(--magenta), var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-points {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.4em;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--amber);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.shake { animation: shake 0.45s var(--easing); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* progress */

.progress-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}
.progress-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--magenta), var(--amber));
  border-radius: 999px;
  transition: width 0.6s var(--easing);
  box-shadow: 0 0 10px rgba(255, 46, 136, 0.5);
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.78em;
}
.progress-label {
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}
.progress-count {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.progress-divider { color: var(--ink-dim); margin: 0 1px; }

/* ---------- History ---------- */

.history-panel { padding: 12px 14px; }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 3px;
}
.history-list::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }

.history-entry {
  --team-color: var(--violet);
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 2fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.88em;
  transition: background 0.15s var(--easing);
}
.history-entry.fresh { animation: entry-in 0.28s var(--easing); }
@keyframes entry-in {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: translateX(0); }
}
.history-entry:hover { background: rgba(255, 255, 255, 0.04); }

.hist-team {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--team-color);
}
.hist-team > span:last-child { color: var(--ink); }

.hist-item {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-item .rank {
  background: linear-gradient(135deg, var(--magenta), var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
  font-family: 'Bricolage Grotesque', sans-serif;
}

.hist-points {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 36px;
  text-align: right;
}

.hist-remove {
  width: 24px;
  height: 24px;
  font-size: 0.78em;
  opacity: 0.5;
}
.hist-remove:hover { opacity: 1; }

/* ---------- Confetti ---------- */

.confetti {
  position: fixed;
  width: 7px;
  height: 11px;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  animation: confetti var(--dur, 900ms) cubic-bezier(0.2, 0.8, 0.4, 1) forwards;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
}
@keyframes confetti {
  0% { transform: translate(-50%, -50%) rotate(0) scale(0.8); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) rotate(var(--r)) scale(1); opacity: 0; }
}

/* ---------- Responsive ---------- */

@media (max-width: 920px) {
  .teams-panel { position: static; }
  .teams-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .topbar-title {
    order: 3;
    flex-basis: 100%;
    padding: 4px 4px 0;
  }
  .topbar-actions { margin-left: auto; }
  .stage { padding: 14px 14px 12px; min-height: auto; }
  .answer-form { flex-direction: column; }
  .answer-input { font-size: 0.96em; padding: 10px 12px; }
  .answer-form .btn { padding: 10px 20px; }
  .stage-team { font-size: 1.1em; }
  .category-grid { grid-template-columns: 1fr 1fr; }
  .history-entry { grid-template-columns: 1fr auto auto; }
  .history-entry .hist-item {
    grid-column: 1 / -1;
    order: 3;
  }
}

@media (max-width: 480px) {
  .category-grid { grid-template-columns: 1fr; }
  .teams-list { grid-template-columns: 1fr 1fr; }
  .team-card-score { font-size: 1.1em; }
  .result-points { font-size: 1.2em; }
  .brand-mark { width: 44px; height: 44px; font-size: 0.95rem; }
}

/* ============================================================
   Toasts
   ============================================================ */

.toast-root {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1100;
  pointer-events: none;
  width: max-content;
  max-width: calc(100% - 24px);
}

.toast {
  pointer-events: auto;
  background: var(--surface-strong);
  border: 1px solid var(--border-bright);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.94em;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s var(--easing), transform 0.2s var(--easing);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-warn { border-color: rgba(255, 182, 39, 0.5); background: linear-gradient(135deg, rgba(255, 182, 39, 0.18), var(--surface-strong)); }
.toast-error { border-color: rgba(255, 84, 112, 0.6); color: var(--ink); }
.toast-success { border-color: rgba(184, 255, 92, 0.5); }

/* ============================================================
   Modals
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 2, 26, 0.72);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  opacity: 0;
  transition: opacity 0.2s var(--easing);
  padding: 20px;
}
.modal-backdrop.show { opacity: 1; }

.modal {
  background: linear-gradient(180deg, var(--surface-strong), rgba(20, 12, 48, 0.92));
  border: 1px solid var(--border-bright);
  border-radius: 20px;
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 64px -20px rgba(0, 0, 0, 0.7);
  transform: scale(0.96);
  transition: transform 0.22s var(--easing);
}
.modal-backdrop.show .modal { transform: scale(1); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.3em;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.modal-subtitle {
  color: var(--ink-muted);
  font-size: 0.88em;
  margin-top: 2px;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
}
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 3px; }

.modal-footer {
  padding: 14px 20px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 22px;
  font-size: 0.96em;
  line-height: 1.5;
}
.rules-list li::marker {
  color: var(--ink-muted);
  font-weight: 700;
}
.rules-tip {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(255, 215, 0, 0.06);
  border: 1px solid rgba(255, 182, 39, 0.25);
  border-radius: 10px;
  color: var(--ink-muted);
  font-size: 0.9em;
}
.rules-tip em { color: var(--ink); font-style: normal; font-weight: 600; }

/* Reveal modal */

.reveal-body { padding: 8px 12px 16px; }
.reveal-list {
  list-style: none;
  display: grid;
  gap: 2px;
}
.reveal-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.92em;
  border-left: 2px solid transparent;
}
.reveal-row:nth-child(odd) { background: rgba(255, 255, 255, 0.02); }
.reveal-row.found { border-left-color: var(--good); }
.reveal-row.missed { opacity: 0.55; }
.reveal-rank {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  background: linear-gradient(135deg, var(--magenta), var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.reveal-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reveal-by {
  font-size: 0.82em;
  color: var(--ink-muted);
}

/* ============================================================
   Settings (start screen)
   ============================================================ */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  padding: 6px 0;
}

.settings-hint {
  margin-top: 8px;
  font-size: 0.85em;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative;
  width: 38px;
  height: 22px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  transition: background 0.18s var(--easing), border-color 0.18s var(--easing);
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.18s var(--easing);
}
.switch input:checked + .switch-track {
  background: linear-gradient(135deg, var(--magenta), var(--amber));
  border-color: transparent;
}
.switch input:checked + .switch-track::after { transform: translateX(16px); background: #fff; }
.switch-label { font-weight: 600; font-size: 0.96em; }

.duration-picker {
  display: inline-flex;
  gap: 6px;
}
.duration-picker.disabled { opacity: 0.45; }
.duration-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 0.88em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: all 0.15s var(--easing);
}
.duration-chip:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-bright);
}
.duration-chip.selected {
  background: linear-gradient(135deg, rgba(255, 46, 136, 0.2), rgba(255, 182, 39, 0.2));
  border-color: var(--magenta);
  color: var(--ink);
}

/* ============================================================
   Timer strip (in stage)
   ============================================================ */

.timer-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}
.timer-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--magenta), var(--amber));
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(255, 46, 136, 0.45);
  transition: width 0.1s linear;
}
.timer-text {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.9em;
  color: var(--ink-muted);
  min-width: 42px;
  text-align: right;
}

/* ============================================================
   Language toggle
   ============================================================ */

.lang-toggle-wrap {
  position: absolute;
  top: 0;
  right: 0;
}
.start-header { position: relative; }

.lang-toggle {
  display: inline-flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
}
.lang-opt {
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.78em;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  transition: color 0.15s var(--easing), background 0.15s var(--easing);
}
.lang-opt:hover { color: var(--ink); }
.lang-opt.active {
  background: linear-gradient(135deg, var(--magenta), var(--amber));
  color: #1a0a30;
  box-shadow: 0 2px 8px -3px rgba(255, 46, 136, 0.5);
}

.topbar-actions .lang-toggle {
  margin-right: 4px;
}

@media (max-width: 540px) {
  .lang-toggle-wrap { position: static; margin-bottom: 8px; }
  .topbar-actions .lang-toggle { order: -1; }
}

/* ---------- Boot loading ---------- */
.boot-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 60vh;
  color: var(--ink-muted);
}
.boot-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--magenta);
  animation: boot-spin 0.8s linear infinite;
}
@keyframes boot-spin { to { transform: rotate(360deg); } }

/* ---------- Card header actions + suggest button ---------- */
.card-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- Suggest a category modal ---------- */
.submit-body { max-height: 70vh; }
.submit-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.submit-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.submit-label {
  font-size: 0.82em;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.submit-counter {
  font-variant-numeric: tabular-nums;
  font-size: 0.92em;
  color: var(--ink-dim);
  white-space: nowrap;
}
.submit-counter.ok { color: var(--good); }
.submit-input,
.submit-textarea {
  width: 100%;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  transition: border-color 0.15s var(--easing);
}
.submit-input:focus,
.submit-textarea:focus {
  outline: none;
  border-color: var(--border-bright);
}
.submit-textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.5;
  font-family: inherit;
}

/* ---------- Moderation dashboard ---------- */
.dash {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}
.dash-login {
  max-width: 420px;
  margin: 12vh auto 0;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dash-login form { display: flex; flex-direction: column; gap: 12px; }
.dash-error { color: var(--bad); font-size: 0.9em; }
.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.dash-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.dash-tab {
  text-transform: capitalize;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s var(--easing);
}
.dash-tab.active {
  color: #1a0a30;
  background: linear-gradient(135deg, var(--magenta), var(--amber));
  border-color: transparent;
}
.dash-list { display: flex; flex-direction: column; gap: 16px; }
.dash-card { padding: 18px 20px; }
.dash-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.dash-card-header h3 { margin: 0 0 2px; }
.dash-tag {
  font-size: 0.7em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-strong);
  vertical-align: middle;
}
.dash-status {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.dash-status-pending { background: rgba(255, 182, 39, 0.2); color: var(--amber); }
.dash-status-accepted { background: rgba(184, 255, 92, 0.18); color: var(--good); }
.dash-status-rejected { background: rgba(255, 84, 112, 0.18); color: var(--bad); }
.dash-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.85em; margin: 8px 0 4px; }
.dash-details { margin: 10px 0; }
.dash-details summary { cursor: pointer; color: var(--ink-muted); font-size: 0.88em; }
.dash-items {
  list-style: none;
  margin: 10px 0 0;
  padding: 10px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface-strong);
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 16px;
}
.dash-item { font-size: 0.86em; padding: 2px 0; }
.dash-item-rank { color: var(--ink-dim); font-variant-numeric: tabular-nums; margin-right: 4px; }
.dash-card-actions { display: flex; gap: 10px; margin-top: 12px; }
@media (max-width: 560px) {
  .dash-items { grid-template-columns: 1fr; }
}
