:root {
  color-scheme: dark; font-family: system-ui, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --line:#576b4f; --gold:#f5ce77;
  --text:#f3edce; --muted:#beccaa; --blue:#8ce7ef;
  background:#111f19; color:var(--text); font-synthesis:none;
}
* { box-sizing:border-box; }
[hidden] { display:none !important; }
body { margin:0; min-height:100dvh; }
#app { padding:max(10px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); }
button { appearance:none; cursor:pointer; font:inherit; min-height:44px; border:1px solid var(--line); border-radius:3px; color:var(--text); background:#224234; padding:.46rem .64rem; touch-action:manipulation; }
button:focus-visible, summary:focus-visible { outline:3px solid var(--blue); outline-offset:2px; }
button:hover { filter:brightness(1.13); }
button[aria-pressed=true] { border-color:var(--gold); }
button:disabled { opacity:.55; cursor:default; }
.quiet { background:#263b30; box-shadow:inset 0 -2px #12281f; font-weight:650; white-space:nowrap; }
.primary { background:var(--gold); color:#222815; font-weight:850; padding:.7rem 1.3rem; border:1px solid #ffe2a0; box-shadow:0 3px #ad8545; }
h1,h2,h3,p { margin:0; }
h2 { font-size:1.22rem; }
#lobby { max-width:1130px; margin:auto; }
img.sprite { image-rendering:pixelated; }
#game {
  --battle-metal:#263d3e; --battle-inset:#1c3034; --battle-rim:#59746c;
  --battle-edge:#15292b; --battle-light:#f5eaca;
  max-width:min(1350px,163vh); width:100%; margin:auto; position:relative;
}
.tutorial-panel {
  position:absolute; z-index:6; top:var(--guide-y,14%); left:var(--guide-x,8%); width:min(88%,420px);
  padding:9px 12px; background:#1d3335f8; color:#faf0d0; border:2px solid #eb725d; box-shadow:0 4px #152426;
}
.tutorial-head { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.tutorial-head h2 { font-size:1.03rem; }
#tutorial-count { font-size:.75rem; color:#eccf8e; }
#tutorial-copy { margin:5px 0 8px; font-size:.88rem; line-height:1.38; }
.tutorial-highlight { outline:3px solid #ff6151; outline-offset:1px; box-shadow:0 0 0 5px #172427b3; }
.tutorial-highlight.guide-arrow { position:relative; }
.guide-arrow::after {
  content:""; position:absolute; z-index:5; left:50%; top:calc(100% + 6px); width:20px; height:20px;
  transform:translateX(-50%); background:#ff6655; pointer-events:none;
  clip-path:polygon(40% 0,60% 0,60% 15%,75% 15%,75% 30%,90% 30%,90% 45%,65% 45%,65% 100%,35% 100%,35% 45%,10% 45%,10% 30%,25% 30%,25% 15%,40% 15%);
}
.guide-arrow-above::after { top:auto; bottom:calc(100% + 6px); transform:translateX(-50%) rotate(180deg); }
.tilt-demo { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin:0 0 8px; }
.tilt-demo-side { display:flex; justify-content:center; align-items:center; gap:8px; min-height:34px; border:1px solid #728680; color:#f7ebc9; font-size:.83rem; background:#273e3f; }
.tilt-device { display:block; width:12px; height:19px; border:2px solid #c8dcc6; box-shadow:inset 0 -2px #c8dcc6; transform:rotate(-20deg); }
.tilt-demo-side[data-side=right] .tilt-device { transform:rotate(20deg); }
.tilt-demo[data-direction=left] [data-side=left],.tilt-demo[data-direction=right] [data-side=right] { background:#66443b; border-color:#ff7565; }
.stat { display:flex; align-items:center; gap:4px; white-space:nowrap; line-height:1.12; padding-inline:3px; }
.stat strong { font-size:clamp(.95rem,2.7vw,1.46rem); font-variant-numeric:tabular-nums; }
.stat img { width:clamp(15px,2.4vw,22px); height:auto; image-rendering:pixelated; }
.stat.energy strong { color:var(--gold); }
.stat.energy img { filter:drop-shadow(0 0 3px #ffc96e66); }
.battle-sr { position:absolute; width:1px; height:1px; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.battle-stage { display:grid; grid-template-columns:clamp(22px,3.1vw,29px) minmax(0,1fr); gap:5px; min-height:0; }
.arena-bay {
  container-type:inline-size;
}
#arena {
  --arena-height:max(160px,calc(100dvh - 126px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
  position:relative;
  width:100%;
  height:min(var(--arena-height),56.25cqw);
  background:#173629;
  box-shadow:0 0 0 1px #607951,0 0 20px #091711c9;
  overflow:hidden;
}
#arena::after {
  content:""; position:absolute; z-index:1; inset:0; pointer-events:none;
  background:
    radial-gradient(ellipse at center,transparent 53%,#0c1e2219 79%,#07151e5c),
    repeating-linear-gradient(0deg,#1025271c 0 1px,transparent 1px 3px),
    linear-gradient(155deg,#a6dbc91a,transparent 29%);
  box-shadow:inset 0 0 0 1px #9cbab036,inset 0 0 12px #14242930;
}
body.reduced #arena::after { opacity:.5; }
#battle-world { position:absolute; inset:0 auto 0 0; width:100%; }
#field { position:absolute; inset:0; height:100%; width:100%; object-fit:cover; object-position:left top; pointer-events:none; }
#field.native-pixels { image-rendering:pixelated; }
#arena-board { position:absolute; inset:0 auto 0 0; height:100%; width:auto; max-width:100%; aspect-ratio:16 / 9; container-type:inline-size; }
.core-label,.entry-label { position:absolute; top:30%; font-size:clamp(9px,2cqw,12px); color:#f5eacc; background:#233e36; border:1px solid #69816a; padding:0 .25em; pointer-events:none; }
.core-label { left:3%; }.entry-label { left:min(var(--entry-left,90%),calc(100% - 26px)); transform:translateX(-50%); white-space:nowrap; }
#arena[data-lanes="5"] .core-label,#arena[data-lanes="5"] .entry-label { top:3%; }
#arena[data-lanes="5"] .core-label { left:1%; }
#game-status:empty { display:none; }
#game-status { position:absolute; z-index:2; top:.6%; right:max(17%,55px); max-width:45%; color:#fff4ba; font-size:.75rem; background:#243e27ed; padding:.16rem .35rem; pointer-events:none; }
#battle-tip { position:absolute; top:1.5%; left:8%; color:#fff2c6; font-size:clamp(.69rem,2cqw,.95rem); background:#233e36; border:1px solid #69816a; padding:.15em .5em; pointer-events:none; max-width:70%; }
#battle-tip.surge { left:50%; transform:translateX(-50%); z-index:3; white-space:nowrap; color:#fff2c6; background:#643827; border-color:#e0af6e; font-weight:850; }
#grid { position:absolute; top:34%; left:11.667%; width:77.292%; height:57%; display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); grid-template-rows:repeat(3,1fr); }
.cell { padding:0; border:1px solid transparent; min-height:0; min-width:0; width:100%; height:100%; border-radius:0; background:transparent; -webkit-tap-highlight-color:transparent; }
.cell.placeable { border-color:#ace8869c; background:#a8db4f19; }
.cell.highlighted { background:#fff3ae26; box-shadow:inset 0 0 0 1px #fff5bc81; }
.cell.removable { border-color:#ffa687a6; }
.cell.shovel-target { outline:2px solid #ffe4a8; outline-offset:-2px; background:#f2bb6733; }
@media (hover:hover) { .cell:hover { background:#9ad37b3e; } }
#sun-drops { position:absolute; inset:0; pointer-events:none; }
.sun-drop { position:absolute; min-width:44px; min-height:44px; transform:translate(-50%,-50%); pointer-events:auto; border:0; background:transparent; padding:0; color:#33210a; overflow:visible; }
.sun-drop span { display:grid; place-items:end center; min-width:38px; height:40px; margin:auto; background:url('/assets/sun-core.png') center top/36px 36px no-repeat,radial-gradient(ellipse at 50% 43%,#fff2aad0 6%,#ffcf8260 38%,#ffcf8200 71%); filter:drop-shadow(0 0 5px #ffcd688f); image-rendering:pixelated; color:#fff0b7; font-weight:900; font-size:.74rem; line-height:1; text-shadow:0 1px 2px #1d281d,1px 1px #1d281d,-1px -1px #1d281d; animation:sun-entry .22s ease-out,sun-float 1.8s .22s ease-in-out infinite alternate; }
@keyframes sun-entry { from { transform:scale(.6);opacity:.35; } }
@keyframes sun-float { from { transform:translateY(1px); } to { transform:translateY(-4px); } }
.shovel-mode .sun-drop { pointer-events:none; }
#remove { touch-action:none; }
#shovel-ghost { width:26px; height:26px; image-rendering:pixelated; }
#remove[aria-pressed=true] { background:#665038; border-color:#ffdb93; }
#shovel-ghost { position:fixed; z-index:9; pointer-events:none; transform:translate(-25%,-76%) scale(1.3); filter:drop-shadow(0 1px 2px #182920); }
#quiz { display:grid; grid-template-columns:minmax(66px,1fr) minmax(0,2.65fr) minmax(66px,1fr); gap:.38rem; align-items:stretch; }
.quiz-center { display:grid; align-content:center; background:var(--battle-inset); border:1px solid var(--battle-rim); border-radius:2px; padding:.1rem .65rem; min-width:0; color:var(--battle-light); box-shadow:inset 0 1px #8aaca73d; }
.quiz-head { display:flex; align-items:center; justify-content:space-between; gap:.35rem; font-size:clamp(.84rem,2.15vw,1.14rem); line-height:1.12; }
#clock { min-width:2.1rem; text-align:right; color:var(--gold); font-weight:800; }
.clock-track { height:3px; background:#496265; margin:.26rem 0 .1rem; }
#clock-bar { display:block; background:var(--gold); height:100%; }
#quiz button { white-space:normal; line-height:1.06; background:#38594b; color:#ebf1d8; border:1px solid #719180; box-shadow:inset 0 1px #a0b7a35e,inset 0 -3px #213e36; padding:.12em .3em; min-height:44px; font-weight:850; font-size:clamp(.89rem,2.35vw,1.19rem); }
#quiz #option-right { background:#60453e; color:#fff0d9; border-color:#8f6b5d; box-shadow:inset 0 1px #d5a28855,inset 0 -3px #422f2b; }
#quiz[data-format="true-false"] button { font-size:clamp(1.02rem,2.55vw,1.24rem); }
#quiz button { display:flex; justify-content:center; align-items:center; gap:5px; }
.answer-symbol { display:none; flex:none; width:19px; height:19px; border:1px solid currentColor; background:#203c32; }
#quiz[data-format="true-false"] .answer-symbol { display:grid; place-items:center; }
.answer-symbol::before { content:""; width:13px; aspect-ratio:1; background:#c4e7a2; clip-path:polygon(0 45%,18% 45%,18% 60%,33% 60%,33% 75%,46% 75%,46% 60%,61% 60%,61% 44%,76% 44%,76% 28%,91% 28%,91% 9%,100% 9%,100% 39%,86% 39%,86% 55%,71% 55%,71% 70%,55% 70%,55% 86%,29% 86%,29% 76%,14% 76%,14% 61%,0 61%); }
#option-right .answer-symbol { background:#48332e; }
#option-right .answer-symbol::before { background:#ffc4ad; clip-path:polygon(0 0,25% 0,25% 14%,39% 14%,39% 29%,61% 29%,61% 14%,75% 14%,75% 0,100% 0,100% 25%,86% 25%,86% 39%,71% 39%,71% 61%,86% 61%,86% 75%,100% 75%,100% 100%,75% 100%,75% 86%,61% 86%,61% 71%,39% 71%,39% 86%,25% 86%,25% 100%,0 100%,0 75%,14% 75%,14% 61%,29% 61%,29% 39%,14% 39%,14% 25%,0 25%); }
.quiz-dock { position:relative; min-height:48px; padding-top:4px; }
#quiz-idle { display:flex; background:var(--battle-inset); border:1px solid var(--battle-rim); border-radius:2px; min-height:44px; gap:.45rem; align-items:center; padding:2px 5px; }
#quiz-idle p { padding:.12em .4em; font-size:clamp(.75rem,1.65vw,.9rem); margin:0; }
#feedback { color:#e8f4c2; flex:1; }
#feedback[data-outcome=timeout],#feedback[data-outcome=wrong] { color:#ffd2b9; }
#effect-notice { --effect:#bce39e; --effect-face:#243e36; pointer-events:none; }
#effect-notice[data-kind=debuff] { --effect:#ffaaa0; --effect-face:#402f33; }
.quiz-dock:has(#effect-notice:not([hidden])) :is(#quiz,#quiz-idle) { display:none; }
.effect-frame {
  min-height:44px; display:flex; flex-wrap:wrap; align-content:center; justify-content:center; align-items:center;
  gap:2px 8px; padding:4px 8px; text-align:center; border:1px solid var(--effect); border-radius:2px;
  background:var(--effect-face); border-inline-width:3px; box-shadow:inset 0 1px #ffffff20;
  color:var(--battle-light); font-size:clamp(.75rem,1.7vw,.96rem);
  animation:effect-arrive .3s ease-out both;
}
.effect-symbol { width:1.4em; aspect-ratio:1; display:grid; place-items:center; color:var(--effect-face); background:var(--effect); font-weight:900; line-height:1; }
.effect-frame strong { color:var(--effect); white-space:nowrap; }
.effect-detail { line-height:1.2; }
@keyframes effect-arrive { from { opacity:.35; transform:translateY(6px) scale(.98); } to { opacity:1; transform:none; } }
#connection { position:absolute; inset:40% 13% auto; text-align:center; padding:.8em; border:1px solid var(--gold); font-weight:800; color:#d5ebbf; background:#142b23f7; z-index:3; pointer-events:none; }
.tools { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:stretch; gap:5px; padding:0 0 4px; }
.tools .energy { justify-content:center; gap:3px; min-width:50px; padding:3px 4px; background:var(--battle-inset); border:1px solid var(--battle-rim); border-radius:3px; box-shadow:inset 0 1px #8aaca73d; }
#battle-deck { min-width:0; display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:3px; }
.battle-card { position:relative; min-width:0; padding:1px 2px 2px; display:grid; grid-template-rows:auto auto; place-items:center; align-content:center; gap:0; background:var(--battle-metal); border-color:var(--battle-rim); box-shadow:inset 0 1px #8aaca73d,inset 0 -2px var(--battle-edge); font-variant-numeric:tabular-nums; }
.battle-card[aria-pressed=true] { background:#414d3b; border-color:var(--gold); box-shadow:inset 0 -2px #9e864f; }
.battle-card-arrive { animation:battle-card-pop .19s steps(6,end) calc(100ms + var(--slot-delay,0ms)) both; }
@keyframes battle-card-pop { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:none; } }
.battle-card-art { position:relative; display:block; width:clamp(31px,4vw,43px); }
.battle-card-art img { display:block; width:100%; height:auto; aspect-ratio:1; }
.locked-art { position:absolute; inset:0; filter:grayscale(1) brightness(.72); clip-path:inset(0 0 calc(100% - var(--cooldown-left,100%)) 0); visibility:hidden; }
.battle-card.cooling .locked-art { visibility:visible; }
.battle-card[aria-disabled=true] { cursor:default; }
.battle-card[aria-disabled=true]:hover { filter:none; }
.battle-card.shortfall { background:#2c3335; border-color:#566165; }
.battle-card.shortfall .battle-card-art { filter:grayscale(1) brightness(.75); }
.battle-card.shortfall .locked-art { visibility:hidden; }
.battle-card-cost { display:flex; align-items:center; gap:2px; color:var(--gold); font-weight:800; font-size:clamp(.71rem,1.4vw,.88rem); line-height:1.14; }
.battle-card-cost img { width:12px; height:12px; image-rendering:pixelated; }
.battle-card.shortfall .battle-card-cost { filter:grayscale(1); }
.battle-card-timer { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); color:#fffbea; font-size:.84rem; font-weight:900; line-height:1.15; text-shadow:0 1px 2px #111916,0 0 2px #111916; }
.battle-rail {
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:9px;
  min-height:0;
  padding:5px 2px;
  background:#182b23;
  box-shadow:inset 0 0 0 1px #445c46;
}
.combo-panel { display:grid; gap:4px; }
.combo { --combo:#9bdd8b; }
.combo.debuff { --combo:#ff8b83; }
.combo-dots { display:flex; gap:2px; }
.combo-dot { width:5px; height:5px; border:1px solid var(--combo); background:#1b2b23; border-radius:50%; }
.combo-dot.on { background:var(--combo); }
#wave-track { display:flex; flex-direction:column-reverse; gap:3px; flex:1; width:9px; min-height:0; }
.wave-segment { flex:1; min-height:0; background:#293e2e; border:1px solid #647657; }
.wave-segment.done { background:#99cb80; border-color:#b8da96; }
.wave-segment.active { background:linear-gradient(to top,#f2d47b var(--wave-fill,0%),#344a34 0); border-color:#d5be72; }
.wave-segment.extension { border-style:dashed; }
.game-actions { grid-column:3; display:flex; align-items:stretch; gap:4px; }
.game-actions button { display:grid; place-items:center; width:44px; min-height:44px; padding:3px; background:var(--battle-metal); border-color:var(--battle-rim); box-shadow:inset 0 1px #8aaca73d,inset 0 -2px var(--battle-edge); }
.game-actions img,#game-fullscreen img { width:22px; height:22px; image-rendering:pixelated; }
.menu-symbol { width:17px; height:2px; background:currentColor; box-shadow:0 -5px currentColor,0 5px currentColor; }
.settings-actions { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
#game-fullscreen { display:flex; align-items:center; justify-content:center; gap:6px; }
#menu-status { flex-basis:100%; color:#ffcd93; font-size:.89rem; }
dialog { max-height:85dvh; width:min(93vw,620px); background:#1a3227; color:var(--text); padding:1rem; border:1px solid #7a9d6b; border-radius:6px; }
dialog::backdrop { background:#091711c2; }
.dialog-head { display:flex; align-items:center; justify-content:space-between; gap:1rem; margin-bottom:.5rem; }
.description { display:grid; grid-template-columns:75px 1fr; align-items:center; gap:.8rem; padding:.5rem 0; }
.description img { width:72px; }.description p { font-size:.91rem; color:var(--muted); margin:.2rem 0; }
.description details { font-size:.9rem; }
.settings-list { display:grid; gap:.6rem; }
.settings-list label { display:flex; gap:.5rem; align-items:center; min-height:44px; }
.settings-list input { height:20px; width:20px; accent-color:var(--gold); }
#tilt-status { color:var(--muted); font-size:.9rem; }
body.reduced *, body.reduced *::before { animation:none!important; }
body.reduced .locked-art { clip-path:none; }
@media (prefers-reduced-motion:reduce) { *,*::before { animation:none!important; } .locked-art { clip-path:none; } }
@media (orientation:landscape) and (max-height:560px) {
  #app { padding-top:max(2px,env(safe-area-inset-top)); padding-bottom:max(2px,env(safe-area-inset-bottom)); }
  #game {
    display:grid;
    grid-template-rows:auto minmax(155px,1fr) auto;
    max-width:none;
    height:calc(100dvh - max(2px,env(safe-area-inset-top)) - max(2px,env(safe-area-inset-bottom)));
  }
  #arena { height:min(100%,56.25cqw); }
  .quiz-head { font-size:clamp(.82rem,1.9vw,1.15rem); }
}
@media (orientation:landscape) and (max-width:740px) {
  .tutorial-panel { width:min(80%,350px); }
}
@media (orientation:portrait) and (max-width:640px) {
  .tutorial-panel { position:relative; inset:auto; width:min(100%,420px); margin:10px auto 0; }
  .tools { gap:3px; }
  .tools .energy { min-width:39px; gap:2px; padding-inline:2px; }
  #battle-deck { grid-template-columns:none; grid-auto-flow:column; grid-auto-columns:52px; overflow-x:auto; scrollbar-width:thin; }
}
