:root{color-scheme:dark;--bg:#081016;--surface:#111e27;--raised:#1b2c37;--line:#344b59;--text:#edf4f4;--muted:#adbec7;--accent:#76ead9;--amber:#ffd48b;--danger:#ffada7;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;font-size:15px}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);min-height:100svh}button,input,select{font:inherit}button,select{min-height:44px;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--text);padding:9px 16px}button{cursor:pointer;touch-action:manipulation;transition:background .15s,border-color .15s}button:hover:not(:disabled),select:hover{background:var(--raised);border-color:var(--muted)}button:disabled{opacity:.45;cursor:default}button.primary{background:var(--accent);border-color:var(--accent);color:#082b27;font-weight:700}button.primary:hover{background:#b4fff0;color:#082b27}a{color:var(--accent);text-underline-offset:4px}button:focus-visible,a:focus-visible,select:focus-visible,input:focus-visible,summary:focus-visible{outline:3px solid var(--amber);outline-offset:3px}::selection{background:var(--accent);color:var(--bg)}*{scrollbar-color:var(--line) var(--bg)}[hidden]{display:none!important}.muted{color:var(--muted)}h1,h2,p{margin:0}h2{font-size:25px;line-height:1.3;font-weight:650}p{line-height:1.65}.app{max-width:1180px;margin:auto;padding:0 28px 24px}.masthead{height:82px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line);gap:12px}.brand{display:flex;align-items:center;gap:12px;color:var(--text);font-size:20px;font-weight:650;letter-spacing:.04em;text-decoration:none}.brand svg{width:30px;height:30px;fill:var(--accent);stroke:var(--accent);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.masthead nav{display:flex;gap:8px}.masthead nav button{background:transparent}#completion{color:var(--muted);font-size:13px;margin-left:5px}.level-heading{display:flex;justify-content:space-between;align-items:center;gap:20px;min-height:88px}.level-heading>div:first-child{display:flex;align-items:center;gap:16px;min-width:0}#levelId{font-size:28px;font-variant-numeric:tabular-nums;color:var(--accent);font-weight:400}h1{font-size:22px;font-weight:550;line-height:1.3;text-wrap:balance}.session-stats{display:flex;gap:24px;align-items:center;white-space:nowrap;color:var(--muted);font-size:14px}time{font-variant-numeric:tabular-nums;font-size:17px;color:var(--text)}.playfield{position:relative}#viewport{position:relative;width:100%;height:clamp(350px,60svh,680px);overflow:hidden;border-radius:12px;background:#0c171e}#scene{display:block;width:100%;height:100%;touch-action:none;cursor:crosshair}#scene:focus-visible{outline:3px solid var(--amber);outline-offset:-4px}#labels{position:absolute;inset:0;pointer-events:none;overflow:hidden}.cell-label{position:absolute;color:#f0f7f8;font-size:12px;font-weight:700;line-height:18px;text-align:center;min-width:18px;transform:translate(-50%,-50%);background:#0c171ee6;border-radius:3px;padding:0 2px}.feedback{height:66px;display:flex;gap:8px;align-items:center;padding:8px 2px}.feedback p{flex:1;min-width:0;max-height:50px;overflow:auto;font-size:14px;color:var(--muted);line-height:1.5}.feedback button{flex:none;padding-inline:10px}.dock{display:flex;justify-content:space-between;gap:16px;align-items:center;border-block:1px solid var(--line);padding:14px 0}#tools{display:flex;gap:8px}.tool{display:flex;align-items:center;gap:10px;min-width:110px;text-align:left;padding:9px 14px}.tool svg{width:25px;height:25px;flex:none}.tool .cnt{font-variant-numeric:tabular-nums;margin-left:5px;color:var(--muted)}.tool.on{border-color:var(--accent);background:#163b39}.tool.on .cnt{color:var(--accent)}.actions{display:flex;gap:8px}.text-button{background:transparent;border-color:transparent;color:var(--muted);padding-inline:8px}.board-caption{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:55px;color:var(--muted);font-size:13px}.board-caption span{max-width:70%}.notice{color:var(--amber);font-size:13px}#hintPanel{padding:18px 0;max-width:680px}#hintPanel>div{display:flex;align-items:center;justify-content:space-between}#hintText{color:var(--muted);margin:4px 0 12px}body.reviewing .app{padding-bottom:calc(100px + env(safe-area-inset-bottom))}body.reviewing .dock{display:none}#reviewBar{position:fixed;z-index:4;bottom:0;left:0;right:0;display:flex;align-items:center;gap:16px;padding:16px max(28px,calc((100vw - 1124px)/2)) calc(16px + env(safe-area-inset-bottom));background:var(--surface);border-top:1px solid var(--line)}.review-tools{display:flex;gap:8px}#reviewNext{margin-left:auto;min-width:200px;min-height:48px;font-size:17px}dialog{color:var(--text);background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:28px;width:min(560px,calc(100vw - 32px));max-height:calc(100svh - 40px);overflow:auto;box-shadow:0 24px 80px #0008}dialog::backdrop{background:#02070bbd}dialog p{margin-block:16px;color:var(--muted)}.dialog-head{display:flex;justify-content:space-between;align-items:center;gap:14px;margin-bottom:22px}.dialog-head h2{font-size:24px}.settings{display:grid;gap:0}.settings label{display:flex;align-items:center;justify-content:space-between;gap:18px;min-height:65px;border-bottom:1px solid var(--line)}.settings input[type=checkbox]{width:22px;height:22px;accent-color:var(--accent);margin:11px}.settings input[type=range]{width:150px;min-height:44px;accent-color:var(--accent)}.menu-actions{display:flex;flex-wrap:wrap;gap:10px;margin:22px 0}details{padding:16px 0;border-top:1px solid var(--line)}summary{cursor:pointer;min-height:32px;line-height:32px;color:var(--muted)}.about-links{display:flex;flex-wrap:wrap;gap:16px}.danger{color:var(--danger)}.help-copy dt{color:var(--accent);font-weight:600;margin-top:20px}.help-copy dd{margin:6px 0 0;line-height:1.7;color:var(--muted)}#levelNav{display:grid;gap:8px}.level-choice{display:grid;grid-template-columns:32px 1fr auto;gap:10px;align-items:center;text-align:left;min-height:66px}.level-choice .record{font-size:12px;color:var(--muted);text-align:right}.level-choice.current{border-color:var(--accent)}.win-content{text-align:center;padding:12px 0}.win-symbol{width:70px;height:70px;stroke:var(--accent);fill:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;margin-bottom:18px}.win-content h2{font-size:32px}.win-actions{display:flex;justify-content:center;gap:12px;margin:24px 0 12px}.win-actions button{min-width:110px}#stageMessage{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;padding:24px;text-align:center;background:var(--bg);z-index:3}#stageMessage p{max-width:40ch;color:var(--muted)}#skipBtn{position:absolute;right:12px;bottom:12px;background:var(--bg)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
@media(max-width:700px){.app{padding:0 12px 20px}.masthead{height:66px}.brand{font-size:17px;gap:8px}.brand svg{width:24px;height:24px}.masthead nav{gap:5px}.masthead nav button{padding:8px 10px}#completion{display:none}.level-heading{min-height:90px;gap:8px;align-items:center}.level-heading>div:first-child{gap:10px}#levelId{font-size:24px}h1{font-size:18px;max-width:190px}.session-stats{flex-direction:column;align-items:flex-end;gap:6px;font-size:12px}time{font-size:15px}#viewport{height:clamp(300px,46svh,500px)}.dock{flex-direction:column;align-items:stretch;gap:10px;padding:12px 0}#tools{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.tool{min-width:0;gap:6px;justify-content:center;padding:8px 5px;font-size:14px}.tool svg{width:21px;height:21px}.tool .cnt{margin-left:0}.actions{justify-content:space-between;gap:6px}.actions button{flex:1}.feedback{height:76px}.feedback p{font-size:13px;max-height:60px}.feedback button{font-size:13px}.board-caption{font-size:12px}.board-caption span{max-width:65%}dialog{padding:22px}.level-choice{grid-template-columns:25px 1fr auto;padding:10px;font-size:14px}#reviewBar{gap:12px;padding:12px 12px calc(12px + env(safe-area-inset-bottom))}.review-tools button{padding-inline:10px;font-size:14px}#reviewNext{flex:1;min-width:120px;font-size:16px}}
@media(max-height:550px) and (orientation:landscape){.masthead{height:56px}.level-heading{min-height:65px}#viewport{height:70svh;min-height:270px}}
@media(prefers-reduced-motion:reduce){button{transition:none}}:root[data-reduced=true] button{transition:none}

.nav-link{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:9px 16px;border:1px solid var(--line);border-radius:8px;color:var(--text);text-decoration:none}.nav-link:hover{background:var(--raised);border-color:var(--muted)}@media(max-width:700px){.nav-link{padding:8px 10px}}

#tools{flex-wrap:wrap}.board-caption{flex-wrap:wrap}.mode-name{color:var(--accent)}#attemptState{margin-left:auto;font-variant-numeric:tabular-nums}.chapter-picker{display:flex;align-items:center;gap:16px}.chapter-picker select{flex:1;min-width:0}
#directions{display:flex;flex-wrap:wrap;gap:8px;padding:12px 0;border-bottom:1px solid var(--line)}.direction{display:flex;gap:8px;align-items:center;padding:8px 12px;min-width:64px}.direction svg{width:28px;height:26px}.direction span{font-variant-numeric:tabular-nums;color:var(--muted)}.direction.on{border-color:var(--accent);background:#163b39}.direction.on span{color:var(--accent)}body.reviewing #directions{display:none}
@media(max-width:700px){.mode-name+#lesson{display:none}#attemptState{font-size:12px}#directions{gap:6px}.direction{padding:7px 8px;min-width:60px}}
.boot-fallback{padding:32px}.boot-fallback button{display:block;margin-top:16px}
.boot-fallback{min-height:100svh;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:var(--text)}
.loading-light{width:min(180px,42vw);height:auto;overflow:visible}
.loading-track,.loading-beam,.loading-mirror{fill:none;stroke-linecap:round;stroke-linejoin:round}
.loading-track{stroke:#29433f;stroke-width:2}
.loading-beam{stroke:#66ffe0;stroke-width:3;stroke-dasharray:140;stroke-dashoffset:140;animation:loading-ray 2.4s ease-in-out infinite}
.loading-source{fill:#66ffe0;animation:loading-source 2.4s ease-in-out infinite}
.loading-mirror{stroke:#ffd48b;stroke-width:3}
.loading-target{fill:#0c171e;stroke:#66ffe0;stroke-width:2;animation:loading-target 2.4s ease-in-out infinite}
.first-guide{display:flex;align-items:center;gap:12px;padding:12px 16px;margin-bottom:10px;border:1px solid #427c71;border-radius:10px;background:#102c2a}
.first-guide p{flex:1;color:#e4fff6;font-size:16px;font-weight:600}
.first-guide button{flex:none}.guide-focus{outline:3px solid #ffd48b;outline-offset:3px}
.guide-target{outline:2px solid #ffd48b;outline-offset:5px;animation:guide-pulse 1.4s ease-in-out infinite}
@keyframes guide-pulse{50%{outline-offset:11px;outline-color:#76ead9}}
@media(max-width:700px){.first-guide{flex-wrap:wrap;gap:8px}.first-guide p{flex-basis:100%;font-size:15px}.first-guide button{flex:1}}
@media(prefers-reduced-motion:reduce){.guide-target{animation:none}}
:root[data-reduced=true] .guide-target{animation:none}
#stageMessage:not(:has(#retryBtn:not([hidden]))) #stageTitle,#stageMessage:not(:has(#retryBtn:not([hidden]))) #stageDetail{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
#stageMessage:has(#retryBtn:not([hidden])) .loading-light{display:none}
@keyframes loading-ray{0%,12%{stroke-dashoffset:140;opacity:.3}60%,80%{stroke-dashoffset:0;opacity:1}100%{stroke-dashoffset:0;opacity:.15}}
@keyframes loading-source{0%,100%{opacity:.55}20%,75%{opacity:1}}
@keyframes loading-target{0%,48%,100%{fill:#0c171e}65%,80%{fill:#66ffe0}}
@media(prefers-reduced-motion:reduce){.loading-beam,.loading-source,.loading-target{animation:none}.loading-beam{stroke-dashoffset:0}}
:root[data-reduced=true] .loading-beam,:root[data-reduced=true] .loading-source,:root[data-reduced=true] .loading-target{animation:none}
:root[data-reduced=true] .loading-beam{stroke-dashoffset:0}
@media(max-width:360px){.brand{font-size:15px;gap:6px;white-space:nowrap}.brand svg{width:20px;height:20px}.masthead nav{gap:4px}.masthead nav button,.nav-link{padding-inline:7px;white-space:nowrap}.tool{position:relative;flex-direction:column;gap:5px;font-size:13px}.tool>span:not(.cnt){white-space:nowrap}.tool .cnt{position:absolute;right:7px;top:7px}.tool svg{width:21px;height:21px}}
.objective{padding:16px 18px;margin-bottom:14px;background:#10212a;border:1px solid #28434c;border-radius:10px}
.objective h2,.dock-title{font-size:13px;letter-spacing:.08em;color:var(--muted);font-weight:600}
.objective p{margin:8px 0;color:var(--text);font-size:16px;font-weight:600;line-height:1.5}
.objective #progTxt{font-size:13px;color:var(--accent);font-variant-numeric:tabular-nums}
.dock-title{display:none}
@media(min-width:1100px){
 .app{max-width:1650px;padding-inline:32px}
 main{display:grid;grid-template-columns:minmax(170px,210px) minmax(0,1fr) minmax(180px,215px);column-gap:24px;align-items:start}
 .level-heading{grid-column:1/-1}.objective{grid-column:1;grid-row:2;margin:0;padding:20px}
 .playfield{grid-column:2;grid-row:2;min-width:0}.dock{grid-column:3;grid-row:2;display:flex;flex-direction:column;align-items:stretch;gap:16px;border:0;border-left:1px solid var(--line);padding:4px 0 12px 20px}
 .dock-title{display:block}#tools{display:flex;flex-direction:column;gap:8px}.tool{width:100%;justify-content:flex-start}.actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}.actions button:last-child{grid-column:1/-1}
 #directions{padding:0 0 12px}.board-caption,#hintPanel{grid-column:2}.board-caption{grid-row:auto}
}
@media(max-width:700px){.objective{padding:10px 14px;margin-bottom:10px;display:flex;align-items:center;gap:10px;flex-wrap:wrap}.objective h2{font-size:12px}.objective p{margin:0;flex:1;font-size:14px}.objective #progTxt{flex-basis:100%;font-size:12px}.dock-title{display:none}}
.feedback:has(#statusTxt:empty):has(#cancelMove[style*="hidden"]){display:none}
.actions button.on{border-color:var(--accent);background:#163b39;color:var(--text)}
.actions{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
@media(min-width:701px) and (max-width:1099px){.dock{flex-direction:column;align-items:stretch}#directions{width:100%}}
@media(min-width:1100px){.actions{grid-template-columns:repeat(2,minmax(0,1fr))}.actions button:last-child{grid-column:auto}body[data-mode="classic"] .actions button:last-child{grid-column:1/-1}}
@media(max-width:700px){.actions{grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}body[data-mode="classic"] .actions{grid-template-columns:repeat(3,minmax(0,1fr))}.actions button{padding-inline:5px}}
