:root {
  color-scheme: light;
  --deep: #183e34;
  --ink: #213c34;
  --muted: #69756e;
  --paper: rgba(255, 253, 244, 0.94);
  --line: rgba(34, 71, 58, 0.14);
  --cream: #eee9d7;
  --gold: #e7c96f;
  --shadow: 0 24px 65px rgba(35, 48, 37, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.24) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
    linear-gradient(145deg, #f1eddc, #dddcc6);
  background-size: 42px 42px, 42px 42px, auto;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

.experiment-glow {
  position: fixed;
  z-index: 0;
  width: 34rem;
  height: 34rem;
  border-radius: 50%;
  pointer-events: none;
}

.experiment-glow-one {
  top: -19rem;
  right: -10rem;
  background: radial-gradient(circle, rgba(69, 129, 96, 0.36), transparent 69%);
}

.experiment-glow-two {
  bottom: -21rem;
  left: -12rem;
  background: radial-gradient(circle, rgba(227, 190, 91, 0.38), transparent 69%);
}

.experiment-nav {
  position: relative;
  z-index: 2;
  display: flex;
  width: min(1460px, calc(100% - 48px));
  margin: 0 auto;
  padding: 25px 0 18px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(31, 65, 52, 0.16);
  color: #68756d;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.wordmark {
  color: var(--deep);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.back-link {
  color: #60736a;
  text-decoration: none;
}

.gallery-page,
.experiment-page {
  position: relative;
  z-index: 1;
  width: min(1460px, calc(100% - 48px));
  margin: 0 auto;
  padding: 40px 0 52px;
}

.gallery-header {
  max-width: 900px;
  margin-bottom: 38px;
}

.experiment-eyebrow {
  margin: 0 0 8px;
  color: #72844e;
  font-size: 0.69rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.gallery-header h1,
.experiment-header h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.98;
}

.gallery-header h1 {
  max-width: 1000px;
  font-size: clamp(2.6rem, 5.5vw, 5.7rem);
}

.gallery-header > p:last-child {
  max-width: 690px;
  margin: 22px 0 0;
  color: #657169;
  font-family: Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.5;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.mode-card {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.mode-art {
  position: relative;
  height: 260px;
  overflow: hidden;
}

.path-art {
  background: linear-gradient(145deg, #bca16b, #cbb77d);
}

.path-line {
  position: absolute;
  display: block;
  background: linear-gradient(90deg, #8ea954, #2d6c4a);
}

.path-one {
  bottom: 66px;
  left: 0;
  width: 55%;
  height: 18px;
}

.path-two {
  bottom: 66px;
  left: 50%;
  width: 18px;
  height: 120px;
}

.path-three {
  top: 56px;
  left: 50%;
  width: 32%;
  height: 18px;
}

.path-head {
  position: absolute;
  top: 46px;
  left: 80%;
  width: 38px;
  height: 38px;
  border: 3px solid #fff7bf;
  border-radius: 50%;
  background: radial-gradient(circle, #f7e886, #7eaa50 45%, transparent 70%);
}

.circles-art {
  background: linear-gradient(145deg, #9eae79, #668f71);
}

.effect-circle {
  position: absolute;
  border: 2px solid rgba(247, 239, 169, 0.62);
  border-radius: 50%;
  background: rgba(219, 229, 133, 0.13);
}

.effect-one {
  top: 42px;
  left: 28px;
  width: 142px;
  height: 142px;
}

.effect-two {
  top: 69px;
  left: 133px;
  width: 166px;
  height: 166px;
}

.effect-three {
  top: 16px;
  right: 20px;
  width: 118px;
  height: 118px;
}

.effect-tree {
  position: absolute;
  color: #174c3d;
  font-size: 2.6rem;
}

.tree-one { top: 88px; left: 80px; }
.tree-two { top: 119px; left: 192px; }
.tree-three { top: 51px; right: 58px; }

.cells-art {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #304c48, #203d3c);
}

.cell-field {
  display: grid;
  width: 82%;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
  transform: skewY(-3deg);
}

.cell-field span {
  aspect-ratio: 1;
  border-radius: 4px;
  background: #ad9d67;
}

.cell-field span:nth-child(6n + 1),
.cell-field span:nth-child(6n + 2) { background: #3b7953; }
.cell-field span:nth-child(6n + 3) { background: #6e9a53; }
.cell-field span:nth-child(5n) { background: #315f49; }

.wind-mark {
  position: absolute;
  right: 28px;
  bottom: 16px;
  color: rgba(239, 235, 202, 0.65);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.mode-copy {
  padding: 23px 24px 25px;
}

.mode-meta {
  display: flex;
  margin-bottom: 16px;
  justify-content: space-between;
  color: #7b887f;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.mode-copy h2,
.experiment-panel h2 {
  margin-bottom: 9px;
  font-family: Georgia, serif;
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.035em;
}

.mode-copy p {
  min-height: 68px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.mode-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: #315f4c;
  font-size: 0.82rem;
  font-weight: 850;
  text-decoration: none;
}

.experiment-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 23px;
}

.experiment-header h1 {
  font-size: clamp(2.5rem, 4.5vw, 4.9rem);
}

.experiment-header > p {
  max-width: 520px;
  margin-bottom: 3px;
  color: #657169;
  font-family: Georgia, serif;
  font-size: 1.08rem;
  line-height: 1.5;
}

.experiment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 315px;
  gap: 18px;
  align-items: start;
}

.simulation-card,
.panel-section,
.stage-legend {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.simulation-canvas-wrap {
  position: relative;
  overflow: hidden;
  background: #ad9b68;
}

.simulation-canvas-wrap canvas {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 3;
  touch-action: none;
}

.life-canvas-wrap canvas {
  aspect-ratio: 9 / 5;
}

.experiment-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 28px;
  text-align: center;
  color: #f9f6e8;
  background: linear-gradient(135deg, rgba(23, 65, 52, 0.92), rgba(45, 93, 66, 0.84));
  transition: opacity 220ms ease, visibility 220ms ease;
}

.life-overlay {
  background: linear-gradient(135deg, rgba(22, 52, 51, 0.94), rgba(34, 76, 65, 0.88));
}

.experiment-overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.experiment-overlay .experiment-eyebrow {
  color: #d0d993;
}

.experiment-overlay h2 {
  margin: 0 0 12px;
  font-family: Georgia, serif;
  font-size: clamp(2rem, 4vw, 3.9rem);
  font-weight: 500;
  letter-spacing: -0.045em;
}

.experiment-overlay > p:last-of-type {
  max-width: 580px;
  margin-bottom: 23px;
  color: rgba(249, 246, 232, 0.78);
  line-height: 1.55;
}

.overlay-orbit {
  position: relative;
  display: block;
  width: 82px;
  height: 56px;
  margin-bottom: 13px;
}

.overlay-orbit i {
  position: absolute;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(236, 234, 150, 0.62);
  border-radius: 50%;
}

.overlay-orbit i:nth-child(1) { left: 0; top: 7px; }
.overlay-orbit i:nth-child(2) { left: 19px; top: 0; }
.overlay-orbit i:nth-child(3) { right: 0; top: 8px; }

.life-glyph {
  margin-bottom: 13px;
  color: #cdd99b;
  font-size: 2.8rem;
}

.experiment-primary,
.experiment-secondary,
.experiment-text-button,
.plant-tool,
.speed-buttons button {
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.experiment-primary {
  padding: 12px 21px;
  border: 0;
  border-radius: 999px;
  color: #173e31;
  background: #f1d77d;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.17);
  font-weight: 850;
}

.simulation-message {
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  color: #586a61;
  font-size: 0.8rem;
}

.simulation-message > span:first-child {
  color: #a6822d;
}

.simulation-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
}

.simulation-stats > div {
  display: grid;
  min-height: 116px;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.simulation-stats > div:last-child {
  border-right: 0;
}

.simulation-stats span {
  color: #76837c;
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.simulation-stats strong {
  margin: 3px 0;
  color: #315f4d;
  font-family: Georgia, serif;
  font-size: 1.65rem;
  font-weight: 500;
}

.simulation-stats small,
.plant-tool small,
.plant-tool em,
.panel-note,
.speed-buttons span {
  color: #748078;
  font-size: 0.7rem;
  font-style: normal;
  line-height: 1.4;
}

.experiment-panel {
  display: grid;
  gap: 14px;
}

.panel-section,
.stage-legend {
  padding: 19px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 13px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.experiment-status {
  padding: 5px 9px;
  border-radius: 999px;
  color: #557341;
  background: #e4ebce;
  font-size: 0.65rem;
  font-weight: 850;
}

.plant-tool {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  margin-bottom: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  background: rgba(245, 243, 229, 0.75);
}

.plant-tool.is-selected,
.speed-buttons button.is-selected {
  border-color: rgba(59, 108, 77, 0.5);
  background: #e8edd8;
}

.plant-tool > span:last-child {
  display: grid;
  gap: 1px;
}

.plant-tool strong {
  font-family: Georgia, serif;
  font-size: 0.94rem;
}

.plant-tool small {
  color: #61736a;
  font-weight: 800;
}

.tool-swatch {
  display: grid;
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  font-size: 1.25rem;
}

.clover-swatch { color: #56783a; background: #dfe8bd; }
.pioneer-swatch { color: #2e6546; background: #d6e3cb; }
.rain-swatch { color: #2d6762; background: #d2e4df; }

.panel-note {
  margin-bottom: 13px;
}

.experiment-secondary,
.experiment-text-button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 850;
}

.experiment-secondary {
  margin-bottom: 7px;
  border: 1px solid rgba(42, 84, 66, 0.2);
  background: #edf0df;
}

.subtle-button {
  background: transparent;
}

.experiment-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.experiment-text-button {
  border: 0;
  color: #66766d;
  background: transparent;
}

.speed-section h2 {
  font-size: 1.1rem;
}

.speed-buttons {
  display: grid;
  gap: 7px;
}

.speed-buttons button {
  display: grid;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  text-align: left;
  background: transparent;
}

.speed-buttons strong {
  font-size: 0.78rem;
}

.stage-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}

.stage-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #69776f;
  font-size: 0.68rem;
  font-weight: 750;
}

.stage-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-grass { background: #8ca64c; }
.legend-sapling { background: #568052; }
.legend-forest { background: #245743; }
.legend-dry { background: #756f61; }

.wind-indicator {
  position: absolute;
  top: 12px;
  right: 15px;
  z-index: 1;
  padding: 5px 9px;
  border-radius: 999px;
  color: rgba(237, 240, 209, 0.8);
  background: rgba(28, 60, 54, 0.6);
  font-size: 0.59rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

button:hover,
.mode-link:hover {
  transform: translateY(-1px);
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid #d9bd66;
  outline-offset: 3px;
}

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

  .experiment-layout {
    grid-template-columns: 1fr;
  }

  .experiment-panel {
    grid-template-columns: 1fr 1fr;
  }

  .stage-legend {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .experiment-nav,
  .gallery-page,
  .experiment-page {
    width: calc(100% - 22px);
  }

  .gallery-page,
  .experiment-page {
    padding-top: 28px;
  }

  .mode-grid,
  .experiment-panel {
    grid-template-columns: 1fr;
  }

  .life-card,
  .stage-legend {
    grid-column: auto;
  }

  .experiment-header {
    display: block;
  }

  .experiment-header > p {
    margin-top: 16px;
  }

  .simulation-stats {
    grid-template-columns: 1fr;
  }

  .simulation-stats > div {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .simulation-stats > div:last-child {
    border-bottom: 0;
  }

  .experiment-overlay > p:last-of-type {
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
