:root {
  --ink: #1d1d1b;
  --ink-2: #55534e;
  --ink-3: #8a877f;
  --paper: #fcfbf8;
  --rule: #e6e3dc;
  --night: #0a0f1c;
  --night-2: #141b2e;
  --g1: #2a78d6; --g2: #eb6834; --g3: #1baf7a; --g4: #6250d6; --g5: #e34948;
  --ctl: #9a978f;
  --accent: #2a78d6;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.6; font-size: 17px;
}
a { color: inherit; text-decoration-color: #b8b4aa; text-underline-offset: 2px; }
button, select, input { font: inherit; color: inherit; }

/* ---- hero ---- */
#hero {
  position: relative; height: min(80vh, 820px); min-height: 460px;
  background: var(--night); color: #e9ecf4; overflow: hidden;
}
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; cursor: crosshair; }
.hero-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; padding: 1.1rem 1.4rem; pointer-events: none;
  background: linear-gradient(rgba(10,15,28,.85), rgba(10,15,28,0));
}
.hero-top a, .hero-top button { pointer-events: auto; }
.hero-title h1 { margin: .1rem 0 0; font-size: clamp(1.9rem, 5vw, 3.1rem); line-height: 1.05; letter-spacing: -.01em; font-weight: 700; }
.hero-title .kicker { margin: .3rem 0 0; color: #aab2c8; font-size: .95rem; }
.hero-title .back { font-size: .85rem; color: #aab2c8; text-decoration: none; }
.hero-title .back::before { content: "← "; }
.hero-stats { display: grid; grid-template-columns: repeat(5, auto); gap: .2rem 1.2rem; margin: .3rem 0 0; text-align: right; }
.hero-stats div { min-width: 3.6rem; }
.hero-stats dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #8f98b0; }
.hero-stats dd { margin: 0; font-variant-numeric: tabular-nums; font-size: 1.05rem; font-weight: 600; }
.hero-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 1rem 1.4rem 1.1rem; pointer-events: none;
  background: linear-gradient(rgba(10,15,28,0), rgba(10,15,28,.85));
}
.hero-bottom > * { pointer-events: auto; }
.hero-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.hint { color: #8f98b0; font-size: .85rem; }

.btn, .seg button {
  border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.06); border-radius: 999px;
  padding: .35rem .85rem; cursor: pointer; line-height: 1.2; min-height: 2.1rem;
}
.btn:hover, .seg button:hover { background: rgba(255,255,255,.14); }
.seg { display: inline-flex; }
.seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: 999px 0 0 999px; margin-left: 0; }
.seg button:last-child { border-radius: 0 999px 999px 0; }
.seg button[aria-pressed="true"] { background: #e9ecf4; color: var(--night); border-color: #e9ecf4; }
#h-play { min-width: 2.6rem; }

.follow {
  width: min(320px, 100%); margin-bottom: .7rem; padding: .7rem .85rem; border-radius: 10px;
  background: rgba(20,27,46,.92); border: 1px solid rgba(255,255,255,.12); font-size: .85rem;
}
.follow-head { display: flex; align-items: center; gap: .5rem; }
.follow-head b { flex: 1; }
.swatch { width: .9rem; height: .9rem; border-radius: 50%; display: inline-block; }
.x { background: none; border: 0; color: #aab2c8; font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 .2rem; }
.follow-meta { color: #aab2c8; margin: .2rem 0 .45rem; }
.genebars { display: grid; grid-template-columns: auto 1fr auto; gap: .15rem .5rem; align-items: center; font-variant-numeric: tabular-nums; }
.genebars .bar { position: relative; height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; }
.genebars .bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.genebars .bar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: rgba(255,255,255,.3); }

/* ---- prose ---- */
main { padding-bottom: 4rem; }
.prose { max-width: 700px; margin: 0 auto; padding: 0 1.25rem; }
.prose h2 { font-size: 1.6rem; margin: 3rem 0 .6rem; line-height: 1.2; }
.prose h4 { margin: 1.4rem 0 .3rem; }
.lede { font-size: 1.15rem; margin-top: 2.2rem; }
.note { color: var(--ink-2); font-size: .95rem; }
.foot { color: var(--ink-2); font-size: .9rem; margin-top: 2rem; }
figure { margin: 1rem 0; }
figure img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
figcaption { text-align: center; color: var(--ink-2); font-size: .85rem; }
.rules { border: 1px solid var(--rule); border-radius: 10px; padding: .2rem 1rem; margin: 1.6rem 0; background: #fff; }
.rules summary { cursor: pointer; padding: .6rem 0; font-weight: 600; }
.rules[open] summary { border-bottom: 1px solid var(--rule); margin-bottom: .4rem; }

/* ---- lab ---- */
.wide { max-width: 1120px; margin: 1.6rem auto 0; padding: 0 1.25rem; }
.lab-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .8rem 1rem; border-radius: 12px; background: var(--night); color: #e9ecf4; }
.lab-bar .btn.primary { background: #e9ecf4; color: var(--night); border-color: #e9ecf4; font-weight: 600; min-width: 5rem; }
.pick { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: #aab2c8; }
.pick select { background: var(--night-2); color: #e9ecf4; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; padding: .3rem .4rem; }
.status { margin-left: auto; color: #aab2c8; font-size: .85rem; font-variant-numeric: tabular-nums; }

.env { margin: .7rem 0 0; border: 1px solid var(--rule); border-radius: 10px; background: #fff; padding: .2rem 1rem; }
.env summary { cursor: pointer; padding: .55rem 0; font-weight: 600; }
.env-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem 1.4rem; padding: .5rem 0; font-size: .9rem; }
.env-grid label { display: flex; flex-direction: column; gap: .25rem; color: var(--ink-2); }
.env-grid output { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.env-grid input[type=range] { width: 100%; accent-color: var(--accent); }
.env-grid select { padding: .3rem; border: 1px solid var(--rule); border-radius: 6px; background: #fff; }
.env-foot { margin: .4rem 0 .8rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.env .btn { border-color: var(--rule); background: #fff; }
.env .btn.primary { background: var(--night); color: #fff; border-color: var(--night); }
.env .btn:hover { background: #f1efe9; }
.env .btn.primary:hover { background: #222a40; }

.thumbs { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: .9rem 0 0; }
.thumb { position: relative; aspect-ratio: 750 / 550; border-radius: 6px; overflow: hidden; background: var(--night); }
.thumb canvas { width: 100%; height: 100%; display: block; }
.thumb span { position: absolute; left: 5px; bottom: 3px; font-size: .62rem; color: #8f98b0; letter-spacing: .04em; text-transform: uppercase; }
.thumb.ctl { background: #262626; }
.thumb.ctl span { color: #bdbab2; }

.legend { display: flex; flex-wrap: wrap; gap: .3rem 1.4rem; margin: 1.1rem 0 .3rem; font-size: .85rem; color: var(--ink-2); }
.legend .ln { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--ink); vertical-align: middle; margin-right: .45rem; }
.legend .ln.ctl { border-top: 2px dashed var(--ctl); }
.charts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem 1.4rem; }
.panel { position: relative; }
.panel h3 { margin: 0 0 .1rem; font-size: .9rem; font-weight: 600; }
.panel h3 small { font-weight: 400; color: var(--ink-2); }
@media (max-width: 640px) { .panel h3 small { display: block; font-size: .72rem; line-height: 1.3; } }
.panel canvas { width: 100%; height: 170px; display: block; touch-action: pan-y; }
.tip {
  position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--rule); border-radius: 6px;
  padding: .3rem .5rem; font-size: .78rem; line-height: 1.35; box-shadow: 0 2px 8px rgba(0,0,0,.08); white-space: nowrap; z-index: 2;
  font-variant-numeric: tabular-nums;
}
.chart-note { font-size: .82rem; color: var(--ink-3); }

/* ---- landscape ---- */
.land { display: grid; grid-template-columns: 1.55fr 1fr; gap: 1.4rem; align-items: start; }
.land-map canvas { width: 100%; aspect-ratio: 1.3; display: block; cursor: crosshair; touch-action: manipulation; }
.ramp { display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: var(--ink-2); margin: .3rem 0 0 54px; }
.ramp i { flex: 0 0 140px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #eef3fa, #9ec3ea, #3f86d4, #164f9c, #0b2a5c); }
.land-test canvas { width: 100%; aspect-ratio: 750 / 550; display: block; border-radius: 8px; background: var(--night); }
.t-read { font-size: .92rem; color: var(--ink-2); margin: .5rem 0 0; }
.t-read b { color: var(--ink); }
.t-hint { display: block; color: var(--ink-3); font-size: .85rem; }

@media (max-width: 900px) {
  .charts { grid-template-columns: repeat(2, 1fr); }
  .land { grid-template-columns: 1fr; }
  .land-test { max-width: 460px; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  #hero { height: 78vh; min-height: 440px; }
  .hero-top { flex-direction: column; padding: .9rem 1rem; }
  .hero-stats { grid-template-columns: repeat(5, auto); gap: .1rem .8rem; text-align: left; }
  .hero-stats div { min-width: 0; }
  .hero-stats dd { font-size: .9rem; }
  .hero-bottom { padding: .8rem 1rem; }
  .hint { width: 100%; }
  .follow { padding: .5rem .7rem; font-size: .78rem; margin-bottom: .5rem; }
  .follow-meta { margin: .1rem 0 .3rem; }
  .thumbs { grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .charts { grid-template-columns: 1fr 1fr; gap: .9rem .8rem; }
  .panel canvas { height: 130px; }
  .panel h3 { font-size: .8rem; }
  .status { margin-left: 0; width: 100%; }
}
@media (max-width: 380px) {
  .charts { grid-template-columns: 1fr; }
}

/* Credit (DB-0202/1 B): the words and the † open a one-line note; on paper the note prints at the foot. */
.credit { pointer-events: auto; margin: .25rem 0 0; font-size: .85rem; color: #aab2c8; max-width: 24rem; }
.credit summary { display: inline-block; padding: .35rem 0; cursor: pointer; list-style: none; }
.credit summary::-webkit-details-marker { display: none; }
.credit summary::marker { content: ""; }
.credit sup { line-height: 0; margin-left: .15em; font-size: 1.05em; color: #e9ecf4; }
.credit .cnote { display: block; padding: .5rem .7rem; border-radius: 6px; background: rgba(10,15,28,.85); color: #e9ecf4; line-height: 1.4; }
.credit .cnote a { color: inherit; }
.cfoot { display: none; }
@media print { .credit .cnote { display: none; } .cfoot { display: block; font-size: 9pt; color: #333; border-top: 1px solid #999; padding-top: .5em; margin-top: 2em; } }
