/* Main Styles for Choose My Adventure */
/* Mobile-first retro 8-bit aesthetic */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* Component imports - must appear before other CSS rules */
:root {
  /* Core palette */
  --primary-color: #5bfdff;
  --primary-hover: #73faff;
  --primary-active: #3ddce6;
  --primary-dark: #0b7288;
  --primary-shadow: #042b33;
  --secondary-color: #ff4dd8;
  --secondary-hover: #ff7ee4;
  --secondary-active: #f030bc;
  --success-color: #a8ff60;
  --warning-color: #ffb14d;
  --danger-color: #ff6f6f;
  --info-color: #5bfdff;

  /* Accent tones */
  --accent-magenta: #ff4dd8;
  --accent-magenta-dark: #7d1f62;
  --accent-lime: #a8ff60;
  --accent-lime-dark: #3e5b1f;
  --accent-purple: #7c4dff;

  /* Surfaces */
  --background: #05070f;
  --surface: #0b1022;
  --surface-hover: #141b35;
  --surface-alt: #151d3c;
  --border: #1c2746;
  --border-strong: #2d3a63;

  /* Typography */
  --text-primary: #5bfdff;
  --text-secondary: #9cf7ff;
  --text-muted: #3f8ea3;
  --font-family: 'Press Start 2P', 'Courier New', Courier, monospace;
  --font-size-xs: 0.65rem;
  --font-size-sm: 0.8rem;
  --font-size-base: 0.9rem;
  --font-size-lg: 1.1rem;
  --font-size-xl: 1.35rem;
  --font-size-2xl: 1.6rem;
  --font-size-3xl: 2.2rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Layout */
  --border-radius: 0;
  --border-radius-lg: 0;
  --border-radius-xl: 0;
  --max-width: 1200px;
  --container-padding: var(--space-4);

  /* Pixel shadows */
  --shadow-sm: 4px 4px 0 var(--primary-shadow);
  --shadow: 6px 6px 0 var(--primary-shadow);
  --shadow-lg: 8px 8px 0 var(--primary-shadow);
  --shadow-xl: 12px 12px 0 var(--primary-shadow);

  /* Motion */
  --transition: all 0.12s steps(2, end);
  --transition-slow: all 0.2s steps(2, end);

  /* Z-index layers */
  --z-base: 1;
  --z-dropdown: 1000;
  --z-overlay: 5000;
  --z-modal: 9000;
  --z-toast: 9500;
  --z-crt-noise: 100;
  --z-crt-scanline: 101;

  /* Dark mode variants keep retro palette */
  --dark-background: #05070f;
  --dark-surface: #0b1022;
  --dark-surface-hover: #141b35;
  --dark-border: #1c2746;
  --dark-text-primary: #5bfdff;
  --dark-text-secondary: #9cf7ff;
  --dark-text-muted: #3f8ea3;
}

/* Reset and base styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.6;
  scroll-behavior: smooth;
  background-color: var(--background);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  /* Disable CRT effects for reduced motion */
  body::before,
  body::after {
    display: none !important;
  }
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  /* No background-color - parallax background provides this */
  /* Reduce global glow to avoid haloing around body text */
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.35),
    0 0 1px rgba(91, 253, 255, 0.12);
  min-height: 100vh;
  border-top: 3px solid var(--accent-magenta);
  position: relative;
}

/* CRT scan line effect overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-crt-scanline);
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.2) 0px,
    transparent 1px,
    transparent 2px,
    rgba(0, 0, 0, 0.2) 3px
  );
  opacity: 0.5;
  mix-blend-mode: multiply;
}

/* Subtle noise texture overlay */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--z-crt-noise);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
  opacity: 0.5;
  animation: noise 0.2s steps(10) infinite;
  mix-blend-mode: overlay;
}

@keyframes noise {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-1%, -1%); }
  20% { transform: translate(-2%, 2%); }
  30% { transform: translate(1%, -2%); }
  40% { transform: translate(-1%, 1%); }
  50% { transform: translate(1%, 1%); }
  60% { transform: translate(-2%, -1%); }
  70% { transform: translate(2%, 1%); }
  80% { transform: translate(-1%, -2%); }
  90% { transform: translate(1%, 2%); }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --background: var(--dark-background);
    --surface: var(--dark-surface);
    --surface-hover: var(--dark-surface-hover);
    --border: var(--dark-border);
    --text-primary: var(--dark-text-primary);
    --text-secondary: var(--dark-text-secondary);
    --text-muted: var(--dark-text-muted);
  }
}

/* High contrast mode */
.high-contrast {
  --primary-color: #0000ff;
  --text-primary: #000000;
  --background: #ffffff;
  --border: #000000;
}

@media (prefers-contrast: high) {
  :root {
    --primary-color: #0000ff;
    --text-primary: #000000;
    --background: #ffffff;
    --border: #000000;
  }
}

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  top: -40px;
  left: 6px;
  background: var(--accent-magenta);
  color: var(--background);
  padding: 8px 12px;
  text-decoration: none;
  border: 3px solid var(--accent-magenta-dark);
  z-index: 1000;
  transition: var(--transition);
  box-shadow: 4px 4px 0 var(--accent-magenta-dark);
  display: inline-block;
  width: auto;
  opacity: 0;
  visibility: hidden;
}

.skip-link:focus {
  top: 6px;
  opacity: 1;
  visibility: visible;
}

/* Screen reader only content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* App container */
.app-container {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* Loading screen */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--background);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-screen[aria-hidden="true"] {
  display: none !important;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid var(--primary-dark);
  border-top: 4px solid var(--accent-magenta);
  border-radius: 0;
  animation: spin 1s steps(6, end) infinite;
  box-shadow: 4px 4px 0 var(--primary-shadow);
  margin-bottom: var(--space-4);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  font-size: var(--font-size-lg);
  color: var(--accent-lime);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 400;
  line-height: 1.3;
  margin-bottom: var(--space-4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-magenta);
  text-shadow: 0 0 12px rgba(255, 77, 216, 0.35);
}

h1 { font-size: var(--font-size-3xl); }
h2 {
  font-size: var(--font-size-2xl);
  color: var(--accent-lime);
  text-shadow: 0 0 10px rgba(168, 255, 96, 0.4);
}
h3 {
  font-size: var(--font-size-xl);
  color: var(--text-primary);
}
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p {
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

/* Focus styles */
*:focus {
  outline: 3px solid var(--accent-lime);
  outline-offset: 0;
  box-shadow: 0 0 0 3px var(--accent-lime-dark);
}

*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 3px solid var(--accent-lime);
  outline-offset: 0;
  box-shadow: 0 0 0 3px var(--accent-lime-dark);
}

/* Layout utilities */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

.screen {
  flex: 1;
  padding: var(--space-6);
  min-height: calc(100vh - 80px); /* Ensure screen fills viewport minus header */
  display: flex;
  flex-direction: column;
}

.screen-content {
  max-width: 600px;
  margin: 0 auto;
}

/* Hidden elements */
.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Responsive breakpoints */
@media (min-width: 640px) {
  :root {
    --container-padding: var(--space-6);
  }

  .screen {
    padding: var(--space-8);
  }
}

@media (min-width: 768px) {
  :root {
    --container-padding: var(--space-8);
  }
}

@media (min-width: 1024px) {
  :root {
    --container-padding: var(--space-12);
  }
}

/* Mobile-specific styles for Choose My Adventure */
/* Enhanced mobile experience and touch interactions */

/* ==========================================================================
   MOBILE OPTIMIZATIONS
   ========================================================================== */

@media (max-width: 768px) {
  /* Increase touch targets for mobile */
  .btn,
  .choice-btn,
  .menu-btn {
    min-height: 48px;
    padding: var(--space-4);
  }
  
  /* Keep primary button prominent on mobile */
  .menu-btn.primary {
    min-height: 64px;
    font-size: var(--font-size-lg);
  }

  /* Larger text for mobile readability */
  .scene-text {
    font-size: var(--font-size-lg);
    line-height: 1.6;
  }

  /* Stack form actions vertically on mobile */
  .form-actions {
    flex-direction: column;
    gap: var(--space-3);
  }

  .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Mobile navigation improvements */
  .nav-container {
    padding: var(--space-3) var(--space-4);
  }

  .app-title {
    font-size: var(--font-size-lg);
  }

  /* Mobile menu improvements */
  .main-menu {
    padding: var(--space-4);
  }

  .menu-btn {
    font-size: var(--font-size-base);
    padding: var(--space-3) var(--space-4);
  }

  /* Mobile story layout */
  .story-content {
    padding: 0;
  }

  .screen {
    padding: var(--space-4);
  }

  .scene-display {
    margin: var(--space-6) 0;
  }

  /* Mobile choice selector */
  .choice-btn {
    margin-bottom: var(--space-3);
    border-radius: var(--border-radius);
  }

  .choice-number {
    width: 32px;
    height: 32px;
    font-size: var(--font-size-sm);
  }

  .choice-text {
    font-size: var(--font-size-base);
  }

  /* Mobile form improvements */
  .form-input,
  .form-select {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: var(--space-4);
  }

  /* Mobile toast adjustments */
  .error-toast,
  .success-toast {
    left: var(--space-3);
    right: var(--space-3);
    top: var(--space-3);
  }

  /* Mobile dropdown menu */
  .dropdown-menu {
    right: var(--space-3);
    min-width: 180px;
  }

  .dropdown-item {
    padding: var(--space-4);
    font-size: var(--font-size-base);
    min-height: 48px;
  }
}

/* ==========================================================================
   SMALL MOBILE (320px and up)
   ========================================================================== */

@media (max-width: 480px) {
  /* Very small screens - prioritize readability */
  .app-title {
    font-size: var(--font-size-base);
  }

  .title-icon {
    display: none; /* Hide icon on very small screens */
  }

  .scene-text {
    padding: var(--space-3);
    font-size: var(--font-size-base);
  }

  .choice-btn {
    padding: var(--space-3);
  }

  .choice-number {
    width: 28px;
    height: 28px;
    margin-right: var(--space-2);
  }

  /* Reduce spacing on small screens */
  .screen {
    padding: var(--space-3);
  }

  .form-group {
    margin-bottom: var(--space-4);
  }

  .story-meta {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  .adventure-title {
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-2);
  }

  .story-progress {
    justify-content: flex-end;
  }
}

/* ==========================================================================
   TOUCH INTERACTIONS
   ========================================================================== */

/* Enhanced touch feedback */
.btn:active,
.choice-btn:active,
.menu-btn:active {
  transform: scale(0.98);
}

.btn.touched,
.choice-btn.touched,
.menu-btn.touched {
  background-color: var(--surface-hover);
  transform: scale(0.98);
}

/* Prevent text selection on interactive elements */
.btn,
.choice-btn,
.menu-btn,
.menu-toggle {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Better scrolling for mobile */
.story-log-content {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ==========================================================================
   LANDSCAPE MOBILE
   ========================================================================== */

@media (max-width: 768px) and (orientation: landscape) {
  /* Adjust for landscape mobile */
  .loading-screen {
    flex-direction: row;
    gap: var(--space-4);
  }

  .loading-text {
    font-size: var(--font-size-base);
  }

  .scene-text {
    padding: var(--space-4);
  }

  /* Horizontal layout for story actions in landscape */
  .story-actions {
    flex-direction: row;
    justify-content: space-between;
  }

  .story-actions .btn {
    width: auto;
    flex: 1;
  }
}

/* ==========================================================================
   ACCESSIBILITY ON MOBILE
   ========================================================================== */

/* Larger focus indicators for mobile */
@media (max-width: 768px) {
  *:focus-visible {
    outline-width: 3px;
    outline-offset: 3px;
  }
}

/* High contrast adjustments for mobile */
@media (max-width: 768px) and (prefers-contrast: high) {
  .choice-btn {
    border-width: 3px;
  }

  .btn {
    border: 2px solid currentColor;
  }

  .btn.primary {
    border-color: transparent;
  }
}

/* Reduced motion on mobile */
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .choice-btn:hover {
    transform: none;
  }

  .btn:hover {
    transform: none;
  }

  .typing-indicator span {
    animation: none;
  }

  .loading-spinner {
    animation: none;
    border-top-color: var(--primary-color);
  }
}

/* ==========================================================================
   PWA OPTIMIZATIONS
   ========================================================================== */

/* Safe area for devices with notches */
@supports (padding: max(0px)) {
  .app-container {
    padding-left: max(var(--space-4), env(safe-area-inset-left));
    padding-right: max(var(--space-4), env(safe-area-inset-right));
  }

  .main-nav {
    padding-top: max(0px, env(safe-area-inset-top));
  }

  .loading-screen {
    padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  }
}

/* Standalone PWA styles */
@media (display-mode: standalone) {
  .main-nav {
    padding-top: var(--space-4);
  }

  body {
    background-color: var(--background);
  }
}

/* ==========================================================================
   MOBILE HOVER STATES
   ========================================================================== */

/* Only apply hover styles on devices that can hover */
@media (hover: hover) and (pointer: fine) {
  .choice-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
  }

  .btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
  }
}

/* For touch devices, use active states instead of hover */
@media (hover: none) and (pointer: coarse) {
  .choice-btn:active {
    transform: scale(0.98);
    box-shadow: var(--shadow);
  }

  .btn:active {
    transform: scale(0.98);
  }
}

/* ==========================================================================
   MOBILE PERFORMANCE
   ========================================================================== */

/* Optimize animations for mobile */
@media (max-width: 768px) {
  /* Use will-change sparingly on mobile */
  .loading-spinner,
  .typing-indicator span {
    will-change: transform;
  }

  /* Reduce motion complexity */
  .choice-btn {
    transition: background-color 0.2s ease, transform 0.1s ease;
  }

  .btn {
    transition: background-color 0.2s ease, transform 0.1s ease;
  }
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border: 3px solid var(--primary-color);
  border-radius: 0;
  background-color: var(--surface);
  color: var(--primary-color);
  cursor: pointer;
  transition: var(--transition);
  min-height: 44px; /* WCAG AA minimum touch target */
  box-shadow: 4px 4px 0 var(--primary-shadow);
  position: relative;
  text-shadow: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:not(:disabled):hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--primary-shadow);
}

.btn:not(:disabled):active {
  transform: translate(0, 0);
  box-shadow: 2px 2px 0 var(--primary-shadow);
}

/* Button variants */
.btn.primary {
  background-color: var(--primary-color);
  color: var(--background);
  border-color: var(--primary-dark);
  box-shadow: 4px 4px 0 var(--primary-shadow);
}

.btn.primary:not(:disabled):hover {
  background-color: var(--accent-magenta);
  border-color: var(--accent-magenta-dark);
  color: var(--background);
  box-shadow: 6px 6px 0 var(--accent-magenta-dark);
}

.btn.primary:not(:disabled):active {
  background-color: var(--primary-active);
  border-color: var(--primary-dark);
}

.btn.secondary {
  background-color: var(--surface);
  color: var(--accent-magenta);
  border-color: var(--accent-magenta);
  box-shadow: 4px 4px 0 var(--accent-magenta-dark);
}

.btn.secondary:not(:disabled):hover {
  background-color: var(--accent-magenta);
  color: var(--background);
  border-color: var(--accent-magenta-dark);
  box-shadow: 6px 6px 0 var(--accent-magenta-dark);
}

.btn.tertiary {
  background-color: var(--surface);
  color: var(--accent-lime);
  border-color: var(--accent-lime);
  box-shadow: 4px 4px 0 var(--accent-lime-dark);
}

.btn.tertiary:not(:disabled):hover {
  background-color: var(--accent-lime);
  color: var(--background);
  border-color: var(--accent-lime-dark);
  box-shadow: 6px 6px 0 var(--accent-lime-dark);
}

/* Button sizes */
.btn.small {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
  min-height: 36px;
}

.btn.large {
  padding: var(--space-4) var(--space-6);
  font-size: var(--font-size-lg);
  min-height: 52px;
}

/* Button with icons */
.btn-icon {
  font-size: 1.2em;
  line-height: 1;
}

/* Menu buttons */
.menu-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  justify-content: center;
  text-align: center;
  padding: var(--space-5);
  margin-bottom: var(--space-4);
  font-family: var(--font-family);
  font-size: var(--font-size-lg);
  letter-spacing: 0.08em;
  line-height: 1.5;
  text-transform: uppercase;
  border: 3px solid var(--primary-color);
  border-radius: 0;
  background-color: var(--surface-alt);
  color: var(--primary-color);
  box-shadow: 6px 6px 0 var(--primary-shadow);
  transition: var(--transition);
  min-height: 64px;
  cursor: pointer;
  text-shadow: none;
}

.menu-btn:hover {
  transform: translate(-2px, -2px);
}

.menu-btn:last-child {
  margin-bottom: 0;
}

.menu-btn.primary {
  background-color: var(--primary-color);
  color: var(--background);
  border-color: var(--primary-dark);
  box-shadow: 6px 6px 0 var(--primary-shadow);
  font-size: var(--font-size-2xl);
  font-weight: 700;
  padding: var(--space-5) var(--space-4);
  min-height: 72px;
  position: relative;
  overflow: hidden;
  
  /* Center the content for balanced, authoritative look */
  justify-content: center;
  text-align: center;
  
  /* Add glow effect */
  filter: drop-shadow(0 0 12px rgba(91, 253, 255, 0.4));
  
  /* Pulse animation */
  animation: button-pulse 2s ease-in-out infinite;
}

@keyframes button-pulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 12px rgba(91, 253, 255, 0.4));
  }
  50% {
    transform: scale(1.02);
    filter: drop-shadow(0 0 20px rgba(91, 253, 255, 0.6));
  }
}

/* Shimmer effect overlay */
.menu-btn.primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

.menu-btn.primary .btn-icon {
  font-size: 1.5em;
  animation: icon-twinkle 2s ease-in-out infinite;
}

@keyframes icon-twinkle {
  0%, 100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.1) rotate(5deg);
  }
}

.menu-btn.primary:hover {
  background-color: var(--accent-magenta);
  border-color: var(--accent-magenta-dark);
  color: var(--background);
  box-shadow: 8px 8px 0 var(--accent-magenta-dark);
  filter: drop-shadow(0 0 24px rgba(255, 77, 216, 0.6));
  animation: none; /* Stop pulse on hover */
  transform: translate(-2px, -2px);
}

.menu-btn.primary:active {
  transform: translate(2px, 2px);
  box-shadow: 4px 4px 0 var(--accent-magenta-dark);
}

/* Disable animations for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .menu-btn.primary,
  .menu-btn.primary .btn-icon,
  .menu-btn.primary::before {
    animation: none !important;
  }
  
  .menu-btn.primary {
    filter: none;
  }
}

.menu-btn.secondary {
  background-color: var(--surface);
  color: var(--accent-magenta);
  border-color: var(--accent-magenta);
  box-shadow: 6px 6px 0 var(--accent-magenta-dark);
}

.menu-btn.secondary:hover {
  background-color: var(--accent-magenta);
  color: var(--background);
  border-color: var(--accent-magenta-dark);
  box-shadow: 8px 8px 0 var(--accent-magenta-dark);
}

.menu-btn.tertiary {
  background-color: var(--surface);
  color: var(--accent-lime);
  border-color: var(--accent-lime);
  box-shadow: 6px 6px 0 var(--accent-lime-dark);
}

.menu-btn.tertiary:hover {
  background-color: var(--accent-lime);
  color: var(--background);
  border-color: var(--accent-lime-dark);
  box-shadow: 8px 8px 0 var(--accent-lime-dark);
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .menu-btn {
    font-size: clamp(0.65rem, 2vw, 0.85rem);
    padding: var(--space-4) var(--space-3);
    min-height: 56px;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
    white-space: normal; /* Allow text wrapping */
    word-wrap: break-word;
  }
  
  .menu-btn.primary {
    font-size: clamp(0.75rem, 2.5vw, 1rem);
    padding: var(--space-5) var(--space-4);
    min-height: 64px;
  }
  
  .btn-icon {
    font-size: 1em;
    flex-shrink: 0; /* Prevent icon from shrinking */
  }
  
  .menu-btn.primary .btn-icon {
    font-size: 1.2em;
  }
}



/* ==========================================================================
   CHOICE SELECTOR
   ========================================================================== */

.choice-selector {
  margin: var(--space-6) 0;
}

.choice-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  background-color: var(--surface-alt);
  border: 3px solid var(--primary-color);
  text-align: left;
  font-family: var(--font-family);
  cursor: pointer;
  transition: var(--transition);
  min-height: 56px;
  position: relative;
  box-shadow: 6px 6px 0 var(--primary-shadow);
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent-magenta);
  background-color: var(--surface-hover);
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 var(--accent-magenta-dark);
}

.choice-btn:active:not(:disabled) {
  transform: translate(0, 0);
  box-shadow: 4px 4px 0 var(--primary-shadow);
}

.choice-btn.selected {
  border-color: var(--accent-lime);
  background-color: rgba(168, 255, 96, 0.12);
  box-shadow: 8px 8px 0 var(--accent-lime-dark);
}

.choice-btn.unselected {
  opacity: 0.6;
}

.choice-btn.processing {
  cursor: wait;
  opacity: 0.7;
}

.choice-number {
  background-color: var(--accent-magenta);
  color: var(--background);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--font-size-sm);
  margin-right: var(--space-3);
  flex-shrink: 0;
  border: 2px solid var(--accent-magenta-dark);
  box-shadow: 3px 3px 0 var(--accent-magenta-dark);
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.45),
    0 0 2px rgba(0, 0, 0, 0.25);
}

.choice-text {
  flex: 1;
  color: var(--text-primary);
  font-weight: 400;
  /* Subtle shadow to increase legibility without glow */
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.4),
    0 0 1px rgba(91, 253, 255, 0.12);
  line-height: 1.4;
  letter-spacing: 0.03em;
}

.choice-icon {
  color: var(--accent-lime);
  margin-left: var(--space-2);
  transition: var(--transition);
}

.choice-icon.processing {
  animation: spin 1s linear infinite;
}

@media (max-width: 640px) {
  .choice-btn {
    padding: var(--space-3);
    min-height: 48px;
  }

  .choice-number {
    width: 24px;
    height: 24px;
    font-size: var(--font-size-xs);
  }
}


/* ==========================================================================
   FORMS
   ========================================================================== */

.form-group {
  margin-bottom: var(--space-6);
}

.form-label {
  display: block;
  font-family: var(--font-family);
  font-weight: 400;
  margin-bottom: var(--space-2);
  color: var(--accent-magenta);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--space-3);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  border: 3px solid var(--primary-color);
  background-color: var(--surface);
  color: var(--text-primary);
  transition: var(--transition);
  min-height: 44px;
  box-shadow: 4px 4px 0 var(--primary-shadow);
  text-shadow: none;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent-magenta);
  box-shadow: 4px 4px 0 var(--accent-magenta-dark);
}

.form-input[aria-invalid="true"],
.form-select[aria-invalid="true"] {
  border-color: var(--danger-color);
}

.form-help {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.field-error {
  display: none;
  color: var(--danger-color);
  font-size: var(--font-size-sm);
  margin-top: var(--space-1);
}

.field-error:not(:empty) {
  display: block;
}

.form-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: var(--space-8);
}

@media (max-width: 640px) {
  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }
}


/* ==========================================================================
   HERO LOGO
   ========================================================================== */

/* Hero logo container */
.hero-logo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  position: relative;
  width: 100%;
  max-width: 100%;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease-out, transform 0.3s ease-out, visibility 0.3s ease-out;
  background: linear-gradient(180deg, rgba(5,7,15,0.95) 0%, rgba(5,7,15,0.8) 100%);
  border-bottom: 3px solid var(--primary-color);
  box-shadow: 0 3px 0 var(--primary-shadow);
}

/* Burger button positioned on hero banner */
.hero-logo .hero-menu-toggle,
.hero-logo #menu-toggle {
  position: relative;
  z-index: 200;
  margin: 0;
  flex-shrink: 0;
}

/* Dropdown menu positioning when inside hero */
.hero-logo #dropdown-menu {
  position: fixed !important;
  top: calc(var(--space-4) + 60px) !important; /* Below the burger button */
  right: var(--space-4) !important;
  left: auto !important;
  max-width: calc(100vw - var(--space-8));
  z-index: 250 !important;
}

/* On mobile, center dropdown and add backdrop */
@media (max-width: 768px) {
  .hero-logo #dropdown-menu {
    right: var(--space-2) !important;
    top: 80px !important;
  }
}

/* Hide main navigation bar when hero is visible */
.hero-logo:not(.hidden) ~ .main-nav {
  display: none;
}

.hero-logo.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-20px);
  pointer-events: none;
  display: none;
}

/* Animated wizard mascot */
.hero-mascot {
  font-size: clamp(1.5rem, 4vw, 2rem);
  display: inline-block;
  position: relative;
  animation: mascot-idle 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(255, 77, 216, 0.6))
          drop-shadow(0 0 40px rgba(91, 253, 255, 0.4));
  flex-shrink: 0;
}

@keyframes mascot-idle {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-6px) rotate(-2deg);
  }
  75% {
    transform: translateY(-3px) rotate(2deg);
  }
}

/* Add sparkle effect around mascot */
.hero-mascot::before {
  content: '✨';
  position: absolute;
  top: -10px;
  right: -20px;
  font-size: 1.5rem;
  animation: sparkle-top 2s ease-in-out infinite;
  opacity: 0;
}

.hero-mascot::after {
  content: '✨';
  position: absolute;
  bottom: -10px;
  left: -20px;
  font-size: 1.2rem;
  animation: sparkle-bottom 2.5s ease-in-out infinite 0.5s;
  opacity: 0;
}

@keyframes sparkle-top {
  0%, 100% {
    opacity: 0;
    transform: scale(0.5) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1) rotate(180deg);
  }
}

@keyframes sparkle-bottom {
  0%, 100% {
    opacity: 0;
    transform: scale(0.5) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1) rotate(-180deg);
  }
}

/* Removed hero-title and title-text styles - no longer needed */

/* Add sparkle effect around mascot */
.main-menu.home-state {
  position: relative;
  margin: var(--space-3) auto var(--space-6);
  width: min(90%, 520px);
  /* Enhanced shadow when connected to hero */
  box-shadow: 0 0 0 4px var(--primary-shadow),
              12px 12px 0 var(--primary-shadow),
              0 0 40px rgba(91, 253, 255, 0.2);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .hero-mascot,
  .hero-mascot::before,
  .hero-mascot::after {
    animation: none !important;
  }
}

/* Tablet adjustments */
@media (max-width: 768px) {
  .hero-logo {
    padding: var(--space-2);
  }
  
  .hero-mascot {
    font-size: 1.5rem;
  }
  
  .main-menu.home-state {
    margin-top: var(--space-2);
  }
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .hero-logo {
    margin: 0;
    padding: var(--space-2);
  }
  
  .hero-mascot {
    font-size: 1.5rem;
  }
  
  .main-menu.home-state {
    margin-top: var(--space-2);
  }
}


/* ==========================================================================
   NAVIGATION
   ========================================================================== */

.main-nav {
  background-color: var(--surface-alt);
  border-bottom: 3px solid var(--primary-color);
  box-shadow: 0 3px 0 var(--primary-shadow);
  position: sticky;
  top: 0;
  z-index: 150;
  width: 100%;
}

.nav-container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: var(--space-1) var(--space-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-title {
  font-size: var(--font-size-xl);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--accent-magenta);
  text-shadow: 0 0 10px rgba(255, 77, 216, 0.35);
}

/* Compact title - hidden by default, shown when not on home screen */
.app-title-compact {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}

.app-title-compact.visible {
  opacity: 1;
  visibility: visible;
}

.title-icon {
  font-size: 1.2em;
}

.menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface);
  border: 3px solid var(--primary-color);
  padding: var(--space-2);
  cursor: pointer;
  width: 48px;
  height: 48px;
  position: relative;
  box-shadow: 4px 4px 0 var(--primary-shadow);
  transition: var(--transition);
}

.menu-toggle:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--primary-shadow);
}

.hamburger {
  display: block;
  width: 22px;
  height: 3px;
  background-color: var(--primary-color);
  position: relative;
  transition: var(--transition);
}

.hamburger::before,
.hamburger::after {
  content: '';
  display: block;
  width: 22px;
  height: 3px;
  background-color: var(--primary-color);
  position: absolute;
  transition: var(--transition);
}

.hamburger::before {
  top: -7px;
}

.hamburger::after {
  bottom: -7px;
}

.menu-toggle[aria-expanded="true"] {
  background-color: var(--accent-magenta);
  border-color: var(--accent-magenta-dark);
  box-shadow: 6px 6px 0 var(--accent-magenta-dark);
}

.menu-toggle[aria-expanded="true"] .hamburger {
  background-color: transparent;
}

.menu-toggle[aria-expanded="true"] .hamburger::before {
  transform: rotate(45deg);
  top: 0;
}

.menu-toggle[aria-expanded="true"] .hamburger::after {
  transform: rotate(-45deg);
  bottom: 0;
}

/* Dropdown menu (appears next to burger button) */
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background-color: var(--surface);
  border: 3px solid var(--primary-color);
  box-shadow: 6px 6px 0 var(--primary-shadow);
  min-width: 200px;
  z-index: 300;
  padding: var(--space-2);
}

.dropdown-menu[aria-hidden="false"] {
  display: block;
  animation: slideDown 0.2s ease-out;
}

/* Hide main menu when dropdown is open on mobile to prevent overlap
 * Uses :has() pseudo-class for more robust selection without relying on HTML structure
 * Increased specificity naturally avoids need for !important
 */
@media (max-width: 768px) {
  body:has(.dropdown-menu[aria-hidden="false"]) .main-menu.open:not(.home-state) {
    display: none;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3);
  background-color: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  transition: var(--transition);
  border-radius: 0;
}

.dropdown-item:hover:not(:disabled) {
  background-color: var(--accent-magenta);
  color: var(--surface);
}

.dropdown-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dropdown-icon {
  font-size: 1.2em;
  width: 1.5em;
  text-align: center;
}

.nav-actions {
  position: relative;
}

/* Main menu */
.main-menu {
  display: none;
  background-color: var(--surface);
  padding: var(--space-5);
  border: 4px solid var(--primary-color);
  box-shadow: 12px 12px 0 var(--primary-shadow);
  color: var(--text-primary);
}

.main-menu.open {
  display: block;
}

.main-menu.home-state {
  display: block;
  position: relative;
  margin: var(--space-6) auto var(--space-6);
  width: min(90%, 520px);
  /* Enhanced shadow when connected to hero - double border effect */
  box-shadow: 0 0 0 4px var(--primary-shadow),
              12px 12px 0 var(--primary-shadow),
              0 0 40px rgba(91, 253, 255, 0.2);
}

@media (max-width: 768px) {
  .main-menu.home-state {
    width: calc(100vw - var(--space-6));
    max-width: 340px;
    margin: var(--space-4) auto var(--space-4);
  }
}

.main-menu.open:not(.home-state) {
  position: fixed;
  top: 88px;
  right: var(--space-4);
  width: min(90%, 360px);
  margin: 0;
  z-index: 200;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.menu-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

@media (max-width: 768px) {
  .main-menu.open:not(.home-state) {
    position: fixed;
    top: 76px;
    left: var(--space-3);
    right: var(--space-3);
    width: auto;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
}


/* ==========================================================================
   PARALLAX BACKGROUND - 3D DEPTH & SYNTHWAVE PERSPECTIVE GRID
   ========================================================================== */

/* Background container */
.parallax-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background-color: #05070f; /* Dark background base */
}

/* Individual parallax layers */
.parallax-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  will-change: transform;
}

/* Back layer - slowest movement, largest grid */
.parallax-layer.back {
  z-index: 1;
  opacity: 0.3;
}

/* Mid layer - medium movement, medium grid */
.parallax-layer.mid {
  z-index: 2;
  opacity: 0.5;
}

/* Front layer - fastest movement, particles/small grid */
.parallax-layer.front {
  z-index: 3;
  opacity: 0.7;
}

/* Canvas for perspective grid */
.perspective-grid-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* stylelint-disable-next-line declaration-block-no-duplicate-properties */
  /* biome-ignore lint/suspicious/noDuplicateProperties: Progressive enhancement for cross-browser pixelated rendering */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* Particle effects overlay */
.parallax-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(255, 77, 216, 0.1) 0%, transparent 2%),
    radial-gradient(circle at 80% 60%, rgba(91, 253, 255, 0.1) 0%, transparent 2%),
    radial-gradient(circle at 40% 80%, rgba(255, 77, 216, 0.08) 0%, transparent 2%),
    radial-gradient(circle at 70% 20%, rgba(91, 253, 255, 0.08) 0%, transparent 2%);
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%;
  animation: particles-float 20s ease-in-out infinite;
}

@keyframes particles-float {
  0%, 100% {
    transform: translateY(0) translateX(0);
  }
  25% {
    transform: translateY(-10px) translateX(5px);
  }
  50% {
    transform: translateY(-5px) translateX(-5px);
  }
  75% {
    transform: translateY(-15px) translateX(3px);
  }
}

/* Grid overlay for non-canvas fallback */
.parallax-grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(90deg, rgba(91, 253, 255, 0.1) 1px, transparent 1px),
    linear-gradient(0deg, rgba(91, 253, 255, 0.1) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: grid-scroll-horizontal 20s linear infinite;
}

@keyframes grid-scroll-horizontal {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 40px 0;
  }
}

/* Horizon glow effect */
.parallax-horizon {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: linear-gradient(
    to top,
    rgba(255, 77, 216, 0.15) 0%,
    rgba(91, 253, 255, 0.1) 30%,
    transparent 100%
  );
  pointer-events: none;
}

/* Stars/dots background - deepest layer */
.parallax-stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
    radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.15) 1px, transparent 1px),
    radial-gradient(circle at 30% 60%, rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    radial-gradient(circle at 65% 75%, rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    radial-gradient(circle at 15% 85%, rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    radial-gradient(circle at 90% 50%, rgba(255, 255, 255, 0.15) 1px, transparent 1px),
    radial-gradient(circle at 45% 10%, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 100% 100%;
  animation: stars-twinkle 8s ease-in-out infinite;
}

@keyframes stars-twinkle {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Scanlines effect for extra retro feel */
.parallax-scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    to bottom,
    transparent 50%,
    rgba(0, 0, 0, 0.1) 50%
  );
  background-size: 100% 4px;
  pointer-events: none;
  opacity: 0.3;
  animation: scanlines-move 0.5s linear infinite;
}

@keyframes scanlines-move {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 0 4px;
  }
}

/* Mobile optimizations - reduce animations */
@media (max-width: 768px) {
  .parallax-particles {
    animation-duration: 30s; /* Slower on mobile */
  }
  
  .parallax-grid-overlay {
    animation-duration: 30s; /* Slower on mobile */
  }
  
  .parallax-scanlines {
    display: none; /* Remove scanlines on mobile for performance */
  }
  
  .parallax-stars {
    animation-duration: 12s; /* Slower on mobile */
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .parallax-particles,
  .parallax-grid-overlay,
  .parallax-scanlines,
  .parallax-stars {
    animation: none;
  }
  
  .parallax-layer {
    will-change: auto;
  }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
  .parallax-horizon {
    background: linear-gradient(
      to top,
      rgba(255, 77, 216, 0.2) 0%,
      rgba(91, 253, 255, 0.15) 30%,
      transparent 100%
    );
  }
  
  .parallax-stars {
    opacity: 0.8;
  }
}

/* Light mode - softer colors */
@media (prefers-color-scheme: light) {
  .parallax-background {
    opacity: 0.5;
  }
  
  .parallax-horizon {
    background: linear-gradient(
      to top,
      rgba(91, 253, 255, 0.1) 0%,
      rgba(255, 77, 216, 0.08) 30%,
      transparent 100%
    );
  }
  
  .parallax-scanlines {
    display: none;
  }
}


/* ==========================================================================
   SCENE DISPLAY & STORY COMPONENTS
   ========================================================================== */

.story-content {
  max-width: 800px;
  margin: 0 auto;
}

.story-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 3px solid var(--primary-color);
}

.adventure-title {
  margin: 0;
  color: var(--accent-magenta);
  text-shadow: 0 0 10px rgba(255, 77, 216, 0.35);
}

.story-progress {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.scene-counter {
  font-size: var(--font-size-sm);
  color: var(--background);
  background-color: var(--primary-color);
  padding: var(--space-1) var(--space-3);
  border: 2px solid var(--primary-dark);
  box-shadow: 3px 3px 0 var(--primary-shadow);
}

.story-menu-btn {
  background-color: var(--surface);
  border: 2px solid var(--accent-magenta);
  font-size: var(--font-size-lg);
  cursor: pointer;
  padding: var(--space-2);
  color: var(--accent-magenta);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 3px 3px 0 var(--accent-magenta-dark);
  transition: var(--transition);
}

.story-menu-btn:hover {
  background-color: var(--accent-magenta);
  color: var(--background);
  border-color: var(--accent-magenta-dark);
  box-shadow: 4px 4px 0 var(--accent-magenta-dark);
}

.scene-display {
  margin: var(--space-8) 0;
}

.scene-text {
  font-size: var(--font-size-lg);
  line-height: 1.55;
  color: var(--text-secondary);
  background-color: var(--surface);
  padding: var(--space-6);
  border: 3px solid var(--primary-color);
  position: relative;
  transition: var(--transition);
  box-shadow: 8px 8px 0 var(--primary-shadow);
  /* Improve edge contrast without heavy glow */
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.35),
    0 0 1px rgba(91, 253, 255, 0.15);
  /* Narrow content for comfortable line length */
  max-width: 68ch;
  margin-inline: auto;
  /* Slightly reduce tracking for easier reading */
  letter-spacing: 0.02em;
}

.scene-text p {
  margin-bottom: var(--space-4);
}

.scene-text p:last-child {
  margin-bottom: 0;
}

.scene-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-6);
  color: var(--accent-lime);
}

.typing-indicator {
  display: flex;
  gap: var(--space-2);
}

.typing-indicator span {
  width: 10px;
  height: 10px;
  background-color: var(--primary-color);
  animation: typing 1.4s infinite steps(2, end);
  box-shadow: 2px 2px 0 var(--primary-shadow);
}

.typing-indicator span:nth-child(2) {
  background-color: var(--accent-magenta);
  animation-delay: 0.2s;
  box-shadow: 2px 2px 0 var(--accent-magenta-dark);
}

.typing-indicator span:nth-child(3) {
  background-color: var(--accent-lime);
  animation-delay: 0.4s;
  box-shadow: 2px 2px 0 var(--accent-lime-dark);
}

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.story-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 3px solid var(--primary-color);
}

/* ==========================================================================
   STORY LOG
   ========================================================================== */

.story-log-actions {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  justify-content: flex-end;
}

.story-log-content {
  background-color: var(--surface-alt);
  padding: var(--space-6);
  border: 3px solid var(--primary-color);
  box-shadow: 8px 8px 0 var(--primary-shadow);
  max-height: 60vh;
  overflow-y: auto;
  color: var(--text-secondary);
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.35),
    0 0 1px rgba(91, 253, 255, 0.12);
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 640px) {
  .story-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .story-progress {
    align-self: flex-end;
  }

  .scene-text {
    font-size: var(--font-size-base);
    padding: var(--space-4);
  }

  .story-actions {
    flex-direction: column;
    gap: var(--space-3);
  }

  .story-actions .btn {
    width: 100%;
  }
}


/* ==========================================================================
   TOASTS & ALERTS
   ========================================================================== */

.error-toast,
.success-toast {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  max-width: 400px;
  background-color: var(--surface-alt);
  border: 3px solid var(--primary-color);
  border-radius: 0;
  box-shadow: 8px 8px 0 var(--primary-shadow);
  z-index: 1000;
  animation: slideIn 0.3s steps(2, end);
  text-shadow: 0 0 6px rgba(91, 253, 255, 0.25);
}

.error-toast {
  border-color: var(--danger-color);
  box-shadow: 8px 8px 0 rgba(255, 111, 111, 0.4);
}

.success-toast {
  border-color: var(--accent-lime);
  box-shadow: 8px 8px 0 rgba(168, 255, 96, 0.35);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-content {
  display: flex;
  align-items: center;
  padding: var(--space-4);
  gap: var(--space-3);
}

.error-message,
.success-message {
  flex: 1;
  color: var(--text-primary);
}

.toast-close {
  background-color: var(--surface);
  border: 2px solid var(--accent-magenta);
  font-size: var(--font-size-lg);
  cursor: pointer;
  color: var(--accent-magenta);
  padding: var(--space-1);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 3px 3px 0 var(--accent-magenta-dark);
  transition: var(--transition);
}

.toast-close:hover {
  background-color: var(--accent-magenta);
  color: var(--background);
  border-color: var(--accent-magenta-dark);
  box-shadow: 4px 4px 0 var(--accent-magenta-dark);
}

@media (max-width: 640px) {
  .error-toast,
  .success-toast {
    left: var(--space-4);
    right: var(--space-4);
    max-width: none;
  }
}


