@import url('https://fonts.googleapis.com/css2?family=Aleo:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400&display=swap');

:root {
  /* Backgrounds */
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-2: #F1EEE8;

  /* Borders */
  --border: #E3DDD5;

  /* Primary — Red */
  --red: #C41E3A;
  --red-dim: rgba(196, 30, 58, 0.08);
  --red-badge: rgba(196, 30, 58, 0.15);

  /* Blue */
  --blue: #1E4DB7;
  --blue-dim: rgba(30, 77, 183, 0.08);
  --blue-badge: rgba(30, 77, 183, 0.15);

  /* Orange */
  --orange: #C44B0B;
  --orange-dim: rgba(196, 75, 11, 0.08);
  --orange-badge: rgba(196, 75, 11, 0.15);

  /* Green */
  --green: #1A7842;
  --green-dim: rgba(26, 120, 66, 0.08);
  --green-badge: rgba(26, 120, 66, 0.15);

  /* Text */
  --text: #1A1917;
  --text-dim: #4F4A45;
  --text-muted: #6D6660;

  /* Typography */
  --font-body: 'Aleo', serif;
  --font-display: 'Aleo', serif;

  /* Shape */
  --radius: 6px;
  --radius-lg: 14px;

  /* Nav */
  --nav-bg: rgba(247, 245, 240, 0.94);
}

[data-theme="dark"] {
  --bg: #14120F;
  --surface: #1E1B17;
  --surface-2: #2A2520;
  --border: #3A342D;
  --red-dim: rgba(196, 30, 58, 0.12);
  --red-badge: rgba(196, 30, 58, 0.20);
  --blue-dim: rgba(30, 77, 183, 0.12);
  --blue-badge: rgba(30, 77, 183, 0.20);
  --orange-dim: rgba(196, 75, 11, 0.12);
  --orange-badge: rgba(196, 75, 11, 0.20);
  --green-dim: rgba(26, 120, 66, 0.12);
  --green-badge: rgba(26, 120, 66, 0.20);
  --text: #F2EDE6;
  --text-dim: #B8AFA6;
  --text-muted: #8A8078;
  --nav-bg: rgba(20, 18, 15, 0.94);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Typography ──────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

a { color: inherit; text-decoration: none; }

/* ── Logo ──────────────────────────────────────────────────────────────── */

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  color: var(--text);
  display: inline-block;
}

.logo span {
  color: var(--red);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--red);
}

/* ── Nav ────────────────────────────────────────────────────────────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-actions { display: flex; gap: 10px; align-items: center; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all 0.15s ease;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn-primary {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-primary:hover { background: #a81830; border-color: #a81830; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--text-muted); background: var(--surface-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-green {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  font-weight: 600;
}
.btn-green:hover { background: #145f34; }

.btn-lg {
  padding: 13px 32px;
  font-size: 15px;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }

/* ── Hero ──────────────────────────────────────────────────────────────── */

.hero {
  padding: 100px 40px 72px;
  max-width: 860px;
  margin: 0 auto;
  text-align: center;
  animation: fadeUp 0.6s ease both;
}

.hero-eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red);
  border: 1.5px solid var(--red);
  background: var(--red-badge);
  padding: 4px 14px;
  border-radius: 99px;
  margin-bottom: 28px;
}

.hero h1 {
  font-size: clamp(2.8rem, 7vw, 6rem);
  color: var(--text);
  margin-bottom: 24px;
  font-weight: 700;
}

.hero h1 .strike {
  color: var(--red);
  text-decoration: line-through;
  text-decoration-thickness: 4px;
}

.hero h1 .correct {
  color: var(--green);
}

.hero-sub {
  font-size: 16px;
  color: var(--text-dim);
  max-width: 500px;
  margin: 0 auto 40px;
  line-height: 1.7;
  font-style: italic;
}

.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ── Game Configurator ───────────────────────────────────────────────────── */

.configurator {
  max-width: 660px;
  margin: 0 auto 72px;
  padding: 0 40px;
  animation: fadeUp 0.6s 0.1s ease both;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.card-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.config-section { margin-bottom: 28px; }

.config-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
  font-weight: 500;
}

/* Difficulty toggle */
.difficulty-group { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.diff-btn {
  padding: 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  color: var(--text);
  font-family: var(--font-body);
}

.diff-btn .diff-name {
  font-size: 14px;
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}

.diff-btn .diff-desc {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.diff-btn.active { border-color: var(--red); background: var(--red-badge); color: var(--text); }
.diff-btn:hover:not(.active) { border-color: var(--text-muted); }

/* Error type chips */
.error-types { display: flex; flex-wrap: wrap; gap: 8px; }

.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text-dim);
  transition: all 0.15s;
  user-select: none;
}

.type-chip input { display: none; }
.type-chip.active { border-color: var(--green); background: var(--green-badge); color: var(--green); }
.type-chip:hover:not(.active) { border-color: var(--text-muted); color: var(--text); }

/* Source toggle */
.source-toggle { display: flex; gap: 8px; }

.source-btn {
  flex: 1;
  padding: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-dim);
  transition: all 0.15s;
}
.source-btn.active { border-color: var(--text-dim); color: var(--text); background: var(--surface); }

.config-actions { display: flex; gap: 10px; margin-top: 28px; }
.config-actions .btn { flex: 1; justify-content: center; }

/* ── Leaderboard ─────────────────────────────────────────────────────────── */

.leaderboard-section {
  max-width: 780px;
  margin: 0 auto 100px;
  padding: 0 40px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
}

.filter-tabs { display: flex; gap: 4px; }

.filter-tab {
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12px;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  transition: all 0.15s;
}
.filter-tab.active { background: var(--surface); border-color: var(--text-muted); color: var(--text); }

.leaderboard-table { width: 100%; border-collapse: collapse; }

.leaderboard-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--border);
}

.leaderboard-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.lb-rank {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  width: 40px;
}

.lb-rank.top-1 { color: #A07800; }
.lb-rank.top-2 { color: #707070; }
.lb-rank.top-3 { color: #8B4513; }

.lb-user { display: flex; align-items: center; gap: 12px; }
.lb-avatar { width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--border); }
.lb-username { font-size: 14px; font-weight: 500; }
.lb-score { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; color: var(--green); }
.lb-games { color: var(--text-dim); font-size: 13px; }

.leaderboard-table tr:hover td { background: var(--surface-2); }

/* ── Footer ─────────────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border);
  padding: 24px 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.05em;
}

/* ── Game Page ────────────────────────────────────────────────────────────── */

.game-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 24px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px;
}

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

.game-main { min-width: 0; }
.game-sidebar { position: sticky; top: 80px; height: fit-content; }

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.game-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}

.progress-bar-wrap {
  background: var(--surface-2);
  border-radius: 99px;
  height: 5px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--orange));
  border-radius: 99px;
  transition: width 0.3s ease;
}

.progress-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}

/* Text display */
.text-display {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 2.1;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* Clickable words in game */
.word-selectable {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.12s;
  padding: 1px 2px;
}

.word-selectable:hover {
  background: var(--surface-2);
}

/* Corrected word badge — blue */
.word-selectable.corrected,
.error-word.corrected {
  background: var(--blue-badge);
  border: 1.5px solid var(--blue);
  border-radius: 99px;
  color: var(--blue);
  padding: 1px 9px;
  text-decoration: none !important;
  cursor: pointer;
  font-style: normal;
}

.word-selectable.corrected:hover,
.error-word.corrected:hover {
  background: rgba(30, 77, 183, 0.68);
  animation: none;
}

/* Error word highlight */
.error-word {
  color: var(--red);
  text-decoration: underline wavy var(--red);
  text-decoration-thickness: 1.5px;
  cursor: pointer;
  border-radius: 3px;
  padding: 0 2px;
  transition: background 0.15s;
  position: relative;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

.error-word:hover {
  background: var(--red-dim);
  animation: shake 0.3s ease;
}

/* Correction popup */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.48);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.popup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 380px;
  max-width: 90vw;
  animation: popIn 0.2s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.popup-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.popup-word {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 20px;
}

.popup-input {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 11px 16px;
  margin-bottom: 16px;
  outline: none;
  transition: border-color 0.15s;
}

.popup-input:focus { border-color: var(--blue); }
.popup-actions { display: flex; gap: 8px; }
.popup-actions .btn { flex: 1; }

/* Sidebar stats */
.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.stat-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; }
.stat-value.red { color: var(--red); }
.stat-value.green { color: var(--green); }

/* Timer */
.timer {
  text-align: center;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.timer-value {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  transition: color 0.3s;
}

.timer-value.urgent { color: var(--red); }
.timer-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 6px; }

/* ── Results ──────────────────────────────────────────────────────────────── */

.results {
  max-width: 820px;
  margin: 0 auto;
  padding: 48px 24px;
}

.score-display {
  text-align: center;
  margin-bottom: 48px;
}

.score-big {
  font-family: var(--font-display);
  font-size: 7rem;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, var(--red), var(--orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-label {
  font-size: 15px;
  color: var(--text-dim);
  margin-top: 10px;
  font-style: italic;
}

/* ── Result Badges (text-based results view) ─────────────────────────────── */

.results-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 24px;
  padding: 14px 20px;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.results-legend-title {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  margin-right: 4px;
}

.results-legend .result-badge {
  cursor: default;
}

.result-badge {
  display: inline;
  padding: 1px 9px;
  border-radius: 99px;
  border: 1.5px solid;
  position: relative;
  cursor: help;
  font-style: normal;
  white-space: nowrap;
}

.badge-result-red    { background: var(--red-badge);    border-color: var(--red);    color: var(--red);    }
.badge-result-orange { background: var(--orange-badge);  border-color: var(--orange);  color: var(--orange);  }
.badge-result-green  { background: var(--green-badge);  border-color: var(--green);  color: var(--green);  }
.badge-result-blue   { background: var(--blue-badge);   border-color: var(--blue);   color: var(--blue);   }

/* Tooltip */
.result-tooltip {
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  min-width: 240px;
  max-width: 300px;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  text-align: left;
  white-space: normal;
}

.result-badge:hover .result-tooltip {
  opacity: 1;
}

.tooltip-row {
  display: flex;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  align-items: flex-start;
  line-height: 1.4;
}

.tooltip-label {
  color: var(--text-muted);
  min-width: 80px;
  flex-shrink: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 2px;
  font-weight: 500;
}

.tooltip-divider {
  display: block;
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

/* ── Badges (profile history table) ─────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  border: 1.5px solid;
}

.badge-easy   { background: var(--green-badge);  border-color: var(--green);  color: var(--green);  }
.badge-medium { background: var(--orange-badge);  border-color: var(--orange);  color: var(--orange);  }
.badge-hard   { background: var(--red-badge);    border-color: var(--red);    color: var(--red);    }

/* ── VS Page ─────────────────────────────────────────────────────────────── */

.vs-setup {
  max-width: 580px;
  margin: 80px auto;
  padding: 0 24px;
  text-align: center;
}

.vs-title {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.vs-sep { color: var(--red); font-weight: 700; }

.vs-options { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 40px; }

@media (max-width: 500px) { .vs-options { grid-template-columns: 1fr; } }

.room-code-display {
  font-family: var(--font-display);
  font-size: 3.2rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--green);
  padding: 20px;
  border: 1.5px dashed var(--green);
  border-radius: var(--radius-lg);
  margin: 20px 0;
}

.vs-game {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  padding: 16px;
  gap: 16px;
}

.vs-scores {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
}

.vs-player {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.vs-player.me { border-color: var(--green); }
.vs-player-name { font-size: 13px; color: var(--text-dim); flex: 1; }
.vs-player-score { font-family: var(--font-display); font-size: 2rem; font-weight: 700; }
.vs-player.me .vs-player-score { color: var(--green); }

.vs-center { text-align: center; }

.vs-finish-screen {
  position: fixed;
  inset: 0;
  background: rgba(247, 245, 240, 0.96);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
}

.winner-label {
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.winner-name {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
}

/* ── Profile Page ─────────────────────────────────────────────────────────── */

.profile-layout {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 24px;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 40px;
}

.profile-avatar { width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--border); }
.profile-name { font-family: var(--font-display); font-size: 2rem; font-weight: 700; }
.profile-since { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.stat-card-value { font-family: var(--font-display); font-size: 2.5rem; font-weight: 700; color: var(--text); }
.stat-card-label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 32px;
  height: 280px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.history-table { width: 100%; border-collapse: collapse; }

.history-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--border);
}

.history-table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; }

/* ── Modal ─────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.48);
  backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 420px;
  max-width: 90vw;
  animation: popIn 0.2s ease;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.modal-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; margin-bottom: 24px; }
.modal-close { float: right; cursor: pointer; color: var(--text-muted); font-size: 20px; line-height: 1; margin-top: -4px; transition: color 0.15s; }
.modal-close:hover { color: var(--text); }

.form-group { margin-bottom: 16px; }

.form-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  display: block;
  font-weight: 500;
  text-transform: uppercase;
}

.form-input {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--blue); }
.form-error { font-size: 12px; color: var(--red); margin-top: 8px; }

/* ── Notifications ─────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 13px;
  z-index: 9000;
  animation: toastIn 0.3s ease;
  max-width: 320px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.toast.success { border-color: var(--green); color: var(--green); }
.toast.error { border-color: var(--red); color: var(--red); }

/* ── Animations ─────────────────────────────────────────────────────────── */

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Loading ─────────────────────────────────────────────────────────────── */

.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  z-index: 9998;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { font-size: 13px; color: var(--text-muted); }

/* ── Theme Toggle ───────────────────────────────────────────────────────── */

.theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
  width: 34px;
  height: 32px;
}
.theme-btn:hover { background: var(--surface-2); color: var(--text); }
.theme-btn svg { display: block; }
.theme-btn .icon-sun { display: none; }
.theme-btn .icon-moon { display: block; }
[data-theme="dark"] .theme-btn .icon-sun { display: block; }
[data-theme="dark"] .theme-btn .icon-moon { display: none; }

/* ── Language Selector ──────────────────────────────────────────────────── */

.lang-selector { position: relative; display: flex; align-items: center; }

.lang-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.lang-btn:hover { background: var(--surface-2); }

.lang-flag { width: 22px; height: 15px; object-fit: cover; border-radius: 2px; display: block; }

.lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  text-align: left;
  transition: background 0.12s;
}
.lang-option:hover { background: var(--surface-2); }
.lang-option.active { color: var(--red); font-weight: 600; }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .nav { padding: 12px 16px; }
  .hero { padding: 60px 16px 48px; }
  .configurator, .leaderboard-section { padding: 0 16px; }
  .difficulty-group { grid-template-columns: 1fr; }
  .game-layout { padding: 16px; }
}

/* ── VS Finish Tabs ─────────────────────────────────────────────────────── */

.vs-finish-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.vs-tab {
  flex: 1;
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}
.vs-tab.active { color: var(--red); border-bottom-color: var(--red); font-weight: 600; }
.vs-tab:hover:not(.active) { color: var(--text); }

/* ── VS Avatar ──────────────────────────────────────────────────────────── */

.vs-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

/* ── Cancel Button ──────────────────────────────────────────────────────── */

.cancel-btn {
  background: none;
  border: none;
  color: inherit;
  font-size: 10px;
  cursor: pointer;
  padding: 0 2px;
  margin-left: 3px;
  opacity: 0.5;
  vertical-align: middle;
  line-height: 1;
  transition: opacity 0.15s;
}
.cancel-btn:hover { opacity: 1; }

/* ── Utility ─────────────────────────────────────────────────────────────── */

.hidden { display: none !important; }
