/* Default: Illuminated Dark Lab Theme (crisp, airy, glowing — never muddy) */
:root,
[data-theme="dark"] {
  --bg: #131c1a;
  --bg-glow-1: rgba(45, 212, 191, 0.13);
  --bg-glow-2: rgba(255, 122, 51, 0.12);
  --grid-line: rgba(236, 248, 243, 0.065);
  --surface: #1c2824;
  --surface-elevated: #23322d;
  --surface-alt: #253630;
  --fg: #f8f6ef;
  --muted: #b9cdc3;
  --border: #3d594f;
  --border-bright: rgba(248, 246, 239, 0.24);
  --border-soft: rgba(248, 246, 239, 0.22);
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.34), 3px 3px 0 #090e0c;
  --shadow-sm: 2px 2px 0 #090e0c;
  --accent: #ff7a33;
  --accent-2: #2dd4bf;
  --accent-3: #fbbf24;
  --fault: #f87171;
  --ok: #34d399;
  --code-bg: #0f1614;
  --code-fg: #eef5f1;
  --radius: 15px;
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Optional Warm Drafting-Paper Light Theme */
[data-theme="light"] {
  --bg: #f8f4ea;
  --bg-glow-1: rgba(13, 148, 136, 0.08);
  --bg-glow-2: rgba(234, 88, 12, 0.08);
  --grid-line: rgba(21, 35, 29, 0.065);
  --surface: #fffdf8;
  --surface-elevated: #ffffff;
  --surface-alt: #efe8d8;
  --fg: #14221c;
  --muted: #4b5e55;
  --border: #1b2e26;
  --border-bright: rgba(20, 34, 28, 0.25);
  --border-soft: rgba(20, 34, 28, 0.22);
  --shadow: 4px 4px 0 #1b2e26;
  --shadow-sm: 2px 2px 0 #1b2e26;
  --accent: #ea580c;
  --accent-2: #0d9488;
  --accent-3: #f59e0b;
  --fault: #dc2626;
  --ok: #059669;
  --code-bg: #141e1a;
  --code-fg: #edf4f0;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--fg);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 18% 8%, var(--bg-glow-1), transparent 42%),
    radial-gradient(circle at 84% 14%, var(--bg-glow-2), transparent 40%),
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 28px 28px, 28px 28px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: #fff; }
a { color: inherit; text-decoration: none; }

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 22px;
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.accent2 { color: var(--accent-2); }

.stamp {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--border);
}

.header-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: -0.03em;
}

.brand-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  color: var(--fg);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  transition: color 120ms ease;
}

.nav-links a:hover { color: var(--accent); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tactile Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1.8px solid var(--border);
  background: var(--surface-elevated);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 90ms ease, box-shadow 90ms ease, border-color 120ms ease;
}

.btn:hover {
  transform: translate(-1px, -1px);
  border-color: var(--accent);
}
.btn:active { transform: translate(2px, 2px); box-shadow: none; }

.btn-accent {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

[data-theme="light"] .btn-accent { color: #fff; }

.btn-icon {
  padding: 8px 11px;
  font-size: 13px;
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1.8px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.section {
  padding: 50px 0;
  position: relative;
}

/* Hero */
.hero-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.hero-title {
  margin: 10px 0 10px;
  font-size: clamp(2.5rem, 5.2vw, 4.2rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.hero-sub {
  margin: 0;
  font-size: 1.08rem;
  color: var(--muted);
  max-width: 600px;
}

.origin-sticker {
  max-width: 395px;
  padding: 14px 16px;
  border-radius: 13px;
  border: 1.8px solid var(--border);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px;
  line-height: 1.5;
  transform: rotate(-0.5deg);
}

/* Playable Arena */
.arena-toolbar {
  padding: 12px 16px;
  border-bottom: 1.8px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toy-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.chip-btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 90ms ease, border-color 120ms ease;
}

.chip-btn:hover { transform: translateY(-1px); border-color: var(--accent-2); }
.chip-btn.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip-btn.active-fault { background: var(--fault); color: #fff; border-color: var(--fault); }
.chip-btn.chaos {
  background: color-mix(in srgb, var(--accent-3) 20%, var(--surface));
  border-color: color-mix(in srgb, var(--accent-3) 65%, var(--border));
}

.arena-canvas {
  display: block;
  width: 100%;
  height: 430px;
  cursor: grab;
  touch-action: none;
}

.arena-canvas:active { cursor: grabbing; }

.vla-strip {
  padding: 12px 16px;
  border-top: 1.8px solid var(--border);
  background: var(--surface-elevated);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.vla-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.vla-pill {
  border: 1.5px dashed var(--border-bright);
  background: var(--surface-alt);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 90ms ease;
}

.vla-pill:hover {
  border-color: var(--accent);
  background: var(--surface);
  transform: translateY(-1px);
}

.arena-hud {
  padding: 11px 16px;
  border-top: 1.8px solid var(--border);
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.hud-ok { color: #34d399; font-weight: 700; }
.hud-warn { color: #fbbf24; font-weight: 700; }
.hud-err { color: #f87171; font-weight: 700; }

/* Critter Runway Rails (between sections) */
.critter-rail {
  position: relative;
  height: 62px;
  width: 100%;
  overflow: visible;
  pointer-events: none;
  border-bottom: 1.5px dashed var(--border-soft);
  margin-bottom: -14px;
}

.rail-hint {
  position: absolute;
  right: 22px;
  bottom: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  opacity: 0.72;
  pointer-events: none;
}

/* Roaming Critter Sprites */
.critter-actor {
  position: absolute;
  bottom: -2px;
  left: 0;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  will-change: transform;
  z-index: 25;
}

.critter-sprite {
  display: block;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.35));
  transition: filter 120ms ease;
}

.critter-actor:hover .critter-sprite {
  filter: drop-shadow(0 0 10px rgba(255, 122, 51, 0.65));
}

.critter-bubble {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) scale(0.85);
  background: var(--fg);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.critter-bubble.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.rail-treat {
  position: absolute;
  bottom: 4px;
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
  animation: treatBob 1.1s ease-in-out infinite alternate;
}

@keyframes treatBob {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

/* Stress Toy + Scope */
.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.section-head h2 {
  margin: 6px 0 0;
  font-size: clamp(1.7rem, 3.2vw, 2.35rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.06;
}

.lab-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 22px;
}

.sabotage-pad {
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.arcade-btn {
  text-align: left;
  padding: 15px;
  border-radius: 12px;
  border: 1.8px solid var(--border);
  background: var(--surface-alt);
  color: var(--fg);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 90ms ease, box-shadow 90ms ease, background 120ms ease, border-color 120ms ease;
}

.arcade-btn:hover { transform: translate(-1px, -1px); background: var(--surface-elevated); border-color: var(--accent-2); }
.arcade-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.arcade-btn.selected {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.arcade-btn.selected .muted { color: color-mix(in srgb, var(--bg) 74%, transparent); }

.arcade-btn strong { font-size: 14px; }
.arcade-btn span { font-size: 12px; }

.battle-screen {
  display: flex;
  flex-direction: column;
}

.scope-canvas {
  display: block;
  width: 100%;
  height: 160px;
  background: var(--code-bg);
  border-bottom: 1.8px solid var(--border);
}

.battle-compare {
  padding: 18px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  flex: 1;
}

.vs-box {
  padding: 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vs-box.good { border-color: var(--accent-2); }
.vs-box.bad { border-color: var(--fault); }

/* 3-Layer Toybox */
.rack-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.rack-card {
  background: var(--surface);
  border: 1.8px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.rack-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.rack-badge {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  font-weight: 700;
}

.rack-card h3 {
  margin: 6px 0 6px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.rack-quip {
  padding: 11px 13px;
  border-radius: 9px;
  background: var(--surface-alt);
  border: 1.5px dashed var(--border-soft);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.rack-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.spec-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--fg);
  color: var(--bg);
}

/* Open Source + Terminal Ping */
.bottom-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 22px;
}

.terminal-pre {
  margin: 0;
  padding: 18px;
  background: var(--code-bg);
  color: var(--code-fg);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
}

.ping-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ping-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ping-form input,
.ping-form select {
  width: 100%;
  padding: 11px 13px;
  border-radius: 9px;
  border: 1.8px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
}

.ping-form input:focus,
.ping-form select:focus {
  outline: none;
  border-color: var(--accent);
}

.feedback-ok {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ok);
  font-weight: 700;
  display: none;
}

.feedback-ok.visible { display: block; }

/* Footer */
.site-footer {
  border-top: 2px solid var(--border);
  padding: 26px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 900px) {
  .lab-grid,
  .rack-grid,
  .bottom-grid,
  .battle-compare {
    grid-template-columns: 1fr;
  }
  .sabotage-pad { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .origin-sticker { transform: none; }
  .arena-canvas { height: 350px; }
}
