/* Deflect: the Dungeon Gate view, the Quick Match chip, the lobby columns, the match HUD and the result screen
   (js/deflect/*, js/ui/deflect*.js). Tokens come from style.css :root (DESIGN.md). The team colours are game identity
   colours from DEFLECT.colors.team, set on :root as --deflect-blue / --deflect-red by deflectSession.js; text uses them
   mixed towards the parchment text token so it stays readable on the dark panels. The result card is the Chess PvP one
   (chess.css .cs-result*, chessEnd.css moods); only its root and the rosters are styled here. */
:root {
  --dfx-blue: var(--deflect-blue, var(--accent-blue));
  --dfx-red: var(--deflect-red, var(--accent-red));
  --dfx-blue-text: color-mix(in srgb, var(--dfx-blue) 55%, var(--text-primary));
  --dfx-red-text: color-mix(in srgb, var(--dfx-red) 60%, var(--text-primary));
}
.is-blue { --team: var(--dfx-blue); --team-text: var(--dfx-blue-text); }
.is-red { --team: var(--dfx-red); --team-text: var(--dfx-red-text); }
.dfx-icon { image-rendering: pixelated; }

/* ---- Dungeon Gate: Deflect view ---- */
.dfx-size { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.dfx-size-btn { min-height: 44px; font-size: 16px; font-weight: 700; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.dfx-size-btn.is-on { border-color: var(--accent-gold-bright); color: var(--accent-gold-bright); background: var(--bg-deep); box-shadow: inset 0 0 0 2px var(--accent-gold); }
#btn-deflect-create:disabled { opacity: 0.5; cursor: not-allowed; }
.dfx-size-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#btn-deflect-quick .px-icon, #btn-gate-deflect .px-icon { flex: none; width: 32px; height: 32px; image-rendering: pixelated; }
/* Play vs Bots: a framed block as loud as Create Lobby: the bot icon, a title, and two big "Bots: Normal / Bots: Hard" buttons */
.dfx-practice { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); background: var(--bg-deep); border: 2px solid var(--accent-gold); border-radius: var(--radius-sm); }
.dfx-practice-head { display: flex; align-items: center; gap: var(--space-2); }
.dfx-practice-head .px-icon { flex: none; width: 32px; height: 32px; }
.dfx-practice-text { flex: 1; min-width: 0; text-align: left; }
.dfx-practice-title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-primary); text-align: left; }
.dfx-practice-sub { margin: 0; text-align: left; font-size: 13px; color: var(--text-secondary); text-wrap: pretty; }
/* Normal / Hard: the chess bot picker's buttons (.portal-bot-btn: difficulty lines + name, 56 px), two side by side */
.dfx-practice-levels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.dfx-level-btn { justify-content: center; padding: 0 var(--space-3); }
.dfx-level-btn .portal-bot-mark { margin-right: var(--space-1); }
#portal-view-deflect .portal-chess-how { margin-top: calc(var(--space-1) * -1); padding: var(--space-2) var(--space-3) var(--space-3); }
#portal-view-deflect .portal-chess-how .portal-section-title { margin-bottom: var(--space-2); }
/* Landscape phones: three columns so nothing needs scrolling: team size, Quick Match, Create Lobby, Back | Play vs
   Bots | How to play. .dfx-more steps aside (display: contents) so its two parts land in different columns. */
@media (max-height: 520px) and (orientation: landscape) {
  .portal-card-compact:has(#portal-view-deflect:not(.hidden)) { width: min(760px, 94%); max-width: min(760px, 94%); padding: var(--space-3) var(--space-4); }
  #portal-view-deflect:not(.hidden) {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.2fr); align-content: start;
    grid-template-areas: "size practice how" "quick practice how" "create practice how" "back practice how"; grid-template-rows: auto auto auto 1fr;
    column-gap: var(--space-3); row-gap: var(--space-2);
  }
  #portal-view-deflect .dfx-size { grid-area: size; }
  #portal-view-deflect .dfx-quick { grid-area: quick; }
  #portal-view-deflect .dfx-more { display: contents; }
  #btn-deflect-create { grid-area: create; }
  #portal-view-deflect .dfx-practice { grid-area: practice; align-self: start; }
  #portal-view-deflect .dfx-practice-levels { grid-template-columns: minmax(0, 1fr); }
  #portal-view-deflect .dfx-how { grid-area: how; align-self: start; margin-top: 0; }
  #portal-view-deflect .dfx-how .chess-how-list { font-size: 12px; line-height: 1.4; }
  #portal-view-deflect .dfx-how .chess-how-list li + li { margin-top: var(--space-1); }
  #btn-deflect-quick { min-height: 48px; padding: var(--space-1) var(--space-2); }
  #btn-back-deflect { grid-area: back; align-self: start; margin-top: 0; }
  /* the search line in the narrow first column: the dots and "Searching 2v2... 0:12", then Cancel across */
  #deflect-searching { flex-wrap: wrap; row-gap: var(--space-1); padding: var(--space-2); }
  #btn-deflect-cancel { flex: 1 1 100%; }
  /* the lobby in two columns, so Start / Ready never sit below the fold: the title, the invite buttons and the way on
     at the left, the Blue and Red columns at the right */
  #party-lobby-modal.is-deflect .party-lobby-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); align-content: start;
    column-gap: var(--space-4); width: min(780px, 96vw); max-width: min(780px, 96vw); padding: var(--space-3) var(--space-4); }
  #party-lobby-modal.is-deflect .party-lobby-card > * { grid-column: 1; margin-top: 0; margin-bottom: var(--space-2); }
  #party-lobby-modal.is-deflect .party-lobby-card > #party-lobby-slots { grid-column: 2; grid-row: 1 / span 8; margin-bottom: 0; }
  #party-lobby-modal.is-deflect #party-lobby-subtitle { font-size: 13px; text-wrap: pretty; }
  #party-lobby-modal.is-deflect .party-share-btn { padding: var(--space-1) var(--space-2); font-size: 13px; }
  #party-lobby-modal.is-deflect .party-lobby-card > :is(.btn-party-start, .btn-party-ready) { min-height: 48px; padding-block: var(--space-1); }
}

/* ---- Quick Match chip (shares .chess-queue-chip's place and look) ---- */
.dfx-chip-lines { display: flex; flex-direction: column; min-width: 0; text-align: left; }
.dfx-chip-text { font-weight: 700; font-variant-numeric: tabular-nums; }
.dfx-chip-hint { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
body.deflect-match .chess-queue-chip { display: none; }
/* In a match the campaign-only HUD pieces stay out of the way */
body.deflect-match #grand-announcement,
body.deflect-match #hud-party-indicator,
body.deflect-match #room-countdown,
body.deflect-match #hud-dungeon-status { display: none !important; } /* the scoreboard names the mode; a guest's wide HUD pushed this pill under it */
/* Desktop: the top-right cluster stays narrow so it never reaches under the centred scoreboard; the long guest "not
   saved" pill wraps onto its own row under gold / gems / menu (at 1280 the one-row cluster ran under the bar). */
@media (min-width: 951px) {
  body.deflect-match .hud-right { max-width: 340px; }
}
/* Deflect is swing + spin only: the buttons and panels for abilities the server ignores here would only confuse. The
   hero panel keeps the health bar plus Deflect's own swing and spin bars (.dfx-abilities); the phone keeps its special
   button for the spin (deflectAbilities.js drives its cooldown sweep). */
body.deflect-match #btn-mobile-dash,
body.deflect-match #btn-mobile-charge,
body.deflect-match #btn-mobile-interact,
body.deflect-match #hud-bottom-right,
body.deflect-match #hud-buff-bar,
body.deflect-match .hud-vitals-stack .energy-wrapper,
body.deflect-match .hud-vitals-stack .exp-wrapper { display: none !important; } /* no campaign power-ups, charge, energy or XP in Deflect */

/* Clashball ergonomic 2-button placement: Spin sits beside Sword */
body.deflect-match.is-mobile .special-btn { right: 114px; bottom: 11px; }
@media (max-width: 600px) and (orientation: portrait) {
  body.deflect-match.is-mobile .attack-btn { width: 80px; height: 80px; right: calc(18px + env(safe-area-inset-right)); bottom: calc(46px + var(--deck-b)); }
  body.deflect-match.is-mobile .special-btn { width: 62px; height: 62px; right: calc(116px + env(safe-area-inset-right)); bottom: calc(54px + var(--deck-b)); }
}
body.deflect-match.is-mobile[data-orientation="vertical"] .attack-btn { width: 80px; height: 80px; right: calc(18px + env(safe-area-inset-right)); bottom: calc(46px + var(--deck-b)); }
body.deflect-match.is-mobile[data-orientation="vertical"] .special-btn { width: 62px; height: 62px; right: calc(116px + env(safe-area-inset-right)); bottom: calc(54px + var(--deck-b)); }
body.deflect-match.is-mobile[data-orientation="horizontal"] .attack-btn { right: 0; bottom: 0; width: 80px; height: 80px; }
body.deflect-match.is-mobile[data-orientation="horizontal"] .special-btn { right: 114px; bottom: 11px; width: 58px; height: 58px; }

/* ---- Hero panel: swing and spin cooldowns ---- */
.dfx-abilities { display: none; }
body.deflect-match .dfx-abilities { display: flex; flex-direction: column; gap: var(--space-1); }
.dfx-cd-row { display: flex; align-items: center; gap: var(--space-1); }
.dfx-cd-row.hidden { display: none; }
.dfx-cd-icon { flex: none; width: 16px; height: 16px; image-rendering: pixelated; }
.dfx-abilities .dfx-cd { flex: 1; min-width: 0; height: 14px !important; }
.dfx-abilities .dfx-cd-fill { width: 0; background: var(--accent-blue) !important; transition: width 0.04s linear; }
.dfx-cd-row.is-ready .dfx-cd-fill { background: var(--accent-gold) !important; }
.dfx-abilities .dfx-cd-text { font-size: 10px !important; font-variant-numeric: tabular-nums; } /* sentence case like the HP bar ("Spin 24s", not "SPIN 24S") */
.dfx-cd-row.is-ready .dfx-cd-text { color: var(--text-primary) !important; }
body.is-mobile .dfx-cd-row:is(.is-spin, .is-swing) { display: none; } /* phones: the special and sword buttons show the spin and swing */
/* health as hits: the game's HP bar gives way to a chunky pixel segment per sword hit (deflectAbilities.js setHits) */
body.deflect-match .hud-vitals-stack .hp-wrapper { display: none !important; }
.dfx-hits { display: flex; gap: 3px; width: 170px; height: 18px; }
.dfx-hits.hidden { display: none; }
.dfx-hits i { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--bg-deep); box-shadow: inset 0 0 0 2px var(--border-subtle); }
.dfx-hits b { position: absolute; inset: 0 auto 0 0; width: 100%; background: var(--bar-hp);
  box-shadow: inset 0 3px 0 color-mix(in srgb, var(--bar-hp) 55%, var(--text-primary)), inset 0 -3px 0 color-mix(in srgb, var(--bar-hp) 60%, #000), inset 0 0 0 1px #000; }
.dfx-hits i.is-empty b { display: none; }
.dfx-hits i.is-lost { animation: dfx-hit-lost 0.45s steps(1) both; }
.dfx-hits.is-low b { animation: dfx-blink 0.8s steps(1) infinite; }
/* the sword button's swing sweep: the game's radial cooldown (style.css .cooldown-sweep), only in a match */
body:not(.deflect-match) .dfx-swing-cd { display: none; }
/* lock-on ready pop on the mobile attack button when a deflectable orb is inside reach */
body.deflect-match #btn-mobile-attack.is-deflect-ready {
  border-color: var(--accent-gold-bright);
  box-shadow: 0 0 0 2px var(--accent-gold-bright), 0 0 16px 2px var(--accent-gold);
  transform: scale(1.06);
  transition: transform 80ms ease-out, background 80ms ease-out, border-color 80ms ease-out, box-shadow 80ms ease-out;
}
body.deflect-match #btn-mobile-attack.is-deflect-ready:active {
  transform: scale(0.92);
}
/* your lives: a life gem each (15 px = 3 x the 5 px art), spent ones as empty sockets, then the count */
.dfx-life-row { display: flex; align-items: center; gap: 2px; min-height: 16px; }
.dfx-life-row.hidden { display: none; }
.dfx-life-row .px-icon { flex: none; width: 15px; height: 15px; image-rendering: pixelated; }
.dfx-life-text { margin-left: var(--space-1); font-size: 11px; font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ---- Lobby: Blue and Red columns ---- */
#party-lobby-modal.is-deflect #party-lobby-slots { display: block; }
.dfx-lobby { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.dfx-lobby-team { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; padding: var(--space-2); background: var(--bg-deep);
  border: 2px solid var(--team); border-radius: var(--radius-md); }
.dfx-lobby-title { display: flex; justify-content: space-between; align-items: baseline; margin: 0; font-size: 16px; letter-spacing: 0.04em; color: var(--team-text); }
.dfx-lobby-title span { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.dfx-lobby-slot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-2);
  border: 2px solid var(--border-subtle); border-radius: var(--radius-sm); text-align: left; }
.dfx-lobby-slot.is-me { border-color: var(--accent-gold); }
.dfx-lobby-slot.is-empty { border-style: dashed; }
.dfx-lobby-name { display: flex; align-items: center; gap: var(--space-1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 700; color: var(--text-primary); }
.dfx-lobby-name .party-host-crown { flex: none; margin-left: 0; } /* the campaign row pulls its crown in; here the flex gap spaces it */
.dfx-lobby-ready { flex: none; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: var(--success); }
.dfx-lobby-wait { flex: none; font-size: 12px; letter-spacing: 0.04em; color: var(--text-muted); }
.dfx-lobby-bot { display: flex; align-items: center; gap: var(--space-1); font-size: 13px; color: var(--text-muted); }
.dfx-lobby-join { min-height: 44px; }
.dfx-lobby-join:disabled { opacity: 0.6; cursor: default; }

/* ---- Match HUD (never takes a touch) ---- */
.dfx-hud { position: fixed; inset: 0; z-index: var(--z-hud-raised); pointer-events: none; font-family: var(--font-ui); color: var(--text-primary); }
.dfx-hud.hidden, .dfx-hud .hidden { display: none; }
.dfx-stack { position: absolute; left: 50%; top: calc(env(safe-area-inset-top, 0px) + var(--space-2)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2); width: max-content; max-width: calc(100vw - var(--space-4)); }
/* the match board: a team-tinted panel per side round the timer; big lives numbers and player squares */
.dfx-top { display: flex; align-items: stretch; gap: 0; padding: 0; background: var(--panel-bg); overflow: hidden;
  border: 3px solid var(--panel-border); border-radius: var(--radius-sm); box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6); }
.dfx-team { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4);
  background: linear-gradient(180deg, color-mix(in srgb, var(--team) 26%, transparent), color-mix(in srgb, var(--team) 10%, transparent)); }
.dfx-team.is-blue { box-shadow: inset 4px 0 0 var(--team); }
.dfx-team.is-red { box-shadow: inset -4px 0 0 var(--team); }
.dfx-count { min-width: 1ch; font-size: 38px; font-weight: 700; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; color: var(--team-text); text-shadow: 2px 2px 0 var(--bg-deep); }
.dfx-pips { display: flex; gap: var(--space-1); }
.dfx-pips i { width: 14px; height: 14px; background: var(--team); box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.35); }
.dfx-pips i.is-out { background: transparent; box-shadow: inset 0 0 0 2px var(--border-subtle); }
/* down (respawning): the square dimmed, a team-colour edge and two pixel clock hands */
.dfx-pips i.is-down { --hand: var(--text-primary);
  background: linear-gradient(var(--hand), var(--hand)) 6px 3px / 2px 5px no-repeat, linear-gradient(var(--hand), var(--hand)) 6px 6px / 5px 2px no-repeat,
    color-mix(in srgb, var(--team) 30%, var(--bg-deep));
  box-shadow: inset 0 0 0 1px var(--team); }
.dfx-team-gem { display: flex; flex: none; }
.dfx-team-gem .px-icon { width: 22px; height: 22px; image-rendering: pixelated; }
.dfx-timer { display: flex; align-items: center; justify-content: center; min-width: 120px; padding: var(--space-1) var(--space-4); font-size: 42px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; color: var(--accent-gold-bright); background: var(--bg-deep);
  border-left: 3px solid var(--panel-border); border-right: 3px solid var(--panel-border); text-shadow: 3px 3px 0 #000; }
.dfx-timer.is-low { color: var(--danger); }
.dfx-power { display: flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-3) 2px var(--space-1); background: var(--panel-bg);
  border: 2px solid var(--border-subtle); border-radius: var(--radius-sm); font-size: 14px; font-weight: 700; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.dfx-power .px-icon { flex: none; width: 26px; height: 26px; image-rendering: pixelated; }
.dfx-power.is-waiting { border-color: var(--accent-gold); color: var(--accent-gold-bright); }
.dfx-buffs { display: flex; gap: var(--space-2); }
.dfx-buffs:empty { display: none; }
.dfx-buff { display: flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2) 2px var(--space-1); background: var(--panel-bg); border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm); font-size: 14px; font-variant-numeric: tabular-nums; }
.dfx-buff .px-icon { flex: none; width: 22px; height: 22px; image-rendering: pixelated; }
.dfx-combo {
  display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2);
  background: var(--panel-bg); border: 2px solid var(--accent-gold); border-radius: var(--radius-sm);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6); font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: 0.04em; color: var(--text-primary);
  transform: scale(1); transition: transform 110ms cubic-bezier(0.2, 1.6, 0.4, 1), border-color 120ms ease-out, box-shadow 120ms ease-out, opacity 220ms ease-out;
}
.dfx-combo-spark {
  flex: none; width: 8px; height: 8px; background: var(--accent-gold-bright);
  box-shadow: 0 0 0 2px var(--bg-deep), 0 0 6px var(--accent-gold);
}
.dfx-combo-num { font-size: 16px; line-height: 1; color: var(--accent-gold-bright); text-shadow: 2px 2px 0 var(--bg-deep); }
.dfx-combo-tag { font-size: 11px; color: var(--text-secondary); letter-spacing: 0.06em; }
.dfx-combo[data-tier="2"] {
  border-color: var(--accent-gold-bright);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6), 0 0 10px var(--accent-gold-glow);
}
.dfx-combo[data-tier="3"] {
  border-color: var(--danger);
  background: linear-gradient(180deg, color-mix(in srgb, var(--danger) 24%, var(--panel-bg)), var(--panel-bg));
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6), 0 0 12px var(--accent-red-glow);
}
.dfx-combo[data-tier="3"] .dfx-combo-spark { background: var(--danger); box-shadow: 0 0 0 2px var(--bg-deep), 0 0 8px var(--danger); }
.dfx-combo[data-tier="3"] .dfx-combo-tag { color: var(--accent-gold-bright); }
.dfx-combo[data-tier="4"] {
  border-color: var(--accent-blue-light);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent-blue) 28%, var(--panel-bg)), var(--panel-bg));
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6), 0 0 14px var(--accent-blue-glow);
}
.dfx-combo[data-tier="4"] .dfx-combo-spark { background: var(--accent-blue-light); box-shadow: 0 0 0 2px var(--bg-deep), 0 0 8px var(--accent-blue-light); }
.dfx-combo[data-tier="4"] .dfx-combo-num { color: var(--text-primary); }
.dfx-combo[data-tier="4"] .dfx-combo-tag { color: var(--accent-blue-light); }
.dfx-combo.is-pop { animation: dfx-combo-pop 0.22s cubic-bezier(0.2, 1.7, 0.35, 1) both; }
.dfx-combo.is-break { opacity: 0; transform: scale(0.88); }
.dfx-hint { padding: var(--space-1) var(--space-3); background: var(--panel-bg); border: 2px solid var(--accent-gold); border-radius: var(--radius-sm);
  font-size: 16px; font-weight: 700; color: var(--accent-gold-bright); font-variant-numeric: tabular-nums; text-align: center; text-wrap: balance; }
.dfx-hint.is-warn { border-color: var(--danger); color: var(--danger); animation: dfx-blink 0.5s steps(1) infinite; }
.dfx-edge { position: absolute; inset: 0; }
.dfx-hud.is-targeted .dfx-edge { box-shadow: inset 0 0 0 4px var(--danger), inset 0 0 56px 4px color-mix(in srgb, var(--danger) 40%, transparent); animation: dfx-pulse 0.5s ease-in-out infinite alternate; }
.dfx-feed { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }
.dfx-ko { display: flex; align-items: center; gap: var(--space-2); max-width: calc(100vw - var(--space-4)); padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2);
  background: var(--panel-bg); border: 2px solid var(--accent-red); border-radius: var(--radius-sm); box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6); font-size: 14px;
  animation: dfx-ko-in 0.2s ease-out both; }
.dfx-ko .px-icon { flex: none; image-rendering: pixelated; }
.dfx-ko.is-leaving { opacity: 0; transition: opacity 0.25s; }
.dfx-ko-text { text-wrap: balance; }
.dfx-ko-lives { flex: none; padding: 0 var(--space-1); border: 2px solid var(--accent-gold); border-radius: var(--radius-sm); font-size: 12px; font-weight: 700;
  color: var(--accent-gold-bright); white-space: nowrap; font-variant-numeric: tabular-nums; }
.dfx-ko-lives.is-out { border-color: var(--danger); color: var(--danger); }
/* a team wipe: the banner grown, in the wiping team's colour */
.dfx-ko.dfx-wipe { gap: var(--space-3); padding: var(--space-1) var(--space-4); border: 3px solid var(--team); background: color-mix(in srgb, var(--team) 22%, var(--bg-deep));
  animation: dfx-wipe-in 0.35s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.dfx-wipe-lines { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.dfx-wipe-title { font-size: 30px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-gold-bright); text-shadow: 2px 2px 0 var(--bg-deep); white-space: nowrap; }
.dfx-wipe-team { font-size: 14px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--team-text); }
.dfx-name { font-weight: 700; color: var(--team-text); }
.dfx-callout { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: 96px; font-weight: 700; line-height: 1;
  color: var(--accent-gold-bright); text-shadow: 4px 4px 0 var(--bg-deep); font-variant-numeric: tabular-nums; }
.dfx-callout.is-pop { animation: dfx-pop 0.35s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.dfx-watch {
  padding: var(--space-1) var(--space-3); background: var(--panel-bg); border: 2px solid var(--border-subtle); border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text-secondary); text-align: center; text-wrap: balance; }
.dfx-watch.is-respawn { border-color: var(--accent-gold); font-size: 16px; font-weight: 700; color: var(--accent-gold-bright); font-variant-numeric: tabular-nums; }
/* narrower screens: the board one size down, so it stays clear of the hero panel and the currency pills */
@media (max-width: 1180px) {
  .dfx-team { gap: var(--space-1); padding: var(--space-1) var(--space-2); }
  .dfx-count { font-size: 30px; }
  .dfx-pips i { width: 12px; height: 12px; }
  .dfx-team-gem .px-icon { width: 18px; height: 18px; }
  .dfx-timer { min-width: 92px; padding: var(--space-1) var(--space-2); font-size: 32px; }
}
@media (max-width: 950px) {
  .dfx-hits { width: 116px; height: 13px; } /* the phone HUD's bar width */
}
/* desktop and phones keep the power-up countdown, active buffs, and deflect combo badge aligned on one compact row */
.dfx-row { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: center; gap: var(--space-2); }
/* Phones (upright up to 600 px wide, sideways up to 520 px tall): the board one more size down at the top centre
   (boardFit.js moves it below the hero card or the pills when they would sit under it), the power-up countdown and the
   buffs one compact row, the hero panel one small card: class icon, the 5 hits and the life gems (the name and class
   show over the hero) */
@media (max-width: 600px), (max-height: 520px) and (orientation: landscape) {
  .dfx-stack { gap: var(--space-1); }
  .dfx-top { border-width: 2px; box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.6); }
  .dfx-team { gap: var(--space-1); padding: var(--space-1) var(--space-2); }
  .dfx-count { font-size: 24px; }
  .dfx-pips { gap: 3px; }
  .dfx-pips i { width: 10px; height: 10px; }
  .dfx-pips i.is-down { background-position: 4px 2px, 4px 4px, 0 0; background-size: 2px 4px, 4px 2px, auto; }
  .dfx-team-gem .px-icon { width: 15px; height: 15px; }
  .dfx-timer { min-width: 72px; padding: 2px var(--space-2); font-size: 26px; border-width: 0 2px; text-shadow: 2px 2px 0 #000; }
  .dfx-row { display: flex; align-items: stretch; justify-content: center; gap: var(--space-1); }
  .dfx-power { padding: 2px var(--space-2) 2px var(--space-1); font-size: 12px; }
  .dfx-power .px-icon { width: 20px; height: 20px; }
  .dfx-buffs { gap: var(--space-1); }
  .dfx-buff { gap: 3px; padding: 2px var(--space-1); font-size: 12px; }
  .dfx-buff .px-icon { width: 16px; height: 16px; }
  .dfx-combo { padding: 1px var(--space-1); font-size: 11px; gap: 3px; }
  .dfx-combo-spark { width: 6px; height: 6px; }
  .dfx-combo-num { font-size: 13px; }
  .dfx-combo-tag { font-size: 10px; }
  .dfx-hint { padding: 2px var(--space-2); font-size: 14px; }
  .dfx-watch { padding: 2px var(--space-2); font-size: 13px; }
  .dfx-watch.is-respawn { font-size: 14px; }
  .dfx-ko { font-size: 13px; }
  .dfx-wipe-title { font-size: 22px; }
  body.deflect-match #hud .hud-left { gap: var(--space-2); padding: var(--space-1) 6px; align-items: center; }
  body.deflect-match #hud .hero-header { display: none; }
  body.deflect-match #hud .hero-info { gap: 0; }
  body.deflect-match #hud .vitals-container { margin-top: 0 !important; }
  body.deflect-match .dfx-abilities { gap: 3px; }
  .dfx-hits { width: 96px; height: 12px; gap: 2px; }
  .dfx-hits b { box-shadow: inset 0 2px 0 color-mix(in srgb, var(--bar-hp) 55%, var(--text-primary)), inset 0 -2px 0 color-mix(in srgb, var(--bar-hp) 60%, #000), inset 0 0 0 1px #000; }
  .dfx-life-row { min-height: 10px; }
  .dfx-life-row .px-icon { width: 10px; height: 10px; }
  .dfx-life-text { display: none; } /* the gems say it (the row's aria-label too) */
}
@media (max-width: 600px) {
  .dfx-stack { top: calc(env(safe-area-inset-top, 0px) + 52px); } /* below the hero card and gold; boardFit.js refines it */
  .dfx-callout { font-size: 72px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  /* the board top-centre between the hero card and the pills; the feed at the bottom centre, between the joystick
     and the buttons */
  .dfx-stack { bottom: calc(env(safe-area-inset-bottom, 0px) + var(--space-2)); }
  .dfx-feed { margin-top: auto; }
  .dfx-ko { max-width: 280px; }
  .dfx-ko.dfx-wipe { max-width: 360px; }
  .dfx-wipe-team { white-space: nowrap; }
  .dfx-callout { font-size: 64px; }
}

/* ---- Result screen: the chess result card in its own root ---- */
#deflect-result { 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));
  background: color-mix(in srgb, var(--bg-deep) 72%, transparent); font-family: var(--font-ui); color: var(--text-primary); overflow: hidden; }
#deflect-result.hidden { display: none; }
#deflect-result .hidden { display: none !important; }
#deflect-result > .cs-view { grid-area: 1 / 1; justify-content: flex-start; } /* the card centres by its margins, so a tall card scrolls from its top */
#deflect-result .cs-result-card { flex: none; margin-block: auto; }
#deflect-result > .cs-result-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
#deflect-result > .cs-result-back { z-index: 2; }
#deflect-result > .cs-result-front { z-index: 3; }
#deflect-result .cs-leave { min-height: 48px; font-family: var(--font-ui); }
/* The way out: Play again / the lobby rematch vote / Find another match (deflectRematchBar.js) */
.dfx-rematch { display: flex; flex-direction: column; gap: var(--space-2); width: 100%; }
/* a card taller than the screen scrolls under it: the way out stays pinned at the bottom, always reachable */
#deflect-result .dfx-rematch { position: sticky; bottom: calc(var(--space-3) * -1); z-index: 1; padding: var(--space-2) 0 var(--space-5); background: var(--bg-deep);
  box-shadow: 0 calc(var(--space-2) * -1) var(--space-2) calc(var(--space-1) * -1) var(--bg-deep); }
.dfx-rm-line { display: flex; justify-content: center; align-items: baseline; gap: var(--space-2); margin: 0; font-size: 16px; font-weight: 700; color: var(--accent-gold-bright); text-wrap: balance; }
.dfx-rm-clock { min-width: 4ch; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.dfx-rm-count { margin: 0; text-align: center; font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.dfx-rm-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.dfx-rm-actions.is-single { grid-template-columns: minmax(0, 1fr); }
.dfx-rm-btn { display: flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 48px; padding: var(--space-1) var(--space-3); text-wrap: balance; }
.dfx-rm-btn .px-icon { flex: none; image-rendering: pixelated; }
.dfx-rm-btn[aria-busy="true"] { opacity: 0.75; }
.dfx-sb-vote { display: inline-flex; flex: none; width: 16px; height: 16px; }
.dfx-sb-vote:empty { display: none; }
.dfx-sb-vote .px-icon { width: 16px; height: 16px; image-rendering: pixelated; }
#deflect-result .px-icon { image-rendering: pixelated; }
.dfx-result-card { width: min(1040px, 100%); }
#deflect-result .cs-result-gold { flex-wrap: wrap; column-gap: var(--space-2); row-gap: 0; }
.dfx-gold-mult { flex-basis: 100%; text-align: center; font-size: 13px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.04em; }
.dfx-gold-mult.is-mvp, .dfx-gold-mult.is-wipe { color: var(--accent-gold-bright); }
/* The scoreboard: one table, a team colour bar down each team's rows; numbers right-aligned in tabular figures */
.dfx-scoreboard { width: 100%; min-width: 0; }
.dfx-sb { width: 100%; border-collapse: collapse; table-layout: auto; font-size: 16px; font-variant-numeric: tabular-nums; }
.dfx-sb th, .dfx-sb td { padding: var(--space-1) var(--space-3); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.dfx-sb thead th { font-size: 13px; font-weight: 700; letter-spacing: 0.04em; color: var(--text-muted); text-transform: uppercase; white-space: nowrap; }
.dfx-sb abbr { text-decoration: none; }
.dfx-sb-short { display: none; }
.dfx-sb-num { text-align: right; white-space: nowrap; font-size: 18px; }
.dfx-sb-player { text-align: left; width: 100%; max-width: 0; } /* takes the room the numbers leave; a long name ellipsizes instead of widening the table */
.dfx-sb-team { padding-top: var(--space-2) !important; border-bottom: 2px solid var(--team) !important; font-size: 14px; letter-spacing: 0.1em; text-transform: uppercase;
  text-align: left; color: var(--team-text); }
.dfx-sb-row td:first-child { box-shadow: inset 4px 0 0 var(--team); padding-left: var(--space-4); }
.dfx-sb-name-line { display: inline-flex; align-items: center; gap: var(--space-1); min-width: 0; max-width: 100%; vertical-align: baseline; }
.dfx-roster-mark { flex: none; width: 12px; height: 10px; background: var(--mark); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.dfx-sb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: 18px; font-weight: 700; }
.dfx-sb-fate { display: inline-block; max-width: 100%; margin-left: var(--space-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: baseline;
  font-size: 14px; color: var(--text-muted); } /* beside the name, or whole on the next line, never split mid-phrase */
.dfx-sb-mvp { display: inline-flex; flex: none; align-items: center; gap: 2px; padding: 0 var(--space-1) 0 2px; border: 2px solid var(--accent-gold);
  border-radius: var(--radius-sm); background: var(--bg-deep); font-size: 12px; letter-spacing: 0.06em; color: var(--accent-gold-bright); }
.dfx-sb-mvp .px-icon { width: 16px; height: 16px; image-rendering: pixelated; }
.dfx-sb-row.is-out .dfx-sb-name { color: var(--text-secondary); }
.dfx-sb-row.is-me .dfx-sb-name { color: var(--accent-gold-bright); }
.dfx-sb-row.is-mvp td { background: color-mix(in srgb, var(--accent-gold) 10%, transparent); }
.dfx-sb-num.is-top { color: var(--accent-gold-bright); font-weight: 700; }
.dfx-sb-num.is-gold { color: var(--accent-gold); }
#deflect-result[data-layout="portrait"] .dfx-sb-long, #deflect-result[data-layout="landscape"] .dfx-sb-long { display: none; }
#deflect-result[data-layout="portrait"] .dfx-sb-short, #deflect-result[data-layout="landscape"] .dfx-sb-short { display: inline; }
/* Phones (portrait and landscape): each player is two lines, the name (and fate) across, then the numbers in equal columns
   under their headings, so a long name or "(You)" is never cut. --dfx-cols (deflectScoreboard.js) = the number columns. */
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb { display: block; font-size: 15px; }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb :is(thead, tbody) { display: block; }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb tr { display: grid; grid-template-columns: repeat(var(--dfx-cols, 6), minmax(0, 1fr)); border-bottom: 1px solid var(--border-subtle); }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb :is(th, td) { padding: 2px; border-bottom: 0; }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb thead th { font-size: 12px; letter-spacing: 0.04em; }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb-num { font-size: 17px; text-align: center; }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb-name { font-size: 16px; }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb thead .dfx-sb-player { display: none; }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb thead tr { padding-left: var(--space-2); } /* the same inset as the player rows, so the headings sit over their numbers */
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb :is(.dfx-sb-player, .dfx-sb-team) { grid-column: 1 / -1; width: auto; max-width: none; }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb .dfx-sb-team { padding: var(--space-2) var(--space-1) var(--space-1); border-bottom: 2px solid var(--team) !important; }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb tr:has(.dfx-sb-team) { border-bottom: 0; }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb-row { padding: var(--space-2) 0 var(--space-2) var(--space-2); box-shadow: inset 4px 0 0 var(--team); }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb-row.is-mvp { background: color-mix(in srgb, var(--accent-gold) 10%, transparent); }
#deflect-result:is([data-layout="portrait"], [data-layout="landscape"]) .dfx-sb-row :is(td, td:first-child) { padding: 2px; box-shadow: none; background: none; }
#deflect-result[data-layout="portrait"] .dfx-sb-fate { display: block; margin-left: 0; white-space: normal; text-wrap: pretty; font-size: 13px; }
#deflect-result[data-layout="portrait"] .cs-view { padding: var(--space-2); gap: var(--space-3); }
#deflect-result[data-layout="portrait"] .cs-result-card { padding: var(--space-4) var(--space-2); }
#deflect-result[data-layout="portrait"] .cs-result-title { font-size: 44px; }
/* Landscape phones: two columns, the title, gold and the way out on the left, the whole scoreboard on the right (it
   scrolls by itself, its headings pinned, if taller than the screen), so the table gets the full height. */
#deflect-result[data-layout="landscape"] .cs-view { padding: var(--space-2); }
#deflect-result[data-layout="landscape"] .cs-result-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.9fr);
  grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "head sb" "way sb"; column-gap: var(--space-3); row-gap: var(--space-2);
  align-items: stretch; width: 100%; height: calc(100dvh - var(--space-2) * 4); padding: var(--space-3); }
#deflect-result[data-layout="landscape"] .cs-result-head { grid-area: head; align-self: center; padding: 0; }
#deflect-result[data-layout="landscape"] .cs-result-title { font-size: 30px; }
#deflect-result[data-layout="landscape"] .dfx-scoreboard { grid-area: sb; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
#deflect-result[data-layout="landscape"] .dfx-rematch { grid-area: way; position: static; padding: 0; box-shadow: none; background: none; }
#deflect-result[data-layout="landscape"] .dfx-sb thead { position: sticky; top: 0; z-index: 1; background: var(--bg-deep); }
#deflect-result[data-layout="landscape"] .dfx-sb-row { padding-block: var(--space-1); }
#deflect-result[data-layout="landscape"] .dfx-sb-name-line { display: inline-flex; vertical-align: baseline; max-width: 100%; }
#deflect-result[data-layout="landscape"] .dfx-sb-fate { font-size: 12px; } /* beside the name when it fits: one line per name on a short screen */

@keyframes dfx-blink { 50% { opacity: 0.55; } }
@keyframes dfx-hit-lost { 0% { background: var(--text-primary); } 33% { background: var(--danger); } 66% { background: var(--text-primary); } }
@keyframes dfx-pulse { from { opacity: 0.55; } to { opacity: 1; } }
@keyframes dfx-ko-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes dfx-wipe-in { from { opacity: 0; transform: scale(1.5); } to { opacity: 1; transform: none; } }
@keyframes dfx-pop { 0% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; } 60% { transform: translate(-50%, -50%) scale(0.94); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes dfx-combo-pop { 0% { transform: scale(1.24); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .dfx-hint.is-warn, .dfx-hud.is-targeted .dfx-edge, .dfx-ko, .dfx-ko.dfx-wipe, .dfx-callout.is-pop, .dfx-combo.is-pop, .dfx-hits i.is-lost, .dfx-hits.is-low b { animation: none; }
  .dfx-combo, .dfx-combo.is-break,
  body.deflect-match #btn-mobile-attack.is-deflect-ready,
  body.deflect-match #btn-mobile-attack.is-deflect-ready:active { transform: none; transition: none; }
}
