:root {
  --ink: #1d1b2e;
  --paper: #fbf7ea;
  --paper2: #f1e9d2;
  --mute: #6a6676;
  --go: #2f6f4f;
  --red: #b6402e;
  --note: #fdf3bf;
  --stage: min(100vw, calc(100dvh * 16 / 9));
  --read: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  --hand: 'Patrick Hand', 'Segoe Print', cursive;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: #15131c; color: var(--ink); font-family: var(--read); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#stage { position: relative; width: var(--stage); aspect-ratio: 16 / 9; flex: none; overflow: hidden; background: #28315c; }
#view { width: 100%; height: 100%; display: block; }
#spots { position: absolute; inset: 0; }
#fade { position: absolute; inset: 0; background: #15131c; opacity: 0; pointer-events: none; transition: opacity .3s; }
#fade.on { opacity: 1; }

#placename {
  position: absolute; left: 1.4%; top: 2.4%; padding: .25em .7em .3em; background: var(--paper); border: 2px solid var(--ink); border-radius: 3px;
  font-family: var(--hand); font-size: clamp(15px, calc(var(--stage) * .021), 30px); line-height: 1.1; transform: rotate(-1deg);
}

/* things to click in a scene */
.spot, .mapspot { position: absolute; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: .25em; }
.spot i, .mapspot i {
  width: clamp(30px, calc(var(--stage) * .04), 58px); aspect-ratio: 1; border-radius: 50%; border: 3px solid var(--paper);
  box-shadow: 0 0 0 2.5px var(--ink), inset 0 0 0 2.5px var(--ink); background: rgba(251, 247, 234, .28); animation: breathe 2.2s ease-in-out infinite;
}
.spot span, .mapspot span, .who span {
  font-family: var(--hand); font-size: clamp(13px, calc(var(--stage) * .0165), 24px); line-height: 1.1; white-space: nowrap;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 3px; padding: .12em .5em .18em;
}
.spot:hover i, .mapspot:hover i, .spot:focus-visible i { background: rgba(253, 243, 191, .85); animation: none; transform: scale(1.12); }
.spot.plain i { animation: none; opacity: .75; }
@keyframes breathe { 50% { transform: scale(1.13); } }
.who { position: absolute; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 1.5%; }
.who span { transition: transform .15s; }
.who:hover span { background: var(--note); transform: translateY(-3px); }
.who.fresh span::after { content: ' …'; font-weight: 700; color: var(--red); }
.mapspot i { width: clamp(22px, calc(var(--stage) * .026), 40px); background: var(--note); animation: none; }
.mapspot.here i { background: var(--red); }
.mapspot.council i { background: var(--go); animation: breathe 1.6s ease-in-out infinite; }
.mapspot:hover span { background: var(--note); }

/* top right */
#hud { position: fixed; right: max(10px, calc((100vw - var(--stage)) / 2 + 10px)); top: max(10px, calc((100dvh - var(--stage) * 9 / 16) / 2 + 10px)); display: flex; gap: 6px; z-index: 4; }
#hud button {
  font-family: var(--hand); font-size: clamp(15px, calc(var(--stage) * .018), 24px); line-height: 1; padding: .34em .7em .4em; background: var(--paper);
  border: 2px solid var(--ink); border-radius: 4px; position: relative;
}
#hud button:hover { background: var(--note); }
#hud button.off { text-decoration: line-through; color: var(--mute); }
#hud button.new::after { content: ''; position: absolute; right: -5px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: var(--red); border: 2px solid var(--paper); }

/* what lands in the notebook */
#toasts { position: fixed; left: max(10px, calc((100vw - var(--stage)) / 2 + 10px)); top: max(64px, calc((100dvh - var(--stage) * 9 / 16) / 2 + 8%)); display: grid; gap: 6px; z-index: 7; width: min(340px, 70vw); pointer-events: none; }
.toast {
  text-align: left; font-family: var(--hand); font-size: 18px; line-height: 1.2; padding: 7px 11px 8px; background: var(--note);
  border: 2px solid var(--ink); border-radius: 2px; animation: drop .35s ease-out; transition: opacity .5s, transform .5s;
}
.toast span { display: block; font-family: var(--read); font-size: 11.5px; font-weight: 700; letter-spacing: .02em; color: var(--mute); }
.toast span:empty { display: none; }
.toast.map { background: var(--paper); }
.toast.out { opacity: 0; transform: translateX(-12px); }
@keyframes drop { from { opacity: 0; transform: translateY(-10px) rotate(-2deg); } }

/* the box at the bottom: storyteller, choices, people talking */
.panel {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: max(0px, calc((100dvh - var(--stage) * 9 / 16) / 2)); width: var(--stage); z-index: 5;
  padding: 0 clamp(8px, 1.4vw, 22px) clamp(8px, 1.4vw, 20px);
}
#caption { cursor: pointer; }
#caption .tx, #caption .opts, #talk .body {
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 6px; padding: clamp(10px, 1.3vw, 18px) clamp(14px, 1.8vw, 26px);
  font-size: clamp(16px, calc(var(--stage) * .0155), 22px); line-height: 1.45; box-shadow: 0 4px 0 rgba(29, 27, 46, .25);
}
#caption .tx { max-width: 980px; margin: 0 auto; max-height: 46dvh; overflow: auto; }
#caption.tell .tx { font-style: italic; padding-right: 3.4em; position: relative; }
#caption .next { right: 12px; bottom: 12px; font-style: normal; }
#caption p, #talk p { margin: 0 0 .55em; }
#caption p:last-child, #talk p:last-child { margin-bottom: 0; }
.next {
  position: absolute; right: clamp(20px, 2.6vw, 44px); bottom: clamp(16px, 2.2vw, 34px); width: 2.1em; height: 2.1em; border-radius: 50%; background: var(--ink); color: var(--paper);
  font-size: clamp(15px, calc(var(--stage) * .014), 20px); animation: nudge 1.2s ease-in-out infinite;
}
@keyframes nudge { 50% { transform: translateX(4px); } }
#caption.pick .tx { margin-bottom: 8px; font-weight: 600; }
#caption .opts { max-width: 980px; margin: 0 auto; display: grid; gap: 8px; background: none; border: 0; box-shadow: none; padding: 0; }
.opt, .topic {
  display: block; width: 100%; text-align: left; padding: .55em .9em; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 6px;
  font-size: clamp(16px, calc(var(--stage) * .0155), 21px); line-height: 1.3; font-weight: 600;
}
.opt:hover, .topic:hover, .opt:focus-visible, .topic:focus-visible { background: var(--note); }
.opt:disabled { opacity: .45; text-decoration: line-through; }

#talk { display: flex; align-items: flex-end; gap: clamp(6px, 1vw, 16px); }
#face { width: clamp(110px, calc(var(--stage) * .17), 260px); height: auto; flex: none; margin-bottom: -4px; filter: drop-shadow(0 3px 0 rgba(29, 27, 46, .25)); }
#talk.noface #face { display: none; }
#talk .body { flex: 1; min-width: 0; position: relative; max-height: 52dvh; display: flex; flex-direction: column; }
#talk .name { font-family: var(--hand); font-size: 1.25em; line-height: 1; margin-bottom: .35em; }
#talk .says { overflow: auto; padding-right: 2.6em; cursor: pointer; }
#talk .says:empty { display: none; }
#talk .topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 7px; overflow: auto; }
#talk .ask { grid-column: 1 / -1; font-size: .78em; color: var(--mute); }
.topic { font-size: clamp(15px, calc(var(--stage) * .0145), 20px); padding: .45em .8em; border-width: 2px; }
.topic.asked { font-weight: 400; color: var(--mute); border-color: #b9b3a4; }
.topic.leave, .topic.hint { font-weight: 400; border-style: dashed; }
#talk .next { right: 12px; bottom: 12px; }

/* big buttons */
.big {
  padding: .6em 1.3em; background: var(--ink); color: var(--paper); border-radius: 7px; font-weight: 700; font-size: 17px; border: 2.5px solid var(--ink);
}
.big:hover { background: #000; }
.big:disabled { background: #b9b3a4; border-color: #b9b3a4; cursor: default; }
.big.go { background: var(--go); border-color: var(--go); }
.quiet { padding: .6em 1em; border-radius: 7px; font-size: 16px; border: 2px solid #b9b3a4; background: var(--paper); }
.quiet:hover { border-color: var(--ink); }

/* a sheet of paper over everything: evidence, the council, the end */
#sheet, #end { position: fixed; inset: 0; z-index: 9; background: rgba(21, 19, 28, .72); overflow: auto; padding: clamp(10px, 3vw, 40px); display: grid; align-items: start; justify-items: center; }
.sheet {
  width: min(820px, 100%); background: var(--paper); border: 2.5px solid var(--ink); border-radius: 6px; padding: clamp(16px, 3vw, 34px); font-size: 17.5px; line-height: 1.5;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .3); margin: auto 0;
}
.sheet h2 { font-family: 'Fraunces', Georgia, serif; font-weight: 800; font-size: clamp(24px, 3.4vw, 34px); line-height: 1.12; margin: 0 0 .5em; }
.sheet h3 { font-size: 17px; margin: 1.6em 0 .4em; }
.sheet p { margin: 0 0 .7em; }
.sheet p.see { font-style: italic; }
.sheet .foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; }
.paper { margin: 14px 0; padding: 16px 20px; background: #fffdf4; border: 1.5px solid #cdbf98; box-shadow: 2px 3px 0 rgba(29, 27, 46, .12); transform: rotate(-.4deg); }
.paper.hand { font-family: var(--hand); font-size: 21px; line-height: 1.3; }
.paper.typed { font-family: 'Special Elite', 'Courier New', monospace; font-size: 16px; line-height: 1.55; transform: rotate(.3deg); }
.paper + .paper { transform: rotate(.6deg); background: #fff7d6; }
.paper + .paper + .paper { transform: rotate(-.8deg); background: #fffdf4; }
.tbl { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 16.5px; line-height: 1.35; }
.tbl th, .tbl td { text-align: left; vertical-align: top; padding: 6px 10px; border-bottom: 1.5px solid #ddd3b8; }
.tbl th { border-bottom: 2.5px solid var(--ink); }
.tbl.hand { font-family: var(--hand); font-size: 20px; background: #fffdf4; border: 1.5px solid #cdbf98; }
.tbl.hand th { font-family: var(--read); font-size: 14px; }

.readings { margin: 14px 0; padding: 16px; background: #eef3ee; border: 2.5px solid var(--ink); border-radius: 8px; }
.readings .where { font-weight: 700; margin-bottom: 8px; }
.meters { display: flex; gap: 14px; flex-wrap: wrap; }
.meter { flex: 1 1 230px; background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; padding: 10px 14px 12px; }
.meter .when { font-family: var(--hand); font-size: 21px; line-height: 1.1; margin-bottom: 4px; }
.dial { display: block; width: min(100%, 250px); margin: 0 auto; }
.dial text { font: 600 11px var(--read); fill: var(--ink); }
.needle { transform-origin: 100px 104px; transition: transform 1.3s cubic-bezier(.3, 1.5, .5, 1); }
.oxy { text-align: center; font-size: 15px; margin: 2px 0 8px; }
.oxy b { font-size: 34px; line-height: 1; margin-right: 5px; font-family: 'Fraunces', Georgia, serif; }
.mrow { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-top: 1.5px solid #ddd3b8; font-size: 15.5px; }
.mrow span:first-child { flex: 1; }
.strip { display: inline-flex; gap: 2px; }
.strip i { width: 15px; height: 20px; border: 1.5px solid var(--ink); background: #fff; }
.strip.food .on.n1 { background: #dcefc0; } .strip.food .on.n2 { background: #b4d98a; } .strip.food .on.n3 { background: #86bd58; } .strip.food .on.n4 { background: #5a9a3a; } .strip.food .on.n5 { background: #2f6f2a; }
.strip.dye .on.n1 { background: #c3d3fb; } .strip.dye .on.n2 { background: #8ba6f2; } .strip.dye .on.n3 { background: #5a7ce6; } .strip.dye .on.n4 { background: #3558d6; } .strip.dye .on.n5 { background: #1f3aa8; }
.look { display: flex; gap: 12px; padding: 6px 2px; border-top: 1.5px solid #cfd8cf; font-size: 16px; flex-wrap: wrap; }
.look span { flex: 0 0 130px; color: var(--mute); }
.look b { flex: 1 1 180px; font-weight: 600; }
.look em { font-style: normal; color: var(--mute); font-weight: 400; }
.rule { margin: 10px 0 0 !important; font-family: var(--hand); font-size: 19px; }

.graph { display: block; width: 100%; margin: 12px 0; background: #fffdf4; border: 2px solid var(--ink); border-radius: 6px; }
.graph .gl { font: 13px var(--read); fill: var(--mute); }
.graph .gl.red { fill: #c0492f; font-weight: 700; }
.graph .gv { font: 700 14px var(--read); fill: var(--ink); }
.gline { stroke-dasharray: 1; stroke-dashoffset: 1; animation: drawline 2.4s ease-out .4s forwards; }
@keyframes drawline { to { stroke-dashoffset: 0; } }

.photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 12px 0; }
.photos figure { margin: 0; background: #fff; border: 1.5px solid #cdbf98; padding: 8px 8px 10px; box-shadow: 2px 3px 0 rgba(29, 27, 46, .12); }
.photos figure:nth-child(odd) { transform: rotate(-1deg); } .photos figure:nth-child(even) { transform: rotate(1.2deg); }
.photos canvas { width: 100%; display: block; background: #cfe6ee; }
.photos figcaption { font-family: var(--hand); font-size: 18px; line-height: 1.2; margin-top: 6px; }

.jarrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.jar { display: grid; gap: 6px; justify-items: stretch; padding: 8px; border-radius: 8px; border: 2px solid #ddd3b8; background: #fff8dc; }
.jar.cold { background: #e3eef6; }
.jar svg { width: 100%; max-width: 110px; margin: 0 auto; }
.jar .water { fill: #d5ecee; transition: fill 1.6s; }
.jar[data-r=green] .water { fill: #7fa63a; }
.jar[data-r=tint] .water { fill: #c8dfae; }
.jar text { font: 700 16px var(--hand); fill: var(--ink); }
.jar .grains { fill: #8a6240; opacity: 0; }
.jar.fert .grains { opacity: 1; }
.jar button { font-size: 14px; line-height: 1.2; padding: 6px 4px; border: 2px solid var(--ink); border-radius: 5px; background: var(--paper); }
.jar button:hover { background: var(--note); }
.jarsay { min-height: 3em; margin-top: 12px; font-style: italic; }

/* the council */
.proof .step, .sheet .lead { color: var(--mute); font-size: 15px; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.pchip { padding: .4em .8em; background: #e9f0f7; border: 2px solid var(--ink); border-radius: 5px; font-size: 16px; }
.pchip.on { background: var(--ink); color: var(--paper); }
.why { color: #8a2f22; min-height: 1.4em; font-weight: 600; }
.write textarea { width: 100%; padding: 12px 14px; font: 18px/1.45 var(--read); border: 2.5px solid var(--ink); border-radius: 6px; background: #fffdf4; resize: vertical; }
blockquote { margin: 10px 0 16px; padding: 10px 16px; border-left: 4px solid var(--ink); background: #fffdf4; font-family: var(--hand); font-size: 21px; line-height: 1.3; }
blockquote p { margin: 0 0 .4em; }
.listening { font-style: italic; color: var(--mute); }
.voice { margin: 12px 0; padding: 10px 14px; background: #f7e9e4; border: 2px solid var(--ink); border-radius: 6px; }
.voice.june { background: #e8f1ea; }
.voice b { display: block; font-size: 14px; margin-bottom: 2px; }
.voice p { margin: 0; }
.links { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 4px; }
.links li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; border-radius: 4px; background: #eee7d3; font-size: 16px; }
.links li.yes { background: #dcecd8; font-weight: 600; }
.links span { color: var(--mute); font-weight: 400; }
.links li.yes span { color: var(--go); font-weight: 700; }

/* the notebook */
#book { position: fixed; inset: 0; z-index: 8; background: #2c2620; padding: clamp(0px, 1.2vw, 16px); }
.book { height: 100%; display: flex; flex-direction: column; background: #c9a36a; border: 3px solid var(--ink); border-radius: 8px; overflow: hidden; position: relative;
  background-image: radial-gradient(rgba(90, 60, 30, .18) 1.2px, transparent 1.4px); background-size: 9px 9px; }
.book header { display: flex; align-items: baseline; gap: 16px; padding: 10px 16px; background: var(--paper); border-bottom: 3px solid var(--ink); }
.book header h2 { margin: 0; font-family: 'Fraunces', Georgia, serif; font-size: 26px; }
.book header p { margin: 0; flex: 1; font-size: 15.5px; color: var(--mute); }
.book .cols { flex: 1; min-height: 0; display: flex; }
.book aside { flex: 0 0 min(250px, 30vw); overflow: auto; padding: 12px; background: rgba(251, 247, 234, .35); border-right: 2px solid rgba(29, 27, 46, .35); }
.book main { flex: 1; overflow: auto; padding: 12px 16px 30px; position: relative; }
.book h3 { margin: 10px 0 8px; font-family: var(--hand); font-size: 21px; font-weight: 400; color: #3a2a18; }
.book .none { font-size: 14.5px; color: #3a2a18; }
.row, .grid { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; position: relative; z-index: 1; }
.claim { flex: 0 1 240px; padding: 8px 12px 10px; background: #f6dcd6; border: 2px solid var(--ink); border-radius: 2px; font-style: italic; font-size: 15.5px; line-height: 1.3; }
.claim em { display: block; font-style: normal; font-family: var(--hand); font-size: 19px; color: var(--red); margin-top: 2px; transform: rotate(-2deg); }
.claim.out span { text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: var(--red); }
.claim.half em { color: #8a5a00; }
.slip { flex: 0 1 205px; text-align: left; padding: 8px 10px 10px; background: var(--note); border: 2px solid #8f7a2a; border-radius: 2px; font-family: var(--hand); font-size: 18.5px; line-height: 1.18; box-shadow: 1px 2px 0 rgba(29, 27, 46, .18); }
.slip:nth-child(3n) { transform: rotate(.7deg); } .slip:nth-child(3n+1) { transform: rotate(-.6deg); }
.slip:hover { background: #fff6a8; }
.slip.on, .chip.on .pick { outline: 3.5px solid var(--ink); outline-offset: 2px; background: #fff; }
.slip.k-conclusion { background: #dcecd0; border-color: #4f7a3c; font-family: var(--read); font-size: 15.5px; font-weight: 700; line-height: 1.25; flex-basis: 240px; }
.slip.fresh, .chip.fresh .pick { box-shadow: 0 0 0 3px var(--red); }
.chip { display: flex; gap: 4px; margin-bottom: 7px; }
.chip .pick { flex: 1; text-align: left; padding: 6px 8px; background: #e6eef7; border: 2px solid var(--ink); border-radius: 3px; font-size: 14.5px; line-height: 1.2; }
.chip .read { padding: 0 8px; font-size: 13px; border: 2px solid var(--ink); border-radius: 3px; background: var(--paper); }
.chip .read:hover, .chip .pick:hover { background: var(--note); }
.threads { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 0; }
.threads path { stroke: var(--red); stroke-width: 2; opacity: .16; fill: none; }
.threads circle { fill: var(--red); opacity: .3; }
.threads g.hot path { opacity: .95; stroke-width: 3; }
.threads g.hot circle { opacity: 1; }
.book footer { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--paper); border-top: 3px solid var(--ink); flex-wrap: wrap; }
.book footer .count { font-family: var(--hand); font-size: 20px; min-width: 5.5em; }
.book footer .go { margin-left: auto; }
.think { position: absolute; inset: 0; background: rgba(21, 19, 28, .6); display: grid; place-items: center; padding: 16px; z-index: 3; }
.think .card { width: min(600px, 100%); background: var(--paper); border: 2.5px solid var(--ink); border-radius: 8px; padding: 22px; display: grid; gap: 10px; font-size: 17.5px; }
.think .card p { margin: 0; }
.think .opt { font-size: 17px; }

/* the title */
#title { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: linear-gradient(rgba(21, 19, 28, .1), rgba(21, 19, 28, .55)); opacity: 0; transition: opacity .6s; }
#title.ready { opacity: 1; }
.tt { text-align: center; color: #fff; max-width: 660px; text-shadow: 0 2px 12px rgba(21, 19, 28, .8); }
.tt h1 { font-family: 'Fraunces', Georgia, serif; font-weight: 800; font-size: clamp(54px, 11vw, 132px); line-height: .95; margin: 0 0 .15em; letter-spacing: -.01em; }
.tt p { font-size: clamp(17px, 2.2vw, 23px); line-height: 1.4; margin: 0 0 1.4em; }
.tt .go { display: flex; gap: 12px; justify-content: center; }
.tt button { padding: .55em 1.6em; font-size: 21px; font-weight: 700; background: var(--paper); color: var(--ink); border: 2.5px solid var(--ink); border-radius: 8px; text-shadow: none; }
.tt button:hover { background: var(--note); }
.tt small { display: block; margin-top: 1.4em; font-size: 14px; opacity: .85; }

/* held upright: the picture on top, the words underneath */
@media (orientation: portrait) {
  #app { justify-content: flex-start; }
  .panel { position: static; transform: none; width: 100%; flex: 1; min-height: 0; overflow: auto; padding: 8px; }
  #talk { align-items: flex-start; }
  #talk .body { max-height: none; }
  #caption .tx { max-height: none; }
  #face { width: 86px; }
  #hud { top: 6px; right: 6px; gap: 4px; }
  #hud button { font-size: 14px; padding: .3em .5em .34em; }
  #toasts { top: 44px; left: 6px; }
  #placename { top: auto; bottom: 3%; }
  .book aside { flex-basis: 34vw; }
  .jarrow { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .spot i, .mapspot i, .next { animation: none; }
}
