/* 骨骼乱斗 — page + UI styles (UI team). Pixel look: sharp 2px borders, hard shadows, no rounded corners. */

:root {
  --bg: #0b0d14;
  --panel: rgba(22, 26, 38, 0.94);
  --panel2: #232a3b;
  --line: #e8d6a0;
  --line-dark: #11141c;
  --line-mid: #786846;
  --text: #e9ecf3;
  --muted: #9aa3b8;
  --gold: #ffd65c;
  --lime: #d4ef1f;
  --red: #ff5a4e;
  --blue: #4aa8ff;
  --green: #5ad25a;
  --yellow: #ffd23c;
  --btn: #343c51;
  --btn-hi: #46506b;
  --font: "Zpix", "Fusion Pixel", "PingFang SC", "Microsoft YaHei", sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --vw: 1vw;   /* logical 1vw / 1vh — overwritten by src/client/view.js (swapped while the page is rotated) */
  --vh: 1vh;
}
/* Portrait phone: after the 「请把手机横过来玩」 hint the page is drawn rotated 90° (src/client/view.js). Everything in
   <body> lays out in a landscape box of the screen's height × width; position:fixed children are relative to it. */
html.rot {
  --sat: env(safe-area-inset-right, 0px);
  --sar: env(safe-area-inset-bottom, 0px);
  --sab: env(safe-area-inset-left, 0px);
  --sal: env(safe-area-inset-top, 0px);
}
html.rot body { position: fixed; left: 0; top: 0; width: var(--sh); height: var(--sw);
  transform-origin: 0 0; transform: translateX(var(--sw)) rotate(90deg); }

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: #000;
  touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
body { font-family: var(--font); color: var(--text); font-size: clamp(12px, min(calc(2.1 * var(--vw)), calc(3.9 * var(--vh))), 18px); line-height: 1.35; }

canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; background: var(--bg); }

#touch { position: fixed; inset: 0; z-index: 10; touch-action: none; }
#touch[hidden] { display: none !important; }
#touch.editing { z-index: 25; }

#ui { position: fixed; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }
#ui [hidden] { display: none !important; }
#ui .screen { position: absolute; inset: 0; pointer-events: auto; display: flex; flex-direction: column;
  padding: max(8px, var(--sat)) max(10px, var(--sar)) max(8px, var(--sab)) max(10px, var(--sal)); }
#ui .screen.screen-fight { pointer-events: none; padding: 0; }

#rotate { position: fixed; inset: 0; z-index: 30; background: #0b0d14; color: var(--gold); display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 22px; font-family: var(--font);
  font-size: 20px; text-align: center; padding: 24px; touch-action: none; }
#rotate[hidden] { display: none !important; }
.rot-icon { width: 56px; height: 92px; border: 4px solid var(--gold); position: relative; animation: rot 2.2s steps(8) infinite; }
.rot-sub { font-size: 13px; color: var(--muted); margin-top: -12px; }
.rot-icon i { position: absolute; left: 50%; bottom: 6px; width: 10px; height: 4px; margin-left: -5px; background: var(--gold); }
@keyframes rot { 0%, 30% { transform: rotate(0deg); } 60%, 100% { transform: rotate(-90deg); } }

/* ───────────── generic widgets ───────────── */
button { font-family: inherit; }
.btn { position: relative; min-height: 44px; min-width: 44px; padding: 4px 14px; font: inherit; font-weight: 700;
  color: var(--text); background: var(--btn); border: 2px solid var(--line-dark); border-radius: 0; cursor: pointer;
  box-shadow: inset 0 0 0 2px #4a536b, 0 3px 0 #05060a; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; text-align: center; touch-action: manipulation; transition: background .06s; }
.btn:hover { background: var(--btn-hi); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 0 0 2px #4a536b, 0 1px 0 #05060a; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--gold); color: #1b1608; box-shadow: inset 0 0 0 2px #fff3b8, 0 3px 0 #6b5310; }
.btn.primary:hover { background: #ffe38b; }
.btn.danger { background: #a8352c; box-shadow: inset 0 0 0 2px #e0685c, 0 3px 0 #3a0f0b; }
.btn.danger.armed { background: #e0412f; box-shadow: inset 0 0 0 2px #ffd23c, 0 3px 0 #3a0f0b; }
.btn.small { min-height: 36px; padding: 2px 10px; font-size: .9em; }
.btn.on { background: #3e5a2a; box-shadow: inset 0 0 0 2px var(--lime), 0 3px 0 #05060a; }
.btn.wide { width: 100%; }
body:not(.touch-mode) #ui :focus { outline: 3px solid var(--gold); outline-offset: 2px; z-index: 2; }
body.touch-mode #ui :focus { outline: none; }
#ui :focus:not(:focus-visible) { outline-color: var(--gold); }

.cycle { justify-content: space-between; min-width: 9em; }
.cycle .cy-label { color: var(--muted); font-weight: 400; margin-right: 4px; }
.cycle .cy-arrow { color: var(--gold); font-size: .8em; }
.cycle .cy-val { flex: 1; text-align: center; }
.toggle { justify-content: space-between; min-width: 9em; }
.toggle .tg-state { color: var(--muted); }
.toggle.on .tg-state { color: var(--lime); }

.panel { background: var(--panel); border: 2px solid var(--line);
  box-shadow: inset 0 0 0 2px var(--line-dark), inset 0 0 0 3px var(--line-mid), 0 4px 0 rgba(0,0,0,.5); padding: 10px 12px; }
.panel h2 { margin: 0 0 8px; color: var(--gold); font-size: 1.15em; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85em; }
.scroll { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; }
.scroll::-webkit-scrollbar { width: 8px; }
html.rot .scroll { touch-action: none; }   /* rotated page: main.js drags .scroll lists itself (native pan is screen-axis) */
.scroll::-webkit-scrollbar-thumb { background: #4a536b; }
.scroll::-webkit-scrollbar-track { background: transparent; }

.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex: 0 0 auto; min-height: 44px; }
.topbar h2 { margin: 0; color: var(--gold); font-size: 1.25em; text-shadow: 2px 2px 0 #000; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .right { display: flex; gap: 8px; align-items: center; margin-right: 50px; }
.topbar .hint { color: #fff; text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; flex: 0 0 auto; }
.tabs .btn { min-height: 40px; padding: 2px 12px; }
.tabs .btn.on { background: var(--gold); color: #1b1608; box-shadow: inset 0 0 0 2px #fff3b8, 0 3px 0 #6b5310; }

.toast { position: absolute; left: 50%; bottom: max(18px, var(--sab)); transform: translate(-50%, 30px); opacity: 0;
  background: #1b2030; border: 2px solid var(--gold); color: var(--text); padding: 8px 16px; z-index: 50; pointer-events: none;
  max-width: calc(86 * var(--vw)); text-align: center; transition: opacity .15s, transform .15s; box-shadow: 0 4px 0 rgba(0,0,0,.6); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.fps { position: absolute; right: max(6px, var(--sar)); bottom: max(4px, var(--sab)); font-size: 11px; color: var(--lime);
  background: rgba(0,0,0,.5); padding: 1px 4px; pointer-events: none; z-index: 50; }
.fsbtn { position: absolute; top: max(6px, var(--sat)); right: max(8px, var(--sar)); width: 44px; height: 44px; z-index: 40;
  pointer-events: auto; background: rgba(20,24,36,.75); border: 2px solid var(--line-dark); box-shadow: inset 0 0 0 2px #4a536b; cursor: pointer; padding: 0; }
.fsbtn[hidden] { display: none; }
/* in a fight the canvas HUD (P2 portrait / name) sits in that corner on 16:9 phones: the pause menu offers 全屏 instead */
body[data-screen="fight"] .fsbtn { display: none; }
.fs-icon { position: absolute; inset: 12px; --c: var(--text);
  background:
    linear-gradient(var(--c), var(--c)) left top / 7px 3px no-repeat, linear-gradient(var(--c), var(--c)) left top / 3px 7px no-repeat,
    linear-gradient(var(--c), var(--c)) right top / 7px 3px no-repeat, linear-gradient(var(--c), var(--c)) right top / 3px 7px no-repeat,
    linear-gradient(var(--c), var(--c)) left bottom / 7px 3px no-repeat, linear-gradient(var(--c), var(--c)) left bottom / 3px 7px no-repeat,
    linear-gradient(var(--c), var(--c)) right bottom / 7px 3px no-repeat, linear-gradient(var(--c), var(--c)) right bottom / 3px 7px no-repeat; }
.fsbtn.on .fs-icon { inset: 14px; --c: var(--gold); }

/* ───────────── logo ───────────── */
.logo { font-weight: 900; color: var(--gold); letter-spacing: .08em; line-height: 1; text-align: center;
  text-shadow: 3px 0 0 #000, -3px 0 0 #000, 0 3px 0 #000, 0 -3px 0 #000, 3px 3px 0 #000, -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000,
               7px 7px 0 #c2402f, 9px 9px 0 #000; }
.logo span { display: inline-block; font-size: clamp(42px, min(calc(10 * var(--vw)), calc(17 * var(--vh))), 110px); transform: skewX(-6deg); }
.logo small { display: block; font-size: clamp(12px, calc(2.4 * var(--vh)), 18px); color: #fff; letter-spacing: .5em; margin-top: 10px; text-shadow: 2px 2px 0 #000; font-weight: 700; }
.logo.small span { font-size: clamp(28px, calc(7 * var(--vh)), 54px); }
.logo.small { padding-bottom: 10px; }   /* room for the 9px drop shadow above the panel */

/* ───────────── loading ───────────── */
.loading { align-items: center; justify-content: center; gap: 16px; background: var(--bg); }
.load-text { color: var(--text); font-size: 1.1em; }
.progress { width: min(360px, calc(70 * var(--vw))); height: 14px; border: 2px solid var(--line); background: #11141c; box-shadow: 0 3px 0 #000; }
.progress i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--gold) 0 10px, #e0b53e 10px 14px); transition: width .2s; }
.load-detail { color: var(--muted); font-size: .85em; min-height: 1.4em; max-width: calc(80 * var(--vw)); text-align: center; }
.load-detail.bad { color: #ff8a78; }
.fatal .panel { max-width: min(620px, calc(92 * var(--vw))); max-height: calc(70 * var(--vh)); display: flex; flex-direction: column; gap: 8px; }
.fatal pre.err { font-size: 11px; color: #ff8a78; white-space: pre-wrap; max-height: calc(30 * var(--vh)); margin: 0; background: #11141c; padding: 6px; }

/* ───────────── title ───────────── */
.screen-title { align-items: center; justify-content: center; cursor: pointer; }
/* 静音 quick toggle (title + main menu): same look as the 全屏 button, just left of it (in its place when 全屏 is hidden) */
.mute-btn { position: absolute; top: max(6px, var(--sat)); right: calc(max(8px, var(--sar)) + 52px); z-index: 3;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(20,24,36,.75); border: 2px solid var(--line-dark); box-shadow: inset 0 0 0 2px #4a536b; color: var(--text); }
#ui:has(> .fsbtn[hidden]) .mute-btn { right: max(8px, var(--sar)); }
.mute-btn svg { width: 24px; height: 24px; display: block; }
.mute-btn:hover { background: rgba(40,46,64,.9); }
.mute-btn:active { transform: translateY(1px); box-shadow: inset 0 0 0 2px #4a536b; }
.mute-btn.muted, .mute-btn.muted:hover, .mute-btn.muted:active { background: rgba(90,36,32,.85); color: #ffb3a8; box-shadow: inset 0 0 0 2px var(--red); }
.title-roster { width: min(860px, calc(96 * var(--vw))); height: clamp(110px, calc(30 * var(--vh)), 230px); position: relative; margin: calc(2 * var(--vh)) 0 calc(1 * var(--vh)); }
.title-roster canvas { position: absolute; inset: 0; }
.press { font-size: 1.2em; color: #fff; text-shadow: 2px 2px 0 #000; animation: blink 1.1s steps(2) infinite; padding: 8px 14px; }
@keyframes blink { 50% { opacity: .25; } }
.ver { position: absolute; left: max(10px, var(--sal)); bottom: max(6px, var(--sab)); color: var(--muted); font-size: 11px; text-shadow: 1px 1px 0 #000; }

/* ───────────── main menu ───────────── */
.screen-menu { align-items: center; justify-content: center; gap: calc(2 * var(--vh)); }
.screen-menu > * { flex-shrink: 0; }   /* never squash the logo under the panel on short landscape phones */
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(190px, 290px)); gap: 10px; }
.menu-grid .btn > span { white-space: nowrap; }
.menu-grid .btn { min-height: max(48px, calc(9 * var(--vh))); font-size: 1.1em; justify-content: flex-start; padding-left: 16px; }
.menu-grid .btn .ico { width: 1.6em; text-align: center; color: var(--gold); }
.menu-grid .btn .sub { font-size: .7em; color: var(--muted); font-weight: 400; margin-left: auto; }
.menu-grid .btn.primary .sub { color: #5b4a14; }
.menu-grid .btn.primary .ico { color: #6b2d10; }
.menu-foot { color: var(--muted); font-size: .8em; text-shadow: 1px 1px 0 #000; text-align: center; }

/* ───────────── slots ───────────── */
.slots-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }
.slot-row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; flex-wrap: wrap; }
.slot-row .tag { width: 2.6em; height: 44px; display: flex; align-items: center; justify-content: center; font-weight: 900;
  color: #111; font-size: 1.1em; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35), 0 3px 0 #000; flex: 0 0 auto; }
.slot-row.off { opacity: .6; }
/* P1 = the one local human (人机对战): a fixed "你" label where P2–P4 have their 电脑 / 关闭 cycle */
.slot-row .slot-you { flex: 0 0 auto; min-width: 3em; font-weight: 900; color: var(--gold); text-align: center; }
.slot-row .cycle { flex: 1 1 9em; }
.slots-foot { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.slots-foot .hint { flex: 1; min-width: 12em; }

/* ───────────── char select ───────────── */
.cs-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 10px; }
.cs-left { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.cs-right { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.chargrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; flex: 0 1 auto; }
.chartile { position: relative; background: #1d2333; border: 2px solid var(--line-dark); box-shadow: inset 0 0 0 2px #3c4560, 0 3px 0 #000;
  min-height: 44px; aspect-ratio: 5 / 4; padding: 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; color: var(--text); overflow: hidden; font: inherit; }
.chartile::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, color-mix(in srgb, var(--cc) 35%, transparent)); }
.chartile .pix { position: absolute; left: 50%; top: 6%; height: 70%; transform: translateX(-50%); image-rendering: pixelated; pointer-events: none; }
.chartile canvas.pix { height: 70% !important; width: auto !important; }
.chartile .ct-name { position: relative; font-weight: 700; text-shadow: 2px 2px 0 #000; font-size: .95em; }
.chartile .marks { position: absolute; top: 3px; left: 3px; right: 3px; display: flex; gap: 2px; flex-wrap: wrap; pointer-events: none; }
.chartile .mark { font-size: 11px; font-weight: 900; color: #111; padding: 0 3px; line-height: 15px; box-shadow: 0 2px 0 #000; }
.chartile .mark.ok { outline: 2px solid #fff; }
.chartile.hot { box-shadow: inset 0 0 0 3px var(--hc, var(--gold)), 0 3px 0 #000; background: #283048; }
.chartile:hover { background: #262e44; }
.cs-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.pchip { display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 3px; min-height: 44px; background: #1b2030;
  border: 2px solid var(--line-dark); box-shadow: inset 0 0 0 2px #3c4560; cursor: pointer; font: inherit; color: var(--text); flex: 1 1 8em; text-align: left; }
.pchip.active { box-shadow: inset 0 0 0 2px var(--gold); background: #2a2f22; }
.pchip .tag { font-weight: 900; color: #111; padding: 0 4px; box-shadow: 0 2px 0 #000; }
.pchip .pc-info { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.pchip .pc-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pchip .pc-state { font-size: .78em; color: var(--muted); }
.pchip.done .pc-state { color: var(--lime); }
.pchip canvas.portrait { flex: 0 0 auto; background: #11141c; }
.cs-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cs-actions .btn { flex: 1 1 auto; }
.cs-preview { position: relative; display: flex; gap: 8px; align-items: stretch; flex: 0 0 auto; height: clamp(120px, calc(40 * var(--vh)), 290px); padding: 6px; }
.cs-preview .pv-canvas { position: relative; flex: 0 0 46%; background: radial-gradient(ellipse at 50% 85%, rgba(255,255,255,.08), transparent 60%), #141826; border: 2px solid var(--line-dark); overflow: hidden; }
.cs-preview .pv-canvas canvas { position: absolute; left: 0; top: 0; }
.cs-preview .pv-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pv-who { font-weight: 900; }
.pv-name { font-size: 1.5em; font-weight: 900; color: var(--gold); text-shadow: 2px 2px 0 #000; line-height: 1.05; }
.pv-title { color: var(--text); }
.pv-style { color: var(--muted); font-size: .82em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.cs-right .movepanel { flex: 1; min-height: 0; }
.palchip { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-flex; gap: 2px; }
.sw i { display: block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.7); box-shadow: 0 2px 0 #000; }
.sw.mini i { width: 8px; height: 12px; border-width: 1px; box-shadow: none; }
.palchip .pal-name { font-weight: 700; }
.palchip.mini .pal-name { font-weight: 400; font-size: .85em; color: var(--muted); }
.random-tile { min-height: 40px; height: 40px; flex: 0 0 auto; aspect-ratio: auto !important; }
.cs-left .chargrid { flex: 1 1 0; min-height: 0; grid-template-rows: repeat(2, minmax(0, 1fr)); }
.cs-left .chartile { aspect-ratio: auto; min-height: 44px; }
.cs-left .cs-chips, .cs-left .cs-actions { flex: 0 0 auto; }
.lobby-right .chartile { aspect-ratio: 16 / 10; }

/* 出招表 panel */
.movepanel { background: var(--panel); border: 2px solid var(--line); box-shadow: inset 0 0 0 2px var(--line-dark), inset 0 0 0 3px var(--line-mid);
  padding: 6px 8px 8px; }
.movepanel h3 { margin: 2px 0 4px; color: var(--gold); font-size: 1em; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.movepanel h3 small { color: var(--muted); font-weight: 400; font-size: .75em; }
.movepanel h4 { margin: 10px 0 4px; color: var(--muted); font-size: .9em; }
.mv-pagehint { color: var(--muted); font-size: .75em; margin: 0 0 4px; }
body.touch-mode .nontouch { display: none; }
.mv-style { color: var(--muted); margin: 0 0 6px; font-size: .85em; }
.moves { display: flex; flex-direction: column; gap: 2px; }
.mv { display: grid; grid-template-columns: 8.2em 1fr; gap: 1px 8px; text-align: left; width: 100%; padding: 4px 6px;
  border: 1px solid transparent; background: #2d3447; color: var(--text); font: inherit; font-size: .9em; min-height: 0; border-radius: 0; }
button.mv { cursor: pointer; }
.mv:nth-child(even) { background: #293043; }
.mv.special { background: #322c40; border-left: 3px solid #5c9cff; }
.mv.ult { background: #3d2830; border-left: 3px solid var(--gold); }
button.mv:hover { border-color: #6a7491; background: #39415a; }
.mv .cmd { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; grid-row: span 2; }
.mv .nm { font-weight: 700; }
.mv.ult .nm { color: var(--gold); }
.mv.tech { background: #33283f; border-left-color: #c77dff; }
.mv.tech .nm { color: #e2b6ff; }
.mv .k.tech-badge { background: #7a3fb8; color: #fff; }
.mv .meta { display: inline-flex; gap: 6px; margin-left: 6px; font-weight: 400; font-size: .8em; flex-wrap: wrap; }
.mv .mp { background: #28549f; color: #fff; padding: 0 4px; }
.mv .dmg { color: #ff8a78; }
.mv .desc { color: #cfd3dc; font-size: .85em; grid-column: 2; }
.mv .flag { display: inline-block; font-size: .8em; padding: 0 3px; margin-left: 4px; background: #5a6378; color: #fff; }
.k { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 2px;
  font: 700 12px/1 ui-monospace, Menlo, Consolas, monospace; color: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.45); border: 1px solid rgba(0,0,0,.35); }
.k.kA { background: #d64838; } .k.kJ { background: #3eaa4c; } .k.kD { background: #3c70dc; } .k.kS { background: #a24ad8; }
.cmd .legacy { flex-basis: 100%; font-size: 10px; color: var(--muted); }
.k.arr { background: #dee2ec; color: #282c3a; font-size: 13px; }
.k.txt { width: auto; padding: 0 4px; background: #3c4258; font: 600 11px/1 var(--font); box-shadow: none; }
.k.sep { width: auto; min-width: 0; background: none; border: 0; box-shadow: none; color: var(--muted); padding: 0 1px; }
.movepanel.compact .mv .desc { display: none; }
.movepanel.compact .mv { grid-template-columns: 7em 1fr; }
.movepanel.compact .mv .cmd { grid-row: auto; }

/* ───────────── stage select ───────────── */
.ss-body { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; }
.stage-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stagecard { position: relative; padding: 0; background: #11141c; border: 2px solid var(--line-dark); box-shadow: inset 0 0 0 2px #3c4560, 0 4px 0 #000;
  cursor: pointer; display: flex; flex-direction: column; overflow: hidden; color: var(--text); font: inherit; min-height: 44px; }
.stagecard canvas { width: 100%; aspect-ratio: 16 / 9; display: block; image-rendering: pixelated; }
.stagecard .sc-name { padding: 6px 8px; font-weight: 900; font-size: 1.05em; text-align: left; background: #1b2030; }
.stagecard.sel { box-shadow: inset 0 0 0 3px var(--gold), 0 4px 0 #000; }
.stagecard.sel .sc-name { color: var(--gold); }
.ss-foot { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.ss-foot .hint { flex: 1; }

/* ───────────── fight ───────────── */
.pausebtn { position: absolute; top: max(4px, var(--sat)); left: 50%; transform: translateX(-50%); width: 40px; height: 40px; min-height: 40px; min-width: 40px;
  pointer-events: auto; background: rgba(20,24,36,.55); border: 2px solid rgba(0,0,0,.6); color: #fff; font-size: 14px; letter-spacing: -2px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); cursor: pointer; z-index: 3; padding: 0; margin-top: 36px; }
body:not(.touch-mode) .pausebtn { opacity: .55; }
.pausebtn:hover { opacity: 1; }
.fight-msg { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); pointer-events: none; color: #fff; font-size: 1.3em;
  text-shadow: 2px 2px 0 #000; background: rgba(0,0,0,.55); padding: 8px 16px; border: 2px solid var(--line); }
.fight-msg[hidden] { display: none; }
.modal { position: absolute; inset: 0; background: rgba(5,7,12,.72); display: flex; align-items: center; justify-content: center;
  pointer-events: auto; z-index: 10; padding: max(8px, var(--sat)) max(10px, var(--sar)) max(8px, var(--sab)) max(10px, var(--sal)); }
.modal[hidden] { display: none; }
/* desktop skill bar (src/client/skillbar.js): bottom-centre under the fighters' feet, sized by --sb-u (≈ game scale) */
.skillbar { --sb-u: 1; --sb-accent: var(--line); position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: flex-end; gap: calc(5px * var(--sb-u)); padding: calc(3px * var(--sb-u)) calc(5px * var(--sb-u)) calc(2px * var(--sb-u));
  background: rgba(12,10,22,.55); border: 2px solid var(--line-dark); box-shadow: inset 0 0 0 1px rgba(232,214,160,.25);
  pointer-events: none; font-family: var(--font); line-height: 1; }
body.touch-mode .skillbar { display: none; }
.skillbar .sb-item { position: relative; display: flex; flex-direction: column; align-items: center; gap: calc(2px * var(--sb-u));
  width: calc(46px * var(--sb-u)); pointer-events: auto; cursor: pointer; transition: opacity .12s, filter .12s; }
.skillbar .sb-mini { width: calc(42px * var(--sb-u)); margin-right: calc(4px * var(--sb-u)); padding-right: calc(7px * var(--sb-u));
  border-right: 2px solid rgba(232,214,160,.25); }
.skillbar .sb-icon { position: relative; width: calc(32px * var(--sb-u)); height: calc(32px * var(--sb-u)); overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #3a4360, #161a28 75%); border: 2px solid var(--sb-accent);
  box-shadow: 2px 2px 0 rgba(0,0,0,.6), inset 0 0 0 1px rgba(0,0,0,.5); }
.skillbar .sb-mini .sb-icon { width: calc(24px * var(--sb-u)); height: calc(24px * var(--sb-u)); }
.skillbar .ult .sb-icon { border-color: var(--yellow); }
.skillbar .tech .sb-icon { border-color: #c77dff; background: radial-gradient(circle at 50% 35%, #5a3f78, #1d1430 75%); }
.skillbar .sb-art { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }
.skillbar .sb-sweep { position: absolute; inset: 0; pointer-events: none;
  background: conic-gradient(rgba(0,0,0,.68) calc(var(--cd, 0) * 1turn), transparent 0); }
.skillbar .sb-cd { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: calc(11px * var(--sb-u)); font-weight: bold; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.skillbar .sb-key { position: absolute; left: 0; top: 0; min-width: calc(10px * var(--sb-u)); padding: 0 calc(2px * var(--sb-u));
  background: rgba(11,13,20,.85); color: var(--gold); font-size: calc(8px * var(--sb-u)); line-height: calc(10px * var(--sb-u));
  text-align: center; border-right: 1px solid var(--line-mid); border-bottom: 1px solid var(--line-mid); }
.skillbar .sb-mp { position: absolute; right: 0; bottom: 0; padding: 0 calc(2px * var(--sb-u)); background: #2d6cdf; color: #fff;
  font-size: calc(7px * var(--sb-u)); line-height: calc(9px * var(--sb-u)); }
.skillbar .ult .sb-mp { background: #c99400; }
.skillbar .tech .sb-mp { background: #8a3fd1; }
.skillbar .sb-name { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: clip; color: var(--text);
  font-size: calc(7.5px * var(--sb-u)); text-shadow: 1px 1px 0 #000; }
.skillbar .sb-mini .sb-name { color: var(--muted); }
.skillbar .sb-mini .sb-cd { font-size: calc(8.5px * var(--sb-u)); }
.skillbar .sb-item.air { opacity: .6; }
.skillbar .sb-item.nomp .sb-art, .skillbar .sb-item.off .sb-art { filter: grayscale(1) brightness(.55); }
.skillbar .sb-item.nomp .sb-icon, .skillbar .sb-item.off .sb-icon { border-color: #555b66; border-style: dashed; }
.skillbar .sb-item.nomp .sb-mp { background: #555b66; text-decoration: line-through; color: #ff9a8f; }
.skillbar .sb-item.off { opacity: .45; }
/* v5.5: free in the current form (Jay 黑哥形态 → 荧光冲刺): violet frame, ∞ instead of the MP cost */
.skillbar .sb-item.free .sb-icon { border-color: #b89aff; box-shadow: 2px 2px 0 rgba(0,0,0,.6), 0 0 6px 1px rgba(154,120,232,.75); }
.skillbar .sb-item.free .sb-mp { background: #6a4aa8; font-size: calc(8px * var(--sb-u)); }
.skillbar .sb-item.cooling .sb-art { filter: brightness(.7); }
.skillbar .sb-item.pulse .sb-icon { animation: sb-glow 1.1s ease-in-out infinite; }
.skillbar .tech.pulse .sb-icon { animation-name: sb-glow-tech; }
.skillbar .sb-item.flash .sb-icon { animation: sb-flash .26s ease-out; }
.skillbar .sb-item.nope { animation: sb-nope .28s; }
.skillbar .sb-item:hover .sb-icon { box-shadow: 2px 2px 0 rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.55); }
@keyframes sb-glow { 0%, 100% { box-shadow: 2px 2px 0 rgba(0,0,0,.6), 0 0 2px 1px rgba(255,210,60,.35); }
  50% { box-shadow: 2px 2px 0 rgba(0,0,0,.6), 0 0 10px 3px rgba(255,210,60,.85); } }
@keyframes sb-glow-tech { 0%, 100% { box-shadow: 2px 2px 0 rgba(0,0,0,.6), 0 0 2px 1px rgba(199,125,255,.35); }
  50% { box-shadow: 2px 2px 0 rgba(0,0,0,.6), 0 0 10px 3px rgba(199,125,255,.9); } }
@keyframes sb-flash { 0% { filter: brightness(2.2); transform: scale(1.12); } 100% { filter: none; transform: none; } }
@keyframes sb-nope { 0%, 100% { transform: none; } 20% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 80% { transform: translateX(-2px); } }
@media (prefers-reduced-motion: reduce) { .skillbar .sb-item.pulse .sb-icon { animation: none; box-shadow: 0 0 6px 2px rgba(255,210,60,.7); } }
.modal > .panel { max-height: 100%; max-width: min(760px, 100%); display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.pause-menu { width: min(420px, 100%); }
.pause-menu .list { display: flex; flex-direction: column; gap: 6px; }
.pause-menu .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pause-menu h3 { margin: 6px 0 0; color: var(--muted); font-size: .85em; font-weight: 400; }
.wide-modal { width: min(760px, 100%); height: 100%; }
.wide-modal .content { flex: 1; min-height: 0; }

/* ───────────── results ───────────── */
.res-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 10px; }
.res-winner { position: relative; display: flex; flex-direction: column; align-items: center; padding: 8px; min-height: 0; }
.res-winner .wcanvas { position: relative; flex: 1; width: 100%; min-height: 0; }
.res-winner .wcanvas canvas { position: absolute; left: 0; top: 0; }
.res-banner { font-size: 1.6em; font-weight: 900; color: var(--gold); text-shadow: 3px 3px 0 #000; text-align: center; }
.res-table { width: 100%; border-collapse: collapse; font-size: .95em; }
.res-table th { color: var(--muted); font-weight: 400; text-align: center; padding: 4px; border-bottom: 2px solid #3c4560; }
.res-table td { padding: 4px; text-align: center; border-bottom: 1px solid #2a3144; }
.res-table td.who { text-align: left; }
.res-table tr.win td { background: rgba(255, 214, 92, .12); }
.res-who { display: flex; align-items: center; gap: 6px; }
.res-who .tag { font-weight: 900; color: #111; padding: 0 4px; box-shadow: 0 2px 0 #000; }
.res-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 8px; }
.res-rounds { color: var(--muted); font-size: .85em; margin-top: 6px; }

/* ───────────── howto / settings ───────────── */
.ht-body, .st-body { flex: 1; min-height: 0; }
.ht-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.ht-grid > .ht-keys { grid-column: 1 / -1; }
.keytable td, .keytable th { white-space: nowrap; }
.keytable { width: 100%; border-collapse: collapse; font-size: .92em; }
.keytable th, .keytable td { padding: 4px 6px; border-bottom: 1px solid #2a3144; text-align: left; }
.keytable th { color: var(--muted); font-weight: 400; }
.kbd { display: inline-block; min-width: 1.6em; padding: 1px 5px; margin: 1px; background: #dee2ec; color: #222; font: 700 .85em/1.3 ui-monospace, Menlo, Consolas, monospace;
  box-shadow: 0 2px 0 #6b7284; text-align: center; }
.ht-section h3 { margin: 4px 0 6px; color: var(--gold); font-size: 1em; }
.ht-section p { margin: 4px 0; }
.ht-seq { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.ht-techlist { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; }
.ht-tech-row { display: flex; flex-direction: column; font-size: .9em; padding: 2px 6px; background: #33283f; border-left: 3px solid #c77dff; }
.ht-tech-row b { color: #e2b6ff; }
.keytable tr.ht-tech th { color: #e2b6ff; }
.st-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; align-content: start; }
.st-row { display: flex; align-items: center; gap: 8px; }
.st-row > .lbl { flex: 1; }
.st-row .btn { flex: 0 0 auto; }
.bind-row { display: grid; grid-template-columns: 5.5em 1fr auto; gap: 6px; align-items: center; padding: 2px 0; }
.bind-row .keys { display: flex; flex-wrap: wrap; gap: 2px; }
.bind-row.capturing { background: rgba(255, 214, 92, .15); }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper .val { min-width: 3.4em; text-align: center; font-weight: 700; }

/* ───────────── online ───────────── */
.on-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.on-center { margin: auto; width: min(460px, 100%); display: flex; flex-direction: column; gap: 10px; }
.textin { min-height: 44px; font: inherit; font-size: 1.1em; padding: 4px 10px; background: #0f121b; color: var(--text); border: 2px solid var(--line);
  box-shadow: inset 0 0 0 2px #11141c; border-radius: 0; width: 100%; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
.textin.code { text-transform: uppercase; letter-spacing: .4em; text-align: center; font-weight: 900; }
.rooms { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 60px; }
.room { display: grid; grid-template-columns: 4.5em 1fr auto auto; gap: 10px; align-items: center; text-align: left; width: 100%; justify-content: stretch; }
.room .code { font-weight: 900; color: var(--gold); letter-spacing: .15em; }
.room .st { font-size: .85em; color: var(--muted); }
.room.ingame { opacity: .6; }
.on-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.on-row > * { flex: 1 1 auto; }
.lobby-actions .hint, .on-body > .hint, .ss-foot .hint, .slots-foot .hint { color: #fff; text-shadow: 1px 1px 0 #000, -1px 0 0 #000, 0 -1px 0 #000; }
.lobby-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 10px; }
.lobby-left { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.lobby-right { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.slotcards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slotcard { position: relative; display: flex; flex-direction: column; align-items: stretch; background: #1b2030; border: 2px solid var(--line-dark);
  box-shadow: inset 0 0 0 2px #3c4560; min-height: 0; padding: 4px; gap: 2px; }
.slotcard.me { box-shadow: inset 0 0 0 2px var(--gold); }
.slotcard.empty { opacity: .55; }
.slotcard .sc-head { display: flex; align-items: center; gap: 4px; }
.slotcard .tag { font-weight: 900; color: #111; padding: 0 4px; box-shadow: 0 2px 0 #000; font-size: .85em; }
.slotcard .sc-player { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; font-size: .9em; }
.slotcard .sc-sprite { position: relative; height: clamp(64px, calc(24 * var(--vh)), 130px); background: #11141c; }
.slotcard .sc-sprite canvas { position: absolute; left: 0; top: 0; }
.slotcard .sc-char { font-weight: 700; color: var(--gold); font-size: .9em; }
.slotcard .sc-state { font-size: .8em; color: var(--muted); }
.slotcard .sc-state.ready { color: var(--lime); }
.slotcard .sc-btns { display: flex; flex-direction: column; gap: 3px; }
.slotcard .sc-btns .btn { min-height: 36px; font-size: .8em; padding: 2px 4px; min-width: 0; }
.lobby-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.lobby-actions .btn, .lobby-actions .cycle { flex: 1 1 8em; }
/* status text over the stage backdrop: own row, wraps inside the left column, readable backing */
.lobby-status { flex: 1 1 100%; max-width: 100%; min-width: 0; white-space: normal; overflow-wrap: anywhere; margin: 0;
  background: rgba(10,12,22,.72); padding: 3px 8px; box-sizing: border-box; }
.lobby-right .chargrid { grid-template-columns: repeat(3, 1fr); }
.lobby-right .movepanel { flex: 1; min-height: 0; }

/* ───────────── small / short screens (landscape phones) ───────────── */
/* short logical viewport (≤ 430 px tall) — html.short is set by src/client/view.js so it also
   applies while a portrait phone shows the game rotated (a media query would see the tall screen) */
:where(html.short) .slots-body { gap: 4px; }
:where(html.short) .slot-row { padding: 2px 8px; gap: 6px; }
:where(html.short) .slot-row .btn, :where(html.short) .slot-row .tag { min-height: 40px; height: 40px; }
:where(html.short) .slots-foot { padding-top: 4px; }
:where(html.short) .slots-foot .hint { display: none; }
:where(html.short) .pchip { min-height: 40px; padding: 1px 6px 1px 2px; }
:where(html.short) .pchip .pc-state { font-size: .72em; }
:where(html.short) .cs-actions .btn { min-height: 40px; }
:where(html.short) .cs-left { gap: 5px; }
:where(html.short) .chargrid { gap: 4px; }
:where(html.short) .topbar { margin-bottom: 3px; }
:where(html.short) .chartile .ct-name { font-size: .85em; }
:where(html.short) .menu-grid { gap: 7px; }
:where(html.short) .screen-menu { gap: 4px; }
:where(html.short) .screen-menu .logo.small span { font-size: clamp(22px, calc(9 * var(--vh)), 40px); }
:where(html.short) .menu-grid .btn { min-height: 44px; }
:where(html.short) .cs-body, :where(html.short) .lobby-body, :where(html.short) .res-body { gap: 6px; }
:where(html.short) .panel { padding: 6px 8px; }
/* narrow logical portrait viewport (≤ 720 px wide) — html.lportrait set by src/client/view.js */
:where(html.lportrait) .cs-body, :where(html.lportrait) .lobby-body, :where(html.lportrait) .res-body { grid-template-columns: 1fr; overflow-y: auto; }
:where(html.lportrait) .menu-grid { grid-template-columns: 1fr; }
:where(html.lportrait) .slotcards { grid-template-columns: repeat(2, 1fr); }
@media (prefers-reduced-motion: reduce) {
  .press, .rot-icon { animation: none; }
}
