*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden;overscroll-behavior:none}body{color:#34483d;background:#c9c7b7;font-family:system-ui,-apple-system,sans-serif;background-image:repeating-linear-gradient(0deg,transparent,transparent 3px,#fff2d913 4px)}button,select{font:inherit}button{min-height:40px;border:1px solid #b9bba5;border-radius:12px;background:#f6efde;color:#354d40;padding:8px 12px;font-size:12px;cursor:pointer;touch-action:manipulation}button:disabled{opacity:.4}button:focus-visible,canvas:focus-visible,select:focus-visible{outline:3px solid #98623b;outline-offset:2px}#app{height:var(--app-height,100dvh);padding:max(8px,env(safe-area-inset-top)) max(10px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));display:grid;grid-template-rows:56px minmax(0,1fr);gap:8px;max-width:1800px;margin:auto}header{display:flex;justify-content:space-between;align-items:center;padding:0 10px}h1{font-size:25px;letter-spacing:.12em;margin:0;font-family:serif;color:#704e3a}header small{font-size:9px;letter-spacing:.12em}nav{display:flex;gap:7px}main{display:grid;grid-template-columns:minmax(0,1fr) 245px;gap:12px;min-height:0}.board-wrap{position:relative;min-height:0;min-width:0;border:1px solid #9b9d87;border-radius:28px;overflow:hidden;background:radial-gradient(ellipse,#c7cbbb,#b4bcaa);box-shadow:inset 0 0 0 5px #dfd6bf}canvas{display:block;width:100%;height:100%;touch-action:none;cursor:grab}.zoom{position:absolute;bottom:12px;left:50%;transform:translateX(-50%);display:flex;align-items:center;gap:5px;padding:5px;border-radius:16px;background:#efe6d7eb;border:1px dashed #b9a589}.zoom button{min-width:40px;padding:6px 9px}.zoom span{font-size:10px;min-width:35px;text-align:center}.panel{align-self:center;border:1px solid #acac94;outline:1px dashed #c0b49b;outline-offset:-6px;border-radius:22px;background:#f2ead9;padding:20px;position:relative}#turn{font-size:19px;font-family:serif;min-height:25px}.score{display:flex;justify-content:space-between;gap:10px;margin:18px 0}.score span{font-size:11px}.score strong{display:block;font-size:32px;font-family:serif;text-align:center}.cloth{color:#a73f2c}.flower{color:#155e55}#status{font-size:11px;min-height:20px;line-height:1.5}.selection{display:flex;flex-direction:column;gap:10px}.selection span{font-size:10px;line-height:1.5}#confirm{background:#415d4d;color:#fff7e6;border:0;min-height:44px}details{font-size:11px;margin-top:15px}summary{cursor:pointer}#legal{display:flex;flex-wrap:wrap;gap:5px;max-height:130px;overflow:auto;margin-top:8px}#legal button{min-height:35px;padding:5px 8px}.selected{outline:2px solid #a5693b}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}dialog{border:1px solid #a6a88f;border-radius:22px;background:#f4eddd;color:#34483d;width:min(380px,calc(100vw - 24px));max-height:calc(100dvh - 24px);padding:22px;box-shadow:0 18px 70px #26382d55}dialog::backdrop{background:#263d3480}.dialog-head{display:flex;justify-content:space-between;align-items:center}h2{font-family:serif;font-size:21px}dialog label{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:17px 0;font-size:13px}select{padding:9px;border:1px solid #b9bba5;border-radius:8px;background:#fffaef;color:#34483d;font-size:12px}input[type=checkbox]{width:23px;height:23px;accent-color:#456650}dialog p{font-size:11px;line-height:1.8}#fallback{position:absolute;top:40%;padding:30px}@media(max-width:900px) and (orientation:portrait){#app{grid-template-rows:50px minmax(0,1fr);gap:6px;padding-left:7px;padding-right:7px}header{padding:0 4px}h1{font-size:23px}nav{gap:4px}nav button{font-size:10px;padding:7px 9px}main{grid-template-columns:1fr;grid-template-rows:minmax(0,1fr) auto;gap:7px}.panel{padding:13px 15px;display:grid;grid-template-columns:1fr 1fr;gap:4px 10px;width:100%;border-radius:18px}#turn{font-size:17px;align-self:center}.score{margin:0;justify-content:flex-end;gap:13px}.score strong{font-size:22px;display:inline;margin-left:4px}.score span{font-size:9px}#status{margin:2px 0;font-size:10px;grid-column:1/-1;min-height:15px}.selection{grid-column:1/-1;flex-direction:row;align-items:center;justify-content:space-between;gap:8px}.selection span{font-size:9px}#confirm{min-width:105px}.candidates{position:absolute;right:10px;bottom:calc(100% + 10px);margin:0;background:#f4eddd;border-radius:10px;padding:7px;max-width:220px}.candidates:not([open]){font-size:9px}.zoom{bottom:8px;left:10px;transform:none}.zoom button{min-height:36px;min-width:32px}.board-wrap{border-radius:20px}}@media(max-height:500px) and (orientation:landscape){#app{grid-template-rows:40px minmax(0,1fr);gap:3px;padding-top:3px;padding-bottom:3px}header small{display:none}h1{font-size:22px}nav button{min-height:33px}main{grid-template-columns:minmax(0,1fr) 210px;gap:7px}.panel{padding:13px}#turn{font-size:16px}.score{margin:7px 0}.score strong{display:inline;font-size:23px;margin-left:6px}#status{margin:5px 0;font-size:10px}.selection{gap:4px}details{margin-top:7px}.zoom{bottom:6px;padding:3px}.zoom button{min-height:32px}#legal{max-height:55px}}@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto}}
body{background:#91a99b;color:#3e5147;background-image:radial-gradient(ellipse at 15% 10%,#cbd7bf 0,transparent 45%),repeating-linear-gradient(90deg,transparent 0 5px,#456c5710 5px 6px)}.board-wrap{background:#91aa9a;border-color:#718a75;box-shadow:inset 0 0 0 4px #d6ddc7}#opening{position:absolute;inset:0;display:flex;flex-direction:column;justify-content:space-between;align-items:center;padding:18px 14px;pointer-events:none}.opening-copy{text-align:center;background:#f4e4c4e8;padding:12px 24px;border:1px dashed #b58d57;border-radius:50% 50% 14px 14px}.opening-copy>span{font-size:10px;letter-spacing:.15em}.opening-copy h2{margin:4px;font-size:30px;letter-spacing:.18em;color:#8e4837}.opening-actions{display:flex;gap:10px;pointer-events:auto;padding:12px;border-radius:20px;background:#f5e5c8ee;border:1px dashed #b08a5f}.opening-actions button{min-height:46px;font-size:13px;font-weight:600;background:#8f4b3b;color:#fff1cf;border:1px solid #8f4b3b}.opening-actions button:nth-child(2){background:#476b57;border-color:#476b57}.opening-actions button:nth-child(3){background:#f2dfba;color:#654830;border-color:#b49465}body:not([data-screen=play]) .panel,body:not([data-screen=play]) .zoom,body:not([data-screen=play]) #undo,body:not([data-screen=play]) #restart,body:not([data-screen=play]) #home{display:none}body:not([data-screen=play]) main{grid-template-columns:1fr;grid-template-rows:minmax(0,1fr)}#opening[hidden],#result[hidden]{display:none!important}.panel{background:#f7e8ca}#turn{font-size:17px}.score span{font-size:10px}.score strong{font-size:30px}#result{position:absolute;inset:0;z-index:5;display:grid;place-items:center;background:#61492f45;backdrop-filter:blur(2px)}.result-card{text-align:center;background:#fff0cf;border:3px double #b88c44;outline:6px solid #fff0cf;border-radius:32px;padding:24px 30px;max-width:90%;box-shadow:0 20px 60px #5f382b40;animation:storybook-win .55s ease-out}.result-card h2{font-size:23px;color:#a34834}.result-card p{font-size:16px}.result-card button{margin:5px}.crown{font-size:64px;color:#be8a2f;animation:crown-float 2s ease-in-out infinite}#result[data-faction=flower] h2{color:#326d56}#result[data-faction=draw] h2{color:#795b3b}dialog{background:#f6e7c7;border:3px double #ac895a;box-shadow:8px 8px 0 #dfc89e,10px 10px 0 #a6754c,0 20px 90px #3d271b66;transform-origin:left center;animation:page-open .3s ease-out}.sound-tests{display:flex;gap:8px}.sound-tests button{flex:1}.dialog-head h2{color:#7c4e38}#audioStatus{min-height:34px;color:#66503a}button:focus-visible{outline-color:#a65037}@keyframes page-open{from{transform:perspective(800px) rotateY(-45deg);opacity:.3}to{transform:none;opacity:1}}@keyframes storybook-win{from{transform:translateY(30px) scale(.85);opacity:0}to{transform:none;opacity:1}}@keyframes crown-float{50%{transform:translateY(-6px) rotate(4deg)}}@media(max-width:900px) and (orientation:portrait){#turn{font-size:15px}.score{gap:8px}.score span{font-size:8px}.score strong{font-size:20px;margin-left:3px}.opening-actions{gap:6px;padding:8px;flex-wrap:wrap;justify-content:center}.opening-actions button{font-size:12px;padding:8px 12px}.opening-copy h2{font-size:27px}.result-card{padding:18px}.result-card h2{font-size:20px}.crown{font-size:50px}}@media(max-height:500px){.opening-copy{padding:4px 18px}.opening-copy h2{font-size:21px}.opening-copy>span{font-size:8px}.opening-actions{padding:5px}.opening-actions button{min-height:36px}.result-card{padding:10px 22px}.crown{font-size:34px}.result-card h2{font-size:18px;margin:5px}.result-card p{margin:8px}}@media(prefers-reduced-motion:reduce){dialog,.result-card,.crown{animation:none}}
.opening-copy{background:transparent;border:0;padding:10px}.opening-copy>span{font-size:12px;color:#795339}
#entryGate{position:absolute;inset:0;z-index:8;display:flex;flex-direction:column;gap:12px;align-items:center;justify-content:flex-end;padding:0 15px 35px;background:linear-gradient(transparent 35%,#68412b30);backdrop-filter:none}#entryGate button{background:#f7e4ba;border:3px double #9b6b3f;border-radius:40px;min-height:58px;padding:12px 32px;font-size:17px;box-shadow:0 8px 22px #79533630}#entryGate small{font-size:10px;color:#563a28}#entryGate[hidden]{display:none}body[data-entered=false] .opening-actions,body[data-entered=false] #settingsOpen{visibility:hidden}
#captureCount{color:#fff8ec;background:#753064;border:2px solid #f9eaf6;border-radius:20px;padding:7px 11px;font-size:12px;white-space:nowrap;box-shadow:0 0 0 1px #753064}#captureCount[hidden],#resumeAudio[hidden]{display:none}#resumeAudio{font-size:10px}.selection{flex-wrap:wrap}@media(hover:hover){button:not(:disabled):hover{filter:brightness(1.05);box-shadow:0 3px 9px #704b2e22;transform:translateY(-1px);border-color:#997340}button{transition:background .12s,box-shadow .12s,transform .12s}}@media(max-width:900px) and (orientation:portrait){#captureCount{font-size:10px;padding:5px 8px}.selection>span{flex:1;min-width:100px}#confirm{min-width:103px}.selection #captureCount{order:0}.selection #confirm{order:1}}@media(prefers-reduced-motion:reduce){button{transition:none}}

#resumeAudio{position:absolute;right:12px;top:12px;z-index:6;box-shadow:0 3px 12px #654a3030}

/* Closed book has only its live title and one on-cover entry action. */
body[data-screen=home] header{display:none}body[data-screen=home] #app{grid-template-rows:minmax(0,1fr)}
#entryGate{background:none;padding:0;display:block}#entryGate #enterStory{position:absolute;transform:translate(-50%,-50%);font-size:clamp(12px,1.3vw,17px);min-height:42px;padding:10px 22px;white-space:nowrap;box-shadow:0 3px 10px #69473730;background:#f7e8c7f0}
#entryGate #enterStory:hover{transform:translate(-50%,-50%)}

/* Coherent 2.5D craft desk plate behind the live 3D book; no fake repeated grain. */
body{background:#8e9f85 url('./assets/sage-tabletop-plate.png') center center/cover no-repeat fixed}
.board-wrap{background:transparent;border:0;box-shadow:none;border-radius:0}
@media(orientation:portrait){body{background-position:32% center}}

body[data-screen=play] header>div{background:#fbf3dfeb;border:1px solid #d9ccb2;border-radius:12px;padding:3px 12px}
@media(orientation:portrait){body{background-position:12% center}}

/* Exact approved artwork entry. The whole photograph remains one undistorted plane. */
#entryGate{position:fixed;inset:0;z-index:20;overflow:hidden;background:#71816c;box-shadow:inset 0 0 100px #33483840}
#entryArtwork{position:absolute;left:50%;top:50%;width:1536px;height:1024px;transform-origin:center;}
#entryArtwork img{width:100%;height:100%;display:block;user-select:none}
#entryTitle{position:absolute;left:765px;top:365px;margin:0;transform:translate(-50%,-50%) rotate(-10deg) skewX(5deg);font-size:72px;letter-spacing:.12em;color:#f5d58a;text-shadow:0 2px 0 #94642e,0 -1px 0 #fff0be,1px 3px 3px #653b2b80;font-weight:700;white-space:nowrap}
#entryGate #enterStory,#entryGate #enterStory:hover{left:800px;top:490px;transform:translate(-50%,-50%) rotate(-10deg) skewX(5deg);font-size:30px;letter-spacing:.08em;background:#f4e3bde8;border:4px double #906b3f;border-radius:42px;box-shadow:0 5px 6px #713e3440;padding:12px 30px;color:#455e4b;}
body[data-entered=false] #world{visibility:hidden}
body[data-entered=true] #opening{animation:entry-reveal .22s ease-out}
@keyframes entry-reveal{from{opacity:0}to{opacity:1}}
@media(prefers-reduced-motion:reduce){body[data-entered=true] #opening{animation:none}}

body[data-screen=home] #world{visibility:hidden}
body[data-screen=home] #opening{position:fixed;inset:0;z-index:21;justify-content:flex-end;padding-bottom:max(22px,env(safe-area-inset-bottom));}
body[data-screen=home] #entryGate{pointer-events:none}
#entryGate #enterStory{pointer-events:auto}
#entryArtwork{box-shadow:0 0 0 2px #d7c8a780,0 14px 40px #243b3040}
@media(orientation:portrait){#entryGate:before{content:"";position:absolute;inset:18px;border:1px solid #d7c8a760;border-radius:20px;pointer-events:none}}
/* Lightweight original menu: no photography, texture fetches or WebGL on first screen. */
body{background:#e8ede2;background-image:none;color:#354d43}button,select{min-height:44px}button:disabled{cursor:default}button:hover:not(:disabled){filter:brightness(1.04)}[hidden]{display:none!important}
#simpleHome{height:100dvh;padding:max(18px,env(safe-area-inset-top)) 20px max(18px,env(safe-area-inset-bottom));display:flex;flex-direction:column;align-items:center;background:#f4f0e2}
.languageButtons{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}.languageButtons button{background:transparent;border:1px solid transparent;padding:8px 12px;color:#536658}.languageButtons button[aria-pressed=true]{border-color:#8ba18c;background:#e4eadb;border-radius:22px}
.simpleBrand{margin:auto;text-align:center;width:min(100%,370px)}.simpleBrand h1{font-size:clamp(44px,8vw,68px);letter-spacing:.10em;margin:24px 0 12px;color:#365d50}.simpleBrand p{font-size:14px;color:#728073}.simpleBrand #launch{margin-top:28px;width:100%;background:#416c59;color:#fff7e4;border:0;border-radius:20px;min-height:58px;font-size:17px;box-shadow:0 4px 0 #2b5040}.islandMark{display:flex;justify-content:center;gap:12px}.islandMark i{font-style:normal;display:grid;place-items:center;width:76px;height:76px;border-radius:50%;background:#ce8267;color:#fff0cc;box-shadow:0 6px 0 #a86550;font-size:38px}.islandMark i+ i{background:#599b86;box-shadow:0 6px 0 #377461;transform:translateY(10px)}
#entryGate{display:none!important}.board-wrap{background:transparent;border:0;box-shadow:none}#opening{position:fixed!important;inset:0;z-index:4!important;background:#f4f0e2;justify-content:center!important;gap:28px;pointer-events:auto;padding:24px!important}#opening h2{font-size:42px;letter-spacing:.1em;color:#365d50;margin:0}.opening-actions{flex-direction:column;background:none;border:0;gap:12px;width:min(330px,90vw);padding:0}.opening-actions button{font-size:16px;min-height:52px;border-radius:16px}#menuLanguage{max-width:220px;background:#e4eadb;border:1px solid #a6b79e;border-radius:12px;padding:6px 18px}
#result{position:fixed;inset:0;margin:auto;padding:0;border:0;border-radius:26px;max-width:min(440px,calc(100vw - 28px));max-height:calc(100dvh - 28px);background:#fff6df;box-shadow:0 16px 70px #172d4350;transform:none;animation:none;overflow:auto;display:none}#result[open]{display:block}#result::backdrop{background:#20392f99}.result-card{border:0;outline:0;border-radius:26px;padding:26px;max-width:none;box-shadow:none;animation:none}.result-card h2{font-size:25px;line-height:1.3;margin:8px 0 24px}.resultScores{display:grid;grid-template-columns:1fr 1fr;gap:12px}.resultScores>div{padding:16px 10px;border-radius:18px;background:#efcfb5}.resultScores>.flower{background:#c5dfcc}.resultScores span{display:block;font-size:13px;min-height:34px}.resultScores strong{display:block;font-size:46px}.resultActions{display:grid;gap:8px;margin-top:22px}.resultActions button{margin:0;min-height:46px}.resultActions button:first-child{background:#416c59;color:#fff7e4}.crown{font-size:42px;animation:none}#settings{max-width:min(440px,calc(100vw - 24px));max-height:calc(100dvh - 24px);overflow:auto;animation:none}.score b{font-weight:normal}.panel{overflow:auto}.selection{min-width:0}#selectionText{overflow-wrap:anywhere}#resultScore{font-size:inherit}
@media(max-width:600px){header nav button{padding:6px 9px;font-size:11px}header h1{font-size:21px}.score b{font-size:9px}.result-card{padding:20px}.languageButtons{gap:0}.languageButtons button{padding:8px 10px}.simpleBrand{max-width:300px}}
@media(max-height:500px){#simpleHome{padding:8px 18px}.simpleBrand{display:grid;grid-template-columns:90px 1fr;align-items:center;gap:0 22px;max-width:460px;width:100%}.islandMark{grid-row:1/4;gap:0;flex-direction:column}.islandMark i{width:48px;height:48px;font-size:26px}.simpleBrand h1{font-size:32px;margin:8px 0}.simpleBrand p{margin:3px}.simpleBrand #launch{margin-top:10px;min-height:44px}.crown{display:none}.result-card{padding:16px}.result-card h2{margin:0 0 12px;font-size:20px}.resultScores>div{padding:8px}.resultScores strong{font-size:30px}.resultScores span{min-height:0}.resultActions{grid-template-columns:repeat(3,1fr);gap:6px;margin-top:12px}.resultActions button{font-size:12px;padding:8px}}
#result{width:min(420px,calc(100vw - 28px))}.result-card{width:100%}.resultScores{grid-template-columns:repeat(2,minmax(0,1fr))}.resultScores>div{min-width:0}.resultScores span{white-space:normal;overflow-wrap:anywhere;line-height:1.35;font-size:12px;min-height:34px}
@media(max-width:600px){header{padding:0;gap:4px}header h1{font-size:19px;letter-spacing:.03em}header nav{gap:4px}header nav button{padding:6px;min-width:38px;font-size:10px}}

/* Fixed two-digit space: score movement never shifts faction labels. */
#clothCount,#flowerCount{display:inline-block;min-width:2ch;text-align:center;font-variant-numeric:tabular-nums;transform-origin:50% 70%}
/* Small book-like split cards, with a real horizontal hinge and turning halves. */
#clothCount,#flowerCount{min-width:2ch;line-height:1.15;vertical-align:middle}
.score .flap-cards{display:inline-flex;gap:1px;font-size:inherit;line-height:1.15;vertical-align:middle}
.score .flap-digit{display:block;position:relative;width:.66em;height:1.15em;perspective:110px;font-size:inherit;line-height:1.15;isolation:isolate}
.score .flap-half{position:absolute;left:0;width:100%;height:50%;overflow:hidden;background:#fff4dc;border-radius:3px 3px 1px 1px;font-size:inherit;line-height:1.15;backface-visibility:hidden;box-shadow:inset 0 0 0 .5px #98754b35}
.score .flap-top{top:0;transform-origin:center bottom;border-bottom:.5px solid #9c805447}
.score .flap-bottom{bottom:0;transform-origin:center top;border-radius:1px 1px 3px 3px;background:#f8eacb}
.score .flap-ink{position:absolute;left:0;top:0;width:100%;height:1.15em;font-size:inherit;line-height:1.15;text-align:center}
.score .flap-bottom .flap-ink{top:-.575em}
.score .flap-turn{z-index:2}
.score .flap-turn.flap-bottom{z-index:3}
.install-help{background:transparent;box-shadow:none;font-size:12px;min-height:44px;margin-top:10px}
#installDialog{width:min(430px,calc(100vw - 28px));max-height:calc(100dvh - 28px);overflow:auto;line-height:1.65;padding:20px;border-radius:20px;animation:none}
#installDialog h2{font-size:20px;margin:0}#installDialog p{font-size:14px}#installDialog .install-note{font-size:11px;color:#596b60}#installDialog button{min-height:44px;margin:3px 0}#installDialog::backdrop{background:#20392f88}
@media(display-mode:standalone){#simpleHome{padding-left:max(20px,env(safe-area-inset-left));padding-right:max(20px,env(safe-area-inset-right))}}
