:root{color-scheme:light;--ink:#193934;--green:#126050;--muted:#46645e;--paper:#f6f5ec;--line:#d5e0d7;--blue:#54b7ed;--orange:#ffad51}
*{box-sizing:border-box}
body{margin:0;background:radial-gradient(ellipse at 50% 5%,#f6faf2 8%,#e8f0e7 60%,#e3ede4);color:var(--ink);font:16px/1.5 system-ui,"Noto Sans TC",sans-serif}
main{max-width:1120px;margin:auto;padding:16px 26px 30px}
[hidden]{display:none!important}
h1,h2,h3,p{margin:0}
h2{font-size:1.43rem;line-height:1.25}
h3{font-size:1.04rem}
button,input,select{font:inherit}
button{min-height:43px;border:0;padding:8px 16px;border-radius:9px;color:white;background:#13604f;font-weight:720;cursor:pointer}
button:hover:not(:disabled){filter:brightness(1.1)}
button:disabled{cursor:default;opacity:.52}
:focus-visible{outline:3px solid #a74b0e;outline-offset:3px}
.secondary,.top button{background:#e7f2eb;color:#1c5145;border:1px solid #b8d2c4}
.top{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:14px}
.top button{font-size:.84rem;padding:4px 10px;min-height:36px}
.brand{font-weight:850;letter-spacing:.08em;font-size:.92rem}
.brand span{font-weight:630;letter-spacing:0;margin-left:4px}
.hero,.panel{background:#fffdf6;border:1px solid var(--line);border-radius:17px;overflow:hidden;box-shadow:0 10px 28px #21463a12}
.hero{margin-bottom:12px}
.hero-art{aspect-ratio:1536/597;background:#479bd7 url(factory.webp) center/cover no-repeat;padding:clamp(7px,2.4vw,33px) 6%}
.hero h1{font-size:clamp(1.65rem,5.4vw,4.2rem);color:#12382d;letter-spacing:.035em;line-height:1.07;text-shadow:0 1px 2px #e9fcff,0 0 23px #e9fcffe3;max-width:100%}
html[lang=en] .hero h1{font-size:clamp(1.3rem,4.65vw,3.3rem)}
.home-body{padding:23px 7% 28px}
.subtitle{font-weight:800;font-size:1.05rem;margin-bottom:5px}
#intro,.hint{color:var(--muted)}
#startForm{display:flex;gap:10px;align-items:end;flex-wrap:wrap;margin-top:17px}
#startForm label{display:grid;gap:4px;font-size:.9rem}
input,select{border:1px solid #aec7ba;border-radius:8px;min-height:43px;padding:6px 9px;color:var(--ink);background:#f9fcf6}
#name{width:min(52vw,245px)}
.instrument{display:flex;gap:6px 16px;align-items:center;flex-wrap:wrap;background:#21493f;color:#fffdf6;padding:9px 15px;border-radius:10px;font-size:.92rem;font-weight:730}
#map{list-style:none;display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:5px;padding:0;margin:8px 0 12px}
#map li{background:#f5f7ec;border:1px solid #b9cfc1;border-radius:6px;text-align:center;padding:3px;font-variant-numeric:tabular-nums;font-size:.8rem;color:#3f6257}
#map .complete{background:#ccead7;border-color:#81bfa5;color:#124d3e}
#map [aria-current]{background:#164e42;color:#fff;border-color:#164e42}
.panel{padding:15px 19px;margin-bottom:12px}
.brief h2{margin-bottom:5px}
.formula{font-size:clamp(1.15rem,3.4vw,1.8rem);font-weight:760;line-height:1.6;overflow-wrap:normal}
.expression-part{display:inline-block;white-space:pre}
.given-pair{display:flex;gap:10px 24px;flex-wrap:wrap}
.given-pair small{display:block;color:var(--muted);font-weight:750}
.prediction{display:flex;gap:8px 13px;align-items:end;flex-wrap:wrap;margin-top:9px}
#coefficients{display:flex;gap:7px;flex-wrap:wrap}
#coefficients label{display:grid;grid-template-columns:1fr;min-width:0;font-weight:700;font-size:.81rem}
#coefficients input{width:4.1rem;text-align:center;font-weight:800;font-size:1rem}
.prediction .hint{font-size:.8rem;max-width:200px;align-self:center}
.work{padding:0}
.work-head{padding:10px 19px;background:#f5f8ed;border-bottom:1px solid #d5e0d7}
#instruction{color:var(--muted);font-size:.9rem;min-height:1.5em}
.workbench{position:relative;padding:9px 13px 12px;background:linear-gradient(155deg,#294f47,#28574e 60%,#21463d);isolation:isolate;display:grid;gap:8px}
.trays{display:grid;gap:6px;z-index:1}
.tray{display:grid;grid-template-columns:minmax(76px,.6fr) minmax(0,2fr);gap:8px;align-items:center;color:#e0f6ec;background:#122e2ae8;border:1px solid #528b7b;min-height:63px;border-radius:8px;padding:5px 8px}
.tray strong{font-size:.78rem;line-height:1.25}
.tray-tiles,.belt-tiles{display:flex;align-items:center;justify-content:flex-start;gap:5px;flex-wrap:wrap;min-height:42px}
.tray.aligned .tray-tiles{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));justify-items:center}
.tray.flip-glow{border-color:#ffd57d}
.empty{font-size:.74rem;color:#d0e4d5}
.machine-art{display:grid;justify-items:center;background:#4b9690}
.machine-art img{display:block;width:min(100%,520px);height:auto}
.belts{display:grid;grid-template-columns:repeat(var(--lanes,3),minmax(0,1fr));gap:8px;z-index:1}
.belt{min-width:0;min-height:77px;padding:5px;border-radius:9px;background:repeating-linear-gradient(180deg,#3d645a 0 6px,#416d61 6px 11px);border:2px solid #89a99a;color:#fff}
.belt.col0{border-color:#75cfff}.belt.col1{border-color:#ffb66d}.belt.col2{border-color:#ded4b6}
.belt .destination{min-height:29px;padding:1px 7px;width:100%;color:#eaf8ee;background:#172f2b;border:1px solid #6a9788;border-radius:6px;font-size:.79rem}
.belt .destination[disabled]{opacity:1}
.belt .destination:not(:disabled){background:#0c6350;border-color:#a4dbc6}
.belt-tiles{justify-content:center;padding:3px 0 0}
.tile{--tile:#faf0d7;--edge:#827957;position:relative;isolation:isolate;display:inline-grid;place-items:center;flex:0 0 auto;font:800 1rem/1 system-ui,sans-serif;min-width:58px;max-width:100%;height:40px;min-height:0;padding:4px 9px;color:#142f2d;background:transparent;border:0;border-radius:6px;white-space:nowrap;text-shadow:0 1px 0 #ffffff66}
.tile::before,.tile::after{content:"";position:absolute;inset:0;background:var(--edge);z-index:-2;border-radius:inherit}
.tile::after{inset:3px 4px 5px;background:linear-gradient(175deg,#ffffff48,#0000000e),var(--tile);z-index:-1}
.tile.neg::before{background:repeating-linear-gradient(135deg,#2d423b 0 4px,var(--edge) 4px 9px)}
.tile.col0{--tile:#76cbff;--edge:#2a84b3}.tile.col1{--tile:#ffb876;--edge:#bb651c;padding-inline:13px;min-width:66px}
.tile.col0::before,.tile.col0::after{clip-path:polygon(16% 0,84% 0,100% 50%,84% 100%,16% 100%,0 50%)}
.tile.col1::before,.tile.col1::after{clip-path:polygon(47% 0,53% 0,100% 87%,100% 100%,0% 100%,0% 87%)}
.tile.col1{padding-top:12px}
.tile[aria-pressed=true]{outline:2px solid #fff1a7;outline-offset:1px;background:#ffffff28}
.tile.mini{min-width:31px;height:31px;padding-inline:4px;font-size:.76rem}
.tile.mini.col1{min-width:35px;padding-top:9px}
.tile.zero{--tile:#dce8dd;--edge:#97a69c}
.controls{padding:10px 18px;display:flex;gap:6px;flex-wrap:wrap}
.controls:empty{display:none}
.controls button{font-size:.91rem}
.proof{background:#f0f7eb;border-top:1px solid #d3e3d4;padding:11px 18px}
.proof>*+*{margin-top:5px}
.proof .column-note{font-size:.87rem;color:#3c6154;overflow-wrap:anywhere}
.proof .compare-result{display:flex;gap:8px 18px;flex-wrap:wrap}
.proof .compare-result strong{display:block}
.proof .wrong{color:#953717;font-weight:750}
.proof .right{color:#125644;font-weight:750}
.error{border:1px solid #e3a888;border-left:4px solid #ad5230;background:#fff5ed;padding:9px 14px;margin:12px 0;color:#7e321a}
#scene{--accent:#e5a843;background:#173b35;border-top:1px solid #48736a;padding:8px 18px 11px;color:#f1f8ec;text-align:center}
#scene p{font-weight:750;font-size:.91rem}
#scene canvas{display:block;max-width:410px;width:100%;height:auto;aspect-ratio:360/118;margin:auto}
#summary .result-options{display:flex;flex-wrap:wrap;gap:12px;margin:12px 0}
.result-options p{font-size:.9rem}
.board-head{display:flex;justify-content:space-between;gap:8px;align-items:center}
#boardContent{margin-top:10px}
table{width:100%;border-collapse:collapse;margin-top:8px;font-variant-numeric:tabular-nums;font-size:.9rem}
th,td{border-bottom:1px solid #d5e0d7;text-align:left;padding:7px 5px;overflow-wrap:anywhere}
.pagination{display:flex;gap:6px;margin-top:8px}
footer{padding:16px 0 0;text-align:center;font-size:.82rem;color:var(--muted)}
a{color:#135d4c}
@media(max-width:640px){main{padding:10px 12px 20px}.trays,.belts{gap:5px}.belts{grid-template-columns:1fr}.belt{min-height:49px;display:grid;grid-template-columns:minmax(85px,1fr) 2fr;gap:3px;align-items:center}.belt-tiles{justify-content:start}.tray{min-height:53px}.workbench{padding:6px 7px}.panel{padding:12px}.work{padding:0}.work-head,.proof,.controls{padding-right:10px;padding-left:10px}.home-body{padding:13px 14px 16px}.top button{font-size:.73rem}.tile{height:35px;min-width:46px;padding:3px 6px;font-size:.89rem}.tile.col1{min-width:55px;padding-top:10px}.brand{font-size:.76rem}.board-head{align-items:start}.board-head button{font-size:.76rem}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;transition:none!important;animation:none!important}}
#scene button{margin-top:4px;font-size:.78rem;min-height:34px}
.pair-count{font-weight:800;white-space:nowrap}
