/* ============================================
   LIFE · Cellular Automaton
   A distinctive bio-cyberpunk aesthetic
   ============================================ */

/* CSS Custom Properties */
:root {
  /* Core palette - Deep space with bio-luminescent accents */
  --void: #050508;
  --abyss: #0a0a0f;
  --deep: #0f1118;
  --surface: #151820;
  --elevated: #1c2030;
  --border: #252a3a;
  --border-light: #343a4f;
  
  /* Bio-luminescent accent colors */
  --life: #00ff88;
  --life-dim: #00cc6a;
  --life-glow: rgba(0, 255, 136, 0.3);
  --life-pulse: rgba(0, 255, 136, 0.1);
  
  --energy: #00d4ff;
  --energy-dim: #00a8cc;
  --energy-glow: rgba(0, 212, 255, 0.3);
  
  --mutation: #ff00aa;
  --mutation-dim: #cc0088;
  --mutation-glow: rgba(255, 0, 170, 0.3);
  
  --warning: #ffaa00;
  --danger: #ff4444;
  
  /* Text hierarchy */
  --text: #e8ecf4;
  --text-dim: #8892a8;
  --text-muted: #5a6478;
  
  /* Cell aging gradient */
  --cell-new: #00ff88;
  --cell-young: #44ff99;
  --cell-mature: #88ffbb;
  --cell-old: #aaffcc;
  --cell-ancient: #ccffdd;
  
  /* Trails */
  --trail-1: rgba(0, 255, 136, 0.4);
  --trail-2: rgba(0, 255, 136, 0.2);
  --trail-3: rgba(0, 255, 136, 0.08);
  
  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Typography */
  --font-display: 'Outfit', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
  
  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  
  /* Effects */
  --glow-sm: 0 0 10px var(--life-glow);
  --glow-md: 0 0 20px var(--life-glow), 0 0 40px var(--life-pulse);
  --glow-lg: 0 0 30px var(--life-glow), 0 0 60px var(--life-pulse);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
}

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-display);
  background: var(--abyss);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

/* ============================================
   App Layout
   ============================================ */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Ambient Background */
.ambient-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.gradient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: float 20s ease-in-out infinite;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--life-pulse) 0%, transparent 70%);
  top: -200px;
  left: -200px;
  animation-delay: 0s;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--energy-glow) 0%, transparent 70%);
  bottom: -100px;
  right: -100px;
  animation-delay: -7s;
  opacity: 0.3;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--mutation-glow) 0%, transparent 70%);
  top: 50%;
  left: 30%;
  animation-delay: -14s;
  opacity: 0.2;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -20px) scale(1.05); }
  50% { transform: translate(-20px, 30px) scale(0.95); }
  75% { transform: translate(20px, 20px) scale(1.02); }
}

/* ============================================
   Header
   ============================================ */

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo-icon {
  width: 36px;
  height: 36px;
  color: var(--life);
  filter: drop-shadow(0 0 8px var(--life-glow));
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text);
  line-height: 1;
}

.logo-subtitle {
  font-size: 0.625rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.header-nav {
  display: flex;
  gap: var(--space-sm);
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--text-dim);
  transition: all 0.2s var(--ease-out);
  position: relative;
}

.nav-btn svg {
  width: 20px;
  height: 20px;
}

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

.nav-btn[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--elevated);
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
}

/* ============================================
   Main Content
   ============================================ */

.main {
  display: flex;
  flex: 1;
  min-height: 0; /* Allow flex shrinking */
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* Canvas Container */
.canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: var(--space-lg);
  padding-bottom: calc(var(--space-lg) + 90px); /* Room for graph */
  overflow: hidden;
  min-width: 0; /* Allow flex shrinking */
}

#gameCanvas {
  background: var(--deep);
  border-radius: 12px;
  box-shadow: var(--shadow-lg), inset 0 0 80px rgba(0, 0, 0, 0.5), 0 0 60px rgba(0, 255, 136, 0.05);
  cursor: crosshair;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
  transition: box-shadow 0.3s var(--ease-out);
}

#gameCanvas.simulation-active {
  cursor: default;
}

#gameCanvas:hover {
  box-shadow: var(--shadow-lg), inset 0 0 80px rgba(0, 0, 0, 0.5), 0 0 80px rgba(0, 255, 136, 0.08);
}

/* Floating Stats */
.floating-stats {
  position: absolute;
  top: var(--space-lg);
  left: var(--space-lg);
  display: flex;
  gap: var(--space-md);
  pointer-events: none;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: rgba(15, 17, 24, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.evolution-stat .stat-value {
  color: var(--life);
}

/* Mode Indicator */
.mode-indicator {
  position: absolute;
  top: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid var(--life);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--life);
  pointer-events: none;
}

.mode-indicator.active {
  display: flex;
  animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 var(--life-glow); }
  50% { box-shadow: 0 0 10px 2px var(--life-glow); }
}

/* Zoom Controls */
.zoom-controls {
  position: absolute;
  bottom: calc(var(--space-lg) + 90px);
  right: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  z-index: 15;
}

.zoom-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(15, 17, 24, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  transition: all 0.2s var(--ease-out);
}

.zoom-btn svg {
  width: 18px;
  height: 18px;
}

.zoom-btn:hover {
  background: var(--elevated);
  border-color: var(--life);
  color: var(--life);
}

/* Species List */
.species-list {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  background: rgba(15, 17, 24, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--space-sm);
  min-width: 140px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 15;
}

.species-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: var(--space-xs);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border);
}

.species-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.species-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 0.75rem;
  transition: background 0.2s;
}

.species-item:hover {
  background: var(--elevated);
}

.species-item.dominant {
  background: rgba(255, 0, 170, 0.15);
  border: 1px solid rgba(255, 0, 170, 0.3);
}

.species-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.species-name {
  color: var(--text);
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.species-count {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}

.species-percent {
  color: var(--text-muted);
  font-size: 0.65rem;
  min-width: 32px;
  text-align: right;
}

/* Population Graph (Desktop Only) */
.population-graph {
  position: absolute;
  bottom: 0;
  left: var(--space-lg);
  right: calc(320px + var(--space-lg));
  height: 80px;
  background: rgba(15, 17, 24, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: var(--space-xs) var(--space-md);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.graph-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.graph-title {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.graph-value {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--life);
}

#graphCanvas {
  flex: 1;
  width: 100%;
  min-height: 40px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
}

.graph-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  color: var(--text-muted);
  margin-top: 2px;
  flex-shrink: 0;
}

/* Hide population graph on mobile */
@media (max-width: 768px) {
  .population-graph {
    display: none;
  }
}

/* ============================================
   Control Panel
   ============================================ */

.panel {
  width: 320px;
  flex-shrink: 0;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.panel-section {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.panel-section:last-child {
  border-bottom: none;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.section-header h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.info-icon {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  margin-left: 0.25rem;
  opacity: 0.6;
  transition: opacity 0.2s, color 0.2s;
}

.info-icon:hover {
  opacity: 1;
  color: var(--life);
}

.section-header.small {
  margin-bottom: var(--space-sm);
}

.section-header.small span {
  font-size: 0.6875rem;
}

.section-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--life);
}

/* Transport Controls */
.transport {
  padding: var(--space-md) var(--space-lg);
}

.transport-controls {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.transport-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  transition: all 0.2s var(--ease-out);
}

.transport-btn svg {
  width: 24px;
  height: 24px;
}

.transport-btn.primary {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--life) 0%, var(--life-dim) 100%);
  color: var(--void);
  box-shadow: var(--glow-md);
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: var(--glow-md); }
  50% { box-shadow: var(--glow-lg); }
}

.transport-btn.primary:hover {
  transform: scale(1.05);
  box-shadow: var(--glow-lg);
  animation: none;
}

.transport-btn.primary:active {
  transform: scale(0.98);
}

.transport-btn.primary.playing {
  animation: none;
  background: linear-gradient(135deg, var(--energy) 0%, var(--energy-dim) 100%);
}

.transport-btn.secondary {
  background: var(--elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.transport-btn.secondary:hover {
  border-color: var(--life);
  color: var(--life);
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: all 0.2s var(--ease-out);
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

.action-btn:hover {
  border-color: var(--life);
  color: var(--life);
}

/* Slider */
.slider {
  width: 100%;
  height: 4px;
  background: var(--surface);
  border-radius: 2px;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--life);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--glow-sm);
  transition: all 0.15s var(--ease-out);
}

.slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: var(--glow-md);
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--life);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: var(--glow-sm);
}

.slider.small {
  height: 3px;
}

.slider.small::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
}

/* Toggle */
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.toggle input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  position: relative;
  transition: all 0.2s var(--ease-out);
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all 0.2s var(--ease-out);
}

.toggle input:checked + .toggle-slider {
  background: rgba(0, 255, 136, 0.2);
  border-color: var(--life);
}

.toggle input:checked + .toggle-slider::after {
  left: 18px;
  background: var(--life);
  box-shadow: var(--glow-sm);
}

.toggle-label {
  font-size: 0.8125rem;
  color: var(--text-dim);
}

.toggle.compact .toggle-slider {
  width: 32px;
  height: 18px;
}

.toggle.compact .toggle-slider::after {
  width: 12px;
  height: 12px;
}

.toggle.compact input:checked + .toggle-slider::after {
  left: 16px;
}

/* Custom Rules Section */
.rules-section {
  position: relative;
}

.rules-notation {
  font-family: var(--font-mono);
  font-weight: 600;
}

.rules-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.rule-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.rule-type {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  width: 50px;
  flex-shrink: 0;
}

.rule-toggles {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.rule-toggle {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

.rule-toggle:hover {
  border-color: var(--life);
  color: var(--life);
}

.rule-toggle.active {
  background: rgba(0, 255, 136, 0.2);
  border-color: var(--life);
  color: var(--life);
  box-shadow: 0 0 6px var(--life-pulse);
}

.rules-warning {
  display: none;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 170, 0, 0.1);
  border: 1px solid rgba(255, 170, 0, 0.3);
  border-radius: 6px;
  font-size: 0.6875rem;
  color: var(--warning);
}

.rules-warning.visible {
  display: flex;
}

.warning-icon {
  font-size: 0.875rem;
}

.rules-locked-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.9);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-sm);
  border-radius: inherit;
  z-index: 10;
}

.rules-section.locked .rules-locked-overlay {
  display: flex;
}

.locked-icon {
  font-size: 1.5rem;
  opacity: 0.6;
}

.locked-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Locked State for Sections */
.panel-section.locked {
  position: relative;
  pointer-events: none;
  opacity: 0.5;
}

.panel-section.locked::after {
  content: '🔒';
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  font-size: 0.875rem;
  opacity: 0.5;
}

/* Specific locked state for rules section (has custom overlay) */
.rules-section.locked {
  opacity: 1;
}

.rules-section.locked::after {
  display: none;
}

/* Locked state for tools */
.tool-btn.locked {
  pointer-events: none;
  opacity: 0.4;
}

/* Locked state for action buttons */
.action-btn.locked {
  pointer-events: none;
  opacity: 0.4;
}

/* Keep speed section always active */
.panel-section:has(#speedSlider) {
  pointer-events: auto !important;
  opacity: 1 !important;
}

.panel-section:has(#speedSlider)::after {
  display: none !important;
}

/* Evolution Section */
.evolution-content {
  display: none;
}

.evolution-section.active .evolution-content {
  display: block;
}

.rules-display {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: var(--space-md);
}

.rule-badge {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--life);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: 6px;
}

.rule-name {
  font-size: 0.8125rem;
  color: var(--text-dim);
}

.evolution-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.evo-stat {
  display: flex;
  flex-direction: column;
  padding: var(--space-sm);
  background: var(--surface);
  border-radius: 6px;
}

.evo-label {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.evo-value {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-top: 2px;
}

.mutation-rate {
  padding: var(--space-md);
  background: var(--surface);
  border-radius: 8px;
}

.preset-btns {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.preset-btn {
  flex: 1;
  padding: var(--space-xs) var(--space-sm);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

.preset-btn:hover {
  border-color: var(--life);
  color: var(--life);
}

.preset-btn.active {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--life);
  color: var(--life);
}

/* Board Size Presets */
.size-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xs);
}

.size-btn {
  padding: var(--space-sm) var(--space-xs);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

.size-btn:hover {
  border-color: var(--life);
  color: var(--life);
}

.size-btn.active {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--life);
  color: var(--life);
}

/* Patterns Section */
.patterns-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rotation-controls {
  display: none;
  align-items: center;
  gap: var(--space-xs);
}

.rotation-controls.visible {
  display: flex;
}

.rotate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.875rem;
  color: var(--text-dim);
  transition: all 0.15s var(--ease-out);
}

.rotate-btn:hover {
  border-color: var(--life);
  color: var(--life);
}

.rotation-display {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 28px;
  text-align: center;
}

.pattern-categories {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
}

.category-btn {
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.15s var(--ease-out);
}

.category-btn:hover {
  border-color: var(--life);
  color: var(--life);
}

.category-btn.active {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--life);
  color: var(--life);
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  overflow-y: auto;
  flex: 1;
  padding-right: var(--space-xs);
}

.pattern-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.pattern-card:hover {
  border-color: var(--life);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pattern-card.selected {
  background: rgba(0, 255, 136, 0.1);
  border-color: var(--life);
  box-shadow: var(--glow-sm);
  animation: selected-pulse 2s ease-in-out infinite;
}

@keyframes selected-pulse {
  0%, 100% { box-shadow: var(--glow-sm); }
  50% { box-shadow: var(--glow-md); }
}

.pattern-preview {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  margin-bottom: var(--space-xs);
}

.pattern-name {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-dim);
  text-align: center;
}

.pattern-card.selected .pattern-name {
  color: var(--life);
}

/* Tools */
.tool-btns {
  display: flex;
  gap: var(--space-sm);
}

.tool-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

.tool-btn svg {
  width: 20px;
  height: 20px;
}

.tool-btn span {
  font-size: 0.625rem;
  font-weight: 500;
}

.tool-btn:hover {
  border-color: var(--life);
  color: var(--life);
}

.tool-btn.active {
  background: rgba(0, 255, 136, 0.1);
  border-color: var(--life);
  color: var(--life);
}

/* ============================================
   Modals
   ============================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s var(--ease-out);
}

.modal.active {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 8, 0.9);
  backdrop-filter: blur(10px);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s var(--ease-out);
}

.modal.active .modal-content {
  transform: translateY(0) scale(1);
}

.modal-content.large {
  max-width: 560px;
}

.modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elevated);
  border-radius: 8px;
  font-size: 1.5rem;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

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

.modal-content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
  padding-right: var(--space-xl);
}

.modal-body section {
  margin-bottom: var(--space-xl);
}

.modal-body section:last-child {
  margin-bottom: 0;
}

.modal-body h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--life);
  margin-bottom: var(--space-sm);
}

.modal-body p {
  font-size: 0.875rem;
  color: var(--text-dim);
  margin-bottom: var(--space-sm);
}

.modal-body ul {
  list-style: none;
  font-size: 0.875rem;
  color: var(--text-dim);
}

.modal-body li {
  padding: var(--space-xs) 0;
  padding-left: var(--space-lg);
  position: relative;
}

.modal-body li::before {
  content: '•';
  position: absolute;
  left: var(--space-sm);
  color: var(--life);
}

.rules-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding-left: 0;
}

.rules-list li::before {
  display: none;
}

.rule-icon {
  font-size: 1rem;
  line-height: 1.4;
}

.credits {
  padding: var(--space-md);
  background: var(--elevated);
  border-radius: 8px;
  border-left: 3px solid var(--life);
}

.credits p {
  margin-bottom: var(--space-sm);
}

.credits .author {
  margin-bottom: 0;
  color: var(--text);
}

/* Keyboard Shortcuts */
.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.shortcut {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--elevated);
  border-radius: 6px;
}

.shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 var(--space-xs);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--life);
}

.shortcut span {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Share Modal */
.share-content p {
  font-size: 0.875rem;
  color: var(--text-dim);
  margin-bottom: var(--space-md);
}

.share-url-container {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.share-url-container input {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--life);
  border-radius: 8px;
  color: var(--void);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: all 0.15s var(--ease-out);
}

.copy-btn svg {
  width: 16px;
  height: 16px;
}

.copy-btn:hover {
  background: var(--life-dim);
}

.share-note {
  font-size: 0.75rem !important;
  color: var(--text-muted) !important;
}

/* ============================================
   Results Modal
   ============================================ */

.results-modal {
  max-width: 480px;
  text-align: center;
}

.results-header {
  margin-bottom: var(--space-xl);
}

.results-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  animation: result-bounce 0.6s var(--ease-out);
}

@keyframes result-bounce {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.results-header h2 {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
  padding-right: 0;
}

.results-description {
  color: var(--text-dim);
  font-size: 0.875rem;
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.result-stat {
  padding: var(--space-md);
  background: var(--elevated);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.result-stat.primary {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.1) 0%, rgba(0, 212, 255, 0.1) 100%);
  border-color: var(--life);
}

.result-stat.births {
  border-color: rgba(0, 255, 136, 0.3);
}

.result-stat.deaths {
  border-color: rgba(255, 68, 68, 0.3);
}

.result-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.result-stat.primary .result-value {
  font-size: 2.5rem;
  color: var(--life);
}

.result-stat.births .result-value {
  color: var(--life);
}

.result-stat.deaths .result-value {
  color: var(--danger);
}

.result-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.age-breakdown {
  text-align: left;
  margin-bottom: var(--space-xl);
  padding: var(--space-lg);
  background: var(--surface);
  border-radius: 12px;
}

.age-breakdown h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: var(--space-md);
  text-align: center;
}

.age-bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.age-row {
  display: grid;
  grid-template-columns: 80px 1fr 40px;
  align-items: center;
  gap: var(--space-sm);
}

.age-label {
  font-size: 0.6875rem;
  color: var(--text-dim);
  text-align: right;
}

.age-bar-container {
  height: 16px;
  background: var(--elevated);
  border-radius: 8px;
  overflow: hidden;
}

.age-bar {
  height: 100%;
  border-radius: 8px;
  transition: width 0.5s var(--ease-out);
  min-width: 2px;
}

.age-bar.new { background: var(--cell-new); }
.age-bar.young { background: var(--cell-young); }
.age-bar.mature { background: var(--cell-mature); }
.age-bar.old { background: var(--cell-old); }
.age-bar.ancient { background: var(--cell-ancient); }

.age-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.results-actions {
  display: flex;
  gap: var(--space-md);
}

.results-btn {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s var(--ease-out);
}

.results-btn.primary {
  background: linear-gradient(135deg, var(--life) 0%, var(--life-dim) 100%);
  color: var(--void);
}

.results-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-md);
}

.results-btn.secondary {
  background: var(--elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.results-btn.secondary:hover {
  border-color: var(--life);
  color: var(--life);
}

.results-btn.full-width {
  flex: none;
  width: 100%;
}

.results-actions-row {
  margin-top: var(--space-sm);
}

.results-high-score {
  text-align: center;
  margin-bottom: var(--space-md);
  animation: high-score-flash 0.5s ease-in-out infinite alternate;
}

@keyframes high-score-flash {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0.8; transform: scale(1.02); }
}

.high-score-text {
  display: inline-block;
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
  color: var(--void);
  font-weight: 700;
  font-size: 0.875rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.results-mode {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* ============================================
   Initials Modal (Arcade Style)
   ============================================ */

.initials-modal {
  max-width: 360px;
  text-align: center;
}

.initials-header {
  margin-bottom: var(--space-xl);
}

.high-score-badge {
  display: inline-block;
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
  color: var(--void);
  font-weight: 700;
  font-size: 1rem;
  border-radius: 8px;
  margin-bottom: var(--space-md);
  animation: badge-pulse 1s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 20px rgba(255, 215, 0, 0.5); }
  50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(255, 215, 0, 0.8); }
}

.initials-header h2 {
  margin-bottom: var(--space-sm);
  padding-right: 0;
}

.initials-score {
  font-size: 1rem;
  color: var(--text-dim);
}

.initials-score span {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--life);
}

.initials-input-container {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.initial-input {
  width: 60px;
  height: 80px;
  background: var(--elevated);
  border: 3px solid var(--border);
  border-radius: 12px;
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--life);
  text-align: center;
  text-transform: uppercase;
  caret-color: var(--life);
  transition: all 0.2s var(--ease-out);
}

.initial-input:focus {
  outline: none;
  border-color: var(--life);
  box-shadow: var(--glow-md);
  background: rgba(0, 255, 136, 0.1);
}

.initial-input::placeholder {
  color: var(--border);
}

.initials-actions {
  display: flex;
  gap: var(--space-md);
}

/* ============================================
   Leaderboard Modal
   ============================================ */

.leaderboard-modal {
  max-width: 420px;
}

.leaderboard-modal h2 {
  text-align: center;
  padding-right: 0;
}

.leaderboard-tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  padding: var(--space-xs);
  background: var(--elevated);
  border-radius: 10px;
}

.leaderboard-tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s var(--ease-out);
}

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

.leaderboard-tab.active {
  background: var(--life);
  color: var(--void);
}

.leaderboard-content {
  min-height: 200px;
  margin-bottom: var(--space-lg);
}

.leaderboard-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.leaderboard-empty p {
  color: var(--text-dim);
  margin-bottom: var(--space-xs);
}

.empty-hint {
  font-size: 0.75rem !important;
  color: var(--text-muted) !important;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 40px 60px 1fr 80px;
  align-items: center;
  padding: var(--space-md);
  background: var(--elevated);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: all 0.2s var(--ease-out);
}

.leaderboard-row:hover {
  border-color: var(--life);
}

.leaderboard-row.gold {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 170, 0, 0.1) 100%);
  border-color: rgba(255, 215, 0, 0.5);
}

.leaderboard-row.silver {
  background: linear-gradient(135deg, rgba(192, 192, 192, 0.15) 0%, rgba(169, 169, 169, 0.1) 100%);
  border-color: rgba(192, 192, 192, 0.5);
}

.leaderboard-row.bronze {
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.15) 0%, rgba(184, 115, 51, 0.1) 100%);
  border-color: rgba(205, 127, 50, 0.5);
}

.leaderboard-row .rank {
  font-size: 1.25rem;
  text-align: center;
}

.leaderboard-row .initials {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--life);
  letter-spacing: 0.1em;
}

.leaderboard-row .generations {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  padding-right: var(--space-md);
}

.leaderboard-row .date {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: right;
}

.refresh-scores-btn {
  width: 100%;
  padding: var(--space-sm);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: all 0.2s var(--ease-out);
}

.refresh-scores-btn:hover {
  border-color: var(--life);
  color: var(--life);
}

.leaderboard-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ============================================
   Unified Results Modal
   ============================================ */

.results-modal.unified {
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.results-modal.unified .results-header {
  margin-bottom: var(--space-lg);
}

.results-modal.unified .results-stats {
  margin-bottom: var(--space-md);
}

/* Collapsible Age Breakdown */
.age-breakdown-details {
  margin-bottom: var(--space-lg);
  background: var(--surface);
  border-radius: 10px;
  overflow: hidden;
}

.age-breakdown-details summary {
  padding: var(--space-md);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.age-breakdown-details summary::-webkit-details-marker {
  display: none;
}

.age-breakdown-details summary::after {
  content: '▶';
  font-size: 0.625rem;
  transition: transform 0.2s var(--ease-out);
}

.age-breakdown-details[open] summary::after {
  transform: rotate(90deg);
}

.age-breakdown-details .age-bars {
  padding: 0 var(--space-md) var(--space-md);
}

.age-breakdown-details .age-row {
  grid-template-columns: 50px 1fr 30px;
}

.age-breakdown-details .age-label {
  font-size: 0.625rem;
}

/* Initials Section in Results */
.results-initials-section {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(255, 170, 0, 0.05) 100%);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.initials-prompt {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  font-size: 0.875rem;
  color: var(--text);
}

.high-score-badge-inline {
  background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
  color: var(--void);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
  animation: badge-pulse 1s ease-in-out infinite;
}

.initials-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.initial-input-small {
  width: 44px;
  height: 52px;
  background: var(--elevated);
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--life);
  text-align: center;
  text-transform: uppercase;
  transition: all 0.2s var(--ease-out);
}

.initial-input-small:focus {
  outline: none;
  border-color: #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.submit-initials-btn {
  height: 52px;
  padding: 0 var(--space-lg);
  background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--void);
  transition: all 0.2s var(--ease-out);
}

.submit-initials-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

/* Leaderboard Section in Results */
.results-leaderboard-section {
  background: var(--surface);
  border-radius: 12px;
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.leaderboard-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.leaderboard-header-row h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.leaderboard-tabs-inline {
  display: flex;
  gap: var(--space-xs);
}

.tab-btn {
  padding: var(--space-xs) var(--space-sm);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

.tab-btn:hover {
  border-color: var(--life);
  color: var(--life);
}

.tab-btn.active {
  background: var(--life);
  border-color: var(--life);
  color: var(--void);
}

.results-leaderboard-content {
  min-height: 80px;
}

.lb-row {
  display: grid;
  grid-template-columns: 32px 50px 1fr;
  align-items: center;
  padding: var(--space-sm);
  background: var(--elevated);
  border-radius: 6px;
  margin-bottom: var(--space-xs);
  transition: all 0.2s var(--ease-out);
}

.lb-row.new-score {
  background: rgba(0, 255, 136, 0.15);
  border: 1px solid var(--life);
  animation: new-score-flash 0.5s ease-in-out;
}

@keyframes new-score-flash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.lb-rank {
  font-size: 1rem;
  text-align: center;
}

.lb-initials {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--life);
  letter-spacing: 0.05em;
}

.lb-gens {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: right;
}

.lb-more {
  text-align: center;
  font-size: 0.6875rem;
  color: var(--text-muted);
  padding: var(--space-sm);
}

.no-scores {
  text-align: center;
  padding: var(--space-lg);
  color: var(--text-muted);
}

/* Ruleset Info and Navigation */
.leaderboard-ruleset-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--energy);
}

.current-badge {
  background: rgba(0, 212, 255, 0.2);
  color: var(--energy);
  font-size: 0.625rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.leaderboard-ruleset-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.ruleset-nav-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  color: var(--text-dim);
  transition: all 0.15s var(--ease-out);
}

.ruleset-nav-btn:hover {
  border-color: var(--energy);
  color: var(--energy);
}

.ruleset-nav-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 50px;
  text-align: center;
  font-size: 0.875rem;
}

/* Final Actions */
.results-actions-final {
  display: flex;
  gap: var(--space-md);
}

.results-actions-final .results-btn {
  flex: 1;
}

/* ============================================
   Toast Notification
   ============================================ */

.toast {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--life);
  border-radius: 12px;
  box-shadow: var(--shadow-lg), var(--glow-sm);
  z-index: 1100;
  opacity: 0;
  transition: all 0.4s var(--ease-out);
  pointer-events: none;
}

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

.toast-icon {
  font-size: 1.25rem;
  animation: toast-bounce 0.5s var(--ease-out);
}

@keyframes toast-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.toast-message {
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
}

/* ============================================
   Mobile Styles
   ============================================ */

/* Mobile Menu FAB */
.mobile-menu-btn {
  /* Hidden on desktop, shown via media query */
  display: none;
  position: fixed;
  bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
  right: var(--space-lg);
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--life) 0%, var(--life-dim) 100%);
  border-radius: 50%;
  color: var(--void);
  box-shadow: var(--glow-md);
  z-index: 200;
  transition: all 0.3s var(--ease-out);
  /* Flex alignment for icon centering */
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s var(--ease-out);
  flex-shrink: 0;
}

.mobile-menu-btn.active {
  background: var(--danger);
  box-shadow: 0 0 20px rgba(255, 68, 68, 0.4);
}

.mobile-menu-btn.active svg {
  transform: rotate(45deg);
}

.mobile-menu-btn:active {
  transform: scale(0.95);
}

/* Mobile Top Controls */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 50;
  padding: var(--space-sm) var(--space-md);
}

.mobile-transport {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  pointer-events: auto;
}

.mobile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  transition: all 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.mobile-btn svg {
  width: 22px;
  height: 22px;
}

.mobile-btn.primary {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--life) 0%, var(--life-dim) 100%);
  color: var(--void);
  box-shadow: var(--glow-md);
}

.mobile-btn.primary.playing {
  background: linear-gradient(135deg, var(--energy) 0%, var(--energy-dim) 100%);
}

.mobile-btn.secondary {
  background: rgba(15, 17, 24, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.mobile-btn.secondary:active {
  background: var(--elevated);
  border-color: var(--life);
  color: var(--life);
}

/* Mobile Stats */
.mobile-stats {
  position: fixed;
  bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
  left: var(--space-md);
  display: none;
  gap: var(--space-sm);
  pointer-events: auto;
  z-index: 50;
}

.mobile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: rgba(15, 17, 24, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.mobile-stat-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.mobile-stat-label {
  font-size: 0.5625rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ============================================
   Mobile Bottom Sheet
   ============================================ */

.mobile-sheet-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 8, 0.7);
  backdrop-filter: blur(4px);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-out);
}

.mobile-sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-sheet {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  max-height: 85dvh;
  background: var(--abyss);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  z-index: 160;
  transform: translateY(100%);
  transition: transform 0.4s var(--ease-out);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  pointer-events: none;
}

.mobile-sheet.active {
  transform: translateY(0);
  pointer-events: auto;
}

/* Sheet Handle */
.sheet-handle {
  display: flex;
  justify-content: center;
  padding: var(--space-sm) 0;
  cursor: grab;
}

.sheet-handle::before {
  content: '';
  width: 36px;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
}

/* Sheet Tabs */
.sheet-tabs {
  display: flex;
  gap: var(--space-xs);
  padding: 0 var(--space-md) var(--space-sm);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.sheet-tabs::-webkit-scrollbar {
  display: none;
}

.sheet-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  min-width: 70px;
}

.sheet-tab svg {
  width: 20px;
  height: 20px;
}

.sheet-tab.active {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--life);
  color: var(--life);
}

/* Sheet Content */
.sheet-content {
  overflow-y: auto;
  max-height: calc(85vh - 100px);
  max-height: calc(85dvh - 100px);
  overscroll-behavior: contain;
  /* Extra padding at bottom to prevent content hiding behind FAB button */
  padding-bottom: 80px;
}

.sheet-panel {
  display: none;
  padding: var(--space-md);
  padding-bottom: 0; /* Content padding handled by sheet-content */
  animation: sheet-fade-in 0.2s var(--ease-out);
}

.sheet-panel.active {
  display: block;
}

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

/* Sheet Controls Panel */
.sheet-controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.sheet-control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-dim);
  transition: all 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.sheet-control-btn svg {
  width: 24px;
  height: 24px;
}

.sheet-control-btn span {
  font-size: 0.6875rem;
  font-weight: 500;
}

.sheet-control-btn:active,
.sheet-control-btn.active {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--life);
  color: var(--life);
}

/* Sheet Speed Control */
.sheet-speed {
  background: var(--surface);
  border-radius: 12px;
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.sheet-speed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.sheet-speed-header span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sheet-speed-value {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--life);
}

/* Sheet Board Size */
.sheet-board-size {
  margin-bottom: var(--space-lg);
}

.sheet-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-sm);
}

/* Sheet Rules Editor */
.sheet-rules {
  background: var(--surface);
  border-radius: 12px;
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.sheet-rules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.sheet-rules-header .sheet-section-title {
  margin-bottom: 0;
}

.sheet-rules-notation {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--life);
}

.sheet-rules-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.sheet-rule-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sheet-rule-type {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  width: 50px;
  flex-shrink: 0;
}

.sheet-rule-toggles {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.sheet-rule-toggle {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.sheet-rule-toggle:active {
  transform: scale(0.95);
}

.sheet-rule-toggle.active {
  background: rgba(0, 255, 136, 0.2);
  border-color: var(--life);
  color: var(--life);
  box-shadow: 0 0 8px var(--life-pulse);
}

.sheet-rules-warning {
  display: none;
  margin-top: var(--space-sm);
  padding: var(--space-sm);
  background: rgba(255, 170, 0, 0.1);
  border: 1px solid rgba(255, 170, 0, 0.3);
  border-radius: 6px;
  font-size: 0.6875rem;
  color: var(--warning);
  text-align: center;
}

.sheet-rules-warning.visible {
  display: block;
}

.sheet-rules.locked {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

.sheet-rules.locked::after {
  content: '🔒 Locked during simulation';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.8);
  border-radius: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sheet-rules-presets {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.sheet-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.sheet-preset-btn {
  padding: var(--space-sm) var(--space-xs);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-preset-btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-dim);
  color: var(--text);
}

.sheet-preset-btn.active {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--life);
  color: var(--life);
}

.sheet-size-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
}

.sheet-size-btn {
  padding: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s var(--ease-out);
}

.sheet-size-btn.active {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--life);
  color: var(--life);
}

/* Sheet Patterns Panel */
.sheet-pattern-categories {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
  scrollbar-width: none;
}

.sheet-pattern-categories::-webkit-scrollbar {
  display: none;
}

.sheet-cat-btn {
  padding: var(--space-xs) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.2s var(--ease-out);
}

.sheet-cat-btn.active {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--life);
  color: var(--life);
}

.sheet-pattern-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
}

.sheet-pattern-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.2s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.sheet-pattern-card.selected {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--life);
  box-shadow: var(--glow-sm);
}

.sheet-pattern-card canvas {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.sheet-pattern-card span {
  font-size: 0.5625rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
}

.sheet-pattern-card.selected span {
  color: var(--life);
}

/* Pattern Rotation (mobile) */
.sheet-rotation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--surface);
  border-radius: 12px;
  margin-bottom: var(--space-md);
}

.sheet-rotation.hidden {
  display: none;
}

.sheet-rotate-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1.25rem;
  color: var(--text-dim);
  transition: all 0.2s var(--ease-out);
}

.sheet-rotate-btn:active {
  border-color: var(--life);
  color: var(--life);
}

.sheet-rotation-display {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--life);
  min-width: 40px;
  text-align: center;
}

/* Sheet Settings Panel */
.sheet-toggle-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.sheet-toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--surface);
  border-radius: 12px;
}

.sheet-toggle-item label {
  font-size: 0.875rem;
  color: var(--text);
}

/* Sheet Evolution Panel */
.sheet-evolution-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: linear-gradient(135deg, rgba(255, 0, 170, 0.1) 0%, rgba(0, 255, 136, 0.1) 100%);
  border: 1px solid var(--mutation);
  border-radius: 12px;
  margin-bottom: var(--space-md);
}

.sheet-evolution-toggle span {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--mutation);
}

.sheet-evolution-content {
  display: none;
}

.sheet-evolution-content.active {
  display: block;
}

.sheet-evo-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.sheet-evo-stat {
  padding: var(--space-md);
  background: var(--surface);
  border-radius: 10px;
  text-align: center;
}

.sheet-evo-stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--life);
}

.sheet-evo-stat-label {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.sheet-mutation-rate {
  background: var(--surface);
  border-radius: 12px;
  padding: var(--space-md);
}

.sheet-mutation-presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.sheet-mutation-preset {
  padding: var(--space-sm);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s var(--ease-out);
}

.sheet-mutation-preset.active {
  background: rgba(255, 0, 170, 0.15);
  border-color: var(--mutation);
  color: var(--mutation);
}

/* Sheet Tools Panel */
.sheet-tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.sheet-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  color: var(--text-dim);
  transition: all 0.2s var(--ease-out);
}

.sheet-tool-btn svg {
  width: 32px;
  height: 32px;
}

.sheet-tool-btn span {
  font-size: 0.75rem;
  font-weight: 600;
}

.sheet-tool-btn.active {
  background: rgba(0, 255, 136, 0.15);
  border-color: var(--life);
  color: var(--life);
}

/* Quick Actions Row */
.sheet-quick-actions {
  display: flex;
  gap: var(--space-sm);
}

.sheet-quick-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: all 0.2s var(--ease-out);
}

.sheet-quick-btn svg {
  width: 18px;
  height: 18px;
}

.sheet-quick-btn:active {
  border-color: var(--life);
  color: var(--life);
}

/* Hidden utility */
.hidden {
    display: none !important;
  }

/* ============================================
   3D Mode Styles
   ============================================ */

/* 2D/3D Mode Toggle Button */
.mode-toggle-container {
  display: flex;
  align-items: center;
  margin-right: var(--space-sm);
}

.mode-toggle-btn {
  display: flex;
  align-items: center;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px;
  gap: 2px;
  transition: all 0.2s var(--ease-out);
}

.mode-toggle-btn:hover {
  border-color: var(--life);
}

.mode-label {
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 16px;
  color: var(--text-muted);
  transition: all 0.2s var(--ease-out);
  cursor: pointer;
}

.mode-label.active {
  background: var(--life);
  color: var(--void);
  box-shadow: var(--glow-sm);
}

.mode-label:not(.active):hover {
  color: var(--text);
}

/* 3D Canvas Container */
.canvas-3d-container {
  position: absolute;
  inset: var(--space-lg);
  border-radius: 12px;
  overflow: hidden;
  background: var(--deep);
  box-shadow: var(--shadow-lg), inset 0 0 80px rgba(0, 0, 0, 0.5), 0 0 60px rgba(0, 255, 136, 0.05);
}

.canvas-3d-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* 3D Specific UI Elements */
.mode-2d-only.hidden,
.mode-3d-only.hidden {
  display: none !important;
}

/* 3D Size Buttons */
.size-btn-3d {
  padding: var(--space-sm) var(--space-xs);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

.size-btn-3d:hover {
  border-color: var(--energy);
  color: var(--energy);
}

.size-btn-3d.active {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--energy);
  color: var(--energy);
}

/* Layer Controls */
.layer-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.layer-slider-container {
  padding-top: var(--space-sm);
}

.camera-controls {
  margin-top: var(--space-sm);
}

/* 3D Edit Mode */
.edit-mode-content {
  display: none;
  margin-top: var(--space-md);
}

#editMode3DSection.active .edit-mode-content {
  display: block;
}

.edit-layer-control {
  background: var(--surface);
  border-radius: 8px;
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
}

.layer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.layer-nav-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: all 0.15s var(--ease-out);
}

.layer-nav-btn:hover {
  border-color: var(--energy);
  color: var(--energy);
}

.layer-nav-btn:active {
  transform: scale(0.95);
}

.layer-display {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--energy);
}

.layer-display span {
  color: var(--text);
}

#editLayerValue {
  color: var(--energy);
  font-size: 1.125rem;
}

.edit-mode-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-sm);
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: 6px;
}

/* Edit plane indicator in 3D view */
.edit-plane-indicator {
  position: absolute;
  bottom: calc(var(--space-lg) + 50px);
  left: var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid var(--energy);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--energy);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  pointer-events: none;
}

.edit-plane-indicator.hidden {
  display: none;
}

.edit-plane-dot {
  width: 8px;
  height: 8px;
  background: var(--energy);
  border-radius: 50%;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* 3D Rules Presets Grid */
.rules-3d-presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.rule-3d-preset {
  padding: var(--space-sm);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

.rule-3d-preset:hover {
  border-color: var(--energy);
  color: var(--energy);
}

.rule-3d-preset.active {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--energy);
  color: var(--energy);
}

/* Custom 3D Rules Toggle */
.custom-3d-rules-toggle {
  margin-bottom: var(--space-sm);
}

.expand-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: all 0.15s var(--ease-out);
}

.expand-btn:hover {
  border-color: var(--energy);
  color: var(--energy);
}

.expand-btn svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s var(--ease-out);
}

.expand-btn.expanded svg {
  transform: rotate(180deg);
}

/* Custom 3D Rules Editor */
.custom-3d-rules-editor {
  background: var(--surface);
  border-radius: 8px;
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.custom-3d-rules-editor.hidden {
  display: none;
}

.rule-3d-row {
  margin-bottom: var(--space-md);
}

.rule-3d-row:last-of-type {
  margin-bottom: var(--space-sm);
}

.rule-3d-type {
  display: block;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: var(--space-xs);
}

.rule-3d-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.rule-3d-toggle {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.1s var(--ease-out);
}

.rule-3d-toggle:hover {
  border-color: var(--energy);
  color: var(--energy);
}

.rule-3d-toggle.active {
  background: rgba(0, 212, 255, 0.25);
  border-color: var(--energy);
  color: var(--energy);
}

.rule-3d-hint {
  font-size: 0.625rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* 3D Patterns Section */
.pattern-3d-categories {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
}

.pattern-3d-cat {
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: all 0.15s var(--ease-out);
}

.pattern-3d-cat:hover {
  border-color: var(--energy);
  color: var(--energy);
}

.pattern-3d-cat.active {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--energy);
  color: var(--energy);
}

.pattern-3d-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  max-height: 200px;
  overflow-y: auto;
}

.pattern-3d-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.pattern-3d-card:hover {
  border-color: var(--energy);
  transform: translateY(-2px);
}

.pattern-3d-card.selected {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--energy);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.2);
}

.pattern-3d-icon {
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

.pattern-3d-name {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-dim);
  text-align: center;
}

.pattern-3d-card.selected .pattern-3d-name {
  color: var(--energy);
}

/* 3D Mode Indicator */
.mode-3d-indicator {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid var(--energy);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--energy);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  pointer-events: none;
}

.mode-3d-indicator .cube-icon {
  width: 16px;
  height: 16px;
}

/* 3D Controls overlay */
.controls-3d-overlay {
  position: absolute;
  bottom: var(--space-lg);
  left: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  pointer-events: none;
}

.controls-3d-overlay span {
  font-size: 0.6875rem;
  color: var(--text-muted);
  background: rgba(15, 17, 24, 0.8);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 4px;
}

/* 3D Stats overlay */
.stats-3d-overlay {
  position: absolute;
  top: var(--space-lg);
  left: var(--space-lg);
  display: flex;
  gap: var(--space-md);
  pointer-events: none;
}

.stat-3d {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: rgba(15, 17, 24, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.stat-3d .stat-value {
  color: var(--energy);
}

/* 3D Axis Labels */
.axis-label {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

.axis-label.x {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
}

.axis-label.y {
  color: #4ecdc4;
  background: rgba(78, 205, 196, 0.1);
}

.axis-label.z {
  color: #45b7d1;
  background: rgba(69, 183, 209, 0.1);
}

/* 3D Mobile Sheet Panel */
.sheet-3d-edit-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.15) 0%, rgba(0, 255, 136, 0.1) 100%);
  border: 1px solid var(--energy);
  border-radius: 12px;
  margin-bottom: var(--space-sm);
}

.edit-toggle-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.edit-toggle-icon {
  font-size: 1.25rem;
}

.edit-toggle-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--energy);
}

.sheet-3d-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: var(--space-lg);
  padding: var(--space-sm);
  background: var(--surface);
  border-radius: 6px;
}

.sheet-3d-layer-section {
  background: var(--surface);
  border-radius: 12px;
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.sheet-3d-layer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.sheet-3d-layer-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elevated);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text-dim);
  transition: all 0.15s var(--ease-out);
}

.sheet-3d-layer-btn:active {
  border-color: var(--energy);
  color: var(--energy);
  transform: scale(0.95);
}

.sheet-3d-layer-btn svg {
  width: 24px;
  height: 24px;
}

.sheet-3d-layer-display {
  text-align: center;
}

#sheet3DLayerValue {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--energy);
  display: block;
  line-height: 1;
}

.sheet-3d-layer-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sheet-3d-orientation-section {
  margin-bottom: var(--space-md);
}

.sheet-3d-orientation-btns {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.sheet-3d-orient-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 0.875rem;
  transition: all 0.15s var(--ease-out);
}

.sheet-3d-orient-btn .orient-icon {
  font-size: 1.25rem;
  opacity: 0.7;
}

.sheet-3d-orient-btn.active {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--energy);
  color: var(--energy);
}

.sheet-3d-orient-btn:active {
  transform: scale(0.98);
}

/* Sheet 3D Rules */
.sheet-3d-rules-section,
.sheet-3d-patterns-section {
  margin-bottom: var(--space-lg);
}

.sheet-3d-rules-notation {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--energy);
  background: rgba(0, 212, 255, 0.1);
  padding: var(--space-xs) var(--space-sm);
  border-radius: 4px;
  display: inline-block;
  margin-bottom: var(--space-sm);
}

.sheet-3d-rules-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-xs);
}

.sheet-rule-3d-btn {
  padding: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

.sheet-rule-3d-btn:hover,
.sheet-rule-3d-btn:active {
  border-color: var(--energy);
  color: var(--energy);
}

.sheet-rule-3d-btn.active {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--energy);
  color: var(--energy);
}

/* Sheet 3D Patterns */
.sheet-3d-pattern-cats {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.sheet-pattern-cat-btn {
  flex: 1;
  padding: var(--space-xs) var(--space-sm);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

.sheet-pattern-cat-btn.active {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--energy);
  color: var(--energy);
}

.sheet-3d-patterns-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xs);
  max-height: 180px;
  overflow-y: auto;
}

.sheet-pattern-3d-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.15s var(--ease-out);
}

.sheet-pattern-3d-btn:active {
  border-color: var(--energy);
  transform: scale(0.95);
}

.sheet-pattern-3d-btn.selected {
  background: rgba(0, 212, 255, 0.1);
  border-color: var(--energy);
}

.sheet-pattern-3d-icon {
  font-size: 1.25rem;
}

.sheet-pattern-3d-name {
  font-size: 0.5625rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}

.sheet-pattern-3d-btn.selected .sheet-pattern-3d-name {
  color: var(--energy);
}

.sheet-3d-size-section,
.sheet-3d-view-section {
  margin-bottom: var(--space-md);
}

.sheet-size-btn-3d {
  padding: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s var(--ease-out);
}

.sheet-size-btn-3d.active {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--energy);
  color: var(--energy);
}

.sheet-3d-reset-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: var(--space-md);
  transition: all 0.15s var(--ease-out);
}

.sheet-3d-reset-btn svg {
  width: 18px;
  height: 18px;
}

.sheet-3d-reset-btn:active {
  border-color: var(--energy);
  color: var(--energy);
}

/* 3D Mode Mobile Responsive */
@media (max-width: 768px) {
  .mode-toggle-container {
    margin-right: var(--space-xs);
  }
  
  .mode-toggle-btn {
    padding: 3px;
  }
  
  .mode-label {
    padding: 4px 8px;
    font-size: 0.6875rem;
  }
  
  .canvas-3d-container {
    inset: var(--space-sm);
    inset-top: 70px;
    inset-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
  
  .stats-3d-overlay {
    top: 70px;
    left: var(--space-sm);
  }
  
  .stat-3d {
    padding: var(--space-xs) var(--space-sm);
  }
  
  .stat-3d .stat-value {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .mode-label {
    padding: 3px 6px;
    font-size: 0.625rem;
  }
  
  .canvas-3d-container {
    inset-top: 60px;
    inset-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
  }
}
  
/* ============================================
   Responsive Breakpoints
   ============================================ */

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

@media (max-width: 768px) {
  html, body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }
  
  .app {
    height: 100%;
    height: 100dvh;
  }
  
  .header {
    padding: var(--space-sm) var(--space-md);
    flex-shrink: 0;
    height: 56px;
  }
  
  .logo-icon {
    width: 28px;
    height: 28px;
  }
  
  .logo-title {
    font-size: 1rem;
  }
  
  .logo-subtitle {
    display: none;
  }
  
  .header-nav {
    gap: var(--space-xs);
  }
  
  .nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }
  
  .nav-btn svg {
    width: 18px;
    height: 18px;
  }
  
  .main {
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }
  
  .panel {
    display: none;
  }
  
  .canvas-container {
    flex: 1;
    padding: var(--space-sm);
    padding-top: 70px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    min-height: 0;
  }
  
  #gameCanvas {
    max-width: calc(100vw - 16px);
    max-height: 100%;
    border-radius: 8px;
  }
  
  .floating-stats {
    display: none;
  }
  
  .zoom-controls {
    bottom: auto;
    top: 70px;
    right: var(--space-sm);
    flex-direction: row;
    gap: var(--space-xs);
  }
  
  .zoom-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }
  
  .zoom-btn svg {
    width: 16px;
    height: 16px;
  }
  
  .mobile-menu-btn,
  .mobile-overlay,
  .mobile-stats {
    display: flex;
  }
  
  .mobile-sheet-backdrop,
  .mobile-sheet {
    display: block;
  }
  
  .shortcuts-grid {
    grid-template-columns: 1fr;
  }
  
  .modal-content {
    max-height: 85vh;
    max-height: 85dvh;
    border-radius: 16px 16px 0 0;
    margin: 0;
    margin-top: auto;
  }
  
  .modal {
    align-items: flex-end;
    padding: 0;
  }
  
  /* Mode indicator on mobile */
  .mode-indicator {
    top: auto;
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    font-size: 0.6875rem;
    padding: var(--space-xs) var(--space-sm);
  }
  
  /* Hide footer on mobile - we have bottom sheet */
  .site-footer {
    display: none;
  }
}

@media (max-width: 480px) {
  .header {
    padding: var(--space-xs) var(--space-sm);
    height: 52px;
  }
  
  .logo {
    gap: var(--space-sm);
  }
  
  .logo-icon {
    width: 24px;
    height: 24px;
  }
  
  .logo-title {
    font-size: 0.9375rem;
  }
  
  .canvas-container {
    padding: var(--space-xs);
    padding-top: 60px;
    padding-bottom: calc(75px + env(safe-area-inset-bottom, 0px));
  }
  
  .modal-content {
    padding: var(--space-md);
  }
  
  .mobile-overlay {
    top: 52px;
  }
  
  .mobile-transport {
    gap: var(--space-sm);
  }
  
  .mobile-btn {
    width: 44px;
    height: 44px;
  }
  
  .mobile-btn svg {
    width: 20px;
    height: 20px;
  }
  
  .mobile-btn.primary {
    width: 54px;
    height: 54px;
  }
  
  .mobile-stats {
    left: var(--space-sm);
    bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0px));
  }
  
  .mobile-stat {
    padding: var(--space-xs) var(--space-sm);
  }
  
  .mobile-stat-value {
    font-size: 0.875rem;
  }
  
  .mobile-menu-btn {
    width: 50px;
    height: 50px;
    right: var(--space-md);
    bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0px));
  }
  
  .mobile-menu-btn svg {
    width: 22px;
    height: 22px;
  }
  
  .zoom-controls {
    top: 60px;
    right: var(--space-xs);
  }
  
  .zoom-btn {
    width: 32px;
    height: 32px;
  }
  
  .zoom-btn svg {
    width: 14px;
    height: 14px;
  }
  
  /* Smaller sheet elements on small screens */
  .sheet-tabs {
    padding: 0 var(--space-sm) var(--space-sm);
  }
  
  .sheet-tab {
    padding: var(--space-xs) var(--space-sm);
    min-width: 60px;
  }
  
  .sheet-tab svg {
    width: 18px;
    height: 18px;
  }
  
  .sheet-pattern-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .sheet-controls-grid {
    gap: var(--space-xs);
  }
  
  .sheet-control-btn {
    padding: var(--space-sm);
  }
  
  .sheet-control-btn svg {
    width: 20px;
    height: 20px;
  }
  
  .sheet-control-btn span {
    font-size: 0.625rem;
  }
}

/* Extra small screens */
@media (max-width: 360px) {
  .sheet-pattern-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xs);
  }
  
  .sheet-pattern-card {
    padding: var(--space-xs);
  }
  
  .sheet-pattern-card canvas {
    width: 32px;
    height: 32px;
  }
  
  .sheet-size-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .sheet-tools-grid {
    gap: var(--space-sm);
  }
  
  .sheet-tool-btn {
    padding: var(--space-md);
  }
  
  .sheet-tool-btn svg {
    width: 28px;
    height: 28px;
  }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
  .mobile-overlay {
    top: 52px;
  }
  
  .mobile-transport {
    gap: var(--space-sm);
  }
  
  .mobile-btn {
    width: 40px;
    height: 40px;
  }
  
  .mobile-btn.primary {
    width: 48px;
    height: 48px;
  }
  
  .canvas-container {
    padding-top: 55px;
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }
  
  .mobile-sheet {
    max-height: 70vh;
    max-height: 70dvh;
  }
  
  .sheet-content {
    max-height: calc(70vh - 90px);
    max-height: calc(70dvh - 90px);
    padding-bottom: 70px; /* Slightly less on landscape */
  }
  
  .sheet-pattern-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ============================================
   Scrollbar Styling
   ============================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ============================================
   Selection
   ============================================ */

::selection {
  background: var(--life);
  color: var(--void);
}

/* ============================================
   Focus States
   ============================================ */

:focus-visible {
  outline: 2px solid var(--life);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--life);
  outline-offset: 2px;
}

/* ============================================
   Site Footer
   ============================================ */

.site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-sm) var(--space-lg);
  background: linear-gradient(to top, var(--abyss) 0%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}

.footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
  pointer-events: auto;
}

.footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.2s;
}

.footer-nav a:hover {
  color: var(--life);
}

@media (max-width: 768px) {
  .site-footer {
    padding: var(--space-xs) var(--space-sm);
    padding-bottom: calc(var(--space-xs) + env(safe-area-inset-bottom, 0));
  }
  
  .footer-nav {
    gap: var(--space-xs) var(--space-md);
  }
  
  .footer-nav a {
    font-size: 0.6875rem;
  }
}
