:root{color-scheme:light;--ink:#173e56;--green:#397148;--cream:#fffbed}*{box-sizing:border-box}body{margin:0;color:var(--ink);background:#d8edc9;font-family:"BIZ UDPGothic","Hiragino Kaku Gothic ProN","Yu Gothic",sans-serif}button,a{-webkit-tap-highlight-color:transparent}button{font:inherit;cursor:pointer;color:inherit;touch-action:manipulation}button:disabled{cursor:default;opacity:.5}button:focus-visible,a:focus-visible{outline:3px solid #874100;outline-offset:3px}button,button:hover,button:active{transition:none}h1,h2,p{margin:0}ruby{ruby-align:center}rt{font-size:.55em;font-weight:500}[hidden]{display:none!important}.journey{min-height:calc(100svh - 54px);background:#d8edc9 url('./images/02-game-background.webp') center/cover fixed}.title-screen{min-height:calc(100svh - 54px);padding:4vh 20px 20px;display:flex;align-items:center;flex-direction:column;background:url('./images/01-title-background.webp') center/cover;gap:12px}.title-screen h1{width:min(720px,85vw);margin:0}.title-screen h1 img{display:block;width:100%;height:auto}.tagline{font-weight:800;font-size:clamp(18px,2.4vw,26px);padding:10px 20px;border-radius:30px;background:#fffce8ed;box-shadow:0 3px 0 #bacfaa}.title-menu{display:grid;justify-items:center;gap:8px;margin:5px 0}.art-button{display:inline-grid;place-items:center;border:0;background:transparent center/100% 100% no-repeat;min-height:60px;padding:16px 30px;font-weight:800;font-size:20px;min-width:200px}.art-button.green{background-image:url('./images/12-button-green-blank.webp');color:white;text-shadow:0 1px 1px #23482b}.art-button.cream{background-image:url('./images/13-button-cream-blank.webp')}.title-menu .green{width:300px;font-size:28px;min-height:84px}.title-menu .cream{width:240px}.small-button{min-height:44px;min-width:44px;border:1px solid #b6c4a0;border-radius:14px;background:#fffcf0;padding:9px 13px;font-size:14px;font-weight:700;box-shadow:0 2px 0 #90ab773d}.sound{width:96px;white-space:nowrap;flex-shrink:0}.title-guide{display:flex;align-items:center;gap:10px;background:#fffcedee;padding:7px 18px;border-radius:20px;font-weight:700;line-height:1.8}.title-guide img{width:66px;height:66px;object-fit:contain}.title-guide small{font-size:13px;font-weight:500}.credits-link{font-size:12px;color:#17415e;background:#fffce8e8;border-radius:16px;padding:8px}.play-screen{max-width:1360px;margin:auto;padding:12px 20px 24px}.play-header{display:flex;align-items:center;gap:18px}.play-header>img{width:210px;height:75px;object-fit:contain}.play-header nav{display:flex;gap:6px;flex-wrap:wrap;margin-left:auto}.stage-count{background:var(--cream);padding:10px 20px;border-radius:20px;white-space:nowrap;font-size:14px}.stage-count strong{font-size:26px}.stage-intro{background:#fffdecf2;padding:13px 22px;border:2px solid #d9c999;border-radius:22px;margin:8px 0 14px;text-align:center}.stage-intro h2{font-size:clamp(20px,2vw,26px);margin-bottom:6px}.stage-intro p{font-size:15px;line-height:1.7}.workbench{display:grid;grid-template-columns:minmax(0,1fr) 285px;gap:16px;align-items:start}.map-panel{background:#f5f6d8dc;border:2px solid #ccdaa6;border-radius:26px;padding:12px;box-shadow:0 6px 0 #7b9e6c22}.map{position:relative;width:100%;height:var(--map-height);min-height:230px;isolation:isolate}.routes{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;overflow:visible;z-index:-1}.route-track{stroke:#849284;stroke-width:5;fill:none;opacity:.5}.route-flow{stroke-width:5;fill:none;stroke-linecap:round;stroke-dasharray:7 3;animation:flow 1s linear infinite}.route-arrow{fill:#335449}.node{position:absolute;left:calc(var(--x)*100%/var(--cols));top:calc(var(--y)*100%/var(--rows));width:calc(100%/var(--cols));height:calc(100%/var(--rows));border:0;background:none;padding:10px 3px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;isolation:isolate}.node-art{width:94%;height:calc(100% - 40px);max-height:145px;object-fit:contain;filter:drop-shadow(0 3px 2px #435a3a22)}.node .node-name{font-size:16px;font-weight:800;line-height:1.55;background:#fffef4ef;padding:5px 4px 2px;border-radius:7px;max-width:100%;white-space:nowrap}.node.empty:before{content:'';position:absolute;inset:15% 12%;background:#fffbedee;border:2px dashed #839f75;border-radius:20%;z-index:-1}.node.empty .slot-symbol{font-size:38px;line-height:1.2;color:#6d8970}.node.empty .node-name{font-size:13px}.node.empty .slot-number{font-size:11px;color:#57704e}.node.has-water:after{content:'';position:absolute;inset:6px 3px;border:3px solid var(--water-color);border-radius:20px;z-index:-1;background:color-mix(in srgb,var(--water-color) 8%,transparent)}.node.selected:before{content:'';position:absolute;inset:3px;background:#ffe99577;border:3px solid #a6671b;border-radius:20px;z-index:-1}.node.pipe .node-name{font-size:12px}.pipe-svg{display:block;width:90px;height:90px;overflow:visible;pointer-events:none;filter:drop-shadow(0 3px 2px #435a3a25)}.pipe-water{fill:none;stroke:var(--water-color);stroke-width:5;stroke-linecap:round;stroke-linejoin:round;opacity:0}.node.has-water .pipe-water{opacity:.85}.water-status{position:absolute;bottom:0;left:0;right:0;margin:auto;font-size:10px;text-align:center;font-weight:800;background:#fffffff2;border:1px solid var(--water-color);border-radius:8px;padding:2px 0;width:max-content;max-width:100%}.river-art{font-size:44px;line-height:1.8;color:#1584b2}.legend{display:flex;flex-wrap:wrap;gap:6px 14px;font-size:12px;padding:2px 4px 10px;justify-content:center}.legend span{display:flex;align-items:center;gap:4px}.legend i{display:inline-block;height:7px;width:18px;background:var(--color);border-radius:4px}.map-note{font-size:11px;text-align:center;margin-top:12px;line-height:1.6}.tool-panel{background:#fffbedf5;border:2px solid #dbcd9f;border-radius:24px;padding:14px;box-shadow:0 6px 0 #9b956025}.guide{display:flex;align-items:center;gap:8px;margin-bottom:10px;min-height:68px}.guide img{width:48px;height:60px;object-fit:contain}.guide p{font-size:14px;font-weight:700;line-height:1.65}.cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.tool-card{background:transparent url('./images/15-card-blank.webp') center/100% 100% no-repeat;border:0;min-height:104px;padding:12px 6px;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:2px;font-size:14px;font-weight:800;line-height:1.6}.tool-card>img{width:70px;height:55px;object-fit:contain}.tool-card>.pipe-svg{width:76px;height:64px;min-height:0}.tool-card[aria-pressed=true]{outline:3px solid #47762d;outline-offset:-3px;border-radius:15px;background-color:#f9e995}.edit-controls{display:flex;flex-wrap:wrap;gap:6px;margin-top:12px}.edit-controls button{flex:1;font-size:13px;white-space:nowrap}.tool-note{font-size:11px;line-height:1.9;margin-top:10px}.success{max-width:900px;margin:18px auto 0;padding:18px;text-align:center;border:3px solid #93ae66;background:#fffbed;border-radius:24px;box-shadow:0 5px 0 #709c582a}.success>strong{font-size:25px;color:#397148}.success p{line-height:1.9;margin:8px auto;max-width:680px}.success .art-button{min-height:56px}.result-screen{max-width:1080px;margin:auto;text-align:center;padding:25px 20px}.result-logo{width:min(420px,80vw);height:auto}.result-screen h2{font-size:clamp(24px,4vw,38px);margin:14px 0;color:#205740}.result-screen>p{line-height:1.9}.review-route{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:8px;background:#fffcebf2;border-radius:26px;padding:20px;margin:20px auto}.review-stop{display:flex;flex-direction:column;align-items:center;font-size:13px;font-weight:700;gap:10px}.review-stop img{height:75px;width:100px;object-fit:contain}.review-arrow{font-size:25px;color:#286e88}.achievements{list-style:none;padding:0;display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:10px;text-align:left}.achievements li{background:#fffcf0;border:1px solid #c9d7ad;padding:14px;border-radius:14px;line-height:1.7}.achievements li:before{content:'✓ ';color:#357340;font-weight:800}.result-note{font-size:13px;margin:18px 0}.result-actions{display:flex;justify-content:center;align-items:center;gap:12px;flex-wrap:wrap}.save-status,.dm-completion-status{max-width:900px;background:#fff6dd;padding:14px;margin:12px auto;border:1px solid #ad8635;border-radius:14px;line-height:1.7}.save-status p{margin-bottom:8px}.dm-completion-status button{min-height:44px}.sound-note:empty{display:none}.sound-note{background:#fffbed;padding:8px;text-align:center;font-size:12px}dialog{color:var(--ink);background:var(--cream);border:3px solid #c6c998;border-radius:24px;width:min(600px,calc(100% - 24px));max-height:85svh;padding:24px;text-align:center}dialog::backdrop{background:#163d4670}dialog h2{font-size:24px;margin-bottom:20px}dialog p,dialog li{line-height:1.9;font-size:15px}dialog ol{text-align:left;padding-left:24px}dialog .art-button{margin-top:18px}dialog .stage-buttons{display:grid;gap:10px}dialog .stage-buttons button{min-height:52px;text-align:left}dialog .role-list{display:grid;grid-template-columns:1fr 1fr;gap:8px;text-align:left;margin:18px 0}.role-list p{font-size:13px;padding:8px;background:#eaf2d9;border-radius:12px}.review-lit{animation:review-glow 3s ease-in-out infinite}.map[data-stage="5"]{max-width:650px;margin:auto}.map[data-stage="5"] .node-art{max-height:100px}@keyframes flow{to{stroke-dashoffset:-20}}@keyframes review-glow{50%{filter:drop-shadow(0 0 8px #7aa93d)}}
@media(max-width:900px){.workbench{grid-template-columns:minmax(0,1fr)}.tool-panel{padding:12px}.cards{grid-template-columns:repeat(6,minmax(0,1fr))}.tool-card{min-height:92px;font-size:13px}.tool-card>img{width:60px;height:45px}.guide{min-height:50px;margin-bottom:8px}.guide img{height:44px;width:38px}.edit-controls{justify-content:center}.edit-controls button{flex:0 1 160px}.tool-note{text-align:center}.play-header>img{width:160px}.play-header{gap:10px;flex-wrap:wrap}.play-header nav{margin:auto}.node .node-name{font-size:14px}.stage-count{margin-left:auto}.play-screen{padding:10px}.map-panel{padding:10px}}
@media(max-width:540px){.title-screen{padding:25px 12px 18px;gap:14px}.title-screen h1{width:100%;margin:12px 0}.title-screen .tagline{font-size:17px;padding:8px 12px}.title-menu .green{width:260px;min-height:76px}.title-guide{padding:6px 12px}.play-header>img{width:155px;height:58px}.play-header nav{width:100%;justify-content:space-between;gap:3px}.play-header nav button{font-size:11px;padding:7px 8px}.play-header nav .sound{width:75px}.stage-count{font-size:11px;padding:8px 12px}.stage-count strong{font-size:22px}.stage-intro{padding:12px 8px;margin:10px 0}.stage-intro h2{font-size:19px}.stage-intro p{font-size:13px}.map-panel{padding:8px 3px;border-radius:18px}.legend{font-size:10px;gap:5px 10px}.map{min-height:180px}.node{padding:6px 0;gap:6px}.node .node-name{font-size:12px;padding:4px 2px 1px}.node[data-type=wastewater] .node-name{font-size:10px}.node.empty .slot-symbol{font-size:28px}.node.empty .node-name{font-size:11px}.node.has-water:after{inset:6px 0;border-width:2px;border-radius:12px}.node.selected:before{inset:3px 0;border-radius:12px}.water-status{font-size:8px}.cards{grid-template-columns:repeat(3,minmax(0,1fr))}.tool-card{min-height:100px;font-size:13px}.tool-card>img{width:64px;height:48px}.tool-panel{padding:10px;border-radius:18px}.map-note{font-size:10px;padding:0 4px}.success{padding:14px 10px;font-size:14px}.success>strong{font-size:22px}.result-screen{padding:20px 12px}.review-route{gap:8px;padding:15px 10px}.review-stop{font-size:12px}.review-stop img{width:70px;height:62px}.review-arrow{font-size:20px}.result-actions{gap:7px}.result-actions .art-button{min-width:170px;font-size:17px}.achievements{grid-template-columns:1fr;font-size:14px}.map[data-stage="5"] .node-art{height:62px}.map[data-stage="5"] .node .node-name{font-size:11px}.map[data-stage="5"] .node[data-type=wastewater] .node-name{font-size:10px}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;scroll-behavior:auto!important}.route-flow{stroke-dasharray:none}}

/* Keep the same pipe center as the underlying route, regardless of its label. */
.facility-node{position:absolute;left:calc(var(--x)*100%/var(--cols));top:calc(var(--y)*100%/var(--rows));width:calc(100%/var(--cols));height:calc(100%/var(--rows))}
.facility-node>.node{inset:0;width:100%;height:100%;padding:10px 3px 66px}
.facility-node .node-art{height:100%}
.facility-caption{position:absolute;bottom:18px;left:3px;right:3px;display:flex;align-items:center;justify-content:center;gap:3px;pointer-events:none}
.facility-caption .node-name{font-size:16px;font-weight:800;line-height:1.55;background:#fffef4ef;padding:5px 4px 2px;border-radius:7px;min-width:0;text-align:center}
.facility-info{pointer-events:auto;flex:0 0 44px;width:44px;height:44px;padding:0;border:2px solid #548662;border-radius:50%;background:#fffdf0;color:#285d40;font-size:23px;font-weight:800;box-shadow:0 2px 0 #47762d33}
.facility-detail>img{display:block;width:min(230px,75%);height:180px;object-fit:contain;margin:0 auto 18px}
.facility-detail>p{font-size:18px;line-height:1.9;text-align:left;max-width:420px;margin:auto}
@media(max-width:900px){.facility-caption .node-name{font-size:14px}}
@media(max-width:540px){.facility-node>.node{padding:6px 0 64px}.portrait-route .facility-node .node .node-art{height:100%;max-height:66px}.facility-caption{bottom:17px;left:1px;right:1px}.facility-caption .node-name{font-size:13px;padding:3px 2px}.facility-detail>img{height:150px}.facility-detail>p{font-size:16px}}
.pipe-water-outline{fill:none;stroke:#fffdf0;stroke-width:8;stroke-linecap:round;stroke-linejoin:round;opacity:0}
.node.has-water .pipe-water-outline,.node.has-water .pipe-water{opacity:1}
.node.pipe.filled .pipe-svg{position:absolute;top:50%;left:50%;width:min(94%,160px);height:calc(125% - 90px);max-height:150px;transform:translate(-50%,-50%)}
.node.pipe.filled .node-name{position:absolute;bottom:14px;left:0;right:0;width:max-content;margin:auto;line-height:1.3;padding:2px 4px}
.route-track{stroke-width:12}.route-flow{stroke-width:8;stroke-dasharray:12 10}.route-arrow{paint-order:stroke;stroke:#fffef0;stroke-width:3px;stroke-linejoin:round;fill:#294f54}
.tool-card>span{white-space:nowrap}.tool-card .pipe-svg{flex:none}
.edit-controls button{min-width:0;padding:9px 7px}.edit-controls button:first-child{flex-basis:100%;font-size:14px}
.stage-intro{background-image:url('./images/14-panel-wide-blank.webp');background-size:100% 100%;background-color:transparent;border:0;padding:20px 30px}
.mobile-dock{display:none}
@media(max-width:900px){.play-screen{padding-bottom:95px}.mobile-dock{display:block;position:fixed;bottom:0;left:0;right:0;z-index:4;background:#fffbeeed;border-top:2px solid #a4c791;padding:5px 10px max(7px,env(safe-area-inset-bottom));box-shadow:0 -3px 12px #476a3930;text-align:center}.mobile-dock>span{font-size:11px;display:block;margin-bottom:5px}.mobile-dock>div{display:flex;gap:8px;max-width:450px;margin:auto}.mobile-dock button{flex:1;padding:8px 6px;font-size:13px}.tool-panel .cards,.tool-panel .edit-controls,.tool-note{display:none}.tool-panel{order:-1}.tool-panel .guide{margin:0;min-height:44px}.tool-panel .guide img{height:38px}.guide p{font-size:12px}.stage-intro{padding:18px 20px}.edit-controls button:first-child{flex-basis:160px}dialog .cards{grid-template-columns:repeat(3,minmax(0,1fr));margin-top:16px}dialog .tool-card{min-height:100px;font-size:12px}.map-panel{scroll-margin-bottom:90px}.node{scroll-margin-top:20px;scroll-margin-bottom:100px}}

@media(min-width:901px){.map[data-stage="5"]{max-width:none}.map[data-stage="5"] .node-art{height:70px}}
@media(max-width:540px){.portrait-route .node .node-art{max-width:120px;height:76px}.portrait-route .node .node-name{font-size:14px}.portrait-route .node[data-type=wastewater] .node-name{font-size:13px}.portrait-route .node.empty:before{inset:13px max(10px,calc(50% - 54px))}.portrait-route .node.has-water:after,.portrait-route .node.selected:before{left:max(0px,calc(50% - 72px));right:max(0px,calc(50% - 72px))}.portrait-route .node.pipe .pipe-svg{left:50%;width:100px;height:72px;max-height:72px}.portrait-route .node.pipe .node-name{font-size:11px}.mobile-dock #open-cards{flex:1.4}.mobile-dock button{white-space:nowrap}}

.title-screen{gap:10px;padding:20px 20px 16px}.title-screen h1{width:min(460px,85vw)}.title-menu{grid-template-columns:repeat(2,minmax(0,1fr));width:min(430px,100%);align-items:center;gap:5px 10px;margin:0}.title-menu #start{grid-column:1/-1}.title-menu .cream{width:100%;min-width:0;font-size:19px}.title-menu #stage-select{font-size:13px;width:100%;min-height:48px}.title-guide{width:min(430px,100%);display:grid;grid-template-columns:56px 1fr 96px;padding:7px 12px;gap:9px}.title-guide img{width:56px;height:64px}.title-guide p{font-size:14px}.title-guide small{font-size:11px}.title-guide small br{display:none}.title-guide .sound{font-size:13px}
@media(max-width:540px){.title-screen{padding:20px 12px 15px}.title-screen h1{width:min(360px,100%);margin:0}.title-menu .cream{font-size:16px}.title-menu #stage-select{font-size:11px;padding:8px 4px}.title-guide{grid-template-columns:36px 1fr 76px;padding:7px 8px;gap:7px}.title-guide img{width:36px;height:52px}.title-guide p{font-size:12px}.title-guide small{font-size:10px}.title-guide small br{display:initial}.title-guide .sound{width:76px;padding:8px 4px;font-size:12px}}

/* Keep progression visible on phones and short viewports. */
@media(max-width:700px),(max-height:600px){
 #success #next{position:fixed;z-index:30;left:12px;right:12px;top:auto;bottom:max(10px,env(safe-area-inset-bottom));width:calc(100% - 24px);max-width:660px;min-height:52px;margin:0 auto;box-shadow:0 0 0 7px #fffaf0,0 2px 14px #243b5140}
 .play-screen:has(#success:not([hidden])){padding-bottom:calc(96px + env(safe-area-inset-bottom))}
}
