/* Retro 8-bit + GeoCities Design System */

/* Import retro fonts from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

/* ============================================
   CSS Custom Properties (Color Palette)
   ============================================ */
:root {
  /* CGA Colors (Classic) */
  --cga-black: #000000;
  --cga-blue: #0000AA;
  --cga-green: #00AA00;
  --cga-cyan: #00AAAA;
  --cga-red: #AA0000;
  --cga-magenta: #AA00AA;
  --cga-brown: #AA5500;
  --cga-white: #AAAAAA;
  --cga-bright-cyan: #55FFFF;
  --cga-bright-magenta: #FF55FF;
  --cga-bright-white: #FFFFFF;
  
  /* Neon Accent Colors */
  --neon-pink: #FF10F0;
  --neon-blue: #00D9FF;
  --neon-green: #39FF14;
  --neon-yellow: #FFFF00;
  --neon-orange: #FF6600;
  
  /* Semantic Colors */
  --bg-primary: #000000;
  --bg-secondary: #0A0A0A;
  --text-primary: #55FFFF;
  --text-secondary: #FFFFFF;
  --border-primary: #00FFFF;
  --border-secondary: #FF00FF;
  --success: #39FF14;
  --error: #FF0000;
  --warning: #FFFF00;
  
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  
  /* Responsive spacing - adapts to viewport */
  --spacing-responsive-xs: 4px;
  --spacing-responsive-sm: 8px;
  --spacing-responsive-md: 16px;
  --spacing-responsive-lg: 24px;
  
  /* Touch target minimum (44px per WCAG guidelines) */
  --touch-target-min: 44px;
  
  /* Container padding - responsive */
  --container-padding: 24px;
  
  /* Border widths */
  --border-thin: 2px;
  --border-medium: 4px;
  --border-thick: 6px;
  
  /* Responsive border widths - adapt to viewport */
  /* Requirements: 5.3 */
  --border-thin-responsive: 2px;
  --border-medium-responsive: 4px;
  --border-thick-responsive: 6px;
  
  /* Glow/shadow intensity multiplier (1 = full, 0.5 = half) */
  /* Requirements: 5.3 */
  --glow-intensity: 1;
  --shadow-blur-base: 20px;
  --shadow-blur-responsive: 20px;
  
  /* ============================================
     CONSISTENT TYPOGRAPHY SIZES
     These are the STANDARD sizes used across ALL themes
     ============================================ */
  --font-size-base: 16px;        /* Body text */
  --font-size-small: 14px;       /* Small text, labels */
  --font-size-large: 18px;       /* Larger body text */
  --font-size-h1: 24px;          /* Main headings */
  --font-size-h2: 20px;          /* Section headings */
  --font-size-h3: 18px;          /* Sub-section headings */
  --font-size-button: 14px;      /* Button text */
  --font-size-button-small: 12px;
  --font-size-button-large: 16px;
  --font-size-badge: 11px;       /* Badge text */
  --font-size-input: 16px;       /* Form inputs */
  --font-size-label: 13px;       /* Form labels */
  
  --line-height-base: 1.5;
  --line-height-tight: 1.3;
  --line-height-relaxed: 1.6;
  
  /* ============================================
     RESPONSIVE TYPOGRAPHY SIZES
     These adapt based on viewport - used by headings
     Requirements: 5.2
     ============================================ */
  --font-size-h1-responsive: 24px;
  --font-size-h2-responsive: 20px;
  --font-size-h3-responsive: 18px;
}

/* ============================================
   Base Styles
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

body {
  font-family: 'VT323', monospace;
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  background-image: 
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 255, 255, 0.03) 2px,
      rgba(0, 255, 255, 0.03) 4px
    );
  min-height: 100vh;
  overflow-x: hidden;
  /* Prevent horizontal scroll on mobile */
  max-width: 100vw;
}

/* Ensure html also prevents horizontal overflow */
html {
  overflow-x: hidden;
}

/* ============================================
   Typography
   ============================================ */
h1, h2, h3, h4, h5, h6, .pixel-text {
  font-family: 'Press Start 2P', monospace;
  text-shadow: 2px 2px 0px #000;
  line-height: var(--line-height-tight);
  color: var(--text-secondary);
}

/* Headings use responsive variables that adapt to viewport */
/* Requirements: 5.2 */
h1 {
  font-size: var(--font-size-h1-responsive);
  margin-bottom: var(--spacing-lg);
  text-transform: uppercase;
}

h2 {
  font-size: var(--font-size-h2-responsive);
  margin-bottom: var(--spacing-md);
  text-transform: uppercase;
}

h3 {
  font-size: var(--font-size-h3-responsive);
  margin-bottom: var(--spacing-sm);
}

p {
  margin-bottom: var(--spacing-md);
}

a {
  color: var(--neon-blue);
  text-decoration: underline;
  cursor: pointer;
}

a:hover {
  color: var(--neon-pink);
  text-shadow: 0 0 10px var(--neon-pink);
}

/* ============================================
   Layout Components
   ============================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--container-padding);
  width: 100%;
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--container-padding);
  width: 100%;
}

/* ============================================
   Header Components
   ============================================ */
.header-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.header-title {
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.header-controls {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

/* Navigation rows */
.header-nav {
  text-align: center;
}

.nav-row {
  display: flex;
  gap: var(--spacing-sm);
  justify-content: center;
  flex-wrap: wrap;
}

.nav-row-primary {
  margin-bottom: var(--spacing-sm);
}

.nav-row-secondary {
  /* Secondary nav inherits from .nav-row */
}

/* Navigation buttons - base styles for touch targets */
.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Ensure minimum touch target on all devices */
  min-height: var(--touch-target-min);
}

/* ============================================
   Pixel Borders
   ============================================ */
/* Pixel borders use responsive variables for mobile optimization */
/* Requirements: 5.3 */
.pixel-border {
  border: var(--border-medium-responsive) solid var(--border-primary);
  box-shadow: 
    0 0 0 var(--border-thin-responsive) var(--bg-primary),
    0 0 0 var(--border-thick-responsive) var(--border-primary),
    0 0 var(--shadow-blur-responsive) var(--border-primary);
  padding: var(--spacing-lg);
  background-color: var(--bg-secondary);
  image-rendering: pixelated;
}

.pixel-border-magenta {
  border-color: var(--border-secondary);
  box-shadow: 
    0 0 0 var(--border-thin-responsive) var(--bg-primary),
    0 0 0 var(--border-thick-responsive) var(--border-secondary),
    0 0 var(--shadow-blur-responsive) var(--border-secondary);
}

.pixel-border-thin {
  border-width: var(--border-thin-responsive);
  box-shadow: 
    0 0 0 1px var(--bg-primary),
    0 0 0 calc(var(--border-thin-responsive) + 1px) var(--border-primary),
    0 0 calc(var(--shadow-blur-responsive) / 2) var(--border-primary);
}

/* ============================================
   Retro Buttons
   ============================================ */
.retro-button {
  font-family: 'Press Start 2P', monospace;
  font-size: var(--font-size-button);
  background: var(--border-secondary);
  border: var(--border-medium) solid var(--text-secondary);
  box-shadow: 4px 4px 0 var(--bg-primary);
  color: var(--text-secondary);
  padding: 12px 24px;
  text-transform: uppercase;
  cursor: pointer;
  image-rendering: pixelated;
  transition: all 0.1s ease;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.retro-button:hover {
  background: var(--border-primary);
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--bg-primary);
  color: var(--bg-primary);
}

.retro-button:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--bg-primary);
}

.retro-button:disabled {
  background: var(--cga-white);
  color: var(--cga-black);
  cursor: not-allowed;
  opacity: 0.5;
}

.retro-button-cyan {
  background: var(--border-primary);
  color: var(--bg-primary);
}

.retro-button-cyan:hover {
  background: var(--neon-green);
}

.retro-button-green {
  background: var(--success);
  color: var(--bg-primary);
}

.retro-button-green:hover {
  background: var(--neon-yellow);
}

.retro-button-small {
  font-size: var(--font-size-button-small);
  padding: 8px 16px;
}

.retro-button-large {
  font-size: var(--font-size-button-large);
  padding: 16px 32px;
}

/* ============================================
   CRT Scanlines Effect
   Performance optimized: uses will-change and 
   content-visibility for GPU acceleration
   ============================================ */
.crt-effect {
  position: relative;
}

.crt-effect::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15),
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 9999;
  /* Performance optimizations */
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Optional: CRT screen curvature effect */
.crt-screen {
  border-radius: 20px;
  box-shadow: 
    inset 0 0 50px rgba(0, 0, 0, 0.5),
    0 0 50px rgba(0, 255, 255, 0.3);
}

/* ============================================
   Animations
   ============================================ */

/* Blinking text - GPU accelerated */
.blink {
  animation: blink 1s step-start infinite;
  will-change: opacity;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* Slow blink for emphasis - GPU accelerated */
.blink-slow {
  animation: blink-slow 2s ease-in-out infinite;
  will-change: opacity;
}

@keyframes blink-slow {
  0%, 49% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0.3;
  }
}

/* Pixel fade in */
.pixel-fade-in {
  animation: pixelate-in 0.5s ease-out;
}

@keyframes pixelate-in {
  0% {
    filter: blur(10px);
    opacity: 0;
  }
  100% {
    filter: blur(0);
    opacity: 1;
  }
}

/* Spinning animation for loading */
.spin {
  animation: spin 2s linear infinite;
}

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

/* Pulse glow effect - GPU accelerated */
/* Uses responsive shadow blur for mobile optimization */
/* Requirements: 5.3 */
.pulse-glow {
  animation: pulse-glow 2s ease-in-out infinite;
  will-change: box-shadow;
}

@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 calc(var(--shadow-blur-responsive) / 2) var(--border-primary);
  }
  50% {
    box-shadow: 0 0 calc(var(--shadow-blur-responsive) * 1.5) var(--border-primary);
  }
}

/* Shake animation for errors */
.shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* ============================================
   Marquee Text (Modern CSS Alternative)
   ============================================ */
.marquee {
  overflow: hidden;
  white-space: nowrap;
  background: var(--bg-secondary);
  border: var(--border-thin) solid var(--border-primary);
  padding: var(--spacing-sm);
  margin: var(--spacing-md) 0;
}

.marquee span {
  display: inline-block;
  animation: marquee 20s linear infinite;
  padding-left: 100%;
  /* GPU acceleration for smooth animation */
  will-change: transform;
  transform: translateZ(0);
}

@keyframes marquee {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-100%, 0, 0);
  }
}

/* ============================================
   Retro Badges and Decorations
   ============================================ */
.badge {
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: var(--font-size-badge);
  padding: 4px 8px;
  border: 2px solid;
  text-transform: uppercase;
  margin: 0 4px;
}

.badge-new {
  background: var(--neon-yellow);
  color: var(--bg-primary);
  border-color: var(--neon-yellow);
  animation: blink-slow 1.5s ease-in-out infinite;
}

.badge-hot {
  background: var(--neon-orange);
  color: var(--text-secondary);
  border-color: var(--neon-orange);
  animation: pulse-glow 2s ease-in-out infinite;
}

.badge-updated {
  background: var(--neon-green);
  color: var(--bg-primary);
  border-color: var(--neon-green);
}

.badge-admin {
  background: var(--neon-pink);
  color: var(--text-secondary);
  border-color: var(--neon-pink);
}

.badge-success {
  background: var(--success);
  color: var(--bg-primary);
  border-color: var(--success);
  font-size: 8px;
  padding: 2px 6px;
}

.badge-warning {
  background: var(--warning);
  color: var(--bg-primary);
  border-color: var(--warning);
  font-size: 8px;
  padding: 2px 6px;
}

.badge-error {
  background: var(--error);
  color: var(--text-secondary);
  border-color: var(--error);
  font-size: 8px;
  padding: 2px 6px;
}

.badge-info {
  background: var(--neon-cyan);
  color: var(--bg-primary);
  border-color: var(--neon-cyan);
  font-size: 8px;
  padding: 2px 6px;
}

/* ============================================
   Visitor Counter
   ============================================ */
.visitor-counter {
  font-family: 'Press Start 2P', monospace;
  font-size: var(--font-size-badge);
  text-align: center;
  padding: var(--spacing-sm);
  border: var(--border-thin) solid var(--border-primary);
  background: var(--bg-secondary);
  display: inline-block;
  margin: var(--spacing-md) 0;
}

.visitor-counter .digits {
  color: var(--neon-green);
  font-size: var(--font-size-button);
  letter-spacing: 2px;
}

/* ============================================
   "Best Viewed In" Badges
   ============================================ */
.retro-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  justify-content: center;
  margin: var(--spacing-lg) 0;
}

.retro-badges img {
  height: 31px;
  image-rendering: pixelated;
}

/* ============================================
   Under Construction
   ============================================ */
.under-construction {
  text-align: center;
  padding: var(--spacing-lg);
  border: var(--border-medium) solid var(--neon-yellow);
  background: repeating-linear-gradient(
    45deg,
    var(--bg-primary),
    var(--bg-primary) 10px,
    var(--neon-yellow) 10px,
    var(--neon-yellow) 20px
  );
  margin: var(--spacing-lg) 0;
}

.under-construction .icon {
  font-size: 48px;
  animation: blink 1s step-start infinite;
}

/* ============================================
   Forms
   ============================================ */
.retro-form {
  max-width: 600px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-label {
  font-family: 'Press Start 2P', monospace;
  font-size: var(--font-size-label);
  display: block;
  margin-bottom: var(--spacing-sm);
  color: var(--text-primary);
  text-transform: uppercase;
}

.form-input,
.form-textarea,
.form-select {
  font-family: 'VT323', monospace;
  font-size: var(--font-size-input);
  width: 100%;
  padding: var(--spacing-md);
  border: var(--border-medium) solid var(--border-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: inset 0 0 10px rgba(0, 255, 255, 0.2);
}

/* Form input focus uses responsive shadow blur */
/* Requirements: 5.3 */
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--neon-pink);
  box-shadow: 
    inset 0 0 calc(var(--shadow-blur-responsive) / 2) rgba(255, 16, 240, 0.3),
    0 0 var(--shadow-blur-responsive) var(--neon-pink);
}

.form-input::placeholder {
  color: var(--cga-white);
  opacity: 0.5;
}

/* Blinking cursor effect */
.form-input-cursor::after {
  content: '█';
  animation: blink 1s step-start infinite;
  margin-left: 2px;
}

/* Radio buttons and checkboxes */
.form-radio,
.form-checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  border: var(--border-thin) solid var(--border-primary);
  background: var(--bg-primary);
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  margin-right: var(--spacing-sm);
}

.form-radio {
  border-radius: 50%;
}

.form-radio:checked::before,
.form-checkbox:checked::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: var(--neon-green);
  box-shadow: 0 0 10px var(--neon-green);
}

.form-radio:checked::before {
  border-radius: 50%;
}

.form-checkbox:checked::before {
  width: 10px;
  height: 10px;
}

/* Error states */
.form-error {
  color: var(--error);
  font-family: 'Press Start 2P', monospace;
  font-size: var(--font-size-badge);
  margin-top: var(--spacing-sm);
  animation: shake 0.5s ease-in-out;
}

.form-input.error,
.form-textarea.error,
.form-select.error {
  border-color: var(--error);
  box-shadow: 
    inset 0 0 10px rgba(255, 0, 0, 0.3),
    0 0 20px var(--error);
}

/* ============================================
   Loading Indicators
   ============================================ */
.loading {
  text-align: center;
  padding: var(--spacing-xl);
}

.loading-spinner {
  display: inline-block;
  width: 64px;
  height: 64px;
  border: var(--border-medium) solid var(--border-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  /* GPU acceleration */
  will-change: transform;
}

.loading-text {
  font-family: 'Press Start 2P', monospace;
  font-size: var(--font-size-button);
  margin-top: var(--spacing-md);
  animation: blink 1s step-start infinite;
}

.loading-dots::after {
  content: '...';
  animation: loading-dots 1.5s steps(4, end) infinite;
}

@keyframes loading-dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* ============================================
   Progress Bar
   ============================================ */
.progress-bar {
  width: 100%;
  height: 32px;
  border: var(--border-medium) solid var(--border-primary);
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    var(--neon-green),
    var(--neon-green) 8px,
    var(--success) 8px,
    var(--success) 16px
  );
  transition: width 0.3s ease;
  box-shadow: 0 0 20px var(--neon-green);
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Press Start 2P', monospace;
  font-size: var(--font-size-badge);
  color: var(--text-secondary);
  text-shadow: 1px 1px 0 var(--bg-primary);
  z-index: 1;
}

/* ============================================
   Alerts and Messages
   ============================================ */
.alert {
  padding: var(--spacing-md);
  border: var(--border-medium) solid;
  margin: var(--spacing-md) 0;
  font-family: 'VT323', monospace;
  font-size: var(--font-size-large);
}

.alert-success {
  border-color: var(--success);
  background: rgba(57, 255, 20, 0.1);
  color: var(--success);
}

.alert-error {
  border-color: var(--error);
  background: rgba(255, 0, 0, 0.1);
  color: var(--error);
  animation: shake 0.5s ease-in-out;
}

.alert-warning {
  border-color: var(--warning);
  background: rgba(255, 255, 0, 0.1);
  color: var(--warning);
}

.alert-info {
  border-color: var(--border-primary);
  background: rgba(0, 255, 255, 0.1);
  color: var(--text-primary);
}

/* ============================================
   Page Transitions
   ============================================ */
.page-transition-out {
  animation: page-fade-out 0.3s ease-out forwards;
}

@keyframes page-fade-out {
  0% {
    opacity: 1;
    filter: blur(0);
  }
  100% {
    opacity: 0;
    filter: blur(5px);
  }
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }

.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

.hidden { display: none; }
.visible { display: block; }

/* Responsive visibility utilities */
@media (max-width: 480px) {
  .hide-mobile { display: none !important; }
}

@media (max-width: 768px) {
  .hide-tablet { display: none !important; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* ============================================
   Accessibility
   ============================================ */
.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;
}

/* Reduce motion for accessibility */
/* Applies when user has OS-level reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .crt-effect::before {
    display: none;
  }
}

/* ============================================
   Responsive Design
   ============================================ */

/* Tablet breakpoint - responsive variable overrides */
@media (max-width: 768px) {
  :root {
    --container-padding: 16px;
    --spacing-responsive-lg: 16px;
    --spacing-responsive-md: 12px;
    
    /* Responsive typography - proportional reduction (~83% of desktop) */
    /* Requirements: 5.2 */
    --font-size-h1-responsive: 20px;
    --font-size-h2-responsive: 17px;
    --font-size-h3-responsive: 15px;
    
    /* Responsive border widths - thinner on tablet */
    /* Requirements: 5.3 */
    --border-thin-responsive: 1px;
    --border-medium-responsive: 2px;
    --border-thick-responsive: 4px;
    
    /* Reduced glow/shadow intensity on tablet */
    /* Requirements: 5.3 */
    --shadow-blur-responsive: 12px;
  }
  
  body {
    font-size: var(--font-size-base);
  }
  
  /* Heading text shadow - reduce on tablet for readability */
  h1, h2, h3, h4, h5, h6, .pixel-text {
    text-shadow: 1px 1px 0px #000;
  }
  
  .retro-button {
    font-size: var(--font-size-button-small);
    padding: 10px 20px;
  }
  
  /* Container padding now handled by --container-padding variable */
  
  /* Pixel border padding reduced on tablet */
  .pixel-border {
    padding: var(--spacing-md);
  }
  
  /* Simplify effects on mobile */
  .crt-effect::before {
    opacity: 0.5;
  }
  
  /* Header responsive - stack on mobile */
  .header-top-bar {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .header-title {
    min-width: auto;
    width: 100%;
    text-align: center;
  }
  
  .header-controls {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  
  /* Navigation buttons - ensure touch targets */
  .nav-button {
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* Small mobile breakpoint - responsive variable overrides */
@media (max-width: 480px) {
  :root {
    --container-padding: 12px;
    --spacing-responsive-md: 10px;
    --spacing-responsive-sm: 6px;
    
    /* Responsive typography - proportional reduction (~67% of desktop) */
    /* Requirements: 5.2 */
    --font-size-h1-responsive: 16px;
    --font-size-h2-responsive: 14px;
    --font-size-h3-responsive: 12px;
    
    /* Responsive border widths - minimal on mobile */
    /* Requirements: 5.3 */
    --border-thin-responsive: 1px;
    --border-medium-responsive: 2px;
    --border-thick-responsive: 3px;
    
    /* Minimal glow/shadow on mobile for performance and clarity */
    /* Requirements: 5.3 */
    --shadow-blur-responsive: 8px;
  }
  
  .retro-button {
    font-size: 10px;
    padding: 8px 16px;
  }
  
  /* Button box-shadow reduced on mobile */
  /* Requirements: 5.3 */
  .retro-button {
    box-shadow: 2px 2px 0 var(--bg-primary);
  }
  
  .retro-button:hover {
    box-shadow: 1px 1px 0 var(--bg-primary);
  }
  
  /* Navigation - full width stacked buttons on small mobile */
  .nav-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .nav-button {
    width: 100%;
    min-height: var(--touch-target-min);
  }
}

/* Extra small mobile breakpoint - minimum readable sizes */
@media (max-width: 360px) {
  :root {
    --container-padding: 8px;
    --spacing-responsive-sm: 4px;
    
    /* Responsive typography - minimum readable sizes */
    /* Requirements: 5.2 */
    --font-size-h1-responsive: 14px;
    --font-size-h2-responsive: 12px;
    --font-size-h3-responsive: 11px;
    
    /* Minimal border widths on extra small screens */
    /* Requirements: 5.3 */
    --border-thin-responsive: 1px;
    --border-medium-responsive: 1px;
    --border-thick-responsive: 2px;
    
    /* Minimal glow/shadow for performance */
    /* Requirements: 5.3 */
    --shadow-blur-responsive: 4px;
  }
  
  /* Remove outer glow entirely on very small screens for clarity */
  /* Requirements: 5.3 */
  .pixel-border {
    box-shadow: 
      0 0 0 1px var(--bg-primary),
      0 0 0 2px var(--border-primary);
  }
  
  .pixel-border-magenta {
    box-shadow: 
      0 0 0 1px var(--bg-primary),
      0 0 0 2px var(--border-secondary);
  }
  
  .pixel-border-thin {
    box-shadow: 
      0 0 0 1px var(--bg-primary),
      0 0 0 2px var(--border-primary);
  }
}

/* ============================================
   Quiz Grid Responsive Styles
   Requirements: 2.1, 2.2, 2.3
   ============================================ */

/* Quiz grid base styles */
#quiz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-xl);
}

/* Quiz card styles */
.quiz-card {
  text-align: center;
  padding: var(--spacing-lg);
}

.quiz-card .quiz-icon {
  font-size: 64px;
  margin-bottom: var(--spacing-md);
}

.quiz-card .quiz-question-count {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--neon-green);
}

/* Tablet breakpoint: 2 columns (768px - 1024px) */
/* Requirements: 2.1 */
@media (min-width: 768px) and (max-width: 1024px) {
  #quiz-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile breakpoint: 1 column (<768px) */
/* Requirements: 2.2 */
@media (max-width: 767px) {
  #quiz-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }
}

/* Mobile: Reduce icon sizes and padding */
/* Requirements: 2.3 */
@media (max-width: 768px) {
  .quiz-card {
    padding: var(--spacing-md);
  }
  
  .quiz-card .quiz-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-sm);
  }
  
  /* Quiz card h3 uses responsive variable automatically */
  
  .quiz-card p {
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-sm);
  }
}

/* Small mobile: Further reduce sizes */
@media (max-width: 480px) {
  .quiz-card {
    padding: var(--spacing-sm);
  }
  
  .quiz-card .quiz-icon {
    font-size: 40px;
  }
  
  /* Quiz card h3 uses responsive variable automatically */
}

/* ============================================
   Responsive Table Handling
   Requirements: 3.1, 3.2, 3.3
   ============================================ */

/* Table responsive wrapper - prefer fitting content without scroll */
/* Requirements: 3.1, 3.3 */
.table-responsive {
  width: 100%;
  overflow-x: visible; /* Changed: prefer no horizontal scroll */
  position: relative;
}

/* Only enable horizontal scroll when explicitly needed */
.table-responsive.force-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Scroll shadow indicators for visual feedback */
/* Requirements: 3.3 */
.table-responsive.force-scroll::before,
.table-responsive.force-scroll::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 20px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.table-responsive.force-scroll::before {
  left: 0;
  background: linear-gradient(to right, var(--bg-secondary) 0%, transparent 100%);
}

.table-responsive.force-scroll::after {
  right: 0;
  background: linear-gradient(to left, var(--bg-secondary) 0%, transparent 100%);
}

/* Show scroll shadows when content is scrollable */
.table-responsive.has-scroll-left::before {
  opacity: 1;
}

.table-responsive.has-scroll-right::after {
  opacity: 1;
}

/* ============================================
   Admin & Leaderboard Table Styles
   Compact, retro-styled tables that fit without scrolling
   ============================================ */

/* Base admin table styles */
.admin-table,
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'VT323', monospace;
  font-size: var(--font-size-base);
  table-layout: fixed;
}

.admin-table th,
.results-table th {
  background: var(--bg-secondary);
  padding: var(--spacing-sm) var(--spacing-xs);
  text-align: left;
  border-bottom: 2px solid var(--neon-cyan);
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--neon-cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-table td,
.results-table td {
  padding: var(--spacing-sm) var(--spacing-xs);
  border-bottom: 1px solid var(--border-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0; /* Required for text-overflow with table-layout: fixed */
}

.admin-table tr:hover,
.results-table tr:hover {
  background: rgba(0, 255, 255, 0.1);
}

/* Compact action buttons in tables */
.admin-table .action-cell,
.results-table .action-cell {
  white-space: nowrap;
  overflow: visible; /* Allow button to show fully */
}

.admin-table .action-cell .retro-button-small,
.results-table .action-cell .retro-button-small {
  padding: 4px 8px;
  font-size: 9px;
  margin: 2px;
}

/* Results table specific - ensure no horizontal scroll */
.results-table {
  table-layout: fixed;
  width: 100%;
}

/* Badge styling in tables - more compact */
.results-table .badge {
  font-size: 7px;
  padding: 2px 4px;
  white-space: nowrap;
}

/* Tablet: More compact tables */
@media (max-width: 768px) {
  .admin-table th,
  .results-table th {
    font-size: 8px;
    padding: var(--spacing-xs);
  }
  
  .admin-table td,
  .results-table td {
    font-size: 13px;
    padding: var(--spacing-xs);
  }
  
  .admin-table .action-cell .retro-button-small,
  .results-table .action-cell .retro-button-small {
    padding: 3px 6px;
    font-size: 8px;
  }
}

/* Mobile: Stack or hide less important columns */
@media (max-width: 480px) {
  .admin-table th,
  .results-table th {
    font-size: 7px;
  }
  
  .admin-table td,
  .results-table td {
    font-size: 12px;
  }
  
  /* Hide less important columns on mobile */
  .admin-table .hide-mobile,
  .results-table .hide-mobile {
    display: none;
  }
}

/* Ensure tables inside responsive wrapper don't break layout */
.table-responsive table {
  min-width: 100%;
  white-space: nowrap;
}

/* Mobile table styles */
@media (max-width: 768px) {
  .table-responsive {
    margin: 0 calc(-1 * var(--spacing-sm));
    padding: 0 var(--spacing-sm);
    width: calc(100% + var(--spacing-md));
  }
  
  /* Allow text wrapping on mobile for better readability */
  .table-responsive table {
    white-space: normal;
  }
  
  .table-responsive table th,
  .table-responsive table td {
    min-width: 80px;
  }
}

/* ============================================
   Admin Panel Responsive Styles
   Requirements: 4.1, 4.2, 4.3
   ============================================ */

/* Admin tab navigation base styles */
.admin-tabs {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  justify-content: center;
}

/* Tab button base styles for consistent sizing */
.tab-button {
  min-height: var(--touch-target-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

/* Admin bulk action bar base styles */
.admin-bulk-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.admin-bulk-actions-buttons {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

/* Admin form grid base styles */
.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-md);
}

/* Admin filter row base styles */
.admin-filter-row {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
  align-items: flex-end;
}

.admin-filter-row > * {
  flex: 1;
  min-width: 150px;
}

/* Admin header with actions */
.admin-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

/* Tablet breakpoint for admin panel */
/* Requirements: 4.1 */
@media (max-width: 768px) {
  /* Admin tabs - wrap with consistent gap */
  .admin-tabs,
  #admin-container .pixel-border-thin > div[style*="flex"] {
    gap: var(--spacing-xs);
  }
  
  /* Reduce tab button sizes on tablet */
  .tab-button,
  #admin-container .tab-button {
    font-size: 9px;
    padding: 6px 10px;
    min-height: var(--touch-target-min);
  }
  
  /* Admin form grids - 2 columns on tablet */
  .admin-form-grid,
  #admin-container div[style*="grid-template-columns"] {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Admin filter rows - wrap properly */
  .admin-filter-row,
  #admin-container div[style*="flex"][style*="gap"] {
    flex-wrap: wrap;
  }
  
  /* Admin bulk action bars - stack on tablet */
  .admin-bulk-actions,
  #admin-container div[id^="bulk-actions"] > div {
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-sm);
  }
  
  .admin-bulk-actions-buttons,
  #admin-container div[id^="bulk-actions"] div[style*="flex"][style*="gap"]:last-child {
    justify-content: center;
  }
  
  /* Admin header actions - wrap on tablet */
  .admin-header-actions {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  
  .admin-header-actions > button {
    width: 100%;
  }
}

/* Mobile breakpoint for admin panel */
/* Requirements: 4.1, 4.2, 4.3 */
@media (max-width: 480px) {
  /* Admin tabs - smaller on mobile, wrap into rows */
  .tab-button,
  #admin-container .tab-button {
    font-size: 8px;
    padding: 8px 8px;
    min-height: var(--touch-target-min);
    flex: 1 1 calc(50% - var(--spacing-xs));
    max-width: calc(50% - var(--spacing-xs));
  }
  
  /* Admin form grids - single column on mobile */
  /* Requirements: 4.2 */
  .admin-form-grid,
  #admin-container div[style*="grid-template-columns"] {
    grid-template-columns: 1fr;
  }
  
  /* Form inputs full width on mobile */
  #admin-container .form-input,
  #admin-container .form-select,
  #admin-container .form-textarea {
    width: 100%;
    min-width: 0;
  }
  
  /* Admin filter rows - stack vertically */
  .admin-filter-row > *,
  #admin-container div[style*="flex: 0 0"] {
    flex: 1 1 100%;
    min-width: 100%;
  }
  
  /* Admin bulk action buttons - ensure touch targets */
  /* Requirements: 4.3 */
  .admin-bulk-actions-buttons button,
  #admin-container div[id^="bulk-actions"] button {
    min-height: var(--touch-target-min);
    flex: 1;
  }
  
  /* Admin action buttons - full width on mobile */
  #admin-container .retro-button-small {
    min-height: var(--touch-target-min);
  }
  
  /* Legal pages grid - single column on mobile */
  #tab-legal div[style*="grid-template-columns"] {
    grid-template-columns: 1fr;
  }
  
  /* Cache management grid - single column on mobile */
  #tab-cache div[style*="grid-template-columns"] {
    grid-template-columns: 1fr;
  }
  
  /* Scoring config grid - single column on mobile */
  #scoring-config-form div[style*="grid-template-columns"] {
    grid-template-columns: 1fr;
  }
}

/* Action button groups in admin rows */
.admin-action-buttons {
  display: flex;
  gap: var(--spacing-xs);
  flex-wrap: wrap;
  justify-content: center;
}

/* Mobile: Action buttons in rows */
@media (max-width: 768px) {
  .admin-action-buttons {
    gap: var(--spacing-xs);
  }
  
  .admin-action-buttons .retro-button-small {
    min-height: var(--touch-target-min);
    padding: 8px 12px;
  }
}

/* Extra small mobile - ensure everything fits */
@media (max-width: 360px) {
  /* Admin tabs - even smaller */
  .tab-button,
  #admin-container .tab-button {
    font-size: 7px;
    padding: 6px 6px;
  }
  
  /* Admin panel headings */
  #admin-container h3 {
    font-size: 10px;
  }
  
  #admin-container h4 {
    font-size: 9px;
  }
  
  /* Action buttons - icon only on very small screens */
  .admin-action-buttons .retro-button-small {
    padding: 8px;
    min-width: var(--touch-target-min);
  }
}

/* ============================================
   Modal Responsive Styles
   Requirements: 6.1, 6.2, 6.3
   ============================================ */

/* Modal base styles (for global consistency) */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: var(--spacing-md);
  box-sizing: border-box;
}

.modal-content {
  background: var(--bg-primary);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  border-bottom: 2px solid var(--border-primary);
  background: rgba(0, 255, 255, 0.1);
  flex-shrink: 0;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 32px;
  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  color: var(--neon-cyan);
  transform: scale(1.1);
}

.modal-body {
  padding: var(--spacing-lg);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  border-top: 2px solid var(--border-primary);
  flex-shrink: 0;
}

/* Tablet breakpoint for modals */
@media (max-width: 768px) {
  /* Requirements: 6.1 - Modal fits within viewport with margins */
  .modal {
    padding: var(--spacing-sm);
  }
  
  .modal-content {
    max-width: calc(100% - var(--spacing-md));
    width: calc(100% - var(--spacing-md));
    max-height: calc(100vh - var(--spacing-xl));
    margin: var(--spacing-sm);
  }
  
  /* Requirements: 6.2 - Enable vertical scrolling for modal content */
  .modal-body {
    padding: var(--spacing-md);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .modal-header h3 {
    font-size: 14px;
  }
  
  /* Modal footer - reduce gap on tablet */
  .modal-footer {
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
  }
}

/* Mobile breakpoint for modals */
/* Requirements: 6.1, 6.2, 6.3 */
@media (max-width: 480px) {
  /* Requirements: 6.1 - Near-full-width on mobile with margins */
  .modal {
    padding: var(--spacing-xs);
    align-items: flex-start;
    padding-top: var(--spacing-md);
  }
  
  .modal-content {
    max-width: calc(100% - var(--spacing-sm));
    width: calc(100% - var(--spacing-sm));
    max-height: calc(100vh - var(--spacing-lg));
    margin: 0 auto;
  }
  
  .modal-header {
    padding: var(--spacing-sm);
  }
  
  .modal-header h3 {
    font-size: 12px;
    flex: 1;
    margin-right: var(--spacing-sm);
  }
  
  .modal-close {
    font-size: 28px;
    width: var(--touch-target-min);
    height: var(--touch-target-min);
  }
  
  /* Requirements: 6.2 - Vertical scrolling for modal content */
  .modal-body {
    padding: var(--spacing-sm);
    max-height: none;
    overflow-y: auto;
  }
  
  /* Requirements: 6.3 - Stack buttons vertically with full width */
  .modal-footer {
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
  }
  
  .modal-footer .retro-button,
  .modal-footer button {
    width: 100%;
    min-height: var(--touch-target-min);
    justify-content: center;
  }
  
  /* Ensure textarea in modals is properly sized */
  .modal-body textarea,
  .modal-body .form-textarea {
    min-height: 100px;
    font-size: var(--font-size-base);
  }
}

/* Extra small mobile - ensure modals still work */
@media (max-width: 360px) {
  .modal-content {
    max-width: calc(100% - var(--spacing-xs));
    width: calc(100% - var(--spacing-xs));
  }
  
  .modal-header h3 {
    font-size: 10px;
  }
  
  .modal-footer .retro-button,
  .modal-footer button {
    font-size: 10px;
    padding: 10px 12px;
  }
}

/* ============================================
   Admin Modal Responsive Styles
   For modals using container-narrow pattern
   Requirements: 6.1, 6.2, 6.3
   ============================================ */

/* Admin modal overlay base styles */
[id$="-modal"][style*="position: fixed"] {
  padding: var(--spacing-lg);
}

/* Tablet breakpoint for admin modals */
@media (max-width: 768px) {
  /* Requirements: 6.1 - Admin modals fit within viewport */
  [id$="-modal"][style*="position: fixed"] {
    padding: var(--spacing-md) !important;
  }
  
  [id$="-modal"] .container-narrow {
    padding: 0;
    max-width: 100%;
  }
  
  [id$="-modal"] .pixel-border {
    padding: var(--spacing-md);
  }
  
  /* Admin modal header - wrap on tablet */
  [id$="-modal"] .pixel-border > div:first-child {
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }
  
  [id$="-modal"] .pixel-border > div:first-child h3 {
    flex: 1 1 100%;
    margin-bottom: var(--spacing-sm);
  }
}

/* Mobile breakpoint for admin modals */
@media (max-width: 480px) {
  /* Requirements: 6.1 - Near-full-width on mobile */
  [id$="-modal"][style*="position: fixed"] {
    padding: var(--spacing-sm) !important;
  }
  
  [id$="-modal"] .pixel-border {
    padding: var(--spacing-sm);
  }
  
  /* Admin modal header */
  [id$="-modal"] .pixel-border > div:first-child h3 {
    font-size: 12px;
  }
  
  /* Requirements: 6.3 - Stack buttons vertically */
  [id$="-modal"] div[style*="display: flex"][style*="gap"][style*="justify-content: flex-end"],
  [id$="-modal"] .retro-form > div:last-child {
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  
  [id$="-modal"] div[style*="display: flex"][style*="gap"][style*="justify-content: flex-end"] .retro-button,
  [id$="-modal"] .retro-form > div:last-child .retro-button {
    width: 100%;
    min-height: var(--touch-target-min);
  }
  
  /* Form inputs full width */
  [id$="-modal"] .form-input,
  [id$="-modal"] .form-select,
  [id$="-modal"] .form-textarea {
    width: 100%;
  }
  
  /* Textarea minimum height for touch */
  [id$="-modal"] .form-textarea {
    min-height: 120px;
  }
}

/* Extra small mobile for admin modals */
@media (max-width: 360px) {
  [id$="-modal"][style*="position: fixed"] {
    padding: var(--spacing-xs) !important;
  }
  
  [id$="-modal"] .pixel-border > div:first-child h3 {
    font-size: 10px;
  }
  
  [id$="-modal"] .retro-button {
    font-size: 10px;
    padding: 8px 12px;
  }
}


/* ============================================
   Quiz Interface Touch Optimization
   Requirements: 7.1, 7.2, 7.3
   ============================================ */

/* Answer option base styles for touch targets */
/* Requirements: 7.1 - Minimum 48px height for answer options */
.answer-option {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  cursor: pointer;
}

.answer-option label {
  cursor: pointer;
  flex: 1;
  margin-left: var(--spacing-md);
  /* Ensure label text doesn't make option too cramped */
  padding: var(--spacing-xs) 0;
}

/* Quiz navigation grid base styles */
/* Requirements: 7.2 - Navigation grid columns */
.quiz-nav-grid,
#navigation-grid div[style*="grid"] {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: var(--spacing-sm);
}

/* Quiz navigation buttons - ensure tappable */
#navigation-grid .nav-button {
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Quiz header layout base styles */
/* Requirements: 7.3 - Timer and progress visibility */
.quiz-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

/* Quiz navigation bar base styles */
.quiz-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

/* Tablet breakpoint for quiz interface */
@media (max-width: 768px) {
  /* Requirements: 7.1 - Answer options touch targets on tablet */
  .answer-option {
    min-height: 48px;
    padding: var(--spacing-md) var(--spacing-sm);
  }
  
  .answer-option label {
    font-size: 18px;
  }
  
  /* Requirements: 7.2 - Navigation grid on tablet */
  .quiz-nav-grid,
  #navigation-grid div[style*="grid"] {
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: var(--spacing-xs);
  }
  
  #navigation-grid .nav-button {
    font-size: 9px;
    padding: var(--spacing-xs);
  }
  
  /* Requirements: 7.3 - Quiz header on tablet */
  .quiz-header-row {
    gap: var(--spacing-sm);
  }
  
  /* Timer and bonus display - reduce font size */
  #timer {
    font-size: 12px !important;
  }
  
  #time-bonus-display {
    font-size: 10px !important;
  }
  
  #question-counter {
    font-size: 12px !important;
  }
  
  /* Flag button - ensure touch target */
  #flag-button {
    min-height: var(--touch-target-min);
    padding: 8px 12px;
  }
  
  /* Quiz navigation bar - ensure buttons don't overlap */
  .quiz-nav-bar {
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }
  
  /* Navigation legend - wrap on tablet */
  #nav-legend {
    font-size: 14px;
  }
}

/* Mobile breakpoint for quiz interface */
/* Requirements: 7.1, 7.2, 7.3 */
@media (max-width: 480px) {
  /* Requirements: 7.1 - Answer options with 48px minimum height */
  .answer-option {
    min-height: 48px;
    padding: var(--spacing-sm);
    flex-direction: row;
    align-items: center;
  }
  
  .answer-option .form-radio {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
  }
  
  .answer-option label {
    font-size: 16px;
    margin-left: var(--spacing-sm);
    line-height: 1.4;
    word-break: break-word;
  }
  
  /* Requirements: 7.2 - Navigation grid columns for mobile */
  .quiz-nav-grid,
  #navigation-grid div[style*="grid"] {
    grid-template-columns: repeat(5, 1fr);
    gap: var(--spacing-xs);
  }
  
  #navigation-grid .nav-button {
    font-size: 8px;
    padding: var(--spacing-xs);
    min-height: 40px;
    min-width: 40px;
  }
  
  /* Navigation legend - stack on mobile */
  #nav-legend {
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    align-items: center;
  }
  
  #nav-legend .nav-legend-separator {
    display: none;
  }
  
  /* Requirements: 7.3 - Quiz header stacking on mobile */
  .quiz-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-sm);
    text-align: center;
  }
  
  /* Question counter - full width on mobile */
  #question-counter {
    font-size: 11px !important;
    order: 1;
  }
  
  /* Timer section - center on mobile */
  .quiz-timer-section {
    order: 2;
    align-items: center !important;
  }
  
  #timer {
    font-size: 11px !important;
  }
  
  #time-bonus-display {
    font-size: 9px !important;
  }
  
  /* Flag button - full width on mobile */
  #flag-button {
    order: 3;
    width: 100%;
    min-height: var(--touch-target-min);
    justify-content: center;
  }
  
  /* Quiz navigation bar - stack on mobile */
  .quiz-nav-bar {
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  
  .quiz-nav-bar > button,
  .quiz-nav-bar > div {
    width: 100%;
  }
  
  #prev-button,
  #nav-toggle {
    width: 100%;
    min-height: var(--touch-target-min);
    justify-content: center;
  }
  
  /* Hide the empty spacer div on mobile */
  .quiz-nav-spacer {
    display: none;
  }
  
  /* Question text - slightly smaller on mobile */
  #question-text {
    font-size: 18px !important;
    line-height: 1.5 !important;
  }
  
  /* Question container - reduce padding */
  #question-container.pixel-border {
    padding: var(--spacing-md);
    min-height: auto !important;
  }
}

/* Extra small mobile (320px) */
@media (max-width: 360px) {
  /* Answer options - ensure they still fit */
  .answer-option {
    padding: var(--spacing-xs);
  }
  
  .answer-option label {
    font-size: 14px;
  }
  
  /* Navigation grid - 4 columns on very small screens */
  .quiz-nav-grid,
  #navigation-grid div[style*="grid"] {
    grid-template-columns: repeat(4, 1fr);
  }
  
  #navigation-grid .nav-button {
    font-size: 7px;
    min-height: 36px;
    min-width: 36px;
  }
  
  /* Quiz header - even smaller text */
  #question-counter,
  #timer {
    font-size: 10px !important;
  }
  
  #time-bonus-display {
    font-size: 8px !important;
  }
  
  #question-text {
    font-size: 16px !important;
  }
  
  /* Flag button text */
  #flag-button {
    font-size: 9px;
  }
}
