:root{color-scheme:light;--page:#f7f3e8;--card:#fffdf6;--ink:#142f41;--sub:#4e5c60;--amber:#d7a949;--line:#cfc8b6;--sea:#1c4854;font-family:"Source Sans 3","Segoe UI",Arial,sans-serif;color:var(--ink);background:var(--page)}
*{box-sizing:border-box}
body{margin:0;min-height:100vh;background:radial-gradient(ellipse at 75% 20%,#fffaf0 0,transparent 53%),var(--page)}
a{color:inherit;text-underline-offset:4px}
button,input{font:inherit}
button,.mast a{touch-action:manipulation}
button{color:var(--ink);cursor:pointer}
button:disabled{cursor:default}
button:focus-visible,a:focus-visible,input:focus-visible{outline:3px solid #ae480b;outline-offset:4px}
.skip,.sr{position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden}
.skip:focus{width:auto;height:auto;clip-path:none;z-index:6;background:white;padding:1rem}
.mast{border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.65rem clamp(1rem,5vw,5rem);min-height:68px}
.brand{font:600 clamp(1rem,2vw,1.35rem) Georgia,serif;text-decoration:none}
.brand span{color:#8d5827;font-size:1.6em;vertical-align:middle;margin-right:.28em}
.mast nav{display:flex;align-items:center;gap:1.15rem;font-size:.92rem}
.mast nav a{display:inline-flex;align-items:center;min-height:44px}
.mast nav button{border:1px solid var(--line);border-radius:3px;background:none;padding:.55rem .85rem;min-height:44px}
[hidden]{display:none!important}
#save-notice{padding:.7rem 5%;background:#fee4a2}
main{max-width:1440px;margin:auto;padding:clamp(1.35rem,5vw,4.8rem) clamp(1.05rem,5vw,5rem);outline:none}
h1,h2,p,figure{margin:0}
h1,h2{font-family:"Baskervville","Book Antiqua",Georgia,serif;font-weight:500;line-height:1.06;text-wrap:balance}
h1 em{color:var(--sea);font-weight:400}
.kicker{text-transform:uppercase;font-weight:700;color:#74501d;font-size:.76rem;letter-spacing:.1em;line-height:1.5}
.welcome{display:grid;grid-template-columns:minmax(0,.82fr) minmax(0,1.3fr);gap:clamp(1.5rem,4vw,4rem);align-items:center}
.welcome h1{font-size:clamp(3rem,5.8vw,6.2rem);letter-spacing:-.05em;line-height:.99;margin:1.05rem 0 1.25rem}
.welcome h1 em{display:block}
.welcome-copy p{max-width:32ch;font-size:clamp(1.05rem,1.4vw,1.3rem);line-height:1.5;color:var(--sub);margin-bottom:1.8rem}
.primary,.board-btn,.quiet,.plain,.tools button{border-radius:5px;min-height:46px;padding:.66rem 1rem;font-weight:650;border:1px solid var(--line);background:var(--card)}
button:not(:disabled):hover{filter:brightness(.94)}
.primary,.board-btn{background:var(--ink);color:white;border-color:var(--ink)}
.primary{padding:.8rem 1.35rem}
.primary span{margin-left:.7rem}
.welcome small{display:block;color:var(--sub);font-size:.86rem;margin-top:1rem}
.cover{position:relative;background:#f0e4ce;border:1px solid #9c8b6e;padding:7px;box-shadow:0 7px 16px #3f2e2215;transform:rotate(-.65deg)}
.cover img{width:100%;display:block;aspect-ratio:1.35;object-fit:cover}
.route{display:grid;grid-template-columns:repeat(4,1fr);border-block:1px solid var(--line);margin-top:clamp(2rem,6vw,5.6rem);padding:1rem 0;gap:.7rem}
.route div{display:flex;gap:.7rem;align-items:center;font:500 1.08rem Georgia,serif}
.route svg{width:44px;height:44px;flex:none}
.work{max-width:1050px;margin:0 auto}
.work-head{display:flex;gap:1rem;align-items:center;justify-content:space-between;margin-bottom:1rem}
.work h1,.interlude h1,.ending h1{font-size:clamp(2.05rem,4.6vw,4.4rem);letter-spacing:-.04em;margin:.25rem 0}
.whale-card{text-align:center;width:145px;flex:none}
.whale-card svg{display:block;width:100%;max-height:72px}
.whale-card figcaption{font-size:.76rem;color:var(--sub)}
.bench{border-radius:9px;border:1px solid #baa988;background:#eee2cd;box-shadow:0 4px 13px #3e29110f;overflow:hidden}
.bench-top{display:flex;align-items:center;justify-content:space-between;gap:1rem;background:var(--card);padding:.9rem clamp(.8rem,3vw,2rem);border-bottom:1px solid #c3b497}
.bench-top h2{font-size:clamp(1.25rem,2.7vw,1.9rem)}
.bench-top span{white-space:nowrap;font-size:.85rem;letter-spacing:.1em;color:#48606b}
.playing{display:grid;align-content:center;justify-items:center;gap:1.2rem;min-height:280px;padding:clamp(1rem,3vw,2rem);background:repeating-linear-gradient(4deg,transparent 0 28px,#c8b58d18 29px 30px),radial-gradient(ellipse at 50% 10%,#faf2de,transparent 80%)}
.token{min-width:46px;min-height:46px;display:grid;place-items:center;border:1px solid #b1a68d;background:var(--card);border-radius:7px;position:relative;overflow:hidden;box-shadow:0 3px 0 #876d4e3b;transition:transform .14s,background-color .16s}
.token svg,.zoomed svg,.film svg,.demo svg,.signal svg,.signature svg,.parade-stage svg{width:100%;height:100%;display:block}
.token.chosen{outline:3px solid #22617a;outline-offset:2px;background:#fff3ce;transform:translateY(-2px)}
.tray,.intro-props,.sockets,.switches,.signal{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:clamp(.4rem,1.7vw,1.1rem)}
.tray .token,.switches .token,.sockets .token{width:clamp(56px,10vw,96px);aspect-ratio:1;padding:.45rem}
.intro-props .token{width:clamp(58px,15vw,128px);aspect-ratio:1;padding:.45rem}
.token.used{opacity:.29;box-shadow:none}
.sockets .empty{background:#d4c6a6;border:2px dashed #736c5e}
.sockets .empty svg{opacity:.72}
.shapes .sockets .empty svg{filter:grayscale(1) contrast(1.25)}
.slot.set,.token.paired,.token.lit,.signal .lit{border:2px solid #426951;background:#f8ebbc}
.window-rack{background:#24485a;border-radius:2rem;padding:.8rem}
.puzzle-board{display:grid;grid-template-columns:repeat(var(--cols),1fr);width:min(100%,min(380px,50vh));aspect-ratio:1.5;border:3px solid #775d38;gap:1px;background:#8d795d}
.puzzle-board .slot{padding:0;width:100%;height:100%;border:0;border-radius:0;box-shadow:none;min-height:0;min-width:0}
.puzzle-board .slot.empty svg{opacity:.21}
.puzzle .tray .token{width:clamp(52px,7vw,78px);aspect-ratio:1.15;padding:0;border-radius:4px}
.memory-board{display:grid;grid-template-columns:repeat(4,minmax(0,94px));gap:.7rem;justify-content:center;width:min(100%,420px)}
.memory-board:has(>:last-child:nth-child(6)){grid-template-columns:repeat(3,minmax(0,94px))}
.memory-board .token{aspect-ratio:1.1;min-width:0}
.memory-board .back{background:#294a58;color:#fbda92;border:4px double #a5977c}
.card-back{font:2.6rem Georgia,serif}
.album{display:flex;align-items:center;justify-content:center;gap:clamp(.3rem,2vw,1.1rem);padding:.1rem;max-width:100%}
.arrow{width:46px;height:48px;background:var(--card);border:1px solid #988b74;border-radius:50%;font-size:2rem;line-height:1;flex:none}
.print{border:1px solid #a59376;background:#fff7e6;padding:6px 6px 14px;width:clamp(100px,32vw,285px);box-shadow:0 3px 8px #46301924;transform:rotate(-1.1deg)}
.print svg{width:100%;display:block}
.film{display:flex;gap:.4rem;justify-content:center}
.film span{display:grid;place-items:center;background:#f4ead7;color:#715d42;width:clamp(55px,9vw,93px);aspect-ratio:1.5;border:1px dashed #897e6b;border-radius:2px}
.film span.filled{border-style:solid}
.strip-label{font-size:.9rem;font-weight:650}
.signal{gap:.3rem;background:var(--card);padding:.5rem;border:1px solid #ae9e7e}
.signal span{position:relative;width:clamp(37px,8vw,60px);aspect-ratio:1;border:1px solid transparent}
.signal b{position:absolute;right:-2px;bottom:-4px;color:white;background:#356048;border-radius:50%;padding:.02rem .3rem}
.bar,.bottom,.tools,.end-actions{display:flex;align-items:center;gap:.6rem;flex-wrap:wrap}
.bar{justify-content:space-between;min-height:52px;margin:.6rem 0}
.feedback{color:#31544d;font-weight:600}
.bottom{justify-content:space-between}
.tools button:disabled{opacity:.55}
.plain{background:none;border:0;text-decoration:underline}
.interlude,.ending{max-width:880px;margin:0 auto;text-align:center}
.interlude{max-width:610px;background:var(--card);border:1px solid var(--line);padding:clamp(1rem,4vw,3rem);border-radius:7px}
.interlude p{margin:1rem}
.interlude .whale-card,.signature{width:min(100%,420px);margin:1rem auto}
.interlude .whale-card svg{max-height:none}
.signature{height:145px}
.interlude label,.interlude legend{font-weight:650;font-size:.9rem}
.interlude input{display:block;margin:.4rem auto .7rem;padding:.65rem;border:1px solid #968971;border-radius:3px;background:white;max-width:100%}
.patterns{display:flex;justify-content:center;gap:.5rem;border:0;padding:.5rem;margin:.5rem 0 1rem}
.patterns .token{width:55px;height:55px}
.ending h1{margin:1rem 0}
.parade-stage{position:relative;overflow:hidden;width:100%;min-width:0;grid-template-columns:minmax(0,1fr);min-height:0;aspect-ratio:2.65;background:linear-gradient(170deg,#132b48,#315263 65%,#c49064);border:6px double #dfc18e;border-radius:8px;display:grid;place-items:center}
.parade-stage:before{content:"";position:absolute;inset:0;background-image:radial-gradient(ellipse at center,#f8d48c 1px,transparent 2px);background-size:51px 45px;opacity:.6}
.parade-stage svg{width:76%;height:85%;filter:drop-shadow(0 6px 9px #101f3080);position:relative;animation:float 6s ease-in-out infinite alternate}
@keyframes float{from{transform:translate(-5%,4%) rotate(-1.8deg)}to{transform:translate(5%,-4%) rotate(1.8deg)}}
.end-actions{justify-content:center;margin:1rem}
dialog{border:1px solid #a4977c;border-radius:10px;width:min(92vw,570px);max-height:88vh;overflow:auto;padding:clamp(1rem,4vw,2rem);background:var(--card);color:var(--ink)}
dialog::backdrop{background:#102733b0}
dialog h2{font-size:clamp(1.6rem,4vw,2.25rem);margin:.1rem 0 .65rem}
dialog p{margin:.5rem 0;line-height:1.5}
dialog form{margin-top:1rem}
.souvenir{width:100%;border:4px solid #f2e6cb}
.zoomed,.demo{display:flex;gap:.65rem;align-items:center;justify-content:center;background:#eee3cf;border-radius:6px;padding:1rem;margin:.8rem 0;min-height:130px}
.zoomed>svg{max-height:265px}
.zoomed figure{width:33%;text-align:center}
.zoomed figcaption{font-size:.8rem}
.demo span{width:32%;border:2px solid #a89b7a;border-radius:6px;background:var(--card);padding:.35rem}
.demo span:first-child{animation:example-a 3.5s infinite}
.demo span:last-child{animation:example-b 3.5s infinite}
@keyframes example-a{0%,40%{box-shadow:0 0 0 4px #be8f3c}60%,100%{box-shadow:none}}
@keyframes example-b{0%,40%{box-shadow:none}60%,100%{box-shadow:0 0 0 4px #2a6774}}
.chap-list{padding-left:1.5rem}
.chap-list li{padding:.4rem;border-bottom:1px solid var(--line)}
.chap-list strong{float:right;font-size:.8rem}
@media(max-width:700px){.parade-stage{aspect-ratio:1.85}.welcome{grid-template-columns:1fr}.cover{grid-row:1}.cover img{aspect-ratio:2.15}.welcome-copy{max-width:35rem}.welcome h1 em{display:inline}.route{grid-template-columns:1fr 1fr}.work-head{gap:.45rem}.whale-card{width:90px}.mast{min-height:54px}.mast nav{gap:.6rem}.mast nav a{font-size:.82rem}.work h1{font-size:clamp(1.7rem,6vw,2.5rem)}.playing{min-height:235px}.bar{min-height:44px}.route div{font-size:.95rem}}
@media(max-width:390px){.mast{padding:.45rem .65rem;gap:.3rem}.brand{font-size:.92rem}.brand span{display:none}.mast nav{gap:.35rem}.mast nav button{padding:.35rem}.work-head .whale-card{width:62px}.work-head .whale-card figcaption{font-size:.65rem}.playing{padding:.8rem .45rem}.tools{gap:.25rem}.tools button{padding:.45rem .6rem;font-size:.88rem}.route svg{width:32px;height:32px}.memory-board{gap:.45rem}.signal{gap:.13rem}.welcome small{font-size:.8rem}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}
.lab-options,.lab-sequence{display:flex;flex-wrap:wrap;justify-content:center;gap:.5rem;align-items:center;margin:1rem 0}
.lab-options .token{width:clamp(50px,12vw,76px);aspect-ratio:1;line-height:1}
.lab-options.wide .token{width:clamp(90px,18vw,115px);aspect-ratio:1.5}
.lab-sequence svg{width:clamp(28px,8vw,59px);height:42px}
.lab-model{margin:auto;width:min(48%,180px)}
.lab-model svg{width:100%}
.lab-puzzle{margin:0 auto;width:min(65%,280px);aspect-ratio:1.5}
.lab-puzzle .token{width:100%;height:100%;padding:0;min-width:0;min-height:0;border-radius:1px}
.lab-feedback{font-weight:650;color:var(--sea)}
