:root {
  --paper: #f2ecdf;
  --paper-2: #faf6ee;
  --ink: #1d1a14;
  --ink-2: #3d382e;
  --muted: #6b6354;
  --rule: #d9cfbb;
  --grid: rgba(29, 26, 20, .045);
  --deck: #1d1a14;
  --display: 'Gloock', Georgia, serif;
  --body: 'Newsreader', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --good: #2e7d4f;
  --bad: #c0392b;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(17px, 1.2vw, 21px);
  line-height: 1.5;
  display: grid;
  grid-template-rows: 60px 1fr 64px;
  overflow: hidden;
}
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .1 0 0 0 0 .08 0 0 0 0 .05 0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
button { font: inherit; color: inherit; }
kbd { font-family: var(--mono); font-size: .72em; border: 1px solid currentColor; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; opacity: .8; }

/* ---- chrome ---- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid var(--rule); background: color-mix(in srgb, var(--paper) 88%, transparent); }
.brand { background: none; border: 0; cursor: pointer; font-family: var(--display); font-size: 19px; padding: 0; }
.brand em { font-family: var(--body); font-style: italic; color: var(--muted); }
.where { display: flex; gap: 12px; align-items: baseline; }
:root { --deck-text: color-mix(in srgb, var(--deck) 68%, #000); }
#deck-tag { font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--deck-text); }
#deck-title { font-family: var(--body); font-style: italic; color: var(--ink-2); }
.mapbtn { background: none; border: 1.5px solid var(--ink); border-radius: 999px; padding: 4px 14px; cursor: pointer; font-family: var(--mono); font-size: 13px; }
.mapbtn:hover { background: var(--ink); color: var(--paper); }
.bottom { display: flex; align-items: center; justify-content: center; gap: 22px; border-top: 1px solid var(--rule); }
.nav { width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--paper-2); cursor: pointer; font-family: var(--mono); font-size: 18px; box-shadow: 2px 2px 0 var(--ink); }
.nav:hover:not(:disabled) { background: var(--deck); color: var(--paper-2); }
.nav:disabled { opacity: .18; cursor: default; box-shadow: none; }
.nav.locked { border-style: dashed; box-shadow: none; color: var(--muted); }
.nav.tomap { width: auto; padding: 0 16px; border-radius: 999px; font-size: 13px; background: var(--ink); color: var(--paper-2); }
.dots { display: flex; gap: 2px; align-items: center; }
.dot { --fill: transparent; --ring: var(--ink); width: 25px; height: 25px; padding: 0; border: 0; border-radius: 50%; background: radial-gradient(circle at center, var(--fill) 0 5px, var(--ring) 5px 6.5px, transparent 7px); cursor: pointer; transition: transform .2s; }
.dot.reached { --fill: color-mix(in srgb, var(--deck) 30%, transparent); }
.dot.on { --fill: var(--deck); --ring: var(--deck); transform: scale(1.3); }
.dot:disabled { opacity: .3; cursor: default; }
.dot:hover:not(:disabled) { transform: scale(1.3); }

/* ---- slides ---- */
#stage { overflow-y: auto; overflow-x: hidden; position: relative; }
.slide { min-height: 100%; padding: 4vh 6vw; display: flex; flex-direction: column; justify-content: center; }
.slide.center { align-items: center; }
.slide.center > .col { max-width: 820px; width: 100%; }
.slide.split { display: grid; grid-template-columns: minmax(320px, 5fr) 7fr; gap: 5vw; align-items: center; }
.slide.wide > .wrap { max-width: 1180px; width: 100%; margin: 0 auto; }
.enter { animation: slideIn .5s cubic-bezier(.2, .75, .2, 1) both; }
.enter.back { animation-name: slideBack; }
@keyframes slideIn { from { opacity: 0; translate: 22px 0; } }
@keyframes slideBack { from { opacity: 0; translate: -22px 0; } }
#stage.fitted { overflow: hidden; }
.reveal { animation: fadeUp .55s cubic-bezier(.2, .75, .2, 1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }

h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0 0 .45em; letter-spacing: -.005em; }
h1 { font-size: clamp(40px, 4.3vw, 70px); line-height: 1.03; }
h2 { font-size: clamp(30px, 2.9vw, 48px); line-height: 1.08; }
h3 { font-size: 1.35em; }
p { margin: 0 0 .75em; max-width: 38em; }
.kicker { font-family: var(--mono); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--deck-text); margin-bottom: 1em; }
.lede { font-size: 1.1em; color: var(--ink-2); }
.muted { color: var(--muted); }
.note { font-size: .92em; color: var(--ink-2); }
.small { font-size: .85em; }
.mono, code { font-family: var(--mono); font-size: .82em; }
mark { background: linear-gradient(transparent 55%, color-mix(in srgb, var(--deck) 30%, transparent) 55%); color: inherit; padding: 0 .1em; }
.hidden { display: none !important; }
.gate-hint, .try-hint { font-family: var(--mono); font-size: 13px; color: var(--deck-text); letter-spacing: .02em; }
.try-hint { color: var(--muted); }
.nudge { animation: nudge .45s; }
@keyframes nudge { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* ---- components ---- */
.demo { background: var(--paper-2); border: 1.5px solid var(--ink); border-radius: 14px; box-shadow: 6px 6px 0 var(--ink); padding: 22px; position: relative; }
.btn { font-family: var(--mono); font-size: 14px; background: var(--paper-2); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 10px; padding: 9px 16px; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; transition: transform .08s, box-shadow .08s, background .15s; }
.btn:hover:not(:disabled) { background: #fff; }
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn.small { font-size: 12.5px; padding: 6px 12px; min-height: 28px; box-shadow: 2px 2px 0 var(--ink); }
.btn.primary { background: var(--deck-text); color: var(--paper-2); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--deck) 55%, #000); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.chosen, .btn.chosen:hover:not(:disabled) { background: var(--ink); color: var(--paper-2); }
.btn.correct { background: var(--good); color: #fff; border-color: var(--good); }
.btn.wrong { text-decoration: line-through; opacity: .6; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

input[type=range] { accent-color: var(--deck); width: 100%; cursor: pointer; }
.textin { font-family: var(--mono); font-size: 22px; padding: 6px 12px; border: 1.5px solid var(--ink); border-radius: 8px; background: #fff; width: 7.5ch; }

.door { display: flex; flex-direction: column; gap: 1px; text-decoration: none; color: var(--ink); background: var(--paper-2); border: 1.5px solid var(--ink); border-left: 9px solid var(--door, var(--ink)); border-radius: 10px; padding: 11px 42px 12px 14px; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; transition: transform .12s, box-shadow .12s; position: relative; }
.door:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.door b { font-family: var(--display); font-weight: 400; font-size: 1.12em; line-height: 1.2; }
.door > span:not(.door-tag) { font-size: .88em; color: var(--ink-2); line-height: 1.35; }
.door-tag { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: color-mix(in srgb, var(--door) 68%, #000); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doors { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; margin-top: 18px; }
.door::after { content: '→'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-family: var(--mono); transition: right .12s; }
.door:hover::after { right: 10px; }
.door.seen .door-tag::after { content: '  ✓ explored'; color: var(--muted); }
.door.soon { border-style: dashed; border-left-style: solid; box-shadow: none; opacity: .62; }
.door.soon:hover { transform: none; }
.link-door { color: inherit; text-decoration: none; border-bottom: 2.5px solid var(--door, var(--deck)); cursor: pointer; font-weight: 600; }
.link-door::after { content: ' ↗'; font-family: var(--mono); font-size: .75em; color: var(--door); }
.link-door:hover { background: color-mix(in srgb, var(--door) 16%, transparent); }
.link-door.soon { border-bottom-style: dashed; }

/* ---- map ---- */
.map { position: fixed; inset: 0; background: rgba(29, 26, 20, .5); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; animation: fadeUp .25s both; }
.map-inner { background: var(--paper); border: 1.5px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); border-radius: 16px; width: min(1080px, 94vw); max-height: 94vh; padding: 18px 26px 10px; display: flex; flex-direction: column; }
.map-head { display: flex; justify-content: space-between; align-items: flex-start; }
.map-head h2 { margin: 0; font-size: 32px; }
.map-head p { font-size: 14px; color: var(--muted); margin: 0; }
#mapsvg { width: 100%; height: auto; max-height: 80vh; }
.band rect.even { fill: rgba(29, 26, 20, .035); }
.band rect.odd { fill: transparent; }
.band text { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; fill: var(--muted); }
.map .colhead { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; fill: var(--muted); }
.edge { stroke: var(--rule); stroke-width: 2.5; fill: none; stroke-dasharray: 5 6; }
.edge.walked { stroke: var(--ink); stroke-dasharray: none; }
.node { cursor: pointer; outline: none; }
.node .disc { fill: var(--paper-2); stroke: var(--c); stroke-width: 3.5; transition: stroke-width .15s; }
.node.started .disc { fill: color-mix(in srgb, var(--c) 30%, var(--paper-2)); }
.node.done .disc { fill: var(--c); }
.node .tick { stroke: #fff; stroke-width: 2.5; fill: none; }
.node.soon { opacity: .42; }
.node.soon .disc { stroke-dasharray: 4 3; }
.node:hover .disc { stroke-width: 6; }
.node:focus-visible .disc { stroke: var(--ink); stroke-width: 6; }
.node .ring { fill: none; stroke: var(--c); stroke-width: 3; }
.node text { paint-order: stroke; stroke: var(--paper); stroke-width: 5px; stroke-linejoin: round; }
.node .t1 { font-family: var(--display); font-size: 17px; fill: var(--ink); }
.node .t2 { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; fill: var(--muted); }
.node .you { font-family: var(--mono); font-size: 11px; fill: var(--c); font-weight: 600; }
.node .pulse { fill: none; stroke: var(--c); stroke-width: 2; animation: pulse 1.6s infinite; }
@keyframes pulse { from { r: 18px; opacity: .9; } to { r: 36px; opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 12px); background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 13.5px; padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .slide.split { grid-template-columns: 1fr; }
  .where { display: none; }
}


/* ================= identity layer ================= */
:root { --photon: #ffc53d; }
.mono, code, .x-ribbon, #map-progress { font-variant-numeric: tabular-nums; }

/* Signal-trace headlines: the room's name in bits, with a photon riding the wire. */
.x-trace { display: block; height: 15px; width: auto; max-width: 100%; margin: -.45em 0 .1em; pointer-events: none; }

/* The 300 ms ribbon: where this room sits inside the one request. */
.bottom { position: relative; }
.x-ribbon { position: absolute; left: 28px; top: 50%; transform: translateY(-50%); width: 300px; font-family: var(--mono); }
.x-ribbon .strip { display: flex; height: 12px; border: 1.5px solid var(--ink); border-radius: 3px; overflow: hidden; background: var(--paper-2); }
.x-ribbon .strip button { display: block; height: 100%; opacity: .22; border: 0; border-right: 1px solid var(--paper-2); padding: 0; cursor: pointer; transition: opacity .15s; }
.x-ribbon .strip button:hover { opacity: .7; }
.x-ribbon .strip button.on { opacity: 1; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.x-ribbon .strip.floor { height: 5px; margin-top: 2px; border-width: 1px; background: repeating-linear-gradient(135deg, var(--ink) 0 1px, transparent 1px 4px); opacity: .25; }
.x-ribbon .strip.floor.on { opacity: 1; background: repeating-linear-gradient(135deg, var(--deck) 0 1.5px, transparent 1.5px 4px); }
.x-ribbon .lab { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: .06em; color: var(--muted); margin-top: 3px; text-transform: uppercase; }
.x-ribbon .lab b { color: var(--deck-text); font-weight: 600; }
.x-ribbon .head { position: absolute; top: -4px; width: 2px; height: 20px; background: var(--ink); pointer-events: none; }
.x-ribbon .head::after { content: ''; position: absolute; left: -3px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--photon); border: 1.5px solid var(--ink); }
@media (max-width: 1000px) { .x-ribbon { display: none; } }

/* Postmarks: settled bets get cancelled like stamps. api.stamp(anchor, {value}). */
.x-stamp { --sc: var(--deck-text); position: relative; display: inline-grid; place-items: center; width: 100px; height: 100px; border-radius: 50%; white-space: nowrap;
  color: var(--sc); border: 2.5px solid var(--sc); box-shadow: inset 0 0 0 5px var(--paper-2), inset 0 0 0 6.5px var(--sc);
  font-family: var(--mono); text-transform: uppercase; text-align: center; rotate: -11deg; mix-blend-mode: multiply;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -2.2 1.9'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 -2.2 1.9'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
  animation: x-thunk .32s cubic-bezier(.3,1.6,.5,1) both; }
.x-stamp .t { font-size: 11px; letter-spacing: .12em; line-height: 1.2; }
.x-stamp .v { display: inline-block; font-family: var(--display); font-weight: 400; text-transform: none; font-size: var(--vs, 22px); line-height: 1; margin: 3px 0; letter-spacing: -.01em; white-space: nowrap; }
@keyframes x-thunk { from { scale: 1.6; opacity: 0; } }
.x-betstamp { position: absolute; right: -14px; top: -26px; z-index: 5; pointer-events: none; }

/* Map as a cross-section: paper darkens as you descend to the sea floor. */
.band text.light { fill: #dfe7ea; }
.deco .sealine { fill: none; stroke: #efe6d2; stroke-width: 2; opacity: .8; }
.deco .sealabel { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; fill: #dfe7ea; }
.deco .cable { fill: none; stroke: #b0602a; stroke-width: 3; }
.deco .cablepulse { fill: none; stroke: var(--photon); stroke-width: 2.5; stroke-dasharray: 5 120; filter: drop-shadow(0 0 4px var(--photon)); animation: x-cable 4s linear infinite; }
@keyframes x-cable { to { stroke-dashoffset: -625; } }
.edge.walked { stroke: #9c7a45; }
.node.x-dark .t1 { fill: #efe6d2; }
.node.x-dark .t2 { fill: #b9c6cb; }
.node.x-dark text { stroke: var(--bandc); }

@media (prefers-reduced-motion: reduce) {
  .x-stamp, .deco .cablepulse, .enter, .reveal { animation: none; }
}

/* Night shift: the bottom floor is below sea level. A deck opts in with theme: 'night'. */
html[data-theme=night] {
  --paper: #0e1820; --paper-2: #14222c; --ink: #efe6d2; --ink-2: #cfc6b2; --muted: #9aa7ad; --rule: #2a3a46;
  --grid: rgba(239, 230, 210, .035); --deck-text: color-mix(in srgb, var(--deck) 55%, #fff);
}
html[data-theme=night] body { background-image:
  radial-gradient(120% 60% at 50% 115%, rgba(47, 95, 167, .28), transparent 70%),
  linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100% 100%, 28px 28px, 28px 28px; }
html[data-theme=night] body::after { mix-blend-mode: screen; opacity: .25; }
html[data-theme=night] .top { background: color-mix(in srgb, var(--paper) 88%, transparent); }
html[data-theme=night] .demo { box-shadow: 6px 6px 0 #04080b; }
html[data-theme=night] .btn { box-shadow: 3px 3px 0 #04080b; }
html[data-theme=night] .btn.small { box-shadow: 2px 2px 0 #04080b; }
html[data-theme=night] .door, html[data-theme=night] .nav { box-shadow: 3px 3px 0 #04080b; }
html[data-theme=night] .btn:hover:not(:disabled) { background: #1c2d39; }
html[data-theme=night] .textin { background: #0b141b; color: var(--ink); }
html[data-theme=night] .btn.primary { color: #0e1820; background: color-mix(in srgb, var(--deck) 70%, #fff); }
html[data-theme=night] .x-stamp { mix-blend-mode: screen; }
html[data-theme=night] #stage::after { content: ''; position: fixed; left: 0; right: 0; bottom: 64px; height: 26px; pointer-events: none; z-index: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='1440' height='26' preserveAspectRatio='none'><path d='M0,14 C240,6 420,22 720,12 S1180,6 1440,15' fill='none' stroke='%23b0602a' stroke-width='3'/></svg>") no-repeat center / 100% 100%; opacity: .7; }
html[data-theme=night] .btn.chosen:hover:not(:disabled) { background: var(--ink); color: var(--paper-2); }
