:root{
  --bg:#f4f7fb;--panel:#ffffff;--panel2:#f8fafc;--text:#172033;--muted:#667085;--line:#dbe3ec;
  --aqua:#22a89b;--water:#179ed1;--pipe:#7f96a5;--gold:#e5a900;--danger:#dc5b4d;
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color-scheme:light;
}
*{box-sizing:border-box}html{background:var(--bg)}body{margin:0;min-width:320px;background:linear-gradient(180deg,#ffffff 0,#f4f7fb 22rem,#eef3f8 100%);color:var(--text);min-height:100vh}button{font:inherit;color:inherit}button:focus-visible{outline:3px solid var(--gold);outline-offset:3px}#app{min-height:100vh}.eyebrow{font-size:.73rem;letter-spacing:.16em;color:var(--aqua);font-weight:800}.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:50}.home-shell,.map-shell,.game-shell{width:min(100%,900px);margin:auto;padding:22px clamp(16px,4vw,34px) 46px}.hero{display:flex;align-items:center;gap:18px;padding:22px 0 16px}.hero h1,.map-header h1,.game-topbar h1{margin:.1rem 0;font-size:clamp(2rem,6vw,3.6rem);line-height:.95}.hero p,.map-header p{color:var(--muted);margin:.6rem 0 0;max-width:600px}.brandmark{width:70px;height:70px;border-radius:20px;background:var(--panel);border:1px solid var(--line);position:relative;flex:none}.brandmark span{position:absolute;background:var(--aqua);border-radius:10px}.brandmark span:nth-child(1){width:44px;height:13px;left:13px;top:28px}.brandmark span:nth-child(2){width:13px;height:44px;left:28px;top:13px}.brandmark span:nth-child(3){width:18px;height:18px;border-radius:50%;background:var(--gold);left:26px;top:26px}.progress-strip{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin:8px 0 14px}.progress-strip>div,.hud>div,.arcade-hud>div{background:rgba(255,255,255,.94);border:1px solid var(--line);border-radius:16px;padding:12px}.progress-strip span,.hud span,.arcade-hud span{display:block;font-size:.72rem;color:var(--muted);text-transform:uppercase;letter-spacing:.08em}.progress-strip b,.hud b,.arcade-hud b{font-size:1.25rem}.continue-card{width:100%;border:0;border-radius:22px;padding:20px;background:linear-gradient(135deg,#19756f,#125767);display:flex;justify-content:space-between;align-items:center;text-align:left;box-shadow:0 12px 28px rgba(31,48,71,.12);cursor:pointer}.continue-card div{display:flex;flex-direction:column}.continue-card small{letter-spacing:.12em;opacity:.8}.continue-card strong{font-size:1.65rem;margin:.2rem 0}.continue-card>b{font-size:2rem}.mode-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;margin-top:14px}.mode-card{min-height:170px;border-radius:22px;border:1px solid var(--line);background:var(--panel);padding:18px;text-align:left;display:flex;flex-direction:column;align-items:flex-start;cursor:pointer}.mode-card:hover{border-color:#9fb5c4;box-shadow:0 8px 20px rgba(31,48,71,.08)}.mode-card small{color:var(--muted);letter-spacing:.1em}.mode-card strong{font-size:1.2rem;margin:.35rem 0}.mode-card span{color:var(--muted);line-height:1.35}.mode-icon{font-size:2rem;margin-bottom:auto}.puzzle-mode{background:linear-gradient(160deg,#f1fbf9,#ffffff)}.arcade-mode{background:linear-gradient(160deg,#fff9e8,#ffffff)}.locked-mode{opacity:.55;cursor:default}.secondary-row{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:12px}.secondary-row button{border:1px solid var(--line);border-radius:16px;background:transparent;padding:14px;text-align:left;color:var(--muted)}.secondary-row em{float:right;font-style:normal;font-size:.75rem}.map-header{display:flex;gap:14px;align-items:flex-start;margin-bottom:18px}.icon-btn{width:46px;height:46px;border-radius:14px;border:1px solid var(--line);background:var(--panel);font-size:1.35rem;cursor:pointer;flex:none}.journey-line{display:flex;flex-direction:column;gap:10px;position:relative}.journey-line:before{content:"";position:absolute;left:27px;top:30px;bottom:30px;width:2px;background:var(--line);z-index:0}.region-heading{display:flex;align-items:center;gap:10px;color:var(--aqua);margin:18px 0 4px;position:relative;z-index:1}.region-heading span{height:1px;background:var(--line);flex:1}.region-heading b{font-size:.78rem;letter-spacing:.12em;text-transform:uppercase}.level-node{width:100%;min-height:74px;display:grid;grid-template-columns:54px 1fr auto;align-items:center;gap:12px;background:var(--panel);border:1px solid var(--line);border-radius:18px;padding:10px 14px;text-align:left;position:relative;z-index:1}.level-node.unlocked{cursor:pointer}.level-node.locked{opacity:.44}.level-node.milestone{border-color:#e6c45f;background:linear-gradient(90deg,#fff9e7,var(--panel))}.node-num{width:44px;height:44px;border-radius:50%;display:grid;place-items:center;background:#eaf6f6;border:2px solid var(--aqua);font-weight:800}.milestone .node-num{border-color:var(--gold);background:#fff4ce}.node-meta{display:flex;flex-direction:column}.node-meta small{color:var(--muted);margin-top:3px}.node-stars{color:var(--gold);letter-spacing:.04em}.future-banner{margin-top:16px;border:1px dashed var(--line);border-radius:18px;padding:18px;display:flex;justify-content:space-between;gap:12px;color:var(--muted)}.future-banner strong{color:var(--text)}.game-topbar{display:grid;grid-template-columns:46px 1fr 46px;align-items:center;gap:12px}.game-topbar h1{font-size:1.7rem}.objective-card{margin:14px 0 10px;background:linear-gradient(90deg,rgba(34,168,155,.10),rgba(23,158,209,.05));border:1px solid #b7d9dc;border-radius:16px;padding:13px 15px;display:flex;justify-content:space-between;gap:10px}.objective-card span{color:var(--muted);font-size:.88rem}.hud,.arcade-hud{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-bottom:12px}.board-wrap{position:relative;width:100%;max-width:100%;overflow:hidden;display:flex;justify-content:center}.puzzle-board{display:grid;grid-template-columns:repeat(var(--cols),minmax(0,1fr));gap:3px;background:#dfe7ee;border:1px solid var(--line);border-radius:20px;padding:7px;overflow:hidden;touch-action:manipulation;width:min(100%,calc(var(--cols) * 78px + (var(--cols) - 1) * 3px + 14px));max-width:100%;margin-inline:auto}.tile{aspect-ratio:1;border:0;border-radius:8px;display:flex;align-items:center;justify-content:center;position:relative;background:#f8fafc;min-width:0}.tile.empty{background:#f2f6f9}.tile.obstacle{background:#e8edf1}.tile.obstacle span,.tile.source span,.tile.target span{font-size:clamp(1.05rem,5vw,2.1rem)}.tile.source,.tile.target{flex-direction:column;gap:1px;background:#edf7fa}.tile.target.connected{background:#e2f6f2;box-shadow:inset 0 0 0 2px var(--aqua)}.tile.source{box-shadow:inset 0 0 0 2px #267b8b}.tile small{font-size:clamp(.48rem,1.7vw,.7rem);font-weight:800;color:var(--muted)}.tile.pipe{padding:0;cursor:pointer}.tile.pipe.fixed{cursor:default}.pipe-svg{width:100%;height:100%;display:block}.pipe-svg.flowing{filter:drop-shadow(0 0 5px rgba(71,207,255,.5))}.pipe.connected{background:#e9f7fb}.lock{position:absolute;right:2px;bottom:1px;font-size:.65rem}.game-actions{display:flex;gap:10px;margin-top:12px}.primary-btn,.secondary-btn{border-radius:14px;padding:12px 18px;border:1px solid var(--line);cursor:pointer}.primary-btn{background:var(--aqua);color:#ffffff;border-color:transparent;font-weight:800}.secondary-btn{background:var(--panel)}.modal-layer{position:fixed;inset:0;background:rgba(35,47,62,.38);display:grid;place-items:center;padding:18px;z-index:20;backdrop-filter:blur(8px)}.result-card{width:min(100%,430px);background:#ffffff;border:1px solid #cbd7e2;border-radius:26px;padding:24px;text-align:center}.water-burst{font-size:3rem}.result-card h2{margin:.4rem 0}.stars{font-size:2.5rem;letter-spacing:.08em;color:var(--gold)}.result-card p{color:var(--muted)}.result-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:18px 0}.result-stats span{font-size:1.25rem;background:#f2f6f9;border-radius:14px;padding:12px}.result-stats small{display:block;color:var(--muted);font-size:.7rem;text-transform:uppercase}.result-actions{display:flex;justify-content:center;gap:10px}.arcade-hud{grid-template-columns:repeat(4,1fr)}.arcade-layout{display:grid;grid-template-columns:minmax(0,1fr) 120px;gap:12px;align-items:start}.arcade-board{display:grid;grid-template-columns:repeat(8,1fr);gap:2px;background:#dfe7ee;border:1px solid var(--line);border-radius:18px;padding:6px;touch-action:none}.a-tile{aspect-ratio:1;background:#f2f6f9;border-radius:5px;display:grid;place-items:center;min-width:0}.a-tile.obstacle{background:#e5e9ed}.a-tile.source,.a-tile.target{background:#eaf5f8}.a-tile.falling{background:#fff1bf}.next-box{border:1px solid var(--line);border-radius:16px;background:var(--panel);padding:12px;text-align:center}.next-box>span{display:block;color:var(--muted);font-size:.75rem;text-transform:uppercase}.next-box [data-next]{width:72px;height:72px;margin:8px auto}.next-box small{color:var(--muted);font-size:.72rem}.arcade-controls{display:grid;grid-template-columns:1fr 1fr 1fr 1.5fr;gap:8px;margin-top:12px}.arcade-controls button{min-height:52px;border:1px solid var(--line);border-radius:14px;background:var(--panel);font-weight:800;cursor:pointer}.flow-flash{position:absolute;left:50%;top:40%;transform:translate(-50%,-50%) scale(.8);background:var(--aqua);color:#ffffff;padding:10px 16px;border-radius:999px;font-weight:900;opacity:0;pointer-events:none;transition:.25s}.flow-flash.show{opacity:1;transform:translate(-50%,-50%) scale(1)}
@media(max-width:620px){.home-shell,.map-shell,.game-shell{padding-left:12px;padding-right:12px}.hero{padding-top:14px}.brandmark{width:58px;height:58px}.brandmark span:nth-child(1){width:36px;left:11px;top:23px}.brandmark span:nth-child(2){height:36px;left:23px;top:11px}.brandmark span:nth-child(3){left:20px;top:20px}.mode-grid{grid-template-columns:1fr 1fr}.mode-card{min-height:150px;padding:14px}.objective-card{flex-direction:column}.future-banner{flex-direction:column}.arcade-layout{grid-template-columns:1fr}.next-box{display:none}.arcade-hud{grid-template-columns:repeat(4,1fr)}.arcade-hud>div{padding:8px}.arcade-hud b{font-size:1rem}.puzzle-board{gap:2px;padding:5px;border-radius:14px}.level-node{grid-template-columns:50px 1fr auto}.node-stars{font-size:.85rem}}
@media(max-width:390px){.mode-grid{grid-template-columns:1fr}.secondary-row{grid-template-columns:1fr}.progress-strip>div{padding:9px}.progress-strip b{font-size:1.05rem}.hud>div{padding:9px}.hud b{font-size:1rem}.arcade-controls{grid-template-columns:repeat(3,1fr)}.arcade-controls [data-drop]{grid-column:1/-1}.node-meta small{font-size:.72rem}}

/* FlowGrid light-mode refinement */
.brandmark{box-shadow:0 8px 20px rgba(31,48,71,.08)}
.continue-card{color:#fff;background:linear-gradient(135deg,#23a99c,#1686a6)}
.continue-card small{color:rgba(255,255,255,.82)}
.mode-card,.level-node,.icon-btn,.secondary-btn,.next-box,.arcade-controls button{box-shadow:0 4px 14px rgba(31,48,71,.045)}
.tile.pipe:not(.connected){background:#f8fafc}
.tile.pipe:hover{background:#eef8fa}
.tile.target.connected{box-shadow:inset 0 0 0 2px var(--aqua),0 0 0 1px rgba(34,168,155,.08)}
.puzzle-board,.arcade-board{box-shadow:inset 0 1px 0 rgba(255,255,255,.75),0 8px 24px rgba(31,48,71,.08)}
.modal-layer{backdrop-filter:blur(5px)}
.result-card{box-shadow:0 24px 60px rgba(31,48,71,.18)}
.secondary-row button{background:rgba(255,255,255,.55)}
.flow-flash{color:#fff;box-shadow:0 8px 20px rgba(34,168,155,.22)}

/* v0.3 responsive board hotfix */
@media(max-width:620px){.game-shell{width:100%;max-width:100%;overflow-x:hidden}.board-wrap{width:100%;max-width:100%}.puzzle-board{width:100%;max-width:100%;grid-template-columns:repeat(var(--cols),minmax(0,1fr));gap:clamp(1px,.45vw,2px);padding:clamp(3px,1vw,5px)}.tile{min-width:0;width:100%;max-width:100%}.tile.obstacle span,.tile.source span,.tile.target span{font-size:clamp(.9rem,calc(12vw / var(--cols) * 4),1.7rem)}.tile small{font-size:clamp(.42rem,1.7vw,.62rem)}}
@media(max-width:380px){.game-shell{padding-left:8px;padding-right:8px}.puzzle-board{border-radius:12px}.tile{border-radius:6px}}

/* FlowGrid v0.4 — manual flow test + refreshed game art */
.pipe-svg{overflow:visible;color:transparent}
.pipe-svg .pipe-shadow{color:#6f7e88}
.pipe-svg .pipe-metal{color:#c9d4db}
.pipe-svg .pipe-highlight{color:#eef5f8;opacity:.75;transform:translate(-2px,-2px)}
.pipe-svg .pipe-joint-outer{fill:#7b8b95;stroke:#56656f;stroke-width:3}
.pipe-svg .pipe-joint-inner{fill:#d6e0e5;stroke:#f7fbfd;stroke-width:3}
.pipe-svg.active-piece .pipe-metal{color:#ffd66b}.pipe-svg.active-piece .pipe-joint-inner{fill:#ffe39a}
.pipe-svg.flowing .pipe-water{color:#27bdf1;filter:drop-shadow(0 0 3px rgba(39,189,241,.45));stroke-dasharray:12 7;animation:waterDash .48s linear infinite}
.pipe-svg.flowing .pipe-water-core{fill:#26bff2;filter:drop-shadow(0 0 4px rgba(39,189,241,.6))}
@keyframes waterDash{to{stroke-dashoffset:-19}}

.source-art,.building-art{width:min(76%,54px);height:min(76%,54px);display:block;overflow:visible}
.source-art .source-tank{fill:#dbe6eb;stroke:#758994;stroke-width:4}.source-art .source-water{fill:#9edff4}.source-art .source-cap{fill:#7c909b}.source-art .source-leg{fill:none;stroke:#758994;stroke-width:5;stroke-linecap:round}.source-art .source-spout{fill:none;stroke:#758994;stroke-width:8;stroke-linecap:round}.source-art .source-drop{fill:#a9d9e8;opacity:.35}.source-art.active .source-water,.source-art.active .source-drop{fill:#22bdf0;opacity:1}.source-art.active .source-drop{animation:sourceDrop .55s ease-in-out infinite alternate}.source-art.active{filter:drop-shadow(0 0 7px rgba(34,189,240,.35))}
@keyframes sourceDrop{from{transform:translateY(-3px)}to{transform:translateY(5px)}}

.building-art .building-body{fill:#f3f7f9;stroke:#7c8d98;stroke-width:3}.building-art .building-roof{fill:#df8a52;stroke:#8d6047;stroke-width:3;stroke-linejoin:round}.building-art .building-door{fill:#8b6b55}.building-art .building-window{fill:#9fd8ed}.building-art .building-accent{fill:#e45f67}.building-art .building-drop{fill:#b9dbe5}.building-art.school .building-roof{fill:#d79b57}.building-art.apartment .building-body{fill:#e7edf1}.building-art.factory .building-body{fill:#d8e0e4}.building-art.factory .building-roof{fill:#7d8c96}.building-art.active{filter:drop-shadow(0 0 7px rgba(38,190,238,.38))}.building-art.active .building-window,.building-art.active .building-drop{fill:#27bdf1}.building-art.active .building-body{stroke:#25b8eb}

.tile.source,.tile.target{padding:3px}.tile.source small,.tile.target small{font-size:clamp(.38rem,1.45vw,.58rem);letter-spacing:.04em}.tile.target.connected{animation:buildingSupplied .38s ease-out both}@keyframes buildingSupplied{0%{transform:scale(.93)}65%{transform:scale(1.06)}100%{transform:scale(1)}}

.game-actions{display:grid;grid-template-columns:minmax(86px,1fr) minmax(130px,1.45fr) minmax(86px,1fr);align-items:stretch}.game-actions>button{min-height:52px}.flow-btn{border:0;border-radius:15px;background:linear-gradient(180deg,#35c6ee,#13a8df);color:white;font-weight:900;letter-spacing:.08em;cursor:pointer;display:flex;align-items:center;justify-content:center;gap:7px;box-shadow:0 7px 18px rgba(22,165,216,.2)}.flow-btn:hover{filter:brightness(1.03)}.flow-btn:disabled{cursor:wait;opacity:.78}.flow-btn.testing .flow-btn-drop{animation:flowButtonPulse .55s ease-in-out infinite alternate}@keyframes flowButtonPulse{to{transform:translateY(4px) scale(1.12)}}.flow-help{text-align:center;color:var(--muted);font-size:.82rem;margin:9px 4px 0}.puzzle-board.testing{pointer-events:none}.puzzle-board.flow-error{animation:boardError .16s ease-in-out 0s 3 alternate}@keyframes boardError{from{transform:translateX(-3px);border-color:#ef7373}to{transform:translateX(3px);border-color:#ef7373}}
.toast{max-width:min(90vw,520px);padding:11px 16px;border-radius:999px;background:#1e3743;color:white;font-weight:700;box-shadow:0 10px 26px rgba(20,54,70,.2);opacity:0;pointer-events:none;transition:.2s}.toast.show{opacity:1}.toast.error{background:#b94747}
.a-tile .source-art,.a-tile .building-art{width:88%;height:88%}
@media(max-width:480px){.game-actions{grid-template-columns:1fr 1.35fr 1fr;gap:6px}.game-actions>button{padding:10px 7px;font-size:.85rem}.flow-btn{letter-spacing:.04em}.source-art,.building-art{width:82%;height:82%}}

/* Arcade v0.5 — random-grid placement, not falling blocks */
.random-arcade-board{grid-template-columns:repeat(8,minmax(0,1fr));width:min(100%,680px);max-width:100%;margin-inline:auto;gap:clamp(2px,.55vw,4px);padding:clamp(5px,1.2vw,8px);touch-action:manipulation;background:linear-gradient(180deg,#dff0d2,#cfe7bf);border-color:#b9cfac}
.arcade-cell{border:1px solid rgba(71,101,67,.08);background:rgba(255,255,255,.62);overflow:hidden;position:relative;cursor:default}
button.arcade-cell{padding:0;color:inherit;font:inherit}
button.arcade-cell.pipe{cursor:pointer;background:rgba(255,255,255,.78)}
button.arcade-cell.pipe:hover{box-shadow:inset 0 0 0 2px rgba(21,166,198,.25)}
.arcade-cell.empty{background:rgba(255,255,255,.28)}
.arcade-cell.random-selected{animation:randomTilePick .33s ease-in-out infinite alternate;background:#fff6b8;box-shadow:inset 0 0 0 3px #ffc928,0 0 0 2px rgba(255,255,255,.75)}
@keyframes randomTilePick{from{transform:scale(.94)}to{transform:scale(1);filter:brightness(1.08)}}
.arcade-cell.obstacle{background:#e9e2d2}
.obstacle-art{font-size:clamp(1.2rem,5.5vw,2.5rem);filter:drop-shadow(0 2px 1px rgba(37,52,40,.18))}
.arcade-cell.source,.arcade-cell.target{background:#eef9ff}
.arcade-cell.supplied{background:#dff9f5;box-shadow:inset 0 0 0 2px #20b79e}
.arcade-cell.flowing{background:#e4f8ff}
.arcade-status{display:grid;grid-template-columns:1fr 1fr auto;align-items:center;gap:8px;margin:0 0 10px}
.arcade-status>div{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:9px 12px;display:flex;justify-content:space-between;gap:10px;align-items:center}
.arcade-status span{color:var(--muted);font-size:.78rem}.arcade-status b{font-size:.95rem}
.arcade-instruction{margin:0 0 12px;border:1px solid #cfe1c6;background:#f4faef;border-radius:15px;padding:11px 13px;color:var(--muted);font-size:.88rem;line-height:1.4}.arcade-instruction strong{color:var(--text)}
.arcade-legend{display:flex;flex-wrap:wrap;gap:8px 14px;justify-content:center;margin-top:10px;color:var(--muted);font-size:.78rem}.arcade-legend span{display:flex;align-items:center;gap:6px}.legend-dot{width:9px;height:9px;border-radius:50%;display:inline-block}.pipe-dot{background:#56a9c8}.obstacle-dot{background:#ae8c63}
@media(max-width:620px){.random-arcade-board{width:100%;gap:2px;padding:4px;border-radius:14px}.arcade-status{grid-template-columns:1fr 1fr}.arcade-status>[data-pause]{grid-column:1/-1;min-height:42px}.arcade-instruction{font-size:.8rem;padding:9px 10px}.obstacle-art{font-size:clamp(1rem,7vw,2rem)}}

/* v0.6 puzzle pipe-container placement mode */
.pipe-tray-wrap{margin:10px 0 12px;border:1px solid #cbd7e2;background:#fff;border-radius:18px;padding:12px;box-shadow:0 6px 18px rgba(31,48,71,.06)}
.tray-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin-bottom:10px}.tray-heading>div{display:flex;flex-direction:column}.tray-heading small,.tray-heading>span{color:var(--muted);font-size:.78rem}.tray-heading>span{white-space:nowrap}
.pipe-tray{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px}.tray-pipe{min-width:0;border:1px solid var(--line);background:#f8fbfd;border-radius:14px;padding:7px 5px 6px;cursor:pointer;display:grid;grid-template-columns:1fr auto;grid-template-rows:auto auto;align-items:center;gap:2px 4px;color:var(--text)}.tray-pipe:hover{border-color:#8ebac8}.tray-pipe.selected{border:2px solid var(--aqua);background:#eaf9f7;box-shadow:0 0 0 3px rgba(34,168,155,.10)}.tray-pipe-art{grid-column:1/-1;width:min(54px,80%);aspect-ratio:1;margin:auto;display:block}.tray-pipe-art .pipe-svg{width:100%;height:100%}.tray-pipe-label{font-size:.7rem;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tray-pipe b{font-size:.82rem}.tray-empty{grid-column:1/-1;text-align:center;color:var(--muted);padding:12px;border:1px dashed var(--line);border-radius:12px}
.placement-board .tile.empty.place-cell{border:0;background:#f2f6f9;cursor:default}.placement-board .tile.empty.place-cell.ready{cursor:pointer;background:#eef9f7;box-shadow:inset 0 0 0 1px #b8dfd9}.place-plus{opacity:0;color:var(--aqua);font-size:clamp(1rem,4vw,1.7rem);font-weight:500}.place-cell.ready .place-plus{opacity:.6}.place-cell.ready:hover .place-plus{opacity:1}
.tile.pipe.placed{padding:0;position:relative;overflow:visible}.pipe-rotate{position:absolute;inset:0;border:0;border-radius:inherit;background:transparent;padding:0;cursor:pointer;overflow:hidden}.pipe-rotate .pipe-svg{width:100%;height:100%}.return-pipe{position:absolute;right:2px;bottom:2px;z-index:4;width:22px;height:22px;border-radius:50%;border:1px solid #b9c8d2;background:rgba(255,255,255,.94);color:#365268;font-size:.74rem;line-height:1;display:grid;place-items:center;cursor:pointer;box-shadow:0 2px 5px rgba(31,48,71,.12)}.return-pipe:hover{background:#fff;border-color:var(--aqua);color:var(--aqua)}
@media(max-width:620px){.pipe-tray-wrap{padding:9px;border-radius:14px}.tray-heading{align-items:flex-start}.tray-heading>span{font-size:.7rem}.pipe-tray{grid-template-columns:repeat(5,minmax(0,1fr));gap:4px}.tray-pipe{padding:4px 2px;border-radius:10px;display:flex;flex-direction:column;gap:1px}.tray-pipe-art{width:min(42px,78%)}.tray-pipe-label{font-size:.56rem;max-width:100%}.tray-pipe b{font-size:.68rem}.return-pipe{width:18px;height:18px;font-size:.6rem;right:1px;bottom:1px}.place-plus{font-size:1.15rem}}

/* v0.7 full-width cartoon puzzle workspace */
body{background:linear-gradient(180deg,#bfe8ff 0 18rem,#dff4ff 18rem 29rem,#b8df93 29rem 38rem,#eef6e8 38rem 100%);background-attachment:fixed}
.game-shell{width:100%;max-width:1540px;margin:0 auto;padding:18px clamp(14px,2.2vw,34px) 42px}
.game-topbar{background:rgba(255,255,255,.94);border:1px solid rgba(121,159,177,.28);border-radius:24px;padding:12px 16px;box-shadow:0 7px 18px rgba(52,95,118,.10);margin-bottom:12px}
.game-topbar h1{font-size:clamp(1.55rem,2.4vw,2.15rem)}
.puzzle-hud-row{width:min(620px,100%);margin:0 auto 12px;grid-template-columns:repeat(3,1fr)}
.puzzle-hud-row>div{box-shadow:0 4px 10px rgba(52,95,118,.06)}
.puzzle-workspace{display:grid;grid-template-columns:minmax(190px,230px) minmax(0,1fr) minmax(230px,300px);gap:16px;align-items:start;width:100%}
.puzzle-side{display:flex;flex-direction:column;gap:12px;min-width:0}
.puzzle-panel{background:rgba(255,255,255,.96);border:1px solid rgba(102,151,170,.28);border-radius:22px;padding:16px;box-shadow:0 8px 18px rgba(44,87,108,.09)}
.panel-title{display:flex;align-items:center;gap:9px;color:#175768;margin-bottom:9px}.panel-title span{font-size:1.25rem}.panel-title b{font-size:1.04rem}
.how-panel p,.objective-panel span{color:#5f7280;line-height:1.45;margin:.5rem 0}.objective-panel>strong{display:block;line-height:1.35;margin-bottom:8px;color:#203644}
.rule-callout{background:#eaf8fb;border:1px solid #b8dfe7;border-radius:15px;padding:11px 12px;display:flex;flex-direction:column;gap:4px;color:#315d68}.rule-callout b{color:#147b87}.rule-callout span{font-size:.86rem;line-height:1.35}
.action-panel{display:grid;gap:9px}.wide-action{width:100%;min-height:48px;justify-content:center}
.puzzle-center{min-width:0;background:rgba(255,255,255,.92);border:1px solid rgba(102,151,170,.26);border-radius:26px;padding:14px;box-shadow:0 10px 22px rgba(44,87,108,.10)}
.board-heading{display:flex;justify-content:space-between;align-items:end;gap:12px;padding:2px 4px 10px}.board-heading>div{display:flex;flex-direction:column;gap:3px}.board-heading b{font-size:1.06rem}.connection-tip{font-size:.8rem;color:#587381;background:#eff8fa;border:1px solid #d1e8ed;border-radius:999px;padding:6px 10px;white-space:nowrap}
.board-wrap{width:100%;display:flex;justify-content:center;overflow:visible}
.puzzle-board{width:min(100%,860px);max-width:100%;padding:8px;gap:4px;border-radius:20px;background:linear-gradient(135deg,#d5e4ec,#cbdce6);border:2px solid rgba(62,111,133,.18);box-shadow:inset 0 1px 0 rgba(255,255,255,.65)}
.tile{border-radius:9px;background:#eef4f7}.tile.empty{background:linear-gradient(145deg,#f8fbfc,#e8f0f4);box-shadow:inset 0 0 0 1px rgba(99,139,156,.08)}
.tile.source,.tile.target{background:linear-gradient(145deg,#f3fbfd,#e7f5f7)}
.tile.source:after,.tile.target:before{content:"";position:absolute;top:50%;width:14%;height:22%;transform:translateY(-50%);background:#7b93a1;border:2px solid #55717e;z-index:1}.tile.source:after{right:-8%}.tile.target:before{left:-8%}
.tile.target.connected{box-shadow:inset 0 0 0 2px #21a594,0 0 0 2px rgba(33,165,148,.08)}
.pipe-tray-wrap{padding:14px}.tray-heading{display:flex;flex-direction:column;gap:5px;margin-bottom:10px}.tray-heading>div{display:flex;flex-direction:column}.tray-heading small{color:#6d7f89;margin-top:2px}.tray-heading>span{align-self:flex-start;background:#eef7f9;color:#3f6b77;border-radius:999px;padding:5px 8px;font-size:.75rem}
.pipe-tray{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}.tray-pipe{min-width:0;border:1px solid #cfdce3;border-radius:16px;background:linear-gradient(180deg,#fff,#f5f8fa);padding:9px 7px;cursor:pointer}.tray-pipe:hover{border-color:#84bdc7}.tray-pipe.selected{border:2px solid #1fa397;background:#ecfbf8}.tray-pipe-art{display:block;width:58px;max-width:100%;aspect-ratio:1;margin:auto}.tray-pipe-label{display:block;font-size:.75rem;color:#4d626c;margin-top:3px}.tray-pipe b{display:block;color:#1f4955;margin-top:2px}
.flow-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:15px;padding:12px 18px;background:linear-gradient(180deg,#20ad9d,#118c83);color:white;font-weight:900;cursor:pointer;box-shadow:0 5px 10px rgba(17,140,131,.18)}
.flow-btn:disabled{opacity:.65;cursor:wait}.flow-help{text-align:center;color:#5d7580;margin:11px 4px 0;font-size:.9rem}
.place-cell .place-plus{opacity:.18;font-weight:800}.place-cell.ready .place-plus{opacity:.6;color:#158f88}
@media(max-width:1100px){.puzzle-workspace{grid-template-columns:210px minmax(0,1fr)}.puzzle-side-right{grid-column:1/-1;display:grid;grid-template-columns:minmax(220px,.65fr) minmax(0,1.35fr)}.pipe-tray{grid-template-columns:repeat(5,minmax(0,1fr))}}
@media(max-width:760px){body{background:linear-gradient(180deg,#c7ebfb 0 12rem,#eef8fb 12rem 100%)}.game-shell{padding:10px 8px 30px}.game-topbar{border-radius:18px;padding:9px 10px}.puzzle-hud-row{gap:6px;margin-bottom:8px}.puzzle-hud-row>div{padding:9px}.puzzle-workspace{display:flex;flex-direction:column;gap:9px}.puzzle-center{order:1;width:100%;padding:7px;border-radius:18px}.puzzle-side-right{order:2;display:flex;width:100%}.puzzle-side-left{order:3;width:100%;display:grid;grid-template-columns:1fr}.puzzle-panel{border-radius:18px;padding:12px}.puzzle-board{width:100%;padding:5px;gap:2px;border-radius:14px}.board-heading{padding:2px 3px 7px;align-items:flex-start}.connection-tip{display:none}.pipe-tray{grid-template-columns:repeat(5,minmax(0,1fr));gap:5px}.tray-pipe{padding:6px 3px;border-radius:12px}.tray-pipe-art{width:44px}.tray-pipe-label{font-size:.65rem}.how-panel{order:2}.action-panel{order:1;grid-template-columns:1fr 1.2fr 1fr}.wide-action{min-height:46px;padding:9px}.flow-help{font-size:.8rem}}
@media(max-width:430px){.pipe-tray{grid-template-columns:repeat(3,minmax(0,1fr))}.action-panel{grid-template-columns:1fr}.puzzle-hud-row b{font-size:1rem}.puzzle-hud-row span{font-size:.62rem}}


/* v0.9 — viewport-fit puzzle board + true cartoon pipe artwork */
.puzzle-center{display:flex;flex-direction:column;min-height:0}
.board-wrap{min-height:0;align-items:flex-start}
.puzzle-board{
  width:min(100%,860px,calc((100dvh - 245px) * var(--cols) / var(--rows)));
  max-height:calc(100dvh - 245px);
  aspect-ratio:var(--cols)/var(--rows);
  grid-template-rows:repeat(var(--rows),minmax(0,1fr));
}
.puzzle-board .tile{min-height:0;aspect-ratio:auto;height:100%}
.flow-help{margin-top:7px}

/* Proper pipe silhouette: thick cylindrical body, dark outline, metal shine and collars. */
.pipe-svg.cartoon-pipe{overflow:visible}
.pipe-svg .pipe-outline{stroke:#52646f;stroke-width:36}
.pipe-svg .pipe-body{stroke:#b9c8d0;stroke-width:30}
.pipe-svg .pipe-body-shade{stroke:#8fa2ad;stroke-width:22;opacity:.72}
.pipe-svg .pipe-sheen{stroke:#eef6f9;stroke-width:7;opacity:.9;transform:translate(-2px,-2px)}
.pipe-svg .pipe-hub{fill:#a9bac3;stroke:#536873;stroke-width:4}
.pipe-svg .pipe-hub-shine{fill:#edf5f8;opacity:.62}
.pipe-svg .pipe-collar-shadow{fill:#52646f}
.pipe-svg .pipe-collar{fill:#9eafb9;stroke:#5d707a;stroke-width:2}
.pipe-svg .pipe-collar-shine{stroke:#edf5f8;stroke-width:2;stroke-linecap:round;opacity:.8}
.pipe-svg.flowing .pipe-water{stroke:#22bff2;stroke-width:13;stroke-dasharray:11 8;animation:waterDash .46s linear infinite;filter:drop-shadow(0 0 4px rgba(34,191,242,.65))}
.pipe-svg.active-piece .pipe-body{stroke:#ffd86c}.pipe-svg.active-piece .pipe-body-shade{stroke:#e8a925}
.tile.pipe,.tray-pipe-art{filter:drop-shadow(0 2px 1px rgba(42,65,76,.12))}
.tray-pipe-art{width:min(72px,92%)}

/* More game-like source/buildings. */
.source-art,.building-art{width:min(84%,68px);height:min(84%,68px)}
.source-art .source-base-shadow{fill:rgba(51,76,89,.18)}
.source-art .source-tank{fill:#d9e8ef;stroke:#607985;stroke-width:4}
.source-art .source-rim{fill:#edf6f9;stroke:#607985;stroke-width:4}
.source-art .source-water{fill:#8edff7}
.source-art .source-cap{fill:#5f7b88;stroke:#425c68;stroke-width:2}
.source-art .source-leg{fill:none;stroke:#607985;stroke-width:5;stroke-linecap:round}
.source-art .source-spout{fill:none;stroke:#607985;stroke-width:9;stroke-linecap:round}
.source-art .source-drop{fill:#34bff0}.source-art .source-gloss{fill:none;stroke:white;stroke-width:4;stroke-linecap:round;opacity:.8}
.building-art .building-ground{fill:none;stroke:#667b84;stroke-width:4;stroke-linecap:round;opacity:.45}
.building-art .building-body{fill:#fff7e6;stroke:#6f7e86;stroke-width:3}
.building-art .building-roof{fill:#e67545;stroke:#8b4e38;stroke-width:3;stroke-linejoin:round}
.building-art .building-door{fill:#9a653d;stroke:#6d4a34;stroke-width:2}
.building-art .building-window{fill:#77c9ee;stroke:#557d91;stroke-width:2}
.building-art .building-accent{fill:#e84f5d}.building-art .building-drop{fill:#28bdf0}
.building-art .school-clock{fill:#fff;stroke:#6f7e86;stroke-width:2}.building-art .factory-stack{fill:#7d8c96;stroke:#596770;stroke-width:2}

@media(max-height:820px) and (min-width:761px){
  .game-shell{padding-top:8px;padding-bottom:18px}
  .game-topbar{padding:8px 12px;margin-bottom:7px}.game-topbar h1{font-size:1.35rem}
  .puzzle-hud-row{margin-bottom:7px}.puzzle-hud-row>div{padding:7px 10px}.puzzle-hud-row b{font-size:1rem}
  .puzzle-center{padding:9px}.board-heading{padding-bottom:6px}.flow-help{font-size:.76rem;margin-top:4px}
  .puzzle-board{max-height:calc(100dvh - 190px);width:min(100%,860px,calc((100dvh - 190px) * var(--cols) / var(--rows)))}
}
@media(max-width:760px){
  .puzzle-board{width:min(100%,calc((100dvh - 165px) * var(--cols) / var(--rows)));max-height:calc(100dvh - 165px)}
  .source-art,.building-art{width:88%;height:88%}
  .tray-pipe-art{width:min(54px,90%)}
}
@media(max-width:430px){
  .puzzle-board{width:100%;max-height:none;aspect-ratio:var(--cols)/var(--rows)}
}

/* v0.10 — FlowGrid brand/logo refresh */
.hero{display:grid;grid-template-columns:minmax(180px,300px) minmax(0,1fr);gap:28px;align-items:center;padding:20px 0 18px}
.flowgrid-logo-wrap{display:flex;align-items:center;justify-content:center;min-width:0}
.flowgrid-logo{display:block;width:min(100%,300px);height:auto;filter:drop-shadow(0 10px 18px rgba(32,87,112,.13))}
.hero-copy h1{margin:.15rem 0 .3rem}.brand-credit{display:inline-block;margin-top:.5rem;color:#687b87;font-weight:700;letter-spacing:.035em}
.brandmark{display:none!important}
@media(max-width:700px){.hero{grid-template-columns:1fr;text-align:center;gap:8px;padding-top:8px}.flowgrid-logo{width:min(66vw,250px);margin-inline:auto}.hero-copy p{margin-inline:auto}.hero-copy .eyebrow{margin-top:2px}}

/* v0.11 — fuller cartoon plumbing + MTBCustoms screen branding */
.screen-brand{display:block;margin-top:2px;color:#738397;font-size:.68rem;font-weight:800;letter-spacing:.035em}
.pipe-cast-shadow{stroke:#425866;stroke-width:48;opacity:.98}
.pipe-metal{stroke:#aebdc6;stroke-width:42}
.pipe-metal-highlight{stroke:#eef6f8;stroke-width:13;opacity:.95;transform:translate(-3px,-3px)}
.pipe-center-fill{fill:#aebdc6;stroke:#425866;stroke-width:5}
.pipe-hub-shadow{fill:#425866}
.pipe-hub{fill:#aebdc6;stroke:#718591;stroke-width:3}
.pipe-hub-shine{fill:#eef6f8;opacity:.9}
.pipe-collar-shadow{fill:#425866}
.pipe-collar{fill:#93a7b2;stroke:#dce8ed;stroke-width:2}
.pipe-collar-inner{fill:#bac8cf}
.pipe-collar-shine{stroke:#f7fbfc;stroke-width:3;opacity:.9}
.pipe-water-core{stroke:#16a9ee;stroke-width:23;filter:drop-shadow(0 0 4px rgba(0,157,232,.5))}
.pipe-water-glint{stroke:#9ceaff;stroke-width:6;stroke-dasharray:9 10;animation:waterDash .65s linear infinite}
@keyframes waterDash{to{stroke-dashoffset:-19}}
.pipe-svg.flowing{filter:drop-shadow(0 0 5px rgba(22,169,238,.35))}

/* v0.12 compact game shell + branded results + local sign-in/leaderboard */
.home-shell,.map-shell,.game-shell{width:min(100%,1240px);padding:12px clamp(10px,2vw,22px) 24px}
.game-topbar{margin-bottom:8px}
.game-topbar h1{font-size:clamp(1.25rem,2.4vw,2rem)}
.puzzle-hud-row,.arcade-hud{gap:7px;margin-bottom:8px}
.puzzle-hud-row>div,.arcade-hud>div{padding:8px 10px}
.puzzle-workspace{gap:10px}
.puzzle-panel,.arcade-status,.arcade-instruction{padding:10px}
.result-brand{width:72px;height:72px;margin:0 auto 8px;border-radius:20px;overflow:hidden;box-shadow:0 7px 18px rgba(31,63,96,.16)}
.result-brand img{display:block;width:100%;height:100%;object-fit:cover}
.water-burst{display:none!important}
.home-topline{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:6px}
.mini-brand{display:flex;align-items:center;gap:8px;font-weight:900}
.mini-brand img{width:36px;height:36px;border-radius:10px}
.mini-brand span{display:flex;flex-direction:column}
.mini-brand small{font-size:.62rem;color:var(--muted);font-weight:700}
.home-account{display:flex;gap:7px;flex-wrap:wrap;justify-content:flex-end}
.top-pill{border:1px solid var(--line);background:#fff;border-radius:999px;padding:8px 12px;font-weight:800;cursor:pointer}
.compact-home .hero{padding:10px 0}
.compact-home .flowgrid-logo{max-height:190px}
.signin-label{display:block;text-align:left;font-weight:800;margin:12px 0}
.signin-label input{width:100%;margin-top:6px;border:1px solid var(--line);border-radius:12px;padding:12px;background:#fff;font:inherit}
.leader-list{display:grid;gap:6px;max-height:360px;overflow:auto;margin:12px 0}
.leader-row{display:grid;grid-template-columns:34px 1fr auto;gap:8px;align-items:center;border:1px solid var(--line);border-radius:12px;padding:9px 10px;text-align:left}
.leader-row>b{width:28px;height:28px;border-radius:50%;background:var(--aqua-soft,#e8f7f5);display:grid;place-items:center}
.leader-row span{display:flex;flex-direction:column;font-weight:800}
.leader-row small{font-size:.7rem;color:var(--muted);font-weight:600}
.leader-row strong{font-size:1rem}
.empty-board{padding:18px;border:1px dashed var(--line);border-radius:12px;color:var(--muted)}
.wide-btn{width:100%}
@media(max-width:700px){
  .home-topline{align-items:flex-start}
  .home-account{gap:5px}
  .top-pill{padding:7px 9px;font-size:.82rem}
  .home-shell,.map-shell,.game-shell{padding:8px 8px 18px}
}
