/* ============================================================
   style.css — Botanical Field Journal theme v3
   Hyperplane Hero · ZeroToML
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400&family=Lora:ital,wght@0,400;0,600;1,400&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ──────────────────────────────────────────────────────────
   VARIABLES
────────────────────────────────────────────────────────── */
:root {
  --cream: #f9f6ef;
  --parchment: #ede8da;
  --parchment-d: #e0d8c8;
  --sage-lt: #d4e4c8;
  --sage: #7faa65;
  --forest: #3a6b35;
  --canopy: #264d21;
  --amber: #c07a2a;
  --amber-lt: #e8c87a;
  --earth: #7a5a38;
  --bark: #3d2a1a;
  --river: #2a6b8c;
  --plum: #7c4fa0;
  --text-dark: #2a1f14;
  --text-body: #4a3c2c;
  --text-muted: #7a6e5e;
  --shadow-sm: 0 1px 4px rgba(60, 40, 20, 0.10);
  --shadow-md: 0 4px 16px rgba(60, 40, 20, 0.12);
  --shadow-lg: 0 8px 32px rgba(60, 40, 20, 0.16);
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Lora', Georgia, serif;
  --font-ui: 'DM Sans', system-ui, sans-serif;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background: var(--cream);
  color: var(--text-dark);
  font-family: var(--font-body);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ──────────────────────────────────────────────────────────
   SHARED BUTTONS
────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--forest);
  color: var(--cream);
  box-shadow: 0 2px 8px rgba(58, 107, 53, 0.3);
}

.btn-primary:hover {
  background: var(--canopy);
  box-shadow: 0 4px 14px rgba(58, 107, 53, 0.4);
  transform: translateY(-1px);
}

.btn-amber {
  background: var(--amber);
  color: var(--cream);
  box-shadow: 0 2px 8px rgba(192, 122, 42, 0.3);
}

.btn-amber:hover {
  background: #a86820;
  box-shadow: 0 4px 14px rgba(192, 122, 42, 0.4);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--earth);
  border: 1.5px solid var(--parchment-d);
}

.btn-outline:hover {
  background: var(--parchment);
  border-color: var(--earth);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--parchment-d);
  padding: 8px 16px;
}

.btn-ghost:hover {
  background: var(--parchment);
  color: var(--text-body);
}

.btn-ghost:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ──────────────────────────────────────────────────────────
   INTRO SECTION
────────────────────────────────────────────────────────── */
#intro-section {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  background: linear-gradient(160deg, #f4f0e2 0%, #ebe4ce 50%, #e0d9c2 100%);
  display: flex;
  flex-direction: column;
}

.intro-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  border-bottom: 1px solid rgba(122, 90, 56, 0.12);
  flex-shrink: 0;
}

.intro-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: var(--forest);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(58, 107, 53, 0.3);
}

.logo-text h1 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--canopy);
  line-height: 1.1;
}

.logo-text p {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

.intro-nav-links a {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--earth);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--parchment-d);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.intro-nav-links a:hover {
  background: var(--parchment);
  color: var(--canopy);
}

.intro-nav-links a.zerotoml {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}

.intro-nav-links a.zerotoml:hover {
  background: var(--canopy);
}

/* Slides */
.intro-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.intro-slides-wrap {
  flex: 1;
  position: relative;
}

.intro-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 40px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(40px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.intro-slide.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.intro-slide.exiting {
  opacity: 0;
  transform: translateX(-40px);
}

/* Slide layout helpers */
.slide-single {
  max-width: 680px;
  width: 100%;
  text-align: center;
}

.slide-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  max-width: 920px;
  width: 100%;
  align-items: center;
}

.slide-4col {
  max-width: 890px;
  width: 100%;
}

/* Slide typography */
.slide-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--forest);
  margin-bottom: 12px;
  display: block;
}

.slide-heading {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  font-weight: 900;
  color: var(--text-dark);
  line-height: 1.15;
  margin-bottom: 16px;
}

.slide-heading em {
  font-style: italic;
  color: var(--forest);
}

.slide-body {
  font-size: 1rem;
  color: var(--text-body);
  line-height: 1.75;
  margin-bottom: 20px;
}

.concept-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.concept-tag {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--parchment-d);
  color: var(--earth);
  border: 1px solid rgba(122, 90, 56, 0.2);
}

.concept-tag.green {
  background: rgba(90, 158, 63, 0.15);
  color: var(--forest);
  border-color: rgba(90, 158, 63, 0.3);
}

.concept-tag.amber {
  background: rgba(192, 122, 42, 0.15);
  color: var(--amber);
  border-color: rgba(192, 122, 42, 0.3);
}

/* Kernel grid (slide 3) */
.kernel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.k-card {
  background: var(--parchment);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--parchment-d);
  padding: 12px 14px;
}

.k-card-name {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.k-card-name.linear {
  color: var(--forest);
}

.k-card-name.poly {
  color: var(--earth);
}

.k-card-name.rbf {
  color: var(--river);
}

.k-card-name.sigmoid {
  color: var(--plum);
}

.k-card-formula {
  font-family: 'Courier New', monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.k-card-desc {
  font-size: 0.74rem;
  color: var(--text-body);
  line-height: 1.55;
}

/* How-to grid */
.how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.how-card {
  background: var(--parchment);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  border: 1px solid var(--parchment-d);
  box-shadow: var(--shadow-sm);
  text-align: left;
}

.how-card .how-icon {
  font-size: 1.7rem;
  margin-bottom: 8px;
  display: block;
}

.how-card h4 {
  font-family: var(--font-ui);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--forest);
  margin-bottom: 5px;
}

.how-card p {
  font-size: 0.8rem;
  color: var(--text-body);
  line-height: 1.6;
}

/* Intro bottom nav */
.intro-bottom {
  padding: 18px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-shrink: 0;
  border-top: 1px solid rgba(122, 90, 56, 0.10);
}

#intro-dots {
  display: flex;
  gap: 10px;
}

.intro-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--parchment-d);
  border: none;
  cursor: pointer;
  transition: all 0.25s;
}

.intro-dot.active {
  background: var(--forest);
  transform: scale(1.3);
}

/* ──────────────────────────────────────────────────────────
   ANIMATED DIAGRAMS
────────────────────────────────────────────────────────── */
/* SVM Diagram */
#svm-diagram {
  width: 100%;
  max-width: 420px;
  background: var(--parchment);
  border-radius: var(--radius-lg);
  border: 1px solid var(--parchment-d);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

#svm-diagram svg,
#kernel-diagram svg {
  width: 100%;
  height: auto;
  display: block;
}

#svm-diagram .dot-g0,
#svm-diagram .dot-g1 {
  opacity: 0;
  transform-origin: center;
  transform: scale(0);
}

#svm-diagram.animated .dot-g0:nth-child(1) {
  animation: popDot 0.4s 0.2s ease-out forwards;
}

#svm-diagram.animated .dot-g0:nth-child(2) {
  animation: popDot 0.4s 0.35s ease-out forwards;
}

#svm-diagram.animated .dot-g0:nth-child(3) {
  animation: popDot 0.4s 0.5s ease-out forwards;
}

#svm-diagram.animated .dot-g0:nth-child(4) {
  animation: popDot 0.4s 0.65s ease-out forwards;
}

#svm-diagram.animated .dot-g0:nth-child(5) {
  animation: popDot 0.4s 0.8s ease-out forwards;
}

#svm-diagram.animated .dot-g1:nth-child(6) {
  animation: popDot 0.4s 1.0s ease-out forwards;
}

#svm-diagram.animated .dot-g1:nth-child(7) {
  animation: popDot 0.4s 1.15s ease-out forwards;
}

#svm-diagram.animated .dot-g1:nth-child(8) {
  animation: popDot 0.4s 1.3s ease-out forwards;
}

#svm-diagram.animated .dot-g1:nth-child(9) {
  animation: popDot 0.4s 1.45s ease-out forwards;
}

#svm-diagram.animated .dot-g1:nth-child(10) {
  animation: popDot 0.4s 1.6s ease-out forwards;
}

#svm-diagram .hp-line {
  stroke: var(--bark);
  stroke-width: 2.5;
  fill: none;
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
  opacity: 0;
}

#svm-diagram .margin-l,
#svm-diagram .margin-r {
  stroke: var(--sage);
  stroke-width: 1.5;
  fill: none;
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
  opacity: 0;
}

#svm-diagram .margin-fill {
  opacity: 0;
  fill: rgba(127, 170, 101, 0.12);
}

#svm-diagram .sv-ring {
  fill: none;
  opacity: 0;
  stroke-width: 1.5;
}

#svm-diagram .diag-label {
  font-family: var(--font-ui);
  font-size: 9px;
  opacity: 0;
}

#svm-diagram.animated .hp-line {
  animation: drawLine 0.8s 2.0s ease-out forwards;
}

#svm-diagram.animated .margin-l {
  animation: drawLine 0.6s 2.7s ease-out forwards;
}

#svm-diagram.animated .margin-r {
  animation: drawLine 0.6s 2.9s ease-out forwards;
}

#svm-diagram.animated .margin-fill {
  animation: fadeIn 0.5s 3.2s ease-out forwards;
}

#svm-diagram.animated .sv-ring {
  animation: pulseRing 0.8s 3.5s ease-out forwards;
}

#svm-diagram.animated .label-hp {
  animation: fadeIn 0.4s 3.0s ease-out forwards;
}

#svm-diagram.animated .label-margin {
  animation: fadeIn 0.4s 3.3s ease-out forwards;
}

#svm-diagram.animated .label-sv {
  animation: fadeIn 0.4s 3.6s ease-out forwards;
}

/* Kernel diagram */
#kernel-diagram {
  width: 100%;
  max-width: 420px;
  background: var(--parchment);
  border-radius: var(--radius-lg);
  border: 1px solid var(--parchment-d);
  box-shadow: var(--shadow-md);
  padding: 18px;
}

#kernel-diagram .kd-dot {
  opacity: 0;
}

#kernel-diagram.animated .kd-g0 {
  animation: popDot 0.35s ease-out forwards;
}

#kernel-diagram.animated .kd-g1 {
  animation: popDot 0.35s ease-out forwards;
}

#kernel-diagram .k-arrow {
  opacity: 0;
}

#kernel-diagram.animated .k-arrow {
  animation: fadeIn 0.4s 1.4s ease-out forwards;
}

#kernel-diagram .kd-after {
  opacity: 0;
}

#kernel-diagram.animated .kd-after {
  animation: fadeIn 0.5s 2.0s ease-out forwards;
}

#kernel-diagram .k-line {
  stroke: var(--bark);
  stroke-width: 2;
  opacity: 0;
  stroke-dasharray: 200;
  stroke-dashoffset: 200;
}

#kernel-diagram.animated .k-line {
  animation: drawLine 0.6s 2.6s ease-out forwards;
}

#kernel-diagram.animated .kd-g0:nth-child(1) {
  animation-delay: 0.2s !important
}

#kernel-diagram.animated .kd-g0:nth-child(2) {
  animation-delay: 0.35s !important
}

#kernel-diagram.animated .kd-g0:nth-child(3) {
  animation-delay: 0.5s !important
}

#kernel-diagram.animated .kd-g0:nth-child(4) {
  animation-delay: 0.65s !important
}

#kernel-diagram.animated .kd-g1:nth-child(5) {
  animation-delay: 0.8s !important
}

#kernel-diagram.animated .kd-g1:nth-child(6) {
  animation-delay: 0.95s !important
}

#kernel-diagram.animated .kd-g1:nth-child(7) {
  animation-delay: 1.1s !important
}

#kernel-diagram.animated .kd-g1:nth-child(8) {
  animation-delay: 1.25s !important
}

/* ──────────────────────────────────────────────────────────
   KEYFRAMES
────────────────────────────────────────────────────────── */
@keyframes popDot {
  0% {
    opacity: 0;
    transform: scale(0)
  }

  70% {
    transform: scale(1.2)
  }

  100% {
    opacity: 1;
    transform: scale(1)
  }
}

@keyframes drawLine {
  0% {
    stroke-dashoffset: 320;
    opacity: 0.4
  }

  100% {
    stroke-dashoffset: 0;
    opacity: 1
  }
}

@keyframes fadeIn {
  0% {
    opacity: 0
  }

  100% {
    opacity: 1
  }
}

@keyframes pulseRing {
  0% {
    opacity: 0;
    r: 14
  }

  60% {
    opacity: 0.8;
    r: 17
  }

  100% {
    opacity: 0.6;
    r: 15
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0)
  }

  20% {
    transform: translateX(-6px)
  }

  40% {
    transform: translateX(6px)
  }

  60% {
    transform: translateX(-4px)
  }

  80% {
    transform: translateX(4px)
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(14px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

@keyframes hintPulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(192, 122, 42, 0.4)
  }

  50% {
    box-shadow: 0 0 0 8px rgba(192, 122, 42, 0)
  }
}

/* ──────────────────────────────────────────────────────────
   GAME SECTION
────────────────────────────────────────────────────────── */
#game-section {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  background: var(--cream);
  display: flex;
  flex-direction: column;
}

#game-section.hidden,
#intro-section.hidden {
  display: none;
}

/* Game header */
.game-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 22px;
  background: white;
  border-bottom: 1px solid var(--parchment-d);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.game-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 6px;
}

.game-logo .logo-icon {
  width: 32px;
  height: 32px;
  font-size: 15px;
}

.game-logo h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--canopy);
}

.header-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--parchment);
  border: 1px solid var(--parchment-d);
  border-radius: var(--radius-sm);
}

.stat-label {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-val {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-dark);
}

#lives-val {
  color: var(--amber);
  letter-spacing: 2px;
}

.header-spacer {
  flex: 1;
}

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

.header-links a {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--earth);
  text-decoration: none;
  padding: 5px 12px;
  border: 1.5px solid var(--parchment-d);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-links a:hover {
  background: var(--parchment);
  color: var(--canopy);
}

.header-links a.ztm {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
}

.header-links a.ztm:hover {
  background: var(--canopy);
}

/* ──────────────────────────────────────────────────────────
   LANDSCAPE LAYOUT
────────────────────────────────────────────────────────── */
.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 355px;
  min-height: 0;
}

/* Canvas column */
.canvas-column {
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 10px;
  border-right: 1px solid var(--parchment-d);
  min-height: 0;
}

#canvas-wrapper {
  flex: 1;
  min-height: 280px;
  max-height: 510px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1.5px solid var(--parchment-d);
  box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  position: relative;
  cursor: grab;
  background: var(--cream);
}

#canvas-wrapper:active {
  cursor: grabbing;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Controls bar */
.canvas-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--parchment);
  border-radius: var(--radius-md);
  border: 1px solid var(--parchment-d);
}

.ctrl-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-label {
  font-family: var(--font-ui);
  font-size: 0.69rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Kernel buttons ── */
.kernel-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.kernel-btn {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--parchment-d);
  background: white;
  color: var(--text-body);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
}

.kernel-btn:hover:not(:disabled) {
  background: var(--parchment);
  border-color: var(--earth);
}

/* Per-kernel active colours */
.kernel-btn[data-kernel="linear"].active {
  background: var(--forest);
  color: var(--cream);
  border-color: var(--forest);
  box-shadow: 0 2px 6px rgba(58, 107, 53, 0.35);
}

.kernel-btn[data-kernel="poly"].active {
  background: var(--earth);
  color: var(--cream);
  border-color: var(--earth);
  box-shadow: 0 2px 6px rgba(122, 90, 56, 0.35);
}

.kernel-btn[data-kernel="rbf"].active {
  background: var(--river);
  color: var(--cream);
  border-color: var(--river);
  box-shadow: 0 2px 6px rgba(42, 107, 140, 0.35);
}

.kernel-btn[data-kernel="sigmoid"].active {
  background: var(--plum);
  color: var(--cream);
  border-color: var(--plum);
  box-shadow: 0 2px 6px rgba(124, 79, 160, 0.35);
}

.kernel-btn.hint-pulse {
  animation: hintPulse 0.7s 3 ease-in-out;
}

/* Sliders */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-row input[type=range] {
  accent-color: var(--forest);
  cursor: pointer;
  width: 110px;
  height: 4px;
}

.slider-val {
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--earth);
  min-width: 34px;
}

/* Action buttons */
.action-group {
  display: flex;
  gap: 7px;
  margin-left: auto;
}

.act-btn {
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.act-btn-check {
  background: var(--forest);
  color: var(--cream);
  box-shadow: 0 2px 6px rgba(58, 107, 53, 0.3);
}

.act-btn-check:hover {
  background: var(--canopy);
  transform: translateY(-1px);
}

.act-btn-next {
  background: var(--amber);
  color: var(--cream);
  box-shadow: 0 2px 6px rgba(192, 122, 42, 0.3);
}

.act-btn-next:hover {
  background: #a86820;
  transform: translateY(-1px);
}

.act-btn-reset {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--parchment-d);
}

.act-btn-reset:hover {
  background: var(--parchment);
  color: var(--earth);
}

.hidden {
  display: none !important;
}

/* ──────────────────────────────────────────────────────────
   THEORY SIDEBAR
────────────────────────────────────────────────────────── */
.theory-column {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: calc(100vh - 54px);
  background: white;
  scrollbar-width: thin;
  scrollbar-color: var(--parchment-d) transparent;
}

.level-card {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--parchment);
  animation: slideUp 0.4s ease-out;
}

.level-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.level-badge {
  font-family: var(--font-ui);
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--sage-lt);
  color: var(--forest);
  padding: 3px 10px;
  border-radius: 20px;
}

.level-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.2;
  margin-bottom: 2px;
}

.level-sub {
  font-family: var(--font-ui);
  font-size: 0.73rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 9px;
}

.level-gameplay {
  font-size: 0.83rem;
  color: var(--text-body);
  line-height: 1.7;
  margin-bottom: 12px;
}

.level-gameplay strong {
  color: var(--canopy);
}

.level-gameplay em {
  color: var(--earth);
  font-style: italic;
}

/* Margin bar */
.margin-quality {
  margin-bottom: 10px;
}

.mq-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.mq-label {
  font-family: var(--font-ui);
  font-size: 0.69rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#margin-pct {
  font-family: var(--font-ui);
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--forest);
}

.margin-bar-track {
  height: 5px;
  border-radius: 3px;
  background: var(--parchment);
  overflow: hidden;
  border: 1px solid var(--parchment-d);
}

#margin-bar-fill {
  height: 100%;
  background: var(--forest);
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease, background 0.3s ease;
}

/* Stars */
.stars-row {
  display: flex;
  gap: 3px;
  margin-top: 3px;
}

.star {
  font-size: 1.35rem;
  transition: all 0.2s;
}

.star.filled {
  color: var(--amber);
  text-shadow: 0 0 8px rgba(192, 122, 42, 0.4);
}

.star.empty {
  color: var(--parchment-d);
}

/* Field Journal */
.field-journal {
  padding: 14px 18px;
  border-bottom: 1px solid var(--parchment);
  animation: slideUp 0.5s 0.1s ease-out both;
}

.journal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.journal-header-title {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.journal-divider {
  flex: 1;
  height: 1px;
  background: var(--parchment-d);
}

.concept-section {
  margin-bottom: 12px;
}

.concept-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.concept-icon-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--sage-lt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.concept-title-text {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--canopy);
}

.concept-body {
  font-size: 0.81rem;
  color: var(--text-body);
  line-height: 1.75;
}

.concept-body strong {
  color: var(--canopy);
}

.concept-body em {
  font-style: italic;
  color: var(--earth);
}

.concept-body code {
  font-family: 'Courier New', monospace;
  font-size: 0.77rem;
  background: var(--parchment);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--earth);
}

.concept-body ul {
  padding-left: 14px;
  margin-top: 5px;
}

.concept-body li {
  margin-bottom: 3px;
  font-size: 0.81rem;
}

.formula-block {
  background: var(--parchment);
  border-left: 3px solid var(--sage);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 9px 13px;
  margin: 10px 0;
}

.formula-main {
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--canopy);
  display: block;
  margin-bottom: 3px;
}

.formula-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

.fun-fact {
  background: rgba(192, 122, 42, 0.07);
  border: 1px solid rgba(192, 122, 42, 0.2);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin-top: 10px;
  font-size: 0.79rem;
  color: var(--earth);
  line-height: 1.65;
}

.fun-fact strong {
  color: var(--canopy);
}

/* Level dots */
.level-dots-section {
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ld-label {
  font-family: var(--font-ui);
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#level-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lvl-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid;
  transition: all 0.3s;
  cursor: default;
}

.lvl-dot.done {
  background: var(--sage);
  border-color: var(--forest);
}

.lvl-dot.current {
  background: var(--amber);
  border-color: var(--amber);
  transform: scale(1.35);
}

.lvl-dot.todo {
  background: transparent;
  border-color: var(--parchment-d);
}

.theory-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--parchment);
  margin-top: auto;
}

.theory-footer a {
  display: block;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.77rem;
  font-weight: 500;
  color: var(--forest);
  text-decoration: none;
  padding: 7px;
  border: 1.5px solid var(--sage-lt);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  background: var(--parchment);
}

.theory-footer a:hover {
  background: var(--sage-lt);
}

/* ──────────────────────────────────────────────────────────
   MODALS
────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(40, 30, 16, 0.55);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 490px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--parchment-d);
  overflow: hidden;
}

.modal-header {
  padding: 22px 26px 14px;
  border-bottom: 1px solid var(--parchment);
  text-align: center;
}

.modal-icon {
  font-size: 2.7rem;
  margin-bottom: 7px;
  display: block;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 3px;
}

.modal-pts {
  font-family: var(--font-ui);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--forest);
}

.modal-stars {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 9px;
}

.modal-body {
  padding: 16px 26px 22px;
}

.modal-learn-label {
  font-family: var(--font-ui);
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.modal-learn {
  font-size: 0.83rem;
  color: var(--text-body);
  line-height: 1.75;
  padding: 11px 13px;
  background: var(--parchment);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--sage);
  margin-bottom: 16px;
}

.modal-learn strong {
  color: var(--canopy);
}

.modal-learn em {
  font-style: italic;
}

.modal-btns {
  display: flex;
  gap: 9px;
  justify-content: center;
}

/* ──────────────────────────────────────────────────────────
   RESPONSIVE
────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .theory-column {
    height: auto;
    overflow-y: visible;
    border-top: 1px solid var(--parchment-d);
    border-right: none;
  }

  #canvas-wrapper {
    max-height: 360px;
  }
}

@media (max-width: 640px) {
  .intro-header {
    padding: 12px 16px;
  }

  .intro-nav-links {
    display: none;
  }

  .intro-slide {
    padding: 14px 16px;
  }

  .slide-split {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .intro-bottom {
    padding: 12px 16px;
  }

  .game-header {
    padding: 7px 12px;
    gap: 7px;
  }

  .canvas-column {
    padding: 8px;
    gap: 7px;
  }

  .canvas-controls {
    padding: 7px 9px;
    gap: 7px;
  }

  .action-group {
    margin-left: 0;
  }

  .kernel-btn {
    padding: 5px 9px;
    font-size: 0.68rem;
  }

  .how-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kernel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {
  .how-grid {
    grid-template-columns: 1fr;
  }

  .slide-heading {
    font-size: 1.65rem;
  }
}