@font-face {
  font-family: 'Atkinson Hyperlegible Next';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('./Atkinson.abde1ad5cf78.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('./Plex.81fc864103e7.woff2') format('woff2');
}

:root {
  --font-sans: 'Atkinson Hyperlegible Next', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Dark Theme (Default) */
  --bg-page: #0a0e17;
  --bg-surface: #111827;
  --bg-surface-raised: #1e293b;
  --bg-surface-card: #151e2e;
  --border-subtle: #1e293b;
  --border-strong: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-brass: #eab308;
  --accent-brass-hover: #ca8a04;
  --accent-brass-bg: rgba(234, 179, 8, 0.15);
  --accent-laser: #f43f5e;
  --accent-laser-bg: rgba(244, 63, 94, 0.18);
  --accent-cyan: #38bdf8;
  --accent-green: #22c55e;
  --accent-green-bg: rgba(34, 197, 94, 0.15);

  --ruler-body-grad: linear-gradient(90deg, #713f12 0%, #9a580a 35%, #854d0e 75%, #593108 100%);
  --ruler-grain: rgba(0, 0, 0, 0.18);
  --ruler-mark: #fef08a;
  --ruler-text: #fef9c3;
  --caliper-body: #334155;
  --caliper-jaw: #475569;
  --caliper-bevel: #64748b;
  --pin-badge: #fbbf24;
  --pin-text: #1e1b4b;

  --shadow-stage: 0 20px 40px -15px rgba(0, 0, 0, 0.7);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-raised: #f1f5f9;
  --bg-surface-card: #f8fafc;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-primary: #090d16;
  --text-secondary: #1e293b;
  --text-muted: #475569;

  --accent-brass: #b45309;
  --accent-brass-hover: #92400e;
  --accent-brass-bg: rgba(180, 83, 9, 0.12);
  --accent-laser: #e11d48;
  --accent-laser-bg: rgba(225, 29, 72, 0.12);
  --accent-cyan: #0284c7;
  --accent-green: #15803d;
  --accent-green-bg: rgba(21, 128, 61, 0.12);

  --ruler-body-grad: linear-gradient(90deg, #c49261 0%, #e8ba84 35%, #d4a373 75%, #b88251 100%);
  --ruler-grain: rgba(255, 255, 255, 0.15);
  --ruler-mark: #1c1917;
  --ruler-text: #0c0a09;
  --caliper-body: #334155;
  --caliper-jaw: #475569;
  --caliper-bevel: #64748b;
  --pin-badge: #92400e;
  --pin-text: #ffffff;

  --shadow-stage: 0 16px 32px -12px rgba(15, 23, 42, 0.12);
  --shadow-card: 0 8px 20px -4px rgba(15, 23, 42, 0.08);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Container */
.container {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header & Navigation */
.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: var(--accent-brass-bg);
  color: var(--accent-brass);
  border: 1px solid var(--border-strong);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-surface-raised);
  color: var(--text-primary);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.nav-btn:hover {
  border-color: var(--accent-brass);
  background-color: var(--bg-surface);
}

.nav-btn:focus-visible {
  outline: 2px solid var(--accent-brass);
  outline-offset: 2px;
}

/* Main Hero */
.hero {
  padding: 36px 0 24px;
}

.hero-header {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 28px;
}

.hero-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-brass);
  background-color: var(--accent-brass-bg);
  border: 1px solid var(--border-strong);
  padding: 4px 12px;
  border-radius: 9999px;
  margin-bottom: 14px;
}

h1.hero-title {
  font-size: clamp(1.75rem, 4.5vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.hero-lede {
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Stage & Metrology Instrument */
.stage-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: var(--shadow-stage);
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

/* Stage Telemetry Header */
.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.round-counter {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 9999px;
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-brass);
  animation: pulse-dot 2s infinite ease-in-out;
}

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

/* The Metrology Chamber */
.chamber {
  position: relative;
  height: 380px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  background: radial-gradient(circle at center 75%, var(--bg-surface-raised) 0%, var(--bg-surface) 80%);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

/* Background Reference Scale Grid */
.chamber-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(var(--border-subtle) 1px, transparent 1px);
  background-size: 100% 20px;
  opacity: 0.5;
  pointer-events: none;
}

/* The Caliper Assembly */
.caliper-assembly {
  position: absolute;
  top: 270px;
  left: 0;
  width: 100%;
  height: 48px;
  pointer-events: none;
  z-index: 20;
}

/* Laser Catch Line */
.caliper-laser {
  position: absolute;
  top: 24px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--accent-laser);
  box-shadow: 0 0 8px var(--accent-laser);
  opacity: 0.85;
}

.laser-label {
  position: absolute;
  right: 12px;
  top: -18px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent-laser);
  background-color: var(--bg-surface);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--accent-laser);
}

/* Caliper Jaws */
.caliper-jaw {
  position: absolute;
  top: 8px;
  width: 140px;
  height: 32px;
  background-color: var(--caliper-jaw);
  border: 1px solid var(--border-strong);
  transition: transform 0.08s cubic-bezier(0.16, 1, 0.3, 1);
}

.caliper-jaw.left {
  left: 0;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  border-left: none;
  transform: translateX(-15px);
  background: linear-gradient(180deg, var(--caliper-bevel) 0%, var(--caliper-body) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.caliper-jaw.right {
  right: 0;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  border-right: none;
  transform: translateX(15px);
  background: linear-gradient(180deg, var(--caliper-bevel) 0%, var(--caliper-body) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Clamped state for calipers */
.chamber[data-clamped="true"] .caliper-jaw.left {
  transform: translateX(38px);
}

.chamber[data-clamped="true"] .caliper-jaw.right {
  transform: translateX(-38px);
}

/* The Hanging Ruler */
.ruler-track {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 72px;
  left: 50%;
  margin-left: -36px;
  z-index: 10;
}

.ruler {
  position: absolute;
  width: 72px;
  height: 600px;
  top: -300px; /* Zero mark aligns with laser at 270px (600 - 300 = 300, -30px = 270px) */
  left: 0;
  background: var(--ruler-body-grad);
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  transform: translateY(0);
  will-change: transform;
}

/* Ruler SVG scale overlay */
.ruler-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Pins placed on ruler for attempts */
.ruler-pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ruler-pin {
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--pin-badge);
  color: var(--pin-text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  border: 1.5px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  z-index: 15;
}

/* Active / Action Zone */
.action-zone {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.trigger-btn {
  width: 100%;
  max-width: 440px;
  min-height: 64px;
  padding: 16px 24px;
  font-family: var(--font-sans);
  font-size: 1.15rem;
  font-weight: 700;
  border-radius: 12px;
  border: 2px solid var(--accent-brass);
  background-color: var(--accent-brass);
  color: #1c1917;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 6px 16px -4px var(--accent-brass-bg);
  transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.trigger-btn:hover {
  background-color: var(--accent-brass-hover);
  border-color: var(--accent-brass-hover);
}

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

.trigger-btn:focus-visible {
  outline: 3px solid var(--accent-cyan);
  outline-offset: 3px;
}

/* Button armed and falling states */
body[data-game-state="armed"] .trigger-btn {
  background-color: var(--bg-surface-raised);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

body[data-game-state="falling"] .trigger-btn {
  background-color: var(--accent-laser);
  border-color: var(--accent-laser);
  color: #ffffff;
  animation: pulse-danger 0.4s infinite alternate;
}

@keyframes pulse-danger {
  from { box-shadow: 0 0 10px var(--accent-laser); }
  to { box-shadow: 0 0 25px var(--accent-laser); }
}

.trigger-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

/* Live Telemetry Display */
.telemetry-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

.telemetry-card {
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: center;
}

.telemetry-label {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.telemetry-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Five Attempt Scoreboard */
.scoreboard-section {
  margin-bottom: 36px;
}

.section-heading {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
}

.slot-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 6px;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  min-width: 0;
  overflow: hidden;
}

.slot-card.active {
  border-color: var(--accent-brass);
  background-color: var(--accent-brass-bg);
}

.slot-card.completed {
  border-color: var(--border-strong);
}

.slot-index {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.slot-dist {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.slot-time {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-secondary);
}

/* Complete Analysis Summary Card */
.summary-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow-card);
  margin-bottom: 40px;
  display: none;
}

.summary-container.visible {
  display: block;
}

.summary-header {
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 18px;
  margin-bottom: 24px;
}

.summary-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.summary-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}

.stat-box {
  background-color: var(--bg-surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Neurophysiology Anatomy */
.anatomy-box {
  background-color: var(--bg-surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 28px;
}

.anatomy-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pathway-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pathway-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.92rem;
}

.pathway-time {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent-brass);
  background-color: var(--accent-brass-bg);
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.pathway-desc {
  color: var(--text-secondary);
  line-height: 1.45;
}

.pathway-desc strong {
  color: var(--text-primary);
}

.summary-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}

.btn-action {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-primary {
  background-color: var(--accent-brass);
  color: #1c1917;
  border: 1px solid var(--accent-brass);
}

.btn-primary:hover {
  background-color: var(--accent-brass-hover);
}

.btn-secondary {
  background-color: var(--bg-surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  border-color: var(--accent-brass);
}

.share-status {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-green);
  margin-left: 8px;
}

/* Editorial & Method Sections */
.article-section {
  padding: 28px 0;
  border-top: 1px solid var(--border-subtle);
}

.article-prose {
  max-width: 680px;
  margin: 0 auto;
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.article-prose h2 {
  font-size: 1.45rem;
  color: var(--text-primary);
  margin: 28px 0 14px;
  letter-spacing: -0.015em;
}

.article-prose h2:first-child {
  margin-top: 0;
}

.article-prose p {
  margin-bottom: 16px;
}

.article-prose ul {
  margin-bottom: 20px;
  padding-left: 24px;
}

.article-prose li {
  margin-bottom: 8px;
}

.sources-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px 20px;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 24px;
}

.sources-box p {
  margin-bottom: 8px;
}

.sources-box p:last-child {
  margin-bottom: 0;
}

/* Site Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  padding: 24px 0;
  margin-top: auto;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* Responsive & Mobile Adjustments */
@media (max-width: 640px) {
  .header-inner {
    padding: 10px 0;
    gap: 8px;
  }

  .brand-link {
    font-size: 0.92rem;
    gap: 6px;
  }

  .brand-badge {
    font-size: 0.65rem;
    padding: 1px 6px;
  }

  .nav-btn {
    font-size: 0.78rem;
    padding: 4px 8px;
  }

  .nav-actions {
    gap: 6px;
  }

  .chamber {
    height: 330px;
    max-width: 100%;
  }

  .caliper-assembly {
    top: 230px;
  }

  .ruler {
    top: -340px;
  }

  .telemetry-strip {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .slots-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }

  .slot-card {
    padding: 6px 2px;
  }

  .slot-index {
    font-size: 0.62rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .slot-dist {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .slot-time {
    font-size: 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

.formula-val {
  font-size: 1.15rem;
  padding-top: 4px;
}

.noscript-warning {
  text-align: center;
  padding: 20px;
  background-color: var(--accent-laser-bg);
  color: var(--accent-laser);
  font-weight: 700;
  border-bottom: 1px solid var(--accent-laser);
}

.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 20px;
}

.error-main {
  max-width: 480px;
}

.error-eyebrow {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--accent-brass);
  margin-bottom: 8px;
}

.error-title {
  font-size: 1.8rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.error-desc {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
