/* 9:16 game frame, matching WFTest's 540×960 screen. Every view lives inside this frame; in battle
   the field fills it and the HUD and party board overlay its top and bottom like the reference. */
.device{--frame-w:min(540px,calc((100dvh - 56px)*9/16));width:var(--frame-w);aspect-ratio:9/16;height:auto;border:0;display:flex;flex-direction:column;justify-self:center}
.device>.header,.device>nav{flex:none}
@media(max-width:740px){.device{--frame-w:min(100vw,calc(100dvh*9/16))}}
/* Taller than 9:16 (phones, narrow windows): use the whole screen instead of letterboxing. */
@media(max-aspect-ratio:9/16){.layout{display:block;padding:0;min-height:0}.side,.right-side{display:none}.device{width:100%;height:calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));aspect-ratio:auto;max-width:none;margin:0;border-radius:0;box-shadow:none}}
/* Short landscape screens: keep 9:16 at a readable size and let the page scroll. */
@media(min-width:741px) and (max-width:1000px) and (max-height:520px){.device{--frame-w:min(100%,405px)}}
@media(max-width:740px) and (display-mode:standalone){.device{--frame-w:min(100vw,calc((100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom))*9/16))}}

/* Battle: full-frame field with the reference HUD — a slim top bar (combo, time, score, the three
   party faces with HP and skill gauges), pause/AUTO/speed tabs on the left edge and a thin fever
   strip at the bottom. The field itself shows everything else. */
.in-battle>.header{display:none}
#battle:not([hidden]){display:block;position:relative;flex:1 1 0;min-height:0;overflow:hidden;background:#0c2434}
.battle-hud{position:absolute;top:0;left:0;right:0;z-index:3;padding:4px 8px 6px 50px;background:linear-gradient(#0d1f2ae6,#0d1f2aa8 75%,#0d1f2a00);pointer-events:none}
.battle-hud .battle-info{height:auto;padding:0;background:transparent;gap:8px}
.hud-clock{margin-left:auto;display:flex;white-space:nowrap;align-items:baseline;gap:5px;background:#0c1a22d9;border:1px solid #ffffff40;border-radius:3px 12px 12px 3px;padding:2px 10px;color:#fff}
.hud-clock small{font-size:9px;letter-spacing:1px;color:#b9d4dc}
.hud-clock b{font-size:14px;letter-spacing:1px;font-variant-numeric:tabular-nums}
.wave-track{display:inline-flex;gap:2px;margin-right:6px;align-self:center}
.wave-track i{display:block;width:14px;height:6px;border-radius:2px;background:#ffffff33}
.wave-track i.done{background:#e8453c}
.wave-track i.now{background:#ffb14a;box-shadow:0 0 4px #ffb14a}
.wave-track i.boss{width:18px;border:1px solid #ff8a8a}
.hud-clock #wave{font-size:9px;color:#ffe9a0;margin-right:4px}
.battle-hud .battle-party{display:flex;gap:6px;padding:4px 0 0;background:transparent}
.battle-hud .battle-member{pointer-events:auto;flex:1;min-width:0;height:auto;display:grid;grid-template-columns:40px 1fr;grid-template-rows:auto auto;column-gap:4px;align-items:center;padding:0;border:0;border-radius:0;background:transparent;overflow:visible;box-shadow:none}
.battle-hud .battle-member{position:relative}
.battle-hud .battle-member>.portrait-art{grid-row:1/3;position:relative;z-index:1;width:30px;height:30px;margin:3px;border-radius:50%;border:2px solid #fff;box-shadow:0 1px 3px #0008}
/* Skill gauge ring around the face: fills clockwise with --gauge (0-100), gold and pulsing when ready. */
.battle-hud .battle-member::before{content:'';position:absolute;left:0;top:50%;width:40px;height:40px;margin-top:-20px;border-radius:50%;background:conic-gradient(#5cc8ff calc(var(--gauge,0)*1%),#0b1a24b3 0)}
.battle-hud .battle-member.ready::before{background:#ffd84a;box-shadow:0 0 10px #ffd84a;animation:skill-ready .8s ease-in-out infinite alternate}
@keyframes skill-ready{to{box-shadow:0 0 18px #fff1a0}}
.battle-hud .battle-member.ready>.portrait-art{border-color:#ffe36a;box-shadow:0 0 8px #ffe36a}
.hud-bars{display:flex;flex-direction:column;gap:2px;min-width:0}
.hud-hp{display:block;height:6px;background:#fff;border:1px solid #1d3a2c;border-radius:3px;overflow:hidden}
.hud-hp i{display:block;height:100%;background:linear-gradient(#8ee57f,#4fbf4a)}
.battle-hud .skill-meter{position:static;display:block;height:6px;background:#0b1a24b3;border:1px solid #ffffff55;border-radius:3px;overflow:hidden}
.battle-hud .skill-meter i{background:linear-gradient(#9be3ff,#3fa9f5)}
.battle-hud .battle-member.ready .skill-meter i{background:linear-gradient(#fff3a0,#ffc93a)}
.battle-hud .hud-state{display:none;justify-content:space-between;gap:4px;font-size:8px;line-height:1.2;color:#dbeef3;white-space:nowrap;overflow:hidden}
.hud-state b,.hud-state strong{font-size:8px;font-weight:700;color:inherit}
.battle-hud .battle-member.ready .hud-state{display:flex;grid-column:2}
.battle-hud .battle-member.ready .hud-state b{display:none}
.battle-hud .battle-member.ready .hud-state strong{color:#ffe36a}
.arena-tools{top:4px;left:0;z-index:4;flex-direction:column;gap:4px}
.arena-tools button,.arena-tools .icon{width:42px;height:auto;min-height:26px;padding:4px 2px;font-size:9px;line-height:1.1;color:#2b3d47;background:#fbfdfe;border:1px solid #c9d7de;border-left:0;border-radius:0 8px 8px 0;box-shadow:0 2px 4px #0005}
.arena-tools #pause{height:40px;font-size:18px}
#gesture{bottom:40px}

/* Tapping anywhere on the field flips, as in the reference. The button stays for keyboard and
   assistive tech but is invisible; HUD, tools and fever strip sit above it. */
#battle .flip{position:absolute;inset:0;z-index:2;margin:0;width:100%;height:100%;opacity:0;border:0;border-radius:0;box-shadow:none}

.battle-board{position:absolute;left:0;right:0;bottom:0;z-index:3;display:flex;flex-direction:column;background:linear-gradient(#0d1f2a00,#0d1f2acc 45%);padding-top:10px;pointer-events:none}
.battle-board .battle-foot{height:18px;padding:0 10px 2px;gap:10px;color:#c3dde4}
.battle-board .battle-foot #power{margin-left:auto;color:#ffe9a0}
@media(prefers-reduced-motion:reduce){.battle-hud .battle-member.ready::before{animation:none}}

/* SKILL READY!! pop-in: a teardrop badge with the member's face slides in from the left edge. */
.skill-ready{position:absolute;left:0;top:44%;z-index:4;display:flex;flex-direction:column;gap:6px;pointer-events:none}
.skill-ready-pop{position:relative;display:flex;align-items:center;gap:6px;width:180px;height:50px;padding-left:6px;border-radius:0 30px 30px 0;background:linear-gradient(90deg,#ffffff,#fdf7d8);border:3px solid #2b2b33;border-left:0;box-shadow:0 4px 10px #0006;animation:skill-ready-in 1.6s ease-out both}
.skill-ready-pop>.portrait-art{width:44px;height:44px;border-radius:50%;border:2px solid #2b2b33}
.skill-ready-pop b{font-size:15px;font-style:italic;font-weight:900;letter-spacing:.5px;color:#39e07a;text-shadow:-2px -2px 0 #0d3b27,2px -2px 0 #0d3b27,-2px 2px 0 #0d3b27,2px 2px 0 #0d3b27}
@keyframes skill-ready-in{0%{transform:translateX(-110%)}15%{transform:translateX(0)}80%{transform:translateX(0);opacity:1}100%{transform:translateX(-20%);opacity:0}}
@media(prefers-reduced-motion:reduce){.skill-ready-pop{animation:none}}
