/* Battle screen: a two-screen console (top = scene, bottom = commands) plus log/chat. Colours, fonts and radii come from tokens.css. */

/* ---------------------------------------------------------------- page layout */
.bt { position: relative; max-width: 1320px; margin: 0 auto; padding: var(--s3) var(--s4) var(--s6); display: flex; flex-direction: column; gap: var(--s3); animation: page-in .25s var(--ease); }
.bt-col { display: contents; }
.bt-bar { order: 1; }
.bt-timer { order: 2; }
.scr.top { order: 3; }
.bt-hinge { order: 4; }
.scr.bottom { order: 5; }
.pn-players { order: 6; }
.pn-rest { order: 7; }
@media (min-width: 900px), (orientation: landscape) and (max-height: 520px) and (min-width: 600px) {
  .bt { display: grid; grid-template-columns: minmax(0, 800px) minmax(340px, 420px); justify-content: center; align-items: start; column-gap: var(--s4); row-gap: 0; }
  .bt-col { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
  .bt-col > * { min-width: 0; }
  .bt-hinge { display: none; }
  .bt-col.side { position: sticky; top: 56px; }
}
/* phones held sideways: scene on the left, commands on the right, nothing taller than the screen */
@media (orientation: landscape) and (max-height: 520px) and (max-width: 899px) {
  .bt { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); column-gap: var(--s3); padding-top: var(--s2); }
  .scr.bottom { width: 100%; }
  .bt-col.side { top: 4px; }
  .bt-col.main { gap: 6px; }
  .bt-bar { flex-wrap: nowrap; gap: 4px; min-height: 32px; }
  .bt-bar > .btn:first-child { width: 36px; padding: 0; font-size: 0; gap: 0; }
  .bt-title, .bt-bar .pill { display: none; }
  .bt-tools { width: auto; margin-left: 0; flex-wrap: nowrap; }
  .bt-tools .btn.sm { padding: 0 8px; font-size: 11px; }
  .bt-panelbtn { font-size: 0 !important; width: 32px; padding: 0 !important; gap: 0 !important; }
  .bt-timer-row { margin-top: 2px; }
}

.bt-bar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-height: 36px; }
.bt-title { font-size: 16px; letter-spacing: .02em; margin-right: var(--s1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; }
.bt-tools { display: flex; gap: var(--s1); flex-wrap: wrap; align-items: center; }
.bt-tools .btn[aria-pressed="true"] { background: var(--panel-3); border-color: var(--blue); }
.bt-panelbtn { display: none; }
@media (max-width: 899px) { .bt-panelbtn { display: inline-flex; } .pn-rest:not(.open) { display: none; } }
.bt-loading { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s3); background: var(--bg); min-height: 60vh; padding: var(--s5); }
.bt-loading .card { max-width: 480px; }

/* decision timer */
.bt-timer { padding: 0 2px; }
.bt-timer-bar { height: 6px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); overflow: hidden; }
.bt-timer-fill { height: 100%; background: var(--blue); transform-origin: left center; transition: transform .3s linear, background .3s; }
.bt-timer[data-state="mine"] .bt-timer-fill { background: var(--green); }
.bt-timer[data-state="idle"] .bt-timer-bar, .bt-timer[data-state="playing"] .bt-timer-bar { opacity: .45; }
.bt-timer[data-state="playing"] .bt-timer-label { color: var(--text-faint); }
.bt-timer.low .bt-timer-fill { background: var(--red); }
.bt-timer-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); margin-top: 4px; font: 600 12px var(--font-display); letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); }
.bt-timer.low .bt-timer-label { color: var(--danger); }
.bt-timer[data-state="mine"] .bt-timer-label { color: var(--green); }
.bt-strikes { display: inline-flex; align-items: center; gap: 4px; }
.strike { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; }
.strike.on { background: var(--red); border-color: var(--red); }

/* ---------------------------------------------------------------- the two screens */
.scr { background: linear-gradient(180deg, var(--panel-2), var(--panel)); border: 1px solid var(--line-2); border-radius: calc(var(--radius-lg) + 4px); padding: 8px; box-shadow: var(--shadow); }
.scr.top { width: min(100%, 800px); margin: 0 auto; }
@media (max-width: 899px) { .scr.top { width: min(100%, 800px, 78vh); } }   /* on phones the scene (5:3) never gets taller than ~47vh, so the commands stay in reach */
.scr.bottom { width: min(100%, 640px); margin: 0 auto; }
@media (min-width: 900px) { .scr.bottom { width: 100%; } }
.bt-hinge { width: 36%; height: 10px; margin: -4px auto; border-radius: 0 0 8px 8px; background: linear-gradient(var(--panel-3), var(--line)); display: flex; justify-content: center; align-items: center; gap: 6px; }
.bt-hinge i { width: 5px; height: 5px; border-radius: 50%; background: var(--bg); }

/* ---------------------------------------------------------------- top screen (scene) */
.sc { position: relative; width: 100%; aspect-ratio: 5 / 3; container-type: inline-size; overflow: hidden; border-radius: var(--radius); background: var(--bg-2); isolation: isolate; user-select: none; -webkit-user-select: none; color: var(--text); }
.sc-bg { position: absolute; inset: 0; background: center / cover no-repeat var(--bg-2); }
.sc-terrain { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .6s; }
.sc[data-terrain="electric"] .sc-terrain { opacity: 1; background: linear-gradient(transparent 40%, color-mix(in srgb, var(--t-electric) 34%, transparent)); }
.sc[data-terrain="grassy"] .sc-terrain { opacity: 1; background: linear-gradient(transparent 40%, color-mix(in srgb, var(--t-grass) 34%, transparent)); }
.sc[data-terrain="misty"] .sc-terrain { opacity: 1; background: linear-gradient(transparent 40%, color-mix(in srgb, var(--t-fairy) 38%, transparent)); }
.sc[data-terrain="psychic"] .sc-terrain { opacity: 1; background: linear-gradient(transparent 40%, color-mix(in srgb, var(--t-psychic) 34%, transparent)); }

/* platforms and sprites */
.sc-ground { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; z-index: 1;
  background: radial-gradient(ellipse at 50% 38%, rgba(255, 255, 255, .26), rgba(8, 12, 26, .46) 72%); box-shadow: inset 0 -.6cqw 1.2cqw rgba(0, 0, 0, .35), 0 1cqw 1.4cqw rgba(0, 0, 0, .22); }
.sc-ground[data-pos="foe"] { left: 71%; top: 50%; width: 31%; height: 10.5%; }
.sc-ground[data-pos="me"] { left: 27%; top: 77%; width: 43%; height: 13%; }
.sc-mon { position: absolute; width: 0; height: 0; z-index: 2; transition: opacity .25s; }
.sc-mon[data-pos="foe"] { left: 71%; top: 49.5%; }
.sc-mon[data-pos="me"] { left: 27%; top: 76%; z-index: 3; }
.sc-mon[data-state="empty"] { display: none; }
.sc-pivot { position: absolute; left: 0; bottom: 0; transform: translateX(-50%); }
.sc-body { transform-origin: 50% 90%; will-change: transform, filter; }
.sc-sprite { display: block; width: auto; height: auto; max-width: none; image-rendering: pixelated; filter: drop-shadow(0 .5cqw .3cqw rgba(0, 0, 0, .3)); transition: opacity .15s; }
.sc-mon[data-pos="me"] .sc-sprite { max-height: 27cqw; }
.sc-mon[data-pos="foe"] .sc-sprite { max-height: 23cqw; }
.sc-mon.is-hidden { opacity: .18; }
.sc-mon.is-dmax .sc-pivot { transform: translateX(-50%) scale(1.3); transform-origin: 50% 100%; }
.sc-mon.is-dmax .sc-sprite { filter: drop-shadow(0 0 1.2cqw var(--red)) drop-shadow(0 0 .5cqw var(--red)); }
.sc-mon.is-entering .sc-sprite { filter: none; }

/* info boxes */
.sc-info { position: absolute; z-index: 6; width: 38%; padding: 1.1cqw 1.8cqw 1.3cqw 2cqw; background: rgba(10, 15, 31, .87); border: .25cqw solid rgba(255, 255, 255, .16); border-left-width: .8cqw; border-radius: 1.3cqw; box-shadow: 0 .6cqw 1.6cqw rgba(0, 0, 0, .45); font-family: var(--font-display); }
.sc-info[data-pos="foe"] { left: 2.5%; top: 4%; border-left-color: var(--red); }
.sc-info[data-pos="me"] { right: 2.5%; bottom: 23.5%; width: 41%; border-left-color: var(--blue); }
.i-top { display: flex; align-items: baseline; gap: 1cqw; min-width: 0; }
.i-name { font-weight: 700; font-size: clamp(11px, 2.9cqw, 24px); line-height: 1.15; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.i-gender { font-weight: 800; font-size: clamp(11px, 2.7cqw, 22px); }
.i-gender[data-g="M"] { color: var(--blue); } .i-gender[data-g="F"] { color: var(--t-psychic); }
.i-lvl { margin-left: auto; font-weight: 600; font-size: clamp(10px, 2.5cqw, 20px); color: var(--text-dim); white-space: nowrap; }
.i-mid { display: flex; align-items: center; gap: 1cqw; margin-top: .5cqw; }
.i-hplabel { font-weight: 800; font-size: clamp(8px, 1.9cqw, 15px); color: var(--yellow); letter-spacing: .06em; }
.sc-info .hpbar { flex: 1; height: clamp(6px, 1.5cqw, 12px); border-radius: 999px; background: rgba(0, 0, 0, .55); }
.sc-info .hpbar-fill { transition: background .25s; }   /* width is driven frame by frame from JS */
.i-status { display: inline-block; padding: 0 .9cqw; border-radius: .5cqw; font: 800 clamp(8px, 1.9cqw, 15px)/1.45 var(--font-display); letter-spacing: .06em; color: #fff; background: var(--panel-3); }
.i-status[data-st="brn"] { background: var(--t-fire); color: var(--on-fire); }
.i-status[data-st="par"] { background: var(--t-electric); color: var(--on-electric); }
.i-status[data-st="psn"] { background: var(--t-poison); color: var(--on-poison); }
.i-status[data-st="tox"] { background: color-mix(in srgb, var(--t-poison) 70%, #000); color: #fff; }
.i-status[data-st="slp"] { background: #6b7799; color: #fff; }
.i-status[data-st="frz"] { background: var(--t-ice); color: var(--on-ice); }
.i-bot { display: flex; align-items: center; justify-content: space-between; gap: 1cqw; margin-top: .6cqw; min-height: clamp(9px, 2.3cqw, 19px); }
.i-hpnum { font-weight: 700; font-size: clamp(10px, 2.5cqw, 20px); font-variant-numeric: tabular-nums; color: var(--text); }
.sc-info[data-pos="foe"] .i-hpnum { color: var(--text-dim); }
.i-balls { display: flex; gap: .3cqw; }
.i-ball { width: clamp(8px, 2.2cqw, 18px); height: auto; image-rendering: pixelated; display: block; }
.i-ball[data-st="unk"] { opacity: .3; filter: grayscale(1); }
.i-ball[data-st="fnt"] { opacity: .5; filter: grayscale(1) brightness(.45); }
.i-ball[data-st="brn"] { filter: drop-shadow(0 0 2px var(--t-fire)); } .i-ball[data-st="par"] { filter: drop-shadow(0 0 2px var(--t-electric)); }
.i-ball[data-st="psn"], .i-ball[data-st="tox"] { filter: drop-shadow(0 0 2px var(--t-poison)); } .i-ball[data-st="slp"] { filter: drop-shadow(0 0 2px #8fa0cc); } .i-ball[data-st="frz"] { filter: drop-shadow(0 0 2px var(--t-ice)); }
.i-chips, .sc-conds { display: flex; flex-wrap: wrap; gap: .5cqw; }
.i-chips:not(:empty), .sc-conds:not(:empty) { margin-top: .7cqw; }
.chip { display: inline-flex; align-items: center; gap: .4cqw; padding: 0 1cqw; border-radius: 999px; font: 600 clamp(8px, 1.9cqw, 15px)/1.5 var(--font-display); letter-spacing: .02em; white-space: nowrap; background: rgba(255, 255, 255, .1); color: var(--text); }
.chip.boost.up { background: color-mix(in srgb, var(--green) 28%, #000); color: var(--green); }
.chip.boost.down { background: color-mix(in srgb, var(--danger) 26%, #000); color: var(--danger); }
.chip.vol { background: color-mix(in srgb, var(--t-psychic) 22%, #000); color: #ffc1d4; }
.chip.cond { background: color-mix(in srgb, var(--yellow) 18%, #000); color: var(--yellow); }
.chip.tera { background: color-mix(in srgb, var(--blue) 22%, #000); color: var(--blue); }
.chip.tera img { width: 2.4cqw; height: auto; }
.sc-pop { position: absolute; z-index: 7; white-space: nowrap; padding: .4cqw 1.8cqw; border-radius: 999px; background: linear-gradient(90deg, var(--yellow), var(--yellow-2)); color: #1c1700; font: 800 clamp(10px, 2.4cqw, 20px) var(--font-display); letter-spacing: .03em; box-shadow: var(--shadow-sm); }
.sc-pop[data-pos="foe"] { top: calc(100% + .8cqw); left: 0; }
.sc-pop[data-pos="me"] { bottom: calc(100% + .8cqw); right: 0; }
.sc-pop.show { animation: pop-in .25s var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.9); } }

/* field badges (weather, terrain, rooms) + turn counter */
.sc-turn { position: absolute; z-index: 6; top: 3%; right: 2.5%; padding: .3cqw 1.6cqw; border-radius: 999px; background: rgba(10, 15, 31, .8); border: 1px solid rgba(255, 255, 255, .18); font: 700 clamp(10px, 2.4cqw, 19px) var(--font-display); letter-spacing: .06em; text-transform: uppercase; }
.sc-field { position: absolute; z-index: 6; top: 11%; right: 2.5%; max-width: 42%; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6cqw; }
.sc-field .chip { background: rgba(10, 15, 31, .8); border: 1px solid rgba(255, 255, 255, .2); }
.sc-field .chip[data-k="rain"] { color: var(--t-water); } .sc-field .chip[data-k="sun"] { color: var(--t-fire); } .sc-field .chip[data-k="sand"] { color: var(--t-ground); }
.sc-field .chip[data-k="hail"] { color: var(--t-ice); } .sc-field .chip[data-k="terrain"] { color: var(--t-grass); } .sc-field .chip[data-k="room"] { color: var(--t-psychic); }

/* weather overlay */
.sc-wx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; transition: background .6s; }
.sc-wx i { position: absolute; display: block; }
.sc[data-weather="rain"] .sc-wx { background: rgba(30, 60, 130, .2); }
.sc[data-weather="rain"] .sc-wx i { top: -12%; left: var(--x); width: .32cqw; height: 6cqw; background: linear-gradient(transparent, rgba(210, 232, 255, .95)); transform: rotate(14deg); animation: wx-rain calc(.6s / var(--s)) linear infinite; animation-delay: var(--d); }
@keyframes wx-rain { to { top: 105%; margin-left: -9%; } }
.sc[data-weather="sand"] .sc-wx { background: rgba(214, 160, 70, .22); }
.sc[data-weather="sand"] .sc-wx i { top: var(--y); left: -5%; width: .7cqw; height: .7cqw; border-radius: 50%; background: rgba(240, 205, 130, .9); animation: wx-sand calc(1.5s / var(--s)) linear infinite; animation-delay: var(--d); }
@keyframes wx-sand { 0% { left: -4%; transform: translateY(0); } 50% { transform: translateY(2cqw); } 100% { left: 104%; transform: translateY(-1cqw); } }
.sc[data-weather="hail"] .sc-wx { background: rgba(170, 215, 235, .14); }
.sc[data-weather="hail"] .sc-wx i { top: -6%; left: var(--x); width: .9cqw; height: .9cqw; border-radius: 50%; background: rgba(240, 250, 255, .95); animation: wx-hail calc(2.2s / var(--s)) linear infinite; animation-delay: var(--d); }
@keyframes wx-hail { to { top: 104%; margin-left: -4%; } }
.sc[data-weather="sun"] .sc-wx { background: radial-gradient(circle at 10% -8%, rgba(255, 232, 120, .75), transparent 58%), rgba(255, 150, 40, .1); animation: sun-pulse 3s ease-in-out infinite; }
@keyframes sun-pulse { 50% { opacity: .7; } }
.sc[data-weather="wind"] .sc-wx i { top: var(--y); left: -10%; width: 8cqw; height: .2cqw; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent); animation: wx-wind calc(1s / var(--s)) linear infinite; animation-delay: var(--d); }
@keyframes wx-wind { to { left: 110%; } }

/* dialogue box */
.sc-text { position: absolute; z-index: 9; left: 0; right: 0; bottom: 0; height: 21%; display: flex; align-items: center; padding: 1.2cqw 4cqw 1.2cqw 3cqw; cursor: pointer;
  background: linear-gradient(180deg, rgba(10, 15, 31, .6), rgba(10, 15, 31, .94) 30%); border-top: 1px solid rgba(255, 255, 255, .14); }
.sc-line { margin: 0; font: 600 clamp(12px, 3.1cqw, 26px)/1.28 var(--font-body); color: var(--text); text-shadow: 0 1px 0 rgba(0, 0, 0, .6); max-height: 100%; overflow: hidden; }
.sc-line.long { font-size: clamp(11px, 2.55cqw, 21px); }
.sc-caret { position: absolute; right: 2.5cqw; bottom: 1.4cqw; color: var(--yellow); font-size: clamp(10px, 2.4cqw, 18px); animation: bob .8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }
.sc-banner { position: absolute; z-index: 10; left: 50%; top: 38%; transform: translate(-50%, -50%); font: 800 clamp(26px, 8.5cqw, 68px) var(--font-display); letter-spacing: .05em; text-transform: uppercase; color: #fff; text-shadow: 0 .6cqw 0 rgba(0, 0, 0, .55), 0 0 3cqw rgba(0, 0, 0, .6); white-space: nowrap; pointer-events: none; }
.sc-banner[data-r="win"] { color: var(--yellow); } .sc-banner[data-r="lose"] { color: var(--blue); }
.sc[data-victory="lose"] .sc-bg { filter: saturate(.5) brightness(.8); }

/* team preview overlay */
.sc-preview { position: absolute; z-index: 8; inset: 0 0 21% 0; padding: 2.4cqw 3cqw; display: flex; flex-direction: column; justify-content: space-between; background: rgba(5, 8, 18, .58); }
.pv-row { display: flex; flex-direction: column; gap: .6cqw; }
.pv-row[data-pos="me"] { align-items: flex-start; } .pv-row[data-pos="foe"] { align-items: flex-end; }
.pv-name { font: 700 clamp(10px, 2.4cqw, 19px) var(--font-display); letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.pv-mons { display: flex; gap: .8cqw; }
.pv-mon { position: relative; width: 11.5cqw; height: 9.5cqw; display: flex; align-items: flex-end; justify-content: center; border-radius: 1cqw; background: rgba(255, 255, 255, .08); border: .2cqw solid rgba(255, 255, 255, .12); transition: transform .15s; }
.pv-mon img { max-width: 92%; max-height: 92%; image-rendering: pixelated; }
.pv-mon.picked { border-color: var(--yellow); background: rgba(255, 210, 63, .22); transform: translateY(-.6cqw); }
.pv-n { position: absolute; top: -.8cqw; left: -.5cqw; min-width: 3.4cqw; height: 3.4cqw; border-radius: 50%; background: var(--yellow); color: #1c1700; font: 800 clamp(9px, 2.1cqw, 16px)/3.4cqw var(--font-display); text-align: center; }

/* effects layer */
.sc-fx { position: absolute; inset: 0; z-index: 8; pointer-events: none; overflow: hidden; }
.sc-fx > * { position: absolute; }
.sc-orb { width: calc(5.2cqw * var(--s, 1)); height: calc(5.2cqw * var(--s, 1)); border-radius: 50%; background: radial-gradient(circle at 36% 34%, #fff 0 12%, var(--c) 46%, transparent 72%); box-shadow: 0 0 2.4cqw var(--c); mix-blend-mode: screen; }
.sc-impact { width: calc(15cqw * var(--sz, 1)); aspect-ratio: 1; background: radial-gradient(circle, #fff 0 20%, var(--c) 22% 100%); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.sc-crit { width: 24cqw; aspect-ratio: 1; background: radial-gradient(circle, #fff 0 25%, var(--yellow) 28% 100%); clip-path: polygon(50% 0, 58% 30%, 85% 15%, 70% 42%, 100% 50%, 70% 58%, 85% 85%, 58% 70%, 50% 100%, 42% 70%, 15% 85%, 30% 58%, 0 50%, 30% 42%, 15% 15%, 42% 30%); }
.sc-ring { width: calc(var(--sz, 90px) * 1.1); aspect-ratio: 1; border-radius: 50%; border: .6cqw solid var(--c); box-shadow: 0 0 2cqw var(--c), inset 0 0 2cqw var(--c); }
.sc-ring.big { border-width: 1cqw; }
.sc-float { white-space: nowrap; font: 800 clamp(11px, 2.7cqw, 22px) var(--font-display); letter-spacing: .06em; color: var(--c); text-shadow: 0 1px 0 #000, 0 0 .8cqw rgba(0, 0, 0, .85); }
.sc-arrow { font-size: clamp(14px, 4cqw, 32px); line-height: 1; color: var(--c); text-shadow: 0 1px 0 #000, 0 0 .8cqw rgba(0, 0, 0, .85); }
.sc-spark { font: 800 clamp(14px, 3.4cqw, 26px)/1 var(--font-display); color: var(--green); text-shadow: 0 1px 0 #000; }
.sc-flash { width: 17cqw; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, #fff 0, rgba(255, 255, 255, .6) 35%, transparent 70%); }
.sc-ball { position: absolute; max-width: none; width: clamp(14px, 4.4cqw, 34px); height: auto; image-rendering: pixelated; }
.sc-rays { width: 52cqw; aspect-ratio: 1; border-radius: 50%; background: repeating-conic-gradient(from 0deg, var(--c) 0 5deg, transparent 5deg 15deg); -webkit-mask: radial-gradient(circle, #000 12%, transparent 68%); mask: radial-gradient(circle, #000 12%, transparent 68%); mix-blend-mode: screen; }
.sc-vignette { left: 0; top: 0; width: 100%; height: 100%; background: radial-gradient(circle at 50% 50%, transparent 25%, rgba(0, 0, 0, .8)); }
.sc-crystal { width: 22cqw; aspect-ratio: 1; background: conic-gradient(from 0deg, var(--c), #fff, var(--c), #fff, var(--c)); clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%); opacity: .9; }

/* ---------------------------------------------------------------- bottom screen (commands) */
.cm { position: relative; width: 100%; aspect-ratio: 4 / 3; display: flex; flex-direction: column; container-type: inline-size; border-radius: var(--radius); background: linear-gradient(180deg, var(--bg-2), var(--panel)); padding: var(--s3); }
.cm > * { flex: 1 1 auto; min-height: 0; }
.cm-main { display: grid; grid-template-rows: auto minmax(70px, 1.5fr) minmax(56px, 1fr) auto; gap: var(--s2); }
.cm-prompt { margin: 0; font: 700 clamp(14px, 4.2cqw, 20px) var(--font-display); text-align: center; color: var(--text); padding: 2px 0; }
.cm-hint { margin: 0; font-size: 12px; color: var(--text-faint); text-align: center; }
.cm-row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.cm-big { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border: 0; border-radius: var(--radius); cursor: pointer; font: 800 clamp(16px, 5.6cqw, 28px) var(--font-display); letter-spacing: .08em; text-transform: uppercase; color: #fff; transition: transform .08s, filter .15s; }
.cm-big small { font: 600 11px var(--font-display); letter-spacing: .08em; opacity: .85; }
.cm-big .k { position: absolute; top: 6px; left: 8px; font: 700 11px var(--font-display); opacity: .65; border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; letter-spacing: 0; }
.cm-big.fight { background: linear-gradient(180deg, #ff6a5f, var(--red)); box-shadow: 0 4px 0 var(--red-2), inset 0 0 0 2px rgba(255, 255, 255, .22); }
.cm-big.mon { background: linear-gradient(180deg, #55e3a0, var(--green)); color: #05261a; box-shadow: 0 4px 0 #2a9e68, inset 0 0 0 2px rgba(255, 255, 255, .25); }
.cm-big.run { background: linear-gradient(180deg, var(--line-2), var(--panel-3)); box-shadow: 0 4px 0 var(--line), inset 0 0 0 2px rgba(255, 255, 255, .12); color: var(--text-dim); }
.cm-big:hover:not(:disabled) { filter: brightness(1.1); }
.cm-big:active:not(:disabled) { transform: translateY(3px); }
.cm-big:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; filter: saturate(.5); }

.cm-bar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s2); flex: 0 0 auto; }
.cm-title { font: 700 14px var(--font-display); letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); margin-right: auto; }
.cm-back { border: 1px solid var(--line-2); background: transparent; color: var(--text); border-radius: 999px; padding: 4px 14px; min-height: 34px; cursor: pointer; font: 700 13px var(--font-display); letter-spacing: .04em; }
.cm-back:hover { background: var(--panel-2); }
.cm-mechs { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.cm-mech { --mc: var(--t-fairy); display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--mc); background: transparent; color: var(--text); cursor: pointer; font: 700 12px var(--font-display); letter-spacing: .05em; text-transform: uppercase; }
.cm-mech .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mc); box-shadow: 0 0 6px var(--mc); }
.cm-mech.z { --mc: var(--yellow); } .cm-mech.dmax { --mc: var(--red); } .cm-mech.tera { --mc: var(--blue); } .cm-mech.ultra { --mc: var(--t-electric); }
.cm-mech[aria-pressed="true"] { background: color-mix(in srgb, var(--mc) 30%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--mc) 55%, transparent); }
.cm-mech:disabled { opacity: .45; cursor: not-allowed; }

.cm-fight { display: flex; flex-direction: column; }
.cm-moves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.mv { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 3px; text-align: left; min-height: 62px; padding: 8px 10px 7px 12px; border: 0; border-radius: var(--radius); cursor: pointer; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tc) 82%, #fff), var(--tc)); color: var(--on); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .22), 0 3px 0 rgba(0, 0, 0, .4); transition: transform .08s, filter .15s; }
.mv:hover:not(:disabled), .mv:focus-visible { filter: brightness(1.08); }
.mv:active:not(:disabled) { transform: translateY(2px); }
.mv:disabled { cursor: not-allowed; filter: grayscale(.75) brightness(.55); box-shadow: none; }
.mv-key { position: absolute; top: 4px; right: 7px; font: 700 10px var(--font-display); opacity: .55; }
.mv-name { font: 800 clamp(13px, 4cqw, 17px)/1.1 var(--font-display); letter-spacing: .02em; padding-right: 22px; overflow-wrap: anywhere; }
.mv-meta { display: flex; align-items: center; gap: 6px; font: 700 11px var(--font-display); letter-spacing: .04em; }
.mv-meta img { height: 14px; width: auto; display: block; image-rendering: auto; }
.mv-pp { margin-left: auto; font-variant-numeric: tabular-nums; }
.mv-eff { padding: 0 7px; border-radius: 999px; background: rgba(10, 15, 31, .88); font: 800 12px/18px var(--font-display); color: var(--text); }
.mv-eff[data-e="2"], .mv-eff[data-e="4"] { color: var(--green); } .mv-eff[data-e="4"] { box-shadow: 0 0 0 1px var(--green); }
.mv-eff[data-e="0.5"], .mv-eff[data-e="0.25"] { color: var(--danger); } .mv-eff[data-e="0"] { color: var(--text-dim); text-decoration: line-through; }
.mv-why { position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 8px; background: rgba(10, 15, 31, .85); color: var(--text-dim); font: 600 10px/16px var(--font-display); letter-spacing: .04em; text-transform: uppercase; }
.cm-detail { margin-top: var(--s2); padding: var(--s2) var(--s3); border-radius: var(--radius); background: rgba(5, 8, 18, .5); border: 1px solid var(--line); font-size: 13px; line-height: 1.35; min-height: 74px; flex: 1 1 auto; }
.dt-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; } .dt-head strong { font: 700 14px var(--font-display); margin-right: 4px; }
.dt-stats { display: flex; gap: var(--s3); flex-wrap: wrap; color: var(--text-dim); font-size: 12px; margin-top: 2px; } .dt-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.dt-desc { margin: 4px 0 0; color: var(--text-dim); font-size: 12px; }
.dt-eff { margin: 4px 0 0; font-weight: 600; font-size: 12px; color: var(--text-dim); }
.dt-eff[data-e="2"], .dt-eff[data-e="4"] { color: var(--green); } .dt-eff[data-e="0.5"], .dt-eff[data-e="0.25"], .dt-eff.bad { color: var(--danger); }
.cm-note { margin: var(--s2) 0 0; padding: 6px 10px; border-radius: var(--radius-sm); background: rgba(255, 210, 63, .1); border: 1px solid rgba(255, 210, 63, .35); color: var(--yellow); font-size: 12px; flex: 0 0 auto; }
.cm-note.bad { background: rgba(255, 107, 125, .1); border-color: rgba(255, 107, 125, .4); color: var(--danger); }

.cm-switch, .cm-preview { display: flex; flex-direction: column; }
.cm-party { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); align-content: start; }
.pc { position: relative; display: flex; align-items: center; gap: 8px; min-height: 64px; padding: 6px 8px; text-align: left; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer; transition: border-color .15s, background .15s, transform .08s; }
.pc:hover:not(:disabled), .pc:focus-visible { border-color: var(--blue); background: var(--panel-3); }
.pc:active:not(:disabled) { transform: translateY(1px); }
.pc:disabled { cursor: not-allowed; opacity: .55; }
.pc.act { border-color: var(--green); } .pc.fnt { filter: grayscale(.85); opacity: .5; } .pc.picked { border-color: var(--yellow); background: color-mix(in srgb, var(--yellow) 16%, var(--panel-2)); opacity: 1; }
.pc-key { position: absolute; top: 3px; left: 5px; font: 700 10px var(--font-display); opacity: .5; }
.pc-img { width: 40px; height: 40px; object-fit: contain; image-rendering: pixelated; flex: none; }
.pc-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.pc-name { display: flex; align-items: baseline; gap: 4px; font: 700 13px var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-name .g { font-style: normal; } .pc-name .g[data-g="M"] { color: var(--blue); } .pc-name .g[data-g="F"] { color: var(--t-psychic); }
.pc-lv { font: 600 11px var(--font-display); color: var(--text-faint); }
.pc .hpbar { display: block; height: 6px; } .pc .hpbar-fill { display: block; transition: none; }
.pc-hp { display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; font: 600 11px var(--font-display); color: var(--text-dim); font-variant-numeric: tabular-nums; }
.pc-item { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-tag { position: absolute; top: 4px; right: 6px; padding: 0 7px; border-radius: 999px; background: var(--green); color: #05261a; font: 800 10px/16px var(--font-display); letter-spacing: .05em; text-transform: uppercase; }
.pc-order { position: absolute; top: -6px; left: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--yellow); color: #1c1700; font: 800 12px/22px var(--font-display); text-align: center; }
.pc .i-status { font-size: 10px; padding: 0 5px; line-height: 15px; border-radius: 4px; }
.pc .i-status[data-st="brn"] { background: var(--t-fire); color: var(--on-fire); } .pc .i-status[data-st="par"] { background: var(--t-electric); color: var(--on-electric); }
.pc .i-status[data-st="psn"], .pc .i-status[data-st="tox"] { background: var(--t-poison); color: #fff; } .pc .i-status[data-st="slp"] { background: #6b7799; color: #fff; } .pc .i-status[data-st="frz"] { background: var(--t-ice); color: var(--on-ice); }
.cm-actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: auto; padding-top: var(--s3); flex: 0 0 auto; }
.cm-actions.col { flex-direction: column; align-items: stretch; margin-top: var(--s3); }

.cm-wait, .cm-replay, .cm-result { align-items: center; justify-content: center; text-align: center; gap: var(--s3); display: flex; flex-direction: column; }
.cm-dots { display: flex; gap: 8px; } .cm-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--blue); animation: dot 1.1s ease-in-out infinite; } .cm-dots i:nth-child(2) { animation-delay: .15s; } .cm-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
.cm-rbtns { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: center; }
.cm-segs { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg-2); }
.cm-seg { border: 0; border-radius: 999px; padding: 6px 14px; min-height: 32px; background: transparent; color: var(--text-dim); cursor: pointer; font: 700 12px var(--font-display); letter-spacing: .05em; }
.cm-seg[aria-pressed="true"] { background: var(--panel-3); color: var(--text); box-shadow: inset 0 -2px 0 var(--red); }
.cm-result h2 { font-size: clamp(28px, 9cqw, 44px); letter-spacing: .04em; text-transform: uppercase; }
.cm-result[data-tone="win"] h2 { color: var(--yellow); } .cm-result[data-tone="lose"] h2 { color: var(--blue); } .cm-result[data-tone="draw"] h2 { color: var(--text); }
.cm-rows { display: grid; grid-template-columns: auto auto; gap: 4px var(--s4); margin: 0; font: 600 14px var(--font-display); }
.cm-rows dt { color: var(--text-dim); text-align: right; } .cm-rows dd { margin: 0; text-align: left; } .cm-rows .good { color: var(--green); } .cm-rows .bad { color: var(--danger); }
.cm-result .muted { margin: 0; }

/* ---------------------------------------------------------------- players header, log, chat */
.pn-players { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.pn-vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s2); }
.pn-pl { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.pn-pl:last-child { flex-direction: row-reverse; text-align: right; }
.pn-pl .avatar { width: 36px; height: 36px; }
.pn-pl-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.pn-pl-t strong { font: 700 14px var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pn-pl-t strong small { color: var(--text-dim); font-weight: 600; }
.pn-pl-t .muted { font-size: 12px; }
.pn-pl.me .avatar { border-color: var(--green); }
.pn-vsmark { font: 800 12px var(--font-display); color: var(--text-faint); letter-spacing: .1em; }
.pn-pills { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pn-pills:empty { display: none; }
.pn-rest { display: flex; flex-direction: column; gap: var(--s2); }
.pn-tabs { align-self: flex-start; }
.pn-tabs .badge { margin-left: 6px; }
.pn-body { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.pn-log, .pn-chat { list-style: none; margin: 0; padding: var(--s2) var(--s3); height: 260px; overflow-y: auto; font-size: 13px; line-height: 1.4; scroll-behavior: smooth; }
@media (min-width: 900px) { .pn-log, .pn-chat { height: clamp(220px, 34vh, 400px); } }
.pn-log li, .pn-chat li { padding: 2px 0; overflow-wrap: anywhere; }
.pn-log li.move { color: var(--text); font-weight: 600; }
.pn-log li:not(.move):not(.pn-turn):not(.pn-sys):not(.pn-empty) { color: var(--text-dim); }
.pn-log li.win { color: var(--yellow); font-weight: 700; }
.pn-turn { display: flex; align-items: center; gap: var(--s2); margin: 8px 0 2px; color: var(--text-faint); font: 700 11px var(--font-display); letter-spacing: .1em; text-transform: uppercase; }
.pn-turn::before, .pn-turn::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.pn-sys { color: var(--blue); font-style: italic; }
.pn-empty { color: var(--text-faint); text-align: center; padding: var(--s4) 0; }
.pn-msg b { color: var(--blue); } .pn-msg.mine b { color: var(--yellow); } .pn-msg time { margin-left: 8px; font-size: 11px; }
.pn-chatform { display: flex; gap: var(--s2); padding: var(--s2); border-top: 1px solid var(--line); background: var(--bg-2); }

@media (max-width: 480px) {
  .bt-bar { gap: 6px; }
  .bt-tools { margin-left: 0; width: 100%; gap: 4px; justify-content: space-between; }
  .bt-tools .btn.sm { padding: 0 9px; font-size: 11px; gap: 4px; }
  .bt-seg { padding: 0 8px; font-size: 10px; }
  .bt-bar > .btn:first-child { width: 36px; padding: 0; font-size: 0; gap: 0; }
  .bt-title { flex: 1 1 0; }
  .bt { padding-left: var(--s2); padding-right: var(--s2); }
  .scr { padding: 5px; border-radius: calc(var(--radius) + 2px); }
  .cm { padding: var(--s2); }
  .bt-title { font-size: 14px; }
  .pn-vs { grid-template-columns: 1fr 1fr; } .pn-vsmark { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sc-wx i, .sc-caret, .cm-dots i { animation: none !important; } }

/* narrow bottom screen: drop the category icon so PP and the effectiveness badge fit on one line */
@container (max-width: 360px) { .mv-cat { display: none; } .mv-pp { font-size: 10px; } }
.mv-pp { white-space: nowrap; }

/* animation speed selector */
.bt-segs { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--bg-2); }
.bt-seg { border: 0; border-radius: 999px; padding: 0 10px; min-height: 28px; background: transparent; color: var(--text-dim); cursor: pointer; font: 700 11px var(--font-display); letter-spacing: .05em; text-transform: uppercase; }
.bt-seg[aria-pressed="true"] { background: var(--panel-3); color: var(--text); box-shadow: inset 0 -2px 0 var(--red); }
