:root {
  --ink: #1f2937;
  --panel: #ffffff;
  --go: #22c55e;
  --go-dark: #15803d;
  --blue: #3b82f6;
  --blue-dark: #1d4ed8;
  --vowel: #ef4444;
  --cons: #2563eb;
  --team: #9333ea;
  --gold: #fbbf24;
  --shadow: 0 6px 0 rgba(0,0,0,.25);
  --font: "Arial Rounded MT Bold", "Nunito", "PingFang HK", "Heiti TC", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd8ff; font-family: var(--font); color: var(--ink);
  -webkit-user-select: none; user-select: none; touch-action: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- 按鈕（方塊感） ---------- */
.btn { font-family: var(--font); font-weight: 800; border: 0; border-radius: 14px; cursor: pointer; color: #fff;
  background: var(--blue); box-shadow: 0 5px 0 var(--blue-dark); padding: 12px 20px; font-size: 20px;
  transition: transform .08s; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--blue-dark); }
.btn.go { background: var(--go); box-shadow: 0 5px 0 var(--go-dark); }
.btn.go:active { box-shadow: 0 1px 0 var(--go-dark); }
.btn.big { font-size: 40px; padding: 18px 56px; border-radius: 20px; }
.btn.mid { font-size: 22px; }
.btn.icon { width: 56px; height: 56px; padding: 0; font-size: 28px; background: #fff; color: var(--ink); box-shadow: 0 5px 0 #cbd5e1; }
.btn.gray { background: #94a3b8; box-shadow: 0 5px 0 #64748b; }
.pill { background: rgba(255,255,255,.92); padding: 8px 16px; border-radius: 999px; font-size: 22px; font-weight: 800; box-shadow: var(--shadow); }

/* ---------- 開始畫面 ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  padding: max(16px, env(safe-area-inset-top)) 16px 16px; z-index: 10; }
.screen.scroll { overflow-y: auto; justify-content: flex-start; background: rgba(15,23,42,.5); touch-action: pan-y; }
.logo { text-align: center; filter: drop-shadow(0 8px 0 rgba(0,0,0,.2)); }
.logo-blocks { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.logo-blocks span { width: 64px; height: 72px; display: grid; place-items: center; font-size: 50px; font-weight: 900; color: #fff;
  border-radius: 10px; border: 4px solid rgba(255,255,255,.7); animation: bob 1.6s ease-in-out infinite; }
.logo-blocks span:nth-child(odd) { background: var(--cons); }
.logo-blocks span:nth-child(3), .logo-blocks span:nth-child(5) { background: var(--vowel); }
.logo-blocks span:nth-child(even):not(:nth-child(3)):not(:nth-child(5)) { background: #f59e0b; }
.logo-blocks span:nth-child(2) { animation-delay: .1s } .logo-blocks span:nth-child(3) { animation-delay: .2s }
.logo-blocks span:nth-child(4) { animation-delay: .3s } .logo-blocks span:nth-child(5) { animation-delay: .4s }
.logo-blocks span:nth-child(6) { animation-delay: .5s } .logo-blocks span:nth-child(7) { animation-delay: .6s }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-3deg); } }
.logo-sub { font-size: 34px; font-weight: 900; color: #fff; letter-spacing: 6px; margin-top: 8px; -webkit-text-stroke: 2px #1e3a8a; }
.logo-zh { font-size: 24px; font-weight: 800; color: #1e3a8a; background: #fff; display: inline-block; padding: 4px 16px; border-radius: 10px; margin-top: 6px; }
.title-btns { display: flex; flex-direction: column; gap: 18px; align-items: center; }
.parent-btn { position: fixed; right: 14px; bottom: 14px; background: rgba(255,255,255,.8); border: 0; border-radius: 12px; padding: 8px 14px;
  font-family: var(--font); font-size: 15px; color: #334155; display: flex; flex-direction: column; align-items: center; }
.parent-btn small { font-size: 11px; color: #64748b; }
.parent-btn.holding { background: #fde68a; }

/* ---------- 地圖 ---------- */
.bar { width: 100%; max-width: 980px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bar h2 { margin: 0; font-size: 30px; color: #fff; -webkit-text-stroke: 1.5px #1e3a8a; }
#map { justify-content: flex-start; background: linear-gradient(#8fd8ff, #d6f3ff); overflow-y: auto; touch-action: pan-y; }
.world-grid { width: 100%; max-width: 980px; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; padding-bottom: 30px; }
.world { position: relative; border: 0; border-radius: 20px; padding: 16px 12px 14px; color: #fff; font-family: var(--font); text-align: center;
  cursor: pointer; box-shadow: 0 8px 0 rgba(0,0,0,.25); transition: transform .1s; }
.world:active { transform: translateY(5px); }
.world .num { position: absolute; top: 8px; left: 12px; font-size: 18px; font-weight: 900; opacity: .8; }
.world .em { font-size: 44px; }
.world .nm { font-size: 22px; font-weight: 900; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.world .zh { font-size: 15px; background: rgba(255,255,255,.9); color: var(--ink); border-radius: 8px; padding: 2px 8px; display: inline-block; margin-top: 6px; }
.world .st { font-size: 26px; margin-top: 6px; letter-spacing: 2px; }
.world.locked { filter: grayscale(1) brightness(.85); }
.world.locked::after { content: "🔒"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 60px; background: rgba(0,0,0,.25); border-radius: 20px; }
.world.review { background: linear-gradient(135deg, #f97316, #ec4899); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
#hud > .hud-top, #hud > .toast { pointer-events: none; }
.hud-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.dots { display: flex; gap: 6px; background: rgba(255,255,255,.85); padding: 8px 12px; border-radius: 999px; box-shadow: var(--shadow); }
.dots i { width: 18px; height: 18px; border-radius: 5px; background: #cbd5e1; display: block; }
.dots i.done { background: var(--go); }
.dots i.now { background: var(--gold); animation: pulse 1s infinite; }
.dots i.tower { border-radius: 50%; }
@keyframes pulse { 50% { transform: scale(1.25); } }

.word-card { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 70px); left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,.95); border-radius: 22px; padding: 10px 14px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
  border: 4px solid #fff; }
.word-card.win { border-color: var(--go); animation: winpop .5s; }
@keyframes winpop { 40% { transform: translateX(-50%) scale(1.12); } }
.wc-emoji { font-size: 54px; line-height: 1; }
.wc-emoji.huge { font-size: 90px; text-align: center; }
.wc-btns { display: flex; gap: 10px; justify-content: center; }
.boxes { display: flex; gap: 8px; }
.box { width: 56px; height: 62px; border-radius: 10px; border: 4px dashed #94a3b8; display: grid; place-items: center; font-size: 36px; font-weight: 900; background: #f8fafc; }
.box.team { width: 72px; }
.box.now { border-color: var(--gold); border-style: solid; animation: pulse 1.2s infinite; }
.box.filled { border-style: solid; color: #fff; animation: fillpop .35s; }
.box.filled.v { background: var(--vowel); border-color: #b91c1c; }
.box.filled.c { background: var(--cons); border-color: #1e3a8a; }
.box.filled.t { background: var(--team); border-color: #581c87; }
.box.shake { animation: shake .35s; }
@keyframes fillpop { 0% { transform: scale(.3); } 70% { transform: scale(1.2); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.boxes.large .box { width: 74px; height: 82px; font-size: 48px; }
.boxes.large .box.team { width: 96px; }

.joy { position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: max(24px, env(safe-area-inset-bottom)); width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255,255,255,.35); border: 4px solid rgba(255,255,255,.8); touch-action: none; }
.knob { position: absolute; left: 50%; top: 50%; width: 66px; height: 66px; margin: -33px 0 0 -33px; border-radius: 50%; background: #fff; box-shadow: 0 4px 0 #94a3b8; }
.jump { position: absolute; right: max(24px, env(safe-area-inset-right)); bottom: max(34px, env(safe-area-inset-bottom)); width: 110px; height: 110px; border-radius: 28px; border: 0;
  background: var(--go); color: #fff; font-size: 44px; font-weight: 900; box-shadow: 0 7px 0 var(--go-dark); font-family: var(--font); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.jump small { font-size: 16px; }
.jump:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--go-dark); }
.toast { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.5); opacity: 0; pointer-events: none;
  font-size: 56px; font-weight: 900; color: #fff; -webkit-text-stroke: 2.5px #1e3a8a; text-align: center; white-space: nowrap; transition: all .25s; }
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------- 面板 ---------- */
.panel-wrap { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(15,23,42,.35); padding: 16px; }
.panel { background: var(--panel); border-radius: 26px; padding: 20px 22px; box-shadow: 0 10px 0 rgba(0,0,0,.2); max-width: 640px; width: 100%;
  display: flex; flex-direction: column; gap: 16px; align-items: center; border: 5px solid #e2e8f0; }
.panel.wide { max-width: 900px; align-items: stretch; margin: 10px 0 40px; }
.panel.wide .bar h2 { color: var(--ink); -webkit-text-stroke: 0; }
.panel-title { font-size: 28px; font-weight: 900; color: #7c3aed; }
.tiles { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.tile { min-width: 78px; height: 78px; padding: 0 12px; border-radius: 14px; border: 0; font-family: var(--font); font-size: 44px; font-weight: 900; color: #fff; cursor: pointer; }
.tile.v { background: var(--vowel); box-shadow: 0 6px 0 #991b1b; }
.tile.c { background: var(--cons); box-shadow: 0 6px 0 #1e3a8a; }
.tile.t { background: var(--team); box-shadow: 0 6px 0 #581c87; }
.tile:active { transform: translateY(4px); }
.tile.used { visibility: hidden; }
.tile.glow { outline: 6px solid var(--gold); animation: pulse .8s infinite; }
.tile.shake { animation: shake .35s; }
#cardBody { text-align: center; font-size: 22px; line-height: 1.5; }
#cardBody h2 { margin: 0 0 6px; font-size: 34px; }
#cardBody .big-em { font-size: 70px; }
.card-btns { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.stars-row { font-size: 64px; letter-spacing: 6px; }
.stars-row span { display: inline-block; animation: fillpop .5s both; }
.stars-row span.off { filter: grayscale(1) opacity(.35); }
.result-words { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.result-words span { background: #f1f5f9; border-radius: 10px; padding: 4px 10px; font-size: 20px; }
.result-words span.ok { background: #dcfce7; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.steps div { background: #f1f5f9; border-radius: 14px; padding: 10px 6px; font-size: 17px; }
.steps b { display: block; font-size: 40px; }

/* ---------- 換裝 ---------- */
#avatar.side { align-items: flex-end; justify-content: center; }
.side-panel { max-width: 380px; align-items: stretch; max-height: 92vh; overflow-y: auto; touch-action: pan-y; }
.side-panel h2 { margin: 0; text-align: center; } .side-panel h3 { margin: 4px 0 0; } .side-panel h3 small { font-size: 13px; color: #64748b; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { width: 46px; height: 46px; border-radius: 10px; border: 4px solid #fff; box-shadow: 0 0 0 2px #cbd5e1; cursor: pointer; }
.sw.on { box-shadow: 0 0 0 4px var(--gold); }
.hats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hat { font-family: var(--font); border: 3px solid #e2e8f0; background: #f8fafc; border-radius: 12px; padding: 8px; font-size: 16px; font-weight: 800; cursor: pointer; }
.hat.on { border-color: var(--gold); background: #fef9c3; }
.hat.locked { color: #94a3b8; }

/* ---------- 家長報告 ---------- */
#parentBody { font-size: 17px; line-height: 1.55; }
#parentBody h3 { margin: 18px 0 6px; font-size: 20px; border-left: 6px solid var(--blue); padding-left: 8px; }
#parentBody table { width: 100%; border-collapse: collapse; }
#parentBody td, #parentBody th { border-bottom: 1px solid #e2e8f0; padding: 6px; text-align: left; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: #f1f5f9; border-radius: 14px; padding: 10px; text-align: center; }
.kpi b { display: block; font-size: 30px; color: var(--blue-dark); }
.chip { display: inline-block; background: #fee2e2; border-radius: 8px; padding: 2px 8px; margin: 3px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #e2e8f0; }
.toggle-row input { width: 26px; height: 26px; }
.note { color: #475569; font-size: 15px; }

@media (max-width: 640px), (max-height: 500px) {
  .btn.big { font-size: 32px; padding: 14px 40px; }
  .logo-blocks span { width: 44px; height: 52px; font-size: 34px; }
  .logo-sub { font-size: 24px; }
  .box { width: 44px; height: 50px; font-size: 28px; } .box.team { width: 56px; }
  .wc-emoji { font-size: 42px; }
  .word-card { gap: 8px; padding: 8px 10px; top: calc(max(10px, env(safe-area-inset-top)) + 62px); }
  .word-card .btn.icon { width: 46px; height: 46px; font-size: 22px; }
  .joy { width: 124px; height: 124px; } .jump { width: 92px; height: 92px; font-size: 36px; }
  .tile { min-width: 62px; height: 64px; font-size: 34px; }
  .boxes.large .box { width: 58px; height: 64px; font-size: 36px; } .boxes.large .box.team { width: 74px; }
  .wc-emoji.huge { font-size: 64px; }
  .toast { font-size: 40px; }
}
