/* ==========================================
   TypeCow — Main CSS with 5 Themes
   ========================================== */

/* ---- CSS Variables per theme ---- */
:root,
[data-theme="terminal"] {
  --bg: #0d0d0d;
  --bg-secondary: #111;
  --bg-card: #1a1a1a;
  --bg-input: #0a0a0a;
  --text: #e0e0e0;
  --text-muted: #666;
  --text-dim: #444;
  --accent: #00ff88;
  --accent2: #00cc6a;
  --accent-glow: 0 0 10px #00ff8866;
  --error: #ff4444;
  --success: #00ff88;
  --warning: #ffcc00;
  --border: #2a2a2a;
  --border-focus: #00ff88;
  --char-correct: #00ff88;
  --char-incorrect: #ff4444;
  --char-cursor: #ffffff;
  --char-cursor-bg: #00ff8844;
  --hill-back: #0a2e1a;
  --hill-mid: #0d3d20;
  --hill-front: #114d2a;
  --navbar-bg: rgba(10,10,10,0.95);
  --card-shadow: 0 4px 20px rgba(0,255,136,0.05);
  --hm-wood: #4a3000;
  --hm-figure: #00ff88;
  --font-main: 'JetBrains Mono', 'Courier New', monospace;
  --font-ui: 'JetBrains Mono', monospace;
  --radius: 4px;
  --crt-filter: none;
}

[data-theme="terminal-light"] {
  --bg: #f5f5f0;
  --bg-secondary: #ebebE6;
  --bg-card: #fff;
  --bg-input: #f0f0eb;
  --text: #1a1a1a;
  --text-muted: #666;
  --text-dim: #aaa;
  --accent: #007a3d;
  --accent2: #005a2d;
  --accent-glow: 0 0 8px rgba(0,122,61,0.3);
  --error: #c0392b;
  --success: #27ae60;
  --warning: #e67e22;
  --border: #ddd;
  --border-focus: #007a3d;
  --char-correct: #007a3d;
  --char-incorrect: #c0392b;
  --char-cursor-bg: rgba(0,122,61,0.2);
  --hill-back: #c8e6c9;
  --hill-mid: #a5d6a7;
  --hill-front: #81c784;
  --navbar-bg: rgba(245,245,240,0.97);
  --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
  --hm-wood: #6d4c41;
  --hm-figure: #1a1a1a;
  --font-main: 'JetBrains Mono', monospace;
  --font-ui: 'JetBrains Mono', monospace;
  --radius: 4px;
}

[data-theme="modern-dark"] {
  --bg: #0f0f23;
  --bg-secondary: #16213e;
  --bg-card: #1a1a3e;
  --bg-input: #0f0f30;
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --text-dim: #444466;
  --accent: #7c4dff;
  --accent2: #ff6b6b;
  --accent-glow: 0 0 20px rgba(124,77,255,0.4);
  --error: #ff6b6b;
  --success: #69f0ae;
  --warning: #ffca28;
  --border: #2a2a4a;
  --border-focus: #7c4dff;
  --char-correct: #69f0ae;
  --char-incorrect: #ff6b6b;
  --char-cursor-bg: rgba(124,77,255,0.3);
  --hill-back: #0a0a2e;
  --hill-mid: #0d0d38;
  --hill-front: #111142;
  --navbar-bg: rgba(10,10,30,0.95);
  --card-shadow: 0 8px 32px rgba(124,77,255,0.1);
  --hm-wood: #5d4037;
  --hm-figure: #69f0ae;
  --font-main: 'JetBrains Mono', monospace;
  --font-ui: 'Nunito', sans-serif;
  --radius: 12px;
}

[data-theme="modern-light"] {
  --bg: #f8f9ff;
  --bg-secondary: #eef0ff;
  --bg-card: #ffffff;
  --bg-input: #f0f2ff;
  --text: #1a1a2e;
  --text-muted: #6666aa;
  --text-dim: #ccccee;
  --accent: #5c35cc;
  --accent2: #e94444;
  --accent-glow: 0 0 16px rgba(92,53,204,0.25);
  --error: #e94444;
  --success: #00c853;
  --warning: #ff9800;
  --border: #e0e0f0;
  --border-focus: #5c35cc;
  --char-correct: #00c853;
  --char-incorrect: #e94444;
  --char-cursor-bg: rgba(92,53,204,0.15);
  --hill-back: #dce8ff;
  --hill-mid: #c8daff;
  --hill-front: #b5ccff;
  --navbar-bg: rgba(248,249,255,0.97);
  --card-shadow: 0 4px 24px rgba(92,53,204,0.1);
  --hm-wood: #6d4c41;
  --hm-figure: #1a1a2e;
  --font-main: 'JetBrains Mono', monospace;
  --font-ui: 'Nunito', sans-serif;
  --radius: 12px;
}

[data-theme="cartoon"] {
  --bg: #fef9f0;
  --bg-secondary: #fff5e6;
  --bg-card: #fff;
  --bg-input: #fff9f0;
  --text: #3d2b1f;
  --text-muted: #a0886a;
  --text-dim: #d4c4b0;
  --accent: #ff6b9d;
  --accent2: #ffd93d;
  --accent-glow: 0 0 20px rgba(255,107,157,0.4);
  --error: #ff3b3b;
  --success: #2bc56e;
  --warning: #ff9f43;
  --border: #f0d9c0;
  --border-focus: #ff6b9d;
  --char-correct: #2bc56e;
  --char-incorrect: #ff3b3b;
  --char-cursor-bg: rgba(255,107,157,0.2);
  --hill-back: #a8e6cf;
  --hill-mid: #7cd8a0;
  --hill-front: #55c97a;
  --navbar-bg: rgba(255,249,240,0.97);
  --card-shadow: 0 8px 30px rgba(255,107,157,0.15);
  --hm-wood: #8b5e3c;
  --hm-figure: #3d2b1f;
  --font-main: 'Nunito', 'Comic Sans MS', cursive;
  --font-ui: 'Nunito', cursive;
  --radius: 20px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* ---- Animated background ---- */
.bg-scene {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.hills { position: absolute; bottom: 0; left: 0; right: 0; height: 100%; }
.hill { position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; }
.hill-back { bottom: 0; opacity: 0.6; }
.hill-mid  { bottom: 0; opacity: 0.8; }
.hill-front { bottom: 0; }

.flowers-container {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  pointer-events: none;
}

.flower-spawn {
  position: absolute;
  font-size: 16px;
  animation: flowerBob 3s ease-in-out infinite;
  bottom: 20px;
}

@keyframes flowerBob {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-6px) rotate(5deg); }
}

/* ---- Navbar ---- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 60px;
  background: var(--navbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--card-shadow);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-svg { width: 52px; height: 32px; }

.logo-text {
  font-family: var(--font-ui);
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
}

.logo-cow { color: var(--accent); }

.nav-menu {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  margin-left: auto;
  flex-wrap: wrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem;
  text-decoration: none;
  color: var(--text-muted);
  border-radius: var(--radius);
  font-size: 0.9rem;
  transition: all 0.15s;
  white-space: nowrap;
}
.nav-link:hover, .nav-link.active { color: var(--accent); background: var(--bg-card); }

.nav-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  transition: opacity 0.15s;
}
.nav-btn:hover { opacity: 0.85; }

.nav-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.nav-avatar-placeholder {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge { background: var(--error); color: #fff; border-radius: 10px; padding: 1px 5px; font-size: 0.7rem; margin-left: 3px; }

.nav-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 4px; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; transition: 0.3s; }

.theme-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  transition: border-color 0.15s;
}
.theme-btn:hover { border-color: var(--accent); }

/* ---- Main content ---- */
.main-content {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 60px - 200px);
  padding-bottom: 2rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); box-shadow: var(--accent-glow); }
.btn-secondary { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.82rem; }
.btn-lg { padding: 0.8rem 1.8rem; font-size: 1.05rem; }
.btn-xl { padding: 1rem 2.5rem; font-size: 1.1rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
.btn-full { width: 100%; }
.btn-oauth {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
  justify-content: center;
}
.btn-oauth:hover { border-color: var(--accent); }
.oauth-icon { width: 20px; height: 20px; }

/* ---- Forms ---- */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.form-group label { font-size: 0.875rem; color: var(--text-muted); font-weight: 600; }
.form-control, .form-control-sm {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.95rem;
  padding: 0.6rem 0.85rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.form-control:focus, .form-control-sm:focus { border-color: var(--border-focus); box-shadow: 0 0 0 2px var(--border-focus)22; }
.form-control-sm { padding: 0.4rem 0.6rem; font-size: 0.85rem; }
textarea.form-control { resize: vertical; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 150px; }
.input-with-toggle { position: relative; }
.input-with-toggle .form-control { padding-right: 3rem; }
.pw-toggle { position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--text-muted); }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; }
.pw-strength { height: 4px; border-radius: 2px; margin-top: 4px; overflow: hidden; position: relative; }
.pw-bar { height: 100%; border-radius: 2px; transition: width 0.3s, background 0.3s; }
.pw-strength span { font-size: 0.75rem; display: block; margin-top: 2px; }

/* ---- Alerts ---- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error { background: var(--error)18; border: 1px solid var(--error); color: var(--error); }
.alert-success { background: var(--success)18; border: 1px solid var(--success); color: var(--success); }
.alert a { color: inherit; font-weight: 700; }

/* ---- Landing Page ---- */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 2rem 2rem;
  align-items: center;
}

.hero-badge {
  display: inline-block;
  background: var(--accent)22;
  color: var(--accent);
  border: 1px solid var(--accent)44;
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.hero-title {
  font-family: var(--font-ui);
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.hero-highlight { color: var(--accent); }

.hero-sub {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  max-width: 480px;
}

.hero-cta { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 2rem; }

.hero-stats {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}
.hero-stat { text-align: center; }
.hero-stat strong { display: block; font-size: 1.5rem; font-weight: 900; color: var(--accent); }
.hero-stat span { font-size: 0.8rem; color: var(--text-muted); }

/* Demo terminal */
.demo-terminal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}
.demo-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.6rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27c93f; }
.demo-title { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; }
.demo-content {
  padding: 1.5rem;
  font-family: var(--font-main);
  font-size: 0.95rem;
  min-height: 80px;
  color: var(--text);
}
.demo-text { color: var(--accent); }
.demo-cursor { color: var(--accent); }
.demo-wpm { padding: 0.5rem 1rem; border-top: 1px solid var(--border); display: flex; gap: 1rem; font-size: 0.85rem; }
.wpm-badge { color: var(--accent); font-weight: 700; }
.acc-badge { color: var(--text-muted); }

/* ---- Sections ---- */
.section { padding: 4rem 0; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.section-title { font-size: 2rem; font-weight: 900; text-align: center; margin-bottom: 2.5rem; }

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--accent-glow); }
.feature-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.feature-card h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.feature-card p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; }

.steps { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.step { text-align: center; max-width: 180px; }
.step-num { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: var(--bg); font-size: 1.3rem; font-weight: 900; display: flex; align-items: center; justify-content: center; margin: 0 auto 0.5rem; }
.step h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.step p { font-size: 0.8rem; color: var(--text-muted); }
.step-arrow { font-size: 1.5rem; color: var(--text-dim); flex-shrink: 0; }

.theme-showcase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}
.showcase-item { background: var(--bg-card); border: 2px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color 0.2s; }
.showcase-item:hover, .showcase-item.active { border-color: var(--accent); }
.showcase-preview {
  height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}
.terminal-showcase { background: #0d0d0d; color: #e0e0e0; }
.ts-green { color: #00ff88; }
.ts-dim { color: #444; }
.ts-white { color: #e0e0e0; }
.modern-dark-showcase { background: #0f0f23; color: #e8e8f0; }
.ts-accent { color: #7c4dff; }
.ts-topbar { background: #16213e; padding: 6px 12px; font-size: 0.8rem; color: #7c4dff; border-bottom: 1px solid #2a2a4a; }
.ts-modern-content { padding: 12px; color: #e8e8f0; }
.ts-cursor-b { color: #7c4dff; animation: blink 1s infinite; }
.cartoon-showcase { background: #fef9f0; }
.ts-cartoon-top { background: #ff6b9d; color: white; padding: 6px 12px; font-family: 'Nunito', sans-serif; font-weight: 900; }
.ts-cartoon-content { padding: 12px; font-family: 'Nunito', cursive; color: #3d2b1f; font-size: 1rem; }
.showcase-item h3 { padding: 0.75rem 1rem 0.25rem; font-size: 1rem; }
.showcase-item p { padding: 0 1rem 1rem; font-size: 0.85rem; color: var(--text-muted); }

.testimonials-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; }
.testimonial-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.testimonial-card p { color: var(--text-muted); font-style: italic; margin-bottom: 1rem; line-height: 1.6; }
.testimonial-author { display: flex; align-items: center; gap: 0.75rem; }
.t-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--bg); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }

.cta-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem;
  text-align: center;
  box-shadow: var(--card-shadow);
}
.cta-box h2 { font-size: 2rem; margin-bottom: 0.75rem; }
.cta-box p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ---- Ad Placeholders ---- */
.ad-container { margin: 2rem auto; display: flex; justify-content: center; }
.ad-container-small { margin: 1rem auto; display: flex; justify-content: center; }
.ad-placeholder {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  color: var(--text-muted);
  text-align: center;
}
.ad-600x300 { width: 600px; min-height: 300px; max-width: 100%; }
.ad-300x250 { width: 300px; min-height: 250px; }
.ad-sidebar { width: 250px; min-height: 200px; margin-top: 1rem; }
.ad-label { font-size: 0.75rem; margin-top: 0.5rem; color: var(--text-dim); }
.ad-label a { color: var(--accent); }

/* ---- Auth Pages ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 200px);
  padding: 2rem 1rem;
}
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--card-shadow);
}
.auth-cow-icon { font-size: 3rem; text-align: center; margin-bottom: 0.5rem; }
.auth-title { font-size: 1.6rem; font-weight: 900; text-align: center; margin-bottom: 0.25rem; }
.auth-sub { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }
.auth-form { margin-bottom: 1rem; }
.auth-divider { text-align: center; position: relative; margin: 1.5rem 0; }
.auth-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.auth-divider span { position: relative; background: var(--bg-card); padding: 0 0.75rem; color: var(--text-muted); font-size: 0.85rem; }
.oauth-buttons { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }
.auth-footer { text-align: center; font-size: 0.9rem; color: var(--text-muted); margin-top: 1rem; }
.auth-footer a { color: var(--accent); font-weight: 700; }
.link-small { font-size: 0.85rem; color: var(--accent); text-decoration: none; }
.link-small:hover { text-decoration: underline; }

/* ---- Game Layout ---- */
.game-layout {
  display: grid;
  grid-template-columns: 220px 1fr 240px;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  min-height: calc(100vh - 120px);
}

.game-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  height: fit-content;
  position: sticky;
  top: 70px;
}
.game-sidebar h3 { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1rem; }
.sidebar-section { margin-bottom: 1rem; }
.sidebar-section label { font-size: 0.8rem; color: var(--text-muted); display: block; margin-bottom: 0.3rem; }
.sidebar-stats { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.qs-row { display: flex; justify-content: space-between; padding: 0.25rem 0; font-size: 0.85rem; }
.qs-row span { color: var(--text-muted); }
.qs-row strong { color: var(--accent); font-weight: 700; }
.sidebar-note { font-size: 0.8rem; color: var(--text-muted); }
.sidebar-note a { color: var(--accent); }

.game-main { display: flex; flex-direction: column; gap: 1rem; }

.game-stats-bar {
  display: flex;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}
.gs-item { display: flex; flex-direction: column; align-items: center; min-width: 60px; flex: 1; }
.gs-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.gs-value { font-size: 1.4rem; font-weight: 700; font-family: var(--font-main); color: var(--accent); min-height: 1.8rem; }
.gs-timer .gs-value { color: var(--text-muted); }

.game-exercise-wrap {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-height: 200px;
  transition: opacity 0.3s;
  cursor: text;
}

.exercise-meta { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.badge-diff, .badge-cat, .badge-len {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-diff { background: var(--accent)22; color: var(--accent); }
.badge-cat { background: var(--bg-secondary); color: var(--text-muted); }
.badge-len { background: var(--bg-secondary); color: var(--text-muted); }

.exercise-text {
  font-family: var(--font-main);
  font-size: 1.2rem;
  line-height: 2.2;
  letter-spacing: 0.03em;
  word-break: break-all;
  user-select: none;
}

.char { color: var(--text-dim); transition: color 0.05s; }
.char.correct { color: var(--char-correct); }
.char.incorrect {
  color: var(--error);
  background: var(--error)22;
  border-radius: 2px;
}
.char.cursor {
  color: var(--char-cursor, var(--text));
  background: var(--char-cursor-bg);
  border-radius: 2px;
  animation: cursorPulse 0.8s ease-in-out infinite;
}

@keyframes cursorPulse {
  0%, 100% { background: var(--char-cursor-bg); }
  50% { background: var(--accent)44; }
}

.exercise-overlay {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: var(--bg-card)ee;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s;
}
.overlay-content { text-align: center; }
.overlay-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.overlay-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

.game-input-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.progress-container {
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* ---- Game Results ---- */
.game-results {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
}
.results-header { margin-bottom: 1.5rem; }
.results-cow { font-size: 3rem; }
.results-header h2 { font-size: 1.5rem; font-weight: 900; }
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.result-item { text-align: center; }
.result-value { font-size: 2rem; font-weight: 900; color: var(--accent); font-family: var(--font-main); }
.result-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.results-chart-wrap { margin-bottom: 1.5rem; }
.results-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.results-signup-prompt { background: var(--accent)11; border: 1px solid var(--accent)33; border-radius: var(--radius); padding: 0.75rem 1rem; font-size: 0.9rem; }
.new-best-badge { display: inline-block; background: var(--warning); color: #000; font-weight: 700; font-size: 0.9rem; padding: 0.3rem 0.8rem; border-radius: 999px; margin: 0.5rem 0; }

/* ---- Leaderboard sidebar in game ---- */
.leaderboard-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  height: fit-content;
  position: sticky;
  top: 70px;
}
.leaderboard-sidebar h3 { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 1rem; }
.lb-mini { display: flex; flex-direction: column; gap: 0.4rem; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  transition: background 0.15s;
}
.lb-row:hover { background: var(--bg-secondary); }
.lb-top { background: var(--accent)11; }
.lb-pos { min-width: 20px; color: var(--text-muted); font-weight: 700; font-size: 0.8rem; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-wpm { color: var(--accent); font-weight: 700; font-size: 0.9rem; }
.lb-empty { font-size: 0.85rem; color: var(--text-muted); text-align: center; padding: 0.5rem; }

/* ---- Leaderboard Page ---- */
.leaderboard-page { padding: 2rem 1rem; }
.lb-page-header { text-align: center; margin-bottom: 2rem; }
.lb-page-header h1 { font-size: 2rem; font-weight: 900; margin-bottom: 0.5rem; }
.lb-filters { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; margin-top: 1.5rem; }
.lb-filter-group { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.lb-filter-group span { font-size: 0.85rem; color: var(--text-muted); }
.my-rank-banner { background: var(--accent)11; border: 1px solid var(--accent)33; border-radius: var(--radius); padding: 0.75rem 1rem; text-align: center; margin-bottom: 1.5rem; }
.lb-table-wrap { overflow-x: auto; }
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th { padding: 0.75rem 1rem; text-align: left; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.lb-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.lb-table tr:hover td { background: var(--bg-secondary); }
.lb-podium.lb-rank-1 td { background: rgba(255,215,0,0.08); }
.lb-podium.lb-rank-2 td { background: rgba(192,192,192,0.08); }
.lb-podium.lb-rank-3 td { background: rgba(205,127,50,0.08); }
.lb-mine td { border-left: 3px solid var(--accent); }
.lb-player { display: flex; align-items: center; gap: 0.6rem; }
.lb-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.lb-avatar-placeholder { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; }
.lb-you-badge { background: var(--accent); color: var(--bg); font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
.lb-rank { font-size: 1.1rem; font-weight: 700; }
.lb-wpm { font-weight: 700; color: var(--accent); font-size: 1rem; }
.lb-level { background: var(--bg-secondary); padding: 2px 6px; border-radius: var(--radius); font-size: 0.8rem; }
.lb-date { color: var(--text-muted); font-size: 0.8rem; }
.lb-empty-state { text-align: center; padding: 4rem 0; }
.lb-empty-icon { font-size: 4rem; margin-bottom: 1rem; }
.lb-signup-cta { margin-top: 2rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; font-size: 0.9rem; color: var(--text-muted); }
.lb-signup-cta a { color: var(--accent); font-weight: 700; }

/* ---- Profile ---- */
.profile-layout { max-width: 1000px; margin: 0 auto; padding: 0 1rem; }

.profile-hero {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  padding: 2rem 0;
  flex-wrap: wrap;
}
.profile-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-avatar, .profile-avatar-placeholder {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
}
.profile-avatar-placeholder {
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 900;
}
.profile-level-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  border: 2px solid var(--bg);
}
.profile-info { flex: 1; min-width: 250px; }
.profile-info h1 { font-size: 1.8rem; font-weight: 900; margin-bottom: 0.25rem; }
.profile-bio { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.75rem; }
.profile-badges { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.badge-achievement { background: var(--accent)22; color: var(--accent); border: 1px solid var(--accent)44; padding: 0.2rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.profile-meta { display: flex; gap: 1rem; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.75rem; }
.xp-bar-wrap { max-width: 300px; }
.xp-label { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2px; }
.xp-bar { height: 6px; background: var(--bg-secondary); border-radius: 3px; overflow: hidden; }
.xp-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.5s; }
.xp-label-small { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }
.profile-rank-card { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.rank-item { text-align: center; }
.rank-num { font-size: 1.8rem; font-weight: 900; color: var(--accent); font-family: var(--font-main); }
.rank-label { font-size: 0.8rem; color: var(--text-muted); }

.stats-overview { padding: 2rem 0; }
.stats-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1rem; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--card-shadow);
}
.stat-card.accent { border-color: var(--accent); }
.stat-num { font-size: 1.8rem; font-weight: 900; color: var(--accent); font-family: var(--font-main); }
.stat-name { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

.charts-section { padding: 2rem 0; }
.charts-section h2 { margin-bottom: 1.5rem; }
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.chart-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.chart-box h3 { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 0.75rem; }

.category-breakdown { margin-bottom: 2rem; }
.category-breakdown h3 { margin-bottom: 1rem; }
.cat-grid { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  min-width: 130px;
}
.cat-name { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.25rem; text-transform: capitalize; }
.cat-wpm { font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.cat-acc, .cat-cnt { font-size: 0.8rem; color: var(--text-muted); }

.error-heatmap { margin-bottom: 2rem; }
.error-heatmap h3 { margin-bottom: 1rem; }
.heatmap-chars { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.heatmap-char {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: rgba(255, 68, 68, calc(var(--intensity) / 100));
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
}
.heatmap-char span { font-family: var(--font-main); font-size: 0.9rem; color: var(--text); }

.best-session { padding: 1.5rem 0; }
.best-session h3 { margin-bottom: 0.75rem; }
.best-session-card {
  background: var(--bg-card);
  border: 1px solid var(--accent)44;
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}
.best-session-card strong { font-size: 1.3rem; font-weight: 900; color: var(--accent); }

.recent-sessions { padding: 1.5rem 0; }
.recent-sessions h3 { margin-bottom: 1rem; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th { padding: 0.6rem 0.75rem; text-align: left; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.data-table tr:hover td { background: var(--bg-secondary); }
.wpm-cell { font-weight: 700; color: var(--accent); }
.flagged-row td { background: rgba(255,68,68,0.05); }
.inactive-row { opacity: 0.5; }

.profile-settings { padding: 2rem 0; }
.profile-settings h3 { margin-bottom: 1rem; }
.settings-form { max-width: 500px; }
.settings-links { margin-top: 1.5rem; display: flex; gap: 1rem; }
.settings-links a { color: var(--accent); font-size: 0.9rem; }

/* ---- Messages ---- */
.messages-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 70px);
  overflow: hidden;
}
.conversations-sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.conv-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem; border-bottom: 1px solid var(--border); }
.conv-header h3 { font-size: 1rem; font-weight: 700; }
.new-conv-form { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; border-bottom: 1px solid var(--border); }
.conv-list { flex: 1; overflow-y: auto; }
.conv-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  align-items: center;
}
.conv-item:hover, .conv-item.active { background: var(--bg-secondary); }
.conv-avatar { position: relative; }
.conv-avatar img, .conv-avatar span {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--bg); font-weight: 700;
  object-fit: cover; flex-shrink: 0;
}
.conv-unread {
  position: absolute; top: -4px; right: -4px;
  background: var(--error); color: #fff;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 0.7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.conv-info { flex: 1; min-width: 0; }
.conv-info strong { display: block; font-size: 0.9rem; }
.conv-preview { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.conv-time { font-size: 0.75rem; color: var(--text-dim); flex-shrink: 0; }
.conv-empty { padding: 2rem; text-align: center; font-size: 0.9rem; color: var(--text-muted); }

.chat-area { display: flex; flex-direction: column; overflow: hidden; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem; border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}
.chat-user { display: flex; align-items: center; gap: 0.75rem; }
.chat-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.chat-avatar-ph { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--bg); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.msg { display: flex; flex-direction: column; max-width: 70%; }
.msg-me { align-self: flex-end; }
.msg-them { align-self: flex-start; }
.msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}
.msg-me .msg-bubble { background: var(--accent)22; border-color: var(--accent)44; }
.msg-time { font-size: 0.75rem; color: var(--text-dim); margin-top: 3px; padding: 0 4px; }
.msg-me .msg-time { text-align: right; }
.chat-input-area {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  padding: 0.6rem 0.85rem;
  outline: none;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}
.chat-input:focus { border-color: var(--border-focus); }
.emoji-picker-wrap { position: relative; }
.emoji-btn { background: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 0.6rem; cursor: pointer; font-size: 1.1rem; color: var(--text-muted); }
.emoji-panel {
  position: absolute;
  bottom: 100%;
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  width: 220px;
  box-shadow: var(--card-shadow);
  z-index: 50;
}
.emoji-item { background: none; border: none; cursor: pointer; font-size: 1.2rem; padding: 3px; border-radius: 4px; transition: background 0.1s; }
.emoji-item:hover { background: var(--bg-secondary); }
.send-btn { flex-shrink: 0; }
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; color: var(--text-muted); gap: 0.75rem; }
.chat-empty-icon { font-size: 4rem; }

/* ---- Hangman ---- */
.hangman-layout { display: grid; grid-template-columns: 1fr 260px; gap: 1rem; max-width: 1100px; margin: 0 auto; padding: 1rem; }
.hangman-header { margin-bottom: 1rem; }
.hangman-header h1 { font-size: 1.5rem; font-weight: 900; }
.hangman-header p { color: var(--text-muted); font-size: 0.9rem; }
.hm-landscape {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 200px;
  overflow: hidden;
  position: relative;
  margin-bottom: 1rem;
}
.hm-scroll-inner { position: absolute; width: 3000px; height: 100%; }
.ls-ground { position: absolute; bottom: 0; left: 0; width: 100%; height: 30px; background: var(--hill-front); }
.ls-tree { position: absolute; }
.ls-flower { position: absolute; font-size: 16px; animation: flowerBob 2s ease-in-out infinite; }
.ls-cow { position: absolute; font-size: 24px; animation: cowWalk 4s ease-in-out infinite; }
@keyframes cowWalk { 0%,100% { transform: translateX(0); } 50% { transform: translateX(10px); } }
.hm-gallows-fixed {
  position: absolute;
  right: 60px;
  top: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 28px;
}
.hangman-svg { width: 120px; height: 160px; }
.hm-mistakes-display { font-size: 0.85rem; color: var(--text-muted); text-align: center; margin-top: 4px; }
#hmMistakesLeft { font-weight: 700; color: var(--error); font-size: 1rem; }
.shake { animation: shake 0.3s ease-in-out; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }

.hm-speed-bar-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1rem; }
.hm-speed-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.hm-speed-label span { color: var(--text); font-weight: 700; }
.hm-speed-bar-bg { height: 8px; background: var(--bg-secondary); border-radius: 4px; position: relative; overflow: visible; }
.hm-speed-bar { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.hm-speed-bar.speed-danger { background: var(--error); animation: danger-flash 0.3s ease-in-out; }
@keyframes danger-flash { 0%,100%{opacity:1} 50%{opacity:0.3} }
.hm-speed-min-marker { position: absolute; top: -4px; width: 3px; height: 16px; background: var(--warning); border-radius: 2px; transform: translateX(-50%); }
.hm-alive-timer { font-size: 0.85rem; color: var(--accent); font-weight: 700; }
.hangman-sidebar { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; height: fit-content; position: sticky; top: 70px; }
.hm-rules h4 { font-size: 0.9rem; margin: 1rem 0 0.5rem; }
.hm-rules ul { list-style: none; }
.hm-rules li { font-size: 0.85rem; color: var(--text-muted); padding: 0.2rem 0; }
.hm-rules li::before { content: '• '; color: var(--accent); }
.hm-gameover {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.hm-gameover-inner {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  max-width: 500px;
  width: 100%;
  text-align: center;
}
#hmGameoverIcon { font-size: 4rem; margin-bottom: 0.5rem; }

/* ---- Race ---- */
.race-layout { max-width: 1000px; margin: 0 auto; padding: 1rem; }
.race-header { margin-bottom: 1.5rem; }
.race-header h1 { font-size: 1.5rem; font-weight: 900; }
.race-lobby { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; margin-bottom: 1.5rem; }
.race-guest { text-align: center; color: var(--text-muted); }
.race-guest a { color: var(--accent); }
.challenge-form { max-width: 400px; margin-bottom: 2rem; }
.challenge-form h3 { margin-bottom: 1rem; }
.pending-challenges h3 { margin-bottom: 0.75rem; }
.challenge-card { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem; background: var(--bg-secondary); border-radius: var(--radius); margin-bottom: 0.5rem; font-size: 0.9rem; }
.race-track-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.race-track { margin-bottom: 1rem; }
.race-landscape { background: var(--bg-secondary); border-radius: var(--radius); overflow: hidden; height: 200px; position: relative; }
.race-road { position: relative; height: 100%; display: flex; flex-direction: column; }
.race-lane { flex: 1; position: relative; border-bottom: 1px solid var(--border); }
.race-divider { height: 4px; background: var(--border); }
.race-scenery { position: absolute; bottom: 0; height: 40px; width: 2000px; display: flex; align-items: flex-end; }
.finish-line {
  position: absolute;
  right: 20px;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  font-size: 2rem;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.3));
}
.cow-racer { position: absolute; top: 50%; transform: translateY(-50%); transition: left 0.3s linear; }
.cow-car-svg { width: 80px; height: 50px; }
.racer-label { text-align: center; font-size: 0.75rem; color: var(--text-muted); font-weight: 700; }
.race-progress-bars { display: flex; flex-direction: column; gap: 0.5rem; }
.race-pb { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.race-pb > span:first-child { min-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.race-pb-bar { flex: 1; height: 8px; background: var(--bg-secondary); border-radius: 4px; overflow: hidden; }
.race-pb-fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.p1-fill { background: #E53935; }
.p2-fill { background: #1976D2; }
.race-pb-wpm { min-width: 60px; font-size: 0.8rem; color: var(--text-muted); font-weight: 700; text-align: right; }
.countdown { font-size: 4rem; font-weight: 900; color: var(--accent); margin-top: 0.5rem; animation: countPulse 1s ease-in-out; }
@keyframes countPulse { 0%{transform:scale(1.5);opacity:0} 100%{transform:scale(1);opacity:1} }
.race-result { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; }
.race-result-inner { max-width: 500px; margin: 0 auto; }
.race-result-icon { font-size: 4rem; margin-bottom: 0.5rem; }

/* ---- Admin ---- */
.admin-layout { padding: 2rem 1rem; max-width: 1200px; margin: 0 auto; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.admin-stat { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center; }
.admin-stat strong { display: block; font-size: 1.8rem; font-weight: 900; color: var(--accent); }
.admin-stat span { font-size: 0.8rem; color: var(--text-muted); }
.admin-stat.danger strong { color: var(--error); }
.admin-nav { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.admin-panels { display: flex; flex-direction: column; gap: 1.5rem; }
.admin-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.admin-panel h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }
.admin-form { max-width: 600px; }
.admin-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.backup-info { background: var(--bg-secondary); border-radius: var(--radius); padding: 1rem; margin: 1rem 0; font-size: 0.9rem; }
.backup-info p { margin-bottom: 0.25rem; color: var(--text-muted); }
.backup-info code { color: var(--accent); }
.backup-actions { margin: 1.5rem 0; }
.install-script-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin: 1.5rem 0; }
.install-script-section h3 { margin-bottom: 0.5rem; }
.install-script-section p { color: var(--text-muted); margin-bottom: 1rem; font-size: 0.9rem; }
.backup-list { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.backup-list h3 { margin-bottom: 1rem; }

/* ---- Theme Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 600px;
  width: 100%;
}
.modal-box h2 { text-align: center; margin-bottom: 1.5rem; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.theme-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s;
}
.theme-card:hover, .theme-card[aria-pressed="true"] { border-color: var(--accent); }
.theme-preview {
  height: 80px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: monospace;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.terminal-preview { background: #0d0d0d; color: #00ff88; }
.terminal-light-preview { background: #f5f5f0; color: #007a3d; }
.modern-dark-preview { background: #0f0f23; color: #7c4dff; }
.modern-light-preview { background: #f8f9ff; color: #5c35cc; }
.cartoon-preview { background: #fef9f0; color: #ff6b9d; font-family: 'Nunito', cursive; font-size: 1.1rem; font-weight: 700; }
.theme-card span { font-size: 0.85rem; font-weight: 600; }
.blink { animation: blink 1s step-end infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ---- Footer ---- */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  position: relative;
  z-index: 1;
  margin-top: 200px;
}
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1.5rem; align-items: center; }
.footer-brand p { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }
.footer-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); font-size: 0.9rem; text-decoration: none; transition: color 0.15s; }
.footer-links a:hover { color: var(--accent); }
.footer-legal p { color: var(--text-dim); font-size: 0.8rem; }
.footer-legal a { color: var(--text-muted); }

/* ---- Cartoon theme extras ---- */
[data-theme="cartoon"] .feature-card {
  border-width: 2px;
  box-shadow: 4px 4px 0 var(--border);
}
[data-theme="cartoon"] .char.correct { text-shadow: 0 0 8px var(--success); }
[data-theme="cartoon"] .gs-value { color: var(--accent); text-shadow: 2px 2px 0 var(--accent)44; }
[data-theme="cartoon"] .btn-primary { box-shadow: 3px 3px 0 var(--accent2); }
[data-theme="cartoon"] .btn-primary:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--accent2); }

/* ---- Terminal CRT effect (optional) ---- */
[data-theme="terminal"] body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px, transparent 1px, transparent 2px);
  pointer-events: none;
  z-index: 9999;
}

/* ---- Utility ---- */
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
a { color: var(--accent); }
code { font-family: var(--font-main); background: var(--bg-secondary); padding: 0.1em 0.3em; border-radius: 3px; font-size: 0.9em; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .game-layout { grid-template-columns: 1fr; }
  .game-sidebar, .leaderboard-sidebar { display: none; }
  .hangman-layout { grid-template-columns: 1fr; }
  .hangman-sidebar { display: none; }
}

@media (max-width: 768px) {
  .hero { grid-template-columns: 1fr; }
  .hero-demo { display: none; }
  .nav-menu { display: none; flex-direction: column; position: fixed; inset: 60px 0 0 0; background: var(--navbar-bg); padding: 1rem; gap: 0.25rem; z-index: 99; overflow-y: auto; }
  .nav-menu.open { display: flex; }
  .nav-toggle { display: flex; }
  .messages-layout { grid-template-columns: 1fr; }
  .conversations-sidebar { height: 250px; }
  .profile-hero { flex-direction: column; }
}

@media (max-width: 480px) {
  .results-grid { grid-template-columns: repeat(2, 1fr); }
  .game-stats-bar { gap: 0.25rem; }
  .gs-value { font-size: 1.1rem; }
}
