/* 2-4 指數律 05～07 共用：全畫面 3D 積木＋懸浮算式＋懸浮操作塢（沿用 03、04 的樣式） */
:root {
  --cream: #fff8e8; --ink: #3b2a1a; --orange: #ef9a4f; --orange-d: #d9772c;
  --mint: #5cc2a6; --mint-d: #3a9a80; --red: #e2553a; --gold: #f6d36b; --sky: #0c4a6e;
  --blue: #2563eb;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans TC", sans-serif; color: var(--ink); background: #cce9ff;
  display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden;
}
header { background: var(--sky); color: #fff; flex: 0 0 auto; z-index: 10; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.hd { display: flex; align-items: center; gap: 10px; padding: 6px 14px; max-width: 1400px; margin: 0 auto; }
.hd h1 { font-size: 15px; font-weight: 900; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { display: flex; gap: 5px; flex: 1; justify-content: center; min-width: 0; }
.dot {
  width: 22px; height: 22px; border-radius: 5px; background: rgba(255,255,255,.18);
  font-size: 11px; font-weight: 900; display: flex; align-items: center; justify-content: center;
  border: 2px solid transparent; flex-shrink: 0;
}
.dot.cur { border-color: var(--gold); }
.dot.s10 { background: #22c55e; } .dot.s5 { background: #f59e0b; } .dot.s0 { background: #ef4444; }
.score { background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.2); border-radius: 10px; padding: 3px 10px; font-weight: 900; white-space: nowrap; }
.score b { color: #fcd34d; font-size: 17px; }

main { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; overflow: hidden; }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }

.hud-top {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 4; pointer-events: none; max-width: calc(100% - 24px);
}
.qtag { background: var(--ink); color: var(--cream); font-weight: 900; font-size: 12px; padding: 2px 10px; border-radius: 99px; box-shadow: 0 2px 6px rgba(0,0,0,.2); white-space: nowrap; }
.qbox {
  background: rgba(255,255,255,.94); border: 3.5px solid var(--ink); border-radius: 16px;
  padding: 6px 22px; box-shadow: 0 5px 0 rgba(59,42,26,.28); text-align: center; white-space: nowrap;
}
.qbox .katex { font-size: 1.75em; }

.hud-bottom {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(760px, calc(100% - 20px));
}
.fb {
  background: rgba(255,255,255,.96); border: 3px solid var(--ink); border-radius: 12px;
  padding: 6px 14px; font-size: 14.5px; font-weight: 800; line-height: 1.45;
  box-shadow: 0 4px 0 rgba(59,42,26,.22); display: none; text-align: center; max-width: 100%;
}
.fb.show { display: block; }
.fb.bad { background: #fde8e3; border-color: var(--red); }
.fb.good { background: #ddf6ec; border-color: var(--mint-d); }
.fb .katex { font-size: 1.08em; }

.dock {
  background: rgba(255,248,232,.95); border: 3.5px solid var(--ink); border-radius: 18px;
  padding: 10px 14px; box-shadow: 0 6px 0 rgba(59,42,26,.3);
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; width: 100%;
}
.btn {
  font-family: inherit; font-weight: 900; font-size: 16px; border: 3px solid var(--ink);
  border-radius: 11px; padding: 9px 22px; cursor: pointer; background: #fff; color: var(--ink);
  box-shadow: 0 4px 0 var(--ink); transition: transform .06s, box-shadow .06s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.act { background: var(--blue); color: #fff; font-size: 18px; padding: 10px 28px; }
.btn.next { background: var(--orange); color: #fff; font-size: 17px; padding: 9px 22px; }

.input-area { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: nowrap; width: 100%; }
.slots { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 2.5px solid #cbd5e1; border-radius: 12px; padding: 6px 10px; flex-shrink: 0; }
.slot { display: flex; align-items: center; gap: 4px; font-weight: 900; font-size: 20px; }
.slot-box {
  min-width: 50px; height: 44px; border: 3px solid #94a3b8; border-radius: 9px;
  background: #f8fafc; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900; cursor: pointer; padding: 0 8px; transition: all .15s;
}
.slot-box.active { border-color: var(--blue); background: #eff6ff; box-shadow: 0 0 0 3px rgba(37,99,235,.22); }
.slot-box.right { border-color: var(--mint-d); background: #d8f5ea; color: var(--mint-d); }

.keypad { display: grid; grid-template-columns: repeat(7, minmax(38px, 1fr)); gap: 5px; flex: 1; max-width: 460px; }
.kbtn {
  font-family: inherit; font-weight: 900; font-size: 16px; height: 36px;
  border: 2.5px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink);
  cursor: pointer; box-shadow: 0 3px 0 var(--ink); transition: transform .05s; padding: 0 4px;
}
.kbtn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.kbtn.del { background: #fee2e2; color: var(--red); }
.kbtn.go { background: var(--mint-d); color: #fff; grid-column: span 3; font-size: 15px; }

#intro { position: fixed; inset: 0; background: rgba(12,30,50,.55); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.card { background: var(--cream); border: 4px solid var(--ink); border-radius: 14px; box-shadow: 6px 6px 0 rgba(0,0,0,.3); max-width: 460px; width: 100%; padding: 18px 20px; }
.card h2 { margin: 0 0 8px; font-size: 22px; font-weight: 900; }
.card ul { margin: 6px 0 14px; padding-left: 20px; line-height: 1.7; font-weight: 700; font-size: 15px; }
.card .katex { font-size: 1.05em; }
#done-fallback { display: none; }

@media (max-width: 640px) {
  .dots { display: none; }
  .hd { justify-content: space-between; padding: 6px 8px; }
  .hd h1 { font-size: 13px; }
  .hud-top { top: 8px; }
  .qbox { padding: 4px 12px; }
  .qbox .katex { font-size: 1.25em; }
  .hud-bottom { bottom: 8px; width: calc(100% - 14px); gap: 6px; }
  .dock { padding: 8px 10px; border-radius: 14px; gap: 8px; }
  .input-area { gap: 8px; flex-direction: column; }
  .slot-box { min-width: 44px; height: 38px; font-size: 18px; }
  .keypad { grid-template-columns: repeat(6, 1fr); max-width: 100%; width: 100%; }
  .kbtn { height: 34px; font-size: 15px; }
  .kbtn.go { grid-column: span 1; font-size: 13px; }
  .fb { font-size: 12.5px; padding: 5px 10px; }
}
