:root {
  --paper: #f3ede2; --paper2: #ebe3d4; --ink: #2b241d; --ink2: #6b5f52; --line: #cdbfa9;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font: 19px/1.6 var(--serif); background-image: radial-gradient(rgba(120,90,50,0.05) 1px, transparent 1px); background-size: 5px 5px; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: #8a3f1c; }

#hero { position: relative; height: 100vh; height: 100svh; min-height: 480px; overflow: hidden; background: #8b887e; }
#hero-field { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#hero-text {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 80px 6vw 44px;
  background: linear-gradient(to top, rgba(25,20,14,0.78), rgba(25,20,14,0.45) 55%, rgba(25,20,14,0));
  color: #f6efe3; pointer-events: none;
}
#hero-text > * { pointer-events: auto; }
#hero .home { z-index: 2; position: absolute; top: 16px; left: 18px; color: #f6efe3; text-decoration: none; font: 15px var(--sans); text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
h1 { font: 600 clamp(38px, 7vw, 76px)/1.02 var(--serif); margin: 0; letter-spacing: -0.01em; }
.sub { font: italic clamp(20px, 2.6vw, 28px)/1.3 var(--serif); margin: 8px 0 18px; color: #e9dcc6; }
.count { font: 17px/1.4 var(--sans); margin: 0; color: #efe4d2; }
#show-me { margin-left: 8px; border: 1px solid rgba(255,255,255,0.6); background: rgba(255,255,255,0.12); color: #fff; border-radius: 20px; padding: 8px 16px; min-height: 40px; font: 15px var(--sans); }
#show-me:hover { background: rgba(255,255,255,0.25); }
.scroll-cue { position: absolute; right: 6vw; bottom: 40px; color: #f6efe3; font-size: 26px; animation: bob 2.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(8px); } }
.top-link { position: absolute; top: 16px; left: 18px; z-index: 2; color: #f6efe3; text-decoration: none; font: 15px var(--sans); text-shadow: 0 1px 3px rgba(0,0,0,0.5); }

#story { display: grid; grid-template-columns: minmax(300px, 440px) minmax(0, 1fr); gap: 0 48px; max-width: 1500px; margin: 0 auto; padding: 0 3vw; }
#text { grid-column: 1; grid-row: 1; padding: 30vh 0 20vh; }
#stage-wrap { grid-column: 2; grid-row: 1; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 3vh 0; }
#stage {
  position: relative; border-radius: 6px; overflow: hidden; background: #6a5a40;
  box-shadow: 0 0 0 1px rgba(60,40,20,0.25), 0 14px 40px -16px rgba(60,40,20,0.55);
  aspect-ratio: 1200 / 750; width: min(100%, calc(68vh * 1.6)); margin: 0 auto;
}
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
#stage.painting #stage-field { touch-action: none; cursor: crosshair; }
#stage #plate { display: none; background: var(--paper2); }
#stage.plate #plate { display: block; }
#stage.plate #stage-field { visibility: hidden; }
#stage-tag { position: absolute; left: 12px; bottom: 12px; background: rgba(255,236,140,0.92); color: #3a2a10; padding: 4px 10px; border-radius: 12px; font: 600 12px var(--sans); display: none; }
#stage-tag.on { display: block; }
#stage-toast { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(30,24,18,0.82); color: #f6efe4; padding: 6px 14px; border-radius: 18px; font: 14px var(--sans); opacity: 0; transition: opacity 0.35s; pointer-events: none; max-width: 90%; text-align: center; }
#stage-toast.show { opacity: 1; }
#stage-chart { display: flex; gap: 14px; align-items: flex-end; height: 140px; width: min(100%, calc(68vh * 1.6)); margin: 0 auto; }
#stage-chart canvas { display: none; }
#stage-chart canvas.on { display: block; }
#story-wheel { width: auto; height: 100%; flex: 0 0 auto; }
#story-river { flex: 1; min-width: 0; height: 100%; }
#story-birds { flex: 1; min-width: 0; max-height: 100%; }

section { min-height: 80vh; padding: 6vh 0; }
section h2 { font: 600 30px/1.15 var(--serif); margin: 0 0 14px; }
section p { margin: 0 0 16px; }
.act, .speed, .seg button, .mini-tray button { font: 15px var(--sans); }
.act { border: 1px solid var(--line); background: var(--paper2); border-radius: 18px; padding: 6px 16px; }
.act[aria-pressed="true"] { background: #f7e48c; border-color: #c9a92a; }
.speedline { font: 15px var(--sans); color: var(--ink2); display: flex; align-items: center; gap: 6px; }
.speed { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 3px 10px; min-height: 36px; min-width: 44px; }
.speed.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 6px 0 12px; }
.seg button { flex: 1; border: none; background: transparent; padding: 7px 4px; border-left: 1px solid var(--line); font-size: 13.5px; min-height: 40px; }
.seg button:first-child { border-left: none; }
.seg button.on { background: var(--ink); color: var(--paper); }
.slider { display: flex; align-items: center; gap: 8px; font: 13px var(--sans); color: var(--ink2); margin: 4px 0 16px; }
.slider input { flex: 1; accent-color: var(--ink); }
.genes { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; font: 14px var(--sans); color: var(--ink2); margin: 0 0 16px; }
.genes input { accent-color: var(--ink); width: 100%; }
.mini-tray { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.mini-tray button { border: none; background: none; padding: 0; width: 56px; font-size: 11px; color: var(--ink2); text-align: center; line-height: 1.15; }
.mini-tray canvas { display: block; width: 50px; height: 50px; margin: 0 auto 3px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(60,40,20,0.3); }
.mini-tray button[aria-checked="true"] canvas { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--ink); }
.mini-tray button[aria-checked="true"] { color: var(--ink); font-weight: 600; }
.end .play a { display: inline-block; background: var(--ink); color: var(--paper); text-decoration: none; padding: 12px 22px; border-radius: 26px; font: 18px var(--sans); }
.end .play a:hover { background: #4a3e32; }
.credits { font-size: 15px; color: var(--ink2); margin-top: 40px; }

@media (max-width: 860px) {
  body { font-size: 17.5px; }
  #story { display: block; padding: 0; }
  #stage-wrap { position: sticky; top: 0; height: auto; z-index: 2; padding: 0; gap: 0; background: var(--paper); box-shadow: 0 6px 12px -8px rgba(60,40,20,0.35); }
  #stage { border-radius: 0; box-shadow: none; width: min(100%, calc(44vh * 1.6), calc(44dvh * 1.6)); }
  #stage-chart { padding: 4px 8px; gap: 8px; height: 92px; width: 100%; }
  #text { padding: 4vh 20px 10vh; }
  section { min-height: 70vh; padding: 4vh 0; }
  section h2 { font-size: 25px; }
}
@media (max-height: 500px) and (max-width: 1000px) {
  #stage-chart { display: none; }
  #stage { width: min(100%, calc(56vh * 1.6), calc(56dvh * 1.6)); }
}

/* Credit (DB-0202/1 B): the words and the † open a one-line note; on paper the note prints at the foot. */
.credit summary { display: inline-block; 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; }
.credit .cnote { display: block; line-height: 1.4; }
.credit .cnote a { color: inherit; }
.cfoot { display: none; }
#hero-text .credit { margin: -10px 0 14px; font: 15px/1.4 var(--sans); color: #e9dcc6; max-width: 30rem; }
#hero-text .credit summary { padding: 4px 0; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
#hero-text .credit sup { color: #fff; }
#hero-text .credit .cnote { margin: 4px 0 0; padding: 9px 12px; border-radius: 8px; background: rgba(25,20,14,0.88); color: #f6efe3; }
@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; } }
