:root {
  color-scheme: light;
  --paper:#f8f0e5; --white:#fffbf2; --edge:#e2cdb9; --ink:#30241f; --muted:#6d5549;
  --warm:#ad3e2d; --night:#221d30; --stage:#242033; --cream:#ffedcf; --gold:#f5bd6b;
  --title:"Noto Serif CJK TC",Georgia,serif;
  font: 16px/1.55 "Noto Sans CJK TC","Microsoft JhengHei",system-ui,sans-serif;
  color:var(--ink); background:var(--paper);
}
*{box-sizing:border-box}
[hidden]{display:none!important}
body,h1,h2,p{margin:0}
button,input,select{font:inherit}
button,a,input,summary,select{outline-offset:3px}
:focus-visible{outline:3px solid #ba602f}
button{min-height:44px;border:1px solid #ae8f79;border-radius:8px;padding:.48rem .83rem;background:#fff9ed;color:var(--ink);font-weight:750;cursor:pointer}
button:hover:not(:disabled){background:#f4e1ca}
button:disabled{opacity:.55;cursor:default}
button.primary{background:var(--warm);border-color:var(--warm);color:white}
button.primary:hover:not(:disabled){background:#842f26}
a{color:inherit;text-underline-offset:.18em}
.top{background:var(--night);color:var(--cream)}
.top-inner,main,footer{max-width:1080px;margin:auto;padding-inline:22px}
.top-inner,.brand,.tools{display:flex;align-items:center;gap:10px}
.top-inner{justify-content:space-between;min-height:61px}
.brand{font-weight:800}
.emblem{height:28px;width:26px;flex:none;border-radius:9px;background:repeating-linear-gradient(90deg,#ffcb78 0 5px,#f0a652 5px 7px);box-shadow:0 -3px #a65b40,0 3px #a65b40}
.tools button{background:#302638;color:var(--cream);border-color:#77575b;white-space:nowrap;min-height:38px}
.tools button:hover:not(:disabled){background:#493345}
.hero{padding:25px 0 12px}
.subject{font-size:.83rem;color:#8d3528;font-weight:800;letter-spacing:.09em}
h1{font:800 clamp(2.05rem,6vw,3.7rem)/1.22 var(--title);letter-spacing:.04em;margin:2px 0 5px}
#tagline{color:var(--muted)}
body.running .hero{padding:10px 0 7px}
body.running h1{font-size:clamp(1.38rem,3.3vw,2rem);margin:0}
body.running .subject,body.running #tagline{display:none}
.paper{border:1px solid var(--edge);border-radius:12px;padding:13px 15px;margin:12px 0;background:var(--white)}
#start-form,.actions{display:flex;flex-wrap:wrap;gap:8px;align-items:end}
#start-form label{display:grid;gap:3px;flex:0 1 265px}
label span{font-weight:800;font-size:.82rem}
input:not([type=range]),select{min-height:44px;border:1px solid #ab8d75;border-radius:8px;color:var(--ink);background:#fffdf5;padding:6px 10px}
input:not([type=range]){min-width:0}
.workshop{background:var(--night);color:var(--cream);border-radius:15px;overflow:hidden;box-shadow:0 9px 24px #30201f24}
.workshop-head{display:flex;justify-content:space-between;align-items:center;padding:10px 16px;gap:8px;border-bottom:1px solid #6d4b42}
.eyebrow{font-size:.72rem;font-weight:800;letter-spacing:.1em;color:var(--gold)}
.workshop h2{font-size:clamp(1.02rem,3vw,1.38rem)}
.stats{font-size:.82rem;display:flex;gap:8px 13px;justify-content:end;flex-wrap:wrap;font-variant-numeric:tabular-nums}
.stage{isolation:isolate;padding:13px 20px 14px;min-height:265px;background:linear-gradient(#201a293b,#201a29ae),var(--backdrop,url('./night.webp')) center 52%/cover,#3e2838}
.lesson{display:flex;gap:8px;justify-content:space-between;align-items:start;margin-bottom:7px}
#question{font-weight:750;background:#201a2ceb;border:1px solid #a78462a0;border-radius:8px;padding:6px 9px}
.predict{border:1px solid #d99466;color:#fff2d7;background:#422635ef;border-radius:8px;padding:5px 9px;font-weight:800;flex:none}
.rack{padding-top:5px;display:grid;grid-template-columns:repeat(var(--slots,7),minmax(0,1fr));gap:clamp(1px,1.1vw,10px);max-width:750px;margin:auto;min-height:159px;align-items:end}
.piece{position:relative;display:flex;min-width:0;min-height:138px;align-items:center;justify-content:end;flex-direction:column;gap:4px;background:#261e30b5;color:#fff5dc;border:1px solid #be8d6459;border-radius:9px;padding:5px 1px 4px;touch-action:manipulation}
.piece:disabled{opacity:1;cursor:default}
.piece:hover:not(:disabled),.piece[aria-pressed=true]{background:#754529;border-color:var(--gold)}
.piece[aria-pressed=true]{box-shadow:inset 0 0 0 2px var(--gold)}
.piece.central{background:#613a20;border-color:#f3bf77;box-shadow:0 0 16px #f7ac6555}
.piece .label{background:#181526;border-radius:4px;color:#fff3d0;text-align:center;font-size:clamp(.8rem,2.6vw,1.16rem);font-weight:900;padding:1px 3px;line-height:1.25;white-space:nowrap}
.piece .index{color:#f4cb9e;font-size:.68rem;line-height:1}
.lamp{display:block;height:calc(var(--height)*1.85px);width:min(62%,44px);margin-bottom:4px;border-radius:42% 42% 36% 36%/24% 24% 24% 24%;position:relative;background:repeating-linear-gradient(90deg,#a94335aa 0 2px,transparent 2px 8px),linear-gradient(90deg,#a94434,#ffd578 49%,#d57849 79%,#9b342f);box-shadow:0 0 13px #f39d5d48,inset 0 0 9px #f4be6f90}
.lamp::before,.lamp::after{content:"";display:block;position:absolute;background:#e2ad67;width:63%;height:4px;border-radius:2px;left:18%;top:-3px}
.lamp::after{top:auto;bottom:-3px}
.parked{max-width:750px;margin:7px auto 0;display:flex;gap:7px;flex-wrap:wrap;color:#ffedcf;font-weight:650;font-size:.79rem}
.parked span,.order-row{display:inline-flex;align-items:center;gap:5px;background:#2a1c2ce8;border:1px solid #ad7d62;border-radius:6px;padding:2px 7px;color:#ffe8ba}
.order-row{margin:2px 5px 3px 0;min-height:36px}
.order-row:disabled{opacity:.65}
.order-row:hover:not(:disabled){background:#6c3d31;color:white}
.inventory-info,.comparison{max-width:750px;margin:6px auto 0;background:#241b29ea;border:1px solid #9d7359;border-radius:7px;padding:5px 9px;color:#ffedca}
.comparison{text-align:center;font-size:.88rem}
.slot{min-width:35px;padding-inline:3px;color:#fce9c9;background:#3f293c;border-color:#a67b64}
.slot:hover:not(:disabled){color:#352025}
.slots{display:flex;flex-wrap:wrap;gap:5px;justify-content:center;margin:7px auto}
.activity #instruction{font-weight:700;color:#5a4134}
.actions{margin-top:8px}
.actions input{width:min(123px,40vw)}
.proof{background:#efe0c6;color:#492719;border-radius:7px;padding:7px 10px;margin-top:7px;font-weight:740}
.error{padding:8px 12px;background:#fae1d5;border:1px solid #bf735a;color:#762918;border-radius:8px;margin:8px 0}
.ruler{max-width:670px;margin:10px auto 2px;background:#221a29ee;border-radius:9px;border:1px solid #c59870;padding:8px 14px;text-align:center}
.ruler-label,#readout{font-size:.84rem;color:#ffe3a8}
#ruler-input{display:block;width:100%;accent-color:var(--gold);min-height:37px;margin:0}
.scale{position:relative;height:51px;border-bottom:1px solid #f9c98a;margin-inline:8px}
.tick{position:absolute;bottom:0;display:block;width:1px;height:7px;background:#dabc9b}
.tick.major{height:11px}
.tick b{position:absolute;bottom:10px;transform:translateX(-50%);font-size:.63rem;color:#fff2d1}
.pin{position:absolute;bottom:22px;transform:translateX(-50%);white-space:nowrap;color:#ffe7b4;background:#893f32;border-radius:4px;padding:0 3px;font-size:.75rem}
.pin:nth-last-of-type(2){bottom:36px}
.pin.mid{bottom:7px;background:#e5b267;color:#321a24}
.ceremony{max-width:750px;height:116px;margin:6px auto 0;background:#251828bb;border:1px solid #aa784f;border-radius:11px}
#art{display:block;width:100%;height:100%}
.progress{display:flex;gap:5px;padding:8px 13px}
.progress span{height:7px;flex:1;background:#594250;border-radius:8px}
.progress .now{background:#edaf63}
.progress .past{background:#d97148}
summary{font-weight:800;cursor:pointer}
footer{display:flex;gap:15px;padding-bottom:18px;color:var(--muted);font-size:.8rem}
@media(max-width:600px){
  .top-inner,main,footer{padding-inline:9px}
  .top-inner{gap:4px}
  .brand{font-size:.82rem}
  .tools{gap:4px}
  .tools button{font-size:.82rem;padding-inline:7px}
  .stage{padding:8px 6px 10px;min-height:186px}
  .workshop-head{padding:7px 9px}
  .rack{min-height:125px}
  .piece{min-height:115px}
  .piece .label{font-size:.75rem}
  .lamp{width:76%;height:calc(var(--height)*1.55px)}
  .lesson{flex-wrap:wrap;margin-bottom:3px;gap:4px}
  #question,.predict{font-size:.85rem}
  .stats{gap:4px;font-size:.69rem}
  .paper{padding:9px 11px}
  .scale .tick.minor{display:none}
}
.ceremony.gallery{height:39px;margin-top:8px;background:#251828d9}
.workshop.finished .rack{display:none}
@media(max-width:600px){.scale .tick.minor{display:block;opacity:.42}}
