/* ========================================================================== 
   MouseAim Pro - Base layout and reusable UI components
   Theme tokens live in themes.css; active-session rules live in session.css.
   ========================================================================== */

:root {
  /* Typography - System Native High-Tech Stack */
  --font-main: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  
  /* Layout & Spacing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
  
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
  --shadow-neon: 0 0 20px var(--primary-glow);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: url('../assets/grid.svg');
  background-size: 32px 32px;
  opacity: var(--grid-opacity);
  pointer-events: none;
}

/* Accessibility: Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Focus styles for keyboard accessibility */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

/* Main Container Layout */
.app-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  gap: 1.5rem;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.brand-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: var(--radius-sm);
  -webkit-text-fill-color: var(--primary);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Common Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  user-select: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

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

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

.btn-primary:active {
  transform: translateY(0);
}

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

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

.btn-accent {
  background: var(--secondary);
  color: var(--text-on-arena);
  box-shadow: 0 4px 14px var(--secondary-glow);
}

.btn-accent:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--secondary-glow);
}

.btn-icon-only {
  padding: 0.6rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.sound-icon-muted {
  display: none;
}

.btn-sound[aria-pressed="true"] {
  color: var(--accent-red);
  border-color: color-mix(in srgb, var(--accent-red) 55%, transparent);
  background: color-mix(in srgb, var(--accent-red) 10%, var(--bg-surface-elevated));
}

.btn-sound[aria-pressed="true"] .sound-icon-on {
  display: none;
}

.btn-sound[aria-pressed="true"] .sound-icon-muted {
  display: block;
}

.fullscreen-icon-exit {
  display: none;
}

.btn-fullscreen[aria-pressed="true"] {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 55%, transparent);
}

.btn-fullscreen[aria-pressed="true"] .fullscreen-icon-enter {
  display: none;
}

.btn-fullscreen[aria-pressed="true"] .fullscreen-icon-exit {
  display: block;
}

/* Toast popup notification */
.fullscreen-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--toast-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--primary);
  box-shadow: 0 8px 32px var(--primary-glow);
  border-radius: var(--radius-full);
  padding: 0.65rem 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-on-arena);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.fullscreen-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.fullscreen-toast svg {
  color: var(--primary);
}

.fullscreen-toast-highlight {
  color: var(--primary);
  font-weight: 800;
}

.floating-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: min(240px, calc(100vw - 16px));
  padding: 0.42rem 0.65rem;
  color: var(--text-on-arena);
  background: var(--toast-bg);
  border: 1px solid color-mix(in srgb, var(--primary) 42%, transparent);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  pointer-events: none;
  animation: floating-tooltip-enter 120ms ease-out both;
}

@keyframes floating-tooltip-enter {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}


/* ==========================================================================
   Navigation Tabs
   ========================================================================== */
.view-nav {
  display: flex;
  gap: 0.5rem;
  min-width: 0;
  background: var(--bg-surface-elevated);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  align-self: flex-start;
}

.nav-tab {
  flex: 0 0 auto;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.nav-tab svg {
  width: 16px;
  height: 16px;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  background: var(--primary);
  color: var(--text-on-primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Keep navigation labels readable instead of shrinking tabs down to icons. */
@media (max-width: 1200px) {
  .site-header {
    flex-wrap: wrap;
    gap: 0.85rem 1rem;
  }

  .view-nav {
    order: 3;
    width: 100%;
  }

  .nav-tab {
    flex: 1 1 0;
    justify-content: center;
    min-width: 0;
    padding-inline: 0.65rem;
  }
}

@media (max-width: 900px) {
  .nav-tab {
    gap: 0.3rem;
    padding-inline: 0.45rem;
    font-size: 0.78rem;
  }
}

@media (max-width: 800px) {
  .nav-label {
    display: none;
  }

  .nav-tab {
    flex: 1 1 25%;
    padding: 0.55rem;
  }

  .nav-tab svg {
    width: 19px;
    height: 19px;
  }
}

@media (max-width: 640px) {
  .app-layout {
    padding: 0.65rem;
    gap: 0.9rem;
  }

  .site-header {
    padding: 0.8rem;
  }

  .brand-title {
    font-size: 1.05rem;
  }

  .brand-badge {
    display: none;
  }

  .view-nav {
    justify-content: stretch;
  }

  .nav-tab {
    flex: 1 1 25%;
  }
}

/* ==========================================================================
   Main Content Views
   ========================================================================== */
.main-view-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex: 1;
}

.view-section {
  display: none;
  flex-direction: column;
  gap: 1.5rem;
}

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

/* ==========================================================================
   Arena & Training Dashboard
   ========================================================================== */
.training-dashboard {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .training-dashboard {
    grid-template-columns: 1fr;
  }
}

/* Side Control Panel */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--bg-surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition-normal);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

/* Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

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

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.label-hint {
  font-size: 0.75rem;
  color: var(--primary);
  font-family: var(--font-mono);
}

.form-input, .form-select {
  width: 100%;
  padding: 0.55rem 0.8rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px var(--primary-glow);
}

.form-range {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-help {
  color: var(--text-dim);
  font-size: 0.68rem;
}

/* Mode Grid Selection */
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  padding: 0.75rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.mode-btn svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.mode-btn-heading {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.mode-icon {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--primary);
}

.mode-selector-icon {
  width: 1.35rem;
  height: 1.35rem;
}

.mode-btn-title {
  font-size: 0.85rem;
  font-weight: 700;
}

.mode-btn-desc {
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.2;
}

.mode-btn:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.mode-btn.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  box-shadow: 0 0 12px var(--primary-glow);
}

.mode-btn.active .mode-btn-title {
  color: var(--primary);
}

.mode-btn-wide {
  grid-column: 1 / -1;
}

/* ==========================================================================
   Shooting Arena Stage
   ========================================================================== */
.arena-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Live Telemetry HUD */
.live-hud {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.6rem;
}

@media (max-width: 900px) {
  .live-hud {
    grid-template-columns: repeat(3, 1fr);
  }
}

.hud-pill {
  background: var(--bg-surface-glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.hud-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.hud-label svg {
  width: 12px;
  height: 12px;
}

.hud-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
}

.hud-value.highlight-primary { color: var(--primary); }
.hud-value.highlight-secondary { color: var(--secondary); }
.hud-value.highlight-green { color: var(--accent-green); }
.hud-value.highlight-yellow { color: var(--accent-yellow); }

/* Canvas Play Area */
.canvas-container {
  position: relative;
  width: 100%;
  height: 520px;
  max-height: calc(100vh - 280px);
  min-height: 360px;
  background: var(--arena-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.8), var(--shadow-card);
  user-select: none;
}

.arena-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Start / Pause / Overlay screens on canvas */
.arena-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 10, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  z-index: 10;
  padding: 2rem;
  text-align: center;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

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

.overlay-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text-on-arena);
}

.overlay-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 480px;
}

.countdown-display {
  font-family: var(--font-mono);
  font-size: 5rem;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 0 0 30px var(--primary-glow);
  animation: pulseScale 0.6s ease-in-out infinite alternate;
}

@keyframes pulseScale {
  from { transform: scale(0.9); opacity: 0.8; }
  to { transform: scale(1.1); opacity: 1; }
}

.arena-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.2rem;
}

.instruction-text {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.instruction-text kbd {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Post-Session Telemetry Modal / View (Bento Grid)
   ========================================================================== */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.results-header-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: color-mix(in srgb, var(--primary) 8%, var(--bg-surface));
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
}

.results-main-score {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.score-badge-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
}

.score-big-number {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
  color: var(--text-main);
  text-shadow: 0 0 20px var(--primary-glow);
}

#resModeBadge,
.mode-identity,
.progress-card-title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

#resModeBadge .mode-icon {
  width: 0.95rem;
  height: 0.95rem;
}

.bento-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 1024px) {
  .bento-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .bento-grid {
    grid-template-columns: 1fr;
  }
}

.bento-card {
  background: var(--bg-surface-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
}

.bento-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--border-subtle);
}

.bento-card.accent-cyan::before { background: var(--primary); }
.bento-card.accent-pink::before { background: var(--secondary); }
.bento-card.accent-purple::before { background: var(--accent-purple); }
.bento-card.accent-green::before { background: var(--accent-green); }
.bento-card.accent-yellow::before { background: var(--accent-yellow); }

.aim-diagnostic {
  gap: 1rem;
}

.aim-diagnostic-header {
  margin-bottom: 0;
}

.aim-confidence {
  padding: 0.22rem 0.55rem;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
}

.aim-diagnostic[data-diagnostic-state="high"] .aim-confidence {
  color: var(--accent-green);
}

.aim-diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 0.6rem;
}

.aim-metric {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-sm);
}

.aim-metric span {
  color: var(--text-dim);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.aim-metric strong {
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.aim-insights {
  display: grid;
  gap: 0.4rem;
  padding-left: 1.1rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.aim-insight-positive { color: var(--accent-green); }
.aim-insight-warning { color: var(--accent-yellow); }

.aim-diagnostic-note {
  color: var(--text-dim);
  font-size: 0.68rem;
}

.bento-card-span-2 {
  grid-column: span 2;
}

@media (max-width: 640px) {
  .bento-card-span-2 {
    grid-column: span 1;
  }
}

.bento-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.bento-title svg {
  width: 16px;
  height: 16px;
}

.bento-stat {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
}

.bento-subtext {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Heatmap & Path Replay Visualizer */
.visualizer-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 900px) {
  .visualizer-container {
    grid-template-columns: 1fr;
  }
}

.viz-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.viz-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.viz-title-copy {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

.btn-viz-expand {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  padding: 0.42rem;
}

.viz-canvas {
  width: 100%;
  height: 240px;
  background: var(--arena-bg);
  border-radius: var(--radius-sm);
  display: block;
}

body.modal-open {
  overflow: hidden;
}

.graph-modal[hidden] {
  display: none;
}

.graph-modal {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 2vw, 2rem);
}

.graph-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.graph-modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(1200px, 96vw);
  height: min(820px, 90dvh);
  min-height: 320px;
  padding: clamp(0.85rem, 2vw, 1.5rem);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.graph-modal-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.graph-modal-header h2 {
  color: var(--text-main);
  font-size: clamp(1rem, 2vw, 1.35rem);
}

.graph-modal-header .label-hint {
  display: block;
  margin-top: 0.2rem;
}

.graph-modal-close {
  flex: 0 0 auto;
}

.graph-modal-canvas {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  background: var(--arena-bg);
  border-radius: var(--radius-sm);
}

@media (max-width: 560px) {
  .viz-title-copy {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.15rem;
  }

  .graph-modal {
    padding: 0.5rem;
  }

  .graph-modal-panel {
    width: 100%;
    height: 92dvh;
    padding: 0.75rem;
  }
}

/* ========================================================================== 
   History & Records Table
   ========================================================================== */
.progress-dashboard {
  gap: 1.25rem;
}

.progress-header > div {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.progress-summary {
  max-width: 760px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.progress-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  padding: 1rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.progress-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.progress-card-heading h3 {
  overflow: hidden;
  color: var(--text-main);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-card-title {
  min-width: 0;
}

.trend-badge {
  flex: 0 0 auto;
  padding: 0.18rem 0.48rem;
  border: 1px solid currentColor;
  border-radius: var(--radius-full);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.trend-up { color: var(--accent-green); }
.trend-down { color: var(--accent-red); }
.trend-stable { color: var(--text-muted); }
.trend-pending { color: var(--accent-yellow); }

.progress-metric {
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 850;
}

.progress-caption {
  color: var(--text-dim);
  font-size: 0.72rem;
}

.progress-sparkline {
  width: 100%;
  height: 72px;
  margin-top: 0.35rem;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-main) 72%, transparent);
}

.progress-feedback {
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.progress-feedback h3 {
  margin-bottom: 0.65rem;
  color: var(--text-main);
  font-size: 0.85rem;
}

.progress-feedback ul {
  display: grid;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.progress-feedback li {
  padding: 0.65rem 0.8rem;
  border-left: 3px solid var(--text-dim);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--bg-surface-elevated) 82%, transparent);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.progress-feedback .insight-positive { border-left-color: var(--accent-green); }
.progress-feedback .insight-negative { border-left-color: var(--accent-red); }
.progress-feedback .insight-mixed { border-left-color: var(--accent-yellow); }
.progress-feedback .insight-stable { border-left-color: var(--primary); }

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table th {
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  color: var(--text-main);
}

.data-table tr:hover td {
  background: color-mix(in srgb, var(--primary) 3%, transparent);
}

/* ==========================================================================
   Crosshair & Settings View
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.settings-card-wide {
  grid-column: 1 / -1;
}

@media (max-width: 800px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.crosshair-preview-box {
  width: 100%;
  height: 180px;
  background: var(--arena-bg);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-top: 0.5rem;
}

.crosshair-preview-box canvas {
  width: 100%;
  height: 100%;
  display: block;
}


.crosshair-target-preview {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--secondary);
  opacity: 0.4;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  margin-top: auto;
  padding: 1.25rem 1.5rem;
  background: var(--bg-surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: var(--primary);
}

.btn svg,
.btn path {
  pointer-events: none;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}






.hidden {
  display: none !important;
}

.audio-info-text {
  margin-top: 1rem;
  line-height: 1.6;
}

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

.text-dim {
  color: var(--text-dim);
}

.score-cell {
  font-weight: 700;
  color: var(--primary);
}
