/* ==========================================================================
   KLAVOMASTER PRO DESIGN SYSTEM & STYLES (PREMIUM MODERN VANILLA CSS)
   ========================================================================== */

/* --- RESET & DESIGN TOKENS --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Default Cyber Dark Palette */
  --bg-app: #090d13;
  --bg-surface: #111722;
  --bg-surface-elevated: #1a2232;
  --bg-input: #0b0f17;
  --border-subtle: #242f44;
  --border-active: #38bdf8;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #475569;

  --accent-primary: #10b981;
  --accent-primary-hover: #059669;
  --accent-cyan: #38bdf8;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-gold: #fbbf24;

  /* Finger Color Zones */
  --finger-pinky: #f43f5e;
  --finger-ring: #fb923c;
  --finger-middle: #10b981;
  --finger-index: #0ea5e9;
  --finger-thumb: #8b5cf6;

  /* Typography */
  --font-ui: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Shadows & Glassmorphism */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(56, 189, 248, 0.25);

  --transition-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- THEME VARIATIONS --- */
body.theme-obsidian {
  --bg-app: #030303;
  --bg-surface: #0f0f0f;
  --bg-surface-elevated: #181818;
  --bg-input: #080808;
  --border-subtle: #222222;
  --border-active: #38bdf8;
  --text-main: #fafafa;
  --text-muted: #888888;
  --text-dim: #333333;
}

body.theme-nordic {
  --bg-app: #181b22;
  --bg-surface: #202530;
  --bg-surface-elevated: #2a3140;
  --bg-input: #14171d;
  --border-subtle: #363e52;
  --border-active: #2dd4bf;
  --accent-primary: #2dd4bf;
  --accent-primary-hover: #14b8a6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

body.theme-matcha {
  --bg-app: #f4f6f1;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #e9eee4;
  --bg-input: #ffffff;
  --border-subtle: #cbd7c0;
  --border-active: #4d7c0f;
  --accent-primary: #4d7c0f;
  --accent-primary-hover: #3f6212;
  --text-main: #14200e;
  --text-muted: #56684c;
  --text-dim: #98a88d;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.12);
}

body.theme-terminal {
  --bg-app: #080d08;
  --bg-surface: #101a10;
  --bg-surface-elevated: #182618;
  --bg-input: #050805;
  --border-subtle: #213d21;
  --border-active: #22c55e;
  --accent-primary: #22c55e;
  --accent-primary-hover: #16a34a;
  --text-main: #4ade80;
  --text-muted: #2f855a;
  --text-dim: #184224;
}

body.theme-sunset {
  --bg-app: #18131d;
  --bg-surface: #221a2a;
  --bg-surface-elevated: #2f243b;
  --bg-input: #130e18;
  --border-subtle: #453556;
  --border-active: #f97316;
  --accent-primary: #f97316;
  --accent-primary-hover: #ea580c;
  --text-main: #fef08a;
  --text-muted: #c084fc;
}

/* --- BASE STYLES --- */
html, body {
  min-height: 100vh;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  transition: all var(--transition-fast);
}

button:active {
  transform: scale(0.98);
}

.icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: inline-block;
  vertical-align: middle;
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  color: var(--text-muted);
  box-shadow: 0 2px 0 rgba(0,0,0,0.25);
}

.hidden {
  display: none !important;
}

/* --- HEADER --- */
.main-header {
  background-color: rgba(17, 23, 34, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--bg-surface-elevated), var(--bg-surface));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 var(--border-subtle);
}

.logo-key {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 19px;
  color: var(--accent-cyan);
}

.brand-name {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.03em;
}

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

.brand-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 6px;
  color: var(--accent-cyan);
  letter-spacing: 0.05em;
  margin-left: 6px;
}

/* Nav */
.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.nav-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
}

.nav-btn.active {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
  box-shadow: var(--shadow-sm);
}

.nav-counter {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  background: var(--bg-app);
  border-radius: 12px;
  color: var(--accent-amber);
  border: 1px solid var(--border-subtle);
}

/* Actions & Profile */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.action-icon-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
  border-color: var(--border-active);
}

.user-info-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 30px;
  padding: 4px 12px 4px 6px;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-rank {
  font-size: 10px;
  color: var(--accent-gold);
  font-weight: 600;
}

.btn-logout {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  margin-left: 6px;
}

.btn-logout:hover {
  color: var(--accent-red);
}

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 26px;
  font-size: 15px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--border-subtle);
}

.btn-accent {
  background: var(--accent-cyan);
  color: #090d13;
}

.btn-accent:hover {
  opacity: 0.92;
  box-shadow: var(--shadow-glow);
}

.btn-text-action {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-cyan);
  cursor: pointer;
}

.btn-text-action:hover {
  text-decoration: underline;
}

/* --- MAIN CONTENT & VIEWS --- */
.main-content {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.content-view {
  display: none;
  animation: fadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.content-view.active {
  display: block;
}

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

/* --- VIEW 1: TRAINER ARENA --- */

/* Controls Card */
.trainer-controls-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.mode-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-app);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.mode-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
}

.mode-chip:hover {
  color: var(--text-main);
}

.mode-chip.active {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.sub-options {
  display: flex;
  align-items: center;
  gap: 12px;
}

.options-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.opt-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.sub-chip {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.sub-chip.active {
  background: var(--accent-cyan);
  color: #090d13;
  border-color: var(--accent-cyan);
}

.level-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  background: var(--accent-primary);
  color: #fff;
  border-radius: 5px;
  letter-spacing: 0.04em;
}

.level-title-preview {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

/* Metrics HUD */
.metrics-hud {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.hud-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.hud-val {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-main);
}

.hud-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-top: 5px;
}

.combo-val {
  color: var(--accent-amber);
}

/* Layout Alert */
.layout-alert {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  animation: shake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Main Typing Arena Box */
.typing-box-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 36px 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  min-height: 200px;
  user-select: none;
}

.hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  left: -9999px;
}

.focus-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 19, 0.85);
  backdrop-filter: blur(4px);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  cursor: pointer;
  transition: opacity var(--transition-normal);
}

.focus-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.focus-msg {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-surface-elevated);
  padding: 14px 28px;
  border-radius: 40px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
}

.text-stream {
  font-family: var(--font-mono);
  font-size: 25px;
  line-height: 1.8;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  height: 135px;
  overflow: hidden;
  position: relative;
  word-break: break-word;
}

/* Character Rendering */
.char {
  position: relative;
  transition: color 0.08s ease;
}

.char.correct {
  color: var(--text-main);
}

.char.incorrect {
  color: var(--accent-red);
  text-decoration: underline;
  background: rgba(239, 68, 68, 0.18);
  border-radius: 3px;
}

.char.active {
  color: var(--accent-cyan);
}

/* Caret Cursor */
.caret {
  position: absolute;
  width: 2.5px;
  height: 1.35em;
  background: var(--accent-cyan);
  border-radius: 1px;
  will-change: transform;
  transition: transform 0.075s cubic-bezier(0.2, 0.9, 0.3, 1);
  pointer-events: none;
  animation: caretBlink 1.1s infinite;
  box-shadow: 0 0 8px var(--accent-cyan);
}

body.caret-block .caret {
  width: 0.6em;
  background: rgba(56, 189, 248, 0.35);
  border-radius: 3px;
}

body.caret-underline .caret {
  width: 0.6em;
  height: 3px;
  margin-top: 1.25em;
}

@keyframes caretBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.typing-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12px;
}

.btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
}

.btn-icon-text:hover {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
}

/* --- KEYBOARD & HANDS VISUALIZER --- */
.keyboard-visualizer-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.visualizer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  font-size: 12px;
}

.finger-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-weight: 600;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

.legend-dot.pinky { background: var(--finger-pinky); box-shadow: 0 0 6px var(--finger-pinky); }
.legend-dot.ring { background: var(--finger-ring); box-shadow: 0 0 6px var(--finger-ring); }
.legend-dot.middle { background: var(--finger-middle); box-shadow: 0 0 6px var(--finger-middle); }
.legend-dot.index { background: var(--finger-index); box-shadow: 0 0 6px var(--finger-index); }
.legend-dot.thumb { background: var(--finger-thumb); box-shadow: 0 0 6px var(--finger-thumb); }

.target-key-hint {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.target-key-display {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-weight: 800;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.target-finger-name {
  color: var(--text-muted);
  font-size: 11px;
}

/* Hands Visualizer Container */
.hands-visualizer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.hand {
  width: 105px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.hand .finger {
  width: 100%;
  height: 11px;
  border-radius: 6px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}

.hand .finger.active {
  box-shadow: 0 0 12px currentColor;
  transform: scale(1.08);
}

.hand .finger.f-pinky.active { background: var(--finger-pinky); color: var(--finger-pinky); }
.hand .finger.f-ring.active { background: var(--finger-ring); color: var(--finger-ring); }
.hand .finger.f-middle.active { background: var(--finger-middle); color: var(--finger-middle); }
.hand .finger.f-index.active { background: var(--finger-index); color: var(--finger-index); }
.hand .finger.f-thumb.active { background: var(--finger-thumb); color: var(--finger-thumb); }

.palm {
  margin-top: 4px;
  text-align: center;
}

.hand-label {
  font-size: 9px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* 3D Virtual Russian Keyboard */
.virtual-keyboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 790px;
}

.kb-row {
  display: flex;
  gap: 5px;
  justify-content: center;
}

.key {
  position: relative;
  height: 46px;
  min-width: 43px;
  background: linear-gradient(180deg, var(--bg-surface-elevated) 0%, var(--bg-app) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  box-shadow: 0 3px 0 var(--border-subtle), 0 4px 8px rgba(0,0,0,0.3);
  transition: all 0.06s cubic-bezier(0.4, 0, 0.2, 1);
}

.key-main {
  font-size: 14px;
}

.key-shift {
  font-size: 9px;
  color: var(--text-muted);
  position: absolute;
  top: 3px;
  right: 5px;
}

/* Finger bottom accents */
.key[data-finger^="l-pinky"], .key[data-finger^="r-pinky"] { border-bottom: 2px solid var(--finger-pinky); }
.key[data-finger^="l-ring"], .key[data-finger^="r-ring"] { border-bottom: 2px solid var(--finger-ring); }
.key[data-finger^="l-middle"], .key[data-finger^="r-middle"] { border-bottom: 2px solid var(--finger-middle); }
.key[data-finger^="l-index"], .key[data-finger^="r-index"] { border-bottom: 2px solid var(--finger-index); }
.key[data-finger="thumb"] { border-bottom: 2px solid var(--finger-thumb); }

.key.has-bump::after {
  content: '';
  position: absolute;
  bottom: 5px;
  width: 9px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 1px;
}

.key.key-backspace { min-width: 76px; font-size: 11px; }
.key.key-tab { min-width: 56px; font-size: 11px; }
.key.key-caps { min-width: 66px; font-size: 11px; }
.key.key-enter { min-width: 78px; font-size: 11px; }
.key.key-shift { min-width: 88px; font-size: 11px; }
.key.key-space { min-width: 270px; }
.key.key-mod { min-width: 50px; font-size: 11px; }

.key.target {
  background: var(--bg-surface-elevated);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4), 0 3px 0 var(--accent-cyan);
  transform: translateY(-2px);
}

.key.pressed {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
  transform: translateY(3px);
  box-shadow: none;
}

.key.error-flash {
  background: var(--accent-red) !important;
  border-color: var(--accent-red) !important;
  color: #fff !important;
}

/* --- VIEW 2: ACADEMY (50 LEVELS) --- */
.campaign-header-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 26px;
  margin-bottom: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.view-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.view-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 580px;
}

.campaign-progress-summary {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.summary-stars {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 17px;
  font-weight: 800;
  color: var(--accent-gold);
}

.progress-bar-container {
  width: 200px;
  height: 9px;
  background: var(--bg-app);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

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

.progress-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Module Accordion & Cards */
.level-module {
  margin-bottom: 34px;
}

.module-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.module-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
}

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

.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.level-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

.level-card:hover:not(.locked) {
  border-color: var(--accent-cyan);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.level-card.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.level-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.level-num-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  background: var(--bg-surface-elevated);
  border-radius: 5px;
  color: var(--text-muted);
}

.level-card-stars {
  font-size: 14px;
  color: var(--accent-gold);
}

.level-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.level-keys-list {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-cyan);
  margin-bottom: 14px;
}

.level-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

/* --- VIEW 3: WEAK KEYS --- */
.weak-keys-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 34px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

.section-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.section-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 26px;
  max-width: 620px;
}

.weak-keys-list {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.weak-key-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.weak-char {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-red);
}

.weak-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.drill-generator-box {
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

/* --- VIEW 4: STATS, FINGERS & ACHIEVEMENTS --- */
.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.stat-icon-wrap {
  font-size: 26px;
}

.stat-big-val {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 800;
}

.stat-sublabel {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.card-header h3 {
  font-size: 17px;
  font-weight: 800;
}

.canvas-wrapper {
  width: 100%;
  overflow-x: auto;
}

/* Finger Stats Grid */
.finger-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.finger-stat-card {
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.finger-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.finger-stat-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.finger-stat-acc {
  font-size: 13px;
  font-weight: 800;
  font-family: var(--font-mono);
}

.finger-progress-bar {
  width: 100%;
  height: 7px;
  background: var(--bg-surface-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.finger-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.finger-stat-details {
  font-size: 11px;
  color: var(--text-muted);
}

/* Achievements Grid */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.achievement-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: all var(--transition-normal);
}

.achievement-card.unlocked {
  border-color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.08);
}

.achievement-card.locked {
  opacity: 0.45;
  filter: grayscale(0.8);
}

.ach-icon {
  font-size: 28px;
  line-height: 1;
}

.ach-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.ach-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* Heatmap */
.heatmap-legend {
  display: flex;
  gap: 12px;
  font-size: 11px;
  font-weight: 600;
}

.heatmap-pill {
  padding: 3px 10px;
  border-radius: 6px;
}

.heat-low { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.heat-mid { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.heat-high { background: rgba(239, 68, 68, 0.25); color: #ef4444; }

.heatmap-keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 790px;
  margin: 0 auto;
}

/* History & Leaderboard Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.history-table, .leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.history-table th, .leaderboard-table th {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-weight: 700;
}

.history-table td, .leaderboard-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.history-table tr:hover, .leaderboard-table tr:hover {
  background: var(--bg-surface-elevated);
}

/* --- MODALS --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  position: relative;
  animation: modalScaleIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes modalScaleIn {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-close {
  font-size: 26px;
  color: var(--text-muted);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-footer {
  margin-top: 26px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Results Modal */
.result-modal-card {
  max-width: 660px;
}

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

.result-stars {
  font-size: 28px;
  display: flex;
  gap: 6px;
}

.star-badge {
  opacity: 0.2;
  transition: opacity 0.3s ease;
}

.star-badge.earned {
  opacity: 1;
  animation: starPop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

@keyframes starPop {
  0% { transform: scale(0.4); }
  70% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.result-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.result-metric-box {
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.result-metric-box.highlight {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.result-metric-box.highlight .result-val {
  color: var(--accent-cyan);
}

.result-val {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 800;
}

.result-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 4px;
}

.result-chart-box {
  margin-bottom: 22px;
  background: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
}

.chart-mini-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-active);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: 20px;
}

.setting-label-group label {
  font-size: 14px;
  font-weight: 700;
}

.setting-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.setting-item .form-select {
  max-width: 210px;
}

/* Auth */
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-app);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.auth-tab {
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: 6px;
}

.auth-tab.active {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

.auth-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.4;
}

.auth-alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.auth-alert.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
}

.auth-alert.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid var(--accent-primary);
  color: var(--accent-primary);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 14px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- RESPONSIVE --- */
@media (max-width: 960px) {
  .hands-visualizer {
    flex-direction: column;
  }
  .hand {
    display: none;
  }
  .metrics-hud {
    grid-template-columns: repeat(3, 1fr);
  }
  #hud-combo-item {
    display: none;
  }
  .main-nav span {
    display: none;
  }
}

@media (max-width: 640px) {
  .metrics-hud {
    grid-template-columns: repeat(2, 1fr);
  }
  .trainer-controls-card {
    flex-direction: column;
    align-items: stretch;
  }
  .text-stream {
    font-size: 19px;
  }
  .key {
    min-width: 27px;
    height: 38px;
    font-size: 11px;
  }
  .key-shift {
    display: none;
  }
}
