/* Chess PvP match screen (#chess-root). Tokens come from style.css :root (see DESIGN.md); the few below are
   derived from them. Layouts: data-layout = wide | portrait | landscape; phases: data-phase on the root. */
@import url('chessEnd.css'); /* the CHECKMATE! moment and the result moods */
#chess-root {
  --chess-backdrop: color-mix(in srgb, var(--bg-deep) 86%, transparent);
  --chess-strip-h: 52px;
  --chess-side-w: 300px;
  --chess-edge: 2px solid var(--border-subtle);
  --chess-shadow: 4px 4px 0 rgba(0, 0, 0, 0.7);
  position: fixed; inset: 0; z-index: var(--z-match);
  display: grid; place-items: center; grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  padding: max(var(--space-2), env(safe-area-inset-top)) max(var(--space-2), env(safe-area-inset-right))
    max(var(--space-2), env(safe-area-inset-bottom)) max(var(--space-2), env(safe-area-inset-left));
  font-family: var(--font-ui); color: var(--text-primary); overflow: hidden;
}
#chess-root .hidden { display: none !important; }
#chess-root > .cs-board-screen, #chess-root > .cs-view { grid-area: 1 / 1; }
.cs-backdrop { position: absolute; inset: 0; background: var(--chess-backdrop); }
#chess-root[data-phase="fight"] { pointer-events: none; }
#chess-root[data-phase="fight"] .cs-backdrop,
#chess-root[data-phase="intro"][data-kind="fight"] .cs-backdrop { display: none; }
#chess-root[data-phase="over"] .cs-board-screen { filter: brightness(0.45); pointer-events: none; }
.cs-piece-img, .cs-icon, .cs-hero-art, .cs-board, .cs-result-fx, #chess-root .px-icon { image-rendering: pixelated; }

/* Shared text */
.cs-head { text-align: center; }
.cs-kicker { font-size: 12px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent-gold); }
.cs-title { font-size: 30px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-primary); text-wrap: balance; }
.cs-rule { font-size: 14px; color: var(--text-secondary); margin-top: var(--space-1); text-wrap: pretty; }
.cs-view { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: var(--space-4); width: 100%; max-width: 980px; max-height: 100%; overflow-y: auto; padding: var(--space-4); }

/* Vote */
.cs-vote-timer { display: flex; align-items: center; gap: var(--space-2); width: min(460px, 100%); }
.cs-vote-track { position: relative; flex: 1; height: 10px; background: var(--bg-deep); border: var(--chess-edge); }
.cs-vote-bar { position: absolute; inset: 0; background: var(--accent-gold-bright); transform-origin: left; }
.cs-vote.is-urgent .cs-vote-bar { background: var(--danger); }
.cs-vote-secs { width: 32px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent-gold-bright); }
.cs-vote.is-urgent .cs-vote-secs { color: var(--danger); }
.cs-hero-art { display: block; width: 96px; height: 96px; }
.cs-rcard .cs-hero-art { width: 144px; height: 144px; }
#chess-root[data-layout="portrait"] .cs-rcard .cs-hero-art { width: 96px; height: 96px; }
#chess-root[data-layout="landscape"] .cs-hero-art { width: 72px; height: 72px; }
.cs-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); width: 100%; }
.cs-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); min-height: 44px;
  padding: var(--space-4) var(--space-2) var(--space-5); cursor: pointer; color: var(--text-primary);
  background: linear-gradient(170deg, var(--panel-top), var(--bg-deep)); border: var(--chess-edge); border-radius: var(--radius-md);
  box-shadow: var(--chess-shadow); transition: border-color 0.15s, transform 0.15s;
}
.cs-card:hover, .cs-card:focus-visible { border-color: var(--accent-gold); transform: translateY(-2px); outline: none; }
.cs-card.is-picked { border-color: var(--accent-gold-bright); box-shadow: var(--chess-shadow), 0 0 0 2px var(--accent-gold-glow); }
.cs-card-art { position: relative; display: grid; place-items: center; width: 112px; height: 112px; background: var(--bg-deep); border: var(--chess-edge); }
.cs-card-icon { position: absolute; right: -10px; bottom: -10px; line-height: 0; }
.cs-card-name { margin-top: var(--space-2); font-size: 18px; font-weight: 700; }
.cs-card-role { font-size: 12px; line-height: 1.35; color: var(--text-muted); text-align: center; text-wrap: balance; }
.cs-card-pick { position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); display: none; align-items: center; gap: var(--space-1); white-space: nowrap;
  padding: 2px var(--space-2); font-size: 12px; font-weight: 700; color: var(--bg-deep); background: var(--accent-gold-bright); border: 2px solid var(--bg-deep); }
.cs-card.is-picked .cs-card-pick { display: inline-flex; }
.cs-opp-status { font-size: 14px; color: var(--text-muted); }
.cs-opp-status.is-done { color: var(--success); }

/* Reveal */
.cs-reveal-row { display: flex; align-items: center; justify-content: center; gap: var(--space-5); }
.cs-rcard { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); min-width: 150px;
  background: linear-gradient(170deg, var(--panel-top), var(--bg-deep)); border: var(--chess-edge); border-radius: var(--radius-md); box-shadow: var(--chess-shadow);
  transition: border-color 0.12s, opacity 0.3s; }
.cs-rcard.is-lit { border-color: var(--accent-gold-bright); box-shadow: var(--chess-shadow), 0 0 0 2px var(--accent-gold-glow); }
.cs-rcard.is-out { opacity: 0.4; }
.cs-rcard-who { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.cs-rcard-name { font-size: 18px; font-weight: 700; }
.cs-coin { line-height: 0; }
.cs-reveal.is-flipping .cs-coin img { animation: cs-coin 0.24s linear infinite; }
.cs-reveal-title { color: var(--accent-gold-bright); min-height: 1.3em; }
.cs-sides { font-size: 15px; color: var(--text-secondary); }
.cs-side-w { color: var(--text-primary); } .cs-side-b { color: var(--accent-purple-light); }

/* Board screen */
.cs-board-screen {
  position: relative; z-index: 1; display: grid; gap: var(--space-2) var(--space-5);
  grid-template-columns: auto var(--chess-side-w); grid-template-areas: "top side" "board side" "bottom side";
}
.cs-strip-top { grid-area: top; } .cs-board-wrap { grid-area: board; } .cs-strip-bottom { grid-area: bottom; } .cs-side { grid-area: side; }
#chess-root[data-layout="portrait"] .cs-board-screen {
  grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "board" "bottom" "side";
  grid-template-rows: auto auto auto minmax(0, 1fr); height: 100%; width: 100%; justify-items: center; gap: var(--space-1);
}
#chess-root[data-layout="landscape"] .cs-board-screen {
  grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "board top" "board side" "board bottom";
  grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; width: 100%; gap: var(--space-2) var(--space-3);
}
#chess-root[data-layout="portrait"] .cs-strip, #chess-root[data-layout="portrait"] .cs-side { width: var(--cs-board-w, 100%); max-width: 100%; }
.cs-board-wrap { position: relative; line-height: 0; align-self: center; }
.cs-board { display: block; touch-action: none; box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.7); }
.cs-board-wrap.cs-shake { animation: cs-shake 0.3s; }

/* Player strips */
.cs-strip { display: flex; align-items: center; gap: var(--space-2); height: var(--chess-strip-h); min-width: 0; padding: 0 var(--space-2);
  background: var(--panel-bg); border: var(--chess-edge); border-radius: var(--radius-md); }
.cs-chip { flex: none; width: 14px; height: 14px; border: 2px solid var(--bg-deep); box-shadow: 0 0 0 1px var(--text-muted); }
.cs-chip-w { background: var(--text-primary); } .cs-chip-b { background: var(--bg-deep); }
.cs-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cs-name-row { display: flex; gap: var(--space-1); align-items: baseline; min-width: 0; }
.cs-name { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-bot-tag { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.cs-caps { display: flex; align-items: center; height: 16px; min-width: 0; overflow: hidden; }
.cs-caps .cs-piece-img { flex: none; }
.cs-caps .cs-piece-img.is-stacked { margin-left: -8px; }
.cs-caps .cs-piece-img.is-dark { filter: drop-shadow(1px 0 0 var(--text-muted)) drop-shadow(-1px 0 0 var(--text-muted)) drop-shadow(0 -1px 0 var(--text-muted)); }
.cs-caps-diff { margin-left: var(--space-1); font-size: 12px; font-weight: 700; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.cs-mini-hp { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; width: 84px; }
.cs-mini-hp-track { width: 100%; height: 6px; background: var(--border-subtle); border: 1px solid var(--bg-deep); }
.cs-mini-hp-fill { height: 100%; background: var(--bar-hp); transform-origin: left; transition: transform 0.25s ease-out; }
.cs-mini-hp-num { font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.cs-clock { flex: none; min-width: 88px; padding: var(--space-1) var(--space-2); text-align: right; background: var(--bg-deep); border: var(--chess-edge); }
.cs-clock-time { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-secondary); }
.cs-clock.is-turn { background: var(--accent-gold); border-color: var(--accent-gold-bright); }
.cs-clock.is-turn .cs-clock-time { color: var(--bg-deep); text-shadow: none !important; }
.cs-clock.is-low .cs-clock-time { color: var(--danger); }
.cs-clock.is-turn.is-low { background: var(--danger); border-color: var(--danger); animation: cs-pulse 0.9s ease-in-out infinite; }
.cs-clock.is-turn.is-low .cs-clock-time { color: var(--bg-deep); }

/* Side panel */
.cs-side { display: flex; flex-direction: column; gap: var(--space-2); min-height: 0; padding: var(--space-3);
  background: var(--panel-bg); border: var(--chess-edge); border-radius: var(--radius-md); box-shadow: var(--chess-shadow); }
.cs-rounds { display: flex; gap: var(--space-1); list-style: none; min-width: 0; }
/* Pips shrink to fit every round on a phone; the icon snaps to whole pixel scales (32 or 16 px) so the art stays crisp. */
.cs-round-pip { display: grid; place-items: center; flex: 0 1 36px; min-width: 0; aspect-ratio: 1; background: var(--bg-deep); border: var(--chess-edge); line-height: 0; }
.cs-round-pip .cs-icon { width: clamp(16px, round(down, 100%, 16px), 32px); height: auto; }
.cs-round-pip.is-past { opacity: 0.35; }
.cs-round-pip.is-now { border-color: var(--accent-gold-bright); background: var(--panel-top); box-shadow: 0 0 0 2px var(--accent-gold-glow); }
.cs-round-fight { background: color-mix(in srgb, var(--accent-red) 30%, var(--bg-deep)); }
.cs-round-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
/* "Round 3 of 11" in bold, then a two-tone tab [CHESS|0:42] (sidePanel.js tick): the round's kind on a solid fill, then,
   in a chess round, its time left on dark, same size. Gold like the chess pips; red for a Fight round (its timer is in
   the fight HUD); in the last 10 s the fill, frame and time go red and the tab pulses */
.cs-round-label { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.cs-round-chip { display: inline-flex; align-items: stretch; font-size: 20px; font-weight: 700; line-height: 1.15; color: var(--accent-gold-bright);
  background: var(--bg-deep); border: 2px solid var(--accent-gold); font-variant-numeric: tabular-nums; }
.cs-round-chip.hidden, .cs-round-time.hidden { display: none; }
.cs-round-kind, .cs-round-time { padding: 2px var(--space-2); }
.cs-round-kind { text-transform: uppercase; letter-spacing: 0.04em; color: var(--bg-deep); background: var(--accent-gold); }
.cs-round-chip.is-fight { border-color: var(--danger); }
.cs-round-chip.is-fight .cs-round-kind { color: var(--text-primary); background: color-mix(in srgb, var(--accent-red) 60%, var(--bg-deep)); }
.cs-round-chip.is-low { color: var(--danger); border-color: var(--danger); animation: cs-pulse 0.9s ease-in-out infinite; }
.cs-round-chip.is-low .cs-round-kind { background: var(--danger); }
@media (prefers-reduced-motion: reduce) { .cs-round-chip.is-low { animation: none; } }
.cs-turn { font-size: 18px; font-weight: 700; color: var(--text-muted); }
.cs-turn.is-mine { color: var(--accent-gold-bright); } .cs-turn.is-check { color: var(--danger); }
.cs-moves-title { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.cs-moves { flex: 1; min-height: 64px; overflow-y: auto; list-style: none; background: var(--bg-deep); border: var(--chess-edge); }
.cs-move-row { display: grid; grid-template-columns: 36px 1fr 1fr; padding: 2px var(--space-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.cs-move-row:nth-child(even) { background: var(--panel-top); }
.cs-mnum { color: var(--text-muted); }
.cs-ply.is-last { color: var(--accent-gold-bright); font-weight: 700; }
.cs-moves-empty { padding: var(--space-2); font-size: 13px; color: var(--text-muted); }
.cs-side-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }
/* Phones out of fullscreen only (sidePanel.js); in a narrow column it wraps above Resign, into the empty space. */
#chess-root .cs-fullscreen { display: none; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; min-width: 112px;
  font-family: var(--font-ui); font-size: 14px; color: var(--accent-gold-bright); border-color: var(--accent-gold); }
body.is-mobile:not(.app-fullscreen) #chess-root .cs-fullscreen { display: inline-flex; }
#chess-root .cs-resign { min-height: 44px; min-width: 112px; font-family: var(--font-ui); font-size: 14px; border-color: var(--border-subtle); }
#chess-root .cs-resign.is-armed { color: var(--danger); border-color: var(--danger); }

/* Promotion picker */
.cs-promo { position: absolute; z-index: 4; display: flex; flex-direction: column; background: var(--panel-top); outline: 2px solid var(--accent-gold-bright); box-shadow: var(--chess-shadow); }
.cs-promo-btn { flex: 1; display: grid; place-items: center; min-height: 0; padding: 0; cursor: pointer; background: var(--panel-top); border: 0; border-bottom: 1px solid var(--border-subtle); }
.cs-promo-btn:hover, .cs-promo-btn:focus-visible { background: var(--accent-gold-glow); outline: none; }
.cs-promo-btn .cs-piece-img { width: 100%; height: 100%; }
.cs-promo-shade { position: absolute; inset: 0; z-index: 3; background: color-mix(in srgb, var(--bg-deep) 55%, transparent); }

/* Call-outs (banners.js): one family over the board. Every call-out is the same dark plate with a 2px pixel border, an
   uppercase label and a gold number; .is-danger turns border and number red. The round banner is one centred column. */
.cs-callout { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 32px;
  padding: var(--space-1) var(--space-3); line-height: 1; white-space: nowrap;
  background: var(--chess-backdrop); border: 2px solid var(--accent-gold); box-shadow: var(--chess-shadow); }
.cs-callout-label { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-secondary); }
.cs-callout-num { display: inline-block; min-width: 2ch; text-align: center; font-size: 20px; font-weight: 700;
  color: var(--accent-gold-bright); font-variant-numeric: tabular-nums; }
.cs-callout.is-danger { border-color: var(--danger); }
.cs-callout.is-danger .cs-callout-num { color: var(--danger); }

/* Call-outs inside the board's top frame (the frame is a ninth of the board: 16 of its 144 art px), clear of every
   square and of the player strip above: the countdown, or the referee; with both, the referee drops just under it */
.cs-countdown, .cs-ref { position: absolute; z-index: 4; left: 50%; top: calc(var(--cs-board-w, 432px) / 18); translate: -50% -50%;
  pointer-events: none; max-width: 96%; }
.cs-ref { z-index: 5; }
.cs-board-wrap:has(.cs-countdown:not(.hidden)) .cs-ref { top: calc(var(--cs-board-w, 432px) / 9 + var(--space-5)); }
.cs-ref-icon { flex: none; }
.cs-ref.is-mine { animation: cs-pulse 0.8s ease-in-out infinite; }
.cs-ref.is-mine .cs-callout-label { color: var(--text-primary); }
.cs-countdown.is-tick .cs-callout-num { animation: cs-count-tick 0.35s ease-out; }

/* CHECK!: the large chip, centred on the board, pops in and fades out over 1.1 s */
.cs-check { position: absolute; z-index: 4; left: 50%; top: 50%; translate: -50% -50%; pointer-events: none;
  padding: var(--space-2) var(--space-4); font-size: clamp(20px, calc(var(--cs-board-w, 480px) * 0.065), 34px);
  font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-gold-bright); text-shadow: 3px 3px 0 var(--bg-deep); }
.cs-check.is-pop { animation: cs-check-pop 1.1s ease-out both; }

/* Round banner: a full-width band; inside, one centred column: round line, [icon] TITLE [icon], final chip, 3-2-1 */
.cs-banner { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; pointer-events: none; }
.cs-banner-band { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); width: 100%;
  padding: var(--space-4) var(--space-3); text-align: center; background: var(--chess-backdrop);
  border-top: 2px solid var(--accent-gold); border-bottom: 2px solid var(--accent-gold); box-shadow: 0 6px 0 rgba(0, 0, 0, 0.5); }
.cs-banner[data-kind="fight"] .cs-banner-band { border-color: var(--danger); }
.cs-banner-round { font-size: 14px; font-weight: 700; letter-spacing: 0.3em; text-transform: uppercase; color: var(--accent-gold);
  margin-right: -0.3em; /* the last letter's tracking, so the line centres optically */ }
.cs-banner-title { display: flex; align-items: center; justify-content: center; gap: var(--space-4); }
.cs-banner-icon { flex: none; line-height: 0; }
.cs-banner-icon.is-left { transform: scaleX(-1); } /* both icons face the title */
/* both knights on the dark band: the same one-art-pixel parchment outline, so the pair matches */
.cs-banner[data-kind="chess"] .cs-banner-icon img { filter: drop-shadow(3px 0 0 var(--text-muted)) drop-shadow(-3px 0 0 var(--text-muted)) drop-shadow(0 3px 0 var(--text-muted)) drop-shadow(0 -3px 0 var(--text-muted)); }
.cs-banner-kind { font-size: 56px; line-height: 1; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-primary);
  text-shadow: 3px 3px 0 var(--bg-deep); }
.cs-banner[data-kind="fight"] .cs-banner-kind { color: var(--danger); }
/* The last chess round / last fight: the round line turns red and a gold chip under the title says so */
.cs-banner-final { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-gold-bright); }
.cs-banner-final:empty { display: none; }
.cs-banner.is-final .cs-banner-round { color: var(--danger); }
.cs-banner-count { min-width: 2ch; font-size: 28px; line-height: 1; font-weight: 700; color: var(--accent-gold-bright); font-variant-numeric: tabular-nums; }
.cs-banner-band.is-slam { animation: cs-slam 0.42s cubic-bezier(0.2, 1.4, 0.4, 1); }

/* Fight HUD: a band pinned to the top edge. You = left gauges, opponent = right, timer in the middle. Both HP bars stay
   attached to the timer and drain toward the outer screen edge; the energy cells fill from the timer side too. */
.cs-fight { position: absolute; z-index: 3; top: max(env(safe-area-inset-top), var(--space-2));
  left: calc(var(--space-2) + env(safe-area-inset-left)); right: calc(var(--space-2) + env(safe-area-inset-right));
  max-width: 960px; margin-inline: auto; display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.cs-vs { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: var(--space-2); width: 100%;
  padding: var(--space-1) var(--space-2) var(--space-2); background: var(--chess-backdrop); border: 2px solid var(--accent-red); box-shadow: var(--chess-shadow); }
.cs-fighter { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cs-fighter-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-1); min-width: 0; }
.cs-fighter.is-opp .cs-fighter-head { flex-direction: row-reverse; }
.cs-fighter-name { min-width: 0; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-fighter-hp { flex: none; font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.cs-bar { position: relative; height: 14px; background: var(--bg-deep); border: 2px solid var(--bg-deep); box-shadow: 0 0 0 1px var(--border-subtle); }
.cs-bar-fill, .cs-bar-trail { position: absolute; inset: 0; transform-origin: right; }
.cs-bar-fill { background: var(--bar-hp); transition: transform 0.18s ease-out; }
.cs-bar-trail { background: var(--text-secondary); transition: transform 0.6s ease-in 0.25s; }
.cs-fighter.is-opp .cs-bar-fill, .cs-fighter.is-opp .cs-bar-trail { transform-origin: left; }
.cs-fighter.is-opp .cs-bar-fill { background: var(--accent-purple-light); }
/* Energy: one cell per 10 energy; the gold notch closes the cell where the charged attack's cost is reached */
.cs-energy { display: flex; align-items: center; gap: var(--space-1); min-height: 12px; }
.cs-fighter.is-opp .cs-energy { flex-direction: row-reverse; }
.cs-cells { flex: 1; display: flex; flex-direction: row-reverse; gap: 2px; min-width: 0; }
.cs-fighter.is-opp .cs-cells { flex-direction: row; }
.cs-cell { position: relative; flex: 1; height: 8px; min-width: 0; background: var(--bg-deep); box-shadow: 0 0 0 1px var(--border-subtle); }
.cs-cell i { position: absolute; inset: 0; background: var(--bar-mana); transform-origin: right; }
.cs-fighter.is-opp .cs-cell i { transform-origin: left; }
.cs-cell.is-cost::after { content: ""; position: absolute; top: -3px; bottom: -3px; left: -2px; width: 2px; background: var(--accent-gold-bright); }
.cs-fighter.is-opp .cs-cell.is-cost::after { left: auto; right: -2px; }
.cs-charged-tag { flex: none; visibility: hidden; font-size: 9px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-gold-bright); }
.cs-energy.is-ready .cs-charged-tag { visibility: visible; }
.cs-energy.is-ready .cs-cell i { background: var(--accent-gold); box-shadow: 0 0 6px var(--accent-gold-bright); animation: cs-charged-glow 1s ease-in-out infinite; }
.cs-vs-mid { display: flex; flex-direction: column; align-items: center; padding: 0 var(--space-1); }
.cs-fight-time { font-size: 28px; line-height: 1; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent-gold-bright); }
.cs-fight-time.is-low { color: var(--danger); }
.cs-fight-round { font-size: 10px; color: var(--text-muted); white-space: nowrap; }
.cs-fight-foot { display: flex; align-items: center; gap: var(--space-2); }
.cs-rounds-fight .cs-round-pip { flex-basis: 24px; }
#chess-root .cs-resign-small { pointer-events: auto; min-height: 44px; min-width: 88px; padding: 0 var(--space-3); font-size: 12px; background: var(--panel-bg); }
/* During a fight the band replaces the game's own HUD: hide the hero box, class picker, currencies, status, friends, guest, party and the
   FPS readout. Menu, chat, the touch deck and Fullscreen stay; the top-right buttons drop below the band. */
body:has(#chess-root[data-phase="fight"]:not(.hidden)) :is(#hud .hud-left, #hud .hud-center, #hud .currency-pill, #hud-dungeon-status, #btn-hud-friends,
  #hud .guest-pill, #hud-party-indicator, #stats-overlay) { display: none !important; }
body:has(#chess-root[data-phase="fight"]:not(.hidden)) #hud > .hud-right { margin-top: var(--cs-fight-h, 64px); }
@media (max-width: 600px) {
  .cs-vs { gap: var(--space-1); padding: var(--space-1); }
  .cs-bar { height: 12px; }
  .cs-fighter-name { font-size: 12px; }
  .cs-fight-time { font-size: 24px; }
  .cs-charged-tag { font-size: 8px; letter-spacing: 0.04em; }
}
@media (max-height: 500px) { .cs-fight-time { font-size: 22px; } .cs-fight-round { display: none; } }
@media (prefers-reduced-motion: reduce) { .cs-energy.is-ready .cs-cell i { animation: none; } }
@keyframes cs-charged-glow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.35); } }

/* Result */
.cs-result { justify-content: center; }
.cs-result-card { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); width: min(460px, 100%); padding: var(--space-5);
  background: linear-gradient(160deg, var(--panel-top), var(--bg-deep)); border: 2px solid var(--accent-red); box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.7); }
.cs-result-head { position: relative; width: 100%; text-align: center; padding: var(--space-4) 0; }
.cs-result-title { position: relative; display: flex; align-items: center; justify-content: center; gap: var(--space-2); font-size: 52px; line-height: 1.05; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.cs-result[data-outcome="win"] .cs-result-title { color: var(--accent-gold-bright); } /* each mood's look: chessEnd.css */
.cs-result-reason { position: relative; font-size: 16px; color: var(--text-secondary); text-wrap: balance; }
.cs-summary { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.cs-summary th, .cs-summary td { padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--border-subtle); text-align: right; }
.cs-summary th:first-child { text-align: left; color: var(--text-muted); font-weight: 600; }
.cs-summary thead th { color: var(--text-muted); font-size: 12px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-sum-moves { font-size: 13px; color: var(--text-muted); }
.cs-summary thead th > span { display: block; overflow: hidden; text-overflow: ellipsis; }
.cs-sum-level { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.cs-sum-level:empty { display: none; }
#chess-root .cs-leave { min-height: 48px; font-family: var(--font-ui); }

/* Phones */
#chess-root[data-layout="portrait"] .cs-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5) var(--space-3); }
#chess-root[data-layout="portrait"] .cs-view { padding: var(--space-2); gap: var(--space-3); }
#chess-root[data-layout="portrait"] .cs-title { font-size: 24px; }
#chess-root[data-layout="portrait"] .cs-reveal-row { gap: var(--space-2); }
#chess-root[data-layout="portrait"] .cs-rcard { min-width: 0; padding: var(--space-2); }
#chess-root[data-layout="portrait"] .cs-side { padding: var(--space-2); gap: var(--space-1); }
#chess-root[data-layout="portrait"] .cs-mini-hp { width: 64px; }
#chess-root[data-layout="portrait"] .cs-clock { min-width: 76px; }
#chess-root[data-layout="portrait"] .cs-clock-time { font-size: 19px; }
#chess-root[data-layout="portrait"] .cs-banner-kind, #chess-root[data-layout="landscape"] .cs-banner-kind { font-size: 40px; }
#chess-root[data-layout="portrait"] .cs-banner-title, #chess-root[data-layout="landscape"] .cs-banner-title { gap: var(--space-3); }
#chess-root[data-layout="portrait"] .cs-banner-icon img, #chess-root[data-layout="landscape"] .cs-banner-icon img { width: 32px; height: 32px; }
#chess-root[data-layout="landscape"] .cs-view { padding: var(--space-2); gap: var(--space-2); }
#chess-root[data-layout="landscape"] .cs-head .cs-rule { display: none; }
#chess-root[data-layout="landscape"] .cs-card { padding: var(--space-2) var(--space-1) var(--space-4); }
#chess-root[data-layout="landscape"] .cs-card-art { width: 80px; height: 80px; }
#chess-root[data-layout="landscape"] .cs-card-role { display: none; }
#chess-root[data-layout="landscape"] .cs-side { padding: var(--space-2); }
#chess-root[data-layout="landscape"] .cs-strip { --chess-strip-h: 48px; }
#chess-root[data-layout="landscape"] .cs-result-card { gap: var(--space-2); padding: var(--space-3); }
#chess-root[data-layout="landscape"] .cs-result-title { font-size: 38px; }

@keyframes cs-shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes cs-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
@keyframes cs-slam { 0% { transform: scale(2.2); opacity: 0; } 60% { transform: scale(0.94); opacity: 1; } 100% { transform: scale(1); } }
@keyframes cs-coin { 0% { transform: scaleX(1); } 50% { transform: scaleX(0.1); } 100% { transform: scaleX(1); } }
@keyframes cs-check-pop { 0% { transform: scale(0.4); opacity: 0; } 14% { transform: scale(1.15); opacity: 1; }
  24% { transform: scale(1); } 75% { opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
@keyframes cs-count-tick { 0% { transform: scale(1.5); } 100% { transform: scale(1); } }
@keyframes cs-check-fade { 0%, 100% { opacity: 0; } 15%, 75% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .cs-check.is-pop { animation: cs-check-fade 1.1s linear both; }
  .cs-countdown.is-tick .cs-callout-num { animation: none; }
  .cs-board-wrap.cs-shake, .cs-banner-band.is-slam, .cs-clock.is-turn.is-low, .cs-ref.is-mine, .cs-reveal.is-flipping .cs-coin img { animation: none; }
  .cs-card, .cs-rcard, .cs-mini-hp-fill, .cs-bar-fill, .cs-bar-trail { transition: none; }
}
