/* Dual N-Back Design System and Styling */

:root {
  /* Colors - Dark Theme (Default) */
  --bg-color: #05060b;
  --bg-gradient: radial-gradient(circle at 50% 50%, #0d0f1a 0%, #05060b 100%);
  --panel-bg: rgba(13, 17, 30, 0.45);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-hover: rgba(255, 255, 255, 0.15);
  
  --text-primary: #f0f2fa;
  --text-secondary: #90a0c7;
  --text-muted: #5e6b8c;
  
  --primary-accent: #6c5ce7;
  --primary-glow: rgba(108, 92, 231, 0.4);
  --secondary-accent: #00d2d3;
  --secondary-glow: rgba(0, 210, 211, 0.3);
  
  --success-color: #10ac84;
  --success-glow: rgba(16, 172, 132, 0.4);
  --danger-color: #ee5253;
  --danger-glow: rgba(238, 82, 83, 0.4);
  
  --kbd-bg: rgba(255, 255, 255, 0.1);
  --kbd-border: rgba(255, 255, 255, 0.2);
  
  /* Font families */
  --font-main: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Layout details */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-slow: 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Light Theme Variables */
.light-theme {
  --bg-color: #f3f5fa;
  --bg-gradient: radial-gradient(circle at 50% 50%, #f7f9fc 0%, #ebedf4 100%);
  --panel-bg: rgba(255, 255, 255, 0.7);
  --panel-border: rgba(0, 0, 0, 0.06);
  --panel-border-hover: rgba(0, 0, 0, 0.12);
  
  --text-primary: #1e2230;
  --text-secondary: #5a627a;
  --text-muted: #8c96ab;
  
  --primary-accent: #5f27cd;
  --primary-glow: rgba(95, 39, 205, 0.25);
  --secondary-accent: #0abde3;
  --secondary-glow: rgba(10, 189, 227, 0.2);
  
  --success-color: #10ac84;
  --success-glow: rgba(16, 172, 132, 0.25);
  --danger-color: #d63031;
  --danger-glow: rgba(214, 48, 49, 0.25);
  
  --kbd-bg: rgba(0, 0, 0, 0.05);
  --kbd-border: rgba(0, 0, 0, 0.12);
}

/* Base resets & layouts */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Mesh Background Orbs */
.mesh-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.mesh-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.25;
  mix-blend-mode: screen;
  transition: transform var(--transition-slow);
}

.light-theme .mesh-orb {
  opacity: 0.12;
  mix-blend-mode: multiply;
  filter: blur(140px);
}

.orb-1 {
  background: var(--primary-accent);
  width: 50vw;
  height: 50vw;
  top: -10vw;
  right: -5vw;
  animation: orb-float-1 30s infinite alternate ease-in-out;
}

.orb-2 {
  background: var(--secondary-accent);
  width: 45vw;
  height: 45vw;
  bottom: -15vw;
  left: -10vw;
  animation: orb-float-2 25s infinite alternate ease-in-out;
}

.orb-3 {
  background: #ff9f43;
  width: 35vw;
  height: 35vw;
  top: 35vh;
  left: 45vw;
  animation: orb-float-3 28s infinite alternate ease-in-out;
}

@keyframes orb-float-1 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-10%, 15%) scale(1.1); }
}

@keyframes orb-float-2 {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(15%, -10%) scale(1.15); }
}

@keyframes orb-float-3 {
  0% { transform: translate(0, 0) scale(0.9); }
  100% { transform: translate(-15%, -15%) scale(1.1); }
}

/* App Container Layout */
.app-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navigation styles */
.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
  border-bottom: 1px solid var(--panel-border);
}

.logo {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-accent {
  background: linear-gradient(135deg, var(--secondary-accent), var(--primary-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-links {
  display: flex;
  gap: 8px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  padding: 6px;
  border-radius: var(--radius-md);
}

.nav-link {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.light-theme .nav-link:hover {
  background: rgba(0, 0, 0, 0.03);
}

.nav-link.active {
  color: var(--text-primary);
  background: var(--primary-accent);
  box-shadow: 0 4px 15px var(--primary-glow);
}

.theme-toggle-container {
  display: flex;
  align-items: center;
}

.theme-toggle {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  border-color: var(--panel-border-hover);
  transform: translateY(-2px);
}

.sun-icon { display: none; }
.moon-icon { display: block; }

.light-theme .sun-icon { display: block; }
.light-theme .moon-icon { display: none; }

/* PWA Install Button */
.pwa-install-btn {
  background: linear-gradient(135deg, var(--secondary-accent), var(--primary-accent));
  box-shadow: 0 4px 10px var(--primary-glow);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  margin-right: 12px;
  transition: all var(--transition-fast);
}

.pwa-install-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px var(--primary-glow);
  filter: brightness(1.1);
}

.pwa-install-btn.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .pwa-install-btn span {
    display: none;
  }
  .pwa-install-btn {
    padding: 8px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    justify-content: center;
    margin-right: 8px;
  }
}

/* Main Content Views */
.main-content {
  flex: 1;
  padding: 32px 0;
  position: relative;
}

.view-section {
  display: none;
  animation: view-fade-in 0.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

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

@keyframes view-fade-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Glassmorphism Panel styles */
.glass {
  background-color: var(--panel-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass:hover {
  border-color: var(--panel-border-hover);
}

/* Buttons Common */
.btn {
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 15px;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--primary-accent);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
  filter: brightness(1.1);
}

.btn-glow {
  animation: button-pulse 2s infinite;
}

@keyframes button-pulse {
  0% { box-shadow: 0 0 0 0 var(--primary-glow); }
  70% { box-shadow: 0 0 0 10px rgba(108, 92, 231, 0); }
  100% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0); }
}

.btn-secondary {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--panel-border-hover);
  transform: translateY(-2px);
}

.light-theme .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.04);
}

.btn-danger {
  background: var(--danger-color);
  color: #fff;
  box-shadow: 0 4px 12px var(--danger-glow);
}

.btn-danger:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 6px 16px var(--danger-glow);
}

.btn-sm {
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 8px;
}

.btn-lg {
  font-size: 17px;
  padding: 16px 32px;
  border-radius: 14px;
}

.w-100 { width: 100%; }

.link-btn {
  background: none;
  border: none;
  font-family: var(--font-main);
  color: var(--secondary-accent);
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.link-btn:hover {
  opacity: 0.8;
}

/* 1. DASHBOARD VIEW STYLING */
.welcome-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.hero-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: linear-gradient(135deg, rgba(13, 17, 30, 0.5) 0%, rgba(38, 30, 62, 0.3) 100%);
}

.hero-card h1 {
  font-size: 38px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ffffff 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.light-theme .hero-card h1 {
  background: linear-gradient(135deg, #1e2230 0%, #5a627a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-card p {
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.quick-stats-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.position-glow {
  background: var(--primary-accent);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.audio-glow {
  background: var(--secondary-accent);
  box-shadow: 0 4px 12px var(--secondary-glow);
}

.accent-glow {
  background: #ff9f43;
  box-shadow: 0 4px 12px rgba(255, 159, 67, 0.3);
}

.score-glow {
  background: var(--success-color);
  box-shadow: 0 4px 12px var(--success-glow);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 4px;
}

.dashboard-secondary {
  padding: 28px;
}

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

.card-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.dashboard-chart-placeholder {
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed var(--panel-border);
  border-radius: var(--radius-md);
}

.empty-state-text {
  color: var(--text-muted);
  font-size: 14px;
}

/* 2. GAME VIEW LAYOUT */
.game-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 24px;
}

.game-meta-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.meta-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.badge-row {
  display: flex;
  gap: 8px;
}

.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--primary-glow);
  color: var(--text-primary);
  border: 1px solid var(--primary-accent);
}

.badge-secondary {
  background: var(--secondary-glow);
  color: var(--text-primary);
  border-color: var(--secondary-accent);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.progress-text {
  color: var(--text-secondary);
}

.progress-val {
  font-weight: 700;
}

.progress-bar-container {
  height: 8px;
  background: var(--panel-border);
  border-radius: 4px;
  overflow: hidden;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.light-theme .stats-grid {
  background: rgba(0, 0, 0, 0.02);
}

.mini-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.mini-val {
  font-size: 16px;
  font-weight: 700;
}

.meta-actions {
  margin-top: auto;
}

/* Board Panel Area & Grid */
.game-board-panel {
  position: relative;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px;
  overflow: hidden;
}

/* Overlays (Start / Pause / Results) */
.game-overlay, .results-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 6, 11, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.light-theme .game-overlay, .light-theme .results-overlay {
  background: rgba(243, 245, 250, 0.9);
}

.game-overlay.hidden, .results-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-content, .results-content {
  max-width: 440px;
  width: 100%;
  text-align: center;
  padding: 24px;
  animation: overlay-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes overlay-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overlay-content h2, .results-content h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 12px;
}

.overlay-content p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 24px;
}

.keyboard-cues {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 32px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  padding: 14px;
  border-radius: var(--radius-md);
}

.light-theme .keyboard-cues {
  background: rgba(0, 0, 0, 0.02);
}

.key-cue {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.key-cue span {
  color: var(--text-secondary);
}

kbd {
  font-family: var(--font-mono);
  background: var(--kbd-bg);
  border: 1px solid var(--kbd-border);
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

/* Results Overlay Summary */
.results-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--primary-accent);
  text-transform: uppercase;
}

.score-summary-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.5fr;
  gap: 20px;
  margin: 24px 0;
  text-align: left;
}

.summary-score-big {
  background: var(--panel-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.score-big-val {
  font-size: 42px;
  font-weight: 800;
  color: var(--secondary-accent);
  line-height: 1;
}

.score-big-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-top: 8px;
}

.summary-details {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--panel-border);
}

.detail-row span {
  color: var(--text-secondary);
}

.performance-eval {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.results-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Trial Timing Bar */
.trial-timer-container {
  width: 100%;
  max-width: 320px;
  height: 4px;
  background: var(--panel-border);
  border-radius: 2px;
  margin-bottom: 24px;
  overflow: hidden;
}

.trial-timer-bar {
  height: 100%;
  width: 0%;
  background: var(--secondary-accent);
  box-shadow: 0 0 6px var(--secondary-accent);
  border-radius: 2px;
  transition: width 0.05s linear;
}

/* The actual 3x3 Grid */
.grid-container {
  width: 100%;
  max-width: 320px;
  aspect-ratio: 1;
  margin-bottom: 32px;
}

.nback-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  height: 100%;
}

.grid-cell {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
}

.light-theme .grid-cell {
  background: rgba(0, 0, 0, 0.02);
}

.grid-cell:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--panel-border-hover);
}

.light-theme .grid-cell:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Active lighting state */
.grid-cell.active-stimulus {
  background: linear-gradient(135deg, var(--secondary-accent) 0%, var(--primary-accent) 100%);
  border-color: transparent;
  box-shadow: 0 0 25px var(--primary-glow), inset 0 0 10px rgba(255,255,255,0.3);
  transform: scale(0.96);
  animation: cell-pulse 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes cell-pulse {
  0% { transform: scale(1.0); }
  50% { transform: scale(0.9); }
  100% { transform: scale(0.96); }
}

.grid-cell-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-center-logo {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  color: var(--text-muted);
}

.radar-ping {
  position: absolute;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--text-muted);
  opacity: 0.15;
}

/* Interactive Match Buttons at Bottom */
.match-buttons-row {
  display: flex;
  gap: 16px;
  width: 100%;
  max-width: 440px;
}

.match-btn {
  flex: 1;
  font-family: var(--font-main);
  background: var(--panel-bg);
  border: 1.5px solid var(--panel-border);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all var(--transition-fast);
  position: relative;
}

.match-btn:hover {
  transform: translateY(-2px);
  border-color: var(--panel-border-hover);
}

.match-btn-key {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 10px;
  color: var(--text-muted);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 1px 4px;
  background: rgba(0,0,0,0.1);
}

.match-btn-icon {
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.match-btn:hover .match-btn-icon {
  color: var(--text-primary);
}

.match-btn-label {
  font-size: 14px;
  font-weight: 600;
}

/* Active Instant Feedback on Button Presses */
.match-btn.feedback-correct {
  background: var(--success-glow);
  border-color: var(--success-color);
  color: #fff;
  box-shadow: 0 4px 15px rgba(16, 172, 132, 0.3);
}

.match-btn.feedback-incorrect {
  background: var(--danger-glow);
  border-color: var(--danger-color);
  color: #fff;
  box-shadow: 0 4px 15px rgba(238, 82, 83, 0.3);
}

/* 3. STATS VIEW STYLING */
.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.stats-header h2 {
  font-size: 28px;
  font-weight: 800;
}

.analytics-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
}

.analytics-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stats-summary-panel h3, .session-history-panel h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.detailed-metrics {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.metric-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
}

.metric-title {
  font-size: 13px;
  color: var(--text-secondary);
}

.metric-num {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.history-list-wrapper {
  max-height: 220px;
  overflow-y: auto;
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: rgba(255,255,255,0.01);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.light-theme .history-item {
  background: rgba(0,0,0,0.01);
}

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-n {
  font-weight: 700;
}

.history-date {
  font-size: 10px;
  color: var(--text-muted);
}

.history-acc {
  font-weight: 700;
  color: var(--secondary-accent);
}

.history-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 0;
}

/* SVG Chart Panel */
.analytics-chart-panel {
  display: flex;
  flex-direction: column;
}

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

.chart-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.chart-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.n-level-dot { background: var(--primary-accent); }
.accuracy-dot { background: var(--secondary-accent); }

.chart-container {
  flex: 1;
  min-height: 280px;
  position: relative;
}

/* SVG Styling */
#stats-svg-chart {
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--panel-border);
  stroke-width: 1;
  stroke-dasharray: 4,4;
}

.chart-axis-line {
  stroke: var(--text-muted);
  stroke-width: 1;
  opacity: 0.3;
}

.chart-axis-text {
  font-family: var(--font-mono);
  font-size: 10px;
  fill: var(--text-muted);
}

.chart-line-n {
  stroke: var(--primary-accent);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line-acc {
  stroke: var(--secondary-accent);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point-n {
  fill: var(--bg-color);
  stroke: var(--primary-accent);
  stroke-width: 2.5;
  transition: r 0.15s ease;
  cursor: pointer;
}

.chart-point-n:hover {
  r: 6;
}

.chart-point-acc {
  fill: var(--bg-color);
  stroke: var(--secondary-accent);
  stroke-width: 2.5;
  transition: r 0.15s ease;
  cursor: pointer;
}

.chart-point-acc:hover {
  r: 6;
}

/* 4. CONFIGURATION DASHBOARD (SETTINGS) */
.settings-title-row {
  margin-bottom: 24px;
}

.settings-title-row h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.settings-title-row p {
  color: var(--text-secondary);
  font-size: 15px;
}

.settings-card {
  max-width: 800px;
}

.form-section {
  padding: 24px 0;
}

.form-section:first-child {
  padding-top: 0;
}

.border-top {
  border-top: 1px solid var(--panel-border);
}

.border-top-thin {
  border-top: 1px solid rgba(255,255,255,0.04);
}

.light-theme .border-top-thin {
  border-top-color: rgba(0,0,0,0.04);
}

.form-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--primary-accent);
}

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

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.form-label-with-val {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.form-val-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  background: var(--panel-border);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--secondary-accent);
}

.form-desc {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Custom inputs styling */
.slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-limit {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.range-slider {
  flex: 1;
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--panel-border);
  outline: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-accent);
  cursor: pointer;
  box-shadow: 0 0 10px var(--primary-glow);
  transition: transform 0.1s ease;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Segmented Control Buttons */
.segmented-control {
  display: flex;
  background: var(--panel-border);
  padding: 4px;
  border-radius: var(--radius-sm);
  gap: 2px;
}

.segment-btn {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.segment-btn:hover {
  color: var(--text-primary);
}

.segment-btn.active {
  background: var(--panel-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  color: var(--text-primary);
  border: 1px solid var(--panel-border);
}

.light-theme .segment-btn.active {
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* Form Select Dropdown */
.form-select {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.form-select:focus {
  border-color: var(--primary-accent);
}

/* Switches (Toggles) */
.toggle-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 16px;
}

.toggle-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--panel-border);
  transition: .3s;
  border-radius: 24px;
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: .3s;
  border-radius: 50%;
}

.switch input:checked + .switch-slider {
  background-color: var(--primary-accent);
}

.switch input:checked + .switch-slider:before {
  transform: translateX(20px);
}

.settings-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* 5. GUIDE VIEW STYLING */
.guide-header {
  margin-bottom: 28px;
}

.guide-header h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.guide-header p {
  color: var(--text-secondary);
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.guide-card {
  height: 100%;
}

.guide-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--secondary-accent);
}

.guide-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.guide-card ul {
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.guide-card.full-width {
  grid-column: 1 / -1;
}

.offset-examples {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.example-item {
  padding: 12px;
  background: rgba(255,255,255,0.01);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
}

.light-theme .example-item {
  background: rgba(0,0,0,0.01);
}

.example-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-accent);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.example-item p {
  font-size: 13px;
  margin-bottom: 0;
}

/* Timeline Example Animation / Graphics */
.timeline-visual {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.01);
  border: 1px solid var(--panel-border);
  padding: 24px;
  border-radius: var(--radius-md);
  margin: 16px 0;
  overflow-x: auto;
}

.light-theme .timeline-visual {
  background: rgba(0,0,0,0.01);
}

.timeline-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 90px;
}

.node-index {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 12px);
  grid-template-rows: repeat(3, 12px);
  gap: 2px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--panel-border);
  padding: 3px;
  border-radius: 4px;
}

.light-theme .mini-grid {
  background: rgba(0,0,0,0.05);
}

.mini-cell {
  background: rgba(255,255,255,0.05);
  border-radius: 1px;
}

.light-theme .mini-cell {
  background: rgba(0,0,0,0.05);
}

.mini-cell.active-cell {
  background: var(--primary-accent);
  box-shadow: 0 0 5px var(--primary-accent);
}

.node-letter {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 16px;
}

.node-meta {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
}

.timeline-arrow {
  font-size: 20px;
  color: var(--text-muted);
}

.match-candidate {
  border: 1.5px dashed var(--secondary-accent);
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 210, 211, 0.03);
}

.position-match-text {
  color: var(--secondary-accent) !important;
  font-weight: 600;
}

.audio-match-text {
  color: #ff9f43 !important;
  font-weight: 600;
}

.node-action {
  font-size: 9px;
  background: var(--kbd-bg);
  border: 1px solid var(--kbd-border);
  padding: 1px 4px;
  border-radius: 4px;
  color: var(--text-primary);
}

.timeline-caption {
  font-size: 12px !important;
  color: var(--text-muted) !important;
  text-align: center;
}

/* Footer styling */
.app-footer {
  padding: 24px 0;
  border-top: 1px solid var(--panel-border);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 48px;
}

/* Responsive Media Queries */
@media (max-width: 960px) {
  .welcome-grid {
    grid-template-columns: 1fr;
  }
  
  .game-layout {
    grid-template-columns: 1fr;
  }
  
  .game-meta-panel {
    order: 2;
  }
  
  .game-board-panel {
    order: 1;
  }
  
  .analytics-layout {
    grid-template-columns: 1fr;
  }
  
  .guide-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-container {
    padding: 0 16px;
  }
  
  .main-header {
    flex-direction: column;
    gap: 16px;
    padding: 16px 0;
  }
  
  .nav-links {
    width: 100%;
    overflow-x: auto;
    justify-content: flex-start;
  }
  
  .nav-link {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .hero-card h1 {
    font-size: 28px;
  }
  
  .quick-stats-container {
    grid-template-columns: 1fr;
  }
  
  .score-summary-grid {
    grid-template-columns: 1fr;
  }
}
