/* ===== War Room Theme for Map Room ===== */

/* PERF (WebKit): drop ALL backdrop-filters. They force expensive re-composites
 * of the blurred region over the whole (3D-tilted) board on every pan. Panels
 * keep their own bg, just lose the frosted blur. (#3036, #5015)
 *
 * iOS WebKit, including WKWebView (the Discord in-app browser has no Safari UA
 * token), supports -webkit-touch-callout. Desktop Safari does not; main.tsx
 * tags html.safari-no-backdrop from navigator.vendor instead. */
@supports (-webkit-touch-callout: none) {
  html *,
  html *::before,
  html *::after {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}
html.safari-no-backdrop *,
html.safari-no-backdrop *::before,
html.safari-no-backdrop *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Faces load from <link> tags in index.html so they fetch in parallel with
 * this sheet. Weights are the ones rules actually use: Cinzel 400/700,
 * EB Garamond 400/500/600 plus italic 400, Plex Sans 400/500/600,
 * Plex Mono 400/500, Special Elite. */

/* Fixed bottom phase hint (PixiMapView). A class, not an inline blur, so the
 * WebKit kill switch above reaches it. */
.phase-hint-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-sm) var(--space-lg);
  background: var(--overlay-panel-brown);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  border-top: 1px solid var(--overlay-light-08);
  z-index: var(--z-bottom-bar);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
}

:root {
  /* Motion standard (#4233): keep in step with src/motion/motion.ts. */
  --motion-duration: 700ms;
  --motion-ease: cubic-bezier(0.4, 0, 1, 1);
  /* === Base Palette === */
  --bg-primary:       #18161a;
  --bg-secondary:     #1e1c20;
  --bg-tertiary:      #242228;
  --bg-overlay:       rgba(15, 15, 10, 0.85);
  --bg-modal:         #2e2e24;
  --bg-dark:          #141214;  /* dark background — darker than bg-primary, for pill/chip text on bright backgrounds */
  --bg-darkest:       #0a0a08;
  --bg-warm-card:     #3a382e;  /* warm dark card/panel background (FieldManualPanel, TutorialOverlay) */
  --bg-warm-card-deep: #353228; /* deeper warm dark panel background */

  /* === Surface Colors === */
  --surface-panel:    rgba(255,255,255,0.04);
  --surface-card:     rgba(255,255,255,0.04);
  --surface-mid:      rgba(255,255,255,0.07);  /* mid-level surface — between card and hover, for inactive pill/chip backgrounds */
  --surface-input:    #2a2a22;
  --surface-hover:    #45423a;
  --surface-disabled-mid: #3a3a3a;

  /* === Border Colors === */
  --border-primary:   rgba(255,255,255,0.08);
  --border-secondary: rgba(255,255,255,0.06);
  --border-accent:    rgba(196,164,74,0.25);
  --border-modal:     #6b6040;
  --border-tan-08:    rgba(100,90,60,0.08);   /* very subtle warm tan divider (row separators) */
  --border-tan-12:    rgba(100,90,60,0.12);   /* warm tan card border */
  --border-tan-20:    rgba(100,90,60,0.2);    /* medium warm tan border */

  /* === Text Colors === */
  --text-primary:     rgba(255,255,255,0.9);
  --text-secondary:   rgba(255,255,255,0.6);
  --text-muted:       rgba(255,255,255,0.4);
  --text-heading:     #c4a44a;
  --text-accent:      #d4a038;
  --text-warning:     #ff9800;  /* warning text color — amber/orange for alerts and dispute labels */

  /* === Accent Colors === */
  --accent-gold:      #e8d48b;
  --accent-gold-bright: #f0dfa0;
  --accent-gold-dark: #7a5500;   /* dark-gold for icons on bright backgrounds */
  --accent-brass:     #b89a3a;
  --accent-amber:     #c87533;  /* warm amber — warning/beta notices (between brass and red) */
  --accent-red:       #a04040;
  --accent-red-bright: #c05050;
  --accent-danger:    #c45252;  /* danger accent (red-tinted) — for inline danger labels/icons */
  --accent-danger-text: #d86e6e; /* danger as TEXT: 4.9:1 on --bg-raised (--accent-danger is 3.59:1); fills keep --accent-danger (#5175) */
  --accent-blue:      #5a7a9a;
  --accent-green:     #5a8a4a;
  --color-on-gold:    #1a1a10;  /* dark text for use on gold/accent backgrounds */

  /* Combat-board side tints (attacker red / defender slate-blue). RGB triplets
   * so callers compose any alpha via rgba(var(--combat-atk-rgb), a). (#3037) */
  --combat-atk-rgb:   196, 82, 82;
  --combat-def-rgb:   138, 164, 194;

  /* === Alliance Colors === */
  --alliance-axis:    #a04040;
  --alliance-axis-text: #d86e6e; /* Axis as TEXT: 5.6:1 on --bg-ink (--alliance-axis is 2.92:1); fills keep --alliance-axis (#5175) */
  --alliance-allies:  #5a8a4a;

  /* === Phase Colors === */

  /* === Shadows === */
  --shadow-md:        0 2px 8px rgba(0,0,0,0.5);
  --shadow-lg:        0 4px 16px rgba(0,0,0,0.6);
  --shadow-inset:     inset 0 1px 3px rgba(0,0,0,0.5);

  /* === Typography === */
  --font-heading:     'Cinzel', 'Georgia', 'Times New Roman', serif;
  --font-body:        'EB Garamond', 'Georgia', 'Times New Roman', serif;
  --font-ui:          'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-mono:        'IBM Plex Mono', 'Courier New', Courier, monospace;
  --font-diary:       'Special Elite', 'Courier New', monospace;

  /* === Instrument HUD (#3562) — apply at chrome surfaces; do not
   * reassign --bg-primary globally. Brass hue is --accent-brass. === */
  --bg-ink:           #10131a;
  --bg-rail:          #141821;
  --bg-raised:        #1c212b;
  --text-ivory:       #e6e0d2;
  --text-ivory-muted: #8d8983;  /* 4.6:1 on --bg-raised (was 4.46:1, #5130 Po-1) */
  --border-brass:     rgba(184, 154, 58, 0.38);
  --border-brass-grid: rgba(184, 154, 58, 0.06);
  --toggle-track-on:  #3a3420;

  /* === Fluid Text Scale (Utopia-style clamp tokens) === */
  --text-xs:   clamp(0.5625rem, 0.52rem + 0.13vw, 0.6875rem);  /* ~9–11px  */
  --text-sm:   clamp(0.6875rem, 0.63rem + 0.18vw, 0.8125rem);  /* ~11–13px */
  --text-base: clamp(0.8125rem, 0.71rem + 0.32vw, 1.0625rem);  /* ~13–17px */
  --text-lg:   clamp(1rem,      0.87rem + 0.41vw, 1.3125rem);   /* ~16–21px */
  --text-xl:   clamp(1.1875rem, 1.04rem + 0.47vw, 1.625rem);   /* ~19–26px */
  --text-2xl:  clamp(1.5rem,    1.3rem  + 0.63vw, 2.125rem);   /* ~24–34px */

  /* === Fluid Spacing === */
  --tap-min:   44px;  /* smallest fingertip target */
  /* One height for every top-bar control (#4388): 32px with a mouse, --tap-min
   * on a coarse pointer (#4796). Short landscape still sets 40px, but the
   * coarse rule is declared after it so a phone keeps the 44px floor. */
  --toolbar-control-h: 32px;
  /* Plan chip (#5248, spec §7.3). Fixed sizes, not the fluid text scale. */
  --plan-chip-font: 11px;
  --plan-chip-label-track: 0.14em;
  --plan-chip-seg-track: 0.08em;
  --plan-chip-seg-min: 40px;
  --plan-chip-seg-pad: 9px;
  --plan-chip-label-pad: 8px;
  --plan-chip-glyph: 16px;
  --plan-chip-state: 8px;
  --plan-chip-state-gap: 2px;
  --space-xs:  clamp(0.25rem,  0.21rem + 0.13vw, 0.375rem);
  --space-sm:  clamp(0.5rem,   0.43rem + 0.22vw, 0.6875rem);
  --space-md:  clamp(0.75rem,  0.65rem + 0.32vw, 1.0625rem);
  --space-lg:  clamp(1rem,     0.87rem + 0.41vw, 1.3125rem);
  --space-xl:  clamp(1.5rem,   1.3rem  + 0.63vw, 2rem);
  /* Minimum touch target (#4193). */
  --tap-min:   44px;
  /* Lobby sizes (#5130 Po-10). */
  --lobby-rail-w:      168px;
  --lobby-badge-size:  16px;
  --lobby-content-max: 1280px;
  --games-list-max: 56rem;
  --lobby-sheet-max:   560px;
  --space-2xs:         3px;
  /* Battle text floor (#4193): fixed, so the small-screen --text-* overrides
   * (which take --text-sm to ~9px) cannot shrink battle labels below it.
   * Use as max(var(--text-sm), var(--text-battle-floor)). */
  --text-battle-floor: 0.6875rem;  /* 11px */

  /* === Safe Area Insets (iOS Dynamic Island / notch) ===
   * Single source of truth — every component composes with these vars instead
   * of writing env(safe-area-inset-*) inline. env() is the only raw value
   * permitted by lint:tokens (check-tokens.sh), so it lives here only. */
  --safe-l: env(safe-area-inset-left,   0px);
  --safe-r: env(safe-area-inset-right,  0px);
  --safe-t: env(safe-area-inset-top,    0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  /* Lesson card text (#5457). Fixed, so the small-screen --text-* overrides
   * cannot take it to the 8-9px it had on a phone. */
  --coach-text:       0.75rem;    /* 12px */
  --coach-text-small: 0.6875rem;  /* 11px, the battle text floor */

  /* The lesson card's rail (#5457). 0 except while a lesson card is up on a
   * phone held sideways: see the lesson-rail block by .lesson-coach.
   * --stage-left is where the board, dialogs and drawers start. */
  --lesson-card-w: 220px;
  --lesson-rail-w: 0px;
  --stage-left:    max(var(--safe-l), var(--lesson-rail-w));

  /* Runtime-set layout offset vars (JS writes these via setProperty) */
  --sidebar-w:         0px;
  --territory-panel-h: 0px;

  /* Vertical room above the plan-switcher dropdown (#3369): the board top bar,
   * the HUD anchor's own top offset, and the switcher toggle the menu hangs
   * from. Subtracted from the viewport to bound `.plan-switcher-menu`, which
   * previously dropped unbounded and pushed its tail (and the "+ New plan"
   * button) off a short landscape viewport with no way to scroll to them. */
  --plan-hud-reserve: 6rem;

  /* === Transitions === */
  --transition-fast:   150ms ease;
  --transition-normal: 200ms ease;

  /* === Border Radius === */
  --radius-xs:        3px;
  --radius-sm:        4px;
  --radius-md:        8px;
  --radius-lg:        10px;

  /* Lobby kit marks (#5080). Fixed mockup frames, not the fluid space scale. */
  --roundel-s:        14px;
  --roundel-m:        22px;
  --roundel-l:        40px;
  --roundel-xl:       56px;
  --roundel-nudge:    -3px;
  /* Room seats (#5163): the strip's height, and a seat's roundels overlapped with a ring between them. */
  --seat-strip-h:     48px;
  --roundel-stack-overlap: -6px;
  --roundel-stack-ring: 1.5px;
  --pip-size:         6px;
  --pip-gap:          3px;
  --pip-glow:         5px;
  /* Games home (#5082): the score bar's height and a card's left rail. */
  --card-rail-w:      3px;

  /* === Button Presets === */
  --btn-bg:           rgba(255,255,255,0.05);
  --btn-bg-primary:      rgba(196,164,74,0.2);
  --btn-bg-primary-dark: rgba(196,164,74,0.1);
  --btn-bg-danger:    rgba(180,60,60,0.2);
  --btn-bg-success:   #2a5a3a;
  --btn-text:         rgba(255,255,255,0.8);
  --btn-primary-grad-top: #8b7a3a;  /* primary gradient button — top stop */
  --btn-primary-grad-bot: #6b5a2a;  /* primary gradient button — bottom stop */
  --btn-primary-border:   #a08a40;  /* primary gradient button border */

  /* === Status/Semantic Colors === */
  --color-success:    #4caf50;
  --color-warning:    #ff8c00;
  --color-hit:        #e05050;
  --color-miss:       #666666;
  --color-info-text:  #c0b890;
  --color-danger:     #ff4444;
  --color-danger-soft: #ff6b6b;
  --color-info:       #5090d0;
  --color-casualty:   #c06050;
  --color-parchment:  #c0b890;
  --color-valid:      #40a060;
  --color-success-bright: #44cc88;
  --color-white:      #ffffff;

  /* Team Plan Mode 6-color SEMANTIC annotation palette (#3287). Mirrors
     PLAN_PALETTE hex in plans/planModeStore.ts (the Pixi renderer's numeric
     source). Names are semantic: crimson=Attack, azure=Move, amber=Caution,
     lime=Objective, magenta=Special, ink=Notes. Map-legible + CB-safe. */
  --plan-color-crimson: #ff2e63;
  --plan-color-azure:   #0ab6ff;
  --plan-color-amber:   #ff9f0a;
  --plan-color-lime:    #a3e635;
  --plan-color-magenta: #e935ff;
  --plan-color-ink:     #f0f0f0;

  /* Plan mode order kinds, arrow states and the OddsChip (spec §7.1; S4
     #5250 first named the kind/arrow tokens, M2 #5252 the rest). The arrow table itself is plan/arrowStyle.ts; Pixi reads these
     through tokenColor() once and caches them. */
  --plan-kind-attack:   var(--plan-color-crimson);
  --plan-kind-move:     var(--plan-color-azure);
  --plan-kind-landing:  var(--plan-color-magenta);
  --plan-kind-raid:     var(--plan-color-amber);
  --plan-kind-carrier:  var(--plan-color-ink);
  --plan-arrow-done:    #9a9a9a;
  --plan-arrow-broken:  var(--color-danger-soft);
  --plan-halo:          rgba(0, 0, 0, 0.55);
  --plan-them-text:     #a9bfd6;
  --odds-h:             22px;
  --odds-bar-w:         34px;
  --odds-bar-h:         6px;
  --odds-track:         rgba(var(--combat-def-rgb), 0.55);
  --odds-fill:          rgb(var(--combat-atk-rgb));
  --odds-na-stripe:     repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 3px, transparent 3px 6px);
  --odds-pad:           0 7px 0 5px;
  --odds-gap:           6px;
  --odds-radius:        11px;
  --odds-bar-radius:    3px;
  --odds-font:          11px;
  --odds-swing-font:    10px;
  --odds-dice-font:     12px;

  /* Plan mode M4 (#5274): palette, rail, sheet, badges (spec §7.1, §7.3).
     Text on a filled Attack / Landing tool is dark: white on crimson measured
     3.6:1 and on magenta 3.4:1, under 4.5:1 for 11px text (spec §8). */
  --plan-on-attack:         #1a0008;
  --plan-on-landing:        #1a0008;
  --plan-on-move:           #06202c;
  --plan-on-raid:           #2a1800;
  --plan-order-tool-border: rgba(255, 46, 99, 0.35);
  --plan-tool-ring:         rgba(232, 212, 139, 0.25);
  --plan-label-bg:          rgba(16, 19, 26, 0.86);
  --plan-sheet-shadow:      0 -8px 24px rgba(0, 0, 0, 0.6);
  --plan-badge-h:           20px;
  --plan-rail-pad:          3px;
  --plan-tool-h:            32px;
  --plan-sheet-strip:       108px;
  --plan-sheet-half:        440px;
  --plan-sheet-full:        min(700px, calc(100dvh - 44px - var(--safe-t)));
  --radius-xl:              12px;
  --z-plan-badges:          1090;

  /* Plan mode S3 banner and author roundel (#5249). Named so the mockup's
     8/10/6/13/12 px literals are not raw component values. */
  --plan-pad-banner: 8px 10px;
  --plan-banner-gap: 6px;
  --plan-banner-title: 13px;
  --plan-banner-body: 12px;
  /* Mockup .btn is IBM Plex Sans 11px, weight 500, 26px tall. */
  --plan-banner-btn: 11px;
  --plan-banner-btn-min: 26px;
  --plan-roundel-border: rgba(0, 0, 0, 0.5);
  --plan-roundel-ring: rgba(255, 255, 255, 0.25);
  /* Discord digest (#5270). Channel name is --plan-them-text above. */
  --plan-digest-w: 360px;
  --plan-digest-w-land: 400px;
  --plan-digest-pad: 10px 12px 12px;
  --plan-digest-pad-b: 12px;
  --plan-digest-gap: 8px;
  --plan-digest-sheet-radius: 12px;
  --plan-digest-pre: 220px;
  --plan-digest-pre-phone: 190px;
  --plan-digest-pre-pad: 8px 9px;
  --plan-digest-kicker: 10px;
  --plan-digest-track: 0.14em;
  --plan-digest-link-label: 9px;
  --plan-digest-chk: 14px;
  --plan-digest-close: 12px;
  --plan-digest-inset: 10px;
  --plan-digest-bottom: 48px;
  --plan-digest-land-inset: 8px;

  /* Plan tab (M1 #5273, spec §7.1/§7.3): pills, cards, rows. */
  --plan-ready-text:    #8fd49a;
  --plan-ready-border:  rgba(76, 175, 80, 0.4);
  --plan-broken-border: rgba(180, 60, 60, 0.5);
  --plan-broken-card:   rgba(180, 60, 60, 0.45);
  --plan-fog-border:    rgba(138, 164, 194, 0.5);
  --plan-on-objective:  #111111;
  --plan-pad-card:      6px 8px;
  --plan-pad-pill:      2px 7px;
  --plan-pad-row:       4px 8px;
  --plan-card-gap:      4px;
  --plan-tab-gap:       8px;
  --plan-tab-pad:       10px 12px 12px;
  --plan-tab-pad-land:  8px 10px;
  --plan-group-gap:     6px;
  --plan-dd-h:          26px;
  --plan-switch-w:      26px;
  --plan-switch-h:      14px;
  --plan-switch-knob:   10px;
  --plan-tap-font:      13px;
  --color-black:      #000000;

  /* === Indicator / Demo Colors === */
  --color-teal:           #2a8a9a;  /* teal — intelligence/stealth/convoy/recon indicators */
  --color-teal-dark:      #2a6a7a;  /* darker teal — convoy zone dashed borders */
  --color-teal-light:     #40aacc;  /* lighter teal — convoy zone inner border */
  --color-stat-defense:   #7a9aba;  /* defense stat on unit cards */
  --color-stat-green:     #7aaa6a;  /* HP/green stat on unit cards */
  --color-chip-bg:        #2c2c38;  /* unit chip demo background */
  --color-chip-border:    #6e6e82;  /* unit chip demo border */
  --color-chip-stack:     #3a8a45;  /* unit chip stack-count dot */
  --color-kamikaze:       #8b3030;  /* kamikaze marker dark red */
  --color-kamikaze-text:  #ffaaaa;  /* kamikaze label light red */
  --color-ghost-text:     rgba(160,150,120,0.5);  /* ghost unit demo label */
  --color-fog-text:       rgba(180,180,180,0.5);  /* fog-of-war demo symbol */

  /* === Extended Accent Colors === */
  --accent-blue-light: #7ab0d0;
  --bg-elevated:      #444;

  /* === Combat/Overlay Colors === */
  --color-amphibious:  #5090c0;
  --color-draw:        #c0a040;
  --color-hover-active: #4080d0;
  --color-sbr-aa:      #d09050;
  --color-sbr-bombing: #d0c060;

  /* === Battle Board Gradient Stops === */
  --gradient-battle-header-top: #3a2a18;  /* warm amber — top of battle board headers */
  --gradient-battle-header-bot: #2a1c10;  /* warm amber — bottom of battle board headers */

  /* === Map Feature Indicators === */
  --color-blockade:    #88ddff;
  --color-convoy:      #66ccee;
  --color-installations: #88aacc;

  /* === Log/Diary Entry Type Colors === */
  --color-log-dice:    #8898a8;
  --color-log-purchase: #80a870;
  --color-log-placement: #7898b0;
  --color-log-income:  #c8b040;

  /* === Note Type Colors === */
  --color-note-move:   #5080e0;
  --color-note-strategy: #a070d0;

  /* === Lobby Colors === */
  --color-lobby-title: var(--accent-gold-bright); /* #f0dfa0 — 1-unit green diff, visually identical */
  --color-lobby-subtitle: #a09070;
  --lobby-input-bg:             rgba(26, 26, 20, 0.9);
  --lobby-input-border:         rgba(90, 85, 64, 0.6);
  --lobby-muted-bg:             rgba(51, 51, 42, 0.8);
  --lobby-axis-selected-bg:     rgba(139, 0, 0, 0.8);
  --lobby-allies-selected-bg:   rgba(0, 51, 102, 0.8);
  --lobby-axis-mine-bg:         rgba(139, 0, 0, 0.3);
  --lobby-allies-mine-bg:       rgba(0, 51, 102, 0.3);
  --gradient-lobby-resume:      linear-gradient(180deg, #3a6b3a 0%, #2a5a2a 50%, #204a20 100%);
  --lobby-btn-dark:              #5a4a20;
  --lobby-tagline-color:        rgba(144, 128, 96, 0.6);

  /* === Toggle === */
  --toggle-knob:      var(--text-ivory-muted);
  --toggle-knob-on:   var(--accent-gold);

  /* === Tooltip / Popover === */
  --surface-tooltip:  rgba(25, 24, 18, 0.93);
  --tooltip-border:   #444;
  --tooltip-text:     #ddd;
  --tooltip-divider:  #333;

  /* === Map === */
  --map-bg:           #1a2028;
  --map-battle:       #c05050;
  --map-valid-dest:   #6a9a5a;

  /* === Arrow Glow === */

  /* === Z-Index Scale === */
  --z-search:         20;
  --z-sidebar:        50;
  --z-income-track:   500;       /* fixed income-strip panel — above sidebar, below battle board */
  --z-bottom-bar:     800;       /* fixed bottom chrome — TerritoryBottomPanel / PhaseHintBar (#3691) */
  --z-battle:         1000;
  --z-toast:          1050;      /* above --z-bottom-bar AND --z-battle: an error toast must not hide behind the panel that raised it; a refused casualty pick was invisible under the battle at 900 (#4211). Below --z-overlay. */
  --z-overlay:        1100;
  --z-plan-sheet:     1101;      /* digest card / phone sheet, just above the battle overlay (#5270) */
  --z-tutorial:       3000;      /* TutorialOverlay band; its internal rungs are zToken('tutorial', n) (#3691) */
  --z-sidebar-backdrop: 4000;
  --z-menu-backdrop:  5000;
  --z-menu:           5001;
  --z-debug:          5002;
  --z-settings:       6000;
  --z-dialog:         6001;
  --z-dialog-confirm: 6002;
  --z-modal:          7000;
  --z-cover:          8000;

  /* === Overlay Tints (semi-transparent color tokens) === */
  /* Black-scrim ladder — canonical opacity rungs at 0.1 deciles (10–90).
     This is the only dark-scrim ramp; pick the nearest rung, do not add
     off-grid steps. See docs/styling/conventions.md §5.6. */
  --overlay-dark-10:       rgba(0,0,0,0.1);
  --overlay-dark-20:       rgba(0,0,0,0.2);
  --overlay-dark-30:       rgba(0,0,0,0.3);
  --overlay-dark-40:       rgba(0,0,0,0.4);
  --overlay-dark-50:       rgba(0,0,0,0.5);
  --overlay-dark-60:       rgba(0,0,0,0.6);
  --overlay-dark-70:       rgba(0,0,0,0.7);
  --overlay-dark-80:       rgba(0,0,0,0.8);
  --overlay-dark-90:       rgba(0,0,0,0.9);
  --overlay-light-08:      rgba(255,255,255,0.08);
  --overlay-light-20:      rgba(255,255,255,0.2);
  --overlay-gold-04:       rgba(196,164,74,0.04);
  --overlay-gold-08:       rgba(196,164,74,0.08);
  --overlay-gold-12:       rgba(196,164,74,0.12);
  --overlay-gold-15:       rgba(196,164,74,0.15);
  --overlay-gold-25:       rgba(196,164,74,0.25);
  --overlay-gold-40:       rgba(196,164,74,0.4);
  --overlay-blue-08:       rgba(90,122,154,0.08);   /* accent-blue at 8% */
  --overlay-blue-10:       rgba(77,171,247,0.1);
  --overlay-blue-20:       rgba(77,171,247,0.2);
  --overlay-navy-15:       rgba(80,130,196,0.15);
  --overlay-navy-20:       rgba(76,100,180,0.2);
  --overlay-success-08:    rgba(76,175,80,0.08);    /* color-success at 8% */
  --overlay-success-15:    rgba(76,175,80,0.15);    /* color-success at 15% */
  --overlay-green-15:      rgba(90,138,74,0.15);    /* accent-green at 15% */
  --overlay-danger-10:     rgba(255,68,68,0.1);
  --overlay-danger-15:     rgba(180,60,60,0.15);
  --overlay-danger-40:     rgba(120,30,30,0.4);
  --overlay-danger-50:     rgba(180,60,60,0.5);
  --overlay-panel-brown:   rgba(40,35,30,0.7);
  --gradient-bar-top:      rgba(40,35,30,0.96);     /* stage/preview bar gradient top */
  --gradient-bar-bot:      rgba(30,26,22,0.98);     /* stage/preview bar gradient bottom */

  /* === Die Colors (#2585 Option A — physical top-lit dice, militaria
   * palette aligned to #2580. The *-bg tokens are gradients so the die
   * face reads as a lit physical object; hue still encodes outcome
   * (hit = glossy red, miss = cool pale, damage = brass, dimmed = faded)
   * and border/glow/pip depth reinforce the signal. Only ever consumed
   * as `background:` in Die.tsx — safe as gradients. Hit = gallery row 5
   * (casino glossy red, cream recessed pips, strong top sheen) — #2585.) === */
  --color-die-dimmed-bg:   linear-gradient(155deg, #3a342b 0%, #2b261f 55%, #211d17 100%);
  --color-die-damage-bg:   linear-gradient(155deg, #efce86 0%, #c79a48 44%, #8a6324 100%);
  --color-die-hit-bg:      linear-gradient(155deg, #ef6a5f 0%, #cc352f 40%, #7a1818 100%);
  --color-die-hit-border:  #5a1414;
  --color-die-miss-bg:     linear-gradient(155deg, #dad9d2 0%, #bcbbb1 46%, #8d8c82 100%);
  --color-die-miss-border: #5b5a51;
  --glow-hit:              0 0 8px rgba(192,48,48,0.4);

  /* === Board-mode 3D cube die (#3066) — rounded glossy bodies w/ white dome
   * pips, modelled on the STRATAK reference dice (saturated opaque plastic,
   * soft upper-left sheen). SEPARATE from the flat --color-die-* set above so
   * the off-board die is unchanged. *-bg = face gradient; *-core = the solid
   * backing-cube colour that fills the rounded faces' corner gaps. Mapping:
   * hit = glossy red, miss = reference black, damage = gold. === */
  --color-diecube-hit-bg:      linear-gradient(165deg, #ec4c3e 0%, #d22a22 48%, #971310 100%);
  --color-diecube-hit-core:    #a51b16;
  --color-diecube-miss-bg:     linear-gradient(165deg, #3c3c42 0%, #1e1e23 48%, #0a0a0d 100%);
  --color-diecube-miss-core:   #161619;
  --color-diecube-damage-bg:   linear-gradient(165deg, #f3c652 0%, #d99e2e 48%, #a06915 100%);
  --color-diecube-damage-core: #bd8722;
  --color-diecube-dimmed-bg:   linear-gradient(165deg, #3a342b 0%, #2b261f 55%, #211d17 100%);
  --color-diecube-dimmed-core: #241f18;

  /* === Extended Status Colors === */
  --color-warning-soft:    #ff9966;   /* pulsing timer warning color */
  --color-warning-muted:   #ffaa44;   /* air unit remaining movement */
  --color-warning-error:   #ffaa88;   /* air landing error text */
  --color-stat-hp:         #a050d0;   /* unit stat card HP color */

  /* === Extended Light Overlays === */
  --overlay-light-02:      rgba(255,255,255,0.02);
  --overlay-light-03:      rgba(255,255,255,0.03);
  --overlay-light-04:      rgba(255,255,255,0.04);
  --overlay-light-10:      rgba(255,255,255,0.1);

  /* === Extended Gold Overlays (accent-gold = rgb(196,164,74)) === */
  --overlay-gold-10:       rgba(196,164,74,0.1);
  --overlay-gold-20:       rgba(196,164,74,0.2);
  --overlay-gold-30:       rgba(196,164,74,0.3);
  --overlay-gold-accent-10: rgba(212,160,32,0.1);  /* text-accent at 10% */
  --overlay-gold-accent-20: rgba(212,160,32,0.2);  /* text-accent at 20% */

  /* === Hit/Danger Overlays === */
  --overlay-hit-18:        rgba(224,80,80,0.18);
  --overlay-danger-18:     rgba(180,40,40,0.18);
  --overlay-danger-35:     rgba(200,60,60,0.35);
  --overlay-danger-dark-30: rgba(80,30,30,0.3);    /* dark danger background */
  --overlay-border-30:     rgba(90,85,64,0.3);     /* border-primary at 30% */
  --overlay-casualty-20:   rgba(160,64,64,0.2);    /* casualty selection highlight */
  --overlay-danger-ruby-25: rgba(233,69,96,0.25);  /* ruby danger accent */

  /* === Ocean/Amphibious Overlays === */
  /* Canonical ocean-blue scrim — single RGB (80,144,192) at 10/15/20/30. */
  --overlay-ocean-10:      rgba(80,144,192,0.1);
  --overlay-ocean-15:      rgba(80,144,192,0.15);
  --overlay-ocean-20:      rgba(80,144,192,0.2);
  --overlay-ocean-30:      rgba(80,144,192,0.3);
  --overlay-ocean-dark-30: rgba(20,30,40,0.3);
  --overlay-ocean-dark-50: rgba(20,30,40,0.5);
  --overlay-ocean-dark-60: rgba(20,30,40,0.6);

  /* === SBR / Battle Result Overlays === */
  --overlay-sbr-dark:      rgba(10,8,5,0.93);
  --overlay-battle-screen: rgba(10,8,5,0.92);  /* full-screen battle/combat backdrop */
  --overlay-win-green:     rgba(20,60,20,0.5);
  --overlay-loss-red:      rgba(60,20,20,0.5);
  --overlay-battle-draw-1: rgba(80,80,60,0.3);
  --overlay-battle-draw-2: rgba(40,40,30,0.3);

  /* === Misc Overlays === */
  --overlay-info-30:       rgba(77,120,160,0.3);
  --overlay-parchment-05:  rgba(200,184,120,0.05);
  --overlay-search-bg:     rgba(30,28,20,0.95);
  --overlay-minimap-bg:    rgba(10,16,40,0.9);
  --overlay-map-dark:      rgba(30,28,22,0.85);

  /* === Map Drawing Constants === */
  --color-link-water:      #4080a0;   /* neighbor water territory link */
  --color-link-land:       #a0a0cc;   /* neighbor land territory link */
  --overlay-blue-25:        rgba(77,171,247,0.25);
  --overlay-casualty-12:    rgba(160,64,64,0.12);
  --overlay-amber-12:       rgba(200,130,40,0.12);  /* rocket attack amber accent */
  --overlay-attacker-15:    rgba(224,96,64,0.15);   /* color-attacker at 15% */
  --overlay-attacker-30:    rgba(224,96,64,0.3);    /* color-attacker at 30% */
  --overlay-bright-green-12: rgba(68,204,136,0.12); /* color-success-bright at 12% */
  --overlay-bright-green-15: rgba(68,204,136,0.15); /* color-success-bright at 15% */
  --overlay-bright-green-25: rgba(68,204,136,0.25); /* color-success-bright at 25% */
  --overlay-bright-green-30: rgba(68,204,136,0.3);  /* color-success-bright at 30% */
  --overlay-warning-15:     rgba(255,140,0,0.15);   /* color-warning at 15% */
  --overlay-warning-08:     rgba(255,140,0,0.08);   /* color-warning at 8% — arrow/damage demo bg */
  --overlay-warning-25:     rgba(255,140,0,0.25);   /* color-warning at 25% — arrow/damage demo border */
  --gradient-panel-top-82:  rgba(40,35,30,0.82);    /* bottom panel gradient top (translucent) */
  --gradient-panel-bot-88:  rgba(30,26,22,0.88);    /* bottom panel gradient bottom (translucent) */

  /* === Indicator Demo Overlays (FieldManualPanel / HelpSidebarTab swatches) === */
  --overlay-green-10:       rgba(90,138,74,0.1);    /* accent-green at 10% — chevron demo bg */
  --overlay-green-30:       rgba(90,138,74,0.3);    /* accent-green at 30% — chevron demo border */
  --overlay-teal-08:        rgba(42,106,122,0.08);  /* teal at 8% — convoy/stealth demo bg */
  --overlay-teal-10:        rgba(42,138,154,0.1);   /* lighter teal at 10% — recon demo bg */
  --overlay-teal-30:        rgba(42,106,122,0.3);   /* teal at 30% — stealth demo border */
  --overlay-teal-dark-70:   rgba(26,74,90,0.7);     /* dark teal at 70% — convoy inner circle */
  --overlay-crimson-08:     rgba(139,48,48,0.08);   /* crimson at 8% — kamikaze demo bg */
  --overlay-crimson-35:     rgba(139,48,48,0.35);   /* crimson at 35% — kamikaze dashed border */
  --overlay-crimson-70:     rgba(139,48,48,0.7);    /* crimson at 70% — kamikaze inner circle */
  --overlay-casualty-35:    rgba(160,64,64,0.35);   /* casualty red at 35% — battle demo border */
  --overlay-bronze-12:      rgba(80,70,50,0.12);    /* bronze at 12% — chip/ghost demo bg */
  --overlay-ghost-30:       rgba(120,110,80,0.3);   /* ghost-tan at 30% — ghost demo dashed border */
  --overlay-fog-border:     rgba(80,80,80,0.4);     /* mid-gray at 40% — fog demo border */
  --overlay-amber-25:       rgba(200,130,40,0.25);  /* amber at 25% — damage indicator border */
  --overlay-blue-slate-15:  rgba(90,122,154,0.15);  /* slate-blue at 15% — move-phase tag bg */
  --overlay-blue-slate-25:  rgba(90,122,154,0.25);  /* slate-blue at 25% — move-phase tag border */
}

/* === Safe Area Utility Classes ===
 * Use these on edge-anchored chrome elements so they clear the Dynamic Island
 * and home indicator. Full-bleed backdrops (PixiMapView, overlay scrims) must
 * NOT use these — they should bleed to the physical edge. */
.safe-inset-l, .safe-inset-left   { padding-left:   var(--safe-l); }
.safe-inset-r, .safe-inset-right  { padding-right:  var(--safe-r); }
.safe-inset-t, .safe-inset-top    { padding-top:    var(--safe-t); }
.safe-inset-b, .safe-inset-bottom { padding-bottom: var(--safe-b); }
.safe-inset-x { padding-left: var(--safe-l); padding-right:  var(--safe-r); }
.safe-inset-y { padding-top:  var(--safe-t); padding-bottom: var(--safe-b); }

/* === Tighter text tokens for narrow viewports (≤ 1024px, e.g. iPhone landscape) ===
 * These are for the in-game HUD. The lobby keeps the base scale (#5145 B-1):
 * at 390px the tight scale set its labels at 8–9px. `:root` is matched rather
 * than `.lobby-shell` so sheets the lobby portals to <body> get the scale too. */
@media (max-width: 1024px) {
  :root:not(:has(.lobby-shell)) {
    --text-xs:   clamp(0.5rem,    0.46rem + 0.13vw, 0.625rem);
    --text-sm:   clamp(0.5625rem, 0.52rem + 0.18vw, 0.6875rem);
    --text-base: clamp(0.6875rem, 0.63rem + 0.32vw, 0.8125rem);
    --text-lg:   clamp(0.875rem,  0.81rem + 0.41vw, 1rem);
    --text-xl:   clamp(1rem,      0.93rem + 0.47vw, 1.1875rem);
  }
  /* The base --text-xs is 9px on a phone, under the 11pt iOS caption floor.
   * In the lobby it starts at 11px (tab labels, badges, the bell footer). */
  :root:has(.lobby-shell) {
    --text-xs:   clamp(0.6875rem, 0.63rem + 0.13vw, 0.75rem);
  }
}

/* === Root Font Size === */
html {
  /* Fixed 16px base — fluid sizing lives in --text-* / --space-* tokens,
     not the root, to avoid double-scaling clamp-inside-clamp.
     --text-scale (set by manual text-size preference) still works as a multiplier. */
  font-size: calc(16px * var(--text-scale, 1));
}

/* === Global Overrides === */
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
}

/* Global film grain — subtle noise over all surfaces for analog richness */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
  mix-blend-mode: overlay;
}

/* === Keyboard Focus === */
/* Suppress browser default outline for mouse/touch users */
*:focus:not(:focus-visible) {
  outline: none;
}
/* Gold ring for keyboard navigation — matches war-room accent */
*:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}
/* Text fields that draw their own edge (#5565): the ring sits on the box, as a
 * shadow, because inline styles on these fields cannot be beaten by an outline
 * rule and none of them set box-shadow. Browsers match :focus-visible on a
 * click into a text field too, so this is also the clicked look. */
.input-focus-ring { outline: none; }
.input-focus-ring:focus-visible { box-shadow: 0 0 0 2px var(--accent-gold); }

/* === Disabled controls (#5565) ===
 * A disabled button looks disabled even when its class has no :disabled rule.
 * button:disabled (0,1,1) beats a single class; a class's own :disabled rule
 * (0,2,0) still sets its own opacity. The cursor is !important because many
 * buttons set cursor: pointer inline, and a disabled one must never show it. */
button:disabled {
  opacity: 0.4;
  cursor: not-allowed !important;
}

/*
 * === Hover Convention ===
 *
 * Default:  filter: brightness(1.15) — works on any solid background.
 * Ghost/transparent elements: background swap to show interactivity.
 * Semantic buttons (danger, acknowledge): explicit color changes allowed.
 * Text-only feedback (dismiss, ghost-danger): color change only.
 */

/* === Beveled Button — instrument chrome (#3562) === */
.btn-bevel {
  background: var(--bg-raised);
  color: var(--text-ivory-muted);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  font-family: var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.btn-bevel:hover:not(:disabled) {
  color: var(--text-ivory);
  border-color: var(--accent-brass);
}
.btn-bevel:active:not(:disabled) {
  background: var(--bg-rail);
}
.btn-bevel:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-bevel.is-on {
  background: var(--bg-rail);
  color: var(--text-ivory);
  border-color: var(--accent-brass);
}

/* Text toggle in the top bar (Threats/Plan, #3824) — height from .toolbar-ctl */
.btn-bevel--chip {
  padding: 0 var(--space-sm);
  font-size: var(--text-xs);
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0.2em;
}

/* === END PHASE Button — the one filled gold slab (#3562) === */
.btn-end-phase {
  background: linear-gradient(180deg, #c4b06a 0%, var(--accent-brass) 100%);
  color: var(--color-on-gold);
  border: 1px solid var(--accent-gold);
  border-radius: 0;
  box-shadow: none;
  font-family: var(--font-heading);
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter var(--transition-normal), transform var(--transition-fast);
}
.btn-end-phase:hover:not(:disabled) {
  border-color: var(--accent-gold);
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.btn-end-phase:active:not(:disabled) {
  transform: translateY(0);
}
.btn-end-phase:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* #4246: a commit button whose move is in flight. Dimmed and ringed with a spinner
 * (not the :disabled look) so it reads as "working", not "unavailable". */
.btn-end-phase[aria-busy='true'],
.combat-action-primary[aria-busy='true'],
.btn[aria-busy='true'] {
  opacity: 1;
  cursor: progress;
  position: relative;
}
.btn-end-phase[aria-busy='true']::after,
.combat-action-primary[aria-busy='true']::after,
.btn[aria-busy='true']::after {
  content: '';
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  margin-left: var(--space-sm);
  vertical-align: -0.1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: commit-pending-spin 0.7s linear infinite;
}
@keyframes commit-pending-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn-end-phase[aria-busy='true']::after,
  .combat-action-primary[aria-busy='true']::after,
  .btn[aria-busy='true']::after { animation-duration: 2.4s; }
}

/* === Panel (Crisp Contrast: clean gradient, no texture) === */
.panel-leather {
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 14px;
}

/* === Panel Section === */
.panel-section {
  padding: 14px;
}

/* === Category Headers === */
.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  box-shadow: 0 0 4px currentColor;
}

.category-label {
  font-weight: 600;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.9);
}

/* === Numbered Item Badges === */
.item-badge {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(196,164,74,0.15);
  color: var(--accent-gold);
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.item-row {
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  padding: 8px 10px;
}

/* === Hit Category Chips === */
.chip-sub     { background: rgba(74,158,255,0.12); border: 1px solid rgba(74,158,255,0.3); color: #7ab8ff; }
.chip-air     { background: rgba(255,152,0,0.15);  border: 1px solid rgba(255,152,0,0.4);  color: #ffb74d; }
.chip-surface { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); color: rgba(255,255,255,0.5); }
.chip-aa      { background: rgba(212,160,32,0.12); border: 1px solid rgba(212,160,32,0.3); color: #e8d48b; }

.chip-active { font-weight: bold; }
.chip-sub.chip-active     { box-shadow: 0 0 8px rgba(74,158,255,0.15); }
.chip-air.chip-active     { box-shadow: 0 0 8px rgba(255,152,0,0.15); }
.chip-aa.chip-active      { box-shadow: 0 0 8px rgba(212,160,32,0.15); }

/* === Unit Miniature Effect === */
.unit-miniature {
  filter: drop-shadow(1px 2px 2px rgba(0,0,0,0.6))
          contrast(1.15)
          brightness(1.05);
  image-rendering: auto;
}
.unit-miniature:hover {
  filter: drop-shadow(1px 2px 3px rgba(0,0,0,0.7))
          contrast(1.2)
          brightness(1.15);
}

/* === Heading Font === */
.heading-ww2 {
  font-family: var(--font-heading);
  color: var(--text-ivory);
  letter-spacing: 0.12em;
  text-shadow: none;
}

/* "Show sites" chip under an IC purchase row (#3856). Compact visually, but the
 * ::after pseudo-element grows the touch target to roughly 44px. */
.purchase-sites-chip {
  position: relative;
  align-self: flex-start;
  white-space: nowrap;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-xs);
  line-height: 1.2;
}
.purchase-sites-chip::after {
  content: '';
  position: absolute;
  inset: calc(-1 * var(--space-md)) calc(-1 * var(--space-sm));
}

/* Armed-IC legal-site explainer over the map in Purchase (#3856) */
.ic-site-banner {
  position: absolute;
  top: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90%, 40rem);
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-rail);
  border: 1px solid var(--border-brass);
  color: var(--text-ivory);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  text-align: center;
  pointer-events: none;
  z-index: var(--z-bottom-bar);
}

/* WebGL context loss (#4961). Same placement as the IC banner, but a button:
   the canvas is dead until the player reloads. Not `.btn` — that family's
   hover translate would drop this centering transform. */
.map-context-lost {
  position: absolute;
  top: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90%, 40rem);
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-rail);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
  color: var(--text-ivory);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  text-align: center;
  cursor: pointer;
  z-index: var(--z-overlay);
}
.map-context-lost:hover,
.map-context-lost:active {
  transform: translateX(-50%);
  filter: brightness(1.08);
}

/* 3D board touch camera (#5339): the Rotate button and, under it, the Rotate-mode
   pill, top left of the map: clear of the sidebar (right), the phase hint bar and
   the territory bar (bottom). The column lets map touches through between them. */
.board3d-cam-controls {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
  max-width: calc(100% - 2 * var(--space-sm));
  z-index: var(--z-search);
  pointer-events: none;
}
.board3d-cam-controls > * {
  pointer-events: auto;
}
.board3d-rotate-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: 44px;
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-rail);
  border: 1px solid var(--border-brass);
  color: var(--text-ivory);
  touch-action: manipulation;
}
.board3d-rotate-btn[aria-pressed="true"] {
  background: var(--btn-bg-primary);
  border-color: var(--accent-brass);
}
.board3d-rotate-indicator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  max-width: 22rem;
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-rail);
  border: 1px solid var(--accent-brass);
  border-radius: var(--radius-md);
  color: var(--text-ivory);
  font-size: var(--text-sm);
  touch-action: manipulation;
}
.board3d-rotate-indicator .btn {
  min-height: 36px;
}
.board3d-rotate-indicator__label {
  flex-basis: 100%;
  font-weight: 600;
  padding: 0 var(--space-xs);
}
.board3d-rotate-indicator__presets {
  display: inline-flex;
  gap: 2px;
}
.board3d-rotate-indicator__preset[aria-pressed="true"] {
  border-color: var(--accent-brass);
  color: var(--text-ivory);
}

/* === Phase Chips === */
.phase-chip {
  padding: 2px 5px;
  border-radius: 0;
  font-size: var(--text-xs);
  line-height: 1.2;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  white-space: nowrap;
  border: 1px solid var(--border-brass);
  cursor: default;
  user-select: none;
  font-family: var(--font-ui);
}
.phase-chip--active {
  background: var(--bg-raised);
  color: var(--text-ivory);
  border-color: var(--accent-brass);
  padding: 0 var(--space-sm);
  line-height: 1;
  font-size: var(--text-xs);
  position: relative;
  z-index: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-width: 0;
  max-width: 100%;
}
.phase-chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.phase-chip-round {
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-ivory-muted);
  flex-shrink: 0;
}
.phase-chip-help-icon {
  opacity: 0.65;
  font-size: 0.75em;
  font-weight: bold;
  text-transform: none;
  letter-spacing: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em;
  height: 1.4em;
  border-radius: 50%;
  border: 1px solid currentColor;
  line-height: 1;
  flex-shrink: 0;
}
.phase-chip--activating {
  animation: phaseActivate 0.4s ease-out;
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-primary);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-accent);
}

.lobby-splash-exit {
  animation: lobby-splashFadeOut 0.6s ease-out forwards;
}

/* Lobby split panel base styles */
.lobby-panel-left {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 50%;
  clip-path: polygon(0 0, 100% 0, 85% 100%, 0 100%);
  overflow: hidden;
  z-index: 1;
}
.lobby-panel-right {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  clip-path: polygon(15% 0, 100% 0, 100% 100%, 0 100%);
  overflow: hidden;
  z-index: 1;
}
.lobby-diagonal {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  transform: skewX(-5deg);
  background: linear-gradient(to bottom, rgba(196,165,74,0.1), rgba(196,165,74,0.6), rgba(196,165,74,0.1));
  box-shadow: 0 0 20px rgba(196,165,74,0.3), 0 0 60px rgba(196,165,74,0.1);
  z-index: 2;
  animation: lobby-diagonalGlow 4s ease-in-out infinite;
  pointer-events: none;
}

/* Lobby: mobile — stack panels top/bottom */
@media (max-width: 600px) {
  .lobby-panel-left {
    width: 100% !important;
    height: 55vh !important;
    bottom: 45vh !important;
    top: 0 !important;
    clip-path: polygon(0 0, 100% 0, 100% 87%, 0 100%) !important;
  }
  .lobby-panel-right {
    width: 100% !important;
    height: 55vh !important;
    top: 45vh !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    clip-path: polygon(0 13%, 100% 0, 100% 100%, 0 100%) !important;
  }
  .lobby-diagonal {
    top: 50% !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 6px !important;
    transform: skewY(-3deg) !important;
    box-shadow: 0 0 12px 2px rgba(196,165,74,0.5), 0 0 24px 4px rgba(196,165,74,0.25), 0 0 40px 8px rgba(196,165,74,0.1) !important;
  }
  .lobby-center-content {
    top: 50% !important;
  }
  .lobby-center-content::before {
    content: '';
    position: absolute;
    inset: -24px -32px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    z-index: -1;
  }
  /* iOS Safari: disable backdrop-filter (freezes main thread on M1 iPad) */
  @supports (-webkit-touch-callout: none) {
    .lobby-center-content::before {
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      background: rgba(0, 0, 0, 0.72);
    }
  }
  /* Subtitle: reduce bottom margin */
  .lobby-center-content > h1 + div {
    margin-bottom: 24px !important;
  }
  /* Decorative line: reduce bottom margin */
  .lobby-center-content > h1 + div + div {
    margin-bottom: 16px !important;
  }
}

/* === Dice Animation === */
.dice-rolling {
  display: inline-block;
  animation: diceRoll 0.5s ease-out;
}
.dice-tumble {
  animation: diceTumble 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.dice-hit {
  color: var(--color-hit);
  text-shadow: 0 0 6px rgba(224, 80, 80, 0.6);
  position: relative;
  /* Wins over .dice-tumble's transform animation, as hitPulse used to. */
  animation: none;
}
.dice-hit::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(224, 80, 80, 0.5);
  opacity: 0;
  animation: hitPulse 0.4s ease-out forwards;
  animation-delay: inherit;
}
.dice-miss {
  color: var(--color-miss);
  animation: missFall 0.3s ease-out forwards;
}

/* === Rolling Table (center column felt background) === */
.rolling-table {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 120% 80% at 50% 40%, rgba(52, 78, 52, 0.35) 0%, transparent 70%),
    linear-gradient(180deg, #1c2418 0%, #1a1e14 40%, #181a12 100%);
  position: relative;
}
.rolling-table::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow:
    inset 0 8px 20px rgba(0, 0, 0, 0.5),
    inset 0 -8px 20px rgba(0, 0, 0, 0.4),
    inset 8px 0 16px rgba(0, 0, 0, 0.3),
    inset -8px 0 16px rgba(0, 0, 0, 0.3);
  border-radius: inherit;
  z-index: 0;
}
.rolling-table > * {
  position: relative;
  z-index: 1;
}

/* === Drag ghost chip — GPU compositor hint ===
   will-change:transform promotes the ghost group to a compositor layer so iOS
   Safari can repaint it without repainting the full map SVG. The SVG transform
   attribute is still used for positioning (correct SVG user-space coords). */
.drag-ghost { will-change: transform; }

/* === Map LOD — hide the raster shadow overlay during pan/zoom gestures ===
   The .map-zooming class is added to the SVG by useD3Zoom when the map is
   actually panning/zooming and removed 50 ms after it settles. Only the
   large raster shadow overlay is hidden — it is the most expensive element
   to composite on each frame. Territory labels and unit chips remain
   visible throughout; SVG viewport culling (MapView) keeps their count low
   enough that pan performance is acceptable without hiding them. */
.map-lod-shadow { transition: opacity 0.12s ease-out; }
.map-zooming .map-lod-shadow { opacity: 0; pointer-events: none; }

/* === Map Viewport — vintage cartography styling === */
.map-viewport::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.55) 100%);
  z-index: 10;
}
/* === Acknowledge Hits Button === */
.btn-acknowledge-hits {
  font-family: var(--font-heading);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border: 2px solid var(--accent-red);
  background: linear-gradient(180deg, rgba(224, 80, 80, 0.18) 0%, rgba(180, 50, 50, 0.12) 100%);
  color: var(--accent-red-bright);
  box-shadow: 0 0 12px rgba(224, 80, 80, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn-acknowledge-hits:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(224, 80, 80, 0.28) 0%, rgba(180, 50, 50, 0.2) 100%);
  box-shadow: 0 0 20px rgba(224, 80, 80, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.btn-acknowledge-hits:active:not(:disabled) {
  transform: scale(0.97);
}
.btn-acknowledge-hits--zero {
  border-color: var(--border-accent);
  background: linear-gradient(180deg, rgba(196, 164, 74, 0.12) 0%, rgba(160, 130, 50, 0.08) 100%);
  color: var(--accent-gold);
  box-shadow: 0 0 8px rgba(196, 164, 74, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.btn-acknowledge-hits--zero:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(196, 164, 74, 0.2) 0%, rgba(160, 130, 50, 0.14) 100%);
  box-shadow: 0 0 16px rgba(196, 164, 74, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* === Battle Board === */
.battle-power-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 34px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  color: var(--accent-gold);
  font-size: var(--text-lg);
  font-weight: 700;
  flex-shrink: 0;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.battle-unit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-secondary);
  transition: background var(--transition-fast);
}
.battle-unit-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}
.battle-noncombatant {
  opacity: 0.4;
  font-style: italic;
}

/* === Button Size Variants === */
.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}
.btn-md {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-base);
  border-radius: var(--radius-md);
}

/* === Button Color Variants === */
.btn-primary {
  background: var(--btn-bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--accent-brass);
  transition: background var(--transition-fast), filter var(--transition-fast), transform var(--transition-fast);
}
.btn-danger {
  background: linear-gradient(180deg, rgba(180,60,60,0.2) 0%, rgba(180,60,60,0.1) 100%);
  color: #e8a0a0;
  border: 1px solid rgba(180,60,60,0.35);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.btn-danger:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.btn-danger:active:not(:disabled) {
  transform: translateY(0);
}
.btn-danger:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}
.btn-success {
  background: var(--btn-bg-success);
  color: var(--text-primary);
  border: 1px solid var(--accent-green);
  transition: background var(--transition-fast), filter var(--transition-fast), transform var(--transition-fast);
}
.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.08);
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.btn-ghost:active:not(:disabled) {
  transform: translateY(0);
}
.btn-ghost:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

/* === Button Shape Variants === */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 0;
  letter-spacing: 0;
  text-transform: none;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.btn-stepper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: var(--text-base);
  line-height: 22px;
  text-align: center;
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), filter var(--transition-fast), transform var(--transition-fast);
}

/* === Base Panel Button === */
.btn {
  padding: 4px 10px;
  font-size: var(--text-sm);
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  filter: brightness(1.1);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.3);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* === Floating card (#5565) ===
 * One surface for tooltips, popovers and cards over the map: HoverTooltip,
 * GhostIntelTooltip, UnitStatCard, DragQuantityPopover, IncomeSummaryCard,
 * and the docked AttackPreviewBar and commanders drawer. Components keep only
 * per-instance edges inline (an owner's colour). */
.floating-card {
  background: var(--surface-tooltip);
  border: 1px solid var(--tooltip-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  color: var(--tooltip-text);
}
/* Pinned or featured: the brass edge. */
.floating-card--accent { border-color: var(--border-accent); }
/* Docked to the bottom edge: square, one brass top edge, shadow cast upward. */
.floating-card--bar {
  border-width: 2px 0 0;
  border-color: var(--border-accent);
  border-radius: 0;
  box-shadow: 0 -4px 16px var(--overlay-dark-50);
}
/* Docked to the end edge: square, one gold rule on the inner side. */
.floating-card--drawer {
  border-width: 0 0 0 1px;
  border-color: var(--overlay-gold-25);
  border-radius: 0;
}

/* === Compact Button === */
.btn-xs {
  padding: 2px 6px;
  font-size: var(--text-xs);
}

/* === Header/Overlay Button === */
.btn-header {
  padding: 2px 8px;
  font-size: var(--text-xs);
  color: var(--text-primary);
  background: var(--btn-bg);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: var(--transition-fast);
}

/* === Overlay Close Button (shared across info panels) === */
.btn-close-overlay {
  padding: 2px var(--space-sm);
  font-size: var(--text-lg);
  line-height: 1;
  color: var(--text-ivory-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}
.btn-close-overlay:hover {
  color: var(--text-ivory);
  border-color: var(--border-brass);
}

/* === Lobby / Auth Button === */
.btn-lobby {
  background: linear-gradient(180deg, var(--accent-gold) 0%, var(--accent-brass) 100%);
  color: var(--color-on-gold);
  border: 1px solid var(--accent-gold);
  border-radius: 0;
  font-family: var(--font-heading);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  box-shadow: none;
}
.btn-lobby:hover:not(.btn-lobby--disabled) {
  filter: brightness(1.08);
}
.btn-lobby--disabled {
  background: var(--surface-input);
  color: var(--text-muted);
  border-color: var(--btn-bg);
  cursor: not-allowed;
  box-shadow: none;
}

/* === Debug Panel Button === */
.btn-debug {
  background: var(--btn-bg);
  border: 1px solid var(--border-primary);
  border-radius: 3px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  padding: 2px 5px;
  line-height: 16px;
  min-width: 22px;
  text-align: center;
  transition: var(--transition-fast);
}

/* === Panel Overlay === */
.panel-overlay {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E"),
    var(--bg-rail);
  background-size: 200px 200px, 100% 100%;
  border: 1px solid var(--border-brass);
  border-radius: 0;
  box-shadow: var(--shadow-lg);
  padding: var(--space-lg);
  max-height: 90vh;
  max-height: 90dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  overscroll-behavior: contain;
}

/* === Card === */
.card {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 150 150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.0' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E"),
    var(--bg-tertiary);
  background-size: 150px 150px, 100% 100%;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.card:hover {
  border-color: var(--border-accent);
  box-shadow: 0 0 8px rgba(196, 164, 74, 0.1);
}

/* === Modal Backdrop === */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === Toast === */
.toast {
  background: var(--surface-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-left: 3px solid var(--accent-brass);
  border-radius: 2px;
  box-shadow: var(--shadow-lg);
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-base);
  z-index: var(--z-toast);
  position: relative;
  overflow: hidden;
}
.toast::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    135deg,
    var(--border-brass-grid) 0px,
    transparent 2px,
    transparent 6px
  );
  pointer-events: none;
}

/* === Divider === */
.divider {
  border: none;
  border-top: 1px solid var(--border-secondary);
  margin: var(--space-md) 0;
}

/* === Menu Item === */
.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: var(--text-base);
  font-family: var(--font-ui);
  color: var(--text-ivory);
  border-left: 2px solid transparent;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.menu-item:hover {
  background: var(--bg-raised);
  border-left-color: var(--accent-brass);
}

/* A menu row with a switch on its right ("Defense Profile", #4332): the label
   opens a panel, the switch acts in place. 44px tall for a thumb. */
.menu-item-split {
  display: flex;
  align-items: stretch;
}
.menu-item-split > .menu-item {
  flex: 1;
  min-width: 0;
}
.menu-item-switch {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
  padding: 0 var(--space-lg) 0 var(--space-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.menu-item-switch[aria-checked="true"] {
  color: var(--text-ivory);
}
.menu-item-switch:hover {
  background: var(--bg-raised);
}

/* A link styled as a menu row ("Open game channel", #4276) matches the button rows. */
a.menu-item {
  text-decoration: none;
  box-sizing: border-box;
}

/* Why a menu row did nothing ("Join team voice" refused, #4379), under that row. */
.menu-item-note {
  padding: 0 var(--space-lg) var(--space-sm);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Dialog header + empty copy (#3562) */
.panel-header-dialog {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-brass);
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.panel-header-dialog-title {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-ivory);
  font-family: var(--font-heading);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.dialog-empty {
  padding: var(--space-lg);
  text-align: center;
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--text-ivory-muted);
}

/* Settings drawer (#3562) */
.hamburger-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: linear-gradient(180deg, var(--bg-rail) 0%, var(--bg-ink) 100%);
  border-right: 1px solid var(--border-brass);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-top: var(--safe-t);
  padding-left: var(--safe-l);
  padding-bottom: var(--safe-b);
  font-family: var(--font-ui);
  color: var(--text-ivory);
}
.hamburger-drawer::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.7 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}
.hamburger-drawer > * { position: relative; z-index: 1; }
.hamburger-drawer-header {
  padding-top: calc(var(--space-md) + var(--safe-t));
  padding-bottom: var(--space-md);
  padding-left: calc(var(--space-lg) + var(--safe-l));
  padding-right: var(--space-lg);
  border-bottom: 1px solid var(--border-brass);
  box-shadow: 0 1px 0 rgba(212, 175, 106, 0.18);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hamburger-drawer-title {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-ivory);
  font-family: var(--font-heading);
  letter-spacing: 0.14em;
}
.hamburger-section {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent-brass);
  padding: var(--space-sm) var(--space-lg) var(--space-xs) var(--space-lg);
  font-family: var(--font-ui);
}

/* Settings dialog — one column when tall/narrow; two section columns in landscape. */
.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}
.settings-block { min-width: 0; }
/* Secondary line under a settings row, e.g. Graphics auto-downgrade (#5066). */
.settings-note {
  margin: calc(-1 * var(--space-xs)) 0 var(--space-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
/* A text-button link inside a .settings-note, e.g. Report a problem next to 3D (beta) (#5339). */
.settings-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--text-primary);
  text-decoration: underline;
  cursor: pointer;
}
@media (min-width: 640px) and (orientation: landscape), (min-width: 880px) {
  .settings-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: var(--space-xl);
    row-gap: var(--space-lg);
    align-items: start;
  }
}

/* #5148: below 900px the shared Settings dialog (You tab and in-game) is the
   lobby settings sheet — UI-face title, 44px controls. Desktop stays the
   centred panel. Segments match .options-segment-btn; the switch keeps its
   40×20 track with a 44px hit area (#5562). */
@media (max-width: 899px) {
  [data-testid="settings-dialog"] .panel-header-dialog-title {
    font-family: var(--font-ui);
    letter-spacing: 0.12em;
  }
  [data-testid="settings-dialog"] .btn-close-overlay {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    padding: 0;
  }
  .settings-row {
    flex-wrap: wrap;
    row-gap: var(--space-xs);
  }
  .settings-body .options-segment-group {
    flex: 1 1 100%;
  }
  .settings-body .options-segment-btn,
  .settings-body .btn-bevel,
  .settings-body .btn-primary,
  .settings-body select,
  .settings-body input[type="range"] {
    box-sizing: border-box;
    min-width: var(--tap-min);
    min-height: var(--tap-min);
  }
  /* #5562: the switch keeps its drawn 40x20 size, as in the lobby (#5077);
     a 44px-tall hit area replaces the 70x44 track that was twice the desktop switch. */
  .settings-body .toggle-switch::after {
    content: '';
    position: absolute;
    inset: calc((var(--tap-min) - 20px) / -2) -2px;
  }
  .settings-body a[href] {
    display: inline-flex;
    align-items: center;
    box-sizing: border-box;
    min-width: var(--tap-min);
    min-height: var(--tap-min);
  }
}

/* === Toggle Switch === (ui/Switch, ui/SwitchTrack; one family, #5562) */
.toggle-switch {
  display: inline-block;
  box-sizing: border-box;
  width: 36px;
  height: 18px;
  border-radius: 9px;
  border: 1px solid var(--border-primary);
  background: var(--btn-bg);
  position: relative;
  cursor: pointer;
  transition: background var(--transition-normal);
  flex-shrink: 0;
  padding: 0;
}
.toggle-switch--on {
  background: var(--toggle-track-on);
  border-color: var(--accent-brass);
}
.toggle-switch--lg {
  width: 40px;
  height: 20px;
  border-radius: 10px;
}
.toggle-knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--toggle-knob);
  position: absolute;
  top: 1px;
  left: 1px;
  transition: left var(--transition-normal), background var(--transition-normal);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.toggle-switch--on .toggle-knob {
  background: var(--toggle-knob-on);
  left: 19px;
}
.toggle-switch--lg .toggle-knob {
  width: 16px;
  height: 16px;
}
.toggle-switch--lg.toggle-switch--on .toggle-knob {
  left: 21px;
}

/* === Toast Variants === */
.toast--success::before,
.toast--error::before,
.toast--info::before {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  font-weight: 500;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.toast--success {
  background: var(--bg-tertiary);
  border-left-color: var(--accent-green);
  box-shadow: 0 4px 20px rgba(76, 175, 80, 0.3), 0 0 40px rgba(76, 175, 80, 0.1);
}
.toast--success::before {
  content: 'DISPATCH';
  color: var(--accent-green);
}
.toast--error {
  background: var(--bg-tertiary);
  border-left-color: var(--accent-red-bright);
  box-shadow: 0 4px 20px rgba(192, 64, 64, 0.3), 0 0 40px rgba(192, 64, 64, 0.1);
}
.toast--error::before {
  content: 'ALERT';
  color: var(--accent-red-bright);
}
.toast--info::before {
  content: 'NOTICE';
  color: var(--accent-brass);
}

/* === Stepper Button Hover === */
.btn-stepper-hover {
  transition: filter var(--transition-fast);
}
.btn-stepper-hover:hover:not(:disabled) {
  filter: brightness(1.15);
}

/* === Shared StepperPill — quiet bevel pair (#3562) === */
.stepper-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 0;
  overflow: hidden;
  border: 1px solid var(--border-brass);
  flex-shrink: 0;
}
.stepper-pill-btn {
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-family: var(--font-ui);
  background: var(--bg-raised);
  color: var(--text-ivory);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.stepper-pill-btn:hover:not(:disabled) {
  background: var(--bg-rail);
}
.stepper-pill-btn:disabled {
  background: var(--bg-ink);
  color: var(--text-ivory-muted);
  cursor: not-allowed;
}
.stepper-pill-count {
  text-align: center;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--bg-ink);
  user-select: none;
}
.stepper-pill-btn:focus-visible {
  outline: 2px solid var(--accent-brass);
  outline-offset: -2px;
  position: relative;
  z-index: 1;
}

/* === Hover Highlight (interactive list item bg on hover) === */
.hover-highlight:hover {
  background: var(--btn-bg);
}

/* === Save/Load Slot Row States === */
.slot-row-hover {
  background: transparent;
  border-left: 2px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.slot-row-hover:hover {
  background: var(--surface-hover);
  border-left-color: var(--accent-brass);
}
.slot-row-selected {
  background: var(--surface-panel);
  transition: background var(--transition-fast);
}

/* === Auto-save Row === */
.slot-autosave-row {
  background: var(--bg-tertiary);
  border-left: 2px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.slot-autosave-row:hover {
  background: var(--surface-hover);
  border-left-color: var(--accent-brass);
}

/* === Ghost Button Danger Variant === */
.btn-ghost-danger {
  color: var(--text-muted);
}
.btn-ghost-danger:hover {
  color: var(--accent-red-bright);
}

/* === Search Result Item === */
.search-result-item:hover {
  background: var(--surface-hover);
}

/* === Toolbar Title (game name in top bar) === */
.toolbar-left {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
  /* Never narrower than the gear (#5334). At 0 the gear spilled out and the
   * turn tracker painted over it, taking its taps. */
  min-width: var(--toolbar-control-h);
}
.toolbar-left > .toolbar-ctl { flex-shrink: 0; }
.toolbar-title {
  flex: 0 0 auto;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--accent-gold);
  font-family: var(--font-heading);
  letter-spacing: 0.22em;
  white-space: nowrap;
}

/* In-game top bar (#3562) */
.board-top-bar {
  background: linear-gradient(180deg, var(--bg-rail) 0%, var(--bg-ink) 100%);
  padding: calc(4px + var(--safe-t)) calc(12px + var(--safe-r)) var(--space-xs) calc(12px + var(--safe-l));
  display: flex;
  align-items: center;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-brass);
  min-height: 40px;
  container-type: inline-size;
}

.board-readout {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--bg-raised);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-brass);
  margin-left: 6px;
  font-family: var(--font-mono);
}
.board-readout-label {
  color: var(--text-ivory-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
}
.board-readout-value {
  color: var(--text-ivory);
  font-size: var(--text-sm);
  font-weight: 500;
}

.board-income-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--bg-raised);
  color: var(--text-ivory);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  cursor: pointer;
  font-family: var(--font-mono);
}
/* IPC change (#4240): the number counts, the change floats up and fades. */
.board-ipc-value {
  position: relative;
  font-variant-numeric: tabular-nums;
}
.board-ipc-floater {
  position: absolute;
  left: 50%;
  top: 100%;
  font-size: var(--text-xs);
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
  animation: board-ipc-float var(--motion-duration) var(--motion-ease) forwards;
}
.board-ipc-floater.is-gain { color: var(--color-success-bright); }
.board-ipc-floater.is-loss { color: var(--color-danger-soft); }
@keyframes board-ipc-float {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, 100%); }
}
.board-income-btn.is-on {
  border-color: var(--accent-brass);
  background: var(--bg-rail);
}
.board-income-coin {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid var(--accent-brass);
  background: var(--bg-ink);
  color: var(--text-ivory);
  font-weight: 700;
  line-height: 1;
}
.toolbar-game-name {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  min-width: 0;
}

/* === Responsive Toolbar Collapse === */
@media (max-width: 560px) {
  .toolbar-income {
    display: none !important;
  }
}
@media (max-width: 500px) {
  .toolbar-title,
  .toolbar-game-name {
    display: none !important;
  }
  .board-top-bar {
    flex-wrap: nowrap;
  }
  .board-toolbar-right {
    flex: 0 0 auto;
  }
  .board-phase-row {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--space-xs);
  }
  .phase-chip--active {
    letter-spacing: 0.06em;
    padding-inline: var(--space-xs);
  }
}
@media (max-width: 440px) {
  .toolbar-title,
  .toolbar-game-name {
    display: none !important;
  }
}

/* === Sidebar Toggle Tab (mobile drawer mode) === */
.sidebar-toggle-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: var(--z-sidebar-backdrop);
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  padding: 12px 6px;
  cursor: pointer;
  color: var(--accent-gold);
  font-size: var(--text-lg);
  box-shadow: var(--shadow-md);
  transition: filter var(--transition-fast);
  line-height: 1;
}
.sidebar-toggle-tab:hover {
  filter: brightness(1.15);
}

/* === Loading Shimmer ===
   The highlight is a pseudo-element translated across the box. Animating
   background-position repaints; transform stays on the compositor. (#5016) */
.shimmer {
  position: relative;
  overflow: hidden;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}
.shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 50%;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    transparent        0%,
    var(--bg-secondary) 35%,
    var(--surface-card) 50%,
    var(--bg-secondary) 65%,
    transparent        100%
  );
  animation: shimmer 1.6s ease-in-out infinite;
}
.shimmer > * { position: relative; z-index: 1; }

/* === Radio Shimmer — gold-tinted variant for game-context loading === */

/* === Waiting Room — radio/telegraph status indicator === */

/* === Signal Strength Indicator === */

/* === Error Banner === */
.error-banner {
  background: rgba(160, 64, 64, 0.12);
  border: 1px solid rgba(192, 80, 80, 0.3);
  border-left: 3px solid var(--accent-red-bright);
  border-radius: var(--radius-sm);
  color: var(--accent-red-bright);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATION KEYFRAMES
   All @keyframes consolidated here, grouped by category.
   prefers-reduced-motion coverage is handled globally below.
   ═══════════════════════════════════════════════════════════════ */

/* --- Entrance: elements appearing on screen --- */

/* fadeIn — simple opacity entrance
   Duration: varies | Easing: varies
   Consumers: general-purpose utility */
@keyframes aiTurnDotPulse {
  0%, 80%, 100% { opacity: 0.25; }
  40%           { opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* toastSlideIn — telegram-style slide from right
   Duration: 0.4s | Easing: ease-out
   Consumers: TechBreakthroughToast, InvalidMoveToast, TransportLoadToast, IncomeBanner */
@keyframes toastSlideIn {
  0%   { transform: translateX(100%); opacity: 0; }
  60%  { transform: translateX(-4px); opacity: 1; }
  100% { transform: translateX(0); opacity: 1; }
}

/* slideUp — panel/element slides up into view
   Duration: 0.2s | Easing: ease
   Consumers: PhasePanel */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* slideUpBar — bottom bar entrance from below
   Duration: 200ms | Easing: ease-out
   Consumers: AttackPreviewBar, StagePreviewBar, TerritoryBottomPanel */
@keyframes slideUpBar {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* slideInRight — element slides in from the right
   Duration: varies | Easing: varies
   Consumers: general-purpose utility */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* arrowAppear — movement arrow fade-in on the map
   Duration: 0.35s | Easing: ease-out
   Consumers: MapView .arrow-appear */
@keyframes arrowAppear {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* lobby-titleFade — lobby title/subtitle scale-up entrance
   Duration: 1.2–1.5s | Easing: ease-out
   Consumers: LobbyPage (title, subtitle, divider) */
@keyframes lobby-titleFade {
  0%   { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

/* lobby-ctaFade — delayed fade-in for lobby CTA text
   Duration: 2.5s | Easing: ease
   Consumers: LobbyPage (CTA section) */
@keyframes lobby-ctaFade {
  0%   { opacity: 0; }
  60%  { opacity: 0; }
  100% { opacity: 1; }
}

/* lobby-menuSlideUp — lobby menu items slide up with staggered delay
   Duration: 0.5–0.8s | Easing: ease-out
   Consumers: LobbyPage (menu items, game list, auth section) */
@keyframes lobby-menuSlideUp {
  0%   { opacity: 0; transform: translateY(40px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* --- Exit: elements leaving the screen --- */

/* fadeOut — simple opacity exit
   Duration: varies | Easing: varies
   Consumers: general-purpose utility */
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* slideOutRight — element slides out to the right
   Duration: varies | Easing: varies
   Consumers: general-purpose utility */
@keyframes slideOutRight {
  from { transform: translateX(0); }
  to   { transform: translateX(100%); }
}

/* slideInLeft — element slides in from the left edge
   Duration: varies | Easing: varies
   Consumers: HamburgerMenu (settings panel, gear-triggered) */
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* slideOutLeft — element slides out to the left edge
   Duration: varies | Easing: varies
   Consumers: HamburgerMenu (settings panel, gear-triggered) */
@keyframes slideOutLeft {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* lobby-splashFadeOut — splash screen fade-out on lobby load
   Duration: 0.6s | Easing: ease-out
   Consumers: .lobby-splash-exit */
@keyframes lobby-splashFadeOut {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* --- Feedback: response to user actions --- */

/* phaseActivate — brief flash when a phase chip becomes active
   Duration: 0.4s | Easing: ease-out
   Consumers: .phase-chip--activating */
@keyframes phaseActivate {
  0%   { opacity: 1; }
  20%  { opacity: 0.6; }
  100% { opacity: 1; }
}

/* diceTumble — bouncy dice entry with rotation and scale
   Duration: 0.45s | Easing: cubic-bezier(0.34, 1.56, 0.64, 1)
   Consumers: .dice-tumble */
@keyframes diceTumble {
  0%   { transform: translateY(-8px) rotate(-15deg) scale(0.6); opacity: 0; }
  25%  { transform: translateY(3px) rotate(12deg) scale(1.15); opacity: 0.7; }
  50%  { transform: translateY(-2px) rotate(-6deg) scale(0.95); opacity: 0.9; }
  75%  { transform: translateY(1px) rotate(3deg) scale(1.05); }
  100% { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
}

/* hitPulse — red glow behind hit dice on landing.
   The shadow itself is static on .dice-hit::after; only opacity animates.
   Duration: 0.4s | Easing: ease-out
   Consumers: .dice-hit::after */
@keyframes hitPulse {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Thinking ring. The 2px shadow is static on .presence-pulse::after.
   Opacity + scale stand in for the old 2px→6px spread so the ping still
   grows and fades, without animating box-shadow. (#5016)
   Consumers: .presence-pulse (FlagBadge, roster status dot) */
.presence-pulse { position: relative; }
.presence-pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(196, 82, 82, 0.9);
  animation: presencePulse 1.6s ease-in-out infinite;
}
@keyframes presencePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0; transform: scale(1.35); }
}

/* missFall — subtle downward drift and fade for missed dice
   Duration: 0.3s | Easing: ease-out
   Consumers: .dice-miss */
@keyframes missFall {
  0%   { transform: translateY(0); opacity: 0.8; }
  100% { transform: translateY(2px); opacity: 0.5; }
}

/* diceRoll — rapid spin and scale during dice roll
   Duration: 0.5s | Easing: ease-out
   Consumers: .dice-rolling */
@keyframes diceRoll {
  0%   { transform: rotate(0deg) scale(1); opacity: 0.3; }
  20%  { transform: rotate(72deg) scale(1.3); opacity: 0.6; }
  40%  { transform: rotate(144deg) scale(0.8); }
  60%  { transform: rotate(216deg) scale(1.2); }
  80%  { transform: rotate(288deg) scale(0.9); }
  100% { transform: rotate(360deg) scale(1); opacity: 1; }
}

/* diceTumble3d — board-mode 3D cube die tumbling while rolling
   Duration: 0.55s | Easing: linear | Iterations: infinite
   Consumers: .dice-tumble-3d (board-mode <Die> cube, #3036) */
.dice-tumble-3d {
  transform-style: preserve-3d;
  /* animation-name + duration are set inline per-die (diceTumble3dA/B/C +
   * varied duration) so a volley doesn't tumble in lockstep (#3036). */
  animation: diceTumble3d 0.55s linear infinite;
}
@keyframes diceTumble3d {
  0%   { transform: rotateX(-35deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(-395deg) rotateY(360deg) rotateZ(180deg); }
}
/* Three distinct tumble paths (different axis emphasis + signs) — each die
 * picks one by hash so the roll looks chaotic, not synchronized. */
@keyframes diceTumble3dA {
  0%   { transform: rotateX(-35deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(-395deg) rotateY(180deg) rotateZ(90deg); }
}
@keyframes diceTumble3dB {
  0%   { transform: rotateX(-20deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(-200deg) rotateY(540deg) rotateZ(-140deg); }
}
@keyframes diceTumble3dC {
  0%   { transform: rotateX(15deg) rotateY(0deg) rotateZ(0deg); }
  100% { transform: rotateX(375deg) rotateY(-360deg) rotateZ(240deg); }
}

/* diceFlipbook — compositor-only sprite-die playback (#3267). Scrolls the
   atlas-row strip one frame at a time via translateX + steps(); the strip is
   DICE_FRAMES×S wide so translateX(-100%) lands on the last (result) frame.
   animation-timing-function: steps(N) and animation-duration are set inline
   (N + jitter come from JS). Only translateX animates → stays on the compositor
   (no repaint), replacing the legacy cube's ~15-layer composite. */
.dice-flipbook {
  animation-name: diceFlipbook;
  animation-iteration-count: infinite;
  will-change: transform;
}
@keyframes diceFlipbook {
  from { transform: translateX(0); }
  to   { transform: translateX(-100%); }
}

/* diceSettle3d — one-shot landing bounce for board-mode cube dice (#3036).
   The die drops in, lands, and bounces a couple of diminishing times before
   resting. Pure vertical bounce with UNIFORM scale — no squash/stretch (the
   non-uniform scale read as a cartoonish compress). Lives on the cube's
   perspective wrapper so the translate composes OVER the per-die resting tilt
   (on the inner element's inline transform). Duration 0.52s = SETTLE_MS. */
.dice-settle-3d { animation: diceSettle3d calc(0.52s * var(--battle-anim-scale, 1)) ease-out both; }
@keyframes diceSettle3d {
  0%   { transform: translateY(-30%) scale(0.92); }
  40%  { transform: translateY(0)    scale(1); }   /* land */
  60%  { transform: translateY(-9%)  scale(1); }   /* bounce */
  78%  { transform: translateY(0)    scale(1); }
  90%  { transform: translateY(-3%)  scale(1); }   /* small second bounce */
  100% { transform: translateY(0)    scale(1); }
}

/* diceRevealPop — the hit/damage glow underlay blooms in as the die settles,
   so the colored outcome reads as "just cast" rather than appearing flatly.
   Preserves the centering translate the inline style applies. (#3036) */
.dice-reveal-pop { animation: diceRevealPop calc(0.52s * var(--battle-anim-scale, 1)) ease-out both; }
@keyframes diceRevealPop {
  0%   { opacity: 0;   transform: translate(-50%, -50%) scale(0.35); }
  40%  { opacity: 1;   transform: translate(-50%, -50%) scale(1.3); }
  100% { opacity: 1;   transform: translate(-50%, -50%) scale(1); }
}

/* diceShadowLand — contact shadow spreads from a point on impact then settles
   to its resting pool, selling the die landing on the felt. (#3036) */
.dice-shadow-land { animation: diceShadowLand calc(0.52s * var(--battle-anim-scale, 1)) cubic-bezier(0.22, 0.9, 0.3, 1) both; }
@keyframes diceShadowLand {
  0%   { opacity: 0;    transform: translateX(-50%) scale(0.45, 0.45); }
  42%  { opacity: 0.95; transform: translateX(-50%) scale(1.18, 1.18); }
  100% { opacity: 1;    transform: translateX(-50%) scale(1, 1); }
}

/* shimmer — loading skeleton sweep. The band is 50% of the box wide
   (see .shimmer::after); translateX moves it fully across. (#5016)
   Duration: 1.6s on .shimmer, 2s on .shimmer-radio | Easing: ease-in-out */
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

/* transmit — pulsing opacity for radio/telegraph status text
   Duration: 2s | Easing: ease-in-out | Iterations: infinite
   Consumers: .waiting-status */
@keyframes transmit {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* --- Attention: draw the user's eye --- */

/* turnPulse — pulsing opacity for turn indicator
   Duration: varies | Easing: varies
   Consumers: (available for turn-related highlights) */
@keyframes turnPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* arrowPulse — subtle opacity pulse for arrow indicators
   Duration: varies | Easing: varies
   Consumers: (available for arrow-related highlights) */
@keyframes arrowPulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.6; }
}

/* lobby-ctaPulse — gentle scale+opacity pulse on lobby CTA
   Duration: 3s | Easing: ease-in-out | Iterations: infinite
   Consumers: LobbyPage (CTA button) */
@keyframes lobby-ctaPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.02); }
}

/* lobby-diagonalGlow — pulsing glow on diagonal separator line
   Duration: 4s | Easing: ease-in-out | Iterations: infinite
   Consumers: LobbyPage (diagonal divider) */
@keyframes lobby-diagonalGlow {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

/* --- Ambient: continuous background motion --- */

/* lobby-subtlePan — slow scale/translate drift on lobby backgrounds
   Duration: 25s | Easing: ease-in-out | Iterations: infinite
   Consumers: LobbyPage (background panels, forward and reverse) */
@keyframes lobby-subtlePan {
  0%   { transform: scale(1.08) translateY(0); }
  50%  { transform: scale(1.12) translateY(-1%); }
  100% { transform: scale(1.08) translateY(0); }
}

/* spin-dash — DEPRECATED: was used for must-land dashed ring, replaced by SVG animate halo.
   Kept for backwards compat in case any other consumer references it. */
@keyframes spin-dash {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* lobby-slideLeft — slide-in from left edge
   Duration: varies | Easing: varies
   Consumers: LobbyPage (left panel entrance) */
@keyframes lobby-slideLeft {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(0); }
}

/* lobby-slideRight — slide-in from right edge
   Duration: varies | Easing: varies
   Consumers: LobbyPage (right panel entrance) */
@keyframes lobby-slideRight {
  0%   { transform: translateX(100%); }
  100% { transform: translateX(0); }
}

/* arrow-appear — helper class for arrowAppear keyframe */
.arrow-appear {
  animation: arrowAppear 0.35s ease-out forwards;
}

/* typewriter-in — clip-path reveal for new war diary entries
   Duration: 0.3s | Easing: ease-out
   Consumers: .tan-line-new */
@keyframes typewriter-in {
  from { clip-path: inset(0 100% 0 0); opacity: 0.6; }
  to   { clip-path: inset(0 0 0 0); opacity: 1; }
}
.tan-line-new {
  animation: typewriter-in 0.3s ease-out;
}

/* === Reduced Motion ===
 * Respect the user's OS-level "Reduce motion" preference.
 * Collapses all CSS animations to a single instant frame and
 * removes transition durations so state changes appear immediately.
 * JS animations (useMovementAnimation, D3 zoom) check
 * matchMedia('(prefers-reduced-motion: reduce)') separately.
 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* === Panel Layout Utilities === */
.panel-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.panel-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.flex-1-min0 {
  flex: 1;
  min-width: 0;
}

/* === War Diary Panel === */
.wdiary-round-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--btn-bg);
  font-size: var(--text-sm);
  font-weight: bold;
  color: var(--text-ivory);
}
.wdiary-nav-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: 0 var(--space-xs);
  line-height: 1;
}
.wdiary-filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--btn-bg);
  flex-wrap: wrap;
}
.wdiary-view-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px var(--space-sm);
  border-bottom: 1px solid var(--btn-bg);
  font-size: var(--text-xs);
}
.wdiary-toggle-btn {
  background: none;
  border: 1px solid var(--border-primary);
  border-radius: 3px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--text-xs);
  padding: 1px 6px;
  font-family: var(--font-mono);
  position: relative;
}
.wdiary-toggle-btn::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--accent-brass);
  transition: width var(--transition-normal), left var(--transition-normal);
}
.wdiary-toggle-btn:hover::after,
.wdiary-toggle-btn--active::after {
  width: 100%;
  left: 0;
}
.wdiary-toggle-btn--active {
  background: var(--btn-bg);
  color: var(--text-primary);
}

/* === Game Log === */
.gamelog-scroll,
.wdiary-body {
  font-family: var(--font-diary);
  background: linear-gradient(180deg, rgba(40,38,30,0.4) 0%, rgba(35,33,26,0.3) 100%);
}
.gamelog-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-xs);
  line-height: 1.6;
}
.wdiary-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  font-size: var(--text-xs);
  line-height: 1.5;
}

/* Turn header: nation name left, Watch turn (#4031) right. */
.wdiary-turn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.wdiary-watch {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-width: 0;
}

.wdiary-watch-note {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: normal;
  text-align: right;
}

/* Details disclosure button inside BattleEntryCard / SBREntryCard */
.wdiary-details-btn {
  background: rgba(196, 165, 74, 0.08);
  border: 1px solid rgba(196, 165, 74, 0.25);
  border-radius: 3px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: 4px 10px;
  margin-top: 4px;
  margin-left: 10px;
  display: inline-block;
  letter-spacing: 0.3px;
}
.wdiary-details-btn:hover {
  background: rgba(196, 165, 74, 0.15);
  color: var(--accent-gold);
  border-color: rgba(196, 165, 74, 0.45);
}
.tan-line-phase {
  color: var(--text-primary);
  font-weight: bold;
  margin-top: var(--space-sm);
  padding-top: var(--space-xs);
  display: flex;
  align-items: center;
  gap: 0.5em;
  text-transform: uppercase;
  font-size: calc(var(--text-xs) * 0.9);
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.tan-line-phase::before,
.tan-line-phase::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--tooltip-divider);
}
.tan-line-phase::before {
  max-width: 1.5em;
}
.tan-line-move     { color: var(--text-secondary); }
.tan-line-battle   { color: var(--text-accent); font-weight: bold; }
.tan-line-dice     { color: var(--color-log-dice); }
.tan-line-outcome  { color: var(--text-secondary); }
.tan-line-purchase  { color: var(--color-log-purchase); }
.tan-line-placement { color: var(--color-log-placement); }
.tan-line-income   { color: var(--color-log-income); }
.tan-line-text     { color: var(--text-secondary); }
.tan-line--highlighted {
  background: var(--tooltip-divider);
  border-radius: 2px;
  margin: 0 -4px;
  padding: 0 4px;
}
.tan-line-phase.tan-line--highlighted {
  padding: 2px 4px;
}

/* === Chat Panel === */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}
.chat-tab-bar {
  display: flex;
  padding: var(--space-xs) var(--space-sm) 0;
  border-bottom: 1px solid var(--border-primary);
}
.chat-tab {
  padding: 3px 10px;
  font-size: var(--text-xs);
  font-weight: normal;
  background: transparent;
  border: 1px solid var(--border-primary);
  border-bottom-color: var(--border-primary);
  border-radius: 3px 3px 0 0;
  color: var(--text-muted);
  cursor: pointer;
  margin-right: 2px;
  position: relative;
}
.chat-tab::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--accent-brass);
  transition: width var(--transition-normal), left var(--transition-normal);
}
.chat-tab:hover::after,
.chat-tab--active::after {
  width: 100%;
  left: 0;
}
.chat-tab--active {
  font-weight: bold;
  background: var(--btn-bg);
  border-bottom-color: var(--btn-bg);
  color: var(--text-ivory);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
}
.chat-emoji-picker {
  position: absolute;
  bottom: 44px;
  left: 4px;
  right: 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  z-index: 100;
}
.chat-emoji-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-lg);
  padding: 2px;
  border-radius: 3px;
  line-height: 1;
}
.chat-input-row {
  display: flex;
  border-top: 1px solid var(--btn-bg);
  padding: var(--space-xs);
  gap: var(--space-xs);
}
.chat-emoji-toggle {
  background: var(--surface-input);
  border: 1px solid var(--border-primary);
  border-radius: 3px;
  font-size: var(--text-base);
  padding: 2px 6px;
  cursor: pointer;
  line-height: 1;
}
.chat-emoji-toggle--active {
  background: var(--btn-bg);
}
.chat-text-input {
  flex: 1;
  background: var(--surface-input);
  border: 1px solid var(--border-primary);
  border-radius: 3px;
  color: var(--text-primary);
  font-size: var(--text-sm);
  padding: var(--space-xs) 6px;
  outline: none;
}
.chat-text-input:focus-visible { box-shadow: 0 0 0 2px var(--accent-gold); }
/* Resign type-to-confirm field (#4306): full-width, tap-sized, the typed
   word set apart so a near-miss like "RESIGN " is visible. */
.resign-confirm-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: var(--tap-min);
  margin-bottom: var(--space-sm);
  font-size: var(--text-base);
  letter-spacing: 0.15em;
}
.chat-send-btn {
  background: var(--surface-input);
  border: 1px solid var(--border-primary);
  border-radius: 3px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  padding: var(--space-xs) var(--space-sm);
  cursor: default;
}
.chat-send-btn--active {
  background: var(--btn-bg-primary);
  color: var(--text-ivory);
  cursor: pointer;
}

/* === Badge === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border-secondary);
  line-height: 1.4;
}
.badge-success {
  background: rgba(90, 138, 74, 0.2);
  color: var(--color-success-bright);
  border-color: var(--accent-green);
}
.badge-danger {
  background: rgba(160, 64, 64, 0.2);
  color: var(--accent-red-bright);
  border-color: var(--accent-red);
}
.badge-info {
  background: rgba(90, 122, 154, 0.2);
  color: var(--accent-blue-light);
  border-color: var(--accent-blue);
}
.badge-warning {
  background: rgba(255, 140, 0, 0.15);
  color: var(--color-warning);
  border-color: var(--color-warning);
}

/* === MapRoomBoard === */

/* Loading state before game state is available */
.board-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
}

/* Hidden file input (load-from-file) */
.board-file-input-hidden {
  display: none;
}

/* Main content area: map fills full width; sidebar floats absolutely over the right edge */
.board-main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  /* Keep map/UI clear of the notch when Dynamic Island is on the left in landscape,
     and of a lesson card's rail (#5457). */
  padding-left: var(--stage-left);
}

/* Map wrapper (fills remaining width) */
.board-map-wrapper {
  flex: 1;
  min-height: 0;
  position: relative;
}

/* Disconnection warning banner */
.board-disconnected-banner {
  background: var(--accent-red);
  color: var(--text-primary);
  padding: 6px var(--space-md);
  text-align: center;
  font-size: var(--font-body);
  font-size: var(--text-base);
  font-weight: bold;
  flex-shrink: 0;
}

/* Turn-tracker center group (flag strip with borders) */
.board-turn-tracker {
  display: flex;
  align-items: center;
  gap: 2px;
  border-left: 1px solid var(--border-secondary);
  border-right: 1px solid var(--border-secondary);
  padding-left: var(--space-sm);
  padding-right: var(--space-sm);
  min-width: 0;
}

/* IPC income badge in the toolbar */
.board-income-badge {
  font-weight: 600;
  color: var(--accent-gold);
  margin-left: 6px;
  white-space: nowrap;
  background: rgba(196,164,74,0.12);
  border: 1px solid rgba(196,164,74,0.3);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  line-height: 16px;
}

/* Phase chip row (toolbar right-of-center group) */
.board-phase-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-left: var(--space-sm);
  min-width: 0;
}

/* === AI turn indicator (#3734) ===
 * Ambient "the computer is playing" status, sat beside the phase chip in the
 * top bar. Driven by `isAiInputBlocked` — the same predicate that silently
 * drops human dispatch (#1611) — so it appears exactly when clicks stop
 * working, and never when they still work.
 *
 * Rule 9: a human sentence, so --font-body, and NOT gold. The flag ring and
 * phase chip already carry the warm brass accent in this bar; a second gold
 * object here would be the wrong one. Muted ivory keeps it ambient — the
 * player is meant to keep studying the map, not look at this.
 */
.ai-turn-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-left: var(--space-sm);
  min-width: 0;                 /* let the label ellipsize, not overflow the bar */
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
}

.ai-turn-indicator-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Indeterminate affordance: three dots pulsing in sequence. Never a progress
 * bar — an AI decision runs from ~100ms (defensive picks) to 90s (purchase
 * simulates the whole turn forward), so any percentage would be fiction. */
.ai-turn-indicator-dots {
  display: inline-flex;
  flex-shrink: 0;
  gap: calc(var(--space-xs) / 2);
}

.ai-turn-indicator-dots > span {
  width: var(--space-xs);
  height: var(--space-xs);
  border-radius: 50%;
  background: currentColor;
  animation: aiTurnDotPulse 1.2s ease-in-out infinite;
}

.ai-turn-indicator-dots > span:nth-child(2) { animation-delay: 0.16s; }
.ai-turn-indicator-dots > span:nth-child(3) { animation-delay: 0.32s; }

/* Escalated state (#3548): the match has gone silent long enough that a hung
 * or unclaimed bot is the likelier explanation than a slow one. The dots stop
 * moving on purpose — animating them here would keep advertising activity
 * that demonstrably is not happening, which is the regression this state
 * exists to prevent. */
.ai-turn-indicator--stalled {
  color: var(--color-warning-soft);
}

.ai-turn-indicator--stalled .ai-turn-indicator-dots > span {
  animation: none;
  opacity: 0.5;
}

/* Phone-width bar (.board-top-bar is a size container): drop the dots so the
 * indicator's min-content width is zero and it can ellipsize away entirely
 * rather than pushing the hamburger off the bar — .board-toolbar-right is
 * `flex: 1 0 auto` and does not shrink, so anything that refuses to shrink
 * here overflows the bar instead (the #3001 failure mode). The sentence is
 * the information; the dots are decoration, so the dots go first. */
@container (max-width: 420px) {
  .ai-turn-indicator-dots { display: none; }
}

/* A squeezed bar wraps the phase name onto a second line rather than cutting it
 * to "NON-COMBAT M…" (#5334). With room it stays on one line. */
.board-top-bar .phase-chip--active {
  white-space: normal;
  text-align: center;
  line-height: 1.2;
}
.board-top-bar .phase-chip-help-icon { flex-shrink: 0; }
/* Where the bar can be squeezed (phone portrait, tablets, a 1280 desktop), keep
 * clear space between the wrapped chip and the right-hand group. */
@media (max-width: 500px), (min-height: 501px) and (max-width: 1366px) {
  .board-top-bar .board-toolbar-right { margin-left: var(--space-xs); }
}

/* === Tablet-width top bar (#5334): 501–1279px, set by useIsTabletBar. The turn
 * tracker is one compact strip, the phase name wraps rather than truncating, and
 * no group shrinks below its contents. === */
.board-top-bar--tablet .toolbar-left {
  flex: 0 0 auto;
  margin-right: var(--space-xs);
}
.board-top-bar--tablet .toolbar-game-name { display: none; }
.board-top-bar--tablet .board-turn-tracker { flex: 0 0 auto; padding: 0 0 0 var(--space-xs); border-right: 0; }
.board-top-bar--tablet .board-phase-row { flex: 0 1 auto; min-width: min-content; margin-left: var(--space-xs); }
.board-top-bar--tablet .phase-chip--active { letter-spacing: 0.08em; }
.board-top-bar--tablet .toolbar-ctl.btn-bevel { min-width: var(--toolbar-control-h); }

/* A tablet in portrait has no room for the bid chip beside a turn timer. The
 * settings menu's header shows the bid. */
@media (max-width: 800px) {
  .board-top-bar--tablet .phase-chip--bid { display: none; }
}

/* Narrower than an iPad mini in portrait (a split view, a small window) the
 * bar takes a second row so nothing runs off the right edge. */
@media (max-width: 743px) {
  .board-top-bar--tablet { flex-wrap: wrap; row-gap: var(--space-xs); }
}

.turn-strip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-width: var(--toolbar-control-h);
  margin: 0;
  padding: 0 var(--space-xs);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  background: var(--bg-raised);
}
.turn-strip--button { cursor: pointer; }
.turn-strip-slot { display: inline-flex; border-radius: 50%; opacity: 0.55; }
.turn-strip-slot.is-active { opacity: 1; box-shadow: 0 0 0 2px var(--accent-brass); }
.turn-strip-more {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
}

/* Right end of toolbar, in clusters: [Threats|Plan] │ [Discord] │ [tools] │ [☰] (#4388) */
.board-toolbar-right {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-xs);
}
.toolbar-cluster {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.toolbar-cluster:empty { display: none; }
.toolbar-cluster + .toolbar-cluster {
  padding-left: var(--space-xs);
  border-left: 1px solid var(--border-brass);
}
/* Threats + Plan read as one two-way toggle */
.toolbar-segmented {
  display: inline-flex;
  align-items: center;
}
.toolbar-segmented > .btn-bevel + .btn-bevel { margin-left: -1px; }
.toolbar-segmented > .btn-bevel.is-on { position: relative; z-index: 1; }

/* The shared control height. Every top-bar control carries it. */
.toolbar-ctl {
  box-sizing: border-box;
  height: var(--toolbar-control-h);
}
.btn-icon.toolbar-ctl { width: var(--toolbar-control-h); }
.toolbar-ctl.btn-bevel,
.toolbar-ctl.phase-chip--active,
.toolbar-ctl.board-readout,
.toolbar-ctl.board-income-btn {
  display: inline-flex;
  align-items: center;
}
.toolbar-ctl.board-readout { margin-left: var(--space-xs); }
.toolbar-ctl.btn-bevel { position: relative; }
.toolbar-ctl.btn-bevel:not(.btn-icon):not(.btn-bevel--chip) { padding-block: 0; padding-inline: var(--space-sm); font-size: var(--text-xs); }

/* One on-state for every top-bar control: brass border and text, no fill. */
.board-top-bar .btn-bevel.is-on,
.board-top-bar .board-income-btn.is-on {
  background: var(--bg-raised);
  color: var(--accent-brass);
  border-color: var(--accent-brass);
}

/* Threats / Plan: text on a wide bar, an icon below 1280px (the icon is always
 * labelled by aria-label + title). */
.toolbar-chip-icon { display: none; }
@container (max-width: 1279px) {
  .toolbar-chip-label { display: none; }
  .toolbar-chip-icon { display: inline-flex; }
  .btn-bevel--chip.toolbar-ctl { width: var(--toolbar-control-h); padding: 0; justify-content: center; }
}

/* Film / Reports (#4799): keep the chip text down to 768px. Threats/Plan still
 * collapse to icons below 1280px. */
@container (min-width: 768px) {
  .toolbar-chip--film .toolbar-chip-label,
  .toolbar-chip--reports .toolbar-chip-label { display: inline; }
  .toolbar-chip--film .toolbar-chip-icon,
  .toolbar-chip--reports .toolbar-chip-icon { display: none; }
  .toolbar-chip--film.btn-bevel--chip.toolbar-ctl,
  .toolbar-chip--reports.btn-bevel--chip.toolbar-ctl {
    width: auto;
    padding: 0 var(--space-sm);
    justify-content: center;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  :root { --toolbar-control-h: 40px; }
}
/* Coarse pointers keep --tap-min even when the short-landscape rule also
 * matches (#4796). Same block grows the overlay ✕, icon buttons, sidebar
 * tabs, and steppers. */
@media (pointer: coarse) {
  :root { --toolbar-control-h: var(--tap-min); }
  .btn-close-overlay,
  .btn-icon,
  .board-sidebar-tab,
  .btn-stepper,
  .stepper-pill-btn {
    min-width: var(--tap-min);
    min-height: var(--tap-min);
  }
}

/* Plan chip (#5248). Own rules so the 1279px chip-collapse and the brass
 * no-fill .is-on state do not restyle Off / Show / Edit. The group is the
 * bevel; segment labels stay title case (`.btn-bevel` uppercases). */
.plan-chip-legacy { display: contents; }
.plan-chip {
  display: inline-flex;
  align-items: stretch;
  box-sizing: border-box;
  height: var(--toolbar-control-h);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-xs);
  background: var(--bg-raised);
  overflow: hidden;
  font-family: var(--font-ui);
}
.board-top-bar .plan-chip.toolbar-ctl {
  height: var(--toolbar-control-h);
  padding: 0;
}
.plan-chip-label {
  display: flex;
  align-items: center;
  padding: 0 var(--plan-chip-label-pad);
  border-right: 1px solid var(--border-brass);
  font-family: var(--font-ui);
  font-size: var(--plan-chip-font);
  font-weight: 500;
  line-height: 1;
  letter-spacing: var(--plan-chip-label-track);
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.plan-chip-seg {
  appearance: none;
  margin: 0;
  min-width: var(--plan-chip-seg-min);
  box-sizing: border-box;
  border: 0;
  background: transparent;
  color: var(--text-ivory-muted);
  font-family: var(--font-ui);
  font-size: var(--plan-chip-font);
  font-weight: 500;
  line-height: 1;
  letter-spacing: var(--plan-chip-seg-track);
  cursor: pointer;
}
.board-top-bar .plan-chip-seg.toolbar-ctl {
  height: 100%;
  min-height: 0;
  width: auto;
  padding: 0 var(--plan-chip-seg-pad);
}
.plan-chip-seg + .plan-chip-seg {
  border-left: 1px solid var(--border-brass);
}
.plan-chip-seg[aria-pressed="true"].plan-chip-seg--show {
  background: var(--btn-bg-primary);
  color: var(--text-ivory);
}
.plan-chip-seg[aria-pressed="true"].plan-chip-seg--edit {
  background: var(--accent-brass);
  color: var(--color-on-gold);
}
.plan-chip-seg:hover:not([aria-pressed="true"]) {
  color: var(--text-ivory);
}
.plan-chip-seg:focus-visible,
.plan-chip-icon:focus-visible {
  outline: 2px solid var(--accent-brass);
  outline-offset: -2px;
}
.plan-chip-icon {
  appearance: none;
  box-sizing: border-box;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 0;
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-xs);
  background: var(--bg-raised);
  color: var(--text-ivory-muted);
  font-family: var(--font-ui);
  cursor: pointer;
}
.board-top-bar .plan-chip-icon.toolbar-ctl {
  width: var(--tap-min);
  height: var(--tap-min);
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: var(--space-2xs) 0 0;
}
.plan-chip-glyph {
  font-size: var(--plan-chip-glyph);
  line-height: 1;
}
.plan-chip-state {
  margin-top: var(--plan-chip-state-gap);
  font-size: var(--plan-chip-state);
  font-weight: 600;
  line-height: 1;
  letter-spacing: var(--plan-chip-seg-track);
  text-transform: uppercase;
}
.plan-chip-icon--show {
  border-color: var(--accent-gold);
  color: var(--text-ivory);
}
.plan-chip-icon--edit {
  background: var(--accent-brass);
  border-color: var(--accent-brass);
  color: var(--color-on-gold);
}
.plan-chip-icon--off {
  color: var(--text-ivory-muted);
}

/* Chat panel unread badge (absolute-positioned dot) */
/* #4383: the Discord dropdown that stands in for Chat/Video — the game's threads and
 * voice rooms. It is the only Discord entry (the ☰ menu has none), so the list drops
 * from the button's right edge and is capped to the viewport: on a phone it must not
 * run off either side, and on a short landscape its rows scroll instead of falling
 * below the screen. */
.discord-menu {
  position: relative;
  display: inline-flex;
}
.discord-menu-list {
  position: absolute;
  top: calc(100% + var(--space-xs));
  right: 0;
  z-index: var(--z-menu);
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  max-width: calc(100vw - 2 * var(--space-md));
  max-height: calc(100dvh - 3rem - var(--safe-b));
  overflow-y: auto;
  padding: var(--space-xs) 0;
  background: var(--bg-ink);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
/* #4385: one row per place to talk ("Allies", "Table"): its name, then a message
 * icon (the text thread) and a voice icon (the voice room). On a touch screen each
 * icon is a 44px target. */
.discord-talk-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0 var(--space-sm) 0 var(--space-lg);
}
.discord-talk-name {
  flex: 1;
  min-width: 0;
  padding-right: var(--space-md);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text-ivory);
  white-space: nowrap;
}
.discord-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-ivory);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.discord-icon-btn:hover,
.discord-icon-btn:focus-visible {
  outline: none;
  background: var(--bg-raised);
  color: var(--accent-brass);
}
.discord-icon-btn:disabled {
  color: var(--text-muted);
  cursor: progress;
}
@media (pointer: coarse), (max-width: 500px) {
  .discord-icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

.board-chat-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent-red-bright);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 0 var(--space-xs);
  font-size: var(--text-xs);
  font-weight: bold;
  min-width: 14px;
  text-align: center;
}

/* Chat side panel container */
.board-chat-panel {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-tertiary);
  border-left: 1px solid var(--btn-bg);
  display: flex;
  flex-direction: column;
}

/* Chat side panel header row */
.board-chat-header {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  font-weight: bold;
  color: var(--text-ivory);
  font-family: var(--font-ui);
  border-bottom: 1px solid var(--btn-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Chat close button */
/* The hover tooltip's ✕ is the shared CloseButton (#5562); the tooltip itself ignores the pointer. */
.hover-tooltip-close {
  flex-shrink: 0;
  pointer-events: auto;
  padding: 0 var(--space-2xs);
  font-size: var(--text-base);
}

/* Notes header row (Round label + Add button) */
.board-notes-header {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-bottom: 1px solid var(--btn-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Notes Add button (text-only ghost) */
.board-notes-add-btn {
  background: none;
  border: none;
  color: var(--accent-gold);
  cursor: pointer;
  font-size: var(--text-sm);
  padding: 0;
  line-height: 1;
  font-weight: bold;
}

/* In-game right rail (#3562) */
.board-sidebar {
  background: linear-gradient(180deg, var(--bg-rail) 0%, var(--bg-ink) 100%);
  border-left: 1px solid var(--border-brass);
  box-shadow: var(--shadow-md);
  font-family: var(--font-ui);
  /* Named so the banner row can match the rail's width, not the viewport. */
  container-name: board-sidebar;
}

/* Purchase on a short-landscape phone stretches the sidebar across the whole
 * viewport (BoardSidebar: purchaseFullWidth), so it reaches the left edge where
 * the Dynamic Island / notch sits in landscape. Reserve the left inset so the
 * tab rail and purchase rows stay clear of it (#4689). The sidebar background
 * still runs under the notch; the right inset is already reserved by the
 * content padding below. */
.board-sidebar--full-width {
  padding-left: calc(var(--stage-left) - var(--lesson-rail-w));
  /* Full width stops at a lesson card's rail (#5457). */
  max-width: calc(100% - var(--lesson-rail-w));
}

/* Sidebar icon strip (horizontal tab rail across the top of the panel) */
.board-sidebar-icon-strip {
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  background: var(--bg-rail);
}

/* Sidebar tab — ivory + brass when on, never gold fill (#3562) */
.board-sidebar-tab {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  position: relative;
  padding: 0;
  flex-shrink: 0;
}
.board-sidebar-tab--help {
  font-size: 0.8125rem;
}
.board-sidebar-tab.is-on {
  color: var(--text-ivory);
  background: var(--bg-raised);
  border-bottom-color: var(--accent-brass);
}
.board-sidebar-tab-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  background: var(--accent-brass);
  color: var(--bg-ink);
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* Purchase / Reports HUD tabs — ivory + brass when on (#3562) */
.purchase-repeat {
  width: 100%;
  margin-bottom: var(--space-xs);
  white-space: normal;
  text-align: left;
}

.purchase-tab-bar {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}
.purchase-tab {
  flex: 1;
  padding-block: var(--space-sm);
  padding-inline: 2px;
  font-size: var(--text-xs);
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  color: var(--text-muted);
  background: var(--bg-secondary);
}
.purchase-tab.is-on {
  color: var(--text-ivory);
  background: var(--bg-raised);
  border-bottom-color: var(--accent-brass);
}
.purchase-tab-badge {
  margin-left: var(--space-xs);
  background: var(--accent-brass);
  color: var(--bg-ink);
  border-radius: 8px;
  font-size: var(--text-xs);
  padding-block: 0;
  padding-inline: var(--space-xs);
  font-weight: 700;
  font-family: var(--font-mono);
}
/* Purchase unit list (#5557). One column on desktop, tablet and phone portrait.
 * Phone landscape gives the panel the full screen width (BoardSidebar
 * purchaseFullWidth), so the rows go in two columns: one 800px row put the price
 * about 650px from the name and fitted three units. Anything that is not a unit
 * row (repairs, the empty state) spans both columns. */
.purchase-unit-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}
.purchase-unit-list--two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--space-sm);
}
.purchase-unit-list--two-col > :not(.purchase-unit-row) {
  grid-column: 1 / -1;
}
/* Why a unit can't be bought: a full-width line under its row (#5557). In the
 * name column a 70px-wide sentence ran to seven lines. */
.purchase-lock-reason {
  flex-basis: 100%;
  padding-left: var(--space-xs);
  font-size: var(--text-xs);
  font-style: italic;
  color: var(--text-muted);
  white-space: normal;
}
/* Factory repairs in the Industrial tab (#5406). */
.purchase-repairs {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-secondary);
}
.purchase-repairs__heading {
  /* Clear of a lesson spotlight drawn around the row below (#5406). */
  padding-top: var(--space-xs);
  margin-bottom: var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-brass);
}
.purchase-repairs__row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}
.purchase-repairs__name {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: var(--text-sm);
  color: var(--tooltip-text);
}
.purchase-repairs__damage {
  font-size: var(--text-xs);
  color: var(--color-warning);
}
.purchase-repairs__cost {
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--text-secondary);
}
/* Combat confirm: a move into a sea zone where submarines cannot be seen (#5402). */
.combat-confirm-unsearched {
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-primary);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
  font-size: max(var(--text-sm), var(--text-battle-floor));
  color: var(--text-secondary);
}
.combat-confirm-unsearched__zone {
  display: block;
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}
.reports-tab-bar {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border-brass);
  flex-shrink: 0;
  background: var(--bg-rail);
  padding-top: var(--safe-t);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}
.reports-tab-bar--scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* The Reports close is the shared ✕ (#5562), centred at the end of the tab bar. */
.reports-tab-bar .reports-close {
  flex-shrink: 0;
  align-self: center;
  min-width: 32px;
  min-height: 32px;
  margin-inline: var(--space-xs);
}
@media (pointer: coarse) {
  .reports-tab-bar .reports-close { min-width: var(--tap-min); min-height: var(--tap-min); }
}
/* Wraps the tabs for role=tablist without changing the bar's flex layout (#4798) */
.reports-tablist {
  display: contents;
}
.reports-tab {
  flex: 1;
  flex-shrink: 0;
  padding: 10px var(--space-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.reports-tab--touch {
  flex: unset;
  padding: 12px var(--space-md);
  min-height: 44px;
}
.reports-tab.is-on {
  color: var(--text-ivory);
  background: var(--bg-raised);
  border-bottom-color: var(--accent-brass);
}

/* Income track treasury row — ivory numbers; nation color carries identity (#3562) */
.income-track {
  position: fixed;
  left: 0;
  right: 0;
  z-index: var(--z-income-track);
  background: var(--bg-rail);
  border-bottom: 1px solid var(--border-brass);
  box-shadow: var(--shadow-md);
}
.income-track-treasury {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--border-brass);
  flex-wrap: wrap;
}
.income-track-label {
  color: var(--text-ivory-muted);
  font-weight: 600;
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-right: 4px;
  font-family: var(--font-ui);
}
.income-track-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-raised);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  font-size: var(--text-xs);
}
.income-track-ipc {
  color: var(--text-ivory);
  font-weight: 700;
  font-family: var(--font-mono);
}

/* Sidebar icon strip: with bottom border (when expanded) */
.board-sidebar-icon-strip--expanded {
  border-bottom: 1px solid var(--border-brass);
}

/* Sidebar content area — opaque instrument rail */
.board-sidebar-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0; /* needed in flex-column parent so scroll child can shrink */
  background: var(--bg-ink);
  font-family: var(--font-ui);
  color: var(--text-ivory);
}

/* Tab body above the persistent End Phase footer (#4273).
   min-height:0 lets this region shrink so the footer keeps its own row
   and never covers the tab, including at 390x844 and 844x390. */
.board-sidebar-tab-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sidebar phase name header (when phases tab active) */
.board-sidebar-phase-header {
  padding: 6px calc(10px + var(--safe-r)) 6px 10px;
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-heading);
  letter-spacing: 0.16em;
  color: var(--text-ivory);
  border-bottom: 1px solid var(--border-brass);
  flex-shrink: 0;
}

/* Phase indicator pill inside sidebar phase header */
.board-phase-indicator-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-ivory);
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  line-height: 16px;
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Sidebar scrollable phase content */
.board-sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  /* Pad right for Dynamic Island / notch in landscape; content stays 10px from edge otherwise */
  padding: 6px calc(10px + var(--safe-r)) 6px 10px;
}

/* Host for the phases tab. Unlike .board-sidebar-scroll this does NOT scroll —
   the phase panel (PhasePanelShell) owns its own scroll body. The End Phase
   footer is a sibling below .board-sidebar-tab-pane, not inside this host
   (#4273). Nesting the shell inside an overflow:auto container made iOS Safari
   mis-resolve the height:100% chain (#2998). A plain flex column with
   min-height:0 gives the shell a definite-height parent. */
.board-sidebar-phase-host {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Same insets as .board-sidebar-scroll so phase content keeps identical spacing
     (the footer relies on the right safe-area inset being reserved here). */
  padding: 6px calc(10px + var(--safe-r)) 6px 10px;
}

/* Sidebar End Phase footer. A flex sibling of .board-sidebar-tab-pane, so it
   reserves its own row on every tab (#4273) instead of scrolling away with one
   phase panel. Horizontal inset matches the old nesting: the phase host's 10px
   plus this footer's own 10px, with the notch safe-area on the right. Bottom
   padding clears the home indicator. */
.board-sidebar-footer {
  padding: var(--space-sm) calc(10px + 10px + var(--safe-r)) calc(var(--space-sm) + var(--safe-b)) calc(10px + 10px);
  border-top: 1px solid var(--border-brass);
  flex-shrink: 0;
}

/* Short landscape (iPhone-class): ~75% density scale for right-side panel
   content. Text tokens shrink so stats/list rows don't collide in a
   height-constrained panel (#2597 fix #3); space tokens tighten so padding
   feels proportionate at narrow viewport widths (#2728). Scoped to
   .board-sidebar-content so desktop / portrait / tablet are unaffected. */
@media (orientation: landscape) and (max-height: 500px) {
  .board-sidebar-content {
    --text-xs:   0.5rem;      /* ~8px  */
    --text-sm:   0.5625rem;   /* ~9px  */
    --text-base: 0.625rem;    /* ~10px */
    --space-xs:  0.1875rem;   /* 3px  — ~75% of global min (4px)  */
    --space-sm:  0.375rem;    /* 6px  — ~75% of global min (8px)  */
    --space-md:  0.5625rem;   /* 9px  — ~75% of global min (12px) */
    --space-lg:  0.75rem;     /* 12px — ~75% of global min (16px) */
  }
  /* Tighten hardcoded pixel paddings on sidebar structural elements (#2728).
     These use fixed px values so they are not reached by --space-* overrides above. */
  .board-sidebar-phase-header {
    padding-top: 3px;
    padding-bottom: 3px;
  }
  .board-phase-indicator-pill {
    font-size: 9px;
    line-height: 13px;
  }
  .board-sidebar-scroll,
  .board-sidebar-phase-host {
    padding-top: 4px;
    padding-bottom: 4px;
  }
}

/* Pending moves summary header row (queued count + Review button) */
.board-moves-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
}

/* Filler shown in place of a single-owner phase's interactive body when
   someone else (often an AI seat) is the active player, not this browser
   (#3732). A human sentence / empty state, so --font-body per rule 9. */
.phase-panel-waiting {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-ivory);
  padding: var(--space-sm);
}

/* Phase warning buttons row */
.board-warning-btn-row {
  display: flex;
  gap: 6px;
}

/* Purchase summary / NCM summary modal header */
.board-modal-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-secondary);
  text-align: center;
}

/* Purchase summary / NCM summary modal footer (action buttons) */
.board-modal-footer {
  padding: var(--space-sm) var(--space-lg) var(--space-md);
  border-top: 1px solid var(--border-primary);
  display: flex;
  gap: var(--space-sm);
}
/* Two equal choices (#5557): the purchase summary gave Go Back two thirds of
 * the row, so End Purchase wrapped in what was left. */
.board-modal-footer--equal > button {
  flex: 1 1 0;
  min-width: 0;
  padding: var(--space-sm) var(--space-xs);
  font-size: var(--text-sm);
  text-wrap: balance;
}
.board-modal-footer--equal > .btn-end-phase {
  letter-spacing: 0.14em;
}
/* Purchase summary with nothing bought: say so rather than an empty body. */
.board-purchase-empty {
  margin: 0;
  padding: var(--space-md) var(--space-lg);
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-ivory-muted);
}

/* Purchase summary unit list */
.board-purchase-list {
  padding: var(--space-md) 18px;
}

/* Purchase summary unit row */
.board-purchase-unit-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
  font-size: var(--text-sm);
  color: var(--color-parchment);
}

/* NCM summary move list container */
.board-ncm-list {
  padding: var(--space-md) 18px;
  max-height: 50vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

@media (orientation: landscape) and (max-height: 500px) {
  .board-ncm-list {
    max-height: 30vh;
  }
}

/* NCM summary destination row header */
.board-ncm-dest-header {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

/* NCM summary unit entry row */
.board-ncm-unit-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: var(--space-lg);
  margin-bottom: 2px;
  font-size: var(--text-sm);
  color: var(--color-parchment);
}

/* NCM summary air units section */
.board-ncm-air-section {
  padding: var(--space-sm) 18px;
  border-top: 1px solid var(--border-primary);
}

/* NCM summary individual air unit row */
.board-ncm-air-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
  font-size: var(--text-sm);
}

/* === CombatBoard === */

/* Root combat board overlay (fixed full-screen grid).
 * Rows: tribunal header / rank grid (1fr) / nation row (atk · action · def).
 * The transient battle footer floats above the nation-row as an absolute
 * overlay (.combat-floating-footer) so it never reserves vertical space —
 * critical on iPhone landscape where the footer is empty most of the time
 * (active player has roll/decision UI in the nation row's action cell;
 * inactive player only sees an ambient "Awaiting decision…" badge). */
.combat-root {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 8, 5, 0.92);
  z-index: var(--z-battle);
  display: grid;
  grid-template-rows: auto 1fr;
  font-family: var(--font-body);
}

/* Retreat picker (#4193). Portaled over the battle board; the map fills the
 * scaffold and Cancel is a real button, not the 8px ghost. */
.retreat-target-screen {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--overlay-battle-screen);
  font-family: var(--font-body);
  animation: fadeIn 0.2s ease-out;
}
.retreat-target-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  /* The screen is position:absolute; inset:0, so the scaffold's safe-area
   * padding does not inset this header. Keep the notch clearances here. */
  padding-top: calc(var(--space-sm) + var(--safe-t));
  padding-bottom: var(--space-sm);
  padding-left: calc(var(--space-lg) + var(--safe-l));
  padding-right: calc(var(--space-lg) + var(--safe-r));
  border-bottom: 1px solid var(--border-primary);
  background: var(--bg-secondary);
}
.retreat-target-title {
  min-width: 0;
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--accent-red-bright);
  font-family: var(--font-heading);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.retreat-target-map {
  position: relative;
  overflow: hidden;
  min-height: 0;
}
.retreat-target-header .btn.retreat-target-cancel {
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-base);
}

/* #3707 — applyCasualties side flash + short hit-shake. Gated off under
 * prefers-reduced-motion (JS also skips the class at instant / reduced-motion). */
@keyframes battle-side-flash {
  0%, 100% { background-color: transparent; }
  40% { background-color: var(--overlay-casualty-20); }
}
@keyframes battle-hit-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(calc(var(--space-xs) * -1)); }
  75% { transform: translateX(var(--space-xs)); }
}
.sbr-root--flash-attacker .sbr-side-panel--attacker {
  animation: battle-side-flash 0.25s ease-out;
}
.sbr-root--flash-defender .sbr-side-panel--defender {
  animation: battle-side-flash 0.25s ease-out;
}
.sbr-root--hit-shake .sbr-content {
  animation: battle-hit-shake 0.25s ease-in-out;
}
@media (prefers-reduced-motion: reduce) {
  .sbr-root--flash-attacker .sbr-side-panel--attacker,
  .sbr-root--flash-defender .sbr-side-panel--defender,
  .sbr-root--hit-shake .sbr-content,
  .phone-battle__row--refused {
    animation: none;
  }
}

.battle-casualty-row--selectable {
  cursor: pointer;
  transition: background var(--transition-fast);
  border-radius: var(--radius-xs);
}
.battle-casualty-row--selectable:hover,
.battle-casualty-row--selectable:focus-visible {
  background: var(--overlay-casualty-12);
  outline: none;
}
.battle-casualty-row--selectable:focus-visible {
  box-shadow: inset 0 0 0 1px var(--overlay-casualty-35);
}
/* #3782 — tapping an unselected row with no hit budget left must never be a
 * silent no-op. Reuses the #3707 battle-hit-shake keyframe on the row itself,
 * plus a box-shadow ring that is NOT part of the `animation` shorthand — the
 * reduced-motion override below nulls the shake but must leave this alone, or
 * reduced-motion users get the #3782 silent no-op all over again. */
.phone-battle__row--refused {
  animation: battle-hit-shake 0.25s ease-in-out;
  box-shadow: inset 0 0 0 2px var(--accent-red-bright);
}
.dispatch-card-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  animation: dispatch-overlay-in 0.4s ease-out both;
}
.dispatch-card-overlay:has(.dispatch-card--raid) {
  animation-duration: 0.28s;
}
.dispatch-card-overlay.is-leaving {
  animation: dispatch-overlay-out 0.42s ease-in forwards;
  pointer-events: none;
}
.dispatch-card-overlay.is-leaving:has(.dispatch-card--raid) {
  animation-duration: 0.28s;
}
/* Beat `.combat-root > * { position: relative; z-index: 2 }` — otherwise
 * the slip becomes a grid row behind the glass board and never covers it. */
.combat-root > .dispatch-card-overlay,
.sbr-root > .dispatch-card-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
}
.dispatch-card-overlay .dispatch-card {
  min-height: 0;
}
.dispatch-card-overlay.is-leaving .dispatch-card--land {
  animation: dispatch-land-out 0.42s ease-in forwards;
}
.dispatch-card-overlay.is-leaving .dispatch-card--sea {
  animation: dispatch-sea-out 0.42s ease-in forwards;
}
.dispatch-card-overlay.is-leaving .dispatch-card--raid {
  animation: dispatch-raid-out 0.28s ease-in forwards;
}
.dispatch-card-overlay.is-leaving .dispatch-card__art--bleed {
  animation-play-state: paused;
}

/* Main columns wrapper (fills center grid row) */
.combat-columns-outer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

/* Three-column flex row */
.combat-columns-inner {
  display: flex;
  flex-direction: row;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  max-height: 100%;
}

/* Left portion of the header (title + round badge) */
.combat-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  min-width: 0;
}

/* Right portion of the header (simulate + close buttons) */
.combat-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Floating footer overlay — renders only when there's transient content
 * (round-0 Start Battle, post-AA Continue, SBR buttons, "Awaiting decision…").
 *
 * Rendered as a child of .combat-aa42-nation-row (which is position:
 * relative). Anchored with `bottom: 100%` so its bottom edge sits exactly
 * at the nation-row's top edge — automatic lockstep regardless of how
 * tall either box grows. Earlier attempts (matching `bottom: 3.5rem` to
 * the row's `min-height`, or using `grid-row: 2; align-self: end` in
 * .combat-root) failed: the first matched only the minimum and broke
 * when the row grew; the second collided with .combat-root's auto-flow
 * and pushed the rank grid + nation-row into trailing implicit rows
 * (huge empty space in the middle). */
.combat-floating-footer {
  position: absolute;
  bottom: calc(100% + 0.25rem);  /* sits just above the nation-row's top edge */
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;

  max-width: min(92%, 640px);
  white-space: nowrap;

  background: rgba(20, 16, 12, 0.78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 0.3rem 1rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);

  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 768px) {
  .combat-floating-footer {
    bottom: calc(100% + 0.15rem);
    padding: 0.2rem 0.6rem;
    max-width: 96vw;
    border-radius: var(--radius-sm);
  }
}

/* Footer action buttons row */
.combat-footer-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  align-items: center;
}

/* Dice power-level label ("@3:") above dice group */
.combat-dice-power-label {
  color: var(--text-muted);
  font-size: max(var(--text-xs), var(--text-battle-floor));
  margin-bottom: var(--space-xs);
}

/* Dice group row (wrap of Die components) */
.combat-dice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

/* Individual die + count pair */
.combat-die-pair {
  display: flex;
  align-items: center;
  gap: 3px;
}

/* Phase banner — full-width with gradient and strong border */
.combat-phase-banner {
  width: 100%;
}

/* Dramatic hit counter reveal */
.combat-hit-reveal {
  animation: hitRevealPulse 0.4s ease-out;
}

@keyframes hitRevealPulse {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* Large roll button */
.combat-roll-btn-large {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.combat-roll-btn-large:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 0 20px var(--overlay-gold-15);
}

/* Collapsed center column — vertically centered content */
.combat-center-collapsed {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
}

/* Rotated step label inside collapsed center column */
.combat-center-step-label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.6875rem;
  color: var(--text-muted);
  font-family: var(--font-heading);
  letter-spacing: 1px;
  white-space: nowrap;
}

/* Rotated hit counts inside collapsed center column */
.combat-center-hit-counts {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: var(--text-battle-floor);
  white-space: nowrap;
}

/* "Awaiting decision..." italic hint in floating footer. Sized to feel
 * like a status badge (slim, ambient) rather than a primary header — the
 * old clamp peaked at 19px italic which dominated the overlay. */
.combat-awaiting-hint {
  font-size: clamp(0.8125rem, 0.74rem + 0.18vw, 0.95rem);
  color: var(--text-secondary);
  font-style: italic;
  letter-spacing: 0.02em;
}

/* === CombatBoard tablet (≤ 1024px) === */
@media (max-width: 1024px) {
  .combat-dice-row {
    gap: 5px;
  }
  .combat-die-pair {
    gap: 2px;
  }
  .combat-dice-power-label {
    font-size: var(--text-battle-floor);
    margin-bottom: 2px;
  }
}

/* === CombatBoard mobile (phones ≤ 768px) === */
@media (max-width: 768px) {
  /* Tighter dice spacing on phones */
  .combat-dice-row {
    gap: 3px;
  }
  .combat-die-pair {
    gap: 1px;
  }

  /* Larger touch targets for +/- casualty steppers (44px minimum) */
  .btn-stepper {
    width: 40px !important;
    height: 40px !important;
    font-size: 1.25rem !important;
    border-radius: var(--radius-md) !important;
  }

  /* Phase banners: tighter on phones */
  .combat-phase-banner {
    padding: 6px 8px !important;
  }
  .combat-phase-banner > div:first-child {
    font-size: 0.875rem !important;
    letter-spacing: 1px !important;
  }

  /* Footer buttons: stack on phones if multiple appear (rare; one button
   * is the common case). Slim badge-sized padding matches the floating
   * overlay context — buttons are not stretched to the overlay edges. */
  .combat-footer-actions {
    flex-direction: column;
    gap: var(--space-xs);
  }

  /* Roll button: smaller on phones */
  .combat-roll-btn-large {
    font-size: 0.875rem !important;
    padding: 10px 20px !important;
  }
}

/* Observer mode — non-acting player sees a slim inline status line */
.combat-observer-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  font-size: max(var(--text-sm), var(--text-battle-floor));
  color: var(--text-muted);
  font-style: italic;
  min-height: 1.75rem;
}

.combat-observer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-blue);
  flex: 0 0 auto;
  animation: combat-observer-pulse-anim 1.6s ease-in-out infinite;
}

.combat-observer-text {
  line-height: 1.4;
}

/* Who the game is waiting on, and for how long (#4961). A human sentence,
   so body type and muted ivory — not a second gold object on the battle. */
.waiting-on {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-style: normal;
  font-variant-numeric: tabular-nums;
  color: var(--text-ivory-muted);
  line-height: 1.4;
}

@keyframes combat-observer-pulse-anim {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* Active-player left-border accent */
.combat-active-badge {
  border-left: 3px solid var(--accent-green);
  padding-left: var(--space-sm);
}

/* === LobbyPage === */

/* Full-screen fixed overlay (shared base for all lobby views) */
.lobby-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Splash screen root — full screen, pointer, flex row */
.lobby-splash-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  cursor: pointer;
  user-select: none;
}

/* Dark base layer behind split panels */
.lobby-bg-dark {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg-darkest);
}

/* Poster image layer (used inside left and right split panels) */
.lobby-poster-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center top;
  animation: lobby-subtlePan 25s ease-in-out infinite;
  transform-origin: center center;
}

/* Reverse pan direction for allies side */
.lobby-poster-image--reverse {
  animation-direction: reverse;
}

/* Dark gradient overlay on Axis (left) panel */
.lobby-panel-overlay-axis {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0,0,0,0.3), rgba(0,0,0,0.7));
}

/* Dark gradient overlay on Allies (right) panel */
.lobby-panel-overlay-allies {
  position: absolute;
  inset: 0;
  background: linear-gradient(to left, rgba(0,0,0,0.3), rgba(0,0,0,0.7));
}

/* Red tint overlay for Axis panel */
.lobby-panel-tint-axis {
  position: absolute;
  inset: 0;
  background: rgba(80,0,0,0.15);
}

/* Blue tint overlay for Allies panel */
.lobby-panel-tint-allies {
  position: absolute;
  inset: 0;
  background: rgba(0,0,60,0.15);
}

/* Full-screen vignette (radial darkening toward edges) */
.lobby-vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.6) 70%, rgba(0,0,0,0.9) 100%);
  pointer-events: none;
}

/* Centered content overlay on splash screen */
.lobby-splash-center {
  position: fixed;
  z-index: 10;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  padding: 0 20px;
}

/* Main title on splash. margin-bottom absorbs the breathing room the
   subtitle used to provide before it was removed (#3730), so the gap to
   the decorative line below stays composed rather than collapsing. */
.lobby-title-main {
  font-family: var(--font-heading);
  font-size: clamp(40px, 9vw, 84px);
  font-weight: 900;
  color: var(--accent-gold);
  text-shadow: 0 0 50px rgba(196,165,74,0.4), 0 4px 16px rgba(0,0,0,0.9);
  margin: 0 0 40px 0;
  letter-spacing: 8px;
  line-height: 1;
  animation: lobby-titleFade 1.5s ease-out 0.1s both;
}

/* Decorative gold horizontal rule on splash */
.lobby-decorative-line {
  width: 100px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--accent-gold), transparent);
  margin: 0 auto 30px;
  animation: lobby-titleFade 1.2s ease-out 0.7s both;
}

/* CTA text ("Command Your Forces") */
.lobby-cta {
  font-family: var(--font-heading);
  font-size: clamp(11px, 1.8vw, 15px);
  color: var(--accent-gold);
  letter-spacing: 3px;
  text-transform: uppercase;
  animation: lobby-ctaFade 2.5s ease-out both, lobby-ctaPulse 3s ease-in-out 2.5s infinite;
  text-shadow: 0 0 20px rgba(196,165,74,0.3);
}

/* Main menu content wrapper with slide-up animation */
.lobby-menu-card {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: lobby-menuSlideUp 0.8s ease-out both;
  width: 100%;
  max-width: 420px;
  padding: 0 20px;
}
@media (max-height: 500px) and (orientation: landscape) {
  .lobby-menu-card {
    max-width: 640px;
    padding: 0 12px;
  }
}

/* Frosted-glass backdrop behind main menu content */
.lobby-backdrop-card {
  position: absolute;
  inset: -30px -40px;
  background: rgba(10,10,8,0.75);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(196,165,74,0.15);
  z-index: -1;
}
/* iOS Safari: disable backdrop-filter (freezes main thread on M1 iPad) */
@supports (-webkit-touch-callout: none) {
  .lobby-backdrop-card { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* Frosted-glass backdrop for create/waiting panels (tighter inset) */
.lobby-backdrop-card--sm {
  position: absolute;
  inset: -20px -30px;
  background: var(--bg-raised);
  border-radius: 0;
  backdrop-filter: none;
  border: 1px solid var(--border-brass);
  z-index: -1;
}
@supports (-webkit-touch-callout: none) {
  .lobby-backdrop-card--sm { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* Main menu title */
.lobby-menu-title {
  font-family: var(--font-heading);
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 900;
  color: var(--accent-gold);
  text-shadow: 0 0 20px rgba(196,165,74,0.2);
  margin: 0 0 var(--space-xs) 0;
  letter-spacing: 5px;
}

/* Settings gear button */
.lobby-settings-btn {
  background: rgba(26,26,20,0.6);
  border: 1px solid rgba(196,165,74,0.3);
  color: var(--accent-gold);
  border-radius: 6px;
  padding: var(--space-sm) 20px;
  font-size: var(--text-base);
  cursor: pointer;
  font-family: var(--font-heading);
  letter-spacing: 2px;
}

/* Sign-out anchor link */
.lobby-signout-link {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-family: var(--font-heading);
  letter-spacing: 1px;
  text-decoration: none;
}

/* Footer tagline ("N powers / 361 territories...") */
.lobby-footer-tagline {
  margin-top: var(--space-lg);
  font-size: var(--text-sm);
  color: var(--lobby-tagline-color);
}

/* Options/Create/Waiting view wrapper (with slide-up animation) */
.lobby-view-wrapper {
  position: relative;
  z-index: 10;
  animation: lobby-menuSlideUp 0.5s ease-out both;
  padding: 20px;
}

/* Section heading inside create/waiting views */
.lobby-section-heading {
  color: var(--text-ivory);
  margin-bottom: var(--space-xs);
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
}

/* Match ID display row */

/* #4392: waiting-room join code, link and Open / Invite-only switch */
.lobby-invite-link {
  color: var(--accent-blue);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}
.lobby-invite-hint {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

/* #4393: invite server members from the waiting room by Discord DM */
.lobby-discord-invite {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  width: 350px;
  max-width: 90vw;
}
.lobby-discord-invite-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-height: 14rem;
  overflow-y: auto;
}
.lobby-discord-invite-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border-secondary);
}
.lobby-discord-invite-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-size: var(--text-base);
}

/* Match ID label */

/* Match ID code block */



/* Inline error message */
.lobby-error-msg {
  color: var(--accent-red-bright);
  font-size: var(--text-sm);
}

/* Error message with spacing and centering (used in create/waiting views) */
.lobby-error-msg--spaced {
  color: var(--accent-red-bright);
  font-size: var(--text-sm);
  margin-bottom: var(--space-sm);
  text-align: center;
}

/* Row for primary action buttons (Back / Claim) */
.lobby-action-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* Waiting room player list container */

/* "All players joined!" success message */

/* Center-aligned button container */

/* "Online Multiplayer" section label */
.lobby-multiplayer-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  font-family: var(--font-heading);
  letter-spacing: 2px;
}

/* Gold rule section divider in menu */
.lobby-divider {
  border-top: 1px solid rgba(196,165,74,0.2);
  margin: var(--space-xs) 0;
}

/* Portrait/desktop vertical menu column */
.lobby-menu-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
}

/* Landscape vertical menu column (tighter gaps) */
.lobby-menu-col--landscape {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: 100%;
}

/* Landscape 2-column hotseat + online grid */
.lobby-landscape-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: start;
}

/* Right column in landscape grid (online multiplayer controls) */
.lobby-online-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* "Online Multiplayer" label in landscape layout */
.lobby-online-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-heading);
  letter-spacing: 2px;
}

/* Match-ID input + Join button row (portrait) */
.lobby-join-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* Match-ID input + Join button row (landscape, tighter) */
.lobby-join-row--landscape {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Footer row (settings button + sign-out link) */
.lobby-footer-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: 30px;
}
@media (max-height: 500px) and (orientation: landscape) {
  .lobby-footer-row {
    margin-top: 8px;
  }
}

/* Lobby form input */
.lobby-input {
  background: var(--lobby-input-bg);
  color: var(--text-primary);
  border: 1px solid var(--lobby-input-border);
  border-radius: 4px;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-base);
  width: 100%;
  box-sizing: border-box;
}
.lobby-input[readonly] {
  opacity: 0.7;
  cursor: default;
}

/* Lobby subtitle ("Global 1940") */
.lobby-menu-subtitle {
  font-family: var(--font-heading);
  font-size: clamp(11px, 1.8vw, 14px);
  color: var(--color-lobby-subtitle);
  letter-spacing: 3px;
  margin-bottom: 32px;
}
@media (max-height: 500px) and (orientation: landscape) {
  .lobby-menu-subtitle {
    margin-bottom: 8px;
  }
}

/* Resume match button (green variant of btn-lobby) */
.btn-lobby--resume {
  background: var(--gradient-lobby-resume);
  border: 2px solid var(--accent-green);
  font-size: var(--text-lg);
  padding: 18px 24px;
  width: 100%;
  text-align: center;
}
@media (max-height: 500px) and (orientation: landscape) {
  .btn-lobby--resume {
    font-size: var(--text-sm);
    padding: 8px 16px;
  }
}

/* Muted/back button variant of btn-lobby */
.btn-lobby--muted {
  background: var(--bg-raised);
  color: var(--text-ivory);
  border: 1px solid var(--border-brass);
  padding: 8px 16px;
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  letter-spacing: 0.1em;
}

/* Quiet row action (copy, sit, kick). 44px, not gold (#5080). */
.btn-lobby.btn-lobby--quiet {
  background: transparent;
  color: var(--text-ivory);
  border: 1px solid var(--border-brass);
  box-shadow: none;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: var(--space-xs) var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: none;
  border-radius: 0;
}
.btn-lobby.btn-lobby--quiet:hover:not(:disabled) {
  filter: none;
  border-color: var(--accent-brass);
  color: var(--text-ivory);
}

/* Nation roundel. Sizes match the lobby mockup frames (#5080). */
.nation-roundel {
  display: inline-block;
  flex: none;
  vertical-align: var(--roundel-nudge);
}
.nation-roundel--s { width: var(--roundel-s); height: var(--roundel-s); }
.nation-roundel--m { width: var(--roundel-m); height: var(--roundel-m); }
.nation-roundel--l { width: var(--roundel-l); height: var(--roundel-l); }
.nation-roundel--xl { width: var(--roundel-xl); height: var(--roundel-xl); }
.nation-roundel--board {
  object-fit: contain;
  border-radius: 50%;
}
.nation-roundel__disc {
  stroke: var(--overlay-dark-40);
  stroke-width: 1.5;
}

/* Six phase pips. The name is the board's phase label. */
.phase-pips {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}
.phase-pips__label {
  font-family: var(--font-ui);
  font-style: normal;
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
}
.phase-pips__marks {
  display: inline-flex;
  align-items: center;
  gap: var(--pip-gap);
}
.phase-pips__pip {
  width: var(--pip-size);
  height: var(--pip-size);
  border-radius: 50%;
  background: var(--overlay-gold-20);
}
.phase-pips__pip--on {
  background: var(--accent-brass);
  box-shadow: 0 0 var(--pip-glow) var(--accent-brass);
}

/* Duration phrase. Amber is the 25% warning. */
.lobby-duration {
  font-family: var(--font-mono);
  color: var(--text-ivory);
}
.lobby-duration--amber {
  color: var(--accent-amber);
}

/* Bottom sheet below 900px; side sheet, or an anchored popover, at 900px+. */
.lobby-sheet__panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(80dvh, 100%);
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--accent-brass);
  border-bottom: none;
  box-shadow: var(--shadow-lg);
  padding: var(--space-md) var(--space-lg);
  padding-bottom: calc(var(--space-md) + var(--safe-b));
  color: var(--text-ivory);
  font-family: var(--font-ui);
}
/* A bottom sheet on a wide short screen (a phone on its side) is capped like
   the settings sheet, and centred (#5153). Its last row keeps clear of the
   bottom edge and the home indicator (#5155). */
.lobby-sheet__panel[data-placement="bottom"] {
  max-width: var(--lobby-sheet-max);
  margin: 0 auto;
  padding-bottom: calc(var(--space-lg) + var(--safe-b));
}
.lobby-sheet__body > .lobby-sheet__item:last-child {
  border-bottom: none;
}
.lobby-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
/* #5132: every LobbySheet close is a 44px target on every pointer. In-game
   overlay closes stay at the coarse-pointer rule; only this header grows. */
.lobby-sheet__header .btn-close-overlay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
}
/* #5174: settings sheets and the other lobby dialogs use PanelHeader, so the
   LobbySheet rule above missed their close. In-game overlay closes stay padding-only. */
[data-testid^="setting-sheet-"] .btn-close-overlay,
[data-testid="lobby-delete-dialog"] .btn-close-overlay,
[data-testid="lobby-resign-dialog"] .btn-close-overlay,
[data-testid="pregame-codes"] .btn-close-overlay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
}
.lobby-sheet__title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-ivory);
}
.lobby-sheet__body {
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.lobby-sheet__item {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  width: 100%;
  padding: var(--space-xs) 0;
  border: none;
  border-bottom: 1px solid var(--border-brass);
  background: transparent;
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.lobby-sheet__item:hover {
  color: var(--accent-brass);
}
@media (min-width: 900px) {
  .lobby-sheet__panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(24rem, 40vw);
    max-height: none;
    border-bottom: 1px solid var(--accent-brass);
  }
}
/* The anchored popover (the ⋯ menu): at 900px and wider, and on a tablet in
   portrait below it (#5155). LobbySheet sets top and left beside the trigger. */
.lobby-sheet__panel--anchored {
  top: var(--space-xl);
  right: var(--space-lg);
  bottom: auto;
  left: auto;
  width: min(20rem, 40vw);
  max-height: min(70dvh, 100%);
  height: auto;
  border-bottom: 1px solid var(--accent-brass);
  padding-bottom: var(--space-md);
}

/* ?lobbykit specimen page. Not a product screen. */
.lobby-kit-preview {
  min-height: 100vh;
  box-sizing: border-box;
  background: var(--bg-ink);
  color: var(--text-ivory);
  font-family: var(--font-ui);
  padding: var(--space-lg);
}
.lobby-kit-preview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.lobby-kit-preview__title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-ivory);
}
.lobby-kit-preview__kicker {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.lobby-kit-preview__block {
  margin-bottom: var(--space-lg);
}
.lobby-kit-preview__roundels {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}
.lobby-kit-preview__roundel {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}
.lobby-kit-preview__phases,
.lobby-kit-preview__buttons,
.lobby-kit-preview__line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
}
.lobby-kit-preview__line {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
}
.lobby-kit-preview__gap {
  display: inline-block;
  width: var(--space-sm);
}

/* Sub-line inside a btn-lobby (e.g. "All players on one device") */
.btn-lobby__sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
  font-weight: 400;
}

/* Sub-line in success color (e.g. match details under Resume) */
.btn-lobby__sub--success {
  font-size: var(--text-sm);
  color: var(--color-success);
  margin-top: var(--space-xs);
  font-weight: 400;
}

/* === #4425 pregame room: teams, codes, auction, seat assignment === */
.pregame-room {
  color: var(--text-ivory);
  font-family: var(--font-ui);
}
.pregame-muted {
  color: var(--text-ivory-muted);
  font-size: var(--text-sm);
}
.room-code,
.pregame-code__value {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  letter-spacing: 0.12em;
  color: var(--text-ivory);
}
.pregame-chips {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}
.pregame-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
  background: var(--bg-rail);
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}
button.pregame-chip {
  cursor: pointer;
}
button.pregame-chip[aria-pressed="true"] {
  background: var(--overlay-gold-30);
  border-color: var(--accent-gold);
}
/* #5178: the auction, flat — the Bid pane with two panes, an AUCTION section under the seats with one. */
.room-auction {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-xs) 0;
}
.auction-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}
.auction-body__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-md);
  color: var(--text-ivory-muted);
}
.auction-body__step {
  font-size: var(--text-base);
  color: var(--text-ivory);
}
.auction-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-sm);
}
.auction-controls__note { flex-basis: 100%; }
.room-auction .btn-lobby,
.settings-summary__controls .btn-lobby { min-height: var(--tap-min); }
/* Content-width 44px segments, as in the settings rows. */
.room-auction .options-segment-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  flex: 0 0 auto;
  padding: 0 var(--space-sm);
}
.room-auction .options-segment-group { flex-wrap: wrap; }
.auction-amount .stepper-pill-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
}
.auction-amount__input {
  width: 4ch;
  min-width: var(--tap-min);
  box-sizing: border-box;
  height: var(--tap-min);
  padding: 0 var(--space-xs);
  border: none;
  background: var(--surface-input);
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  text-align: center;
}
.pregame-clock {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
}
.pregame-clock[data-urgent] { color: var(--accent-red-bright); }
.room-auction__history {
  margin-bottom: var(--space-sm);
  font-family: var(--font-ui);
  color: var(--text-ivory);
}
.pregame-ready,
.pregame-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.pregame-starting {
  padding: var(--space-lg);
  text-align: center;
  font-size: var(--text-lg);
}
.pregame-codes {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md);
  overflow-y: auto;
}
.pregame-code {
  display: grid;
  grid-template-columns: 8em auto 1fr;
  align-items: center;
  gap: var(--space-xs) var(--space-sm);
}
.pregame-code__label {
  color: var(--text-ivory-muted);
  font-size: var(--text-sm);
}
.pregame-code__actions {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}
.pregame-code__hint {
  grid-column: 1 / -1;
  color: var(--text-ivory-muted);
  font-size: var(--text-sm);
}
.pregame-size-group {
  flex-wrap: wrap;
}
/* Moving a chip is the assign screen's main tap (#4425 review). */
@media (max-width: 640px) {
  button.pregame-chip {
    min-height: var(--tap-min);
  }
  .pregame-code {
    grid-template-columns: 1fr;
  }
  .pregame-code__actions .btn-lobby--quiet {
    flex: 1;
  }
}

/* === #5086 tasks inside the lobby shell: the room, the create screens === */
.lobby-task {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.lobby-task-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-lg) calc(var(--space-lg) + var(--safe-r)) var(--space-lg) calc(var(--space-lg) + var(--safe-l));
}
/* Rail (900px+): the header sits at the top of the content and stays there. */
.lobby-task-slot:empty { display: none; }
.lobby-task-slot {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-rail);
  border-bottom: 1px solid var(--border-brass);
}
.lobby-task-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  min-height: var(--tap-min);
}
.lobby-task-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  min-height: var(--tap-min);
  padding: 0 var(--space-sm) 0 0;
  border: none;
  background: none;
  color: var(--text-ivory-muted);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
}
.lobby-task-back:hover { color: var(--text-ivory); }
.lobby-task-title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-ivory);
}
.lobby-task-meta {
  color: var(--text-ivory-muted);
  font-size: var(--text-sm);
}
.lobby-task-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-left: auto;
}
.room-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0 var(--space-md);
  border: 1px solid var(--border-brass);
  background: transparent;
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  cursor: pointer;
}
/* Phone: the task header replaces the app-bar title (one row, scrolls sideways if it must). */
.lobby-appbar-task:empty { display: none; }
.lobby-appbar-task {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.lobby-appbar-task .lobby-task-header {
  flex-wrap: nowrap;
  padding: 0;
  gap: var(--space-sm);
}
.lobby-appbar-task .lobby-task-title {
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lobby-appbar-task .lobby-task-meta {
  display: none;
}
.lobby-appbar-task .lobby-task-actions { flex-wrap: nowrap; }
/* The room's Copy link, Team codes and the Discord picker: in the app bar from 700px wide
   (data-bar="wide"), else in the share row at the top of the room body (#5130 B2, #5161). */
.room-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}
/* Phone portrait: the code, who can join, Copy link and Team codes in one 44px row at the top of the room (#5130 B2, redesign slice 1). */
.room-share {
  min-height: var(--tap-min);
  flex-wrap: nowrap;
  border-bottom: 1px solid var(--border-brass-grid);
}
.room-share .room-code { min-height: var(--tap-min); padding: 0 var(--space-sm); font-size: var(--text-sm); }
.room-share__who { flex: 1 1 auto; min-width: 0; color: var(--text-ivory-muted); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* The room's Ready tag (the seat strip's side eyebrow). */
.pregame-ready-tag {
  color: var(--accent-green);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  letter-spacing: normal;
}
.lobby-shell--rail .room-settings {
  max-width: 1080px;
}

/* ── Footer: seat count, Close / Leave, Ready (one right-aligned commit, not a bar) ── */
.room-footer {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  margin-top: auto;
  padding: var(--space-sm) calc(var(--space-lg) + var(--safe-r)) var(--space-sm) calc(var(--space-lg) + var(--safe-l));
  background: var(--bg-rail);
  border-top: 1px solid var(--border-brass);
}
.room-footer__seats {
  color: var(--text-ivory-muted);
  font-size: var(--text-sm);
}
.room-footer .pregame-actions {
  margin-left: auto;
  justify-content: flex-end;
}
.room-commit {
  min-width: 200px;
  min-height: var(--tap-min);
}
/* #5132: Close, Leave, Keep, and Ready are 44px on every pointer. */
.room-footer .btn-lobby {
  min-height: var(--tap-min);
}

/* No rail (phone, tablet in portrait): a team's cards two-up under its name; Ready stays above the tab bar. Keyed on the shell, not a width (#5161). */
.lobby-shell--phone .lobby-task-body { padding: var(--space-md) calc(var(--space-md) + var(--safe-r)) var(--space-md) calc(var(--space-md) + var(--safe-l)); }
.lobby-shell--phone .room-footer { padding: var(--space-sm) calc(var(--space-md) + var(--safe-r)) var(--space-sm) calc(var(--space-md) + var(--safe-l)); }
.lobby-shell--phone .room-footer .pregame-ready > .pregame-muted { display: none; }
.lobby-shell--phone .room-commit { min-width: 9rem; }
/* Short landscape, any width (900x402 has no rail): the footer stays one row. */
@media (orientation: landscape) and (max-height: 500px) {
  .room-footer .pregame-ready > .pregame-muted { display: none; }
}

/* Phone create screens and room (#5147): one surface level, one gutter, compact seats. Keyed on the shell (#5161). */
/* P-1: the options card is the task body itself on a phone, so content sits at the
   body's gutter (the room's, and the Games list's) instead of 29px in. */
.lobby-shell--phone .lobby-task-body > .options-card,
.lobby-shell--phone .lobby-task-body > .options-card.options-card--settings {
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}
.lobby-shell--phone .lobby-task-body > .options-card .options-body { padding: 0; }
/* B-2: below 600px a seat card is a full row so the four kind segments share one 44px row. */
/* P-4: a narrow bar has no room for the code; the share row in the body carries it. */
.lobby-shell[data-bar="narrow"] .lobby-appbar-task .room-code { display: none; }

/* ── Seats (redesign slice 3, #5163): a strip on short landscape and the rail, rows elsewhere; one sheet per seat ── */
.seat-stack { display: inline-flex; align-items: center; flex-shrink: 0; }
.seat-stack .nation-roundel { box-shadow: 0 0 0 var(--roundel-stack-ring) var(--bg-rail); border-radius: 50%; }
.seat-stack .nation-roundel + .nation-roundel { margin-left: var(--roundel-stack-overlap); }
.seat-stack__more { margin-left: var(--space-2xs); font-size: var(--text-xs); color: var(--text-ivory-muted); }

.seat-strip { flex-shrink: 0; background: var(--bg-rail); border-bottom: 1px solid var(--border-brass); }
.seat-strip__in { display: flex; align-items: center; gap: var(--space-xs); height: var(--seat-strip-h); padding: 0 calc(var(--space-md) + var(--safe-r)) 0 calc(var(--space-md) + var(--safe-l)); }
.seat-strip__side { display: flex; align-items: center; gap: var(--space-xs); flex: var(--seat-count, 1) 1 0; min-width: 0; }
.seat-strip__eyebrow, .seat-rows__eyebrow { flex-shrink: 0; font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-ivory-muted); }
[data-side="Axis"] .seat-strip__eyebrow, [data-side="Axis"] .seat-rows__eyebrow { color: var(--alliance-axis-text); }
[data-side="Allies"] .seat-strip__eyebrow, [data-side="Allies"] .seat-rows__eyebrow { color: var(--alliance-allies); }
.seat-strip__vs { align-self: stretch; display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0 var(--space-xs); font-size: var(--text-xs); letter-spacing: 0.1em; color: var(--text-ivory-muted); border-left: 1px solid var(--border-brass); border-right: 1px solid var(--border-brass); }
.seat-btn { flex: 1 1 0; min-width: var(--tap-min); height: var(--tap-min); display: flex; align-items: center; gap: var(--space-xs); padding: 0 var(--space-xs); border: 1px solid transparent; background: none; color: var(--text-ivory); font-family: var(--font-ui); text-align: left; cursor: pointer; transition: border-color var(--transition-fast), background var(--transition-fast); }
.seat-btn:hover, .seat-btn.is-you { border-color: var(--border-brass); background: var(--bg-raised); }
.seat-btn.suppress-focus-ring:focus-visible,
.seat-row.suppress-focus-ring:focus-visible { outline: none; }
.seat-btn[data-target="true"] { border-style: dashed; border-color: var(--accent-brass); }
.seat-btn__who { flex: 1 1 auto; min-width: 0; font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-btn__who b { font-weight: 500; }
.seat-btn__who small, .seat-row__text small { color: var(--text-ivory-muted); font-size: inherit; }
.seat-btn__ready, .seat-row__ready { width: var(--space-sm); height: var(--space-sm); border-radius: 50%; background: var(--accent-green); flex-shrink: 0; }
.seat-btn__caret, .seat-row__caret { color: var(--accent-brass); font-size: var(--text-xs); flex-shrink: 0; }

.seat-rows { display: flex; flex-direction: column; }
.seat-group { display: flex; flex-direction: column; min-width: 0; }
.seat-rows__head { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-xs) 0 0; line-height: 1.6; }
.seat-row { display: flex; align-items: center; gap: var(--space-sm); width: 100%; min-height: var(--lobby-row-h); padding: 0 0 0 var(--space-xs); border: 0; border-bottom: 1px solid var(--border-brass-grid); background: none; color: var(--text-ivory); font-family: var(--font-ui); font-size: var(--text-base); text-align: left; cursor: pointer; }
.seat-row:hover { background: var(--bg-raised); }
.seat-row[data-target="true"] { outline: 1px dashed var(--accent-brass); outline-offset: -1px; }
.seat-row__text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.seat-row__line { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-row__text b { font-weight: 500; }
.seat-row__text small { font-size: var(--text-sm); }
.seat-row__hint { white-space: normal; color: var(--text-ivory-muted); line-height: 1.3; }
.seat-row__pill { display: inline-flex; align-items: center; gap: var(--space-xs); min-height: calc(var(--tap-min) - var(--space-md)); padding: 0 var(--space-sm); border: 1px solid var(--border-brass); font-size: var(--text-sm); color: var(--text-ivory-muted); white-space: nowrap; }
.seat-row.is-you .seat-row__pill { color: var(--text-ivory); background: var(--bg-raised); border-color: var(--accent-brass); }
.lobby-shell[data-panes="two"] .seat-rows { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--space-lg); border-bottom: 1px solid var(--border-brass); padding-bottom: var(--space-xs); }

/* One pane: the share row, the seat rows and the settings list stack flush (spec #5160 §5.2: a 2v2 room fits 360x740). */
.lobby-shell[data-panes="one"] .lobby-task-body.room-body { padding-top: 0; gap: 0; }

/* Two panes: the strip is fixed at the top of the body; the list and the pane take the rest and scroll on their own.
   data-panes sits on .lobby-shell itself, which also carries --task while a room is open. */
.lobby-shell--task[data-panes="two"] .lobby-task-body.room-body { padding: 0 calc(var(--space-md) + var(--safe-r)) 0 calc(var(--space-md) + var(--safe-l)); gap: 0; overflow: hidden; }
/* The body keeps its side gutter (the notch, #5161); the strip bleeds to the edges and its own padding lines its seats up with the list. */
.lobby-shell--task[data-panes="two"] .room-body > .seat-strip { margin: 0 calc(-1 * (var(--space-md) + var(--safe-r))) 0 calc(-1 * (var(--space-md) + var(--safe-l))); }
.lobby-shell--task[data-panes="two"] .room-body > .room-settings { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
/* #5178: one grid row bounded by the body, so a tall pane (the auction) scrolls on its own. */
.lobby-shell--task[data-panes="two"] .room-settings > .settings-summary { flex: 1 1 auto; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; }

/* The seat sheet */
.seat-sheet { display: flex; flex-direction: column; gap: var(--space-sm); }
.seat-sheet__identity { display: flex; align-items: center; gap: var(--space-sm); min-height: var(--tap-min); }
.seat-sheet__side { font-size: var(--text-xs); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-ivory-muted); }
.seat-sheet__status { color: var(--text-ivory-muted); font-size: var(--text-sm); }
.seat-sheet__kind .options-segment-group { flex-wrap: wrap; }
.seat-sheet__kind .options-segment-btn { flex: 0 0 auto; min-width: var(--tap-min); min-height: var(--tap-min); padding: 0 var(--space-md); }
.seat-sheet__confirm { display: flex; flex-direction: column; gap: var(--space-xs); margin-top: var(--space-xs); font-size: var(--text-sm); }
.seat-sheet__actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.seat-sheet__nations { display: flex; flex-direction: column; gap: var(--space-xs); }
.seat-sheet__prompt { font-size: var(--text-sm); color: var(--text-ivory-muted); }
.seat-sheet button.pregame-chip { min-height: var(--tap-min); }
.seat-sheet .btn-lobby { min-height: var(--tap-min); }
.room-footer__cancel-move { margin-left: var(--space-sm); }
.lobby-player-claim[data-claimed="false"] {
  color: var(--text-muted);
}

/* Join count line in waiting room */

/* Screen variant with scroll (options/create views) */
.lobby-screen--scroll {
  overflow: auto;
}

/* On compact height, don't center vertically — let content start at top so it's scrollable */
@media (max-height: 600px) {
  .lobby-screen--scroll {
    justify-content: flex-start;
    padding-top: 16px;
    padding-bottom: 16px;
  }
}

/* === GameOptionsPanel === */

.options-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  backdrop-filter: none;
  padding: 0;
  min-width: 380px;
  max-width: 760px;
  width: min(calc(100vw - 40px), 760px);
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
/* iOS Safari: disable backdrop-filter on .options-card (freezes main thread on M1 iPad) */
@supports (-webkit-touch-callout: none) {
  .options-card { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (max-width: 520px) {
  .options-card {
    min-width: auto;
    max-width: 500px;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .options-card {
    min-width: auto;
    width: min(calc(100vw - 32px), 760px);
    max-width: 760px;
  }
}

/* Number input in the options card (tournament turn limit). The class name
   predates #4298, which removed the game name field it was made for. */
.options-game-name-input {
  background: var(--bg-ink);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  padding: 12px 16px;
  font-size: var(--text-lg);
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-weight: 400;
  letter-spacing: 0;
  outline: none;
  transition: border-color var(--transition-fast);
}
.options-game-name-input:focus {
  border-color: var(--accent-brass);
  box-shadow: none;
}
.options-game-name-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

/* The lobby size of the one switch (ui/Switch variant="lobby", #5562; was the
   separate .toggle-btn family). Every rule names the modifier, so it cannot
   reach the in-game switch (#5553). */
.toggle-switch--lobby {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--surface-input);
  transition: background 0.2s, border-color 0.2s;
  margin-top: 2px;
}
.toggle-switch--lobby.toggle-switch--on {
  border-color: var(--accent-brass);
  background: var(--toggle-track-on);
}
.toggle-switch--lobby .toggle-knob {
  width: 16px;
  height: 16px;
  background: var(--color-miss);
  top: 2px;
  left: 2px;
  transition: left 0.2s, background 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
.toggle-switch--lobby.toggle-switch--on .toggle-knob {
  background: var(--toggle-knob-on);
  left: 20px;
}

.options-resume-btn {
  background: var(--bg-raised);
  color: var(--text-ivory);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  padding: 14px var(--space-xl);
  font-size: var(--text-lg);
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  width: 100%;
  margin: 16px 24px 0;
  width: calc(100% - 48px);
}
@media (max-height: 500px) and (orientation: landscape) {
  .options-resume-btn {
    padding: var(--space-sm) var(--space-lg);
    font-size: var(--text-base);
  }
}

.options-load-btn {
  background: var(--bg-ink);
  color: var(--text-ivory);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-sm);
  cursor: pointer;
  font-family: var(--font-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  width: calc(100% - 48px);
  margin: 0 24px;
  transition: border-color var(--transition-fast);
}
.options-load-btn:hover {
  border-color: var(--accent-brass);
}
@media (max-height: 500px) and (orientation: landscape) {
  .options-load-btn {
    padding: 6px var(--space-md);
  }
}

.options-back-btn {
  background: var(--bg-raised);
  color: var(--text-ivory);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  padding: var(--space-sm) var(--space-xl);
  font-size: var(--text-sm);
  cursor: pointer;
  font-family: var(--font-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: border-color var(--transition-fast);
}
.options-back-btn:hover {
  border-color: var(--accent-brass);
}
@media (max-height: 500px) and (orientation: landscape) {
  .options-back-btn {
    padding: 6px var(--space-md);
  }
}

.options-separator {
  border-top: 1px solid var(--border-brass);
  margin: 12px 24px;
}

.options-body {
  padding: var(--space-md) var(--space-lg);
}
@media (max-height: 500px) and (orientation: landscape) {
  .options-body {
    padding: var(--space-sm);
  }
}
/* The lobby's rail layout (epic #5077): iPad landscape and desktop share the
   settings list + detail pane, so the card grows to hold both columns. */
.lobby-shell--rail .options-card--settings {
  width: min(calc(100vw - 40px), 1080px);
  max-width: 1080px;
}

/* Inside the shell the rail already took its width, so the card fills the task body (#5087);
   100vw would run it under the viewport edge. */
.lobby-task-body > .options-card,
.lobby-task-body > .options-card.options-card--settings {
  width: 100%;
  min-width: 0;
  max-width: 1080px;
  align-self: center;
}

/* The names sheet of a hotseat side: a roundel, the nation and a 44px name field per row (#5164). */
.seat-sheet__name-row { display: flex; align-items: center; gap: var(--space-sm); min-height: var(--tap-min); border-bottom: 1px solid var(--border-brass-grid); }
.seat-sheet__name-row:last-of-type { border-bottom: none; }
.seat-sheet__name-row .seat-sheet__nation { flex: 0 0 8em; font-size: var(--text-sm); color: var(--text-ivory-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-sheet__name { flex: 1 1 auto; min-width: 0; min-height: var(--tap-min); padding: 0 var(--space-sm); background: var(--bg-ink); border: 1px solid var(--border-brass); border-radius: 0; color: var(--text-ivory); font-family: var(--font-ui); font-size: var(--text-sm); }
.seat-sheet__name::placeholder { color: var(--text-ivory-muted); }
/* A locked or read-only setting: the current value, why it cannot change, then the explanation (#5164). */
.settings-summary__readonly { display: flex; flex-direction: column; gap: var(--space-xs); margin-bottom: var(--space-sm); }
.settings-summary__readonly-value { min-height: var(--tap-min); display: flex; align-items: center; color: var(--text-ivory); font-size: var(--text-base); }
.settings-summary__locked { color: var(--text-ivory-muted); font-size: var(--text-sm); }
/* Two panes: the create card hugs its rows (no flex-grow, so a tall screen does not
   leave an empty pane) and can still shrink, so a short screen scrolls the pane
   instead of the task body (#5177). */
.lobby-shell--task[data-panes="two"] .lobby-task-body > .options-card { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; }
.lobby-shell--task[data-panes="two"] .options-card > .options-body { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; padding: 0; }
.lobby-shell--task[data-panes="two"] .options-body > .settings-summary { flex: 0 1 auto; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
.lobby-shell--task[data-panes="two"] .options-card .settings-summary__pane { min-height: 0; }
.lobby-shell--task[data-panes="two"] .options-body > [data-testid="local-seats"] { flex: 0 0 auto; }

/* Gold once per screen (#5106, #5132): inside the settings summary an "on" switch is ivory
   (the track shows the state) and a sheet's title is the UI face, so the footer's btn-lobby
   commit (Begin on a create screen, Ready in a room) is the one gold object and the wordmark
   the one Cinzel. A one-pane row opens a sheet portalled to <body>, outside .settings-summary,
   so the sheet is named too (#5193: House rules showed two gold knobs at 390x844). */
.settings-summary .toggle-switch--on .toggle-knob,
.settings-summary__sheet .toggle-switch--on .toggle-knob { background: var(--text-ivory); }
[data-testid^="setting-sheet-"] .panel-header-dialog-title { font-family: var(--font-ui); }

:root { --lobby-row-h: var(--tap-min); }
/* Short landscape: 40px rows are the one approved exception to the 44px rule (settings rows and seat rows only; buttons stay 44). */
@media (orientation: landscape) and (max-height: 500px) { :root { --lobby-row-h: 40px; } }

/* === Settings summary (#5085) — list + detail pane, or list + sheet === */

.settings-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}
.settings-summary--wide {
  display: grid;
  grid-template-columns: minmax(0, 45fr) minmax(0, 55fr);
  align-items: start;
  min-height: 0;
}
.settings-summary--wide .settings-summary__list { min-height: 0; overflow-y: auto; border-right: 1px solid var(--border-brass); }
.settings-summary--wide .settings-summary__pane { min-height: 0; overflow-y: auto; border: none; background: transparent; padding: var(--space-sm) var(--space-md); }
/* #5563: the wide pane clips the last line. Fade that edge only while more sits below it. */
.settings-summary--wide .settings-summary__pane.is-more-below {
  -webkit-mask-image: linear-gradient(to top, transparent, var(--bg-ink) var(--space-xl));
  mask-image: linear-gradient(to top, transparent, var(--bg-ink) var(--space-xl));
}
/* Short landscape: the pane gets the wider share so seven 44px Players segments stay on one row at 667. */
@media (orientation: landscape) and (max-height: 500px) {
  .settings-summary--wide { grid-template-columns: minmax(0, 40fr) minmax(0, 60fr); }
  .settings-summary--wide .settings-summary__pane { padding: var(--space-sm); }
}
.settings-summary__heading {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
  padding: 0 0 var(--space-sm) var(--space-sm);
}
.settings-summary__rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.settings-summary__row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  min-height: var(--lobby-row-h);
  padding: 0 var(--space-xs) 0 var(--space-sm);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-brass-grid);
  border-left: 2px solid transparent;
  color: var(--text-ivory);
  font-family: var(--font-ui);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.settings-summary__row:hover,
.settings-summary__row:focus-visible {
  background: var(--bg-ink);
}
/* #5175: a keyboard ring, drawn inside the row so the pane's edge does not clip it. */
.settings-summary__row:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: -2px;
}
.settings-summary__row.is-current {
  background: var(--bg-raised);
  border-left-color: var(--accent-brass);
}
.settings-summary__label {
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-ivory);
}
.settings-summary__value {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--text-ivory);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.settings-summary__dot { color: var(--accent-brass); flex-shrink: 0; }
.settings-summary__chevron {
  color: var(--accent-brass);
  font-size: var(--text-base);
  padding-right: var(--space-xs);
}
.settings-summary__pane {
  border: 1px solid var(--border-brass);
  background: var(--bg-ink);
  padding: var(--space-lg);
  min-height: 100%;
}
.settings-summary__pane-title {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.settings-summary__desc {
  max-width: 46ch;
  margin-top: var(--space-sm);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--text-ivory-muted);
}
.settings-summary__controls {
  min-width: 0;
  margin-top: 0;
  border-top: none;
}
.settings-summary__sheet {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg) var(--space-lg);
}
.settings-summary__done {
  min-height: var(--tap-min);
  width: 100%;
}

.setting-field {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-brass);
}
.setting-field:last-child {
  border-bottom: none;
}
.setting-field__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
}
.setting-field__head--toggle {
  cursor: pointer;
  min-height: var(--tap-min);
  align-items: center;
}
.setting-field__text {
  flex: 1;
  min-width: 0;
}
.setting-field__title {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-ivory);
}
.setting-field__title--inactive {
  color: var(--text-ivory-muted);
}
/* #5563: a field title under a pane eyebrow uses that eyebrow, not title case. */
.setting-field__title--eyebrow {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.setting-field__desc {
  margin-top: var(--space-xs);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--text-ivory-muted);
}
.setting-field__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}
.setting-field__body:first-child {
  margin-top: 0;
}
.setting-field__body .options-segment-group {
  flex-wrap: wrap;
}
.setting-field--sub {
  margin-left: var(--space-sm);
  padding-left: var(--space-md);
  border-left: 1px solid var(--border-brass);
  border-bottom: 1px solid var(--border-brass);
}
.setting-field--sub .setting-field {
  border-bottom: none;
}
/* #5132: settings segments are 44px on every pointer, not only a coarse one.
 * Below 900px the rows open a sheet portalled to <body>, outside
 * .settings-summary, so the sheet is named too (#5145 B-4). */
/* Content-width segments in the lobby settings; the in-game segment keeps its stretch. */
.settings-summary .options-segment-btn,
.settings-summary__sheet .options-segment-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  flex: 0 0 auto;
  padding: 0 var(--space-sm);
}
.settings-summary .options-segment-group,
.settings-summary__sheet .options-segment-group { flex-wrap: wrap; }
/* The switch stays its drawn size; a coarse pointer gets a larger hit area (epic #5077). */
@media (pointer: coarse) {
  .settings-summary .toggle-switch::after,
  .settings-summary__sheet .toggle-switch::after {
    content: '';
    position: absolute;
    inset: -11px -2px;
  }
}

.options-segment-group {
  display: flex;
  gap: var(--space-xs);
}

.options-segment-btn {
  flex: 1;
  padding: 5px 0;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-ivory-muted);
  background: var(--bg-ink);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  cursor: pointer;
  font-family: var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: capitalize;
  text-align: center;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.options-segment-btn:hover {
  border-color: var(--accent-brass);
  color: var(--text-ivory);
}
.options-segment-btn--active {
  font-weight: 500;
  color: var(--text-ivory);
  background: var(--bg-raised);
  border-color: var(--accent-brass);
}

/* #5562: every Settings group is ui/SegmentedControl. On desktop each segment is
   its label's width on one line (the lobby settings rows do the same), so
   "3D (beta)" and "My rolls" no longer wrap into tall boxes and Full/Fast/Off
   keep side padding. Below 900px the group fills the row, as before. */
.settings-body .settings-row { column-gap: var(--space-sm); flex-wrap: wrap; }
.settings-body .options-segment-group { flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.settings-body .options-segment-btn {
  flex: 0 0 auto;
  padding-inline: var(--space-xs);
  white-space: nowrap;
}
@media (max-width: 899px) {
  .settings-body .options-segment-group { justify-content: stretch; }
  .settings-body .options-segment-btn { flex: 1 1 0; }
}

/* ui/Select: the app's dropdown (#5562), square and brass like the segments. */
.ui-select {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  min-height: 28px;
  padding: 0 calc(var(--space-sm) + 14px) 0 var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  color: var(--text-ivory);
  background-color: var(--bg-ink);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-ivory-muted) 50%),
    linear-gradient(135deg, var(--text-ivory-muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  border: 1px solid var(--border-brass);
  border-radius: 0;
  cursor: pointer;
}
.ui-select:hover { border-color: var(--accent-brass); }
.ui-select:focus-visible { outline: 2px solid var(--accent-brass); outline-offset: 1px; }
.ui-select:disabled { opacity: 0.5; cursor: default; }

/* ui/RemoveButton: the one "remove this row" ✕ (#5562). Quiet until hovered. */
.btn-remove-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 22px;
  min-height: 22px;
  padding: 0 var(--space-2xs);
  font-size: var(--text-sm);
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.btn-remove-row:hover:not(:disabled) {
  color: var(--accent-red-bright);
  border-color: var(--border-primary);
}
.btn-remove-row:disabled { opacity: 0.4; cursor: default; }
@media (pointer: coarse) {
  .btn-remove-row::after { content: ''; position: absolute; inset: -11px; }
}
/* === TerritoryBottomPanel === */

/* Compact strip inner flex row */
.territory-strip-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  user-select: none;
  min-height: 44px;
}

/* Flag image in compact strip (24px) */
.territory-flag-img {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}

/* Flag image in expanded header (36px) */
.territory-flag-img--lg {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}

/* Territory name in compact strip */
.territory-name-compact {
  font-weight: bold;
  font-size: var(--text-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Phase info span in compact strip */
.territory-strip-info {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  flex: 1;
}

/* Compact strip primary action — ivory + brass, not gold fill (#3562) */
.territory-strip-action-btn {
  padding: var(--space-xs) 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--bg-raised);
  color: var(--text-ivory);
  border: 1px solid var(--accent-brass);
  border-radius: 0;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: var(--font-ui);
}

.dual-econ-pill {
  padding-block: 1px;
  padding-inline: var(--space-xs);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text-ivory-muted);
  border: 1px solid transparent;
  font-family: var(--font-ui);
}
.dual-econ-pill.is-on {
  color: var(--text-ivory);
  border-color: var(--accent-brass);
}

/* Chevron / close buttons inside compact strip */
.territory-strip-icon-btn {
  padding: var(--space-xs) 6px;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  line-height: 1;
  flex-shrink: 0;
}

/* Left section of expanded header (flag + name block) */
.territory-header-left {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}

/* Name + IPC + markers row inside expanded header */
.territory-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.territory-vc-mark {
  color: var(--accent-brass);
  font-weight: 700;
}
.territory-name {
  font-weight: 700;
  color: var(--text-ivory);
  font-size: var(--text-lg);
}
.territory-ipc {
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  font-weight: 600;
}
.territory-unit-count {
  color: var(--text-ivory);
  font-weight: 700;
}

/* Owner/metadata row under territory name */
.territory-meta-row {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 1px;
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* Units center section (combat + installations + AV/DV) */
.territory-units-center {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Individual unit group block */
.territory-unit-group {
  flex: 0 1 auto;
  padding: var(--space-xs) var(--space-sm);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
}

/* Unit group section label */
.territory-unit-group-label {
  font-size: var(--text-xs);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(196, 164, 74, 0.2);
}

/* Unit group items row */
.territory-unit-row {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  align-items: center;
}

/* Single unit entry (icon + count + name) */
.territory-unit-entry {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-base);
  color: var(--tooltip-text);
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.territory-unit-entry:hover {
  background: rgba(196, 164, 74, 0.08);
}

/* Responsive garrison — tablet */
@media (min-width: 481px) and (max-width: 1024px) {
  .territory-unit-entry {
    gap: 5px;
    padding: 4px 8px;
    font-size: var(--text-lg);
  }
}
/* Responsive garrison — mobile */
@media (max-width: 480px) {
  .territory-unit-entry {
    gap: 6px;
    padding: 6px 8px;
    font-size: var(--text-lg);
  }
  .territory-unit-group-label {
    font-size: var(--text-sm);
    margin-bottom: 8px;
  }
}

/* Fog of war intel block */
.territory-fog-block {
  flex: 0 0 auto;
}

/* "Last seen Turn N" label */
.territory-fog-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 3px;
}

/* Fog unit summary row */
.territory-fog-units {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* Single fog unit entry (faded) */
.territory-fog-unit-entry {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  opacity: 0.8;
}

/* AV/DV summary block */
.territory-avdv {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Right controls section (collapse + close buttons) */
.territory-panel-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Relationship badge (Own/Allied/Enemy) */
.territory-rel-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 2px;
}
.territory-rel-own {
  background: rgba(90, 158, 111, 0.15);
  color: var(--color-valid);
  border: 1px solid rgba(90, 158, 111, 0.25);
}
.territory-rel-allied {
  background: rgba(91, 138, 191, 0.15);
  color: var(--color-info);
  border: 1px solid rgba(91, 138, 191, 0.25);
}
.territory-rel-enemy {
  background: rgba(196, 71, 58, 0.12);
  color: var(--color-hit);
  border: 1px solid rgba(196, 71, 58, 0.2);
}

/* Incoming units badge */
.territory-incoming-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(201, 168, 76, 0.15);
  border: 1px solid rgba(201, 168, 76, 0.25);
  border-radius: 3px;
  padding: 3px 8px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--accent-gold, #d4a843);
  white-space: nowrap;
  position: relative;
}
.territory-incoming-badge::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.15);
  animation: incomingPulse 2s ease-in-out infinite;
}
.territory-incoming-arrow {
  animation: incomingSlide 1.2s ease-in-out infinite;
}
@keyframes incomingPulse {
  0%, 100% { opacity: 0; }
  50%      { opacity: 1; }
}
@keyframes incomingSlide {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(3px); }
}

/* Full-width section divider for phase-actions area */
.territory-section-divider {
  width: 100%;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: var(--space-sm);
}

/* Full-width section divider for notes area (tighter padding) */
.territory-notes-divider {
  width: 100%;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 6px;
}

/* Notes section toggle header row */
.territory-notes-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  user-select: none;
}

/* Individual note item row */
.territory-note-item {
  padding: var(--space-xs) var(--space-sm);
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Note add/edit form container */
.territory-note-form {
  padding: 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-primary);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Note form select element */
.territory-note-select {
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: var(--text-sm);
}

/* Note form text input */
.territory-note-text-input {
  flex: 1;
  min-width: 120px;
  background: var(--btn-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: var(--text-sm);
  font-family: inherit;
}

/* Phase section heading (e.g. "Declare War", "Plan Attack") */
.territory-phase-heading {
  font-size: var(--text-xs);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(196, 164, 74, 0.25);
}

/* Phase description text */
.territory-phase-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* #4720 — Anniversary China 3-unit cap: why this homeland cannot take placements.
   Human sentence (Instrument HUD rule 9): body face, not gold. */
.territory-placement-refusal {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  margin: 0;
  padding: var(--space-xs) 0;
  max-width: 100%;
}
.territory-strip-info.territory-placement-refusal {
  white-space: normal;
  padding: 0;
}

/* #4105 "Lands on …" lines under a queued attack's attackers (LandsOnLines) */
.lands-on-lines {
  margin-top: var(--space-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.lands-on-line {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}
.lands-on-planes {
  color: var(--text-muted);
}

/* #4105 "Carrier will move here" rows (CarrierDeclareSection) */
.carrier-declare-section {
  margin-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.carrier-declare-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
.carrier-declare-label {
  flex: 1 1 auto;
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.carrier-declare-status {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}
/* #4120: Undo on the drag-to-declare toast. */
.carrier-declared-undo {
  margin-left: var(--space-sm);
}
.carrier-declare-hint {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* Inline unit tag (icon + name, e.g. cargo items) */
.territory-unit-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* Transport management card */
.territory-transport-card {
  margin-bottom: 6px;
  padding: var(--space-xs) 6px;
  background: rgba(80,144,208,0.08);
  border-radius: 3px;
  border: 1px solid rgba(80,144,208,0.2);
}

/* Transport card header (icon + name + capacity) */
.territory-transport-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}

/* Transport cargo grid */
.territory-transport-cargo {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: var(--space-xs);
}

/* Unit selector sub-section in sea zones */
.territory-unit-selector-sub {
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 6px;
}

/* SBR / recon eligible aircraft list */
.territory-bomber-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Battle combatant sides wrapper */
.territory-battle-sides {
  display: flex;
  gap: var(--space-xl);
  flex-wrap: wrap;
}

/* Unit type list inside a combatant side */
.territory-combatant-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Single combatant type entry (icon + count) */
.territory-combatant-entry {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Placement stepper row */
.territory-placement-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 4px var(--space-xs);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}
.territory-placement-row:hover {
  background: rgba(196, 164, 74, 0.08);
}
.territory-placement-row--active {
  background: rgba(196, 164, 74, 0.15);
}

/* Responsive placement row — tablet */
@media (min-width: 481px) and (max-width: 1024px) {
  .territory-placement-row {
    gap: var(--space-md);
    padding: 6px var(--space-sm);
    min-height: 40px;
  }
}
/* Responsive placement row — mobile */
@media (max-width: 480px) {
  .territory-placement-row {
    gap: var(--space-md);
    padding: 8px var(--space-sm);
    min-height: 48px;
  }
}

/* Note count badge button in compact strip */
.territory-notes-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  font-size: var(--text-xs);
  font-weight: bold;
  background: rgba(192,160,64,0.15);
  color: var(--accent-gold-bright);
  border: 1px solid rgba(192,160,64,0.3);
  border-radius: 3px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Unload / load-adjacent button row */
.territory-transport-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

/* Load-from-adjacent section */
.territory-load-section {
  margin-top: var(--space-xs);
}

/* "N units assigned to this raid" note */
.territory-sbr-assigned {
  margin-bottom: 6px;
}

/* SBR undo button row */
.territory-sbr-undo-row {
  display: flex;
  gap: var(--space-xs);
  margin-top: 6px;
}

/* Attack planner button row */
.territory-attack-btn-row {
  display: flex;
  gap: 6px;
}

/* Win-bar percentage annotation */
.territory-winbar-pct {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* Win-bar wrapper with bottom margin */
.territory-winbar-block {
  margin-bottom: var(--space-sm);
}

/* Recon aircraft list */
.territory-recon-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* Adjacent territory load label */
.territory-load-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 3px;
}

/* ===== SBR Battle Board ===== */

/* Three-column section layout (air / aa / bombing) */
.sbr-section-layout {
  display: flex;
  gap: var(--space-lg);
}
@media (max-width: 768px) {
  .sbr-section-layout { flex-direction: column; }
}

/* Side panels (attacker / defender columns) */
.sbr-side-panel {
  flex: 1;
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: var(--space-md);
}
@media (max-width: 768px) {
  .sbr-side-panel { flex: none; }
}

/* Center column (actions / dice / decisions) */
.sbr-center-col {
  flex: 2;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
@media (max-width: 768px) {
  .sbr-center-col { flex: none; order: -1; }
}

/* Section header (uppercase label above unit lists) */
.sbr-section-header {
  font-size: var(--text-sm);
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: var(--space-sm);
}

/* Mobile summary header (collapsible) */
.sbr-mobile-summary {
  font-size: var(--text-sm);
  font-weight: bold;
  text-transform: uppercase;
  cursor: pointer;
  margin-bottom: var(--space-xs);
}

/* Unit row: icon + name inline */
.sbr-unit-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

/* Unit display name text */
.sbr-unit-name {
  font-size: var(--text-base);
  color: var(--text-primary);
}

/* Dice results panel */
.sbr-dice-panel {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-primary);
  border-radius: 6px;
  padding: var(--space-lg);
}

/* Dice results title */
.sbr-dice-title {
  font-size: var(--text-base);
  font-weight: bold;
  color: var(--accent-gold);
  margin-bottom: 10px;
  text-align: center;
}

/* ---- SBR board chrome (root / header / content / footer) ---------------- */
/* Full-screen SBR overlay. Mirrors overlayBackdropStyle (overlay-styles.ts)
 * with SBR-specific background + column flow; z-index resolves natively here. */
.sbr-root {
  position: fixed;
  inset: 0;
  background: var(--overlay-sbr-dark);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overscroll-behavior: contain;
  font-family: var(--font-body);
}

.sbr-content {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  padding: var(--space-md) var(--space-xl);
  gap: var(--space-lg);
}
@media (max-width: 768px) {
  .sbr-content { padding: 10px 12px; }
}

/* Header */
.sbr-header {
  background: linear-gradient(180deg, var(--gradient-battle-header-top) 0%, var(--gradient-battle-header-bot) 100%);
  border-bottom: 2px solid var(--border-accent);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
@media (max-width: 768px) {
  .sbr-header { padding: 8px 12px; }
}
.sbr-header-side { flex: 1; }
.sbr-header-side--def { text-align: right; }
.sbr-header-center { flex: 2; text-align: center; }
@media (max-width: 768px) {
  .sbr-header-center { flex: 1; }
}
.sbr-header-nation {
  font-size: var(--text-lg);
  font-weight: bold;
  font-family: var(--font-heading);
}
.sbr-header-role {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.sbr-header-title {
  font-size: var(--text-xl);
  font-weight: bold;
  color: var(--accent-gold);
  font-family: var(--font-heading);
}
.sbr-header-section-label {
  font-size: var(--text-base);
  font-weight: bold;
  font-family: var(--font-heading);
  margin-top: 2px;
}
.sbr-header-tabs {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}
/* Section pill — active background/color set inline (computed per section). */
.sbr-section-tab {
  font-size: var(--text-sm);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-lg);
}
.sbr-header-close {
  flex-shrink: 0;
  margin-left: var(--space-sm);
}

/* Footer */
.sbr-footer {
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border-top: 2px solid var(--border-accent);
  padding: 10px 24px;
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  align-items: center;
}
@media (max-width: 768px) {
  .sbr-footer { padding: 8px 12px; }
}
.sbr-footer-waiting {
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: italic;
}

/* ---- SBR section bodies (air / aa / bombing) ---------------------------- */
.sbr-center-col--centered {
  align-items: center;
  justify-content: center;
}
.sbr-blurb {
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--text-base);
}
/* Interceptor + casualty decision panels */
.sbr-decision-panel {
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  background: var(--bg-primary);
}
/* Casualty panel rides on .card (keeps its bg/padding); only the border tints red. */
.sbr-decision-panel--casualty {
  border: 1px solid var(--accent-red);
}
.sbr-panel-title {
  font-size: var(--text-lg);
  font-weight: bold;
  color: var(--accent-blue);
  margin-bottom: var(--space-sm);
}
.sbr-panel-title--casualty {
  font-size: var(--text-base);
  color: var(--accent-red-bright);
}
.sbr-panel-hint {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}
.sbr-interceptor-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-xs);
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
}
/* selected highlight set inline (computed from selection state) */
.sbr-interceptor-from {
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.sbr-panel-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}
.sbr-casualty-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: 6px;
}
.sbr-casualty-name {
  font-size: var(--text-base);
  color: var(--text-primary);
  flex: 1;
}
.sbr-side-block { margin-bottom: 6px; }
.sbr-side-sublabel {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: 3px;
}
.sbr-side-empty {
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.sbr-side-empty--italic { font-style: italic; }
.sbr-side-details-body { margin-top: 6px; }

/* Dice / results rows */
.sbr-dice-panel--full { width: 100%; }
.sbr-dice-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}
.sbr-dice-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-wrap: wrap;
}
.sbr-dice-unit {
  font-size: var(--text-xs);
  color: var(--text-muted);
  min-width: 60px;
}
.sbr-dice-tag {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.sbr-dice-bonus {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}
.sbr-dice-total {
  font-size: var(--text-base);
  font-weight: bold;
  color: var(--accent-gold);
}
.sbr-damage-summary {
  border-top: 1px solid var(--border-primary);
  padding-top: var(--space-sm);
  text-align: center;
}
.sbr-damage-value {
  font-size: var(--text-2xl);
  font-weight: bold;
  color: var(--accent-red-bright);
  line-height: 1;
}
.sbr-damage-label {
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-left: var(--space-sm);
}
.sbr-target-note {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}
.sbr-target-note--after {
  color: var(--color-hit);
}
.sbr-no-dice {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
}
.sbr-blurb--padded { padding: var(--space-xl); }
.sbr-interceptor-check { accent-color: var(--accent-blue); }
.sbr-panel-btn {
  padding: var(--space-xs) var(--space-lg);
  font-size: var(--text-base);
}
.sbr-panel-btn--primary { background: var(--btn-bg); }
.sbr-dice-panel--center { text-align: center; }
.sbr-resolve-line {
  font-size: var(--text-base);
  color: var(--text-secondary);
}
.sbr-resolve-line--gold {
  color: var(--accent-gold);
  margin-top: 6px;
}
.sbr-confirm-btn {
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-lg);
  font-size: var(--text-base);
  color: var(--text-primary);
}

/* Invalid-move reason banner */
.territory-invalid-move {
  background: var(--overlay-danger-18);
  border: 1px solid var(--overlay-danger-35);
  border-radius: var(--radius-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-danger-soft);
  flex: 0 0 auto;
}

/* ===================================================================
   UNIFIED GAME LOBBY
   =================================================================== */

.unified-lobby,
.lobby-screen--table {
  position: relative;
  isolation: isolate;
  background:
    repeating-linear-gradient(90deg, transparent 0 79px, var(--border-brass-grid) 79px 80px),
    repeating-linear-gradient(0deg, transparent 0 79px, var(--border-brass-grid) 79px 80px),
    radial-gradient(ellipse at 50% 120%, rgba(184, 154, 58, 0.07), transparent 55%),
    var(--bg-ink);
  color: var(--text-ivory);
  font-family: var(--font-ui);
  min-height: 100vh;
  min-height: 100dvh;
}
.unified-lobby {
  overflow: hidden;
}
.lobby-screen--scroll.lobby-screen--table {
  overflow: auto;
}

/* Splash-poster ghost (#3562 B) — bottom-weighted stain, not a wallpaper. */
.unified-lobby-ghost {
  position: absolute;
  inset: auto 0 0 0;
  height: 68%;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to top, #000 18%, transparent 100%);
  mask-image: linear-gradient(to top, #000 18%, transparent 100%);
}
.unified-lobby-ghost-axis,
.unified-lobby-ghost-allies {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background-size: cover;
  background-position: center 20%;
  opacity: 0.28;
}
.unified-lobby-ghost-axis {
  left: 0;
  background-image: url('/axis-poster.jpg');
}
.unified-lobby-ghost-allies {
  right: 0;
  background-image: url('/allies-poster.jpg');
}
.unified-lobby-ghost-wash {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    var(--bg-ink) 0%,
    color-mix(in srgb, var(--bg-ink) 78%, transparent) 55%,
    color-mix(in srgb, var(--bg-ink) 62%, transparent) 100%
  );
}
/* Sign out and Join Discord (#4276) are the same quiet text control as Report a bug. */
.unified-topbar-rules,
.unified-topbar-report,
.unified-topbar-signout,
.unified-topbar-discord {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  color: var(--text-ivory-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.unified-topbar-rules:hover,
.unified-topbar-report:hover,
.unified-topbar-signout:hover,
.unified-topbar-discord:hover {
  color: var(--text-ivory);
}

/* #4439: a ranked queue is live — pulses on the Ranked tab. */
.ranked-queue-strip__dot,
.lobby-shell-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-gold);
  vertical-align: middle;
  animation: ranked-queue-pulse 1.4s ease-in-out infinite;
}
/* #5131: a room or create screen is open under Play. Ivory and still: gold stays the screen's one primary. */
.lobby-shell-dot--task { background: var(--text-ivory); animation: none; }
@keyframes ranked-queue-pulse {
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  .ranked-queue-strip__dot,
  .lobby-shell-dot { animation: none; }
}
/* #4439: the queue status under the nav, on every tab. */
.ranked-queue-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) calc(var(--space-md) + var(--safe-r)) var(--space-xs) calc(var(--space-md) + var(--safe-l));
  border-bottom: 1px solid var(--accent-brass);
  background: var(--overlay-gold-08);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory);
  position: relative;
}
.ranked-queue-strip__text {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}
.ranked-queue-strip__cancel {
  flex-shrink: 0;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 0;
  border: 1px solid var(--border-brass);
  background: transparent;
  color: var(--text-ivory);
  cursor: pointer;
  min-height: var(--tap-min);
}
.ranked-queue-strip__cancel:hover:not(:disabled) { border-color: var(--accent-brass); }
.ranked-queue-strip__cancel:disabled { opacity: 0.4; cursor: default; }
.unified-topbar-name-input {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  padding: 5px 10px;
  border-radius: 0;
  border: 1px solid var(--border-brass);
  background: var(--bg-raised);
  color: var(--text-ivory);
  width: 130px;
}
.unified-topbar-name-input::placeholder { font-family: var(--font-ui); color: var(--text-ivory-muted); }
/* A 44px target, drawn as a quiet glyph: a 44px bordered box outweighs the bar. */
.unified-topbar-name-input--error {
  border-color: #b83028 !important;
  box-shadow: 0 0 6px rgba(184,48,40,0.4);
  animation: unified-shake 0.3s ease-in-out;
}
@keyframes unified-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.unified-error-banner {
  background: rgba(184,48,40,0.15);
  border-bottom: 1px solid rgba(184,48,40,0.3);
  color: #e84040;
  font-size: 0.8125rem;
  padding: 8px calc(24px + var(--safe-r)) 8px calc(24px + var(--safe-l));
  text-align: center;
}

/* Session resume banner — appears when a validated session is found on load */
.unified-resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  padding: var(--space-sm) var(--space-md);
  /* In the lobby column's flow: full column width, same gap below as the
     new-game row it sits above (#4291). */
  margin-bottom: var(--space-xl);
  font-size: var(--text-sm);
}

.unified-resume-banner--checking {
  color: var(--text-ivory-muted);
  font-style: italic;
  font-family: var(--font-body);
  justify-content: center;
  border-color: var(--border-brass);
  background: transparent;
}

.unified-resume-banner__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.unified-resume-banner__label {
  color: var(--text-ivory);
  font-weight: 500;
  font-size: var(--text-xs);
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.unified-resume-banner__nations {
  color: var(--text-ivory-muted);
  font-size: var(--text-xs);
}

.unified-resume-banner__btn {
  background: linear-gradient(180deg, var(--accent-gold) 0%, var(--accent-brass) 100%);
  color: var(--color-on-gold);
  border: 1px solid var(--accent-gold);
  border-radius: 0;
  padding: var(--space-xs) var(--space-md);
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: var(--text-sm);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.unified-resume-banner__btn:hover {
  filter: brightness(1.08);
}

/* ── Page Layout ── */
/* Side gutters clear the island side in phone landscape (#4462); the insets are
 * 0 in portrait and on desktop, so those layouts are unchanged. */
.unified-page {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-xl) calc(var(--space-lg) + var(--safe-r)) var(--space-xl) calc(var(--space-lg) + var(--safe-l));
}
.unified-page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.unified-page-title,
.ranked-entry__title {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-ivory-muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

/* ── Filter Tabs ── */
.unified-filter-tabs {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  border: 1px solid var(--border-brass);
}
.unified-filter-tab {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 6px 10px;
  border-radius: 0;
  background: transparent;
  color: var(--text-ivory-muted);
  border: none;
  border-right: 1px solid var(--border-brass);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
}
.unified-filter-tab:last-child { border-right: none; }
.unified-filter-tab:hover { color: var(--text-ivory); }
.unified-filter-tab.active {
  color: var(--text-ivory);
  background: var(--bg-raised);
  border-color: var(--accent-brass);
}
.unified-filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  height: 14px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  background: transparent;
  color: var(--text-ivory-muted);
  border-radius: 0;
  padding: 0 3px;
  margin-left: 5px;
  line-height: 1;
}
.unified-filter-tab.active .unified-filter-badge {
  background: transparent;
  color: var(--text-ivory);
}

/* ── Game Cards ── */
.unified-game-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.unified-game-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  padding: var(--space-md) var(--space-lg);
  transition: background var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
  position: relative;
}
.unified-game-card:hover {
  background: var(--bg-rail);
  border-color: var(--accent-brass);
}
.unified-game-card:hover .unified-delete-btn {
  opacity: 1;
}
.unified-game-card.your-turn {
  border-color: var(--border-brass);
  border-left: 3px solid var(--accent-brass);
}

.unified-game-card-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.unified-game-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.unified-game-name {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-ivory);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Turn status badges */
.unified-turn-badge {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 2px 8px;
  border-radius: 0;
  white-space: nowrap;
  border: 1px solid var(--border-brass);
  color: var(--text-ivory-muted);
  background: transparent;
}
.unified-turn-badge.your-turn {
  background: transparent;
  color: var(--text-ivory);
  border-color: var(--accent-brass);
  border-left-width: 3px;
  font-weight: 600;
  letter-spacing: 0.16em;
}
.unified-turn-badge.waiting,
.unified-turn-badge.filling,
.unified-turn-badge.hotseat,
.unified-turn-badge.vs-ai {
  color: var(--text-ivory-muted);
}
.unified-round-badge {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-ivory);
  background: transparent;
  border: 1px solid var(--border-brass);
  border-radius: 0;
  padding: 2px 8px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

/* Turn info row */
.unified-game-turn-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
}
.unified-current-power {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
}
.unified-power-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.unified-phase-label {
  color: var(--text-ivory-muted);
  font-style: italic;
  font-family: var(--font-body);
}

/* Game metadata row */
.unified-game-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-ivory-muted);
  flex-wrap: wrap;
}
.unified-game-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
/* #3713 — a match created under a previous seat model. Deliberately styled as
   a warning rather than hidden: the player needs to see the game still exists
   and why it will not open, not have it silently vanish from the list. */
.unified-game-meta-item.unified-game-unplayable {
  color: var(--color-warning);
  font-weight: 600;
}
.unified-game-card.unplayable {
  opacity: 0.6;
  cursor: not-allowed;
  border-color: var(--color-warning);
}
.unified-autosave-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-brass);
  flex-shrink: 0;
}

/* Player roster strip */
.unified-player-roster {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}
.unified-roster-pip {
  width: 20px;
  height: 6px;
  border-radius: 3px;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.unified-roster-pip.active {
  opacity: 1;
  box-shadow: 0 0 6px currentColor;
}
.unified-roster-pip.mine {
  border: 1px solid white;
}

/* ── Delete Button (hover-reveal on cards) ── */
.unified-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-ivory-muted);
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  font-family: var(--font-ui);
}
.unified-delete-btn:hover {
  color: var(--accent-danger);
  border-color: var(--accent-red);
}
/* ── Lobby Delete Confirmation Modal (body; the shell is DialogScaffold) ── */
.lobby-delete-modal-body {
  padding: var(--space-lg);
  text-align: left;
}
.lobby-delete-modal-message {
  font-size: var(--text-base);
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-ivory-muted);
  line-height: 1.5;
}
.lobby-delete-modal-game-info {
  margin-top: var(--space-sm);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  color: var(--text-ivory-muted);
}
.lobby-delete-modal-match-id {
  font-family: var(--font-mono);
  color: var(--text-ivory);
}
.lobby-delete-modal-footer {
  padding: var(--space-sm) var(--space-lg) var(--space-md);
  border-top: 1px solid var(--border-brass);
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
}
.lobby-delete-modal-footer .btn,
.lobby-delete-modal-btn-delete {
  flex: 1;
  min-height: var(--tap-min);
}
.lobby-delete-modal-btn-delete {
  flex: 1;
  padding: 10px 0;
  font-size: var(--text-sm);
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--btn-bg-danger);
  color: var(--accent-danger);
  border: 1px solid var(--accent-red);
  border-radius: 0;
  cursor: pointer;
  transition: filter var(--transition-fast);
}
.lobby-delete-modal-btn-delete:hover {
  filter: brightness(1.15);
}

/* ── Join by ID ── */
.unified-join-by-id {
  display: flex;
  align-items: center;
  gap: 6px;
}
.unified-join-by-id-input {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  padding: 5px 10px;
  border-radius: 0;
  border: 1px solid var(--border-brass);
  background: var(--bg-raised);
  color: var(--text-ivory);
  width: 180px;
}
.unified-join-by-id-input::placeholder { font-family: var(--font-ui); color: var(--text-ivory-muted); }
.unified-join-by-id-btn {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 5px 12px;
  border-radius: 0;
  border: 1px solid var(--border-brass);
  background: var(--bg-raised);
  color: var(--text-ivory);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}
.unified-join-by-id-btn:hover:not(:disabled) { border-color: var(--accent-brass); }
.unified-join-by-id-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Empty State ── */
.unified-empty-state {
  text-align: center;
  padding: 48px 20px 8px;
  color: var(--text-ivory-muted);
}
.unified-empty-kicker {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent-brass);
  margin-bottom: var(--space-sm);
}
.unified-empty-text {
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--text-xl);
  color: var(--text-ivory);
  margin-bottom: var(--space-xs);
}
.unified-empty-hint {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  font-style: normal;
}
.unified-empty-state .btn-lobby {
  margin-top: var(--space-md);
}

/* ── New Game Buttons ── */
/* Section spacing for the Games and Play lists. The #4079 "+" create-tile cue
   is retired: Play's START tiles open a game. */
.unified-section {
  margin-bottom: var(--space-xl);
}
.unified-section .unified-page-title {
  margin-bottom: var(--space-md);
}
.unified-section .unified-join-by-id {
  display: flex;
  margin-bottom: var(--space-md);
}
.unified-section .unified-join-by-id-input {
  flex: 1;
  min-width: 0;
}
.unified-open-list {
  gap: var(--space-xs);
}
.unified-empty-state--compact {
  padding: var(--space-md) 0 0;
  text-align: left;
}
/* #4428: the Ranked card (design rev 2 §2.11), the Ranked tab's content since #4439. */
.ranked-entry {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 560px;
  padding: var(--space-md);
  border: 1px solid var(--accent-brass);
  background: var(--bg-ink);
  color: var(--text-ivory);
  font-family: var(--font-ui);
}
.ranked-entry .ranked-entry__title {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text-ivory);
  letter-spacing: 0.16em;
}
.ranked-entry__group {
  display: flex;
  gap: var(--space-xs);
}
.ranked-entry__group .options-segment-btn {
  text-transform: none;
}
.ranked-entry__action {
  width: 100%;
  min-height: var(--tap-min);
  padding: var(--space-sm) var(--space-md);
}
/* #5132: ranked radios are 44px on every pointer.
   The 520px block below only changes wrapping. */
.ranked-entry .options-segment-btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
}
@media (min-width: 640px) {
  .ranked-entry__action {
    width: auto;
    align-self: flex-start;
  }
}
@media (max-width: 520px) {
  /* #4439: one row per choice on a phone (wrapping only if it must), not five stacked bars. */
  .ranked-entry__group {
    flex-wrap: wrap;
  }
  .ranked-entry__group .options-segment-btn {
    flex: 1 1 auto;
    padding: var(--space-sm) var(--space-xs);
  }
  .ranked-entry__group .options-segment-btn,
  .ranked-entry__action {
    min-height: var(--tap-min);
  }
}

/* ── Browse Open Games ── */
.unified-open-header {
  display: flex;
  gap: 16px;
  padding: 0 16px 4px;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.unified-open-game-row {
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  border-radius: 0;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
}
.unified-open-game-row:hover {
  background: var(--bg-rail);
  border-color: var(--accent-brass);
}
.unified-open-game-name {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-ivory);
  min-width: 160px;
  letter-spacing: 0.04em;
}
.unified-open-game-host {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
  min-width: 100px;
}
.unified-open-game-slots {
  display: flex;
  gap: 3px;
  align-items: center;
  flex: 1;
}
.unified-slot-pip {
  width: 8px;
  height: 8px;
  border-radius: 0;
  border: 1px solid var(--border-brass);
}
.unified-slot-pip.filled {
  background: var(--accent-brass);
  border-color: var(--accent-brass);
}
.unified-slot-pip.open {
  background: transparent;
}
.unified-slot-count {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
  margin-left: 4px;
}
.unified-open-game-age {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
  min-width: 60px;
  text-align: right;
}


/* ── Responsive ── */
@media (max-width: 640px) {
  .unified-topbar-rules,
  .unified-topbar-report,
  .unified-topbar-signout,
  .unified-topbar-discord {
    white-space: nowrap;
    letter-spacing: 0.04em;
  }
  .unified-page {
    padding: 20px calc(16px + var(--safe-r)) 20px calc(16px + var(--safe-l));
  }
  .unified-page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .unified-filter-tabs {
    margin-left: 0;
  }
  .unified-open-game-row {
    flex-wrap: wrap;
  }
}

/* ── Compact height (phone landscape / ≤600px tall) ── */
@media (max-height: 600px) {
  .unified-page {
    padding: 12px calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l));
  }
  .unified-page-header {
    margin-bottom: 10px;
  }
  .unified-page-title {
    font-size: 1rem;
  }
  .unified-empty-state {
    padding: 20px;
  }
  .unified-section {
    margin-bottom: var(--space-md);
  }
  .unified-resume-banner {
    margin-bottom: var(--space-md);
  }
  .unified-game-card {
    padding: 10px 14px;
  }
  .unified-game-list {
    gap: 6px;
  }
}

/* ============================================================
 * Combat Board — AA 1942 Theatrical Wartime Tribunal (#2314)
 * ============================================================
 * Side-coded color hierarchy, oversized phase prompts, full-bleed
 * atmosphere (flag watermark + tracer SVG + grain). Center column
 * is the STAGE, not a dice ledger. Gold reserved for critical
 * decisions; sustained warm tint on attacker, cool on defender.
 */
:root {
  /* Side accent palette — distinct from per-nation attColor/defColor. */
  --combat-aa42-atk:        #c45252;  /* deep crimson — attacker side */
  --combat-aa42-atk-glow:   #e07070;  /* highlight glow */
  --combat-aa42-def:        #8aa4c2;  /* steel blue — defender side */
  --combat-aa42-def-glow:   #b0c8de;  /* highlight glow */

  /* CONTINUE / primary CTA tribunal red. */
  --combat-aa42-cta:        #b03838;
  --combat-aa42-cta-hover:  #c64545;
}

/* Darken the combat root and add atmospheric layers — radial vignette plus
 * a soft warm horizon glow at the bottom give the room some depth without
 * stealing focus from the chips. */
.combat-root {
  background:
    /* horizon glow — warm pool at the bottom */
    radial-gradient(ellipse 80% 30% at 50% 100%, rgba(180, 100, 50, 0.10), transparent 70%),
    /* center spotlight — slight brightness in the middle */
    radial-gradient(ellipse 90% 60% at 50% 45%, rgba(60, 50, 40, 0.4), transparent 70%),
    /* base */
    radial-gradient(ellipse 120% 80% at 50% 50%, rgba(20, 16, 12, 0.94), rgba(4, 3, 2, 0.98)),
    rgba(6, 5, 3, 0.96);
}

/* Film grain — slightly more present (was 0.06) for tactile feel.
 * SVG turbulence data URI; mix-blend overlay so it sits on warm darks
 * without crushing chip detail. */
.combat-root::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.085;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.7 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}

/* Vignette — darker corners, brighter middle, gives the board depth. */
.combat-root::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(ellipse 70% 75% at 50% 50%, transparent 55%, rgba(0,0,0,0.55) 100%);
}

/* Ensure descendants still receive pointer events above ::before. */
.combat-root > * {
  position: relative;
  z-index: 2;
}

/* Board-game mode: the battle plays ON the frozen Pixi board behind this
 * overlay (PixiMapApp pauses + holds the last frame while combat is open).
 * Replace the opaque backdrop + vignette/grain with a single ~55% scrim so the
 * paused board shows through, dimmed. (#3052) */
.combat-root--tabletop { background: rgba(8, 6, 4, 0.55); }
.combat-root--tabletop::before,
.combat-root--tabletop::after { display: none; }

/* While a battle is open in board mode the map's chrome would show through the
 * scrim and collide with the battle — hide it so only the dimmed board remains.
 * The top-bar host is display:contents normally (layout-transparent) and the
 * hamburger lives inside the top bar. (#3052) */
.board-top-bar-host { display: contents; }
.timer-handoff-toast { display: contents; }
body.combat-board-modal .board-top-bar-host,
body.combat-board-modal .board-sidebar-content,
body.combat-board-modal [data-testid="territory-bottom-panel"] { display: none !important; }

/* === Tribunal header — giant ATTACKER · TERRITORY · DEFENDER bar === */
.combat-aa42-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  grid-template-areas: "atk center def ctrl";
  align-items: center;
  gap: 8px;
  /* Header background spans the full viewport, but the content box is
   * pulled inward on widescreens so atk/def col-heads sit over the
   * (centered) rank-grid + casualty-col band, not at the screen edges.
   * 1432px target = rank-grid max 1240px + casualty cols 2×96px.
   * Vertical padding kept tight (2px) — the col-head pills carry their own
   * vertical breathing room. */
  padding: 2px max(22px, calc((100vw - 1432px) / 2 + 22px));
  background: linear-gradient(180deg, #15110b 0%, #0a0807 100%);
  border-bottom: 1px solid var(--border-accent);
  position: relative;
}
.combat-aa42-header-side--atk { grid-area: atk; }
.combat-aa42-header-side--def { grid-area: def; }
.combat-aa42-header-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
}
.combat-aa42-header-label {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.25rem, 0.95rem + 1.0vw, 1.85rem);  /* 20–30px */
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.combat-aa42-header-label--atk { color: var(--combat-aa42-atk-glow); }
.combat-aa42-header-label--def { color: var(--combat-aa42-def-glow); }
.combat-aa42-header-action {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 999px;
  display: inline-block;
  animation: combatAa42ActionPulse 2.4s ease-in-out infinite;
}
.combat-aa42-header-action--atk {
  color: #fff5f0;
  background: linear-gradient(135deg, var(--combat-aa42-atk) 0%, #6e1f1f 100%);
  box-shadow: 0 0 12px rgba(196,82,82,0.55);
}
.combat-aa42-header-action--def {
  color: #f0f6fb;
  background: linear-gradient(135deg, var(--combat-aa42-def) 0%, #3a536e 100%);
  box-shadow: 0 0 12px rgba(138,164,194,0.5);
}
@keyframes combatAa42ActionPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
.combat-aa42-header-side-nation {
  margin-top: 2px;
  font-size: max(var(--text-sm), var(--text-battle-floor));
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
}
.combat-aa42-header-side-nation img {
  width: 18px;
  height: auto;
  border-radius: 2px;
  flex-shrink: 0;
}
.combat-aa42-header-center {
  grid-area: center;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  min-width: 0;
}
.combat-aa42-header-title-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
/* Center-upper floating status overlay (#3037). Holds ALL variable combat
 * narration/status/odds text — the phase caption, the single active-status
 * line (casualty progress / Deciding… / Rolling… / Waiting…), and the retreat
 * odds. It floats ABOVE the board, anchored just below the (now constant-
 * height) header, so its content appearing/changing never resizes the header
 * row and never shifts the board. pointer-events:none keeps it click-through;
 * the retreat odds readout is informational only (action buttons live in the
 * bottom slots). */
.combat-center-status {
  position: absolute;
  top: calc(var(--combat-header-bottom, 3.25rem) + 0.4rem);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  pointer-events: none;
  z-index: 6;
  max-width: 92vw;
  text-align: center;
}
/* The phase caption flows statically inside the overlay (override the
 * absolute, board-anchored base .combat-action-caption positioning). */
.combat-center-status .combat-action-caption {
  position: static;
  transform: none;
  top: auto;
  left: auto;
  margin: 0;
  max-width: min(70vw, 30rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Single active-status line (Deciding… / Rolling… / Waiting… / casualty
 * progress). Legible dark-glass text; the casualty-progress span carries its
 * own inline-flex layout via .combat-side-placard__casualty-status. */
.combat-center-status__line {
  font-family: var(--font-heading);
  font-size: clamp(0.75rem, 0.65rem + 0.4vw, 0.9rem);
  font-style: italic;
  letter-spacing: 0.04em;
  color: var(--text-secondary, #a89070);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}
.combat-aa42-header-territory {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-ivory);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 32vw;
}
.combat-aa42-header-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: max(var(--text-xs), var(--text-battle-floor));
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.combat-aa42-header-round {
  background: var(--bg-raised);
  color: var(--text-ivory);
  border: 1px solid var(--accent-brass);
  padding: 1px 8px;
  border-radius: 0;
  font-weight: 700;
  font-size: 0.6875rem;
}

.combat-aa42-header-controls {
  grid-area: ctrl;
  display: flex;
  gap: var(--space-xs);
}
/* Speed / Skip / Close: `.btn.btn-sm.btn-ghost` (+ CloseButton), each held to
 * the touch minimum (#4193). The label keeps its pre-#4193 11px on small
 * screens, where --text-sm falls to ~9px. */
.combat-aa42-header-ctrl {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: max(var(--text-sm), var(--text-battle-floor));
}
/* The close glyph is a glyph, not a label: it was 16px before #4193 and
 * --text-lg falls to ~14px on phones, so small screens step up to --text-xl. */
.combat-aa42-header-ctrl.btn-close-overlay { font-size: var(--text-lg); }
/* The settings gear is a glyph that fills ~60% of its em, so it sits one
 * step above the close glyph to read the same size. (#4211) */
.combat-aa42-header-ctrl.combat-aa42-header-ctrl--icon { font-size: var(--text-xl); line-height: 1; }
@media (max-width: 1024px) {
  .combat-aa42-header-ctrl.btn-close-overlay { font-size: var(--text-xl); }
  .combat-aa42-header-ctrl.combat-aa42-header-ctrl--icon { font-size: var(--text-2xl); }
}

@media (max-width: 768px) {
  .combat-aa42-header {
    padding: 3px 8px;
    gap: 6px;
  }
  .combat-aa42-header-action {
    font-size: 0.6875rem;
    padding: 2px 8px;
    letter-spacing: 0.12em;
  }
  .combat-aa42-header-territory { font-size: 0.8125rem; letter-spacing: 0.08em; }
  .combat-aa42-header-meta { font-size: var(--text-battle-floor); }
  .combat-aa42-header-round { font-size: var(--text-battle-floor); padding: 1px 6px; }
}

/* Phone: territory + round and the controls share the top row; the two nation
 * heads drop to their own row below, so nothing overlaps (#4193). */
@media (max-width: 500px) {
  .combat-aa42-header {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "center ctrl"
      "atk    def";
  }
  .combat-aa42-header-title-row { flex-wrap: wrap; justify-content: flex-start; }
  .combat-aa42-header-center { align-items: flex-start; text-align: left; }
  .combat-aa42-header-territory { max-width: none; }
  .combat-aa42-header-controls { justify-self: end; }
}

.combat-aa42-board-row-span--center { grid-column: 3; }
.combat-aa42-board-row-atk { grid-column: 1 / 3; }
.combat-aa42-board-row-def { grid-column: 4 / 6; }

.combat-aa42-rank-medallion-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.combat-aa42-rank-hits {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.combat-aa42-rank-hits-side {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 5px;
  border-radius: 6px;
}
.combat-aa42-rank-hits-side--atk {
  color: #fff5f0;
  background: linear-gradient(135deg, var(--combat-aa42-atk) 0%, #6e1f1f 100%);
  box-shadow: 0 0 6px rgba(196,82,82,0.45);
}
.combat-aa42-rank-hits-side--def {
  color: #f0f6fb;
  background: linear-gradient(135deg, var(--combat-aa42-def) 0%, #3a536e 100%);
  box-shadow: 0 0 6px rgba(138,164,194,0.4);
}
.combat-aa42-rank-cell--blank {
  min-height: 28px;
  opacity: 0.35;
}

/* Clickable chip during casualty mode — gentle glow to indicate it's an
 * eligible casualty target for the current hit category. */
.combat-aa42-chip-col--clickable {
  filter: drop-shadow(0 0 4px rgba(255,210,120,0.55));
}
.combat-aa42-chip-col--clickable:hover {
  filter: drop-shadow(0 0 8px rgba(255,225,160,0.8));
}
/* === Casualty adjust overlay — popup anchored on a chip when it's clicked
 * in casualty mode. Saves the always-visible +/- vertical space. === */
.combat-aa42-cas-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.5);
}
.combat-aa42-cas-overlay {
  position: fixed;
  z-index: 10000;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto auto;
  gap: 6px 12px;
  align-items: center;
  justify-items: center;
  /* Fully opaque background — no bleed-through from underlying chips. */
  background: #0c0a08;
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-width: 180px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.85);
  pointer-events: auto;
}
.combat-aa42-cas-overlay-num {
  grid-column: 2;
  grid-row: 1 / 3;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 2.25rem;
  color: var(--accent-gold);
  line-height: 1;
  text-shadow: 0 0 18px var(--overlay-gold-40);
}
.combat-aa42-cas-overlay-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.combat-aa42-cas-overlay-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.32);
}
.combat-aa42-cas-overlay-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.combat-aa42-cas-overlay-step {
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  padding: 0;
  border-radius: 50%;
}
.combat-aa42-cas-overlay-step--minus { grid-column: 1; grid-row: 1; }
.combat-aa42-cas-overlay-step--plus  { grid-column: 3; grid-row: 1; }
.combat-aa42-cas-overlay-min { grid-column: 1; grid-row: 2; }
.combat-aa42-cas-overlay-max { grid-column: 3; grid-row: 2; }
.combat-aa42-cas-overlay-actions {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}
.combat-aa42-cas-overlay-action {
  width: 38px;
  height: 30px;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid;
  font-weight: 700;
  transition: all var(--transition-fast);
}
.combat-aa42-cas-overlay-action--confirm {
  background: #2a8a3a;
  border-color: #4ab84a;
  color: #fff;
}
.combat-aa42-cas-overlay-action--confirm:hover { background: #34a345; }
.combat-aa42-cas-overlay-action--cancel {
  background: #8a2a2a;
  border-color: #c64545;
  color: #fff;
}
.combat-aa42-cas-overlay-action--cancel:hover { background: #a33434; }

/* Damage badge — small red ½ disc anchored to the bottom-left corner of
 * 2-hit unit chips (battleships, carriers) when the unit has taken its
 * first hit and is operating at reduced HP. Pure visual; not interactive. */
.combat-aa42-chip-damage {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.78rem;
  line-height: 1;
  color: #fff;
  background: linear-gradient(135deg, #d04a4a 0%, #6e1f1f 100%);
  border: 1.5px solid rgba(255, 220, 200, 0.75);
  box-shadow:
    0 0 6px rgba(208, 74, 74, 0.65),
    inset 0 -1px 1px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 11;
}

.combat-aa42-chip-amphi {
  position: absolute;
  bottom: -4px;
  left: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-battle-floor);
  line-height: 1;
  color: #fff;
  background: var(--color-amphibious, #5090c0);
  border: 1.5px solid rgba(160, 220, 255, 0.65);
  box-shadow:
    0 0 5px rgba(80, 144, 192, 0.6),
    inset 0 -1px 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 11;
}

@keyframes combatAa42HaloPulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; }
}

/* Board-mode AA-fire highlight. The silhouette hug is a static drop-shadow
 *  on the canvas (animating filter repaints every frame). The pulse is
 *  opacity on ::after. The class sits on a wrapper — <canvas> does not
 *  render pseudos. Green = firing AA gun, red = targeted aircraft. (#3036, #5016) */
.combat-aa42-piece-glow {
  position: relative;
  display: block;
  flex-shrink: 0;
  isolation: isolate;
}
.combat-aa42-piece-glow > canvas { display: block; }
.combat-aa42-piece-glow--green > canvas {
  filter: drop-shadow(0 0 3px rgba(110, 220, 110, 0.85)) drop-shadow(0 0 7px rgba(110, 220, 110, 0.5));
}
.combat-aa42-piece-glow--red > canvas {
  filter: drop-shadow(0 0 3px rgba(225, 85, 85, 0.85)) drop-shadow(0 0 7px rgba(225, 85, 85, 0.5));
}
.combat-aa42-piece-glow::after {
  content: '';
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  animation: combatAa42PieceGlow 2.4s ease-in-out infinite;
}
.combat-aa42-piece-glow--green::after {
  background: radial-gradient(circle, rgba(110, 220, 110, 0.55) 0%, rgba(110, 220, 110, 0) 70%);
}
.combat-aa42-piece-glow--red::after {
  background: radial-gradient(circle, rgba(225, 85, 85, 0.55) 0%, rgba(225, 85, 85, 0) 70%);
}
@keyframes combatAa42PieceGlow {
  0%, 100% { opacity: 0; }
  50%      { opacity: 1; }
}

/* Right-justify the DEF loss summary (atk left-justified is the default). */
.combat-aa42-loss-cell--def :first-child {
  justify-content: flex-end;
}

/* Nation row — separate three-column layout above the rank grid.
 * Independent of the rank-grid's 7-col layout so the action cell can take
 * 2/3 of the width without inflating the spine column below. */
.combat-aa42-nation-row {
  display: grid;
  /* Symmetric 1fr / auto / 1fr so the center action cell stays viewport-
   * centered regardless of which side has an action badge. Sides hug their
   * outer edges via .combat-aa42-nation-row-side justify-content. */
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  /* Chrome-less: the old center-band border/gradient was vestigial decoration
   * (#2580). The row is now just a transparent positioning container for the
   * passive stage display + the floating "Awaiting decision" hint. */
  /* Out of grid flow — floats as an overlay above the board-shell so its
   * height changes never cause the rank rows above to reflow/bounce. The
   * rank grid is allowed to extend under this overlay (it stays centered
   * via align-content, so it breathes lower rather than clipping). */
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  min-height: 3.5rem;
}
@media (max-width: 768px) {
  .combat-aa42-nation-row {
    min-height: 2.75rem;
  }
}
.combat-aa42-nation-row .combat-aa42-col-head--atk { color: var(--combat-aa42-atk); }
.combat-aa42-nation-row .combat-aa42-col-head--def { color: var(--combat-aa42-def); }

.combat-aa42-action-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 1px 10px;
}
.combat-aa42-action-cell:empty { background: transparent; }
@media (max-width: 768px) {
  .combat-aa42-action-cell { padding: 2px 6px; gap: 6px; }
}

/* Side slots in the bottom nation row — host the action badges (Roll Attack,
 * Select Casualties, Submerge?, etc.) on each side. */
.combat-aa42-nation-row-side {
  display: flex;
  align-items: center;
  padding: 2px 10px;
  min-width: 0;
}
/* Pull the action badges toward the middle of the row — atk hugs the
 * right edge of its side cell, def hugs the left edge — so they sit
 * close to the central decision buttons instead of the screen edges. */
.combat-aa42-nation-row-side--atk { justify-content: flex-end; }
.combat-aa42-nation-row-side--def { justify-content: flex-start; }

/* Simulate button — small icon-style button that floats at the right edge
 * of the action cell so it sits next to whatever decision buttons are there
 * (Press Attack/Retreat, Confirm Casualties, Roll, etc.). */
.combat-aa42-simulate-btn {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-body);
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}
.combat-aa42-simulate-btn:hover {
  background: rgba(255, 255, 255, 0.10);
  color: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.25);
}

/* === Action bar — horizontal row at the bottom of the stage panel === */
.combat-aa42-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 8px 16px;
  flex-wrap: wrap;
}
.combat-aa42-action-bar-left {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.combat-aa42-action-bar-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.combat-aa42-stage-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  gap: 8px;
  min-height: 80px;
}
.combat-aa42-stage-body--decisions {
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
}
.combat-aa42-stage-hit-reveal {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  font-size: clamp(1.5rem, 0.9rem + 1.6vw, 2.5rem);
  color: var(--accent-gold);
  text-shadow: 0 0 28px var(--overlay-gold-40);
}
.combat-aa42-stage-hit-reveal.is-zero {
  color: var(--text-muted);
  text-shadow: none;
}

/* Live running tally of both sides' hits — visible whenever either has fired. */
.combat-aa42-stage-totals {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 18px;
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.combat-aa42-stage-totals-side {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 14px;
  min-width: 90px;
}
.combat-aa42-stage-totals-side + .combat-aa42-stage-totals-side {
  border-left: 1px solid var(--border-primary);
}
.combat-aa42-stage-totals-label {
  font-size: 0.6875rem;
  letter-spacing: 0.2em;
  color: rgba(255,255,255,0.45);
  font-weight: 600;
}
.combat-aa42-stage-totals-value {
  font-size: clamp(1.25rem, 0.85rem + 1.1vw, 2rem);
  line-height: 1;
}
.combat-aa42-stage-totals-side--atk .combat-aa42-stage-totals-value {
  color: var(--combat-aa42-atk-glow);
  text-shadow: 0 0 18px rgba(196,82,82,0.45);
}
.combat-aa42-stage-totals-side--def .combat-aa42-stage-totals-value {
  color: var(--combat-aa42-def-glow);
  text-shadow: 0 0 18px rgba(138,164,194,0.4);
}
.combat-aa42-stage-totals-suffix {
  font-size: var(--text-battle-floor);
  font-weight: 600;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
}

@keyframes combatAa42FlagDrift {
  0%   { transform: translate(-50%, -50%) scale(1.00) translate(0px, 0px); }
  50%  { transform: translate(-50%, -50%) scale(1.06) translate(-12px, 6px); }
  100% { transform: translate(-50%, -50%) scale(1.02) translate(8px, -4px); }
}

/* === Tribunal column header — anchored above unit rows === */
.combat-aa42-col-head {
  position: relative;
  z-index: 2;
  padding: 3px 14px;
  border-bottom: 1.5px solid currentColor;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.25) 100%);
}
.combat-aa42-col-head--atk { color: var(--combat-aa42-atk); }
.combat-aa42-col-head--def { color: var(--combat-aa42-def); }
.combat-aa42-col-head-flag {
  width: clamp(22px, 1.6vw, 32px);
  height: clamp(22px, 1.6vw, 32px);
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
  object-fit: cover;
}
/* A coalition's other flags, overlapped behind the first: smaller, still round. */
.combat-aa42-col-head-flag--extra {
  width: clamp(17px, 1.25vw, 25px);
  height: clamp(17px, 1.25vw, 25px);
}
.combat-aa42-col-head-text {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.combat-aa42-col-head-nation {
  font-family: var(--font-heading);
  /* 14px → 22px across viewport so the col-head reads at desktop scale. */
  font-size: clamp(0.875rem, 0.75rem + 0.55vw, 1.4rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  line-height: 1.1;
  color: rgba(255,255,255,0.92);
}
.combat-aa42-col-head-count {
  font-size: clamp(0.625rem, 0.55rem + 0.25vw, 0.9rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
}

@media (max-width: 768px) {
  .combat-aa42-col-head { padding: 3px 8px; gap: 6px; }
  .combat-aa42-col-head-flag { width: 18px; height: 18px; }
  .combat-aa42-col-head-flag--extra { width: 14px; height: 14px; }
  .combat-aa42-col-head-nation { font-size: 0.75rem; letter-spacing: 0.06em; }
  .combat-aa42-col-head-count { font-size: var(--text-battle-floor); }
}

/* === Center column — the STAGE === */
/* Oversized phase prompt sitting above the dice grid. */
.combat-aa42-stage-prompt {
  text-align: center;
  padding: 14px var(--space-lg) 8px;
  position: relative;
  z-index: 2;
}
.combat-aa42-stage-prompt-label {
  display: block;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.25rem, 0.85rem + 1.4vw, 2rem);  /* 20–32px */
  letter-spacing: 0.12em;
  line-height: 1.05;
  text-transform: uppercase;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
.combat-aa42-stage-prompt-label--atk { color: var(--combat-aa42-atk-glow); }
.combat-aa42-stage-prompt-label--def { color: var(--combat-aa42-def-glow); }
.combat-aa42-stage-prompt-label--neutral { color: var(--accent-gold); }
.combat-aa42-stage-prompt-owner {
  display: block;
  margin-top: 4px;
  font-size: max(var(--text-xs), var(--text-battle-floor));
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}
.combat-aa42-stage-prompt-rule {
  margin: 8px auto 0;
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  opacity: 0.4;
}

/* === CONTINUE primary CTA (post-roll, war-room red) === */
.combat-aa42-continue {
  display: block;
  width: 100%;
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff8f4;
  background: linear-gradient(180deg, var(--combat-aa42-cta-hover) 0%, var(--combat-aa42-cta) 100%);
  border: 1px solid rgba(255,180,180,0.35);
  border-top-color: rgba(255,200,200,0.55);
  border-bottom-color: rgba(0,0,0,0.4);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  cursor: pointer;
  box-shadow:
    0 2px 12px rgba(176,56,56,0.45),
    inset 0 1px 0 rgba(255,255,255,0.18),
    inset 0 -2px 0 rgba(0,0,0,0.25);
  transition: all var(--transition-normal);
}
.combat-aa42-continue:hover:not(:disabled) {
  background: linear-gradient(180deg, #d65656 0%, var(--combat-aa42-cta-hover) 100%);
  box-shadow:
    0 4px 18px rgba(176,56,56,0.6),
    inset 0 1px 0 rgba(255,255,255,0.22),
    inset 0 -2px 0 rgba(0,0,0,0.2);
  transform: translateY(-1px);
}
.combat-aa42-continue:active:not(:disabled) {
  transform: translateY(0);
  box-shadow:
    0 1px 6px rgba(176,56,56,0.45),
    inset 0 2px 4px rgba(0,0,0,0.35);
}
.combat-aa42-continue:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.combat-aa42-continue-wrap {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: linear-gradient(to top, var(--bg-darkest) 75%, transparent);
  padding: 10px 16px 8px;
}

/* Casualty progress line on the ACTIVE placard ("Surface Hits 1/2 hits
 * assigned"). Sits above the action buttons. Not italic — it's a live count,
 * not a passive status. (Task 2) */
.combat-side-placard__casualty-status {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
  font-style: normal;
  white-space: nowrap;
  /* #3773: wrap so the empty-state hint can sit under the count instead of
   * pushing the line off-screen on tablet widths (reported at 1112x702). */
  flex-wrap: wrap;
}
/* #3773: casualty selection starts empty now, so zero-assigned must read as
 * "your move" rather than a stalled screen. Overrides the nowrap above — this
 * is a sentence, not a counter — and only renders for the deciding player. */
.combat-side-placard__casualty-hint {
  color: var(--text-secondary);
  font-size: max(var(--text-xs), var(--text-battle-floor));
  white-space: normal;
}
.combat-side-placard__casualty-cat {
  font-weight: 700;
  color: var(--accent-gold);
}

/* === Banner retreat decision (Task 3) — the attacker's retreat call lives in
 * the header banner (under the caption) instead of a side placard. The slot
 * divs host the portaled PRESS ATTACK / RETREAT / SIMULATE buttons inline, and
 * an odds readout sits above them. Override the absolute positioning the base
 * .combat-action-primary / .combat-action-secondary-cluster rules apply so the
 * buttons flow inside the banner box. Uses the container class as the sole
 * discriminator so the selector never matches the tap-size test's split. */
.combat-banner-decision {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.35rem;
  pointer-events: auto;
}
.combat-banner-odds {
  font-family: var(--font-heading);
  font-size: clamp(0.75rem, 0.65rem + 0.4vw, 0.9rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent-gold);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.55);
}
.combat-banner-decision__slots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.combat-banner-decision .combat-action-primary-region,
.combat-banner-decision .combat-action-secondary-cluster {
  position: static;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}
.combat-banner-decision .combat-action-primary-region button {
  position: static;
  right: auto;
  bottom: auto;
  min-width: unset;
  min-height: 38px;
  padding: 0 1rem;
  font-size: 0.85rem;
}
.combat-banner-decision .combat-action-secondary-cluster button {
  position: static;
  min-height: 36px;
  min-width: unset;
  padding: 0 0.7rem;
  font-size: 0.78rem;
}
@media (max-width: 600px) {
  .combat-banner-decision .combat-action-primary-region button { min-height: 32px; font-size: 0.78rem; }
  .combat-banner-decision .combat-action-secondary-cluster button { min-height: 30px; font-size: 0.72rem; }
}

/* === Battle action frame (#2580) — center-stage caption + thumb-corner
 * primary + persistent ghost left cluster. Single layout for all viewports;
 * env(safe-area-inset-*) is 0 on non-notch devices and the rail-edge anchor
 * keeps spacing. Dice render inline in the rank rows (not here), so the
 * bottom band is reclaimed for the rank grid; the bottom-CENTER stays free
 * of interactive elements (primary = bottom-right, secondary = bottom-left)
 * so the iOS home-indicator gesture is unobstructed. === */
.combat-action-frame {
  position: absolute;
  inset: 0;
  pointer-events: none; /* regions re-enable; empty space stays click-through */
  /* Above .combat-aa42-nation-row (z-index 3) and the now-expanded board-shell
   * content so the caption/primary/secondary always float clearly on top. */
  z-index: 6;
}
.combat-action-caption {
  position: absolute;
  /* Anchored flush to the battle header's measured bottom edge
   * (--combat-header-bottom, set in CombatBoard.tsx) with a small breathing
   * gap. Falls back to a fixed offset when the var is unset. */
  top: calc(var(--combat-header-bottom, 3.25rem) + 0.4rem);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(70vw, 30rem);
  text-align: center;
  pointer-events: none;
  font-family: var(--font-heading);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(0.875rem, 0.75rem + 0.6vw, 1.125rem);
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  margin: 0;
}
.combat-action-caption__icon { margin-right: 0.4em; opacity: 0.85; }
.combat-action-primary {
  position: absolute;
  /* 1rem from the right edge, never under a notch. */
  right: max(calc(var(--safe-r) + 0.25rem), 1rem);
  bottom: calc(1rem + var(--safe-b));
  pointer-events: auto;
  min-width: 120px;
  min-height: 48px;
  padding: 0 1.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #2e1f0c;
  background:
    repeating-linear-gradient(90deg, rgba(255, 248, 225, 0.05) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #e7c878 0%, #c79a48 42%, #9a6f2c 72%, #7c5620 100%);
  border: 1px solid #5a3f1a;
  border-radius: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 210, 0.6),
    inset 0 -2px 3px rgba(60, 38, 12, 0.55),
    0 3px 9px rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 0 rgba(255, 238, 200, 0.45);
  cursor: pointer;
  transition: filter var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}
.combat-action-primary:hover:not(:disabled) { filter: brightness(1.06) saturate(1.04); }
.combat-action-primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 4px rgba(50, 32, 10, 0.6),
    inset 0 1px 0 rgba(255, 244, 210, 0.3),
    0 1px 4px rgba(0, 0, 0, 0.5);
}
.combat-action-primary:disabled { opacity: 0.5; filter: grayscale(0.55) brightness(0.9); cursor: default; }
.combat-action-primary[data-variant='danger'] {
  background:
    repeating-linear-gradient(90deg, rgba(255, 235, 235, 0.04) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #c97a5a 0%, #a85436 45%, #7d3a22 100%);
  color: #2a120b;
  border-color: #5a2a1a;
  text-shadow: 0 1px 0 rgba(255, 210, 190, 0.4);
}
.combat-action-primary[data-variant='success'] {
  background:
    repeating-linear-gradient(90deg, rgba(235, 255, 235, 0.04) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, #9ec27e 0%, #6f9a52 45%, #4d7236 100%);
  color: #16240f;
  border-color: #39521f;
  text-shadow: 0 1px 0 rgba(225, 245, 205, 0.4);
}
.combat-action-dock {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.combat-action-secondary-cluster {
  position: absolute;
  /* 1rem from the left edge, never under a notch. */
  left: max(calc(var(--safe-l) + 0.25rem), 1rem);
  bottom: calc(1rem + var(--safe-b));
  pointer-events: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 45vw;
}
.combat-action-secondary {
  min-height: 44px;
  min-width: 56px;
  padding: 0 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-gold, #caa86a);
  background: linear-gradient(180deg, #1d140c 0%, #140d07 100%);
  border: 1px solid #6f552f;
  border-radius: 5px;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.6),
    inset 0 -1px 0 rgba(140, 104, 52, 0.25),
    0 1px 3px rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.7);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}
.combat-action-secondary:hover:not(:disabled) {
  color: #f0d8a2;
  border-color: #9a7a44;
  background: linear-gradient(180deg, #241910 0%, #180f08 100%);
}
.combat-action-secondary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.7), 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ===== Portrait battle board (#3036) ===== */
.combat-root--portrait {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  /* A little breathing room between the stacked rows (header · board · tray ·
     action area) so portrait doesn't feel crammed top-and-bottom. (#3052) */
  gap: 0.3rem;
}
/* Header pinned top, action row pinned bottom (thumb zone). */
/* The step caption (top) and the ROLL/decision buttons (bottom) are ABSOLUTE
 * overlays (.combat-action-frame, inset:0) sized for landscape's empty casualty
 * rails. Portrait has no rails, so they'd overlap the in-flow content — reserve
 * vertical bands for them (caption at top, buttons at bottom) + notch room. (#3036) */
.combat-root--portrait .combat-aa42-header {
  flex: 0 0 auto;
  gap: 4px;
  /* When the Safari toolbar collapses, the page goes full-bleed and the header
   * can fall behind BOTH the Dynamic Island and Safari's floating URL pill.
   * env()/--safe-t under-reports on a fixed element in that state, so use a hard
   * MINIMUM clearance (≈ island + pill) and take whichever is larger. (#3036) */
  padding-top: max(calc(var(--safe-t) + 16px), 62px);
  padding-bottom: 6px;
}
/* Single compact header row in portrait: nation name + hits pill INLINE (not the
 * landscape name-over-pill stack) and smaller, so the three columns fit one row. */
.combat-root--portrait .combat-aa42-header-side { flex-direction: row; gap: 5px; min-width: 0; }
.combat-root--portrait .combat-aa42-header-label {
  font-size: 0.8rem; letter-spacing: 0.03em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.combat-root--portrait .combat-aa42-header-action { font-size: var(--text-battle-floor); padding: 1px 6px; }
.combat-root--portrait .combat-aa42-header-territory { font-size: 0.75rem; letter-spacing: 0.04em; }
.combat-root--portrait .combat-aa42-header-round { font-size: var(--text-battle-floor); padding: 1px 5px; }
.combat-root--portrait .combat-aa42-header { padding-left: 8px; padding-right: 8px; }
.combat-root--portrait .combat-aa42-nation-row {
  position: static;             /* override landscape absolute-over-grid; sits in normal flex flow at bottom */
  flex: 0 0 auto;
  /* Reserve the bottom band the floating primary/secondary buttons occupy
   * (min-height 48px anchored at bottom:1.25rem) so the dock's own content
   * (status text / stage panel) sits ABOVE them, not under them. */
  min-height: calc(48px + var(--safe-b, 0px));
  padding-bottom: calc(88px + var(--safe-b, 0px));
}
/* Lift the floating action buttons off the browser nav bar so they don't feel
 * jammed against the bottom edge in portrait, and give the secondary cluster a
 * little more spacing. */
.combat-root--portrait .combat-action-primary,
.combat-root--portrait .combat-action-secondary-cluster {
  bottom: calc(2rem + var(--safe-b, 0px));
}
.combat-root--portrait .combat-action-secondary-cluster { gap: 8px; }
.combat-action-secondary:disabled { opacity: 0.4; cursor: default; }

/* #3230: debug-only perf/memory HUD — fixed corner overlay, non-interactive
 * so it never intercepts touch/pointer on device. */
.perf-hud {
  position: fixed;
  top: var(--space-sm);
  right: var(--space-sm);
  z-index: var(--z-debug);
  pointer-events: none;
  background: var(--surface-tooltip);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text-primary);
  white-space: pre;
}
.perf-hud .perf-hud-muted { color: var(--text-muted); }

/* ── Team Plan Mode HUD (#3272 / #3275) ───────────────────────────────────── */
/* Single upper-left anchor for both the Show-Plan toggle+slider and the
 * Edit-Plan button/toolbar (#3283) — previously two independently
 * absolute-positioned groups (one top-center, one top-right), which put the
 * Show-Plan controls under the right sidebar's hamburger toggle. Anchoring
 * both to one flex container keeps them together, clear of the sidebar. */

.plan-show-toggle-group {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.plan-show-toggle {
  display: inline-flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface-tooltip);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.plan-show-toggle:hover { background: var(--surface-hover); }
.plan-show-toggle[aria-pressed='true'] {
  border-color: var(--accent-gold);
  color: var(--accent-gold-bright);
}

.plan-opacity-slider {
  width: 5rem;
  accent-color: var(--accent-gold);
}

/* ── Plan switcher dropdown (Team Plan Mode, #3285) ───────────────────────────
 * Create / rename / duplicate / delete + switch the active plan. Anchored at the
 * top of the upper-left HUD; the menu drops below its toggle. */
.plan-switcher {
  position: relative;
  display: inline-flex;
}

.plan-switcher-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  max-width: 12rem;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface-tooltip);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.plan-switcher-toggle:hover { background: var(--surface-hover); }

/* Opens the arrow legend (#5250). Same chrome as the switcher beside it. */

.plan-switcher-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-switcher-caret {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.plan-switcher-menu {
  position: absolute;
  top: calc(100% + var(--space-xs));
  left: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-width: 13rem;
  /* #3369: a team may hold up to MAX_PLANS_PER_TEAM (20) plans, and this menu
   * dropped unbounded from a top edge measured at y:75-77 — at 375px of depth
   * that is ~11 rows, so the tail of the list AND the "+ New plan" button below
   * it fell off-screen with no scrollbar to reach them. Budget from the real
   * viewport minus the chrome above (see --plan-hud-reserve) and the bottom
   * inset, so a notched phone doesn't hide the last row behind the home bar. */
  max-height: calc(100dvh - var(--plan-hud-reserve) - var(--safe-b) - var(--space-sm));
  padding: var(--space-xs);
  background: var(--surface-tooltip);
  border: 1px solid var(--border-modal);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* ── Arrow legend popover (spec §6.9, #5250) ─────────────────────────────────
 * Non-modal, floats over the map. Desktop/iPad: 280px at the bottom-left above
 * the 40px strip. Phone portrait: full width under the top bar. Phone
 * landscape: 200px top-left, descriptions hidden. */
.plan-legend {
  position: fixed;
  left: max(10px, calc(var(--safe-l) + var(--space-xs)));
  bottom: 48px;
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 280px;
  max-width: calc(100vw - 20px);
  padding: 10px 12px;
  background: var(--surface-tooltip);
  border: 1px solid var(--border-modal);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.plan-legend__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.plan-legend__title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-heading);
}
.plan-legend__row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.plan-legend__sample { flex: none; }
.plan-legend__swatches {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-xs);
  width: 64px;
}
.plan-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.plan-legend__name {
  flex: none;
  width: 64px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-primary);
}
.plan-legend__d {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
@media (max-width: 500px) {
  .plan-legend {
    left: 10px;
    right: 10px;
    top: calc(54px + var(--safe-t));
    bottom: auto;
    width: auto;
    max-width: none;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .plan-legend {
    left: max(10px, calc(var(--safe-l) + var(--space-xs)));
    right: auto;
    top: 8px;
    bottom: auto;
    width: 200px;
    padding: 8px 10px;
  }
  .plan-legend__d { display: none; }
  /* The HUD sits under the 200px popover here (spec §7.5: HUD hidden while the
   * legend is open); ✕ / Esc / an outside tap bring it back. */
}

/* Planner tab shell (#5250, spec §6.7/§11 S4). The footer is pinned over the
 * bottom of the scrolling column, so the body reserves padding equal to the
 * footer's measured height (`--plan-footer-h`, set by PlanTabShell) and the
 * footer's negative margin pulls it back up into that padding: nothing is ever
 * covered, and there is no dead space under the last row either. The odds block
 * is the part that gives (#3365): it shrinks instead of pushing Confirm away. */
.plan-tab-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.plan-tab-shell__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-height: 0;
  padding-bottom: var(--plan-footer-h, 0px);
}
.plan-tab-shell__odds {
  flex: 0 1 auto;
  min-height: 0;
  padding-top: var(--space-xs);
  border-top: 1px solid var(--overlay-gold-20);
}
.plan-tab-shell__footer {
  margin-top: calc(-1 * var(--plan-footer-h, 0px));
}

/* Map-first target step (#5250, spec §6.7): a small NON-modal card in the
 * Orders HUD anchor, so the map under it stays tappable. */


/* Nation picker / target picker — fixed chrome above the scrollable region. */

/* Target-territory list. Was a hardcoded inline `maxHeight: 160` (#3366): at
 * short landscape that was 46-50% of the whole dialog and pushed the footer off
 * the bottom of the box. Unchanged here; bounded against real height below. */

/* The ONE scrollable region of the menu. Scoping overflow to the list rather
 * than the menu keeps "+ New plan" pinned as visible fixed chrome instead of
 * making it something you must scroll 20 rows to find — the button was half of
 * what #3369 reported unreachable, so scrolling the whole menu would only have
 * moved the problem. Its one fixed sibling is a single button, so the
 * "bounded parent, one flexing child" split holds here. */
.plan-switcher-list {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.plan-switcher-row {
  display: flex;
  align-items: center;
  /* Rows keep their natural height inside the scroller (#3369) — without this
   * a 20-plan list compresses to fit instead of overflowing into the scroll. */
  flex-shrink: 0;
  gap: var(--space-xs);
  border-radius: var(--radius-sm);
}
.plan-switcher-row:hover { background: var(--surface-hover); }

.plan-switcher-select {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  text-align: left;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.plan-switcher-check {
  width: 1rem;
  flex: 0 0 auto;
  color: var(--accent-gold-bright);
}

.plan-switcher-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plan-switcher-select[aria-checked='true'] .plan-switcher-item-name {
  color: var(--accent-gold-bright);
}

.plan-switcher-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding-right: var(--space-xs);
}

.plan-switcher-confirm-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.plan-switcher-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.plan-switcher-action:hover {
  color: var(--text-primary);
  background: var(--surface-mid);
}
.plan-switcher-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.plan-switcher-action--danger:hover {
  color: var(--accent-red-bright);
}

.plan-switcher-rename-input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 2px;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface-mid);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  outline: none;
}
/* Its border is always gold, so keyboard focus thickens it (#5565). */
.plan-switcher-rename-input:focus-visible { box-shadow: 0 0 0 2px var(--accent-gold); }

.plan-switcher-create {
  /* Fixed chrome below the scrolling list (#3369) — never absorbs the squeeze. */
  flex-shrink: 0;
  margin-top: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  text-align: left;
  color: var(--text-primary);
  background: var(--surface-mid);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.plan-switcher-create:hover {
  background: var(--surface-hover);
  border-color: var(--border-accent);
}

.plan-arrow-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  overflow: visible;
}

/* Inline Label text input over the map (Team Plan Mode, #3280). Positioned by
 * inline left/top (computed screen coords) — appearance only here. */
.plan-label-input {
  position: absolute;
  z-index: 20;
  min-width: 120px;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface-mid);
  border: 1px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px var(--overlay-dark-40);
  outline: none;
}
.plan-label-input:focus-visible { box-shadow: 0 0 0 2px var(--accent-gold), 0 2px 8px var(--overlay-dark-40); }

/* #3368 — touch hit areas for the plan switcher. Rename / duplicate / delete
 * sit ~2px apart, so an overlay would make three overlapping targets — worse
 * than three small ones. These grow for real, and the menu widens to keep the
 * plan name legible beside them. Gated on `(pointer: coarse)` so desktop
 * keeps its compact density. */
@media (pointer: coarse) {
  .plan-switcher-action {
    width: 2.75rem;
    height: 2.75rem;
  }
  .plan-switcher-menu {
    min-width: 17rem;
  }
}



/* Nation picker / target picker — fixed chrome above the scrollable region. */

/* Target-territory list. Was a hardcoded inline `maxHeight: 160` (#3366): at
 * short landscape that was 46-50% of the whole dialog and pushed the footer off
 * the bottom of the box. Unchanged here; bounded against real height below. */

/* While the target picker is open there is no attackers region, so the picker
 * is what needs the height — it flexes and its list owns the overflow. */

/* The ONE scrollable region: grows into leftover height and scrolls internally
 * so every attacker row + stepper stays reachable under the fixed odds panel
 * and footer below (#3325). */

/* One-line collapsed odds row (#3365). Replaces the full simulation body when
 * `PlannerSimPanel` is rendered `compact`; the whole row is the tap target that
 * expands it. */
.planner-sim-summary {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: 0;
  font-size: var(--text-xs);
  color: var(--text-primary);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

/* No host supplies `compact` without `onToggleDetail` today, but if one does
 * the row must not advertise a tap it won't honour. */
.planner-sim-summary:disabled { cursor: default; }

.planner-sim-summary-chevron {
  margin-left: auto;
  color: var(--text-secondary);
}

/* Collapse affordance in the expanded panel's "Simulation" title row. */
.planner-sim-collapse {
  margin-left: auto;
  padding: 0 var(--space-xs);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
}

.planner-sim-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

@media (max-height: 500px) and (orientation: landscape) {
  /* #3365 BACKSTOP — not the fix. The compact odds row keeps this column's
   * fixed chrome inside the box, so this should never engage; if it ever does
   * (e.g. the user expands the odds), the overflow becomes reachable by
   * scrolling instead of silently clipped off the bottom of the dialog.
   * `overflow: hidden` above still bounds the x axis. */

  /* ── #3366: two-column reflow ────────────────────────────────────────────
   * Wide-and-short is the one shape a fixed 560px column handles backwards. It
   * left 107-372px of width unused while the attackers region showed 15.7% /
   * 16.7% / 21.4% of its 688px of content at 667×375 / 844×390 / 932×430 —
   * ~2.5 of 15 rows. Worse, expanding the odds (the affordance #3365 shipped)
   * drove the attackers region to 0px at all three, because one column cannot
   * hold a 688px list and a 333px odds panel in 375-430px of depth.
   *
   * The grid gives the attackers the full dialog height in a column of their
   * own and moves the fields, odds and footer out of that vertical budget
   * entirely. Placement is by named area rather than nth-child so the DOM
   * order — and therefore tab order and the reading order for a screen reader
   * — is untouched; only the visual arrangement changes. */

  /* The target list no longer caps at a flat 160px — that was 46-50% of the
   * whole dialog here and clipped the footer clean off the box at 667×375 and
   * 844×390. Bound it against what the dialog actually has left instead. */
}

/* ===================================================================
   Dispatch card — title slip when a fight opens (preview: ?dispatchpreview)
   =================================================================== */
.dispatch-preview {
  min-height: 100dvh;
  background: var(--bg-ink);
  color: var(--text-ivory);
  display: flex;
  flex-direction: column;
}
.dispatch-preview__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-brass);
  background: var(--bg-rail);
  z-index: 2;
}
.dispatch-preview__title {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.dispatch-preview__scenes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.dispatch-preview__chip,
.dispatch-preview__replay {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 10px;
  border: 1px solid var(--border-brass);
  background: transparent;
  color: var(--text-ivory-muted);
  cursor: pointer;
}
.dispatch-preview__chip.is-on,
.dispatch-preview__replay:hover,
.dispatch-preview__chip:hover {
  color: var(--text-ivory);
  background: var(--bg-raised);
}
.dispatch-preview__toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.dispatch-preview__stage {
  flex: 1;
  min-height: 0;
  display: flex;
}
.dispatch-preview__stage--phone {
  flex: 0 0 auto;
  width: 390px;
  height: 720px;
  margin: 16px auto;
  border: 1px solid var(--border-brass);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.dispatch-card {
  position: relative;
  flex: 1;
  min-height: 420px;
  overflow: hidden;
  background: var(--bg-ink);
  isolation: isolate;
  container-type: size;
}
.dispatch-card__art {
  position: absolute;
  inset: 0 auto 0 0;
  width: 46%;
  background-repeat: no-repeat;
  background-position: center 18%;
  background-size: cover;
  transform-origin: center center;
  animation: dispatch-flag-in 0.7s ease-out both;
}
.dispatch-card__art--bleed {
  inset: 0;
  width: 100%;
  background-position: center center;
}
.dispatch-card--land .dispatch-card__art--bleed {
  animation:
    dispatch-land-in 0.65s ease-out both,
    dispatch-land-drift 8s 0.65s linear forwards;
}
.dispatch-card--sea .dispatch-card__art--bleed {
  animation:
    dispatch-sea-in 0.65s ease-out both,
    dispatch-sea-drift 8s 0.65s linear forwards;
}
.dispatch-card--raid .dispatch-card__art--bleed {
  animation:
    dispatch-raid-in 0.45s ease-out both,
    dispatch-raid-drift 7s 0.45s linear forwards;
}
.dispatch-card__art--landscape { display: none; }
@container (min-aspect-ratio: 5/4) {
  .dispatch-card__art--portrait { display: none; }
  .dispatch-card__art--landscape { display: block; }
}
.dispatch-card__art--atk { left: 0; background-position: 22% 18%; }
.dispatch-card__art--def {
  left: auto;
  right: 0;
  animation-delay: 0.08s;
  background-position: 78% 18%;
}
.dispatch-card__wash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* Center well for the title; keep the lower art readable. */
  background:
    radial-gradient(ellipse at 50% 40%, rgba(10, 12, 16, 0.62) 0%, rgba(10, 12, 16, 0.2) 52%, transparent 78%),
    linear-gradient(180deg, rgba(16, 19, 26, 0.28) 0%, transparent 30%, transparent 78%, rgba(16, 19, 26, 0.28) 100%);
}
.dispatch-card--split .dispatch-card__wash {
  background:
    linear-gradient(90deg, rgba(10, 12, 16, 0.35) 0%, transparent 28%, transparent 72%, rgba(10, 12, 16, 0.35) 100%),
    linear-gradient(180deg, rgba(16, 19, 26, 0.15) 0%, rgba(16, 19, 26, 0.55) 100%);
}
.dispatch-card--split.dispatch-card--land .dispatch-card__wash {
  background:
    linear-gradient(90deg, rgba(40, 28, 16, 0.45) 0%, transparent 30%, transparent 70%, rgba(40, 28, 16, 0.45) 100%),
    linear-gradient(180deg, rgba(50, 36, 18, 0.2) 0%, rgba(16, 14, 10, 0.55) 100%);
}
.dispatch-card--split.dispatch-card--sea .dispatch-card__wash {
  background:
    linear-gradient(90deg, rgba(12, 22, 36, 0.5) 0%, transparent 30%, transparent 70%, rgba(12, 22, 36, 0.5) 100%),
    linear-gradient(180deg, rgba(20, 36, 52, 0.25) 0%, rgba(8, 12, 18, 0.55) 100%);
}
.dispatch-card--split.dispatch-card--raid .dispatch-card__wash {
  background:
    linear-gradient(90deg, rgba(28, 12, 12, 0.5) 0%, transparent 30%, transparent 70%, rgba(28, 12, 12, 0.5) 100%),
    linear-gradient(180deg, rgba(36, 16, 12, 0.28) 0%, rgba(10, 8, 8, 0.55) 100%);
}
.dispatch-card--raid .dispatch-card__wash {
  animation: dispatch-raid-flash 0.5s ease-out both;
}
.dispatch-card__center {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  width: min(92%, 640px);
  text-align: center;
  z-index: 1;
}
.dispatch-card__vs {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.7em;
  flex-wrap: wrap;
  margin: 0 0 10px;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.dispatch-card__who {
  color: var(--text-ivory);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dispatch-card__who--atk { animation: dispatch-line-in 0.45s ease-out 0.12s both; }
.dispatch-card__who--def { animation: dispatch-line-in 0.45s ease-out 0.32s both; }
.dispatch-card__pip {
  width: 22px;
  height: 16px;
  object-fit: cover;
  image-rendering: auto;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
.dispatch-card__vs-mark {
  animation: dispatch-vs-in 0.4s ease-out 0.26s both;
}
.dispatch-card__place {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(2rem, 6vw, 4.4rem);
  letter-spacing: 0.06em;
  line-height: 1.12;
  color: var(--text-ivory);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.65);
  white-space: normal;
  overflow-wrap: break-word;
  text-wrap: balance;
  animation: dispatch-line-in 0.55s ease-out 0.44s both;
}
.dispatch-card__kind {
  margin: 12px 0 0;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-ivory);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.75);
  animation: dispatch-line-in 0.45s ease-out 0.6s both;
}
.dispatch-card__actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(24px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  z-index: 1;
  animation: dispatch-actions-in 0.55s ease-out 0.72s both;
}
.dispatch-card__skip {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
}
.dispatch-card__skip:hover { color: var(--text-ivory); }
.dispatch-card__next {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-on-gold, #1a1408);
  background: linear-gradient(180deg, var(--accent-gold) 0%, var(--accent-brass) 100%);
  border: 1px solid var(--accent-gold);
  padding: 12px 36px;
  cursor: pointer;
}
.dispatch-card__next:hover { filter: brightness(1.08); }

@keyframes dispatch-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes dispatch-overlay-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes dispatch-flag-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dispatch-line-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dispatch-vs-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 0.55; transform: translateY(0); }
}
@keyframes dispatch-actions-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dispatch-land-in {
  from { opacity: 0; transform: translateY(6%) scale(1.02); }
  to { opacity: 1; transform: translateY(0) scale(1.02); }
}
@keyframes dispatch-land-drift {
  from { transform: translateY(0) scale(1.02); }
  to { transform: translateY(-2.5%) scale(1.05); }
}
@keyframes dispatch-land-out {
  from { clip-path: inset(0); }
  to { clip-path: inset(7% 10%); }
}
@keyframes dispatch-sea-in {
  from { opacity: 0; transform: translateX(-4%) scale(1.02); }
  to { opacity: 1; transform: translateX(0) scale(1.02); }
}
@keyframes dispatch-sea-drift {
  from { transform: translateX(0) scale(1.02); }
  to { transform: translateX(3%) scale(1.04); }
}
@keyframes dispatch-sea-out {
  from { transform: translateY(0); }
  to { transform: translateY(16px); }
}
@keyframes dispatch-raid-in {
  from { opacity: 0; transform: scale(1.12); }
  to { opacity: 1; transform: scale(1.04); }
}
@keyframes dispatch-raid-drift {
  from { transform: scale(1.04) translateY(0); }
  to { transform: scale(1.07) translateY(-1.2%); }
}
@keyframes dispatch-raid-out {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}
@keyframes dispatch-raid-flash {
  0% { opacity: 0.55; filter: brightness(1.4) saturate(1.15); }
  100% { opacity: 1; filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .dispatch-card-overlay,
  .dispatch-card-overlay.is-leaving,
  .dispatch-card__art,
  .dispatch-card--land .dispatch-card__art--bleed,
  .dispatch-card--sea .dispatch-card__art--bleed,
  .dispatch-card--raid .dispatch-card__art--bleed,
  .dispatch-card--raid .dispatch-card__wash,
  .dispatch-card__who--atk,
  .dispatch-card__who--def,
  .dispatch-card__vs-mark,
  .dispatch-card__place,
  .dispatch-card__kind,
  .dispatch-card__actions {
    animation: none !important;
  }
}

@media (max-width: 640px) {
  .dispatch-card--split .dispatch-card__art { width: 100%; height: 46%; }
  .dispatch-card--split .dispatch-card__art--atk { inset: 0 0 auto 0; height: 46%; width: 100%; }
  .dispatch-card--split .dispatch-card__art--def { inset: auto 0 0 0; height: 46%; width: 100%; top: auto; }
  .dispatch-card__art--bleed { inset: 0; width: 100%; height: 100%; background-position: center bottom; }
  .dispatch-card--split .dispatch-card__wash {
    background:
      linear-gradient(180deg, rgba(10, 12, 16, 0.2) 0%, rgba(10, 12, 16, 0.55) 42%, rgba(10, 12, 16, 0.55) 58%, rgba(10, 12, 16, 0.2) 100%);
  }
  .dispatch-card__center { width: calc(100% - 32px); top: 50%; }
}

@container (max-width: 420px) {
  .dispatch-card__place {
    font-size: clamp(1.55rem, 11cqw, 2.15rem);
    letter-spacing: 0.04em;
  }
  .dispatch-card__kind {
    font-size: 0.78rem;
    letter-spacing: 0.12em;
  }
}

/* ==========================================================================
   Move tab — the movement workspace (#3756)
   Token-only; inline styles are reserved for genuinely computed values
   (drag-ghost position, cost-weighted cargo widths).
   ========================================================================== */

.move-workspace {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm);
  font-family: var(--font-ui);
  color: var(--text-ivory);
}

.move-empty {
  padding: var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-ivory-muted);
  line-height: 1.5;
}

.move-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border-brass);
}

.move-title {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-ivory);
}

.move-sub {
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
  font-variant-numeric: tabular-nums;
}

.move-close { margin-left: auto; }

/* Push / pull. This tab moves units OUT of the selected territory; the planner
   moves them IN. Two chips make the split legible instead of implicit. */
.move-modes {
  display: flex;
  gap: var(--space-xs);
  align-items: center;
}
.move-mode {
  padding: 2px var(--space-sm);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
  cursor: pointer;
}
.move-mode.is-on {
  border-color: var(--border-brass);
  background: var(--surface-panel);
  color: var(--text-ivory);
  cursor: default;
}
.move-mode.is-off { opacity: 0.35; cursor: default; }
button.move-mode:hover { border-color: var(--accent-brass); color: var(--text-ivory); }

/* Live legality readout — the drag's running commentary. */
.move-readout {
  /* Fixed two-line box. If this grows when a drag starts (one-line hint →
     two-line refusal), everything below it reflows DOWNWARD mid-gesture and
     the berth the user was aiming at slides out from under the pointer. Drop
     targets must not move during a drag. */
  height: calc(var(--text-sm) * 2.7 + var(--space-sm));
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-primary);
  background: var(--surface-panel);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  line-height: 1.35;
}
.move-readout.is-ok {
  border-color: var(--overlay-bright-green-25);
  background: var(--overlay-bright-green-12);
  color: var(--color-success);
}
.move-readout.is-bad {
  border-color: var(--overlay-crimson-35);
  background: var(--overlay-crimson-08);
  color: var(--color-hit);
}

.move-section-label {
  margin-top: var(--space-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-brass);
}

.move-note {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  padding: var(--space-xs) 0;
}

/* ── Unit rows (variant B) / tiles (variant C) ───────────────────────── */

.move-rows { display: flex; flex-direction: column; gap: 2px; }

.move-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: var(--space-xs);
}

.move-unit {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px var(--space-xs);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-panel);
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  transition: background 0.12s ease-out, border-color 0.12s ease-out;
}
.move-unit:hover { background: var(--surface-hover); border-color: var(--border-brass); }
.move-unit.is-spent { opacity: 0.4; }
.move-unit.is-spent:hover { background: var(--surface-panel); border-color: transparent; }

.move-unit-grab {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex: 1;
  min-width: 0;
  padding: var(--space-xs) 0;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  text-align: left;
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}
.move-unit-grab:active:not(:disabled) { cursor: grabbing; }
.move-unit-grab:disabled { cursor: default; }

/* How many identical units this row holds. The count PICKER opens on drop
   (the shipped DragQuantityPopover), so the row itself only reports size. */
/* Why a listed unit cannot move right now. Installations are filtered out
   entirely; these are real units that are temporarily stuck. */
.move-blocked {
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
  font-style: italic;
}

.move-count {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
  font-variant-numeric: tabular-nums;
}

/* Two numbers sit on every row — transport cost and movement remaining. Bare
   digits side by side are unreadable, so each carries its own glyph. */
.move-badge {
  flex-shrink: 0;
  padding: 0 var(--space-xs);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  background: var(--overlay-dark-30);
}
.move-badge--cap { color: var(--accent-blue); }
.move-badge--mv { color: var(--text-ivory-muted); }

/* A row that can be loaded onto a transport, not just moved. */
.move-unit--cargo { border-left: 2px solid var(--accent-blue); }

.move-unit-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.move-unit-mv {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
}
.move-unit-from { font-size: var(--text-xs); color: var(--accent-blue); }

/* Variant C tiles stack their label under the icon. */
.move--workspace .move-tiles .move-unit {
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-sm) var(--space-xs);
  text-align: center;
}
.move--workspace .move-tiles .move-unit-name {
  font-size: var(--text-xs);
  width: 100%;
}

/* ── Transport berths — the DOM drop targets ─────────────────────────── */

.move-berth {
  padding: var(--space-xs) var(--space-sm);
  border: 1px dashed var(--border-brass);
  border-radius: var(--radius-md);
  background: var(--overlay-ocean-15);
  transition: background 0.12s ease-out, border-color 0.12s ease-out, box-shadow 0.12s ease-out;
}
.move-berth.is-hot-ok {
  border-style: solid;
  border-color: var(--color-success);
  background: var(--overlay-bright-green-12);
  box-shadow: inset 0 0 0 1px var(--overlay-bright-green-25);
}
.move-berth.is-hot-bad {
  border-style: solid;
  border-color: var(--color-hit);
  background: var(--overlay-crimson-08);
}
/* Pre-light: every berth that COULD take the unit now in flight. */
.move-berth.is-eligible {
  border-style: solid;
  border-color: var(--overlay-bright-green-25);
}
.move-berth.is-ineligible { opacity: 0.45; }
.move-berth-why {
  margin-top: var(--space-xs);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-hit);
  line-height: 1.3;
}

.move-berth-head { display: flex; align-items: center; gap: var(--space-xs); }

.move-berth-grab {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex: 1;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  text-align: left;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.move-berth-grab:disabled { opacity: 0.35; cursor: default; }

.move-berth-cap {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
  font-variant-numeric: tabular-nums;
}

.move-bar {
  height: var(--space-xs);
  margin-top: var(--space-xs);
  border-radius: var(--radius-xs);
  background: var(--overlay-dark-30);
  overflow: hidden;
}
.move-bar-fill { display: block; height: 100%; background: var(--accent-blue); }

/* Capacity drawn to scale. This ruleset weights capacity by COST (transport
   cap 5; infantry 2, artillery/armour/mech 3), so a cargo chip is as wide as
   it is expensive and "2/5 loaded" stops being a lie about unit counts. */
.move-cells {
  display: flex;
  gap: 2px;
  margin-top: var(--space-xs);
  align-items: stretch;
  height: var(--space-lg);
}
.move-cell {
  flex-basis: 0;
  border: 1px dashed var(--border-primary);
  border-radius: var(--radius-xs);
  background: var(--overlay-dark-30);
}
/* A loaded unit: the chip itself (draggable, to unload) plus a cancel-load
   affordance. Sized by cost via flex-grow on the wrapper. */
.move-cargo-slot {
  position: relative;
  display: flex;
  flex-basis: 0;
  min-width: 0;
}
.move-cargo-cancel {
  position: absolute;
  top: -6px;
  right: -4px;
  width: var(--space-md);
  height: var(--space-md);
  min-width: 0;
  min-height: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-brass);
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--text-ivory-muted);
  font-size: var(--text-xs);
  line-height: 1;
  cursor: pointer;
}
.move-cargo-cancel:hover {
  border-color: var(--color-hit);
  color: var(--color-hit);
}

.move-cargo-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-xs);
  background: var(--surface-hover);
  color: var(--text-ivory);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.move-cargo-chip:hover { border-color: var(--accent-brass); }
.move-cargo-chip:active { cursor: grabbing; }
.move-cargo-cost {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
}

.move-cargo-tags { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-xs); }
.move-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px var(--space-xs);
  border-radius: var(--radius-xs);
  background: var(--surface-panel);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
}

/* ── The DOM drag ghost ──────────────────────────────────────────────── */
/* Lives in the DOM, not on the pixi canvas: the sidebar stacks above the
   canvas, so a canvas-drawn ghost is occluded exactly where the new DOM drop
   targets live. */
.move-ghost {
  position: fixed;
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-brass);
  background: var(--bg-raised);
  box-shadow: 0 var(--space-xs) var(--space-md) var(--overlay-dark-50);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory);
  pointer-events: none;
  /* Up and to the right of the cursor, so the pill never covers the drop
     target it is describing. */
  transform: translate(var(--space-sm), -120%);
  white-space: nowrap;
}
.move-ghost.is-valid { border-color: var(--color-success); }
.move-ghost.is-invalid { border-color: var(--color-hit); }
.move-ghost-name { font-weight: 600; }
.move-ghost-cost {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent-blue);
}
.move-ghost-target {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
  padding-left: var(--space-xs);
  border-left: 1px solid var(--border-primary);
}

/* ── Variant C: the workspace is wider and full-height. ──────────────── */
.move--workspace { padding: var(--space-md); gap: var(--space-sm); }
.move--workspace .move-title { font-size: var(--text-lg); }
.move--workspace .move-berth { padding: var(--space-sm); }

/* === Defense Profile sheet (#4453) — summary rows, tap to edit ===
   A centred dialog on desktop, a full-screen sheet on phones (either axis).
   One scroll (.defense-sheet__body) for everything; every target >= --tap-min. */
.defense-sheet {
  display: flex;
  flex-direction: column;
  width: 640px;
  max-width: 95vw;
  max-height: 88vh;
  padding: 0;
  overflow: hidden;
  animation: fadeIn 0.2s ease-out;
}
@media (max-width: 640px), (max-height: 500px) {
  .defense-sheet {
    position: fixed;
    inset: 0;
    width: auto;
    max-width: none;
    max-height: none;
    border: 0;
    padding-top: var(--safe-t);
    padding-left: var(--safe-l);
    padding-right: var(--safe-r);
  }
  .defense-sheet .panel-header-dialog { padding-block: var(--space-xs); }
}
.defense-sheet .btn-close-overlay { min-width: var(--tap-min); min-height: var(--tap-min); }
.defense-sheet__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; font-family: var(--font-ui); }
.defense-sheet__foot {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
  padding: var(--space-sm) var(--space-md) calc(var(--space-sm) + var(--safe-b));
  border-top: 1px solid var(--border-brass);
  font-family: var(--font-ui);
}
.defense-sheet__foot .btn-bevel,
.defense-sheet__foot .btn-ghost { min-height: var(--tap-min); padding: 0 var(--space-md); font-size: var(--text-sm); }
.defense-sheet__grow { flex: 1; }
.defense-sheet__confirm { flex: 1; font-size: var(--text-sm); color: var(--text-ivory); }

.defense-caption {
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.defense-powers {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  overflow-x: auto;
  border-bottom: 1px solid var(--border-secondary);
}
/* #5389: nine powers do not fit the sheet. A mouse gets a scrollbar to see and drag; a touch screen swipes. */
@media (pointer: fine) {
  /* The global scrollbar rule sets only a width, so a sideways bar needs its height here. */
  .defense-powers::-webkit-scrollbar { height: var(--space-sm); }
  .defense-powers::-webkit-scrollbar-thumb { background: var(--accent-brass); }
  /* Firefox only: in Chrome these replace the rules above, and macOS then hides the bar until a scroll. */
  @supports not selector(::-webkit-scrollbar) {
    .defense-powers { scrollbar-width: thin; scrollbar-color: var(--accent-brass) var(--bg-tertiary); }
  }
}
@media (pointer: coarse) {
  .defense-powers { scrollbar-width: none; }
  .defense-powers::-webkit-scrollbar { display: none; }
}
.defense-powers__chip {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
  min-height: var(--tap-min);
  padding: 0 var(--space-md);
  font-size: var(--text-sm);
  white-space: nowrap;
}
.defense-powers__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.defense-powers__dot.is-on { background: var(--accent-brass); }

.defense-master {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xs) var(--space-md);
  border-bottom: 1px solid var(--border-secondary);
}
.defense-master__text,
.defense-switch-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.defense-master__title {
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-ivory);
}

.defense-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.defense-switch .toggle-switch { display: inline-block; }

.defense-group {
  padding: var(--space-sm) var(--space-md) 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.defense-section { border-bottom: 1px solid var(--border-secondary); }
.defense-section.is-open { background: var(--bg-rail); border-bottom-color: var(--border-brass); }
.defense-section__row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
  min-height: calc(var(--tap-min) + var(--space-sm));
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: 0;
  color: inherit;
  font-family: var(--font-ui);
  text-align: left;
  cursor: pointer;
}
.defense-section__row:hover .defense-section__chevron { color: var(--text-ivory); }
.defense-section__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.defense-section__title {
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.defense-section__summary { font-size: var(--text-sm); color: var(--text-ivory); }
.defense-section__chevron { color: var(--text-ivory-muted); font-size: var(--text-lg); }
.defense-section__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: 0 var(--space-md) var(--space-md);
}

.defense-segmented { display: flex; gap: var(--space-xs); }
.defense-segmented .options-segment-btn { min-height: var(--tap-min); text-transform: none; }

.defense-switch-row { display: flex; align-items: center; gap: var(--space-md); min-height: var(--tap-min); }
.defense-switch-row__label { font-size: var(--text-sm); color: var(--text-ivory); }

.defense-stepper { display: flex; align-items: center; gap: var(--space-sm); }
.defense-stepper__label { flex: 1; font-size: var(--text-sm); color: var(--text-ivory-muted); }
.defense-stepper .btn-bevel { min-width: var(--tap-min); min-height: var(--tap-min); font-size: var(--text-lg); }
.defense-stepper__value { min-width: 2.5em; text-align: center; font-family: var(--font-mono); font-size: var(--text-base); color: var(--text-ivory); }

.defense-priority { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border-secondary); }
.defense-priority__row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: var(--tap-min);
  background: var(--bg-secondary);
  padding-left: var(--space-sm);
  border-bottom: 1px solid var(--border-secondary);
}
.defense-priority__row:nth-child(even) { background: var(--bg-tertiary); }
.defense-priority__row:last-child { border-bottom: 0; }
.defense-priority__row.is-pinned { opacity: 0.5; font-style: italic; }
.defense-priority__n { width: 1.6em; text-align: right; font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-secondary); }
.defense-priority__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-ivory);
}
.defense-priority__stat { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); white-space: nowrap; padding-right: var(--space-xs); }
.defense-priority__btn {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  background: transparent;
  border: 0;
  border-left: 1px solid var(--border-secondary);
  color: var(--text-ivory-muted);
  font-size: var(--text-sm);
  cursor: pointer;
}
.defense-priority__btn:hover:not(:disabled) { color: var(--text-ivory); }
.defense-priority__btn:disabled { opacity: 0.3; cursor: default; }

/* Saved profiles sub-page (#4045, #4453) */
.defense-library { display: flex; flex-direction: column; gap: var(--space-sm); padding: var(--space-md); }
.defense-library p { margin: 0; }
.defense-library__empty { font-size: var(--text-sm); color: var(--text-ivory-muted); }
.defense-library__list { display: flex; flex-direction: column; gap: var(--space-xs); }
.defense-library__entry { border: 1px solid var(--border-brass); background: var(--bg-raised); }
.defense-library__entry.is-selected { border-color: var(--accent-brass); }
.defense-library__pick {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  min-height: calc(var(--tap-min) + var(--space-xs));
  padding: 0 var(--space-md);
  background: transparent;
  border: 0;
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.defense-library__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.defense-library__actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); padding: 0 var(--space-md) var(--space-md); }
.defense-library__actions .btn-bevel,
.defense-library__save .btn-bevel,
.defense-library__save .btn-ghost { min-height: var(--tap-min); padding: 0 var(--space-md); font-size: var(--text-sm); }
.defense-library__delete:hover:not(:disabled) { color: var(--color-danger); border-color: var(--color-danger); }
.defense-library__save { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: center; }
.defense-library__input { flex: 1; min-width: 0; min-height: var(--tap-min); }

.staff-plans { display: flex; flex-direction: column; gap: var(--space-sm); padding: var(--space-sm); }
.staff-plans p { margin: 0; }
.staff-plans-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); }
.staff-plans-plan { display: flex; flex-direction: column; gap: var(--space-xs); }
.staff-plans-switch { display: flex; gap: var(--space-xs); }
.staff-plans-head > .btn,
.staff-plans-switch .btn { flex: 0 0 auto; }
/* .btn is later than .btn-primary and paints over it. Ask is the mockup's primary control. */
.staff-plans-head > .btn.btn-primary {
  background: var(--btn-bg-primary);
  color: var(--text-ivory);
  border-color: var(--accent-brass);
  font-family: var(--font-ui);
  font-weight: 500;
}
.staff-plans-hint {
  flex: 1 1 6rem;
  min-width: 6rem;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  line-height: 1.3;
  color: var(--text-ivory-muted);
}
.staff-plans-switch .btn[aria-pressed='true'] { border-color: var(--border-brass); color: var(--text-ivory); }
@media (pointer: coarse) {
  .staff-plans-head > .btn,
  .staff-plans-switch .btn {
    min-width: var(--tap-min);
    min-height: var(--tap-min);
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
  }
}
.staff-plans-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  color: var(--text-ivory);
}
.staff-plans-line { font-family: var(--font-ui); font-size: var(--text-xs); color: var(--text-ivory-muted); }
.staff-plans-note { font-family: var(--font-body); font-size: var(--text-sm); color: var(--text-ivory-muted); }
.staff-plans-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin: 0;
  padding: 0;
  list-style: none;
}
.staff-plans-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  width: 100%;
  min-width: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  border: 1px solid var(--border-brass);
  background: var(--bg-ink);
  padding: var(--space-xs) var(--space-sm);
}
.staff-plans-row[aria-expanded='true'] { background: var(--bg-raised); }
.staff-plans-target {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory);
}
.staff-plans-row-odds,
.staff-plans-row-value {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-ivory);
}
.staff-plans-detail { display: flex; flex-direction: column; gap: var(--space-xs); padding: 0 var(--space-sm) var(--space-xs); }
.staff-plans-meta,
.staff-plans-trade,
.staff-plans-from {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
}
.staff-plans-origin { display: flex; flex-direction: column; gap: var(--space-xs); }
.staff-plans-units { display: flex; flex-wrap: wrap; gap: var(--space-xs); align-items: center; }
.staff-plans-unit { display: inline-flex; align-items: center; gap: var(--space-xs); }
.staff-plans-count { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-ivory); }
.staff-plans-left { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
/* Ask Staff on the Your orders heading (#5328). The round selector keeps the 26px .plan-dd. */
.staff-ask { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 0; }
.staff-ask__confirm { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; max-width: 16rem; }
.staff-ask__confirm-acts { display: flex; gap: 4px; }
.staff-ask .plan-dd__menu { left: auto; right: 0; }
.staff-ask .staff-plans-note { text-align: right; }
.staff-ask .plan-dd:disabled { opacity: 0.55; cursor: not-allowed; }
@media (pointer: coarse) {
  .staff-ask .plan-dd,
  .staff-ask .plan-dd__item,
  .staff-ask__confirm-acts .plan-btn--tap {
    min-height: var(--tap-min);
    min-width: var(--tap-min);
  }
}

/* Carrier commitments (#4105) — list in the movement panel and the combat confirm. */
/* #4719: passive hint while a plane is dragged with an unmarked bought carrier. */
.shadow-drag-hint {
  position: fixed;
  top: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  pointer-events: none;
  max-width: calc(100vw - var(--space-lg) * 2);
}

.carrier-commitments {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
  padding: var(--space-sm);
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  color: var(--text-ivory);
}
.carrier-commitments-title {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-ivory);
}
.carrier-commitment-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-sm);
}
.carrier-commitment-meta {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
}
.carrier-commitment-row--warning {
  color: var(--text-warning);
}
.carrier-refusal {
  font-size: var(--text-xs);
  margin-bottom: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-red-bright);
  font-family: var(--font-body);
}
.carrier-refusal-title {
  color: var(--color-danger);
  font-weight: 700;
  font-family: var(--font-ui);
}
.carrier-refusal-line {
  color: var(--text-ivory);
  margin-top: var(--space-xs);
}
.carrier-refusal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
}
.carrier-refusal-extra {
  color: var(--color-warning-error);
  margin-top: var(--space-xs);
}
/* #4229: "85% · you −12 · them −20 IPC" — one line, clipped on a narrow phone. */
.attack-odds-line {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: var(--space-xs);
}
.owed-carrier-modal-body {
  padding: var(--space-md) var(--space-lg);
}
.owed-carrier-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-sm) var(--space-lg) var(--space-md);
  border-top: 1px solid var(--border-primary);
}
.seat-evicted-modal__body {
  padding: var(--space-md) var(--space-lg);
}
.seat-evicted-modal__text {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-ivory);
}
.seat-evicted-modal__footer {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-sm) var(--space-lg) var(--space-md);
  border-top: 1px solid var(--border-primary);
}
.seat-evicted-modal__footer .btn { min-height: var(--tap-min); }
.air-crash-plan-failed {
  color: var(--accent-red-bright);
  font-family: var(--font-body);
  font-size: var(--text-sm);
}

/* === Battle result card (end of battle) ===
 * --result-color is the winner's nation colour (draw: muted). It paints the
 * border and wash only; the headline stays ivory/gold so it reads on near-black. */
.battle-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  flex: 1;
}
.battle-result__card {
  padding: var(--space-xl) 3rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--result-color) 30%, transparent),
    color-mix(in srgb, var(--result-color) 15%, transparent)
  );
  border: 2px solid var(--result-color);
  text-align: center;
  transform: scale(1.2);
  transform-origin: center center;
}
.battle-result__card--draw {
  background: linear-gradient(180deg, var(--overlay-battle-draw-1), var(--overlay-battle-draw-2));
}
.battle-result__headline {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: bold;
  color: var(--accent-gold);
  text-shadow: 0 2px 4px var(--overlay-dark-60);
  margin-bottom: var(--space-sm);
}
.battle-result__damage {
  font-size: max(var(--text-sm), var(--text-battle-floor));
  color: var(--accent-gold);
  margin-bottom: var(--space-sm);
}
.battle-result__losses {
  margin-top: var(--space-md);
  font-size: var(--text-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.battle-result__row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.battle-result__who {
  color: var(--text-ivory);
  font-weight: bold;
  border-bottom: 2px solid var(--side-color);
}
.battle-result__unit {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--text-primary);
}
.battle-result__ipc {
  margin-top: var(--space-xs);
  text-align: center;
  font-size: max(var(--text-sm), var(--text-battle-floor));
  color: var(--text-secondary);
}

/* === Battle luck meter (#4759) ==========================================
 * Log-odds track: centre = typical, each end = 1 battle in 200. The shaded
 * band is the common middle (between 1 in 3 either way); ticks mark 1 in 10
 * and 1 in 100. Used on the result card and, compact, in the Film. */
.luck-meter {
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-accent);
  text-align: left;
  font-size: max(var(--text-sm), var(--text-battle-floor));
  color: var(--text-ivory);
  max-width: 28rem;
}
.luck-meter--compact { margin-top: var(--space-sm); font-size: var(--text-xs); max-width: none; }
.luck-meter__title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  text-align: center;
}
.luck-meter__track {
  position: relative;
  height: 0.6rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--luck-them) 45%, transparent),
    var(--surface-mid) 40%, var(--surface-mid) 60%,
    color-mix(in srgb, var(--luck-me) 45%, transparent));
  border: 1px solid var(--border-primary);
}
.luck-meter__band { position: absolute; top: 0; bottom: 0; background: var(--border-accent); }
.luck-meter__tick {
  position: absolute; top: 0; bottom: 0; width: 1px;
  transform: translateX(-50%);
  background: var(--text-muted);
}
.luck-meter__marker {
  position: absolute; top: -0.3rem; bottom: -0.3rem; width: 0.25rem;
  transform: translateX(-50%);
  border-radius: var(--radius-xs);
  background: var(--accent-gold);
  box-shadow: 0 0 0 1px var(--overlay-dark-60);
}
.luck-meter__ends {
  display: flex; justify-content: space-between; gap: var(--space-sm);
  margin-top: var(--space-xs);
  font-size: var(--text-xs); color: var(--text-muted);
}
.luck-meter__verdict { margin-top: var(--space-xs); line-height: 1.35; }
.luck-meter__side {
  margin-top: var(--space-xs);
  padding-left: var(--space-sm);
  border-left: 3px solid var(--side-color);
  line-height: 1.35;
  color: var(--text-primary);
}

/* === Reports → Luck ledger (#4759) ===================================== */
.luck-ledger { display: flex; flex-direction: column; gap: var(--space-sm); color: var(--text-primary); }
.luck-ledger__intro, .luck-ledger__empty { margin: 0 0 var(--space-xs); font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.4; }
.luck-ledger__row {
  display: grid;
  grid-template-columns: minmax(7rem, 9rem) 1fr minmax(8rem, 11rem);
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-left: 3px solid var(--side-color);
  background: var(--surface-card);
  border-radius: var(--radius-sm);
}
.luck-ledger__who { display: flex; align-items: center; gap: var(--space-xs); font-size: var(--text-sm); color: var(--text-ivory); }
.luck-ledger__chart { display: block; width: 100%; height: 3rem; }
.luck-ledger__band { fill: var(--border-accent); }
.luck-ledger__zero { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.luck-ledger__line { fill: none; stroke: var(--side-color); stroke-width: 2; vector-effect: non-scaling-stroke; }
.luck-ledger__total { display: flex; flex-direction: column; font-size: var(--text-xs); color: var(--text-secondary); }
.luck-ledger__total b { font-size: var(--text-base); color: var(--text-ivory); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .luck-ledger__row { grid-template-columns: 1fr auto; }
  .luck-ledger__chart { grid-column: 1 / -1; grid-row: 2; }
  .luck-ledger__total { align-items: flex-end; text-align: right; }
}

/* === Phone battle view — one row per unit type (#4203) ===================
 * Replaces the tilted board's body on phones (short side ≤ 500px). Attacker
 * rows on the left half, defender rows mirrored on the right, a spine in the
 * middle. Portrait: thin spine, caption on top, buttons in a bottom bar.
 * Landscape: the spine widens into a centre column that holds the caption,
 * the hits-left count and the buttons, like the reference layout. */
/* Portrait reserves: the caption can run four lines (step, auto-defense,
 * status, retreat odds) and the retreat dock wraps to two rows. Portrait
 * has the height to spare. */
.combat-root--phone {
  --phone-caption-h: 6.25rem;
  --phone-center-w: 34vw;
  /* Landscape: everything that must not sit under the buttons stays above
   * this line (the bar's 20vh lift + one 44px button + a gap). */
  --phone-land-dock-clear: calc(20vh + 3.25rem + var(--space-sm) + var(--safe-b));
}
/* Opaque (the paused map behind would show its seams through the rows).
 * Backdrop (#4211): the battle's dispatch plate, the art the transition card
 * just showed (land / sea / raid; PhoneBattleRows sets --rows-plate*), muted
 * (ink-tinted, under a wash) so the rows stay the subject, with the lobby's brass
 * chart grid over it. Wide plate side by side, tall plate in portrait. */
.combat-root.combat-root--phone {
  --rows-plate-now: var(--rows-plate-wide, none);
  background:
    repeating-linear-gradient(90deg, transparent 0 79px, var(--border-brass-grid) 79px 80px),
    repeating-linear-gradient(0deg, transparent 0 79px, var(--border-brass-grid) 79px 80px),
    linear-gradient(180deg, color-mix(in srgb, var(--bg-ink) 94%, transparent), color-mix(in srgb, var(--bg-ink) 88%, transparent)),
    var(--rows-plate-now) center / cover no-repeat,
    var(--bg-ink);
  /* The plate takes the ink's hue: a monochrome texture, not a picture. */
  background-blend-mode: normal, normal, normal, luminosity, normal;
}
@media (orientation: portrait) {
  .combat-root.combat-root--phone { --rows-plate-now: var(--rows-plate, none); }
}
.phone-battle {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2.75rem minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  gap: var(--space-xs);
  padding:
    var(--phone-caption-h)
    calc(var(--space-xs) + var(--safe-r))
    /* --phone-dock-h is the measured button bar (PhoneBattleRows). */
    calc(var(--phone-dock-h, 4.25rem) + var(--space-sm) + var(--safe-b))
    calc(var(--space-xs) + var(--safe-l));
  font-family: var(--font-ui);
}
.phone-battle--landscape {
  grid-template-columns: minmax(0, 1fr) var(--phone-center-w) minmax(0, 1fr);
  padding-top: var(--space-xs);
  padding-bottom: calc(var(--space-xs) + var(--safe-b));
}

.phone-battle__side { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.phone-battle__side-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
  padding: 0 var(--space-xs) var(--space-xs);
  border-bottom: 2px solid var(--overlay-gold-15);
}
.phone-battle__side--def .phone-battle__side-head { flex-direction: row-reverse; }
.phone-battle__side.is-active .phone-battle__side-head { border-bottom-color: var(--phone-side-color); }
.phone-battle__nation {
  font-family: var(--font-heading);
  font-size: max(var(--text-sm), var(--text-battle-floor));
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-ivory);
}
.phone-battle__role { font-size: max(var(--text-sm), var(--text-battle-floor)); color: var(--text-muted); }

.phone-battle__rows {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  overscroll-behavior: contain;
}
/* Scroll cue: rows fade out at an edge with more rows past it (classes from
 * useScrollEdges). A mask, not painted covers, so the backdrop shows through
 * (#4211); the mask colour only supplies alpha. */
.phone-battle__rows.is-more-above { -webkit-mask-image: linear-gradient(to bottom, transparent, var(--bg-ink) 2rem); mask-image: linear-gradient(to bottom, transparent, var(--bg-ink) 2rem); }
.phone-battle__rows.is-more-below { -webkit-mask-image: linear-gradient(to top, transparent, var(--bg-ink) 2rem); mask-image: linear-gradient(to top, transparent, var(--bg-ink) 2rem); }
.phone-battle__rows.is-more-above.is-more-below {
  -webkit-mask-image: linear-gradient(to bottom, transparent, var(--bg-ink) 2rem, var(--bg-ink) calc(100% - 2rem), transparent);
  mask-image: linear-gradient(to bottom, transparent, var(--bg-ink) 2rem, var(--bg-ink) calc(100% - 2rem), transparent);
}
.phone-battle__row { border-bottom: 1px solid var(--overlay-gold-08); }
.phone-battle__row-body {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  align-items: center;
  gap: var(--space-xs);
  min-height: 3.25rem;
  padding: var(--space-xs) 0;
}
.phone-battle__side--def .phone-battle__row-body { grid-template-columns: minmax(0, 1fr) 2.75rem; }
/* Portrait root is a flex column: the rows take the height. The legacy
 * portrait nation row reserves a 136px band for floating buttons; here the
 * buttons are one measured bar, so the row floats just above it instead. */
.combat-root--phone-portrait .phone-battle { flex: 1 1 auto; }
.combat-root--phone-portrait .combat-aa42-nation-row {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--phone-dock-h, 4.25rem) + var(--space-sm) + var(--safe-b));
  min-height: 0;
  padding-bottom: 0;
}
/* The nation row's centre cell holds the decision panels (scramble,
 * kamikaze, bombardment, interceptors) whose buttons live in the phone bar.
 * Keep the panel above the bar and scroll it when it's taller than the room.
 * Landscape: the bar sits in the centre column, so the panel does too. */
.combat-root--phone .combat-aa42-nation-row {
  max-height: calc(100% - var(--phone-caption-h) - var(--phone-dock-h, 4.25rem));
  overflow-y: auto;
}
.combat-root--phone-landscape .combat-aa42-nation-row {
  left: 50%;
  right: auto;
  bottom: var(--phone-land-dock-clear);
  width: var(--phone-center-w);
  transform: translateX(-50%);
  grid-template-columns: 0 minmax(0, 1fr) 0;
  /* The centre cell's side padding overhangs a 34vw column by ~20px; clip
   * it rather than show a sideways scrollbar. */
  overflow-x: hidden;
  min-height: 0;
  max-height: calc(100% - 7rem - var(--phone-land-dock-clear));
}

.phone-battle__side--def .phone-battle__icon { order: 2; }
.phone-battle__side--def .phone-battle__main { order: 1; align-items: flex-end; text-align: right; }
.phone-battle__row.is-editable .phone-battle__row-body { cursor: pointer; }
.phone-battle__row-body:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: -2px; }
.phone-battle__row.is-marked { background: var(--overlay-danger-15); }
.phone-battle__row.is-dimmed { opacity: 0.4; }
.phone-battle__row.is-gone .phone-battle__icon { opacity: 0.45; }

.phone-battle__icon { position: relative; display: flex; justify-content: center; }
/* Light plate + rim light (#4211): a soft pale disc behind each piece and a
 * pale outline traced around it, so dark pieces (Germany's near-black
 * plastic) read against the backdrop. All nations. */
.phone-battle__icon::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 112%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--text-ivory) 30%, transparent),
    color-mix(in srgb, var(--text-ivory) 10%, transparent) 55%,
    transparent 72%
  );
  pointer-events: none;
}
.phone-battle__icon img {
  position: relative;
  filter:
    drop-shadow(0 0 1px color-mix(in srgb, var(--text-ivory) 95%, transparent))
    drop-shadow(0 0 5px color-mix(in srgb, var(--text-ivory) 35%, transparent));
}
.phone-battle__count {
  position: absolute;
  right: 0;
  bottom: calc(-1 * var(--space-xs));
  padding: 0 var(--space-xs);
  border-radius: var(--radius-sm);
  background: var(--bg-ink);
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: max(var(--text-sm), var(--text-battle-floor));
  font-weight: 700;
  line-height: 1.2;
}
/* The rank grid's ½ damage badge, moved to the top-left: ×N owns the bottom-right. */
.phone-battle__icon .combat-aa42-chip-damage { top: -4px; left: 0; bottom: auto; right: auto; }
/* Seaborne anchor (#4891): bottom-left of the piece, clear of the ½ badge. */
.phone-battle__icon .combat-aa42-chip-amphi { bottom: 0; left: 0; z-index: 10; }
/* The piece stands on its denomination chips (#4222): seat it on the row's
 * baseline, and keep ×N and the badges above the chip discs (UnitChipStack
 * stacks its discs up to z-index chips + 2). */
.phone-battle__icon--chips { align-items: flex-end; }
.phone-battle__icon--chips .phone-battle__count,
.phone-battle__icon--chips .phone-battle__lost-badge,
.phone-battle__icon--chips .combat-aa42-chip-damage { z-index: 10; }
/* Mobilization stacks (#4272): the Rows battle board's piece-on-chips + ×N, one per bought type. */
.mobilization-stacks { display: flex; flex-direction: column; gap: var(--space-xs); }
.mobilization-stacks__grid { display: flex; flex-wrap: wrap; gap: var(--space-sm); padding: var(--space-xs); }
.mobilization-stacks__label {
  display: flex; align-items: center; gap: var(--space-xs);
  padding: var(--space-sm) var(--space-sm) 0;
  font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
}
.mobilization-stacks__label--europe { color: var(--accent-blue); }
.mobilization-stacks__label--pacific { color: var(--accent-amber); }
.mobilization-stacks__empty { padding: var(--space-sm); font-size: var(--text-sm); color: var(--text-secondary); }
.mobilization-stack {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-xs);
  min-width: 64px; padding: var(--space-sm) var(--space-sm) var(--space-xs);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-primary);
  touch-action: none; -webkit-touch-callout: none;
}
button.mobilization-stack { cursor: pointer; }
button.mobilization-stack[aria-pressed="true"] { border-color: var(--accent-brass); background: var(--surface-hover); }
.mobilization-stack.is-exhausted { opacity: 0.4; cursor: default; }
.mobilization-stack__name { font-size: var(--text-xs); color: var(--text-secondary); text-align: center; }
/* Removed casualties slide off the screen edge (#4222). RemovalSlides draws
 * the ghost in .combat-root (full screen, no clip) over its row; an emptied
 * row keeps its slot while its piece leaves, then folds away. */
.phone-battle__slide {
  position: fixed;
  z-index: 11;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.phone-battle__slide .phone-battle__icon { width: 100%; }
.phone-battle__slide--large .phone-battle__count { font-size: var(--rows-text); }
.phone-battle__row.is-leaving { max-height: 14rem; }
.phone-battle__row.is-leaving .phone-battle__main,
.phone-battle__row.is-leaving .phone-battle__count { visibility: hidden; }
.phone-battle__row.is-collapsing { overflow: hidden; animation: phoneRowCollapse 250ms ease-in forwards; }
@keyframes phoneRowCollapse { to { max-height: 0; opacity: 0; padding: 0; border-width: 0; } }
@media (prefers-reduced-motion: reduce) {
  .phone-battle__row.is-collapsing { animation: none; }
}
.phone-battle__main { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-xs); min-width: 0; }
.phone-battle__name {
  display: flex;
  gap: var(--space-xs);
  align-items: baseline;
  max-width: 100%;
  font-size: max(var(--text-sm), var(--text-battle-floor));
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.phone-battle__power { font-family: var(--font-mono); font-size: max(var(--text-sm), var(--text-battle-floor)); font-weight: 400; color: var(--text-muted); }
/* Shore bombardment tag (#4892): the ship fires from offshore, it is not in the battle. */
.phone-battle__bombard { color: var(--text-secondary); white-space: nowrap; }
/* The row's nation, when a side has more than one (#4893). */
.phone-battle__owner { font-size: max(var(--text-xs), var(--text-battle-floor)); font-weight: 400; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* Gaps leave room for each die's corner badge. */
.phone-battle__dice { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 10px; padding: 5px 6px 0 0; }
.phone-battle__die-group { position: relative; display: inline-flex; }
/* The rank grid's ×N badge, shrunk for phone dice: text stays at the 11px
 * floor, the pill loses its padding and sits mostly off the die's corner. */
.phone-battle__die-count {
  position: absolute;
  top: -7px;
  right: -9px;
  z-index: 2;
  pointer-events: none;
  padding: 0 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-ink);
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-battle-floor);
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}
.phone-battle__die-count.is-hit { color: var(--color-hit); }
/* Landscape is ~340px tall: name and dice (or stepper) share a line so five
 * unit types fit without scrolling. Defender mirrors: name nearest the icon. */
.phone-battle--landscape .phone-battle__row-body { min-height: 2.75rem; padding: 2px 0; }
/* The name gets a fixed slot beside the icon so every row's stepper and dice
 * start on the same line: left-aligned for the attacker, right-aligned for
 * the mirrored defender. */
.phone-battle--landscape .phone-battle__main {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  align-items: center;
  column-gap: var(--space-sm);
}
.phone-battle--landscape .phone-battle__main > :not(.phone-battle__name) { justify-self: start; }
.phone-battle--landscape .phone-battle__side--def .phone-battle__main { grid-template-columns: minmax(0, 1fr) 5.5rem; }
.phone-battle--landscape .phone-battle__side--def .phone-battle__name { grid-column: 2; grid-row: 1; justify-content: flex-end; }
.phone-battle--landscape .phone-battle__side--def .phone-battle__main > :not(.phone-battle__name) { grid-column: 1; grid-row: 1; justify-self: end; }
.phone-battle__side--def .phone-battle__dice { justify-content: flex-end; }

/* The side's hit total, at the inner end of its header (toward the spine). */
.phone-battle__hits {
  margin-left: auto;
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-muted);
}
.phone-battle__side--def .phone-battle__hits { margin-left: 0; margin-right: auto; }
.phone-battle__hits.is-hot { color: var(--color-hit); }

.phone-battle__stepper { display: inline-flex; align-items: center; gap: 2px; }
.phone-battle__step {
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--overlay-gold-25);
  background: var(--surface-mid);
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: 700;
  cursor: pointer;
}
.phone-battle__step:disabled { opacity: 0.3; cursor: default; }
.phone-battle__step:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 1px; }
.phone-battle__step-n {
  min-width: 1.25rem;
  text-align: center;
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-muted);
}
.phone-battle__step-n.is-hot { color: var(--color-hit); }

/* The spine: a hairline between the halves; in a casualty step it carries
 * the hits still to assign. */
.phone-battle__spine { position: relative; display: flex; align-items: center; justify-content: center; }
.phone-battle__spine::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  border-left: 1px solid var(--overlay-gold-25);
}
.phone-battle--landscape .phone-battle__spine::before { display: none; }
.phone-battle__open {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-xs) 0;
  /* Transparent over the backdrop (#4211). */
  background: none;
  text-align: center;
}
.phone-battle__open-n {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1;
  color: var(--color-hit);
}
.phone-battle--landscape .phone-battle__open-n { font-size: calc(var(--text-2xl) * 2); }
.phone-battle__open.is-done .phone-battle__open-n { color: var(--accent-gold); }
.phone-battle__open-label { font-size: max(var(--text-sm), var(--text-battle-floor)); color: var(--text-secondary); line-height: 1.1; }

.phone-battle__lost {
  margin: var(--space-xs) 0 0;
  padding: 0 var(--space-xs);
  font-size: max(var(--text-sm), var(--text-battle-floor));
  color: var(--text-secondary);
}
.phone-battle__side--def .phone-battle__lost { text-align: right; }

/* The defender's casualty area (#4808): its general-combat losses, still
 * firing, under a red rule until they leave with the attacker's losses. */
.phone-battle__area {
  flex: 0 0 auto;
  margin-top: var(--space-xs);
  border-top: 1px dashed var(--accent-red);
}
.phone-battle__area-head {
  margin: 0;
  padding: var(--space-xs) var(--space-xs) 0;
  color: var(--accent-red);
  font-size: max(var(--text-sm), var(--text-battle-floor));
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.phone-battle__side--def .phone-battle__area-head { text-align: right; }
.phone-battle__rows--area { flex: 0 0 auto; overflow: visible; }
.phone-battle__rows--area .phone-battle__row { opacity: 0.85; }
/* A piece on its way in: the sliding ghost stands in for it until it lands. */
.phone-battle__row.is-arriving .phone-battle__icon { visibility: hidden; }

/* Caption + status: let lines wrap on a phone instead of running off. In
 * landscape they sit in the centre column. */
.combat-root--phone .combat-center-status .combat-action-caption,
.combat-root--phone .combat-center-status__line { white-space: normal; max-width: none; }
.combat-root--phone-portrait .combat-center-status { width: calc(100vw - 2 * var(--space-sm)); }
.combat-root--phone-landscape .combat-center-status { width: var(--phone-center-w); max-width: var(--phone-center-w); }

/* Buttons: one bar, kept off the bottom centre where a tap or swipe lands
 * on Safari's tab bar / home indicator instead. Portrait: right-aligned
 * across the width, wrapping upward for a retreat. Landscape: in the centre
 * column, lifted clear of the bottom 20% of the screen. */
.combat-root--phone .combat-action-dock {
  inset: auto;
  left: calc(var(--space-sm) + var(--safe-l));
  right: calc(var(--space-sm) + var(--safe-r));
  bottom: calc(var(--space-sm) + var(--safe-b));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-sm);
}
.combat-root--phone-landscape .combat-action-dock {
  left: 50%;
  right: auto;
  bottom: calc(20vh + var(--safe-b));
  width: var(--phone-center-w);
  transform: translateX(-50%);
  justify-content: center;
}
.combat-root--phone .combat-action-secondary-cluster,
.combat-root--phone .combat-action-primary-region {
  position: static;
  max-width: none;
  pointer-events: auto;
}
.combat-root--phone .combat-action-primary { position: static; min-width: 0; }

/* Landscape result on a tablet or desktop: DONE stays in the dock, and the
 * card pads clear of it. Drops the 1.2x scale. Phones override this below
 * (#5490) — the same class is on every landscape root, including rows-large. */
.combat-root--phone-landscape .battle-result {
  padding: 2.25rem var(--space-md) var(--phone-land-dock-clear);
}
.combat-root--phone-landscape .battle-result__card {
  transform: none;
  padding: var(--space-md) var(--space-xl);
}
/* Phone result, both orientations (#5490). DONE is in the flow, directly
 * under the card, not in the dock. The card fills the space above the button
 * and scrolls its own text when a long summary does not fit. The button does
 * not scroll away. The empty nation row must not sit on top of that button.
 *
 * `1fr` is minmax(auto, 1fr): a long card's min-content becomes the row's
 * minimum, the row spills past the screen, and the spill is clipped with
 * nothing to scroll (Safari). minmax(0, 1fr) lets the row shrink. The card
 * uses flex-basis 0 so WebKit gives it a definite height and overflow-y
 * actually scrolls; flex-basis auto clips the text instead. */
.combat-root--phone:not(.combat-root--rows-large).combat-root--result {
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}
.combat-root--phone:not(.combat-root--rows-large) .battle-result {
  flex: 1 1 auto;
  align-self: stretch;
  min-height: 0;
  max-height: 100%;
  justify-content: flex-start;
  align-items: center;
  overflow: hidden;
  margin-bottom: 0;
  padding: var(--space-xs) var(--space-md) calc(var(--space-xs) + var(--safe-b));
}
.combat-root--phone-landscape.combat-root--phone:not(.combat-root--rows-large) .battle-result {
  /* The "Battle Complete" caption is absolute and sits in this padding.
   * Shorter than the tablet dock pad: the headline starts just under the
   * caption, and the card keeps the rest of the height for the summary. */
  padding-top: 1.35rem;
}
.combat-root--phone:not(.combat-root--rows-large) .battle-result__card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  flex: 1 1 0%;
  min-height: 0;
  width: min(100%, 36rem);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-gold) transparent;
  transform: none;
  /* No top pad: the landscape caption already sits in the result's padding,
   * and a long summary needs that line for the last luck row. */
  padding: 0 var(--space-md) var(--space-xs);
}
.combat-root--phone:not(.combat-root--rows-large) .battle-result__headline {
  margin-bottom: 0;
}
.combat-root--phone:not(.combat-root--rows-large) .battle-result__card::-webkit-scrollbar {
  width: 6px;
}
.combat-root--phone:not(.combat-root--rows-large) .battle-result__card::-webkit-scrollbar-thumb {
  background: var(--accent-gold);
  border-radius: var(--radius-sm);
}
.combat-root--phone:not(.combat-root--rows-large) .battle-result__losses {
  margin-top: var(--space-xs);
  gap: var(--space-xs);
}
.combat-root--phone:not(.combat-root--rows-large) .luck-meter {
  margin-top: 0;
  padding-top: var(--space-xs);
}
.combat-root--phone:not(.combat-root--rows-large) .luck-meter__verdict,
.combat-root--phone:not(.combat-root--rows-large) .luck-meter__side {
  margin-top: var(--space-xs);
}
.combat-root--phone:not(.combat-root--rows-large) .battle-result__actions {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  width: min(100%, 36rem);
  margin-top: var(--space-xs);
  pointer-events: auto;
}
.combat-root--phone:not(.combat-root--rows-large) .battle-result__actions .combat-action-primary {
  position: static;
  right: auto;
  bottom: auto;
  min-height: var(--tap-min);
}
.combat-root--phone:not(.combat-root--rows-large).combat-root--result .combat-aa42-nation-row {
  pointer-events: none;
}

/* Phone landscape on a real iPhone loses ~47px a side to Safari's safe-area
 * insets, so the halves need the width: a narrower centre column with
 * smaller narration, a tighter icon/name slot, and compact buttons. −/+ keep
 * their 44px targets. (#4203) */
.combat-root--phone-landscape { --phone-center-w: 27vw; }
.combat-root--phone-landscape .combat-center-status .combat-action-caption { font-size: var(--text-base); }
.combat-root--phone-landscape .combat-center-status__line,
.combat-root--phone-landscape .combat-banner-odds {
  font-size: max(var(--text-sm), var(--text-battle-floor));
}
.combat-root--phone-landscape .phone-battle__open-n { font-size: calc(var(--text-2xl) * 1.4); }
.phone-battle--landscape .phone-battle__row-body,
.phone-battle--landscape .phone-battle__row.is-editable .phone-battle__row-body { grid-template-columns: 2.25rem minmax(0, 1fr); }
.phone-battle--landscape .phone-battle__side--def .phone-battle__row-body,
.phone-battle--landscape .phone-battle__side--def .phone-battle__row.is-editable .phone-battle__row-body { grid-template-columns: minmax(0, 1fr) 2.25rem; }
.phone-battle--landscape .phone-battle__main { grid-template-columns: 4.75rem minmax(0, 1fr); column-gap: var(--space-xs); }
.phone-battle--landscape .phone-battle__side--def .phone-battle__main { grid-template-columns: minmax(0, 1fr) 4.75rem; }
.combat-root--phone-landscape .combat-action-dock .combat-action-primary,
.combat-root--phone-landscape .combat-action-dock .combat-action-secondary {
  min-width: 0;
  min-height: 44px;
  padding: 0 var(--space-sm);
  font-size: max(var(--text-sm), var(--text-battle-floor));
  letter-spacing: 0.05em;
}
.combat-root--phone-landscape .combat-action-dock { gap: var(--space-xs); }

/* Phone scramble: the planes are defender rows (tap to tick); the panel's
 * header and description crowd out the list, so hide it. Its Skip /
 * Scramble selected buttons are portaled into the bar and stay. (#4203) */
.combat-root--phone .scramble-panel { display: none; }
button.phone-battle__row-body {
  width: 100%;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
}
.phone-battle__row--scramble .phone-battle__row-body { grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem; }
.phone-battle__side--def .phone-battle__row--scramble .phone-battle__row-body { grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem; }
.phone-battle__side--def .phone-battle__row--scramble .phone-battle__icon { order: 3; }
.phone-battle__side--def .phone-battle__row--scramble .phone-battle__main { order: 2; }
.phone-battle__side--def .phone-battle__row--scramble .phone-battle__check { order: 1; }
.phone-battle--landscape .phone-battle__row--scramble .phone-battle__main { display: flex; flex-direction: column; align-items: flex-start; }
.phone-battle--landscape .phone-battle__side--def .phone-battle__row--scramble .phone-battle__main { align-items: flex-end; }
/* Scramble candidates read as a choice over the backdrop (#4211): a labelled
 * group of ink cards with a gold edge on the outer side; a picked plane
 * turns gold. */
.phone-battle__scramble-head {
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-top: 1px solid var(--accent-gold);
  color: var(--accent-gold);
  font-size: max(var(--text-sm), var(--text-battle-floor));
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.phone-battle__side--def .phone-battle__scramble-head { text-align: right; }
.phone-battle__row--scramble {
  margin-bottom: 2px;
  border-bottom: 0;
  border-left: 3px solid var(--accent-gold);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(var(--overlay-gold-08), var(--overlay-gold-08)),
    color-mix(in srgb, var(--bg-ink) 82%, transparent);
}
.phone-battle__side--def .phone-battle__row--scramble { border-left: 0; border-right: 3px solid var(--accent-gold); }
.phone-battle__row--scramble.is-picked { background: color-mix(in srgb, var(--accent-gold) 24%, var(--bg-ink)); }
.phone-battle__from { font-size: max(var(--text-sm), var(--text-battle-floor)); color: var(--text-secondary); }
.phone-battle__check {
 
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent-gold);
  background: var(--bg-ink);
  color: var(--bg-ink);
  font-size: var(--text-base);
  font-weight: 700;
}
.phone-battle__check.is-on { background: var(--accent-gold); }

/* Casualty step: −/+ then the row's dice, wrapping when there's no room.
 * The defender mirrors so −/+ stays next to the name. (#4203) */
.phone-battle__act { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-sm); }
.phone-battle__side--def .phone-battle__act { flex-direction: row-reverse; }
/* Side by side (phone landscape, tablet, desktop): −/+ sits at the inner
 * edge, by the centre column's hits left and buttons, so a side's steppers
 * form one column. The side picking losses has no dice of its own up by
 * then (the defender picks before it rolls; the attacker's are spent), so
 * the dice slot by the name is usually empty. (#4211) */
.phone-battle--landscape .phone-battle__side .phone-battle__main > .phone-battle__act { justify-self: stretch; }
.phone-battle--landscape .phone-battle__act,
.phone-battle--landscape .phone-battle__side--def .phone-battle__act { flex-direction: row; }
.phone-battle--landscape .phone-battle__act .phone-battle__stepper { order: 2; margin-left: auto; }
.phone-battle--landscape .phone-battle__side--def .phone-battle__act .phone-battle__stepper { order: 0; margin-left: 0; margin-right: auto; }
.phone-battle--landscape .phone-battle__side--def .phone-battle__act .phone-battle__dice { order: 1; }

/* === Phone portrait: stacked sides (#4203) ================================
 * Opponent on top, your side at the bottom by the buttons, a divider between
 * them. Rows run the full width, unmirrored: icon · name · dice · −/+ at the
 * right edge. Rows take only their own height; the page scrolls if a battle
 * has more unit types than fit. */
.phone-battle.phone-battle--portrait {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-top: var(--space-xs);
}
.phone-battle--portrait .phone-battle__side { flex: 0 0 auto; }
.phone-battle--portrait .phone-battle__rows { flex: none; overflow: visible; background: none; }
.phone-battle--portrait .phone-battle__row-body,
.phone-battle--portrait .phone-battle__side--def .phone-battle__row-body { grid-template-columns: 2.75rem minmax(0, 1fr); min-height: 3.25rem; }
.phone-battle--portrait .phone-battle__side--def .phone-battle__icon { order: 0; }
.phone-battle--portrait .phone-battle__main,
.phone-battle--portrait .phone-battle__side--def .phone-battle__main {
  order: 0;
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  align-items: center;
  column-gap: var(--space-sm);
  text-align: left;
}
.phone-battle--portrait .phone-battle__side--def .phone-battle__dice { justify-content: flex-start; }
.phone-battle--portrait .phone-battle__act,
.phone-battle--portrait .phone-battle__side--def .phone-battle__act { flex-direction: row; justify-content: space-between; }
.phone-battle--portrait .phone-battle__act .phone-battle__stepper { order: 2; margin-left: auto; }
.phone-battle--portrait .phone-battle__side-head,
.phone-battle--portrait .phone-battle__side--def .phone-battle__side-head { flex-direction: row; }
.phone-battle--portrait .phone-battle__side--def .phone-battle__hits { margin-left: auto; margin-right: 0; }
.phone-battle--portrait .phone-battle__side--def .phone-battle__lost { text-align: left; }
.phone-battle--portrait .phone-battle__row--scramble .phone-battle__row-body,
.phone-battle--portrait .phone-battle__side--def .phone-battle__row--scramble .phone-battle__row-body { grid-template-columns: 2.75rem minmax(0, 1fr) 2.75rem; }
.phone-battle--portrait .phone-battle__side--def .phone-battle__row--scramble .phone-battle__icon { order: 1; }
.phone-battle--portrait .phone-battle__side--def .phone-battle__row--scramble .phone-battle__main { order: 2; display: flex; flex-direction: column; align-items: flex-start; }
.phone-battle--portrait .phone-battle__side--def .phone-battle__row--scramble .phone-battle__check { order: 3; }
.phone-battle--portrait .phone-battle__side--def .phone-battle__row--scramble { border-right: 0; border-left: 3px solid var(--accent-gold); }
.phone-battle--portrait .phone-battle__side--def .phone-battle__scramble-head { text-align: left; }

/* The divider: a hairline across, carrying "N hits left" in a casualty step. */
.phone-battle--portrait .phone-battle__spine { min-height: var(--space-md); }
.phone-battle--portrait .phone-battle__spine { justify-content: stretch; }
/* The hairline runs either side of the label, not under it: the label has no
 * fill to hide it any more (#4211). */
.phone-battle--portrait .phone-battle__spine::before,
.phone-battle--portrait .phone-battle__spine::after {
  content: '';
  position: static;
  flex: 1;
  border-left: 0;
  border-top: 1px solid var(--overlay-gold-25);
}
.phone-battle--portrait .phone-battle__open { flex-direction: row; align-items: baseline; gap: var(--space-xs); padding: 0 var(--space-sm); }
.phone-battle--portrait .phone-battle__open-n { font-size: var(--text-xl); }

/* Caption flows above the rows instead of overlaying a reserved band. */
.combat-root--phone-portrait .combat-center-status {
  position: static;
  transform: none;
  top: auto;
  left: auto;
  width: auto;
  max-width: none;
  padding: var(--space-xs) var(--space-sm) 0;
  flex: 0 0 auto;
}

/* Header: one line (territory · round · controls). Each side's own header in
 * the rows names its nation, so the two nation blocks go. Extra top room
 * clears Safari's floating address pill under the status bar. */
.combat-root--phone-portrait .combat-aa42-header {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "center ctrl";
  padding-top: max(calc(var(--safe-t) + 44px), 100px);
}
.combat-root--phone-portrait .combat-aa42-header-side { display: none; }
/* Marked casualties stay in their row until removed; they still fire. */
.phone-battle__lost-tag {
  padding: 0 var(--space-xs);
  border-radius: var(--radius-sm);
  background: var(--overlay-danger-15);
  color: var(--color-hit);
  font-size: max(var(--text-sm), var(--text-battle-floor));
  font-weight: 700;
  white-space: nowrap;
}
/* Landscape's name slot is narrow: the loss shows as a corner badge on the
 * icon instead (top-right; ½ owns top-left, ×N bottom-right). */
.phone-battle__lost-badge {
  display: none;
  position: absolute;
  top: -4px;
  right: 0;
  padding: 0 3px;
  border-radius: var(--radius-sm);
  background: var(--overlay-danger-50);
  color: var(--text-ivory);
  font-size: var(--text-battle-floor);
  font-weight: 700;
  line-height: 1.2;
}
.phone-battle--landscape .phone-battle__lost-badge { display: block; }
.phone-battle--landscape .phone-battle__lost-tag { display: none; }

/* === Rows view on a tablet or desktop (#4211) ============================
 * The phone landscape layout (halves mirrored, centre column) with the room
 * spent on legibility: bigger sprites and dice, names in full, taller rows.
 * Every size below is multiplied by --rows-scale, which PhoneBattleRows sets
 * on the root from the viewport (1 at 1440×900, ~1.2 at 1920×1080, ~1.6 at
 * 2560×1440), so the view grows with the screen instead of leaving margins.
 * The max width scales with it; the grid stays centred so the column lines
 * up with the caption and the button bar, which centre on the viewport.
 * Touch targets keep a 44px floor. Phone rules above are untouched:
 * everything here is scoped to --large / --rows-large. */
.combat-root--rows-large {
  --rows-scale: 1;
  --rows-s: calc(var(--space-sm) * var(--rows-scale));
  --rows-m: calc(var(--space-md) * var(--rows-scale));
  --rows-l: calc(var(--space-lg) * var(--rows-scale));
  --rows-text: calc(var(--text-base) * var(--rows-scale));
  --rows-text-lg: calc(var(--text-lg) * var(--rows-scale));
  --rows-text-xl: calc(var(--text-xl) * var(--rows-scale));
  --rows-target: max(44px, calc(48px * var(--rows-scale)));
  --phone-center-w: calc(clamp(15rem, 24vw, 21rem) * var(--rows-scale));
  --rows-max-w: calc(88rem * var(--rows-scale));
  /* No Safari tab bar to dodge: a smaller lift than the phone's 20vh. */
  --rows-dock-lift: calc(8vh + var(--safe-b));
  --phone-land-dock-clear: calc(var(--rows-dock-lift) + var(--rows-target) + var(--rows-m));
}
.phone-battle.phone-battle--large {
  width: 100%;
  max-width: var(--rows-max-w);
  margin-inline: auto;
  gap: var(--rows-m);
  padding: var(--rows-m) calc(var(--rows-l) + var(--safe-r)) calc(var(--rows-m) + var(--safe-b)) calc(var(--rows-l) + var(--safe-l));
}
.phone-battle--large .phone-battle__side-head { padding: 0 var(--rows-s) var(--rows-s); gap: var(--rows-s); }
.phone-battle--large .phone-battle__nation { font-size: var(--rows-text-lg); }
.phone-battle--large .phone-battle__role { font-size: var(--rows-text); }
.phone-battle--large .phone-battle__hits { font-size: var(--rows-text-xl); }

.phone-battle--large .phone-battle__row-body,
.phone-battle--large .phone-battle__row.is-editable .phone-battle__row-body {
  grid-template-columns: calc(4.5rem * var(--rows-scale)) minmax(0, 1fr);
  min-height: calc(5rem * var(--rows-scale));
  padding: var(--rows-s);
  gap: var(--rows-s);
}
.phone-battle--large .phone-battle__side--def .phone-battle__row-body,
.phone-battle--large .phone-battle__side--def .phone-battle__row.is-editable .phone-battle__row-body { grid-template-columns: minmax(0, 1fr) calc(4.5rem * var(--rows-scale)); }
.phone-battle--large .phone-battle__main { grid-template-columns: calc(9.5rem * var(--rows-scale)) minmax(0, 1fr); column-gap: var(--rows-m); }
.phone-battle--large .phone-battle__side--def .phone-battle__main { grid-template-columns: minmax(0, 1fr) calc(9.5rem * var(--rows-scale)); }
/* Fill the dice cell: an end-aligned cell shrinks to fit and wraps the
 * defender's dice into a block long before the half runs out of width. */
.phone-battle--large .phone-battle__main > :not(.phone-battle__name),
.phone-battle--large .phone-battle__side--def .phone-battle__main > :not(.phone-battle__name) { justify-self: stretch; }
/* Names in full: wrap inside the slot instead of an ellipsis. */
.phone-battle--large .phone-battle__name {
  flex-wrap: wrap;
  row-gap: 0;
  font-size: var(--rows-text);
  line-height: 1.25;
  white-space: normal;
  overflow: visible;
}
.phone-battle--large .phone-battle__side--def .phone-battle__name { justify-content: flex-end; }
.phone-battle--large .phone-battle__power,
.phone-battle--large .phone-battle__count,
.phone-battle--large .phone-battle__lost-tag { font-size: var(--rows-text); }
/* Room for the "N lost" tag, so the corner badge goes. */
.phone-battle--large .phone-battle__lost-tag { display: inline; }
.phone-battle--large .phone-battle__lost-badge { display: none; }

.phone-battle--large .phone-battle__dice { gap: var(--rows-s) var(--rows-m); padding: var(--rows-s) var(--rows-s) 0 0; }
.phone-battle--large .phone-battle__die-count {
  top: calc(-9px * var(--rows-scale));
  right: calc(-11px * var(--rows-scale));
  padding: 0 3px;
  font-size: max(calc(var(--text-sm) * var(--rows-scale)), var(--text-battle-floor));
}
.phone-battle--large .phone-battle__step { min-width: var(--rows-target); min-height: var(--rows-target); font-size: var(--rows-text-lg); }
.phone-battle--large .phone-battle__step-n { font-size: var(--rows-text-lg); min-width: calc(1.25rem * var(--rows-scale)); }
.phone-battle--large .phone-battle__act { gap: var(--rows-s) var(--rows-m); }
.phone-battle--large .phone-battle__lost { font-size: var(--rows-text); padding: 0 var(--rows-s); }
.phone-battle--large .phone-battle__from { font-size: var(--rows-text); }
.phone-battle--large .phone-battle__scramble-head { font-size: var(--rows-text); padding: var(--rows-s); }
.phone-battle--large .phone-battle__check { width: calc(32px * var(--rows-scale)); height: calc(32px * var(--rows-scale)); font-size: var(--rows-text); }
.phone-battle--large .phone-battle__row--scramble .phone-battle__row-body,
.phone-battle--large .phone-battle__side--def .phone-battle__row--scramble .phone-battle__row-body {
  grid-template-columns: calc(4.5rem * var(--rows-scale)) minmax(0, 1fr) calc(3rem * var(--rows-scale));
}

/* Centre column: the hits-left tally reads across the table. */
.combat-root--rows-large .phone-battle__open-n { font-size: calc(var(--text-2xl) * 2.25 * var(--rows-scale)); }
.combat-root--rows-large .phone-battle__open-label { font-size: var(--rows-text); }
.combat-root--rows-large .combat-center-status .combat-action-caption { font-size: var(--rows-text-lg); }
.combat-root--rows-large .combat-center-status__line,
.combat-root--rows-large .combat-banner-odds { font-size: var(--rows-text); }
.combat-root--rows-large .combat-action-dock { bottom: var(--rows-dock-lift); gap: var(--rows-s); }
.combat-root--rows-large .combat-action-dock .combat-action-primary,
.combat-root--rows-large .combat-action-dock .combat-action-secondary {
  min-height: var(--rows-target);
  padding: 0 var(--rows-m);
  font-size: var(--rows-text);
}

/* Tablet portrait (820 wide): two halves plus a full centre column leave
 * ~260px a side, so the dice slid under the column. Keep the mirrored
 * halves but give them the width: the caption becomes a band across the
 * top, the column shrinks to the hits-left tally, the buttons run along the
 * bottom, and each row puts its name above its dice and −/+. */
@media (orientation: portrait) {
  .combat-root--rows-large {
    --phone-center-w: calc(8.5rem * var(--rows-scale));
    --rows-caption-h: calc(7rem * var(--rows-scale));
  }
  .combat-root--rows-large .combat-center-status {
    width: min(calc(100vw - 2 * var(--rows-l)), calc(40rem * var(--rows-scale)));
    max-width: none;
  }
  .phone-battle.phone-battle--large {
    padding-top: var(--rows-caption-h);
    padding-bottom: var(--phone-land-dock-clear);
  }
  .combat-root--rows-large .combat-action-dock {
    left: calc(var(--rows-l) + var(--safe-l));
    right: calc(var(--rows-l) + var(--safe-r));
    width: auto;
    transform: none;
  }
  .phone-battle--large .phone-battle__main,
  .phone-battle--large .phone-battle__side--def .phone-battle__main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }
  .phone-battle--large .phone-battle__side--def .phone-battle__main { align-items: flex-end; }
  .phone-battle--large .phone-battle__act { align-self: stretch; }
}

/* iPad landscape (#5060). The rows board is position:fixed; top:0, and
 * viewport-fit=cover plus the translucent home-screen status bar draw that
 * edge under the status bar. Phone portrait already reserves a tall band.
 * This header did not, so "United States Forces" and the Dice controls
 * started at y=2 and the status bar cut the FORCES line in half.
 * The root itself is the viewport (top:0; bottom:0), not 100vh, so the
 * strip is covered, not shoved up by a vh/dvh mismatch. --safe-t is the
 * inset when Safari reports it. On a fixed element it can under-report
 * (#3036), so a coarse pointer keeps a 24px status-bar floor. A mouse
 * stays at 2px — there is no bar. */
.combat-root--rows-large .combat-aa42-header {
  padding-top: calc(2px + var(--safe-t));
}
@media (pointer: coarse) {
  .combat-root--rows-large .combat-aa42-header {
    padding-top: max(24px, calc(2px + var(--safe-t)));
  }
}

/* Map moments (#4241): a plate over the map for capital capture, victory-city
   count, convoy hit and victory. Entrance uses the one motion curve, scaled by
   the Animation setting. */
.map-moment-anchor {
  position: fixed;
  inset: 0;
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  pointer-events: none;
}
/* At the territory: the plate hangs from the point, kept inside the screen. */
.map-moment-anchor--at { display: block; }
.map-moment-anchor--at .map-moment {
  position: absolute;
  left: clamp(calc(180px + var(--space-sm)), var(--moment-x), calc(100vw - 180px - var(--space-sm)));
  top: var(--moment-y);
  margin-left: -180px;
}
/* The game-over modal is --z-modal; the victory plate is the one larger treatment. */
.map-moment-anchor--victory { z-index: var(--z-cover); }
.map-moment {
  pointer-events: none;
  box-sizing: border-box;
  width: min(100% - var(--space-xl), 360px);
  padding: var(--space-md) var(--space-xl);
  text-align: center;
  background: var(--bg-secondary);
  border: 2px solid var(--border-brass);
  border-radius: var(--radius-md);
  /* duration is set inline from animationMs() (Animation Full/Fast/Off) */
  animation: mapMomentIn var(--motion-duration) var(--motion-ease) both;
}
.map-moment-anchor--victory .map-moment { pointer-events: auto; cursor: pointer; }
.map-moment-big { width: min(100% - var(--space-xl), 460px); padding: var(--space-xl); }
.map-moment-title {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.map-moment-detail { margin-top: var(--space-xs); font-size: var(--text-base); color: var(--text-primary); }
.map-moment-big .map-moment-title { font-size: var(--text-xl); }
@keyframes mapMomentIn {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Convoy walkthrough (#5028): a dice tray docked at the top of the map while
   the camera holds the raided zone at the visible centre, so the tray never
   covers it. On a short landscape screen the tray docks to the left instead. */
.convoy-walkthrough {
  position: fixed;
  z-index: var(--z-toast);
  top: calc(var(--safe-t) + var(--space-sm));
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
  width: min(100vw - 2 * var(--space-md), 420px);
  max-height: 34vh;
  overflow-y: auto;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border: 2px solid var(--border-brass);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-ui);
  animation: mapMomentIn var(--motion-duration) var(--motion-ease) both;
}
@media (orientation: landscape) and (max-height: 500px) {
  .convoy-walkthrough {
    top: calc(var(--safe-t) + var(--space-sm));
    left: calc(var(--safe-l) + var(--space-sm));
    transform: none;
    width: min(40vw, 320px);
    max-height: calc(100vh - 2 * var(--space-sm));
  }
}
.convoy-walkthrough-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.convoy-walkthrough-title {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.convoy-walkthrough-skip { min-height: var(--tap-min); min-width: var(--tap-min); font-size: var(--text-sm); padding: 0 var(--space-md); }
.convoy-walkthrough-zone { font-size: var(--text-base); color: var(--text-ivory); font-weight: 600; }
.convoy-walkthrough-count { font-size: var(--text-xs); color: var(--text-secondary); font-weight: normal; }
.convoy-walkthrough-note { margin-top: var(--space-xs); font-size: var(--text-sm); color: var(--text-secondary); font-style: italic; }
.convoy-rollers { display: flex; flex-direction: column; gap: var(--space-xs); margin-top: var(--space-xs); }
.convoy-roller { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.convoy-roller-label { display: inline-flex; align-items: center; gap: var(--space-xs); font-size: var(--text-sm); color: var(--text-primary); }
.convoy-roller-dot { width: var(--space-sm); height: var(--space-sm); border-radius: 50%; flex: none; }
.convoy-roller-dice { display: inline-flex; gap: var(--space-xs); }
.convoy-walkthrough-result { margin-top: var(--space-sm); font-size: var(--text-sm); color: var(--text-secondary); }
.convoy-damage { font-size: var(--text-base); font-weight: 700; color: var(--accent-red-bright); font-variant-numeric: tabular-nums; }
.convoy-damage--miss { color: var(--text-secondary); }
.convoy-tags { list-style: none; margin: var(--space-xs) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-md); color: var(--text-primary); }
.convoy-tags b { color: var(--accent-red-bright); font-variant-numeric: tabular-nums; }
.convoy-tag-economy { color: var(--text-secondary); font-size: var(--text-xs); }
/* On the map: a ring on the raided zone and a −N tag on each taxed territory. */
.convoy-ring {
  position: fixed;
  z-index: var(--z-toast);
  width: calc(var(--space-xl) * 3);
  height: calc(var(--space-xl) * 3);
  margin: calc(var(--space-xl) * -1.5) 0 0 calc(var(--space-xl) * -1.5);
  border: 3px solid var(--accent-red-bright);
  border-radius: 50%;
  pointer-events: none;
  animation: convoyRingPulse calc(1.2s * var(--battle-anim-scale, 1)) ease-in-out infinite;
}
.convoy-ring--miss { border-color: var(--text-secondary); }
@keyframes convoyRingPulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.12); opacity: 0.5; }
}
.convoy-tag {
  position: fixed;
  z-index: var(--z-toast);
  transform: translate(-50%, -50%);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--accent-red-bright);
  border-radius: var(--radius-sm);
  color: var(--accent-red-bright);
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  animation: mapMomentIn var(--motion-duration) var(--motion-ease) both;
}
@media (prefers-reduced-motion: reduce) {
  .convoy-ring { animation: none; }
}

/* The Rules link is a plain anchor; give it the bar's fingertip height (#4487). */
.unified-topbar-rules {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  text-decoration: none;
}

/* ══ Rules page, /rules (#4487) ══
 * A reading surface: --font-body for the prose, --font-ui for chrome and
 * tables, Cinzel/gold only on the page title (Instrument HUD, rule 9).
 * body and #root are fixed-height app shells, so the page is its own
 * scroll container. */
.rules-page {
  height: 100%;
  overflow-y: auto;
  background: var(--bg-ink);
  color: var(--text-ivory);
}
.rules-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm) var(--space-md);
  padding: calc(var(--space-sm) + var(--safe-t)) calc(var(--space-lg) + var(--safe-r)) var(--space-sm) calc(var(--space-lg) + var(--safe-l));
  background: var(--bg-rail);
  border-bottom: 1px solid var(--border-brass);
}
.rules-header__back {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  text-decoration: none;
}
.rules-header__back:hover { color: var(--text-ivory); }
.rules-header__title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  color: var(--accent-gold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.rules-edition {
  display: inline-flex;
  margin-left: auto;
  border: 1px solid var(--border-brass);
}
.rules-edition__btn {
  min-height: var(--tap-min);
  padding: 0 var(--space-md);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  background: none;
  border: none;
  cursor: pointer;
}
.rules-edition__btn + .rules-edition__btn { border-left: 1px solid var(--border-brass); }
.rules-edition__btn.is-on {
  color: var(--text-ivory);
  background: var(--bg-raised);
}
.rules-toc-toggle {
  display: none;
  min-height: var(--tap-min);
  padding: 0 var(--space-md);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory);
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  cursor: pointer;
}
.rules-layout {
  display: grid;
  grid-template-columns: minmax(0, 14rem) minmax(0, 1fr);
  gap: var(--space-xl);
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-xl) calc(var(--space-lg) + var(--safe-r)) calc(var(--space-xl) + var(--safe-b)) calc(var(--space-lg) + var(--safe-l));
}
.rules-toc {
  position: sticky;
  top: calc(var(--tap-min) + var(--space-xl));
  align-self: start;
  max-height: calc(100dvh - var(--tap-min) - var(--space-xl) * 2);
  overflow-y: auto;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}
.rules-toc ol { list-style: none; }
.rules-toc a {
  display: block;
  padding: var(--space-xs) 0;
  color: var(--text-ivory-muted);
  text-decoration: none;
}
.rules-toc a:hover { color: var(--text-ivory); }
.rules-toc__other a { opacity: 0.5; }
.rules-content {
  min-width: 0;
  max-width: 46rem;
  font-family: var(--font-body);
  font-size: var(--text-lg);
  line-height: 1.55;
}
.rules-section {
  scroll-margin-top: calc(var(--tap-min) * 2 + var(--space-md));
  padding-bottom: var(--space-xl);
}
.rules-section + .rules-section {
  border-top: 1px solid var(--border-brass);
  padding-top: var(--space-lg);
}
.rules-section__title {
  font-family: var(--font-ui);
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}
.rules-section__title a { color: var(--text-ivory); text-decoration: none; }
.rules-section__title a:hover { text-decoration: underline; }
.rules-subhead {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
  margin: var(--space-lg) 0 var(--space-xs);
}
.rules-p { margin-bottom: var(--space-md); }
.rules-list { margin: 0 0 var(--space-md) var(--space-lg); }
.rules-list li { margin-bottom: var(--space-xs); }
.rules-term { font-weight: 600; }
.rules-number { font-weight: 600; font-variant-numeric: tabular-nums; }
.rules-xref { color: var(--accent-brass); }
.rules-note {
  font-style: italic;
  color: var(--text-ivory-muted);
}
.rules-note__switch {
  font: inherit;
  font-style: normal;
  color: var(--accent-brass);
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.rules-table-wrap {
  overflow-x: auto;
  margin: var(--space-sm) 0 var(--space-lg);
}
.rules-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.4;
}
.rules-table__caption {
  text-align: left;
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  padding-bottom: var(--space-xs);
}
.rules-table th,
.rules-table td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--border-brass-grid);
}
.rules-table thead th {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-ivory-muted);
  border-bottom: 1px solid var(--border-brass);
}
.rules-table tbody th { font-weight: 600; }
.rules-table__num {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.rules-table thead th.rules-table__num { font-family: var(--font-ui); }
.rules-table__group th {
  padding-top: var(--space-md);
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-brass);
}
.rules-table__tag {
  margin-left: var(--space-xs);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.rules-table__sub {
  display: block;
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--text-ivory-muted);
}
.rules-table__has-detail th,
.rules-table__has-detail td { border-bottom: none; }
.rules-table__detail td {
  padding-top: 0;
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
}
.rules-table__detail ul { margin-left: var(--space-lg); }
.rules-table__note { font-style: italic; }
.rules-objectives { margin: var(--space-sm) 0 var(--space-lg); font-family: var(--font-ui); font-size: var(--text-base); }
.rules-objectives__opening {
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  margin: var(--space-md) 0 var(--space-xs);
}
.rules-objectives__power { border-bottom: 1px solid var(--border-brass-grid); }
.rules-objectives__power summary {
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
}
.rules-objectives__power ul { margin: 0 0 var(--space-sm) var(--space-lg); }
.rules-objectives__power li { margin-bottom: var(--space-xs); }
.rules-objectives__bonus {
  font-family: var(--font-mono);
  color: var(--accent-brass);
}

/* Phone and narrow tablet: one column; Contents becomes a bottom sheet. */
@media (max-width: 900px) {
  .rules-layout { grid-template-columns: minmax(0, 1fr); }
  .rules-toc-toggle { display: inline-flex; align-items: center; }
  .rules-edition { margin-left: 0; }
  .rules-header__title { margin-right: auto; }
  .rules-toc { display: none; }
  .rules-toc.is-open {
    display: block;
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 70dvh;
    z-index: var(--z-dialog);
    padding: var(--space-md) calc(var(--space-lg) + var(--safe-r)) calc(var(--space-md) + var(--safe-b)) calc(var(--space-lg) + var(--safe-l));
    background: var(--bg-rail);
    border-top: 1px solid var(--border-brass);
    font-size: var(--text-base);
  }
  .rules-toc.is-open a {
    min-height: var(--tap-min);
    display: flex;
    align-items: center;
  }
}

/* ── In-game links into the Rules page (#4487 S3) ───────────────────────── */
.rules-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--accent-brass);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.rules-link:hover,
.rules-link:focus-visible { color: var(--text-ivory); }
/* In-game rules sheet (#5210). The scaffold box fills the backdrop: a
   centered column up to 72rem, edge to edge below that, full height. */
[data-testid="rules-overlay"] .panel-overlay {
  height: 100%;
  max-height: 100%;
}
.rules-overlay__body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.rules-page--embedded {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}
@media (pointer: coarse) {
  .rules-link { min-height: var(--tap-min); }
}
.rules-link-row {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-sm);
}

/* === Drop disambiguation menu (#4738) === */
.drop-menu {
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-xs);
  min-width: 12rem;
  max-width: calc(100vw - 2 * var(--space-sm));
}
.drop-menu-row {
  min-height: var(--tap-min);
  padding: 0 var(--space-sm);
  text-align: left;
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
}
.drop-menu-row:hover,
.drop-menu-row:focus-visible { border-color: var(--border-accent); }

/* === Last roll (#4757 C) ===
 * C1: in Rows, a side's dice stay in their rows until that side rolls again.
 * Once spent (the other side has answered, or a new round began) they dim. */
.phone-battle__dice.is-spent { opacity: 0.4; filter: grayscale(0.5); }

/* C2: the Dice panel over the rows / board. The backdrop starts under the
 * header, so the header's Dice button still toggles it, and covers the
 * action dock: nothing underneath can be pressed while the battle waits.
 * `.combat-root > *` would make it a relative grid row at z 2. */
.combat-root > .battle-dice-panel-backdrop {
  position: absolute;
  top: var(--combat-header-bottom, 3.25rem);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--space-sm);
  background: var(--overlay-dark-50);
}
.battle-dice-panel {
  width: min(52rem, 100%);
  max-height: 100%;
  overflow-y: auto;
}
.battle-dice-panel__body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md) var(--space-md);
}
.battle-dice-panel__side { display: flex; flex-direction: column; gap: var(--space-sm); min-width: 0; }
.battle-dice-panel__side-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-xs);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--border-accent);
}
.battle-dice-panel__side--atk .battle-dice-panel__side-head { border-bottom-color: var(--combat-aa42-atk); }
.battle-dice-panel__side--def .battle-dice-panel__side-head { border-bottom-color: var(--combat-aa42-def); }
.battle-dice-panel__nation {
  font-family: var(--font-heading);
  font-size: max(var(--text-sm), var(--text-battle-floor));
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-primary);
}
.battle-dice-panel__role,
.battle-dice-panel__round { font-size: max(var(--text-sm), var(--text-battle-floor)); color: var(--text-muted); }
.battle-dice-panel__total { margin-left: auto; font-weight: 700; font-size: max(var(--text-sm), var(--text-battle-floor)); color: var(--text-secondary); }
.battle-dice-panel__total.is-hot,
.battle-dice-panel__section-head .is-hot { color: var(--accent-red-bright); }
.battle-dice-panel__none { margin: 0; font-size: max(var(--text-sm), var(--text-battle-floor)); color: var(--text-muted); }
.battle-dice-panel__section { display: flex; flex-direction: column; gap: var(--space-xs); }
.battle-dice-panel__section-head {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-battle-floor);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.battle-dice-panel__group { display: flex; flex-direction: column; gap: 2px; }
.battle-dice-panel__unit { font-size: max(var(--text-sm), var(--text-battle-floor)); color: var(--text-primary); }
.battle-dice-panel__unit-hits { color: var(--text-muted); font-size: var(--text-battle-floor); }
.battle-dice-panel__dice { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.battle-dice-panel__die { display: inline-flex; border-radius: var(--radius-sm); }
.battle-dice-panel__die.is-hit { outline: 2px solid var(--accent-red-bright); outline-offset: 1px; }
.combat-aa42-header-ctrl.is-active { border-color: var(--accent-gold); color: var(--accent-gold); }

/* Ally transport load prompt (#4978) */
.ally-load__header {
  padding: var(--space-md) var(--space-lg) var(--space-sm);
  border-bottom: 1px solid var(--border-primary);
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-accent);
  font-family: var(--font-heading);
}
.ally-load__body { padding: var(--space-lg); text-align: center; }
.ally-load__question { font-size: var(--text-base); color: var(--color-info-text); }
.ally-load__question strong { color: var(--text-primary); }
.ally-load__hint { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-sm); }
.ally-load__footer {
  padding: var(--space-sm) var(--space-lg) var(--space-md);
  border-top: 1px solid var(--border-primary);
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
}
.ally-load__btn {
  flex: 1;
  min-height: 44px;
  padding: var(--space-sm) 0;
  font-size: var(--text-base);
}
.ally-load__btn--leave {
  background: var(--surface-panel);
  color: var(--color-info-text);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ===================================================================
   LOBBY APP SHELL (#5081, epic #5077)
   900px and wider: iPad and desktop share ONE layout (rail + content).
   Below 900px: one-row app bar + bottom tabs. Every control >= --tap-min.
   =================================================================== */
.lobby-shell {
  position: relative;
  z-index: 1;
  display: grid;
  height: 100vh;
  height: 100dvh;
}
.lobby-shell--rail {
  grid-template-columns: auto minmax(0, 1fr);
}
.lobby-shell--phone {
  /* minmax(0, 1fr): an implicit auto column grows to the widest child (the app bar) and
     pushes the bell, avatar and YOU tab off a 390px screen (#5130 B2). */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.lobby-shell-body {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* No -webkit-overflow-scrolling: touch (#5153). iOS has scrolled with momentum
     without it since 13, and in WebKit it makes this box a stacking context, so
     the tab bar painted over every sheet and dialog rendered inside it. */
}
/* Desktop gets more room, never a different layout: the content column is capped
   and starts at the rail. Centering it left a dead gutter beside the rail on a
   wide screen (#5177). */
.lobby-shell-content {
  max-width: var(--lobby-content-max);
  margin: 0;
}
/* #5132: a task (the room, vs AI, hotseat) keeps its footer on screen.
   The shell body stops scrolling; the task body scrolls; the footer is a
   flex sibling, so Begin and Ready stay above the fold. Games, Play, and
   Ranked keep the shell body as their scrollport. */
.lobby-shell--task .lobby-shell-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lobby-shell--task .lobby-shell-body > * {
  flex-shrink: 0;
}
.lobby-shell--task .lobby-shell-body > .lobby-shell-content {
  /* A flex item with auto side margins shrinks to its content: the room was 467px wide on a
     744px iPad portrait. Full width, capped by --lobby-content-max (#5141). */
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.lobby-shell--task .lobby-task {
  flex: 1;
  min-height: 0;
}
.lobby-shell--task .lobby-task-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
/* The task body is the scroller, so its children keep their height. A flex item with
   overflow: hidden (the options card) has an automatic minimum height of 0 and shrinks to
   the body instead of letting the body scroll: on a phone the vs AI card was cut at the
   Axis seats, 667px of 1206px (#5143). */
.lobby-shell--task .lobby-task-body > * {
  flex-shrink: 0;
}
.lobby-shell--task .room-footer {
  flex-shrink: 0;
  position: static;
}
.lobby-shell--rail .unified-page {
  max-width: none;
}

/* ── Rail (>= 900px) ── */
.lobby-rail {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  width: var(--lobby-rail-w);
  box-sizing: border-box;
  padding: calc(var(--space-lg) + var(--safe-t)) var(--space-sm) calc(var(--space-sm) + var(--safe-b)) calc(var(--space-sm) + var(--safe-l));
  background: var(--bg-rail);
  border-right: 1px solid var(--border-brass);
}
.lobby-rail-logo {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-ivory);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  padding: 0 var(--space-sm) var(--space-lg);
}
.lobby-rail-tabs {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex: 1;
}
.lobby-rail-item,
.lobby-tabbar-item {
  position: relative;
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0 var(--space-sm);
  border: none;
  background: none;
  color: var(--text-ivory-muted);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.lobby-rail-item {
  gap: var(--space-sm);
  border-left: 2px solid transparent;
}
.lobby-rail-item:hover,
.lobby-tabbar-item:hover { color: var(--text-ivory); }
.lobby-rail-item.active {
  color: var(--text-ivory);
  background: var(--bg-raised);
  border-left-color: var(--accent-brass);
}
.lobby-rail-item-glyph,
.lobby-tabbar-item-glyph {
  font-size: var(--text-base);
  line-height: 1;
}
.lobby-rail-gear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0;
  border: none;
  background: none;
  font-size: var(--text-lg);
  color: var(--text-ivory-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}
.lobby-rail-gear:hover { color: var(--text-ivory); }

.lobby-shell-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--lobby-badge-size);
  height: var(--lobby-badge-size);
  margin-left: auto;
  padding: 0 var(--space-xs);
  background: var(--accent-brass);
  color: var(--color-on-gold);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0;
  line-height: 1;
}
.lobby-shell-dot { margin-left: auto; }

/* ── Phone: top app bar + bottom tabs (< 900px) ── */
.lobby-appbar {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: calc(var(--tap-min) + var(--safe-t));
  box-sizing: border-box;
  padding: var(--safe-t) calc(var(--space-md) + var(--safe-r)) 0 calc(var(--space-md) + var(--safe-l));
  background: var(--bg-rail);
  border-bottom: 1px solid var(--border-brass);
}
.lobby-appbar-title {
  flex: 1;
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-ivory);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  white-space: nowrap;
}
.lobby-appbar-slot { display: inline-flex; align-items: center; }
.lobby-appbar-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  padding: 0;
  border: 1px solid var(--border-brass);
  border-radius: 50%;
  background: var(--bg-raised);
  color: var(--text-ivory);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  cursor: pointer;
}

/* Notification bell (#5084). The sheet itself is .lobby-sheet. */
.lobby-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  width: var(--tap-min);
  height: var(--tap-min);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-ivory-muted);
  cursor: pointer;
}
.lobby-bell--open,
.lobby-bell:hover { color: var(--text-ivory); }
.lobby-bell__icon {
  width: var(--text-lg);
  height: var(--text-lg);
}
.lobby-bell__badge {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--space-md);
  height: var(--space-md);
  padding: 0 var(--space-xs);
  border-radius: var(--radius-md);
  background: var(--accent-brass);
  color: var(--color-on-gold);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
}
.lobby-bell__section { display: flex; flex-direction: column; }
.lobby-bell__kicker {
  margin: var(--space-sm) 0 var(--space-xs);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.lobby-sheet__item.lobby-bell__row {
  align-items: flex-start;
  gap: var(--space-sm);
  padding-top: var(--space-sm);
  padding-bottom: var(--space-sm);
}
.lobby-bell__clock { white-space: nowrap; }
.lobby-bell__mark {
  flex: none;
  width: var(--roundel-m);
  height: var(--roundel-m);
  border: 1px dashed var(--border-brass);
  border-radius: 50%;
}
.lobby-bell__copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: var(--space-xs);
}
.lobby-bell__name {
  font-size: var(--text-sm);
  color: var(--text-ivory);
}
.lobby-bell__detail {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
}
.lobby-bell__action {
  flex: none;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-brass);
}
.lobby-bell__empty {
  margin: var(--space-sm) 0;
  color: var(--text-ivory-muted);
  font-size: var(--text-sm);
}
.lobby-bell__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
  color: var(--text-ivory-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}
.lobby-bell__settings {
  margin-left: auto;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0 var(--space-sm);
  border: none;
  background: transparent;
  color: var(--text-ivory-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  cursor: pointer;
}
.lobby-bell__settings:hover { color: var(--text-ivory); }
.lobby-bell-preview-page {
  min-height: 100vh;
  background: var(--bg-ink);
}
.lobby-bell-preview__name {
  margin: 0;
  color: var(--text-ivory);
  font-size: var(--text-base);
}

.lobby-tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--bg-rail);
  border-top: 1px solid var(--border-brass);
}
.lobby-tabbar-item {
  flex-direction: column;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-xs) 0;
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
}
.lobby-tabbar-item .lobby-tabbar-item-glyph { font-size: var(--text-lg); }
.lobby-tabbar-item.active {
  color: var(--text-ivory);
  box-shadow: inset 0 2px 0 var(--accent-brass);
}
.lobby-tabbar-item .lobby-shell-badge {
  position: absolute;
  top: var(--space-xs);
  left: 55%;
  margin: 0;
}
.lobby-tabbar-item .lobby-shell-dot {
  position: absolute;
  top: var(--space-sm);
  left: 58%;
  margin: 0;
}
/* Phone landscape (short): keep the bar slim; the 44px tabs set its height. */
@media (max-height: 500px) {
  .lobby-tabbar-item { flex-direction: row; justify-content: center; }
}
/* Phone landscape on a task screen (#5146 L-1): the tab bar goes (‹ Games already returns
   from a task) and the footer is one 44px row, so the scrollport gets the height. The footer
   is now the last element, so it carries the bottom safe-area inset the tab bar had. */
@media (max-height: 500px) and (orientation: landscape) {
  .lobby-shell--task .lobby-tabbar { display: none; }
  .lobby-shell--task .room-footer {
    flex-wrap: nowrap;
    min-height: var(--tap-min);
    padding-top: 0;
    padding-bottom: var(--safe-b);
    box-sizing: content-box;
  }
  .lobby-shell--task .room-footer__seats { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ── You ── */
.lobby-you-name {
  margin-top: var(--space-md);
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  color: var(--text-ivory);
}
.lobby-you-input { margin: var(--space-md) 0 var(--space-lg); min-height: var(--tap-min); box-sizing: border-box; width: 100%; max-width: 320px; }
/* #5131: the name field's visible label; the field sits right under it. */
.lobby-name-field { display: flex; flex-direction: column; gap: var(--space-xs); margin: var(--space-md) 0 var(--space-lg); max-width: 320px; }
.lobby-name-field .lobby-you-input { margin: 0; }
.lobby-name-field__label { font-family: var(--font-ui); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-ivory-muted); }
.lobby-appbar-avatar__glyph { color: var(--text-ivory-muted); font-size: var(--text-lg); line-height: 1; }
/* #5131: no name yet on Play; a quiet line, not the gold kicker and not the red banner. */
.lobby-join-hint { margin: 0 0 var(--space-md); font-size: var(--text-sm); color: var(--text-ivory-muted); }
.lobby-you-links {
  display: flex;
  flex-direction: column;
  max-width: 420px;
  border-top: 1px solid var(--border-brass);
}
.lobby-you-link {
  display: flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 var(--space-sm);
  border: none;
  border-bottom: 1px solid var(--border-brass);
  background: none;
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  letter-spacing: 0.1em;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.lobby-you-link:hover { background: var(--bg-raised); }

/* ── Profile (#5089). Same column at 900px+ and on the phone. ── */
.lobby-profile { display: flex; flex-direction: column; gap: var(--space-xs); }
.lobby-profile-kicker {
  margin: var(--space-lg) 0 var(--space-xs);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.lobby-profile-empty,
.lobby-profile-meta {
  margin: 0;
  color: var(--text-ivory-muted);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
}
.lobby-profile-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}
.lobby-profile-side {
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  padding: var(--space-sm) var(--space-md);
}
.lobby-profile-side-name {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-ivory);
}
.lobby-profile-recent { list-style: none; margin: 0; padding: 0; }
.lobby-profile-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: var(--tap-min);
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border-brass);
}
.lobby-profile-row-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 0;
  flex: 1;
}
.lobby-profile-outcome,
.lobby-profile-gamename { color: var(--text-ivory); }
.lobby-profile-gamename { font-weight: 600; }
.lobby-profile-opponents { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); }
.lobby-profile-recap {
  flex: none;
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: 0 var(--space-sm);
  border: 1px solid var(--border-brass);
  background: none;
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

/* ── Sign-in screen ── */
.login-screen {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg-ink);
}
.login-poster {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background-size: cover;
  background-position: center;
}
.login-poster--axis { left: 0; }
.login-poster--allies { right: 0; }
.login-wash {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--bg-ink) 55%, transparent) 0%, var(--bg-ink) 95%);
}
.login-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  max-width: 420px;
  padding: var(--space-xl) var(--space-lg);
  text-align: center;
}
.login-title {
  margin: 0 0 var(--space-md);
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-ivory);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.login-primary {
  min-height: var(--tap-min);
  padding: var(--space-md) var(--space-xl);
  font-size: var(--text-base);
}
.login-note,
.login-error {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  line-height: 1.5;
}
.login-error { color: var(--text-ivory); }
.login-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  padding: 0 var(--space-sm);
  border: none;
  background: none;
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  text-decoration: underline;
  cursor: pointer;
}

/* ── Join: Open rooms (#5088) ── */
.lobby-room-card { flex-wrap: wrap; }
.lobby-room-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  flex: 1 1 180px;
  min-width: 0;
}
.lobby-room-main .unified-open-game-name { min-width: 0; }
.lobby-room-meta {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
}
.lobby-room-team { display: inline-flex; gap: var(--space-2xs); margin-right: var(--space-sm); }
.lobby-room-join {
  min-height: var(--tap-min);
  min-width: var(--tap-min);
}
.unified-join-by-id-input,
.unified-join-by-id-btn { min-height: var(--tap-min); box-sizing: border-box; }
@media (max-width: 640px) {
  .lobby-room-main { flex-basis: 100%; }
  .lobby-room-card .unified-open-game-slots { flex: 1 1 auto; flex-wrap: nowrap; white-space: nowrap; }
  .lobby-room-card .unified-open-game-age { min-width: 0; text-align: left; }
  .lobby-room-join { margin-left: auto; }
}

/* ===================================================================
   GAMES HOME (#5082): NOW / WAITING / START, the card, the detail pane
   =================================================================== */
.games-home {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-lg);
  padding: var(--space-lg) calc(var(--space-lg) + var(--safe-r)) var(--space-lg) calc(var(--space-lg) + var(--safe-l));
}
/* iPad and desktop share this: the list alone (#5207 removed the detail pane), capped so it does not stretch. */
.games-home--wide { align-items: start; }
.games-home--wide > .games-home__list { width: 100%; max-width: var(--games-list-max); }
/* #5090: the map behind the Games home (900px+, Settings → Display, off by default). Decoration only. */
.games-home--wide { position: relative; isolation: isolate; }
.games-home--wide > .games-home__list { position: relative; z-index: 1; }
.lobby-map-backdrop {
  position: absolute;
  inset: 0;
  max-height: 100dvh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  /* No seam where the list ends (#5130 Po-8). */
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent);
  mask-image: linear-gradient(to bottom, black 55%, transparent);
}
.lobby-map-backdrop__svg { width: 100%; height: 100%; display: block; }
.lobby-map-backdrop__art { opacity: 0.22; }
.games-group { display: flex; flex-direction: column; gap: var(--space-sm); margin-bottom: var(--space-lg); }
.games-group__title {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.games-group__empty { margin: 0; color: var(--text-ivory-muted); font-size: var(--text-sm); }

/* ── Card ── */
.games-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  border-left-width: var(--card-rail-w);
  padding: var(--space-sm) var(--space-md);
}
.games-card--now { border-left-color: var(--accent-brass); }
.games-card--unplayable { opacity: 0.6; }
.games-card__main {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
  min-height: var(--tap-min);
  padding: 0;
  border: none;
  background: none;
  color: var(--text-ivory);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.games-card__body { display: flex; flex-direction: column; gap: var(--space-xs); min-width: 0; }
.games-card__title { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-sm); }
.games-card__name {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-ivory);
}
.games-card__round {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  border: 1px solid var(--border-brass);
  padding: 0 var(--space-xs);
}
.games-card__meta, .games-card__score, .games-card__line, .games-card__fact {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
}
.games-card__turn { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-sm); }
.games-card__badge {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-ivory);
  border: 1px solid var(--accent-brass);
  padding: 0 var(--space-xs);
}
.games-card__line { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-xs); }
.games-card__line b { color: var(--text-ivory); font-weight: 600; }
.games-card__chip {
  margin-left: auto;
  font-family: var(--font-mono);
  border: 1px solid var(--border-brass);
  padding: 0 var(--space-xs);
}
.games-card__warn { font-size: var(--text-sm); color: var(--accent-amber); }
.games-card__side { display: flex; align-items: center; gap: var(--space-sm); }
/* Play on a card is a full 44px target (#5145 B-3); .btn-lobby sets no height. */
.games-card__side .btn-lobby:not(.btn-lobby--quiet) {
  min-height: var(--tap-min);
  min-width: var(--tap-min);
  padding: var(--space-xs) var(--space-md);
}
.games-card__clock { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-ivory); }
/* A visible ⋯ on every card; the old × only showed on hover. */
.games-card__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  padding: 0;
  border: none;
  background: none;
  font-size: var(--text-lg);
  color: var(--text-ivory-muted);
  cursor: pointer;
}
.games-card__menu:hover { color: var(--text-ivory); }
.games-card__menu[aria-expanded="true"] { color: var(--text-ivory); }
/* #5158: the ⋯ actions expand under the card, inside its frame, as one row of
   44px buttons. Always mounted so the height can animate (0fr -> 1fr). Closed, the
   0fr row clips it and `inert` keeps it out of focus and the accessibility tree
   (no visibility toggle: that delayed focus on open). Its row cancels the card's grid gap. */
.games-card__tray {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: 0fr;
  margin-top: calc(-1 * var(--space-sm));
  transition: grid-template-rows var(--transition-fast);
}
.games-card__tray--open {
  grid-template-rows: 1fr;
}
.games-card__tray-inner {
  min-height: 0;
  overflow: hidden;
}
.games-card__tray-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-brass);
}
/* #5176: a tray holding one action (Delete alone) is one tight row, not a tall mostly empty one. */
.games-card__tray-actions:has(> :only-child) {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
/* Destructive, never a second gold. */
.btn-lobby.btn-lobby--quiet.games-card__tray-delete {
  color: var(--accent-danger-text);
  border-color: var(--accent-red);
}
@media (prefers-reduced-motion: reduce) {
  .games-card__tray,
  .games-card__tray--open { transition: none; }
}
.games-card__error {
  grid-column: 1 / -1;
  margin: 0;
  padding: var(--space-xs) var(--space-sm);
  background: var(--overlay-gold-08);
  border-left: 2px solid var(--accent-amber);
  color: var(--text-ivory);
  font-size: var(--text-sm);
}
/* ── Seats ── */
.games-seats { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-md); }
.games-seats__side { display: inline-flex; align-items: center; flex-wrap: wrap; gap: var(--space-xs); }
.games-seats__label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.games-seats__side[data-side="Axis"] .games-seats__label { color: var(--alliance-axis); }
.games-seats__side[data-side="Allies"] .games-seats__label { color: var(--alliance-allies); }
.games-seats__sep { color: var(--text-ivory-muted); }
.games-seat { display: inline-flex; align-items: center; gap: var(--space-xs); font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text-ivory-muted); }
.games-seat--more { padding: 0 var(--space-xs); border: 1px solid var(--border-brass); color: var(--text-ivory-muted); }
.games-seat--you .games-seat__name { color: var(--text-ivory); font-weight: 700; text-decoration: underline; }

/* ── START ── */
.games-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-sm); }
.games-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-xs);
  min-height: var(--tap-min);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
}
.games-tile__name { font-family: var(--font-ui); letter-spacing: 0.14em; text-transform: uppercase; }
.games-tile__sub { font-family: var(--font-ui); font-size: var(--text-sm); text-transform: none; letter-spacing: 0; }
.games-all-link { align-self: flex-start; }

/* ── Tutorial lessons (#5373) ── */
.lesson-list { display: flex; flex-direction: column; gap: var(--space-sm); width: 100%; max-width: var(--games-list-max); margin: 0; padding: 0; list-style: none; }
.lesson-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); width: 100%; min-height: var(--tap-min); padding: var(--space-sm) var(--space-md); text-align: left; }
.lesson-row__text { display: flex; flex-direction: column; gap: var(--space-xs); min-width: 0; }
.lesson-row__title { font-family: var(--font-ui); letter-spacing: 0.14em; }
.lesson-row__summary, .lesson-row__state { font-family: var(--font-ui); font-size: var(--text-sm); text-transform: none; letter-spacing: 0; }
.lesson-row__summary { white-space: normal; color: var(--text-ivory-muted); }
.lesson-row__state { flex-shrink: 0; color: var(--text-ivory-muted); }
.lesson-row__state--done { color: var(--accent-green); }

/* ── Lesson coach (#5377): the interactive lesson card. No scrim: only the card takes clicks.
   It sits above the dialog layers, because a step can be played inside one (#5381). ── */
.lesson-spotlight { position: fixed; z-index: calc(var(--z-dialog-confirm) + 1); pointer-events: none; border: 2px solid var(--accent-brass); animation: lesson-spotlight-pulse 2s ease-in-out infinite; }
@keyframes lesson-spotlight-pulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--overlay-dark-60), 0 0 8px var(--accent-brass); }
  50% { box-shadow: 0 0 0 1px var(--overlay-dark-60), 0 0 20px var(--accent-brass); }
}
@media (prefers-reduced-motion: reduce) { .lesson-spotlight { animation: none; } }
.lesson-coach { position: fixed; z-index: calc(var(--z-dialog-confirm) + 2); top: calc(112px + var(--safe-t)); left: calc(var(--space-md) + var(--safe-l)); width: min(300px, calc(100vw - 2 * var(--space-md))); max-height: calc(100dvh - 180px); overflow-y: auto; background: var(--bg-ink); border: 1px solid var(--border-brass); box-shadow: 0 8px 32px var(--overlay-dark-60); color: var(--text-ivory); font-family: var(--font-body); font-size: var(--coach-text); line-height: 1.45; }
.lesson-coach__header { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-xs) var(--space-sm); background: var(--bg-rail); }
.lesson-coach__count { font-family: var(--font-mono); color: var(--text-secondary); font-size: var(--coach-text-small); }
.lesson-coach__title { flex: 1; min-width: 0; margin: 0; font-family: var(--font-heading); font-size: var(--coach-text); font-weight: 500; letter-spacing: 0.06em; }
.lesson-coach__toggle { background: none; border: 0; color: var(--text-secondary); font-family: var(--font-ui); font-size: var(--coach-text-small); text-transform: uppercase; cursor: pointer; min-height: 32px; padding: 0 var(--space-xs); }
.lesson-coach__body { padding: 0 var(--space-sm); }
.lesson-coach__body p { margin: var(--space-xs) 0; }
.lesson-coach__hint { color: var(--text-secondary); font-style: italic; font-size: var(--coach-text-small); }
.lesson-coach__blocked { margin: var(--space-xs) var(--space-sm); padding: var(--space-xs) var(--space-sm); border-left: 3px solid var(--color-warning); background: var(--bg-raised); animation: lesson-blocked-in 0.3s ease; }
@keyframes lesson-blocked-in { from { transform: translateX(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.lesson-coach__footer { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-xs) var(--space-sm) var(--space-sm); }
.lesson-coach__waiting { font-family: var(--font-ui); font-size: var(--coach-text-small); text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent-brass); }
.lesson-coach__next { border-color: var(--accent-gold); color: var(--accent-gold); }
.lesson-coach--low { top: auto; bottom: calc(var(--space-md) + var(--safe-b)); max-height: 42dvh; }
/* Phone portrait: the sidebar fills the top of the screen, so the card sits just above its End Phase footer. */
@media (max-width: 500px) and (orientation: portrait) {
  .lesson-coach { top: auto; bottom: calc(104px + var(--safe-b)); left: var(--space-sm); right: var(--space-sm); width: auto; max-height: 40dvh; }
  /* Clear of a dialog's buttons along the bottom (a territory panel, or the lower part of Settings). */
  .lesson-coach.lesson-coach--high { top: calc(64px + var(--safe-t)); bottom: auto; }
  .lesson-coach--phone-top { top: calc(56px + var(--safe-t)); bottom: auto; left: calc(68px + var(--safe-l)); } /* clear of the Plan tool rail */

  /* A battle board needs its whole width, so it gets a shelf, not a dock
     (#5457): the board ends where the card starts, and the card cannot cover a
     casualty stepper. The card's height is --lesson-card-h. */
  :root[data-lesson-rail] { --lesson-shelf: var(--lesson-card-h, 0px); }
  /* height: the portrait board sets a full-screen one, which beats `bottom`. */
  :root[data-lesson-rail] :is(.combat-root--phone-portrait, .sbr-root) { bottom: var(--lesson-shelf); height: auto; --safe-b: 0px; }
  /* With no decision panel in it, this strip above the buttons is empty, but it
     still took the taps meant for the last row of the shorter board. */
  :root[data-lesson-rail] .combat-root--phone-portrait .combat-aa42-nation-row:not(:has(.combat-aa42-nation-row-side > *)) { pointer-events: none; }
  :root[data-lesson-rail] .combat-root--phone-portrait .combat-aa42-nation-row:not(:has(.combat-aa42-nation-row-side > *)) * { pointer-events: none; }
  :root[data-lesson-rail]:has(.combat-root--phone-portrait, .sbr-root) :is(.lesson-coach, .lesson-coach--high, .lesson-coach--low) { top: auto; bottom: 0; left: 0; right: 0; padding-bottom: var(--safe-b); max-height: 34dvh; }
}

/* A column whose middle scrolls: the heading, Exit and Next never leave the card
   (#5457). */
.lesson-coach { display: flex; flex-direction: column; overflow: hidden; line-height: 1.35; }
.lesson-coach__header, .lesson-coach__footer { flex: 0 0 auto; }
.lesson-coach__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.lesson-coach__body p { margin-block: var(--space-2xs); }

/* Fingertip targets and readable buttons (#5457). A Rules link keeps its 44px
   target without the 44px line it put in the middle of a paragraph. The target
   reaches up over the text: reaching down, it made a short card scroll. */
.lesson-coach__footer .btn { font-size: var(--coach-text-small); }
.lesson-coach .rules-link { font-size: var(--coach-text-small); }
@media (pointer: coarse) {
  .lesson-coach__toggle,
  .lesson-coach__footer .btn,
  .tutorial-tap { min-width: var(--tap-min); min-height: var(--tap-min); }
  .lesson-coach__footer .btn { padding-inline: var(--space-md); }
  /* The 44px controls are the rows' own height: no padding on top of them. */
  .lesson-coach__header, .lesson-coach__footer { padding-block: 0; }
  .lesson-coach .rules-link,
  [data-testid="tutorial-coach"] .rules-link { position: relative; min-height: 0; }
  .lesson-coach .rules-link::after,
  [data-testid="tutorial-coach"] .rules-link::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: var(--tap-min); }
}

/* Hidden: only the step count, Show, and Next where the step has one (#5457).
   The full-width strip it used to leave still covered what was under it. */
.lesson-coach.lesson-coach--min { left: auto; right: var(--space-sm); width: auto; }
.lesson-coach--min :is(.lesson-coach__title, .lesson-coach__waiting, [data-testid="lesson-exit"]) { display: none; }
.lesson-coach--min .lesson-coach__footer { justify-content: flex-end; padding-block: 0 var(--space-xs); }
.lesson-coach--min .lesson-coach__footer:not(:has(.lesson-coach__next)) { display: none; }

/* ── Lesson rail (#5457): a phone held sideways ──
 * A card docked in a corner covered the territory, the dialog or the battle
 * stacks the step was about. Here it is a column down the left edge instead, and
 * everything else starts to its right: the map (so the camera frames in what is
 * left), dialogs, the menu, the territory panel and both battle boards. */
@media (orientation: landscape) and (max-height: 500px) {
  :root[data-lesson-rail] { --lesson-rail-w: calc(var(--lesson-card-w) + var(--safe-l)); }
  /* These start at the rail, which has already cleared the notch. */
  :root[data-lesson-rail] :is(.combat-root, .sbr-root, .hamburger-drawer, .defense-sheet, [data-testid="territory-bottom-panel"]) { --safe-l: 0px; }
  :root[data-lesson-rail] :is(.combat-root, .sbr-root, .hamburger-drawer, .defense-sheet) { left: var(--lesson-rail-w); }
  /* The Plan tool row wraps rather than run under the side panel. */
  :root[data-lesson-rail] .plan-rail--h { flex-wrap: wrap; max-width: calc(100% - var(--sidebar-w) - 2 * var(--space-sm)); }
  /* Its name tip and first-use hint drop below the second row. */
  :root[data-lesson-rail] .plan-rail--h .plan-rail__flyout { top: calc(100% + var(--tap-min) + var(--space-md)); }
  :root[data-lesson-rail] .plan-rail-hint--h { top: calc(var(--space-md) + 2 * var(--tap-min) + var(--space-lg)); }

  :root[data-lesson-rail] :is(.lesson-coach, .lesson-coach--low) {
    top: calc(var(--toolbar-control-h) + var(--space-md) + var(--safe-t));
    bottom: var(--safe-b);
    left: var(--safe-l);
    width: var(--lesson-card-w);
    box-sizing: border-box;
    max-height: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  /* A battle covers the top bar, so the rail takes the full height. */
  :root[data-lesson-rail]:has(.combat-root, .sbr-root) .lesson-coach { top: var(--safe-t); }
  /* Only the text scrolls: Exit and Next stay in view. */
  :root[data-lesson-rail] .lesson-coach__body { flex: 1; min-height: 0; overflow-y: auto; }

  /* The narrower battle board: a slimmer centre column, each unit's name above
     its steppers and dice, and a header that fits. */
  :root[data-lesson-rail] .combat-root--phone-landscape { --phone-center-w: calc((100vw - var(--lesson-rail-w)) * 0.31); }
  /* The instructions wrap longer here, so the hit count gives them the room. */
  :root[data-lesson-rail] .combat-root--phone-landscape .phone-battle__open-n { font-size: var(--text-2xl); }
  :root[data-lesson-rail] .phone-battle--landscape .phone-battle__side .phone-battle__main { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  :root[data-lesson-rail] .phone-battle--landscape .phone-battle__side--def .phone-battle__main > * { grid-column: 1; grid-row: auto; justify-self: end; }
  /* The rows now clear a notch on the right only, so their middle is half that
     inset left of the board's. The centred status and buttons follow it. */
  :root[data-lesson-rail] .combat-root--phone-landscape :is(.combat-aa42-nation-row, .combat-action-dock, .combat-center-status) { left: calc(50% - var(--safe-r) / 2); }
  /* The buttons stay on one row under the narrow centre column, off the hit count. */
  :root[data-lesson-rail] .combat-root--phone-landscape .combat-action-dock { width: max-content; }
  /* The header keeps the territory, round and controls. Each side's heading below
     already names its nation. */
  :root[data-lesson-rail] .combat-root .combat-aa42-header { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "center ctrl"; gap: var(--space-xs); padding-inline: var(--space-sm); }
  :root[data-lesson-rail] .combat-root .combat-aa42-header-side { display: none; }
}

/* ── Filters (All games) ── */
.games-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); }
.games-filter {
  min-height: var(--tap-min);
  padding: 0 var(--space-md);
  border: 1px solid var(--border-brass);
  background: none;
  color: var(--text-ivory-muted);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.games-filter--active { color: var(--text-ivory); border-color: var(--accent-brass); background: var(--bg-raised); }
.games-filters__back { margin-left: auto; }

/* ── Tray facts (#5207): the last event and the bid, above the actions ── */
.games-card__facts { display: flex; flex-direction: column; gap: var(--space-xs); margin: 0 0 var(--space-sm); }
.games-card__fact { display: flex; gap: var(--space-sm); margin: 0; }
.games-card__fact dt { text-transform: uppercase; letter-spacing: 0.18em; color: var(--text-ivory-muted); }
.games-card__fact dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--text-ivory); }

/* ── Empty state: posters behind, START as the hero ── */
.games-empty { position: relative; isolation: isolate; min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--space-xl) var(--space-lg); }
.games-empty__posters { position: absolute; inset: 0; z-index: -1; overflow: hidden; }
.games-empty__poster { position: absolute; top: 0; bottom: 0; width: 50%; background-size: cover; background-position: center; opacity: 0.45; }
.games-empty__poster--axis { left: 0; background-image: url(/axis-poster.jpg); }
.games-empty__poster--allies { right: 0; background-image: url(/allies-poster.jpg); }
.games-empty__wash { position: absolute; inset: 0; background: radial-gradient(ellipse at center, color-mix(in srgb, var(--bg-ink) 50%, transparent) 0%, var(--bg-ink) 100%); }
.games-empty__content { display: flex; flex-direction: column; gap: var(--space-md); width: 100%; max-width: 40rem; }
/* The wordmark as hero (#5131): the lobby's one Cinzel, larger. */
.games-empty__wordmark { margin: 0; font-family: var(--font-heading); font-size: var(--text-2xl); font-weight: 700; color: var(--text-ivory); letter-spacing: 0.28em; text-transform: uppercase; text-align: center; }
.games-empty__lead { text-align: center; }
.games-empty__lead { margin: 0; color: var(--text-ivory-muted); }
/* The code row spans the tile row above it (#5131): the field takes the width, Join its own. */
.games-empty__code { margin-top: var(--space-sm); display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.games-empty__code .unified-join-by-id-input { width: auto; min-width: 0; }

@media (max-width: 640px) {
  /* A NOW card stacks its clock and Play under the text; a WAITING row keeps its ⋯ beside it. */
  .games-card--now { grid-template-columns: minmax(0, 1fr); }
  .games-card--now .games-card__side { justify-content: flex-end; }
  .games-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* The fifth tile, Tutorial, takes the last row (#5373). */
  .games-tiles > .games-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* The app bar and the tab bar are each --tap-min tall; the posters fill what is left. */
  .games-empty { min-height: calc(100dvh - 2 * var(--tap-min) - var(--safe-t) - var(--safe-b)); padding: var(--space-lg) var(--space-md); }
}

/* #5170: join-code and name errors sit under their own field, in words. */
.join-code-error,
.lobby-name-field__error {
  margin: var(--space-xs) 0 0;
  font-size: var(--text-sm);
  color: var(--accent-red-bright);
}
.unified-join-by-id-input--error { border-color: var(--accent-red-bright); }

/* plan: S3 honest-orders banner (#5249). Mockup .banner / .rd. */
.plan-banner {
  border: 1px solid var(--accent-brass);
  background: var(--overlay-gold-12);
  border-radius: var(--radius-md);
  padding: var(--plan-pad-banner);
  display: flex;
  flex-direction: column;
  gap: var(--plan-banner-gap);
  margin-bottom: var(--space-xs);
}
.plan-banner--line { margin-bottom: var(--space-xs); }
.plan-banner__title,
.plan-toast__title {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--plan-banner-title);
  line-height: 1.25;
  color: var(--text-ivory);
  display: flex;
  gap: var(--plan-banner-gap);
  align-items: center;
}
.plan-banner__body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--plan-banner-body);
  line-height: 1.35;
  color: var(--text-ivory);
}
.plan-banner__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--plan-banner-gap);
}
/* desktop-06 / desktop-06b keep Hide digest on the same row as Review and Apply.
   The sidebar is the container (BoardSidebar sets container-type). A wide rail
   (desktop, iPad) is one row; a narrow one (phone) wraps, as the mockup's .acts does. */
@container board-sidebar (min-width: 300px) {
  .plan-banner__actions { flex-wrap: nowrap; }
}
/* The shared .btn rule is later than .btn-primary and .btn-ghost, so it
   paints every banner button as the same secondary control. Restate the
   mockup .btn here: --font-ui at 11px, Review primary, digest a true ghost. */
.plan-banner__actions .btn {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: var(--plan-banner-btn);
  line-height: 1;
  min-height: var(--plan-banner-btn-min);
  white-space: nowrap;
}
.plan-banner__actions .btn.btn-primary {
  background: var(--btn-bg-primary);
  color: var(--text-ivory);
  border-color: var(--accent-brass);
}
.plan-banner__actions .btn.btn-ghost {
  flex: 0 0 auto;
  width: auto;
  background: transparent;
  color: var(--text-ivory-muted);
  border-color: transparent;
  box-shadow: none;
}
.plan-banner__actions .btn.btn-ghost:hover:not(:disabled) {
  background: transparent;
  color: var(--text-ivory);
  border-color: transparent;
  transform: none;
  box-shadow: none;
  filter: none;
}
.plan-waiting {
  font-family: var(--font-ui);
  font-size: var(--plan-banner-body);
  line-height: 1.3;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}
.plan-needs-units {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px dashed var(--border-primary);
  border-radius: var(--radius-sm);
  padding: var(--space-2xs) var(--space-xs);
}
.plan-roundel {
  display: inline-flex;
  flex: 0 0 auto;
  width: var(--roundel-s);
  height: var(--roundel-s);
  border-radius: 50%;
  overflow: hidden;
  box-sizing: border-box;
  border: 1px solid var(--plan-roundel-border);
  box-shadow: 0 0 0 1px var(--plan-roundel-ring);
  line-height: 0;
}
.plan-roundel .nation-roundel { display: block; width: 100%; height: 100%; border-radius: 50%; }
.plan-roundel--active { box-shadow: 0 0 0 2px var(--accent-gold); }
@media (pointer: coarse), (max-width: 500px) {
  .plan-banner__actions .btn { min-height: var(--tap-min); }
}

/* ── OddsChip (#5252, spec §6.10 / §7.3) ─────────────────────────────────
   The one odds display: a 22px ink pill with a 34×6 win bar, the win percent
   in mono and the IPC swing. `na` is dashed with a striped bar; `map` adds the
   brass border and shadow (the Pixi map sign draws the same geometry). */
.odds-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--odds-gap);
  height: var(--odds-h);
  padding: var(--odds-pad);
  border-radius: var(--odds-radius);
  background: var(--bg-ink);
  border: 1px solid var(--border-primary);
  font: 600 var(--odds-font)/1 var(--font-mono);
  color: var(--text-ivory);
  white-space: nowrap;
  flex: none;
}
button.odds-chip { cursor: pointer; }
button.odds-chip:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: 1px; }
.odds-chip-bar {
  position: relative;
  width: var(--odds-bar-w);
  height: var(--odds-bar-h);
  border-radius: var(--odds-bar-radius);
  background: var(--odds-track);
  overflow: hidden;
  flex: none;
}
.odds-chip-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--odds-fill);
}
.odds-chip-swing { font-weight: 400; font-size: var(--odds-swing-font); color: var(--text-ivory-muted); }
.odds-chip-swing b { font-weight: 500; color: var(--accent-danger-text); }
.odds-chip-swing b.odds-chip-them { color: var(--plan-them-text); }
.odds-chip-dice { font-size: var(--odds-dice-font); opacity: 0.7; }
.odds-chip.is-na { color: var(--text-ivory-muted); border-style: dashed; }
.odds-chip.is-na .odds-chip-bar { background: var(--odds-na-stripe); }
.odds-chip.is-map { box-shadow: var(--shadow-md); border-color: var(--border-brass); }
.target-group-stale { font-size: var(--text-xs); color: var(--accent-gold); }
.plan-tab-odds { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2xs); }
.planner-sim-odds { display: flex; justify-content: center; margin-bottom: var(--space-sm); }

/* plan: L2 Discord digest (#5270). Mockup .digest. Portaled so the sidebar does not clip it. */
.plan-digest {
  position: fixed;
  z-index: var(--z-plan-sheet);
  left: var(--plan-digest-inset);
  bottom: var(--plan-digest-bottom);
  width: var(--plan-digest-w);
  box-sizing: border-box;
  background: var(--surface-tooltip);
  border: 1px solid var(--border-modal);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--plan-digest-pad);
  display: flex;
  flex-direction: column;
  gap: var(--plan-digest-gap);
  color: var(--text-ivory);
}
.plan-digest__head {
  display: flex;
  align-items: center;
  gap: var(--plan-banner-gap);
}
.plan-digest__kicker {
  margin: 0;
  flex: 1;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--plan-digest-kicker);
  line-height: 1;
  letter-spacing: var(--plan-digest-track);
  text-transform: uppercase;
  color: var(--text-heading);
}
.plan-digest__close {
  margin-left: auto;
  font-size: var(--plan-digest-close);
  letter-spacing: 0;
  padding: 0;
}
.plan-digest__channel {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: var(--plan-banner-btn);
  line-height: 1.3;
  color: var(--text-ivory-muted);
}
.plan-digest__channel b {
  color: var(--plan-them-text);
  font-weight: 500;
  white-space: nowrap;
}
.plan-digest__pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: var(--plan-banner-btn);
  line-height: 1.45;
  color: var(--text-ivory);
  background: var(--bg-ink);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  padding: var(--plan-digest-pre-pad);
  max-height: var(--plan-digest-pre);
  overflow: auto;
}
.plan-digest__link {
  display: flex;
  gap: var(--plan-banner-gap);
  align-items: center;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--plan-banner-btn);
  line-height: 1.3;
  color: var(--plan-color-azure);
  white-space: nowrap;
  overflow: hidden;
}
.plan-digest__link span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-digest__link b {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: var(--plan-digest-link-label);
  line-height: 1;
  letter-spacing: var(--plan-digest-track);
  text-transform: uppercase;
  color: var(--text-ivory-muted);
  flex: none;
}
.plan-digest__opts {
  display: flex;
  gap: var(--plan-digest-inset);
  flex-wrap: wrap;
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: var(--plan-banner-btn);
  line-height: 1;
  color: var(--text-ivory-muted);
}
.plan-digest__opt {
  display: inline-flex;
  align-items: center;
  gap: var(--plan-banner-gap);
}
.plan-digest__chk {
  width: var(--plan-digest-chk);
  height: var(--plan-digest-chk);
  box-sizing: border-box;
  padding: 0;
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--plan-digest-link-label);
  line-height: 1;
  cursor: pointer;
}
.plan-digest__chk--on { background: var(--toggle-track-on); }
.plan-digest__acts {
  display: flex;
  gap: var(--plan-banner-gap);
  justify-content: flex-end;
}
.plan-digest__acts .btn {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: var(--plan-banner-btn);
  line-height: 1;
  min-height: var(--plan-banner-btn-min);
  white-space: nowrap;
}
.plan-digest__acts .btn.btn-primary {
  background: var(--btn-bg-primary);
  color: var(--text-ivory);
  border-color: var(--accent-brass);
}
.plan-digest__acts .btn.btn-ghost {
  flex: 0 0 auto;
  width: auto;
  background: transparent;
  color: var(--text-ivory-muted);
  border-color: transparent;
  box-shadow: none;
}
.plan-digest--sheet {
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  border-radius: var(--plan-digest-sheet-radius) var(--plan-digest-sheet-radius) 0 0;
  padding-bottom: calc(var(--plan-digest-pad-b) + var(--safe-b));
  background: var(--bg-rail);
}
.plan-digest--sheet .plan-digest__pre { max-height: var(--plan-digest-pre-phone); }
.plan-digest--land {
  top: var(--plan-digest-land-inset);
  bottom: var(--plan-digest-land-inset);
  left: var(--plan-digest-land-inset);
  width: var(--plan-digest-w-land);
}
.plan-digest--land .plan-digest__pre {
  flex: 1;
  min-height: 0;
  max-height: none;
}
@media (pointer: coarse), (max-width: 500px) {
  .plan-digest__acts .btn { min-height: var(--tap-min); }
}

/* ===== Plan tab (M1 #5273): header, groups, cards, rows ===== */
.plan-tab {
  display: flex;
  flex-direction: column;
  gap: var(--plan-tab-gap);
  padding: var(--plan-tab-pad);
  font-family: var(--font-ui);
  color: var(--text-ivory);
  min-height: 0;
}
.plan-head { display: flex; gap: var(--plan-group-gap); align-items: center; }
.plan-head__spacer { flex: 1; }
.plan-dd {
  display: inline-flex; align-items: center; gap: 5px;
  height: var(--plan-dd-h); padding: 0 8px;
  border: 1px solid var(--border-brass); background: var(--bg-raised);
  border-radius: var(--radius-sm);
  font: 500 11px/1 var(--font-ui); color: var(--text-ivory);
  cursor: pointer; white-space: nowrap;
}
.plan-dd__car { color: var(--text-ivory-muted); font-size: 9px; }
.plan-dd--archived { border-color: var(--text-ivory-muted); color: var(--text-ivory-muted); }
.plan-dd-wrap { position: relative; display: inline-block; }
.plan-dd__menu {
  position: absolute; top: calc(100% + 2px); left: 0; z-index: var(--z-overlay);
  min-width: 100%; display: flex; flex-direction: column;
  background: var(--surface-tooltip); border: 1px solid var(--border-modal);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 2px;
}
.plan-dd__item {
  display: block; width: 100%; text-align: left; padding: 5px 8px; border: 0; background: transparent;
  font: 500 11px/1.2 var(--font-ui); color: var(--text-ivory); border-radius: var(--radius-xs); cursor: pointer; white-space: nowrap;
}
.plan-dd__item:hover, .plan-dd__item[aria-checked='true'] { background: var(--overlay-gold-08); }
.plan-dd__item--archived { color: var(--text-ivory-muted); }
.plan-sh {
  font: 600 10px/1 var(--font-ui); letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-heading); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; row-gap: 4px;
}
.plan-sh__cnt { color: var(--text-ivory-muted); font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 11px; }
.plan-sh__r { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.plan-sh--sub { color: var(--text-ivory-muted); font-size: 9px; }
.plan-sh--sub .plan-sh__note { text-transform: none; letter-spacing: 0; color: var(--text-muted); font-weight: 400; }
.plan-grp__bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.plan-tab { min-width: 0; }
.plan-tab > * { min-width: 0; }
.plan-sh__r { margin-left: auto; }
/* The name is a real flex child so a long one wraps inside the row instead of
   painting under Remove (#5313). `display: contents` let the text shrink to
   nothing and overflow the button. */
.plan-obj__open {
  display: flex; align-items: flex-start; gap: var(--plan-tab-gap);
  flex: 1 1 8rem; min-width: 0;
  background: none; border: 0; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.plan-obj__open .plan-row__grow { flex: 1; min-width: 0; overflow-wrap: break-word; }
.plan-btn--start { align-self: flex-start; }
.plan-picker-slot { display: flex; flex-direction: column; min-height: 0; }
.plan-grp__head {
  display: flex; align-items: center; gap: 6px; flex: 1 1 auto; padding: 2px 0;
  background: none; border: 0; cursor: pointer; user-select: none; text-align: left;
}
.plan-grp__car { width: 12px; color: var(--text-ivory-muted); font-size: 10px; flex: none; }
.plan-grp__body { display: flex; flex-direction: column; gap: var(--plan-group-gap); margin-top: var(--plan-group-gap); }
.plan-grp--closed .plan-grp__body { display: none; }
.plan-row { display: flex; align-items: center; gap: 8px; font: 400 12px/1.3 var(--font-ui); }
.plan-row__grow { flex: 1; min-width: 0; }
.plan-muted { color: var(--text-ivory-muted); }
.plan-sep { height: 1px; background: var(--border-brass); margin: 2px 0; flex: none; }
.plan-empty { font: italic 400 12px/1.4 var(--font-body); color: var(--text-ivory-muted); }
.plan-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 4px 10px; min-height: 26px; font: 500 11px/1 var(--font-ui);
  background: var(--btn-bg); color: var(--btn-text); border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm); cursor: pointer; white-space: nowrap;
}
.plan-btn--primary { background: var(--btn-bg-primary); border-color: var(--accent-brass); color: var(--text-ivory); }
.plan-btn--ghost { background: transparent; border-color: transparent; color: var(--text-ivory-muted); }
.plan-btn--block { width: 100%; }
.plan-btn--lg { min-height: 34px; font-size: 12px; }
.plan-btn--sm { min-height: 22px; }
.plan-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.plan-btn--grow { flex: 1; }
/* Pills (spec §7.3) */
.plan-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: var(--plan-pad-pill); border-radius: 10px;
  font: 500 10px/1.3 var(--font-ui); border: 1px solid var(--border-primary);
  background: var(--surface-mid); color: var(--text-ivory); white-space: nowrap;
}
.plan-pill--proposed { background: var(--overlay-success-15); border-color: var(--plan-ready-border); color: var(--plan-ready-text); }
.plan-pill--planned { color: var(--text-ivory-muted); }
.plan-pill--on-board { background: var(--overlay-gold-12); border-color: var(--accent-brass); color: var(--accent-gold); }
.plan-pill--needs-units { background: var(--overlay-danger-15); border-color: var(--plan-broken-border); color: var(--accent-danger-text); }
.plan-pill--done, .plan-pill--expired { color: var(--text-muted); }
.plan-pill--fog { border-color: var(--plan-fog-border); color: var(--plan-them-text); }
/* Ready switch */
.plan-switch {
  display: inline-flex; align-items: center; gap: 5px; padding: 0; background: none; border: 0;
  font: 500 10px/1 var(--font-ui); color: var(--text-ivory-muted); cursor: pointer;
}
/* The xs size of the one switch (ui/SwitchTrack variant="xs", #5562). */
.toggle-switch--xs {
  width: var(--plan-switch-w); height: var(--plan-switch-h); border-radius: 7px;
  background: var(--surface-mid); box-sizing: border-box; transition: none;
}
.toggle-switch--xs .toggle-knob {
  width: var(--plan-switch-knob); height: var(--plan-switch-knob); top: 1px; left: 1px;
  background: var(--text-ivory-muted); box-shadow: none; transition: left var(--transition-fast);
}
.toggle-switch--xs.toggle-switch--on { background: var(--toggle-track-on); border-color: var(--accent-brass); }
.toggle-switch--xs.toggle-switch--on .toggle-knob { left: 13px; background: var(--accent-gold); }
.plan-switch[aria-checked='true'] { color: var(--accent-gold); }
.plan-switch:disabled { opacity: 0.45; cursor: not-allowed; }
/* Order card */
.plan-ocard {
  border: 1px solid var(--border-tan-12); background: var(--surface-card); border-radius: var(--radius-md);
  padding: var(--plan-pad-card); display: flex; flex-direction: column; gap: var(--plan-card-gap);
}
.plan-ocard--sel { border-color: var(--accent-brass); background: var(--overlay-gold-08); }
.plan-ocard--needs-units { border-color: var(--plan-broken-card); }
.plan-ocard--done, .plan-ocard--expired { opacity: 0.6; }
.plan-ocard__t { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font: 600 13px/1.2 var(--font-ui); }
.plan-ocard__kind { width: 8px; height: 8px; border-radius: 2px; flex: none; background: var(--plan-kind-attack); }
.plan-ocard__kind--move { background: var(--plan-kind-move); }
.plan-ocard__kind--landing { background: var(--plan-kind-landing); }
.plan-ocard__kind--raid { background: var(--plan-kind-raid); }
.plan-ocard__kind--carrier { background: var(--plan-kind-carrier); }
.plan-ocard__k { font-size: 12px; }
.plan-ocard__arrow { color: var(--text-ivory-muted); font-weight: 400; }
.plan-ocard__tag { font: 400 10px/1 var(--font-ui); color: var(--text-ivory-muted); white-space: nowrap; }
.plan-ocard__state { margin-left: auto; }
.plan-ocard__legs { font: 400 11px/1.35 var(--font-ui); color: var(--text-secondary); }
.plan-ocard__legs b { color: var(--text-ivory); font-weight: 500; }
.plan-ocard__vs { color: var(--text-ivory-muted); }
.plan-ocard__why { font: 400 11px/1.3 var(--font-ui); color: var(--accent-danger-text); display: flex; gap: 5px; align-items: flex-start; }
.plan-ocard__foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.plan-ocard__r { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.plan-ocard__later { font: 400 10px/1.3 var(--font-ui); color: var(--text-ivory-muted); text-align: right; }
.plan-ocard__author { display: inline-flex; align-items: center; gap: 4px; font: 400 10px/1 var(--font-ui); color: var(--text-ivory-muted); }
/* Objective and mark rows */
.plan-obj {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--plan-tab-gap);
  padding: var(--plan-pad-row); border-radius: var(--radius-sm);
  background: var(--surface-panel); border: 1px solid var(--border-secondary); font: 500 12px/1.2 var(--font-ui);
  width: 100%; text-align: left; color: var(--text-ivory); cursor: pointer;
}
.plan-obj__ic {
  width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font: 700 10px/1 var(--font-ui); flex: none; color: var(--plan-on-objective); background: var(--plan-kind-attack);
}
.plan-obj__ic--hold { background: var(--plan-color-lime); }
.plan-obj__ic--deny { background: var(--plan-color-amber); }
.plan-obj__sub { display: block; font-weight: 400; font-size: 10px; color: var(--text-ivory-muted); margin-top: 2px; }
.plan-obj__r { margin-left: auto; display: flex; align-items: center; gap: var(--plan-group-gap); flex: 0 0 auto; }
/* Kind picker (#5313): the territory is its own line. The buttons wrap under it
   and do not shrink, so "Greater Southern Germany" cannot sit on Take. */
.plan-objective-kind {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--plan-tab-gap);
  min-width: 0; font: 400 12px/1.3 var(--font-ui); color: var(--text-ivory);
}
.plan-objective-kind__name { min-width: 0; overflow-wrap: break-word; }
.plan-objective-kind__name b { font-weight: 600; }
.plan-objective-kind__acts {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--plan-tab-gap); min-width: 0;
}
.plan-objective-kind__acts .plan-btn { flex: 0 0 auto; }
.plan-mark {
  display: flex; align-items: center; gap: 7px; padding: 4px 2px; font: 400 12px/1.3 var(--font-ui);
  width: 100%; background: none; border: 0; color: var(--text-ivory); text-align: left; cursor: pointer;
}
.plan-mark-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-xs); }
.plan-mark--sel { background: var(--overlay-gold-08); }
.plan-mark__sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.plan-mark__glyph { width: 14px; text-align: center; color: var(--text-ivory-muted); flex: none; }
.plan-archive-bar {
  padding: 6px 8px; border-radius: var(--radius-sm); background: var(--surface-mid); border: 1px dashed var(--border-brass);
  font: 400 12px/1.3 var(--font-body); color: var(--text-ivory); display: flex; gap: 8px; align-items: center;
}
/* Phone and phone landscape: 13px tap buttons and 44px targets (mockup .btn.tap), the S3 banner too. */
@media (max-width: 500px), (max-height: 500px) and (orientation: landscape) {
  .plan-tab .plan-btn--tap, .plan-banner__actions .btn { min-height: var(--tap-min); font-size: var(--plan-tap-font); }
  .plan-switch { min-height: 32px; }
}
/* iPad-class touch is wider than 500px, so the viewport query above stays at
   26px. The kind picker and an objective's Remove still need a fingertip (#5313). */
@media (pointer: coarse) {
  .plan-tab .plan-objective-kind__acts .plan-btn--tap,
  .plan-tab .plan-obj__r .plan-btn--tap {
    min-height: var(--tap-min);
    font-size: var(--plan-tap-font);
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .plan-tab { padding: var(--plan-tab-pad-land); }
  .plan-tab[data-view="picker"] { padding: 0; }
}

/* The plan switcher in the Plan tab header wears the same 26px dropdown chrome as the round selector. */
.plan-head .plan-switcher-toggle {
  height: var(--plan-dd-h); padding: 0 8px; max-width: none;
  border: 1px solid var(--border-brass); background: var(--bg-raised); border-radius: var(--radius-sm);
  font: 500 11px/1 var(--font-ui); color: var(--text-ivory);
}
.plan-head .plan-switcher-caret { color: var(--text-ivory-muted); font-size: 9px; }
.board-sidebar-tab--plan { font-size: 19px; font-weight: 600; }

@media (max-height: 500px) and (orientation: landscape) {
  .plan-head { gap: 4px; }
  .plan-head .plan-dd, .plan-head .plan-switcher-toggle { padding: 0 6px; }
  .plan-head .plan-btn--ghost { padding: 4px 2px; }
  .plan-grp__head { white-space: nowrap; }
  .plan-sh__r .plan-btn--sm { padding: 2px 6px; }
}

/* ── Plan mode M4 (#5274): palette, tool rail, bottom sheet, picker, map badges ── */
/* Spec §6.2–§6.4, §6.7, §6.11, §7.3. Values are the mockup's (`docs/design/plan-mode/mockups`). */

/* Desktop palette: docked top-left of the map, keys 1–8. */
.plan-palette {
  position: absolute;
  /* The map area already clears the notch (.board-main-content pads --safe-l; the top bar takes
     --safe-t), so inside it the gutter alone is enough: adding the inset again doubled it. */
  top: var(--space-sm);
  left: var(--space-sm);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  background: var(--surface-tooltip);
  border: 1px solid var(--border-modal);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-ui);
}
.plan-palette__grp { display: flex; gap: 3px; align-items: center; }
.plan-palette__div { width: 1px; height: 26px; margin: 0 3px; background: var(--border-brass); }
.plan-palette__sect {
  padding: 0 4px;
  font: 600 8px/1 var(--font-ui);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.plan-palette__ctx { padding: 0 6px; font: 500 11px/1 var(--font-ui); color: var(--text-ivory-muted); }
.plan-palette__armed {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  font: 500 10px/1 var(--font-ui);
  color: var(--accent-gold);
  white-space: nowrap;
}
.plan-palette__armed i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 6px var(--accent-gold);
}

.plan-ptool {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: var(--plan-tool-h);
  padding: 0 9px;
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  border: 1px solid var(--border-primary);
  color: var(--text-ivory);
  font: 500 11px/1 var(--font-ui);
  white-space: nowrap;
  cursor: pointer;
}
.plan-ptool:hover:not(:disabled):not([aria-pressed="true"]) { background: var(--surface-hover); }
.plan-ptool:disabled { opacity: 0.45; cursor: not-allowed; }
.plan-ptool:focus-visible,
.plan-pswatch:focus-visible,
.plan-rail__item:focus-visible,
.bottom-sheet__snap:focus-visible,
.plan-ubadge:focus-visible,
.plan-objm:focus-visible,
.plan-lab:focus-visible { outline: 2px solid var(--accent-brass); outline-offset: -2px; }
.plan-ptool__glyph { font-size: 13px; }
.plan-ptool__kbd {
  position: absolute;
  top: -6px;
  right: -4px;
  padding: 1px 3px;
  font: 500 8px/1 var(--font-mono);
  color: var(--text-ivory-muted);
  background: var(--bg-ink);
  border: 1px solid var(--border-primary);
  border-radius: 2px;
}
.plan-ptool--order { border-color: var(--plan-order-tool-border); }
.plan-ptool[aria-pressed="true"] {
  background: var(--accent-brass);
  color: var(--color-on-gold);
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px var(--plan-tool-ring);
}
.plan-ptool[aria-pressed="true"] .plan-ptool__kbd {
  color: var(--color-on-gold);
  background: var(--accent-gold-bright);
  border-color: var(--accent-gold);
}
.plan-ptool--attack[aria-pressed="true"] { background: var(--plan-kind-attack); color: var(--plan-on-attack); border-color: var(--text-ivory); }
.plan-ptool--move[aria-pressed="true"] { background: var(--plan-kind-move); color: var(--plan-on-move); border-color: var(--text-ivory); }
.plan-ptool--landing[aria-pressed="true"] { background: var(--plan-kind-landing); color: var(--plan-on-landing); border-color: var(--text-ivory); }
.plan-ptool--raid[aria-pressed="true"] { background: var(--plan-kind-raid); color: var(--plan-on-raid); border-color: var(--text-ivory); }
/* The Select button is not a tool: no armed fill. */
.plan-ptool--select[aria-pressed="true"] {
  background: var(--btn-bg);
  color: var(--text-ivory);
  border-color: var(--border-primary);
  box-shadow: none;
}

.plan-pswatch {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.plan-pswatch[aria-pressed="true"] { border-color: var(--color-white); box-shadow: 0 0 0 1px var(--bg-ink); }
.plan-pswatch--crimson { background: var(--plan-color-crimson); }
.plan-pswatch--azure { background: var(--plan-color-azure); }
.plan-pswatch--amber { background: var(--plan-color-amber); }
.plan-pswatch--lime { background: var(--plan-color-lime); }
.plan-pswatch--magenta { background: var(--plan-color-magenta); }
.plan-pswatch--ink { background: var(--plan-color-ink); }

/* Touch tool rail: vertical on the left (phone portrait, iPad), a row in phone landscape. */
.plan-rail {
  position: absolute;
  /* The map area already clears the notch (.board-main-content pads --safe-l; the top bar takes
     --safe-t), so inside it the gutter alone is enough: adding the inset again doubled it. */
  top: var(--space-sm);
  left: var(--space-sm);
  z-index: var(--z-overlay);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--plan-rail-pad);
  background: var(--surface-tooltip);
  border: 1px solid var(--border-modal);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.plan-rail--h { flex-direction: row; }
.plan-rail__item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-min);
  height: var(--tap-min);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-ivory);
  font: 400 19px/1 var(--font-ui);
  cursor: pointer;
  -webkit-touch-callout: none;
  user-select: none;
}
.plan-rail__item:disabled { opacity: 0.45; cursor: not-allowed; }
.plan-rail__item[aria-pressed="true"] {
  border-color: var(--accent-gold);
  background: var(--accent-brass);
  color: var(--color-on-gold);
  box-shadow: inset 0 0 0 1px var(--overlay-dark-30);
}
.plan-rail__item--attack[aria-pressed="true"] { background: var(--plan-kind-attack); color: var(--plan-on-attack); }
.plan-rail__item--move[aria-pressed="true"] { background: var(--plan-kind-move); color: var(--plan-on-move); }
.plan-rail__item--landing[aria-pressed="true"] { background: var(--plan-kind-landing); color: var(--plan-on-landing); }
.plan-rail__item--raid[aria-pressed="true"] { background: var(--plan-kind-raid); color: var(--plan-on-raid); }
.plan-rail__kind { position: absolute; left: 4px; top: 4px; width: 6px; height: 6px; border-radius: 2px; }
.plan-rail__item--attack .plan-rail__kind { background: var(--plan-kind-attack); }
.plan-rail__item--move .plan-rail__kind { background: var(--plan-kind-move); }
.plan-rail__item--landing .plan-rail__kind { background: var(--plan-kind-landing); }
.plan-rail__item--raid .plan-rail__kind { background: var(--plan-kind-raid); }
.plan-rail__sep { height: 1px; margin: 2px 4px; background: var(--border-brass); }
.plan-rail--h .plan-rail__sep { width: 1px; height: auto; margin: 4px 2px; }
.plan-rail__swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--color-white);
  box-shadow: 0 0 0 1px var(--bg-ink);
}
.plan-rail__done { color: var(--accent-gold); font-size: 16px; }
.plan-rail__flyout {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  white-space: nowrap;
  font: 500 11px/1 var(--font-ui);
  color: var(--text-ivory);
  background: var(--surface-tooltip);
  border: 1px solid var(--border-modal);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
.plan-rail--h .plan-rail__flyout { left: 0; top: calc(100% + 8px); transform: none; }
.plan-rail__flyout i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-gold);
  box-shadow: 0 0 6px var(--accent-gold);
}
.plan-rail__flyout b { font-weight: 600; }
.plan-rail__flyout small { color: var(--text-ivory-muted); font-size: 10px; }
.plan-rail-hint {
  position: absolute;
  z-index: var(--z-overlay);
  top: var(--space-sm);
  left: calc(var(--space-sm) + 54px);
  padding: 4px 7px;
  font: italic 400 11px/1.2 var(--font-body);
  color: var(--text-ivory-muted);
  background: var(--overlay-dark-70);
  border-radius: var(--radius-xs);
  white-space: nowrap;
  pointer-events: none;
}
.plan-rail-hint--h { top: calc(var(--space-sm) + 54px); left: var(--space-sm); }

/* BottomSheet (components/ui/BottomSheet.tsx): phone-portrait host for the picker. */
.bottom-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-plan-sheet);
  display: flex;
  flex-direction: column;
  height: var(--plan-sheet-half);
  background: linear-gradient(180deg, var(--bg-rail), var(--bg-ink));
  border-top: 1px solid var(--border-brass);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--plan-sheet-shadow);
  transition: height var(--transition-normal);
  outline: none;
}
/* The sheet takes focus when it opens; a keyboard user sees it, inside the edge (#5565). */
.bottom-sheet:focus-visible { outline: 2px solid var(--accent-gold); outline-offset: -2px; }
.bottom-sheet--strip { height: calc(var(--plan-sheet-strip) + var(--safe-b)); }
.bottom-sheet--half { height: calc(var(--plan-sheet-half) + var(--safe-b)); }
.bottom-sheet--full { height: calc(var(--plan-sheet-full) + var(--safe-b)); }
.bottom-sheet--dragging { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .bottom-sheet { transition: none; }
}
.bottom-sheet__grab {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  touch-action: none;
  cursor: grab;
}
.bottom-sheet__grab i { width: 36px; height: 4px; border-radius: 2px; background: var(--text-ivory-muted); }
.bottom-sheet__snaps { position: absolute; z-index: 2; right: 10px; top: 0; display: flex; gap: 2px; }
/* 22×14 visual inside a 44px hit area (spec §8). */
.bottom-sheet__snap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 24px;
  height: var(--tap-min);
  padding: 6px 0 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.bottom-sheet__snap i {
  width: 22px;
  height: 14px;
  border: 1px solid var(--border-primary);
  border-radius: 2px;
  background: var(--surface-mid);
}
.bottom-sheet__snap[aria-pressed="true"] i { background: var(--accent-brass); }
.bottom-sheet__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* No side padding: the picker inside carries its own, so its box spans the sheet (mockup pickerBody). */
  padding: 0 0 calc(var(--space-md) + var(--safe-b));
  scrollbar-width: thin;
}
.bottom-sheet--strip .bottom-sheet__body { overflow: hidden; }

/* The docked order picker (plan/ui/OrderPicker.tsx). */
/* The picker is the whole tab body while it is open (spec §6.7): it runs to the sidebar's edges, so it
   cancels the scroll pane's insets and carries its own padding, as the mockup's pickerBody does. */
.plan-tab[data-view="picker"] { padding: 0; margin: -6px -10px; min-height: calc(100% + 12px); }
.plan-picker-host { display: flex; flex: 1 1 auto; }
.plan-picker { display: flex; flex: 1 1 auto; flex-direction: column; gap: 8px; min-width: 0; padding: 10px 12px 12px; font-family: var(--font-ui); color: var(--text-ivory); }
.plan-picker__head { display: flex; flex-direction: column; gap: 4px; }
.plan-picker__title { display: flex; align-items: center; gap: 6px; font: 600 14px/1.2 var(--font-ui); }
.plan-picker__mode { font: 400 12px/1.3 var(--font-body); color: var(--text-ivory-muted); }
.plan-picker__mode b { font: 600 11px/1.3 var(--font-ui); color: var(--accent-gold); }
/* L1 #5298: on a sea zone the Move tool's picker switches between a Move and a Carrier order. */
.plan-picker__intents { display: flex; gap: var(--space-xs); }
.plan-picker__intent {
  flex: 1; min-height: 26px; padding: 0 var(--space-sm); border: 1px solid var(--border-primary); border-radius: var(--radius-sm);
  background: var(--btn-bg); color: var(--text-ivory); font: 600 11px/1 var(--font-ui); cursor: pointer;
}
.plan-picker__intent[aria-pressed="true"] { border-color: var(--text-ivory); background: var(--plan-kind-move); color: var(--plan-on-move); }
.plan-picker__intent[data-testid="plan-picker-intent-declareCarrier"][aria-pressed="true"] { background: var(--plan-kind-carrier); color: var(--plan-on-move); }
@media (pointer: coarse) { .plan-picker__intent { min-height: 44px; } }
/* A landing's transport and bombardment rows sit under the land and air sources. */
.plan-picker__landing { margin-top: var(--space-sm); }
/* L4 #5311: in the phone and tablet pickers the transport rows (AmphibiousSection, built for the desktop
   planner) get 44 px targets (spec §8): the transport toggle, its sea zone, the load and bombard buttons. */
@media (pointer: coarse) {
  .plan-picker__landing label,
  .plan-picker__landing button,
  .plan-picker__landing select { min-height: 44px; }
  .plan-picker__landing input[type="checkbox"] { width: 22px; height: 22px; }
}
.plan-picker__odds {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  background: var(--bg-rail);
  border-bottom: 1px solid var(--border-brass-grid);
}
.plan-picker__vs { font: 400 11px/1.3 var(--font-ui); color: var(--text-ivory-muted); }
.plan-picker__vs b { font-weight: 500; color: var(--text-ivory); }
.plan-picker__hint { font: italic 400 11px/1.3 var(--font-body); color: var(--text-ivory-muted); }
.plan-picker__empty { font: 400 12px/1.3 var(--font-body); color: var(--text-ivory-muted); }
/* L4 #5311: why the pick cannot be saved yet (a raid with no bomber). */
.plan-picker__blocked { font: 400 12px/1.3 var(--font-body); color: var(--accent-red-bright); }
.plan-picker__srcs { display: flex; flex-direction: column; gap: 8px; }
.plan-src { display: flex; flex-direction: column; gap: 3px; }
.plan-src__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 2px 6px;
  border-left: 2px solid var(--border-primary);
  font: 600 12px/1 var(--font-ui);
  color: var(--text-ivory-muted);
}
.plan-src__head--lit { border-left-color: var(--color-valid); color: var(--text-ivory); }
.plan-src__dist { font-weight: 400; font-size: 10px; color: var(--text-ivory-muted); }
.plan-src__all {
  margin-left: auto;
  padding: 0 4px;
  border: 0;
  background: transparent;
  font: 600 10px/1 var(--font-ui);
  color: var(--accent-gold);
  cursor: pointer;
}
.plan-urow { display: flex; align-items: center; gap: 6px; padding: 2px 0 2px 8px; font: 400 12px/1 var(--font-ui); }
.plan-urow__u { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.plan-urow__max { font: 400 10px/1 var(--font-mono); color: var(--text-ivory-muted); }
@media (pointer: coarse) {
  .plan-urow { padding: 3px 0 3px 8px; font-size: 13px; }
}
/* #5320: in the 216 px phone-landscape drawer the stepper took the row and clipped the name ("Carrie", "Infan").
   The name, icon and count take the first line whole, the stepper the line under it, right-aligned. */
.plan-urow--narrow { flex-wrap: wrap; row-gap: 2px; }
.plan-urow--narrow .plan-urow__u { flex: 1 1 100%; overflow: visible; text-overflow: clip; }
.plan-urow--narrow > :last-child { margin-left: auto; }
/* #3365: the sources own the scroll; nothing pins over them. */
.plan-picker__sources { flex: 0 1 auto; min-height: 0; }
.plan-picker__sim { padding-top: 4px; border-top: 1px solid var(--border-brass-grid); }
.plan-picker__subhead {
  font: 600 9px/1 var(--font-ui);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
  margin-bottom: 4px;
}
.plan-picker__ask {
  flex: 0 0 auto;
  align-self: stretch;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: var(--text-xs);
  line-height: 1;
  border-color: var(--border-primary);
}
@media (pointer: coarse) {
  .plan-picker__ask { min-height: var(--tap-min); }
}
.plan-picker__foot { display: flex; gap: 6px; }
.plan-picker__btn { flex: 1; min-height: 26px; font: 500 11px/1 var(--font-ui); border-color: var(--border-primary); }
.plan-picker__btn--primary { background: var(--btn-bg-primary); border-color: var(--accent-brass); color: var(--text-ivory); }
@media (pointer: coarse) {
  .plan-picker__btn { min-height: var(--tap-min); font-size: 13px; }
}
.plan-kind-square { flex: none; display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.plan-kind-square--attack { background: var(--plan-kind-attack); }
.plan-kind-square--move { background: var(--plan-kind-move); }
.plan-kind-square--declareCarrier { background: var(--plan-kind-carrier); }
.plan-kind-square--amphibious { background: var(--plan-kind-landing); }
.plan-kind-square--sbr { background: var(--plan-kind-raid); }

/* DOM map badges (plan/ui/BadgeLayer.tsx): one rAF loop writes each `.plan-mb` transform. */
.plan-badges {
  position: absolute;
  inset: 0;
  z-index: var(--z-plan-badges);
  overflow: hidden;
  pointer-events: none;
}
.plan-mb {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  visibility: hidden;
  will-change: transform;
}
.plan-mb > * { pointer-events: auto; }
.plan-ubadge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: var(--plan-badge-h);
  padding: 0 7px;
  border-radius: 10px;
  background: var(--bg-ink);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-md);
  font: 500 10px/1 var(--font-ui);
  color: var(--text-ivory);
  white-space: nowrap;
  cursor: pointer;
}
.plan-ubadge--draft { border-style: dashed; color: var(--text-secondary); }
.plan-ubadge--archive { color: var(--text-secondary); opacity: 0.85; }
.plan-ubadge__kind { width: 7px; height: 7px; border-radius: 2px; }
.plan-kind-bg--attack { background: var(--plan-kind-attack); }
.plan-kind-bg--move { background: var(--plan-kind-move); }
.plan-kind-bg--landing { background: var(--plan-kind-landing); }
.plan-kind-bg--raid { background: var(--plan-kind-raid); }
.plan-kind-bg--carrier { background: var(--plan-kind-carrier); }
.plan-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--border-primary);
  background: var(--surface-mid);
  font: 500 10px/1.3 var(--font-ui);
  color: var(--text-ivory);
  white-space: nowrap;
}
.plan-pill--broken { background: var(--overlay-danger-15); border-color: var(--plan-broken-border); color: var(--accent-danger-text); }
.plan-objm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: var(--plan-badge-h);
  padding: 0 7px 0 4px;
  border-radius: 10px;
  background: var(--bg-ink);
  border: 1px solid var(--border-primary);
  box-shadow: var(--shadow-md);
  font: 700 9px/1 var(--font-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-ivory);
  white-space: nowrap;
  cursor: pointer;
}
.plan-objm i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
.plan-objm--take i { background: var(--plan-color-crimson); }
.plan-objm--hold i { background: var(--plan-color-lime); }
.plan-objm--deny i { background: var(--plan-color-amber); }
.plan-lab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: var(--radius-xs);
  background: var(--plan-label-bg);
  border: 1px solid currentColor;
  box-shadow: var(--shadow-md);
  font: 500 11px/1.2 var(--font-ui);
  white-space: nowrap;
  cursor: pointer;
}
.plan-lab--big { font-size: 15px; }
.plan-lab--sel { box-shadow: 0 0 0 2px currentColor, var(--shadow-md); }
.plan-lab--crimson { color: var(--plan-color-crimson); }
.plan-lab--azure { color: var(--plan-color-azure); }
.plan-lab--amber { color: var(--plan-color-amber); }
.plan-lab--lime { color: var(--plan-color-lime); }
.plan-lab--magenta { color: var(--plan-color-magenta); }
.plan-lab--ink { color: var(--plan-color-ink); }
.plan-tail-author { display: inline-flex; }

/* SBR planning (L4 #5311): the chosen factory card; the aircraft are picked in the raid picker. */
.sbr-raid-target {
  margin-bottom: var(--space-sm); padding: var(--space-sm);
  background: var(--bg-raised); border: 1px solid var(--accent-brass); border-radius: var(--radius-sm);
  display: flex; flex-direction: column; gap: var(--space-xs);
}
.sbr-raid-target__head { display: flex; justify-content: space-between; align-items: center; font: 600 var(--text-sm)/1.3 var(--font-ui); color: var(--text-ivory); }
.sbr-raid-target__note { display: flex; align-items: center; gap: 3px; font-size: var(--text-xs); color: var(--text-secondary); }
.sbr-raid-target__none { font-size: var(--text-xs); color: var(--accent-red); }
.sbr-raid-target__plan { width: 100%; }
@media (pointer: coarse) { .sbr-raid-target__plan { min-height: 44px; } }
.territory-sbr-plan { width: 100%; }
@media (pointer: coarse) { .territory-sbr-plan { min-height: 44px; } }

/* ══ Admin console, /admin (#5474, epic #5470 §6) ══
 * Instrument HUD (conventions rule 9): ink page, rail header and nav, raised
 * cards, ivory text, brass hairlines. --font-ui for chrome, --font-mono for ids
 * and counters. Gold and Cinzel once: the page title. Status colour only through
 * the Badge primitive. Phone: the nav becomes top tabs, the drawer goes full
 * width, and only the tables scroll sideways. */
.admin-page {
  height: 100%;
  overflow-y: auto;
  background: var(--bg-ink);
  color: var(--text-ivory);
  font-family: var(--font-ui);
  font-size: var(--text-base);
}
.admin-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sidebar);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: calc(var(--space-sm) + var(--safe-t)) calc(var(--space-lg) + var(--safe-r)) var(--space-sm) calc(var(--space-lg) + var(--safe-l));
  background: var(--bg-rail);
  border-bottom: 1px solid var(--border-brass);
}
.admin-header__back {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  text-decoration: none;
}
.admin-header__back:hover { color: var(--text-ivory); }
.admin-header__title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  color: var(--accent-gold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.admin-header__status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
}
.admin-readonly {
  padding: var(--space-2xs) var(--space-sm);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
  color: var(--text-ivory);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.admin-layout {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  min-height: calc(100% - var(--tap-min) - var(--space-md));
}
.admin-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-md) 0;
  background: var(--bg-rail);
  border-right: 1px solid var(--border-brass);
}
.admin-nav__item {
  min-height: var(--tap-min);
  padding: 0 var(--space-lg);
  text-align: left;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  background: none;
  border: none;
  border-left: 2px solid transparent;
  cursor: pointer;
}
.admin-nav__item:hover { color: var(--text-ivory); }
.admin-nav__item.is-on {
  color: var(--text-ivory);
  background: var(--bg-raised);
  border-left-color: var(--accent-brass);
}
.admin-main {
  min-width: 0;
  padding: var(--space-lg) calc(var(--space-lg) + var(--safe-r)) calc(var(--space-xl) + var(--safe-b)) var(--space-lg);
  container: admin-main / inline-size;
}
.admin-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}
.admin-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: var(--space-sm);
}
.admin-tile {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
}
.admin-tile--alert { border-left: 3px solid var(--color-warning); }
.admin-tile__value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  color: var(--text-ivory);
  white-space: nowrap;
}
.admin-tile__label {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.admin-tile__of {
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-mono);
}
.admin-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
.admin-chip {
  min-height: var(--tap-min);
  padding: 0 var(--space-md);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
  background: none;
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-lg);
  cursor: pointer;
}
.admin-chip:hover { color: var(--text-ivory); }
.admin-chip.is-on {
  color: var(--text-ivory);
  background: var(--bg-raised);
  border-color: var(--accent-brass);
}
.admin-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
  /* Covers scroll with the content; shadows stay on the visible edges. */
  background-image:
    linear-gradient(to right, var(--bg-ink), transparent),
    linear-gradient(to left, var(--bg-ink), transparent),
    radial-gradient(farthest-side at 0 50%, var(--overlay-dark-50), transparent),
    radial-gradient(farthest-side at 100% 50%, var(--overlay-dark-50), transparent);
  background-repeat: no-repeat;
  background-position: left center, right center, left center, right center;
  background-size: var(--space-lg) 100%, var(--space-lg) 100%, var(--space-sm) 100%, var(--space-sm) 100%;
  background-attachment: local, local, scroll, scroll;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.admin-table th,
.admin-table td {
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border-brass-grid);
}
.admin-table thead th {
  position: sticky;
  top: 0;
  font-weight: 500;
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
  background: var(--bg-rail);
  border-bottom: 1px solid var(--border-brass);
  white-space: nowrap;
}
.admin-table tbody th { font-weight: 500; }
/* Phone keeps a wide table and scrolls it. A pane at least 48rem can absorb
   the 52rem floor (iPad), which is what was clipping Last change. */
.admin-table--games { min-width: 52rem; }
@container admin-main (min-width: 48rem) {
  .admin-table--games { min-width: min(52rem, 100%); }
}
/* The floor is wider than this pane, so the right edge is clipped. Fade it. */
@container admin-main (max-width: 47.99rem) {
  .admin-table-wrap:has(> .admin-table--games) {
    mask-image: linear-gradient(to right, var(--text-ivory) calc(100% - var(--space-lg)), transparent);
  }
}
.admin-table--players { min-width: 56rem; }
.admin-table--results { min-width: 56rem; }
.admin-table--games th:last-child,
.admin-table--games td:last-child {
  padding-right: var(--space-md);
}
.admin-table--mid th,
.admin-table--mid td { vertical-align: middle; }
.admin-nowrap { white-space: nowrap; }
.admin-sides { display: flex; flex-direction: column; gap: var(--space-2xs); overflow-wrap: anywhere; }
.admin-subtitle {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.admin-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.admin-list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); min-height: var(--tap-min); }
/* #5531: the player drawer's Waiting / Live / Finished games. */
.admin-games__group + .admin-games__group { margin-top: var(--space-md); }
.admin-row { cursor: pointer; }
.admin-row:hover { background: var(--bg-raised); }
.admin-mono { font-family: var(--font-mono); }
.admin-muted { color: var(--text-ivory-muted); }
.admin-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.admin-link {
  padding: 0;
  font: inherit;
  color: var(--text-ivory);
  text-decoration: underline;
  text-decoration-color: var(--border-brass);
  text-underline-offset: 0.2em;
  background: none;
  border: none;
  cursor: pointer;
}
.admin-link:hover { text-decoration-color: var(--accent-brass); }
.admin-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
}
.admin-waiting {
  display: flex;
  flex-direction: column;
}
.admin-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: var(--space-xs);
  border-radius: 50%;
  border: 1px solid var(--text-ivory-muted);
}
.admin-dot.is-on {
  background: var(--color-success);
  border-color: var(--color-success);
}
.admin-late { color: var(--color-danger); }
.admin-late__note { font-size: var(--text-xs); }
.admin-reason {
  min-width: 12rem;
  max-width: 24rem;
  font-family: var(--font-body);
}
.admin-error-text {
  font-size: var(--text-xs);
  color: var(--color-danger);
}
.admin-empty {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text-ivory-muted);
}
.admin-error,
.admin-banner {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-raised);
  border: 1px solid var(--border-brass);
  border-left: 3px solid var(--color-danger);
  border-radius: var(--radius-sm);
}
.admin-banner { border-left-color: var(--color-warning); }
.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}
.admin-filters--apply { align-items: flex-end; }
.admin-filters--apply .btn { min-height: var(--tap-min); }
.admin-reports {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}
.admin-report {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
}
/* "No game" is plain text, so it centres on the tap-height links beside it. */
.admin-report .admin-links { align-items: center; }
.admin-report__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2xs) var(--space-sm);
  overflow-wrap: anywhere;
}
.admin-report__text {
  max-height: 8rem;
  margin: var(--space-xs) 0 0;
  overflow-y: auto;
  font-family: var(--font-body);
  overflow-wrap: anywhere;
}
.admin-kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-xs) var(--space-md);
  font-size: var(--text-sm);
}
.admin-kv dt { color: var(--text-ivory-muted); }
.admin-kv dd { margin: 0; overflow-wrap: anywhere; }
.admin-kv--wide { max-width: 40rem; }

/* Detail drawer: a fixed right panel on top of the page, below dialogs. */
.admin-drawer-shell {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-overlay);
  width: min(34rem, 100vw);
  padding: var(--safe-t) var(--safe-r) var(--safe-b) 0;
  background: var(--bg-raised);
  border-left: 1px solid var(--border-brass);
}
.admin-drawer.panel-leather {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-raised);
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.admin-drawer__body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg) var(--space-xl);
}
.admin-drawer__body .panel-section { padding: 0; }
.admin-id {
  align-self: flex-start;
  min-height: var(--tap-min);
  padding: 0;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--text-ivory);
  background: none;
  border: none;
  cursor: copy;
}
.admin-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  font-size: var(--text-sm);
}
.admin-links .admin-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-min);
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
.admin-actions .btn { min-height: var(--tap-min); }

/* Rule 9: Cinzel only on the page title. The shared Panel and dialog headers
 * are Cinzel elsewhere in the app, so inside the console they take the HUD face. */
/* Ghost buttons at 40% opacity disappear on the ink page. Keep the label readable. */
.admin-page .btn.btn-ghost:disabled {
  opacity: 1;
  color: var(--text-ivory-muted);
  background: var(--bg-raised);
  border-color: var(--border-brass);
  cursor: not-allowed;
}
.admin-page .heading-ww2,
.admin-page .panel-header-dialog-title {
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.admin-drawer__body { font-size: var(--text-sm); }
.admin-note {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-ivory-muted);
}

/* Intervention dialog body (inside DialogScaffold). */
.admin-dialog {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  overflow-y: auto;
  font-family: var(--font-ui);
  color: var(--text-ivory);
}
.admin-dialog__blurb {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
}
.admin-dialog__note,
.admin-dialog__error {
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  background: var(--bg-ink);
  border: 1px solid var(--border-brass);
  border-left: 3px solid var(--color-info);
  border-radius: var(--radius-sm);
}
.admin-dialog__error { border-left-color: var(--color-danger); }
.admin-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}
.admin-dialog__actions .btn { min-height: var(--tap-min); }
.admin-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  min-width: 10rem;
}
.admin-field__label {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-ivory-muted);
}
.admin-field__control {
  min-height: var(--tap-min);
  padding: var(--space-xs) var(--space-sm);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  color: var(--text-ivory);
  background: var(--bg-ink);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
}
select.admin-field__control {
  appearance: none;
  padding-right: calc(var(--space-lg) + var(--space-sm));
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-ivory-muted) 50%),
    linear-gradient(135deg, var(--text-ivory-muted) 50%, transparent 50%);
  background-position:
    calc(100% - var(--space-lg)) 55%,
    calc(100% - var(--space-md)) 55%;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
}
.admin-field__control--area {
  resize: vertical;
  font-family: var(--font-body);
}
.admin-field__hint {
  font-size: var(--text-xs);
  color: var(--text-ivory-muted);
}
.admin-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: var(--tap-min);
  font-size: var(--text-sm);
}
.admin-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-ink);
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-sm);
}
.admin-preview__summary {
  margin: 0;
  font-size: var(--text-base);
}

/* 403 page. */
.admin-forbidden {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-md);
  max-width: 32rem;
  margin: 0 auto;
  padding: calc(var(--space-xl) * 2 + var(--safe-t)) var(--space-lg) var(--space-xl);
}
.admin-forbidden__code {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  color: var(--text-ivory-muted);
}
.admin-forbidden__title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--accent-gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.admin-forbidden__text {
  font-family: var(--font-body);
  font-size: var(--text-lg);
}

/* In-game admin notice: rides the toast column like the timer handoff toast. */
.admin-notice-toast { display: contents; }

@media (max-width: 640px) {
  .admin-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    align-content: start;
  }
  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
    overflow-x: visible;
    padding: 0 var(--space-lg);
    border-right: none;
    border-bottom: 1px solid var(--border-brass);
  }
  .admin-nav__item {
    flex: 0 0 auto;
    padding: 0 var(--space-md);
    border-left: none;
    border-bottom: 2px solid transparent;
  }
  .admin-nav__item.is-on { border-bottom-color: var(--accent-brass); }
  .admin-main { padding: var(--space-md) var(--space-lg) calc(var(--space-xl) + var(--safe-b)); }
  .admin-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-drawer-shell { border-left: none; }
  .admin-dialog__actions { flex-wrap: wrap; }
}
