/* Branching Evolution. Play: a full-screen universe under the site bar, with glass panels
   floating on it (title top-left, rules on the right, stats and chart bottom-left).
   The science: one readable column. On phones the rules become a sheet opened by a button. */
.game-nav { margin-left: 4px; }
.game-nav a { position: relative; padding-bottom: 4px; white-space: nowrap; }
.game-nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px;
  background: linear-gradient(90deg, var(--warm), var(--cool)); opacity: .4; transition: opacity .2s;
}
.game-nav a:hover::after { opacity: 1; }
.game-nav a[aria-current="page"]::after { opacity: 1; height: 2px; }

.view[hidden] { display: none; }
.kicker { margin: 0 0 10px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

/* ---------- Play ---------- */
body.playing .site-footer { display: none; }
.universe {
  position: relative; height: calc(100vh - 53px); height: calc(100dvh - 53px); min-height: 520px; overflow: hidden;
  background: radial-gradient(70% 60% at 45% 45%, #0b0f1a 0%, #000 70%);
}
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#world.over { cursor: pointer; }
.glass {
  background: rgba(8, 8, 11, 0.72); border: 1px solid #1f1f23; border-radius: 14px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.title-card { position: absolute; left: 24px; top: 20px; max-width: 380px; pointer-events: none; text-shadow: 0 0 14px #000; }
.title-card h1 { margin: 0; font-family: var(--font-serif); font-weight: 300; font-size: clamp(1.8rem, 3.2vw, 2.6rem); line-height: 1.1; }
.intro { margin: 10px 0 0; font-size: 12.5px; line-height: 1.7; color: #b5b5bb; }
.intro b { color: var(--fg); font-weight: 500; }
.intro.demo b { color: var(--warm); }
.hint { margin: 10px 0 0; font-size: 11px; letter-spacing: .04em; color: var(--warm); min-height: 1em; }

.tip {
  position: absolute; z-index: 3; pointer-events: none; transform: translate(-50%, calc(-100% - 14px));
  padding: 6px 10px; font-size: 11px; white-space: nowrap; color: var(--fg);
  background: rgba(8, 8, 11, 0.85); border: 1px solid #2a2a30; border-radius: 8px;
}
.tip[hidden] { display: none; }

.dock { position: absolute; left: 24px; bottom: 20px; width: min(460px, calc(100% - 400px)); padding: 14px 16px; }
.stats { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 6px 16px; margin-bottom: 10px; }
.stats div { display: flex; flex-direction: column; gap: 2px; }
.stats b { font-weight: 500; font-size: 18px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.stats small { font-size: 9.5px; line-height: 1.35; color: var(--muted); max-width: 17ch; }
#chart { width: 100%; height: 90px; display: block; }
.legend { margin: 6px 0 0; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: flex; gap: 14px; align-items: center; }
.legend i { display: inline-block; width: 14px; height: 2px; margin-right: -8px; vertical-align: middle; }
.lg-best { background: var(--warm); }
.lg-mean { background: #8a8a91; }
.lg-div { background: repeating-linear-gradient(90deg, #ff6b9d 0 3px, transparent 3px 5px); }

.panel {
  position: absolute; right: 20px; top: 20px; bottom: 20px; width: 330px; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 16px; padding: 18px;
  scrollbar-width: thin; scrollbar-color: #2a2a30 transparent;
}
.panel-toggle { display: none; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-g {
  display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 14px;
  border: 1px solid #34343a; border-radius: 999px; background: transparent; color: var(--fg);
  font: inherit; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; cursor: pointer;
  transition: border-color .2s, background-color .2s, color .2s;
}
.btn-g:hover { border-color: var(--fg); }
.btn-g.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn-g.primary:hover { background: transparent; color: var(--fg); }

.ctl { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.ctl > span, .ctl legend { display: flex; justify-content: space-between; gap: 8px; padding: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg); }
.ctl legend { width: 100%; margin-bottom: 6px; }
.ctl legend em { font-style: normal; text-transform: none; letter-spacing: 0; color: var(--muted); }
.ctl output { color: var(--warm); font-variant-numeric: tabular-nums; }
.ctl input[type="range"] { width: 100%; margin: 0; accent-color: var(--warm); }
.ctl small, .toggles small { font-size: 11px; line-height: 1.5; color: var(--muted); letter-spacing: 0; text-transform: none; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #34343a; border-radius: 999px; overflow: hidden; }
.seg button {
  height: 32px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
}
.seg button + button { border-left: 1px solid #34343a; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.note { margin: 6px 0 0; font-size: 11px; line-height: 1.55; color: var(--muted); }
.toggles { display: flex; flex-direction: column; gap: 10px; font-size: 12px; color: var(--fg); }
.toggles label { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: start; cursor: pointer; }
.toggles span { display: flex; flex-direction: column; gap: 2px; }
.toggles input { accent-color: var(--warm); width: 15px; height: 15px; margin: 1px 0 0; }

.genome { border-top: 1px solid var(--line); padding-top: 14px; font-size: 11px; color: var(--muted); }
.genome h3 { margin: 0 0 10px; font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--fg); }
.genome .g { display: grid; grid-template-columns: 76px minmax(0, 1fr) 54px; align-items: center; gap: 8px; margin-bottom: 5px; }
.genome .gv { text-align: right; color: var(--fg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.genome .bar { height: 5px; border-radius: 3px; background: #1a1a1e; overflow: hidden; }
.genome .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--warm), var(--cool)); }
.to-science { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg); text-decoration: none; }
.to-science:hover { color: var(--warm); }

/* ---------- The science ---------- */
.science { padding-block: 40px 72px; }
.sci { max-width: 72ch; }
.sci h1 { margin: 0 0 12px; font-family: var(--font-serif); font-weight: 300; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.1; }
.sci h2 { margin: 40px 0 12px; font-family: var(--font-serif); font-weight: 300; font-size: 1.6rem; letter-spacing: -0.01em; }
.sci p, .sci li, .sci dd, .sci td, .sci th { font-size: 13.5px; line-height: 1.8; color: #c9c9ce; }
.sci .lead { font-size: 15px; color: var(--fg); }
.sci p { margin: 0 0 14px; }
.sci ul, .sci ol { margin: 0 0 14px; padding-left: 20px; }
.sci li { margin-bottom: 8px; }
.sci b { color: var(--fg); font-weight: 500; }
.steps li::marker { color: var(--warm); }
.apps li::marker { color: var(--cool); }
.map { width: 100%; border-collapse: collapse; margin: 6px 0 14px; }
.map th { text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 400; padding: 8px 10px 8px 0; border-bottom: 1px solid #34343a; }
.map td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.defs { margin: 0; }
.defs dt { margin-top: 12px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--fg); }
.defs dd { margin: 2px 0 0; }
.refs li { font-size: 12.5px; line-height: 1.7; }
.refs a { color: var(--cool); text-decoration: none; word-break: break-all; }
.refs a:hover { text-decoration: underline; }
.aidisc { margin-top: 28px !important; padding-top: 14px; border-top: 1px solid var(--line); font-size: 11.5px !important; color: var(--muted) !important; }

/* ---------- Smaller screens: rules become a sheet ---------- */
@media (max-width: 900px) {
  .dock { width: auto; right: 24px; }
  .panel-toggle {
    display: inline-flex; position: absolute; right: 16px; top: 16px; z-index: 4; height: 34px; padding: 0 16px;
    align-items: center; border-radius: 999px; border: 1px solid #34343a; background: rgba(8, 8, 11, 0.8); color: var(--fg);
    font: inherit; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
  }
  .panel-toggle[aria-expanded="true"] { background: var(--fg); color: var(--bg); }
  .panel { top: 60px; right: 12px; left: 12px; bottom: 12px; width: auto; z-index: 3; }
  .panel.closed { display: none; }
  .title-card { max-width: calc(100% - 130px); left: 16px; top: 16px; }
}
@media (max-width: 600px) {
  .game-nav { gap: 14px; }
  .game-nav a { font-size: 11px; letter-spacing: .06em; }
  .intro { font-size: 11.5px; line-height: 1.6; }
  .dock { left: 12px; right: 12px; bottom: 12px; padding: 10px 12px; }
  .stats b { font-size: 15px; }
  #chart { height: 60px; }
  .legend { display: none; }
  .science { padding-block: 24px 48px; }
  .map th:nth-child(2), .map td:nth-child(2) { display: none; }
}

/* ---------- Simple version: the four-step cycle, score labels, fewer controls ---------- */
.cycle { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 18px 0 0; padding: 0; }
.cycle li {
  display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px 0 4px;
  border: 1px solid #2a2a30; border-radius: 999px; background: rgba(0, 0, 0, 0.55);
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #6a6a72;
  transition: color .3s, border-color .3s;
}
.cycle li b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #1a1a1e; color: #8a8a91; font-weight: 500; font-size: 10px; transition: background-color .3s, color .3s; }
.cycle li.on { color: var(--fg); border-color: var(--warm); }
.cycle li.on b { background: var(--warm); color: #000; }
.caption { margin: 10px 0 0; max-width: 400px; min-height: 2.8em; font-size: 13px; line-height: 1.55; color: var(--fg); }

.labels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.labels span {
  position: absolute; transform: translate(-50%, -100%); padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--fg);
  background: rgba(0, 0, 0, 0.6); border: 1px solid transparent; transition: opacity .3s, color .3s; opacity: 0;
}
.labels span.win { color: #ffd27a; border-color: rgba(255, 210, 122, 0.55); }
.labels span.lose { color: #6a6a72; }

.stats { grid-template-columns: repeat(2, auto); justify-content: start; gap: 6px 36px; }
.lg-mean { background: #ededed; }
.lg-best { background: repeating-linear-gradient(90deg, var(--warm) 0 3px, transparent 3px 6px); }
.seg { display: flex; }
.seg button { flex: 1; }
.ctl small { margin-top: 2px; }
@media (max-width: 600px) {
  .cycle li { height: 24px; font-size: 9.5px; padding-right: 8px; }
  .cycle li b { width: 17px; height: 17px; }
  .caption { font-size: 12px; }
}

.title-card { z-index: 2; max-width: 470px; }
@media (max-width: 900px) { .title-card { max-width: calc(100% - 130px); } }

/* ---------- Mission card: what to do, progress, Start ---------- */
.mission { pointer-events: auto; margin-top: 16px; padding: 14px 16px; text-shadow: none; transition: border-color .4s; }
.mission.done { border-color: var(--warm); }
.mission.failed { border-color: #ff6b9d; }
.m-head { display: flex; justify-content: space-between; margin: 0 0 6px; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--warm); }
.m-head span + span { color: var(--muted); }
.m-goal { margin: 0 0 12px; font-size: 13.5px; line-height: 1.5; color: var(--fg); }
.m-goal b { font-weight: 500; color: var(--warm); }
.m-bar { position: relative; height: 6px; border-radius: 3px; background: #1a1a1e; }
.m-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--cool), var(--warm)); transition: width .6s; }
.m-bar span { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--fg); transform: translateX(-1px); }
.m-score { display: flex; justify-content: space-between; gap: 10px; margin: 8px 0 12px; font-size: 11px; color: var(--muted); }
.m-score b { color: var(--fg); font-weight: 500; font-variant-numeric: tabular-nums; }
.m-tip { text-align: right; color: var(--warm); }
.mission .btn-g.next { border-color: var(--warm); color: var(--warm); }
.mission .btn-g.next:hover { background: var(--warm); color: #000; }
@media (max-width: 600px) {
  .mission { padding: 10px 12px; margin-top: 10px; }
  .m-goal { font-size: 12.5px; margin-bottom: 8px; }
  .m-score { margin: 6px 0 8px; }
  .title-card .intro { display: none; }
}

/* Family colours key */
.family { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.family i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: -6px; }
.f-mum { background: #ffbf57; box-shadow: 0 0 8px rgba(255, 191, 87, 0.6); }
.f-dad { background: #5fb4ff; box-shadow: 0 0 8px rgba(95, 180, 255, 0.6); }
.family span { color: #6a6a72; }
.btn-g[hidden] { display: none; }
#chart { height: 64px; }
@media (max-height: 760px) and (min-width: 901px) { .dock .stats small, .legend { display: none; } #chart { height: 48px; } }

/* ---------- Evolution report window ---------- */
.report { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: rgba(0, 0, 0, 0.6); }
.report[hidden] { display: none; }
.report-box { position: relative; width: min(760px, 100%); max-height: 100%; overflow-y: auto; padding: 22px 24px; background: rgba(8, 8, 11, 0.94); border-color: #34343a; }
.report-box h2 { margin: 0 0 14px; font-family: var(--font-serif); font-weight: 300; font-size: 1.9rem; line-height: 1.15; color: var(--warm); }
.report-box h3 { margin: 22px 0 6px; font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--fg); }
.r-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: 1px solid #34343a; border-radius: 50%; background: none; color: var(--fg); font-size: 18px; line-height: 1; cursor: pointer; }
.r-close:hover { border-color: var(--fg); }
.r-top { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 20px; align-items: center; }
#rWinner { border: 1px solid #2a2a30; border-radius: 12px; background: radial-gradient(circle at 50% 45%, #14141a, #050507); }
.r-stats { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 14px; margin: 0; font-size: 12px; }
.r-stats dt { color: var(--muted); }
.r-stats dd { margin: 0; color: var(--fg); }
.r-note { margin: 0 0 8px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.r-mut { color: #ff6b9d; }
.r-tree { overflow: auto; max-height: 340px; border: 1px solid #1f1f23; border-radius: 10px; background: #050507; }
.r-tree canvas { display: block; margin: 0 auto; }
.r-pop { display: flex; flex-wrap: wrap; gap: 6px; }
.r-pop canvas { border: 1px solid #1f1f23; border-radius: 8px; background: #050507; }
.report .buttons { margin-top: 18px; }
.report .btn-g[hidden] { display: none; }
@media (max-width: 600px) {
  .report { padding: 10px; }
  .report-box { padding: 16px; }
  .report-box h2 { font-size: 1.5rem; padding-right: 36px; }
  .r-top { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .r-stats { font-size: 11.5px; width: 100%; }
}

/* ---------- Compact left column ---------- */
.title-card { max-width: 400px; }
.title-card h1 { font-size: clamp(1.6rem, 2.4vw, 2.1rem); }
.title-card .intro { margin-top: 6px; font-size: 12px; }
.mission { margin-top: 12px; padding: 10px 12px; }
.m-head { margin-bottom: 4px; font-size: 10px; }
.m-goal { margin-bottom: 8px; font-size: 12.5px; line-height: 1.45; }
.m-score { margin: 6px 0 8px; font-size: 10.5px; }
.mission .buttons { gap: 6px; flex-wrap: nowrap; }
.mission .btn-g { height: 28px; padding: 0 11px; font-size: 10px; }
.cycle { margin-top: 10px; gap: 4px; }
.cycle li { height: 24px; padding-right: 9px; font-size: 9.5px; gap: 5px; }
.cycle li b { width: 17px; height: 17px; font-size: 9px; }
.caption { margin-top: 6px; min-height: 2.6em; font-size: 12px; line-height: 1.45; }
.family { margin-top: 4px; font-size: 10.5px; }
.ctl legend em { font-size: 10.5px; }
#worldNote { color: var(--fg); }
/* soft dark fade behind the left column so drifting neurotrees never hurt the text */
.universe::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 470px; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.82) 55%, rgba(0, 0, 0, 0)); }
.title-card, .dock { z-index: 2; }
@media (max-width: 900px) {
  .universe::after { width: auto; right: 0; bottom: auto; height: 340px; background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 70%, rgba(0, 0, 0, 0)); }
}

/* Narrower left column; the stats box matches the mission box above it */
.title-card { max-width: 330px; }
.dock { left: 24px; width: 330px; padding: 10px 12px; }
.dock .stats small { display: none; }
.stats b { font-size: 16px; }
#chart { height: 44px; }
.legend { margin-top: 4px; }
.universe::after { width: 390px; }
@media (max-width: 900px) { .title-card { max-width: calc(100% - 130px); } .dock { width: auto; } }
@media (min-width: 901px) { .panel { bottom: auto; max-height: calc(100% - 40px); } }
/* chart box at the bottom centre of the free space (between the left column and the rules panel) */
@media (min-width: 901px) {
  .dock { left: calc(50% + 2px); transform: translateX(-50%); width: 380px; }
}

/* ---------- Level card, steps and caption at the bottom left ---------- */
.play-box { position: absolute; left: 24px; bottom: 20px; width: 330px; z-index: 2; }
.play-box .mission { margin-top: 0; }
.title-card .intro a { color: var(--warm); text-decoration: none; pointer-events: auto; white-space: nowrap; }
.title-card .intro a:hover { text-decoration: underline; }
.title-card .intro + .intro { margin-top: 8px; color: #8a8a91; }
@media (max-width: 900px) {
  .play-box { left: 12px; right: 12px; bottom: 12px; width: auto; }
  .dock { display: none; }
  .universe::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 330px; z-index: 1; pointer-events: none;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.88) 65%, rgba(0, 0, 0, 0)); }
  .universe::after { height: 230px; }
}
@media (max-width: 600px) { .title-card .intro + .intro { display: none; } }
@media (max-width: 600px) { .title-card h1 + .intro { display: block; font-size: 11.5px; } }

/* ---------- The science, visual version ---------- */
.loop { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; counter-reset: none; }
.loop li { position: relative; display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 14px 12px; border: 1px solid #1f1f23; border-radius: 12px; background: #0b0b0e; }
.loop li + li::before { content: "→"; position: absolute; left: -10px; top: 26px; transform: translateX(-50%); color: var(--warm); font-size: 13px; }
.loop svg, .apps-grid svg { width: 40px; height: 40px; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.loop b, .apps-grid b { font-size: 12px; font-weight: 500; letter-spacing: .04em; color: var(--fg); }
.loop span, .apps-grid span { font-size: 12px !important; line-height: 1.5; color: #a9a9b0; }
.loop-note { margin-top: 12px !important; font-size: 12.5px !important; color: var(--muted) !important; }
.fig { margin: 8px 0 0; padding: 14px; border: 1px solid #1f1f23; border-radius: 12px; background: #07070a; }
.chart-svg svg { display: block; width: 100%; height: auto; }
.chart-svg .grid { stroke: #1d1d22; stroke-width: 1; }
.chart-svg .tick { fill: #6a6a72; font: 10px "IBM Plex Mono", monospace; }
.chart-svg .axis { fill: #8a8a91; font: 10px "IBM Plex Mono", monospace; letter-spacing: .06em; }
.chart-svg .lbl { font: 500 11px "IBM Plex Mono", monospace; }
.fig figcaption { margin-top: 10px; font-size: 12.5px; line-height: 1.6; color: #b5b5bb; }
.fig figcaption b { color: var(--fg); font-weight: 500; }
.data-note { margin-top: 10px !important; font-size: 11px !important; line-height: 1.6 !important; color: #6a6a72 !important; }
.apps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.apps-grid div { display: flex; flex-direction: column; gap: 6px; padding: 14px 12px; border: 1px solid #1f1f23; border-radius: 12px; background: #0b0b0e; }
.refs-box { margin-top: 36px; border-top: 1px solid var(--line); padding-top: 14px; }
.refs-box summary { cursor: pointer; font-family: var(--font-serif); font-weight: 300; font-size: 1.4rem; color: var(--fg); }
.refs-box summary:hover { color: var(--warm); }
.refs-box .refs { margin-top: 12px; }
.sci { max-width: 860px; }
.sci > p, .sci > h2, .sci > .map { max-width: 72ch; }
@media (max-width: 760px) {
  .loop { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .loop li:nth-child(3)::before { display: none; }
  .apps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) { .apps-grid { grid-template-columns: minmax(0, 1fr); } }
.sci .loop { padding: 0; }
.sci .loop li { margin: 0; }
/* Drought: a dry, dusty warm haze */
.universe.dry { background: radial-gradient(70% 60% at 45% 40%, #1a120a 0%, #000 72%); }
