/* «Эллада против Аида» — base UI theme (CORE).
   The interface follows the side the human plays: <html data-faction="hellas|hades|neutral"> (src/ui/theme.js).
     neutral — main menu: dark bronze (the original theme);
     hellas  — white marble and cream panels, polished bronze / gold trims, Aegean blue accents, meander + laurel;
     hades   — black basalt / obsidian panels, blackened bronze, ember orange and blood red, ash text, asphodel + flames.
   Theme contract (other areas, e.g. the battle chrome, read these; see docs/core.md):
     --ui-bg --ui-panel --ui-panel-2 --ui-border --ui-border-strong --ui-accent --ui-accent-2 --ui-text --ui-text-dim
     --ui-good --ui-bad --ui-title-font --ui-button-bg --ui-button-text --ui-ornament
   --ui-ornament is an image (url) for a horizontal border band; tile it with
     background: var(--ui-ornament) repeat-x center / var(--ui-ornament-size);
   Extra helpers: --ui-heading, --ui-text-faint, --ui-warn, --ui-well, --ui-hover, --ui-primary-*, --ui-hud-bg,
     --ui-tip-bg, --ui-tip-text, --ui-input-bg, --ui-emblem (laurel / asphodel image) and --ui-emblem-w.
   Art skins (src/ui/ui_art.json → skins): <html data-skin-frame|data-skin-button|data-skin-portrait> plus
     --ui-skin-frame / --ui-skin-button / --ui-skin-portrait; nine-slice border-image when present (end of file).
   Shared classes for every area are listed in docs/core.md (buttons, panels, portraits, cost lines…). */

:root {
  /* legacy tokens (neutral bronze); still used by a few rules and by older area styles */
  --bg-0: #0d0b09;
  --bg-1: #15110e;
  --bg-2: #1e1813;
  --bg-3: #2a221b;
  --bg-4: #352a20;
  --line: #4a3a2b;
  --line-soft: rgba(181, 133, 75, 0.22);
  --bronze: #b5854b;
  --bronze-hi: #e2b56f;
  --bronze-lo: #7a5530;
  --gold: #f0cf7a;
  --marble: #ece6da;
  --marble-2: #cfc6b6;
  --text: #ece6da;
  --text-dim: #a99b89;
  --text-faint: #7b6e60;
  --hellas: #3b5a9a;
  --hellas-hi: #6a8cd0;
  --hellas-lo: #1c2b4d;
  --hades: #8e2a1c;
  --hades-hi: #c9523a;
  --hades-lo: #3e130c;
  --ok: #7ea65a;
  --warn: #d9a441;
  --danger: #c0482f;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;
  --sp-16: 64px;
  --hud-h: 0px;
  --radius: 6px;
  --radius-btn: 4px;
  --radius-panel: 8px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.6);
  --font-ui: "Golos Text", "PT Sans", "Segoe UI", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-title: "PT Serif", "Cormorant Garamond", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --scrollbar-thumb: #6b5642;
  --scrollbar-track: #1e1813;
  --meander: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10'%3E%3Cpath d='M0 9H12M0 1H12M10 9V1H4V6H7V4' fill='none' stroke='%23b5854b' stroke-width='1.3'/%3E%3C/svg%3E");
  /* art drop-in points (set to url(...) when the images exist) */
  --menu-art: none;
  --ui-skin-frame: none;
  --ui-skin-button: none;
  --ui-skin-portrait: none;

  /* ── theme: neutral (main menu) = the original bronze ── */
  --ui-bg: #0d0b09;
  --ui-bg-glow: #2c2219;
  --ui-panel: #2a221b;
  --ui-panel-2: #1e1813;
  --ui-panel-grad: linear-gradient(180deg, #2a221b, #1e1813);
  --ui-modal-bg: linear-gradient(180deg, #2a221b, #1e1813 40%, #15110e);
  --ui-texture: none;
  --ui-border: #4a3a2b;
  --ui-border-soft: rgba(181, 133, 75, 0.22);
  --ui-border-strong: #7a5530;
  --ui-accent: #e2b56f;
  --ui-accent-2: #f0cf7a;
  --ui-heading: #e2b56f;
  --ui-text: #ece6da;
  --ui-text-dim: #a99b89;
  --ui-text-faint: #8a7d6e;
  --ui-text-strong: #ffffff;
  --ui-good: #7ea65a;
  --ui-bad: #e06a4c;
  --ui-warn: #d9a441;
  --ui-well: rgba(0, 0, 0, 0.22);
  --ui-hover: rgba(181, 133, 75, 0.14);
  --ui-title-font: var(--font-title);
  --ui-button-bg: linear-gradient(180deg, #3a2e23, #251d16);
  --ui-button-bg-hover: linear-gradient(180deg, #4a3a2b, #2f251c);
  --ui-button-text: #ece6da;
  --ui-button-border: #7a5530;
  --ui-button-border-hover: #b5854b;
  --ui-ghost-text: #cfc6b6;
  --ui-primary-bg: linear-gradient(180deg, #e2b56f, #b5854b 55%, #8e6234);
  --ui-primary-bg-hover: linear-gradient(180deg, #f0c98a, #c4935a 55%, #9a6c3c);
  --ui-primary-text: #1d140b;
  --ui-primary-border: #e2b56f;
  --ui-primary-shadow: 0 1px 0 rgba(255, 240, 210, 0.35);
  --ui-hud-bg: linear-gradient(180deg, #2c2219, #1a140f);
  --ui-hud-border: #7a5530;
  --ui-tip-bg: #0f0c09;
  --ui-tip-text: #ece6da;
  --ui-toast-bg: rgba(22, 17, 13, 0.96);
  --ui-input-bg: #0d0b09;
  --ui-ornament: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10'%3E%3Cpath d='M0 9H12M0 1H12M10 9V1H4V6H7V4' fill='none' stroke='%23b5854b' stroke-width='1.3'/%3E%3C/svg%3E");
  --ui-ornament-size: 12px 10px;
  --ui-ornament-opacity: 0.85;
  --ui-emblem: none;
  --ui-emblem-w: 0px;
  --ui-modal-band: linear-gradient(90deg, transparent, var(--bronze), transparent);
  --ui-modal-band-h: 2px;
  --ui-bar-fill: linear-gradient(90deg, #7a5530, #e2b56f);
  --ui-modal-band-top: 0px;
  --ui-panel-rim: rgba(0, 0, 0, 0.3);
  --ui-select: #f0cf7a;
  --ui-track: #0d0b09;
  --ui-mana-text: #9fb8ee;
  --ui-frieze-h: 6px;
  --ui-frieze-size: 9px 6px;
  --ui-frieze-bg: transparent;
  --ui-frieze-opacity: 0.45;
  --ui-frieze-line: 0 solid transparent;
  color-scheme: dark;
}

/* ── theme: Hellas («Афинеи») — marble #F8F4E8, sand #E6D8BD, limestone #C9B99C, Aegean #2F5E8C, bronze #B56A2D ── */
:root[data-faction="hellas"] {
  --ui-bg: #E6D8BD;
  --ui-bg-glow: #F8F4E8;
  --ui-panel: #F8F4E8;
  --ui-panel-2: #E6D8BD;
  --ui-panel-grad: linear-gradient(180deg, #FAF7EE, #F8F4E8);
  --ui-modal-bg: #F8F4E8;
  --ui-texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='480' height='480'%3E%3Cfilter id='v' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.004 0.012' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.38 0 0 0 0 0.28 1 0 0 0 0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 0 0 0 0 0.045 0 0 0 0 0'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23v)'/%3E%3C/svg%3E");
  --ui-border: #C9B99C;
  --ui-border-soft: rgba(181, 106, 45, 0.22);
  --ui-border-strong: #B56A2D;
  --ui-accent: #2F5E8C;
  --ui-accent-2: #B56A2D;
  --ui-heading: #2B2B2B;
  --ui-text: #2B2B2B;
  --ui-text-dim: #574F45;
  --ui-text-faint: #6D6457;
  --ui-text-strong: #171512;
  --ui-good: #426B40;
  --ui-bad: #B0432B;
  --ui-terracotta: #C4573D;
  --ui-warn: #94521E;
  --ui-well: #EFE6D4;
  --ui-hover: rgba(47, 94, 140, 0.09);
  --ui-title-font: "PT Serif", "Cormorant Garamond", "Palatino Linotype", Georgia, serif;
  --ui-button-bg: #F8F4E8;
  --ui-button-bg-hover: #EFE6D4;
  --ui-button-text: #2B2B2B;
  --ui-button-border: #C9B99C;
  --ui-button-border-hover: #B56A2D;
  --ui-ghost-text: #3F3931;
  --ui-primary-bg: #2F5E8C;
  --ui-primary-bg-hover: #244B73;
  --ui-primary-text: #F8F4E8;
  --ui-primary-border: #244B73;
  --ui-primary-shadow: none;
  --ui-hud-bg: #F8F4E8;
  --ui-hud-border: #C9B99C;
  --ui-tip-bg: #2B2B2B;
  --ui-tip-text: #F8F4E8;
  --ui-toast-bg: rgba(248, 244, 232, 0.98);
  --ui-input-bg: #FFFFFF;
  --ui-ornament: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='10' viewBox='0 0 12 10'%3E%3Cpath d='M0 9H12M0 1H12M10 9V1H4V6H7V4' fill='none' stroke='%23B56A2D' stroke-width='1.2'/%3E%3C/svg%3E");
  --ui-ornament-size: 12px 10px;
  --ui-ornament-opacity: 0.55;
  --ui-emblem: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23B56A2D'%3E%3Cpath d='M10.78 19.29A7.0 7.0 0 0 1 8.93 6.11' fill='none' stroke='%238C5020' stroke-width='.9'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(9.61 18.98) rotate(-106.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(9.61 18.98) rotate(-38.0)'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(7.14 17.44) rotate(-82.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(7.14 17.44) rotate(-14.0)'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(5.51 15.02) rotate(-58.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(5.51 15.02) rotate(10.0)'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(5.00 12.16) rotate(-34.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(5.00 12.16) rotate(34.0)'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(5.71 9.33) rotate(-10.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(5.71 9.33) rotate(58.0)'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(7.41 7.12) rotate(13.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(7.41 7.12) rotate(81.0)'/%3E%3Cpath d='M0 0Q1.39 -2.10 0 -4.20Q-1.39 -2.10 0 0Z' transform='translate(8.93 6.11) rotate(64.0)'/%3E%3C/g%3E%3Cg fill='%23B56A2D' transform='translate(24 0) scale(-1 1)'%3E%3Cpath d='M10.78 19.29A7.0 7.0 0 0 1 8.93 6.11' fill='none' stroke='%238C5020' stroke-width='.9'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(9.61 18.98) rotate(-106.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(9.61 18.98) rotate(-38.0)'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(7.14 17.44) rotate(-82.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(7.14 17.44) rotate(-14.0)'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(5.51 15.02) rotate(-58.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(5.51 15.02) rotate(10.0)'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(5.00 12.16) rotate(-34.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(5.00 12.16) rotate(34.0)'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(5.71 9.33) rotate(-10.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(5.71 9.33) rotate(58.0)'/%3E%3Cpath d='M0 0Q1.65 -2.50 0 -5.00Q-1.65 -2.50 0 0Z' transform='translate(7.41 7.12) rotate(13.0)'/%3E%3Cpath d='M0 0Q1.32 -2.00 0 -4.00Q-1.32 -2.00 0 0Z' transform='translate(7.41 7.12) rotate(81.0)'/%3E%3Cpath d='M0 0Q1.39 -2.10 0 -4.20Q-1.39 -2.10 0 0Z' transform='translate(8.93 6.11) rotate(64.0)'/%3E%3C/g%3E%3Ccircle cx='12' cy='20.4' r='1.3' fill='%232F5E8C'/%3E%3C/svg%3E");
  --ui-emblem-w: 1.15em;
  --ui-modal-band: linear-gradient(90deg, transparent, #B56A2D 20%, #B56A2D 80%, transparent);
  --ui-modal-band-h: 2px;
  --ui-bar-fill: linear-gradient(90deg, #2F5E8C, #4A7FB0);
  --ui-modal-band-top: 0px;
  --ui-panel-rim: rgba(255, 255, 255, 0.5);
  --ui-select: #2F5E8C;
  --ui-track: #E6D8BD;
  --ui-mana-text: #2F5E8C;
  --ui-frieze-h: 0px;
  --ui-frieze-size: 12px 8px;
  --ui-frieze-bg: transparent;
  --ui-frieze-opacity: 0;
  --ui-frieze-line: 0 solid transparent;
  --scrollbar-thumb: #8A7960;
  --scrollbar-track: #E6D8BD;
  /* legacy tokens follow the theme */
  --bg-0: #E6D8BD; --bg-1: #EFE6D4; --bg-2: #F4EDE0; --bg-3: #F8F4E8; --bg-4: #FCF9F2;
  --line: #C9B99C; --line-soft: rgba(181, 106, 45, 0.22);
  --text: #2B2B2B; --text-dim: #574F45; --text-faint: #6D6457; --bronze-hi: #B56A2D;
  --shadow: 0 8px 24px rgba(43, 35, 24, 0.16);
  color-scheme: light;
}

/* ── theme: Hades («Эреб» — Section 10 palette: obsidian #181513, stone #292320, basalt #443A34, bronze #92734C, crimson #80372B, fire #C47B36) ── */
:root[data-faction="hades"] {
  --ui-bg: #181513;
  --ui-bg-glow: #292320;
  --ui-panel: #292320;
  --ui-panel-2: #181513;
  --ui-panel-grad: linear-gradient(180deg, #292320, #181513);
  --ui-modal-bg: linear-gradient(180deg, #292320, #1D1815 55%, #181513);
  --ui-texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='b' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.55 0 0 0 0 0.48 0 0 0 0 0.42 1 0 0 0 0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='table' tableValues='0 0 0 0 0.03 0.06'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23b)'/%3E%3C/svg%3E");
  --ui-border: #443A34;
  --ui-border-soft: rgba(146, 115, 76, 0.28);
  --ui-border-strong: #92734C;
  --ui-accent: #C47B36;
  --ui-accent-2: #80372B;
  --ui-heading: #E8DDC8;
  --ui-text: #E8DDC8;
  --ui-text-dim: #A69A8A;
  --ui-text-faint: #8A7F72;
  --ui-text-strong: #FFF6E8;
  --ui-good: #8FBF6A;
  --ui-bad: #E06E52;
  --ui-warn: #D99B4E;
  --ui-well: rgba(24, 21, 19, 0.55);
  --ui-hover: rgba(196, 123, 54, 0.14);
  --ui-title-font: "PT Serif", "Cormorant Garamond", "Palatino Linotype", Georgia, serif;
  --ui-button-bg: linear-gradient(180deg, #322A25, #211B18);
  --ui-button-bg-hover: linear-gradient(180deg, #3E342E, #292320);
  --ui-button-text: #E8DDC8;
  --ui-button-border: #6B563E;
  --ui-button-border-hover: #C47B36;
  --ui-ghost-text: #C9BFAE;
  --ui-primary-bg: linear-gradient(180deg, #9A4434, #80372B 58%, #63271E);
  --ui-primary-bg-hover: linear-gradient(180deg, #B04E3B, #923F31 58%, #732D22);
  --ui-primary-text: #FFF4E6;
  --ui-primary-border: #C47B36;
  --ui-primary-shadow: 0 1px 1px rgba(0, 0, 0, 0.55);
  --ui-hud-bg: linear-gradient(180deg, #241F1C, #181513);
  --ui-hud-border: #6B563E;
  --ui-tip-bg: #181513;
  --ui-tip-text: #E8DDC8;
  --ui-toast-bg: rgba(24, 21, 19, 0.96);
  --ui-input-bg: #181513;
  --ui-ornament: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='10' viewBox='0 0 16 10'%3E%3Cpath d='M0 9.5H16' stroke='%2392734C' stroke-width='1'/%3E%3Cpath d='M1 9C2.5 7 2 5 4 2.2C4.6 5 6 6 6.6 9ZM8.6 9C9.6 7.5 9.6 6 11 3.8C11.6 6 13 7 13.6 9Z' fill='%2380372B'/%3E%3Cpath d='M2.6 9C3.2 8 3.4 6.5 4.2 5.4C4.6 7 5.3 8 5.3 9ZM9.9 9C10.4 8.2 10.5 7.3 11.1 6.5C11.4 7.6 12 8.3 12.2 9Z' fill='%23C47B36'/%3E%3C/svg%3E");
  --ui-ornament-size: 16px 10px;
  --ui-ornament-opacity: 0.72;
  --ui-emblem: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 23V7M12 17.5L7.6 11M12 15L16.4 11M12 21C9.4 20.4 8 18.6 7.4 16.4' fill='none' stroke='%2392734C' stroke-width='1.1' stroke-linecap='round'/%3E%3Cg fill='%23E8DDC8'%3E%3Cpath d='M0 0Q1.08 -1.80 0 -3.60Q-1.08 -1.80 0 0Z' transform='translate(12 5.2) rotate(0)'/%3E%3Cpath d='M0 0Q1.08 -1.80 0 -3.60Q-1.08 -1.80 0 0Z' transform='translate(12 5.2) rotate(60)'/%3E%3Cpath d='M0 0Q1.08 -1.80 0 -3.60Q-1.08 -1.80 0 0Z' transform='translate(12 5.2) rotate(120)'/%3E%3Cpath d='M0 0Q1.08 -1.80 0 -3.60Q-1.08 -1.80 0 0Z' transform='translate(12 5.2) rotate(180)'/%3E%3Cpath d='M0 0Q1.08 -1.80 0 -3.60Q-1.08 -1.80 0 0Z' transform='translate(12 5.2) rotate(240)'/%3E%3Cpath d='M0 0Q1.08 -1.80 0 -3.60Q-1.08 -1.80 0 0Z' transform='translate(12 5.2) rotate(300)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(7.4 10.6) rotate(0)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(7.4 10.6) rotate(60)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(7.4 10.6) rotate(120)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(7.4 10.6) rotate(180)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(7.4 10.6) rotate(240)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(7.4 10.6) rotate(300)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(16.6 10.6) rotate(0)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(16.6 10.6) rotate(60)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(16.6 10.6) rotate(120)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(16.6 10.6) rotate(180)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(16.6 10.6) rotate(240)'/%3E%3Cpath d='M0 0Q0.93 -1.55 0 -3.10Q-0.93 -1.55 0 0Z' transform='translate(16.6 10.6) rotate(300)'/%3E%3C/g%3E%3Ccircle cx='12' cy='5.2' r='1.15' fill='%23C47B36'/%3E%3Ccircle cx='7.4' cy='10.6' r='0.99' fill='%23C47B36'/%3E%3Ccircle cx='16.6' cy='10.6' r='0.99' fill='%23C47B36'/%3E%3C/svg%3E");
  --ui-emblem-w: 1.2em;
  --ui-modal-band: linear-gradient(90deg, transparent, #92734C 22%, #C47B36 50%, #92734C 78%, transparent);
  --ui-modal-band-h: 2px;
  --ui-bar-fill: linear-gradient(90deg, #80372B, #C47B36);
  --ui-modal-band-top: 0px;
  --ui-panel-rim: rgba(0, 0, 0, 0.45);
  --ui-select: #C47B36;
  --ui-track: #181513;
  --ui-mana-text: #9fb8ee;
  --ui-frieze-h: 0px;
  --ui-frieze-size: 14px 9px;
  --ui-frieze-bg: transparent;
  --ui-frieze-opacity: 0;
  --ui-frieze-line: 0 solid transparent;
  --scrollbar-thumb: #6E5840;
  --scrollbar-track: #181513;
  --bg-0: #181513; --bg-1: #201B18; --bg-2: #292320; --bg-3: #332B27; --bg-4: #443A34;
  --line: #443A34; --line-soft: rgba(146, 115, 76, 0.28);
  --text: #E8DDC8; --text-dim: #A69A8A; --text-faint: #8A7F72; --bronze-hi: #C47B36;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.72);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ui-bg);
  color: var(--ui-text);
  font: 14px/1.45 var(--font-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
input, textarea, select { user-select: text; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--ui-title-font); font-weight: 600; letter-spacing: 0.015em; margin: 0; }
p { margin: 0 0 0.6em; }
.muted { color: var(--ui-text-dim); }
.flavor { color: var(--ui-text-dim); font-style: italic; font-family: var(--font-title); font-size: 15px; margin-top: 10px; }
.section-title {
  font-size: 14px; color: var(--ui-heading); text-transform: uppercase; letter-spacing: 0.1em;
  margin: 14px 0 8px; display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--ui-border-strong), transparent); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
* { scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); scrollbar-width: thin; }
@supports not (scrollbar-color: auto) {
  * { scrollbar-width: auto; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: var(--scrollbar-track); }
  ::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 6px; border: 2px solid var(--scrollbar-track); }
  ::-webkit-scrollbar-thumb:hover { background: var(--ui-border-strong); }
}

/* ───────────── app shell ───────────── */
.app {
  position: fixed; inset: 0; overflow: hidden; overflow: clip; /* clip: no programmatic scrolling either */
  background: radial-gradient(ellipse at 50% -10%, var(--ui-bg-glow) 0%, var(--ui-bg) 60%, color-mix(in srgb, var(--ui-bg) 82%, #000) 100%);
  user-select: none;
}
.screen-host { position: absolute; inset: 0; overflow: hidden; overflow: clip; }
.app.with-hud .screen-host { top: var(--hud-h); }
.screen-slot { position: absolute; inset: 0; overflow: hidden; }
.screen { position: relative; width: 100%; height: 100%; overflow: hidden; }

.boot-splash { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 10px; }
.boot-title { font: 600 44px var(--font-title); color: var(--bronze-hi); letter-spacing: 0.04em; }
.boot-note { color: var(--text-dim); }
.boot-error { position: absolute; inset: 40px; padding: 24px; overflow: auto; }
.boot-error h1 { color: var(--ui-bad); margin-bottom: 10px; }
.boot-error pre, .error-panel pre {
  white-space: pre-wrap; word-break: break-word; font: 12.5px/1.45 ui-monospace, Menlo, monospace;
  color: var(--ui-text); background: var(--ui-well);
  border: 1px solid var(--ui-border); padding: 12px; border-radius: 4px; max-height: 50vh; overflow: auto;
  user-select: text;
}
.screen-error { display: grid; place-items: center; padding: 24px; }
.error-panel { max-width: 760px; width: 100%; padding: 20px 22px; }
.error-panel h2 { color: var(--ui-bad); margin-bottom: 10px; }
.error-panel .error-hint { margin: 10px 0 0; font-size: 13px; color: var(--ui-text-dim); }
.error-panel .row { margin-top: 12px; }

/* ───────────── panels, buttons, tags ───────────── */
.panel {
  position: relative;
  background: var(--ui-texture), var(--ui-panel-grad);
  color: var(--ui-text);
  border: 1px solid var(--ui-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(226, 181, 111, 0.08), inset 0 0 0 1px var(--ui-panel-rim);
}
.panel.marble {
  background: linear-gradient(160deg, #efe9de, #d8cfbf 60%, #c9bfae);
  color: #2a211a; border-color: #a99a83;
}
.meander { height: 10px; background: var(--ui-ornament) repeat-x center / var(--ui-ornament-size); opacity: var(--ui-ornament-opacity); }

.btn {
  appearance: none; position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 6px 14px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--ui-button-border);
  background: var(--ui-button-bg);
  color: var(--ui-button-text);
  font: 600 13px/1.2 var(--font-ui); letter-spacing: 0.02em; white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 1px 2px rgba(0, 0, 0, 0.45);
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.05s;
}
.btn:hover:not(:disabled) { border-color: var(--ui-button-border-hover); background: var(--ui-button-bg-hover); color: var(--ui-text-strong); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn.active { border-color: var(--ui-select); box-shadow: inset 0 0 0 1px var(--ui-select), 0 0 8px color-mix(in srgb, var(--ui-select) 35%, transparent); }
.btn.primary {
  border-color: var(--ui-primary-border); color: var(--ui-primary-text);
  background: var(--ui-primary-bg);
  text-shadow: var(--ui-primary-shadow);
}
.btn.primary:hover:not(:disabled) { background: var(--ui-primary-bg-hover); color: var(--ui-primary-text); border-color: var(--ui-primary-border); }
.btn.danger { border-color: #b9533b; background: linear-gradient(180deg, #8e2a1c, #5c1910); color: #f6e3dc; }
.btn.danger:hover:not(:disabled) { background: linear-gradient(180deg, #a83524, #6c1f14); }
.btn.blue { border-color: var(--hellas-hi); background: linear-gradient(180deg, #46689f, #263f6b); }
.btn.ghost { background: transparent; border-color: var(--ui-border); box-shadow: none; color: var(--ui-ghost-text); }
.btn.ghost:hover:not(:disabled) { background: var(--ui-hover); border-color: var(--ui-border-strong); color: var(--ui-text-strong); }
.btn.small { min-height: 26px; padding: 3px 10px; font-size: 12px; }
.btn.large {
  min-height: 48px; padding: 10px 22px; font: 600 18px/1.2 var(--font-title); letter-spacing: 0.06em;
  flex-direction: column; gap: 2px;
}
.btn-caption { font: 400 11px/1.2 var(--font-ui); letter-spacing: 0; opacity: 0.78; white-space: normal; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 10px; font-size: 12px;
  background: var(--ui-hover); border: 1px solid var(--ui-border-soft); color: var(--ui-text-dim);
}
.tag.tier { background: rgba(226, 181, 111, 0.2); color: var(--ui-heading); border-color: var(--ui-border-strong); }
.tag.tag-rank { background: linear-gradient(180deg, #4a3612, #2a1e0a); color: #f6d98e; border-color: #e2b56f; font-weight: 700; }
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 0 6px currentColor; }

/* ───────────── resource icons & costs ───────────── */
.res-icon { display: inline-block; width: 18px; height: 18px; flex: none; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.res-img { object-fit: contain; box-shadow: none; }
.res-gold { border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff1b8, #e0b23a 50%, #8a6512); }
.res-wood { height: 12px; width: 20px; margin: 3px 0; border-radius: 6px; background: linear-gradient(180deg, #a77847, #6b4423 60%, #4a2e17); }
.res-ore { border-radius: 38% 46% 40% 30%; background: radial-gradient(circle at 35% 35%, #c9ced4, #6f7479 58%, #3a3d41); }
.res-marble { border-radius: 2px; background: linear-gradient(135deg, #ffffff, #e2dbcd 45%, #b9ae9b 70%, #e9e3d7); }
.res-sulfur { background: linear-gradient(180deg, #fbf6a4, #d8c62e 60%, #8f7f10); clip-path: polygon(50% 0, 100% 90%, 0 90%); box-shadow: none; }
.res-crystal { background: linear-gradient(135deg, #effcff, #78d6ea 50%, #2a8aa5); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); box-shadow: none; }
.res-gems { background: radial-gradient(circle at 40% 35%, #ffd6ea, #d0347a 55%, #6e0e38); clip-path: polygon(50% 0, 100% 38%, 82% 100%, 18% 100%, 0 38%); box-shadow: none; }

.cost { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.cost-item { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cost-item.lack { color: var(--ui-bad); }
.cost-free { color: var(--ui-text-dim); font-style: italic; }

/* ───────────── portraits ───────────── */
.portrait {
  --pc: #6b5a45; --pc-hi: #8c7b66; --pc-lo: #2b241c;
  position: relative; flex: none; overflow: hidden; border-radius: 6px;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 28%, var(--pc-hi) 0%, var(--pc) 45%, var(--pc-lo) 100%);
  border: 1px solid var(--ui-border-strong);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45), inset 0 -18px 26px rgba(0, 0, 0, 0.35);
}
.portrait img { width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; pointer-events: none; }
.portrait-initials {
  font: 600 1em/1 var(--font-title); color: var(--marble); letter-spacing: 0.04em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}
.portrait.no-art::after {
  content: ""; position: absolute; inset: 4px; border: 1px dashed rgba(236, 230, 218, 0.22); border-radius: 4px; pointer-events: none;
}
.portrait-count {
  position: absolute; right: 3px; bottom: 3px; min-width: 18px; padding: 0 5px; border-radius: 3px;
  background: rgba(10, 8, 6, 0.82); border: 1px solid rgba(226, 181, 111, 0.35);
  font: 700 12px/17px var(--font-ui); color: #fff; text-align: center; font-variant-numeric: tabular-nums;
}
/* Veteran rank of a stack (core/ranks.js): a small gold plaque in the top-left corner of the cell */
.rank-badge {
  position: absolute; left: 3px; top: 3px; min-width: 16px; padding: 0 4px; border-radius: 3px;
  background: linear-gradient(180deg, #4a3612, #2a1e0a); border: 1px solid #e2b56f; color: #f6d98e;
  font: 700 10px/14px Georgia, "Times New Roman", serif; text-align: center; letter-spacing: 0.5px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); pointer-events: auto;
}
.rank-badge.rank-3 { background: linear-gradient(180deg, #6b4a12, #3a2508); border-color: #ffd98a; color: #fff1c4; }
.portrait-xs .rank-badge { left: 1px; top: 1px; min-width: 12px; padding: 0 2px; font-size: 8px; line-height: 11px; }
/* roadmap 2.6: the rank's metal — I bronze, II silver, III gold — on the plaque and the cell frame; chevrons per rank;
   a thin wins strip toward the next rank along the bottom of the cell (its colour = the next rank's metal) */
.rank-badge.rank-1 { background: linear-gradient(180deg, #5a3218, #2e180a); border-color: #c98a55; color: #f0c39a; }
.rank-badge.rank-2 { background: linear-gradient(180deg, #3e464e, #1e2328); border-color: #c9d2da; color: #eef3f7; }
.rank-badge.rank-3 { box-shadow: 0 0 6px rgba(255, 217, 138, 0.6), 0 1px 2px rgba(0, 0, 0, 0.6); }
.rank-chevrons { display: block; font: 700 8px/6px var(--font-ui, sans-serif); letter-spacing: -1px; opacity: 0.9; }
.portrait-xs .rank-chevrons { display: none; }
.rank-frame-1 { box-shadow: inset 0 0 0 2px #b87333; }
.rank-frame-2 { box-shadow: inset 0 0 0 2px #c0c6cc; }
.rank-frame-3 { box-shadow: inset 0 0 0 2px #e8c060, 0 0 8px rgba(232, 192, 96, 0.45); }
.rank-progress { position: absolute; left: 3px; right: 3px; bottom: 0; height: 3px; border-radius: 2px; background: rgba(0, 0, 0, 0.55); overflow: hidden; pointer-events: auto; }
.rank-progress-fill { display: block; height: 100%; background: #b87333; }
.rank-progress.to-2 .rank-progress-fill { background: #c0c6cc; }
.rank-progress.to-3 .rank-progress-fill { background: #e8c060; }
.portrait-xs { width: 32px; height: 36px; font-size: 13px; border-radius: 4px; }
.portrait-xs .portrait-count { font-size: 10px; line-height: 13px; right: 1px; bottom: 1px; padding: 0 3px; }
.portrait-sm { width: 64px; height: 72px; font-size: 22px; }
.portrait-md { width: 96px; height: 112px; font-size: 30px; }
.portrait-lg { width: 200px; height: 240px; font-size: 64px; border-radius: 8px; }

/* ───────────── bars ───────────── */
.bar { display: grid; grid-template-columns: 84px 1fr auto; align-items: center; gap: 8px; font-size: 12px; margin: 4px 0; }
.bar-label { color: var(--ui-text-dim); }
.bar-track { position: relative; height: 8px; border-radius: 4px; background: var(--ui-track); border: 1px solid var(--ui-border); overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--ui-bar-fill); }
.bar-move .bar-fill { background: linear-gradient(90deg, #2d5a3a, var(--ok)); }
.bar-value { font-variant-numeric: tabular-nums; color: var(--ui-text-dim); min-width: 86px; text-align: right; }

/* ───────────── HUD ───────────── */
.game-toolbar {
  --toolbar-edge: color-mix(in srgb, var(--ui-hud-border, #7a5530) 72%, transparent);
  --toolbar-surface: radial-gradient(ellipse at 52% 0%, color-mix(in srgb, var(--ui-heading, #e2b56f) 11%, transparent), transparent 72%),
    var(--ui-texture, none), var(--ui-hud-bg, #211814);
  background: var(--toolbar-surface);
  color: var(--ui-text, #ece6da);
}
/* The bars (HUD, town header / army bar, map dock) show a faction picture under a dark veil:
   --ui-chrome-img = the human side's town art (theme.js), --ui-chrome-town = the open town's (town screen). */
.hud {
  --turn-color: #b38b64;
  --hud-text: #f3e7cf;
  --hud-dim: #c3ae8e;
  --hud-line: rgba(176, 136, 80, 0.32);
  --hud-rim: #b08850;
  --hud-gold: #e9b862;
  position: absolute; inset: 0 0 auto; z-index: 30;
  display: grid; align-items: center; grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px 18px; padding: 7px clamp(12px, 1.3vw, 28px) 7px;
  background:
    linear-gradient(90deg, rgba(14, 10, 8, 0.86), rgba(14, 10, 8, 0.66) 36%, rgba(14, 10, 8, 0.62) 64%, rgba(14, 10, 8, 0.7)),
    linear-gradient(180deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.42)),
    var(--ui-chrome-town, var(--ui-chrome-img, none)) center 14% / cover no-repeat,
    #1d1612;
  color: var(--hud-text);
  border-bottom: 3px double var(--hud-rim);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 6px 16px rgba(0, 0, 0, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}
.hud-res {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 0;
  margin: 0; padding: 0; list-style: none;
}
.hud .res-item {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 2px clamp(8px, 0.85vw, 15px);
  font: 600 14px/1 var(--font-ui); font-variant-numeric: tabular-nums;
}
.hud .res-item:first-child { padding-left: 0; }
.hud .res-item + .res-item { border-left: 1px solid var(--hud-line); }
.hud .res-icon { width: 24px; height: 24px; flex: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8)); }
.hud .res-name, .hud-tool-label, .hud .sound-text {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}
.hud-turn { min-width: 0; justify-self: center; display: flex; align-items: center; gap: clamp(10px, 1.1vw, 20px); }
.hud-date {
  display: flex; align-items: baseline; gap: 6px; white-space: nowrap; font-variant-numeric: tabular-nums;
  color: var(--hud-gold); font: 600 15px/1.1 var(--font-title);
}
.hud-date-period, .hud-date-day { color: inherit; font: inherit; }
.hud-date-day::before { content: "·"; margin-right: 6px; }
.hud-player {
  min-width: 0; height: 34px; display: flex; align-items: center; gap: 8px;
  padding: 0 16px 0 15px; cursor: pointer; text-align: left;
  border: 1px solid color-mix(in srgb, var(--turn-color) 25%, #d6a45e); border-radius: 999px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--turn-color) 88%, #fff), color-mix(in srgb, var(--turn-color) 62%, #000) 70%, color-mix(in srgb, var(--turn-color) 48%, #000));
  box-shadow: inset 0 1px 0 rgba(255, 230, 190, 0.28), inset 0 0 0 1px rgba(0, 0, 0, 0.45),
    0 0 14px color-mix(in srgb, var(--turn-color) 45%, transparent), 0 2px 4px rgba(0, 0, 0, 0.6);
  color: var(--hud-text);
}
.hud-player:hover, .hud-player[aria-expanded="true"] { filter: brightness(1.14); }
.hud-player .color-dot { display: none; }
.hud-player-copy { display: flex; align-items: baseline; min-width: 0; gap: 8px; white-space: nowrap; }
.hud-player-name { overflow: hidden; text-overflow: ellipsis; font: 700 15px/1.15 var(--font-title); color: #fff3df; }
.hud-player-status { color: color-mix(in srgb, var(--turn-color) 22%, #ffe6c6); font: 500 12px/1.1 var(--font-ui); }
.hud-player.thinking .hud-player-status { animation: pulse 1.2s ease-in-out infinite; }
/* 7-day rule: the viewer has no town */
.hud-townless {
  flex: none; padding: 3px 9px; border-radius: 12px; white-space: nowrap;
  font: 600 12px/1.2 var(--font-ui); color: #ffd9c4;
  background: rgba(120, 28, 16, 0.78); border: 1px solid rgba(255, 140, 100, 0.55);
}
.hud-townless.urgent { animation: pulse 1.2s ease-in-out infinite; background: rgba(160, 24, 12, 0.9); }
.hud-actions, .hud-tools, .hud-files { display: flex; align-items: center; }
.hud-actions { justify-self: end; gap: 10px; }
.hud-tools { gap: 6px; }
.hud-files { gap: 6px; padding-left: 10px; margin-left: 4px; border-left: 1px solid var(--hud-line); }
.hud .btn { min-height: 36px; padding: 5px 10px; font-size: 13px; letter-spacing: 0; }
/* framed bronze plates (double rim: gold outside, dark + faint gold inside) */
.hud .hud-tools .btn, .hud .hud-menu-toggle {
  min-width: 36px; min-height: 36px; gap: 7px;
  color: var(--hud-text); font: 600 13.5px/1 var(--font-title);
  background: linear-gradient(180deg, #3d2c21, #23180f 58%, #1a110c);
  border: 1px solid #95703f; border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.65), inset 0 0 0 2px rgba(214, 170, 100, 0.16),
    inset 0 1px 0 rgba(255, 228, 175, 0.24), 0 1px 3px rgba(0, 0, 0, 0.65);
}
.hud .hud-tools .btn:hover:not(:disabled), .hud .hud-tools .btn.active,
.hud .hud-menu-toggle:hover, .hud-menu-toggle[aria-expanded="true"] {
  background: linear-gradient(180deg, #4f3a2a, #2d1f15 58%, #20160f); color: #fff6e2; border-color: #e2b56f;
}
.hud .hud-tools .btn.active { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 0 2px rgba(233, 184, 98, 0.45), 0 0 10px rgba(233, 184, 98, 0.3); }
.hud .hud-tools .btn .btn-icon { width: 20px; height: 20px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.8)); }
.hud .hud-tools .hud-sound.muted { color: #f3a88e; }
.hud .hud-tools .sound-ctl .sound-toggle { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.hud .hud-tools .sound-more { min-width: 24px; padding-inline: 5px; margin-left: -1px; color: var(--hud-dim); border-top-left-radius: 0; border-bottom-left-radius: 0; }
.hud .hud-debug { color: var(--hud-dim); font-size: 11px; }
/* «☰ Меню»: the tools are a drop-down on every screen width */
.hud-center { min-width: 0; justify-self: center; display: flex; align-items: center; justify-content: center; }
.hud .hud-menu-toggle .hud-tool-label { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; }
.hud-menu-icon { font-size: 16px; line-height: 1; }
.hud-tools {
  flex-direction: column; align-items: stretch; gap: 4px; z-index: 41;
  position: absolute; top: calc(100% + 6px); right: clamp(12px, 1.3vw, 28px); width: 260px;
  max-height: calc(100dvh - var(--hud-h) - 14px); overflow: auto; padding: 8px;
  background: linear-gradient(180deg, #2a1f18, #17110d); border: 1px solid #95703f; border-radius: 4px;
  box-shadow: 0 0 0 1px #0d0907, 0 12px 30px rgba(0, 0, 0, 0.7);
}
.hud .hud-tools .btn { justify-content: flex-start; width: 100%; }
.hud .hud-tools .hud-tool-label, .hud .hud-tools .sound-text { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; }
.hud-tools .hud-files { flex-direction: column; align-items: stretch; margin: 0; padding: 6px 0 0; border: 0; border-top: 1px solid var(--hud-line); }
.hud-tools .sound-ctl { position: static; display: flex; }
.hud .hud-tools .sound-ctl .btn { width: auto; }
.hud .hud-tools .sound-ctl .sound-toggle { flex: 1; }
.hud-tools .sound-pop { position: static; width: 100%; margin: 3px 0; }
.hud-tools .lang-switch { align-self: flex-start; }
.hud .hud-tools .hud-debug { gap: 8px; color: var(--hud-text); font-size: 13.5px; }
.hud-debug-key { min-width: 22px; padding: 1px 4px; border: 1px solid rgba(176, 136, 80, 0.6); border-radius: 2px; font: 700 11px/14px var(--font-ui); color: var(--hud-dim); text-align: center; }
/* a game screen holds the bar: title in the middle, status + back on the right */
.hud-context-title, .hud-context-status, .hud-context-back, .hud-context-close { display: none; }
.hud.has-context .hud-turn, .hud.has-context .hud-menu-toggle, .hud.has-context .hud-tools, .hud.has-context .hud-end { display: none !important; }
.hud.has-context .hud-context-title {
  display: block; margin: 0; font: 700 21px/1.2 var(--font-title); color: #f6e7c8; letter-spacing: 0.03em; white-space: nowrap;
}
.hud.has-context .hud-context-status { display: flex; align-items: baseline; gap: 8px; font-size: 13px; color: var(--hud-dim); white-space: nowrap; }
.hud-context-status .is-ok { color: #e9d6ae; }
.hud-context-status .is-warn { color: #e7b35e; }
.hud.has-context .hud-context-back {
  display: inline-flex; min-height: 36px; padding: 4px 14px 4px 11px; gap: 8px; color: var(--hud-text); font: 600 14px/1 var(--font-title);
  background: linear-gradient(180deg, #3d2c21, #23180f 58%, #1a110c); border: 1px solid #95703f; border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 228, 175, 0.24), 0 1px 3px rgba(0, 0, 0, 0.65);
}
.hud.has-context .hud-context-back:hover { border-color: #e2b56f; color: #fff6e2; }
.hud.has-context .hud-context-close {
  display: inline-grid; place-items: center; width: 36px; min-height: 36px; padding: 0; color: var(--hud-text); font: 400 22px/1 var(--font-ui);
  background: linear-gradient(180deg, #3d2c21, #23180f 58%, #1a110c); border: 1px solid #95703f; border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 228, 175, 0.24), 0 1px 3px rgba(0, 0, 0, 0.65);
}
.hud.has-context .hud-context-close:hover { border-color: #e2b56f; color: #fff6e2; }
.lang-switch {
  display: inline-flex; align-items: center; padding: 2px; gap: 2px;
  border-radius: 5px; border: 1px solid color-mix(in srgb, var(--ui-border) 85%, transparent);
  background: color-mix(in srgb, var(--ui-bg) 55%, #18130e);
}
.lang-switch .lang-opt {
  min-width: 28px; min-height: 24px; padding: 2px 7px; border: 0; border-radius: 3px;
  background: transparent; color: var(--hud-dim, #b7a88e); cursor: pointer;
  font: 600 11px/1.2 var(--font-ui); letter-spacing: 0.04em;
}
.lang-switch .lang-opt:hover { color: var(--hud-text, #f5ead4); background: #fff4d018; }
.lang-switch .lang-opt.active {
  background: color-mix(in srgb, var(--ui-accent, #2F5E8C) 78%, #1e2833);
  color: #fff8ea;
}
.hud .lang-switch.compact { margin-inline: 2px; border-color: var(--hud-line); background: #00000028; }
.hud .lang-switch.compact .lang-opt { min-width: 24px; min-height: 22px; padding: 2px 5px; font-size: 10.5px; }
.menu-footer .lang-switch { border-color: #d8c29d44; background: #16110d99; }
.menu-footer .lang-switch .lang-opt { color: #d6c5aa; }
.menu-footer .lang-switch .lang-opt.active { background: #2F5E8C; color: #fff8ea; }
.hud .hud-end {
  min-height: 38px; padding: 6px 16px; gap: 8px;
  color: #fff4e1; font: 700 14px/1 var(--font-title);
  background: linear-gradient(180deg, color-mix(in srgb, var(--turn-color) 80%, #fff 10%), color-mix(in srgb, var(--turn-color) 60%, #000) 60%, color-mix(in srgb, var(--turn-color) 45%, #000));
  border: 1px solid #d6a45e; border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 230, 190, 0.3), 0 0 12px color-mix(in srgb, var(--turn-color) 40%, transparent), 0 1px 3px rgba(0, 0, 0, 0.6);
}
/* QA 29.11: .btn:hover (more specific) put the theme's cream hover background under the light text — keep the turn colour */
.hud .hud-end:hover:not(:disabled) {
  filter: brightness(1.15); color: #fff8e8; border-color: #f0c98a;
  background: linear-gradient(180deg, color-mix(in srgb, var(--turn-color) 80%, #fff 10%), color-mix(in srgb, var(--turn-color) 60%, #000) 60%, color-mix(in srgb, var(--turn-color) 45%, #000));
}
.hud .hud-end:disabled { filter: saturate(0.35) brightness(0.8); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.55); }
.hud :focus-visible { outline: 2px solid #eac18b; outline-offset: 2px; }
.hud .sound-pop { top: calc(100% + 13px); }
.hud .sound-pop :focus-visible, .hud-popover :focus-visible { outline-color: var(--ui-accent); }
.hud-popover {
  position: absolute; top: calc(100% + 5px); left: 50%; transform: translateX(-50%);
  width: min(300px, calc(100% - 16px)); max-height: min(70vh, calc(100dvh - var(--hud-h) - 14px)); overflow: auto; z-index: 40; padding: 8px;
}
@media (min-width: 1400px), (max-width: 760px) {
  .hud .hud-bestiary .hud-tool-label, .hud .sound-text {
    position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none;
  }
}
@media (min-width: 1880px) {
  .hud .hud-tool-label { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none; }
  .hud .res-name {
    position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none;
    order: 2; font: 400 13px/1 var(--font-ui); color: var(--hud-dim);
  }
}
@media (max-width: 1499px) {
  .hud { column-gap: 12px; }
  .hud .res-item { gap: 5px; padding-inline: 7px; font-size: 13px; }
  .hud .res-icon { width: 22px; height: 22px; }
  .hud-turn { gap: 10px; }
  .hud-date { display: grid; gap: 3px; justify-items: end; }
  .hud-date-period { color: var(--hud-dim); font: 500 10px/1 var(--font-ui); }
  .hud-date-day { font-size: 16px; }
  .hud-date-day::before { content: none; }
  .hud-player { height: 36px; padding-inline: 12px 13px; }
  .hud-player-copy { display: grid; gap: 1px; }
  .hud-player-name { font-size: 13.5px; }
  .hud-player-status { font-size: 11px; }
  .hud-actions { gap: 8px; }
  .hud-tools, .hud-files { gap: 4px; }
  .hud-files { padding-left: 7px; margin-left: 2px; }
  .hud .hud-tools .btn, .hud .hud-menu-toggle { min-width: 33px; min-height: 34px; padding-inline: 7px; }
  .hud .hud-end { padding-inline: 12px; }
}
@media (max-width: 1100px) {
  .hud { grid-template-columns: minmax(0, 1fr) auto; row-gap: 5px; padding-block: 6px 7px; }
  .hud-res { grid-column: 1 / -1; padding: 3px 0 6px; border-bottom: 1px solid var(--hud-line); }
  .hud-center { justify-self: start; }
  .hud-popover { left: 8px; transform: none; }
}
@media (max-width: 760px) {
  .hud .btn, .hud-player { min-height: 44px; }
  .hud-actions { gap: 6px; }
  .hud .hud-menu-toggle { padding-inline: 9px; }
  .hud-tools {
    display: flex; flex-direction: column; align-items: stretch; gap: 3px; z-index: 41;
    position: absolute; top: calc(100% + 5px); right: 8px; width: min(278px, calc(100% - 16px));
    max-height: calc(100dvh - var(--hud-h) - 14px); overflow: auto;
    padding: 6px; background: #29221a; border: 1px solid #87674b; border-radius: 5px; box-shadow: var(--shadow);
  }
  .hud .hud-tools .btn { justify-content: flex-start; }
  .hud .hud-tools .hud-tool-label {
    position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none;
  }
  .hud-files { flex-direction: column; align-items: stretch; margin: 0; padding: 4px 0 0; border: 0; border-top: 1px solid var(--hud-line); }
  .hud .sound-ctl { position: static; flex-wrap: wrap; }
  .hud .sound-ctl .sound-toggle { flex: 1; }
  .hud .sound-ctl .sound-more { min-width: 44px; justify-content: center; }
  .hud .sound-pop { position: static; width: 100%; margin: 3px 0; }
}
@media (max-width: 520px) {
  .hud { grid-template-columns: minmax(0, 1fr); }
  .hud-turn { justify-content: space-between; }
  .hud-actions { justify-self: stretch; justify-content: space-between; }
}
.pop-title { font: 600 13px var(--font-title); color: var(--ui-heading); text-transform: uppercase; letter-spacing: 0.1em; margin: 6px 4px 4px; }
.pop-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 5px 6px; border-radius: 4px; border: 1px solid transparent;
  background: transparent; cursor: pointer; text-align: left;
}
.pop-item:hover:not(:disabled) { background: var(--ui-hover); border-color: var(--ui-border); }
.pop-item:disabled { opacity: 0.5; cursor: not-allowed; }
.pop-name { flex: 1; font-weight: 600; }
.pop-meta { font-size: 11px; }
.pop-empty { padding: 4px 8px; font-size: 12px; }
.pop-town-icon {
  width: 32px; height: 32px; flex: none; border-radius: 4px; border: 1px solid var(--ui-border-strong);
  background: linear-gradient(180deg, transparent 55%, var(--bronze-lo) 55%),
    repeating-linear-gradient(90deg, var(--marble-2) 0 3px, transparent 3px 7px) 0 9px / 100% 14px no-repeat,
    linear-gradient(180deg, var(--bg-4), var(--bg-2));
}

/* AI turn veil: blocks the screen (not the HUD) while the computer moves */
.turn-veil {
  position: absolute; inset: var(--hud-h) 0 0 0; z-index: 25; cursor: progress;
  background: rgba(6, 5, 4, 0.16);
  display: flex; justify-content: center; align-items: flex-start; padding-top: 16px;
}
/* hotseat: nobody at the screen may watch the AI move through another player's fog */
.turn-veil.opaque {
  background: radial-gradient(ellipse at 50% 30%, rgba(30, 24, 18, 0.98), rgba(6, 5, 4, 1) 70%);
  align-items: center; padding-top: 0;
}
.veil-banner {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 20px;
  background: var(--ui-toast-bg); border: 1px solid var(--ui-border-strong); box-shadow: var(--shadow);
  font: 600 15px var(--font-title); color: var(--ui-text); letter-spacing: 0.04em;
}
.veil-spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ui-border-strong); border-top-color: var(--ui-accent);
  animation: spin 0.9s linear infinite;
}

/* ───────────── modal, toast, tooltip ───────────── */
.layer-modal { position: absolute; inset: 0; z-index: 100; pointer-events: none; }
.modal-backdrop {
  position: absolute; inset: 0; pointer-events: auto; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 4, 3, 0.62); backdrop-filter: blur(1.5px);
  animation: fade-in 0.12s ease-out;
}
.modal {
  position: relative; display: flex; flex-direction: column;
  width: min(92vw, 760px); max-height: calc(100vh - 32px);
  background: var(--ui-texture), var(--ui-modal-bg);
  color: var(--ui-text);
  border: 1px solid var(--ui-border-strong); border-radius: 8px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(226, 181, 111, 0.08);
  animation: pop-in 0.14s ease-out;
}
/* top band: a thin bronze line (neutral), a meander (Hellas) or flames (Hades) */
.modal::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: var(--ui-modal-band-top, 0px); height: var(--ui-modal-band-h);
  background: var(--ui-modal-band); opacity: 0.9; pointer-events: none;
}
.modal:focus { outline: none; }
.modal-small { width: min(92vw, 460px); }
.modal-saves { width: min(92vw, 620px); }
.modal-hero { width: min(94vw, 820px); }
.modal-unit { width: min(94vw, 800px); }
.modal-quick-battle { width: min(94vw, 760px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--ui-modal-band-h)) 16px 10px; border-bottom: 1px solid var(--ui-border); }
.modal-title { flex: 1; font-size: 22px; color: var(--ui-heading); }
/* laurel (Hellas) / asphodel (Hades) before titles; zero width in the neutral theme */
.modal-title::before, .screen-title::before, .dbg-head-title::before, .sound-pop-title::before {
  content: ""; display: inline-block; vertical-align: -0.12em; width: var(--ui-emblem-w); height: 1em;
  margin-right: calc(var(--ui-emblem-w) * 0.35); background: var(--ui-emblem) center / contain no-repeat;
}
.modal-x {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--ui-border); background: var(--ui-well);
  font-size: 18px; line-height: 1; cursor: pointer; color: var(--ui-text-dim);
}
.modal-x:hover { border-color: var(--ui-border-strong); color: var(--ui-text-strong); }
.modal-body { padding: 14px 16px; overflow: auto; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--ui-border); }
.dialog-text p:last-child { margin-bottom: 0; }

.prompt-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.prompt-range { flex: 1; accent-color: var(--ui-accent); }
.prompt-number {
  width: 84px; padding: 5px 8px; border-radius: 4px; border: 1px solid var(--ui-border-strong); background: var(--ui-input-bg); color: var(--ui-text);
  font-variant-numeric: tabular-nums;
}
.prompt-sides { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: var(--ui-text-dim); }

.layer-toast {
  position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%); z-index: 200; /* above the map status pill */
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; cursor: pointer; max-width: min(90vw, 560px); padding: 9px 16px; border-radius: 6px;
  background: var(--ui-toast-bg); color: var(--ui-text); border: 1px solid var(--ui-border-strong); box-shadow: var(--shadow);
  font-size: 14px; animation: toast-in 0.18s ease-out;
}
.toast-good { border-color: var(--ui-good); box-shadow: var(--shadow), inset 4px 0 0 var(--ui-good); }
.toast-bad { border-color: var(--ui-bad); box-shadow: var(--shadow), inset 4px 0 0 var(--ui-bad); }
.toast-warn { border-color: var(--ui-warn); box-shadow: var(--shadow), inset 4px 0 0 var(--ui-warn); }
.toast-out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }

.tooltip {
  position: fixed; z-index: 300; pointer-events: none; max-width: 300px; padding: 6px 10px; border-radius: 4px;
  background: var(--ui-tip-bg); border: 1px solid var(--ui-border-strong); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  font-size: 12.5px; line-height: 1.4; color: var(--ui-tip-text); white-space: pre-line;
}

/* ───────────── unit card ───────────── */
.unit-card { display: grid; grid-template-columns: 220px 1fr; gap: 18px; }
.unit-card-art { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.unit-card-art .portrait-lg { width: 220px; height: 270px; border-color: var(--accent, var(--ui-border-strong)); }
.unit-card-count { display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 700; }
.unit-card-count .muted { font-weight: 400; font-size: 12px; }
.unit-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.unit-card-faction { font: 600 15px var(--font-title); color: var(--accent, var(--bronze-hi)); filter: brightness(1.5); text-transform: uppercase; letter-spacing: 0.1em; }
:root[data-faction="hellas"] .unit-card-faction, :root[data-faction="hades"] .unit-card-faction { color: var(--ui-heading); filter: none; }
.lineage { font-size: 13px; color: var(--ui-text-dim); }
.lineage strong { color: var(--ui-text); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 18px; margin-top: 10px; }
.stat-row { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px dotted var(--ui-border-soft); }
.stat-label { color: var(--ui-text-dim); }
.stat-value { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.ability-list { margin: 0; padding-left: 18px; }
.ability-list li { margin: 3px 0; }
.ability-list li::marker { color: var(--ui-accent-2); }
.unit-card-cost { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ───────────── game screens (modal-screen): a modal shown as a full screen below the HUD ─────────────
   Faction art under a dark veil and the dark bronze palette for every theme — the same look as the town screens
   (src/town/town_styles.js .tw-screen). Used by the hero screen; add the class to any modal that should feel like
   a place in the game rather than a pop-up. */
:root .layer-modal .modal-backdrop:has(> .modal-screen) {
  inset: var(--hud-h, 0px) 0 0 0; padding: 0; place-items: stretch; backdrop-filter: none;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(10, 7, 6, 0.55), rgba(10, 7, 6, 0.9) 75%),
    var(--ui-chrome-town, var(--ui-chrome-img, none)) center 45% / cover no-repeat, #120d0a;
}
.modal.modal-screen {
  --ui-text: #eadfca; --ui-text-dim: #bba98d; --ui-text-faint: #8f8170; --ui-text-strong: #fff6e6; --ui-heading: #f0dcb4;
  --ui-panel: #1f1713; --ui-panel-2: #150f0c; --ui-modal-bg: transparent; --ui-texture: none;
  --ui-border: #4f3d2c; --ui-border-strong: #a07a48; --ui-well: rgba(0, 0, 0, 0.32); --ui-hover: rgba(233, 184, 98, 0.1);
  --ui-accent: #e9b862; --ui-good: #a6d680; --ui-bad: #f09880; --ui-select: #ffd889; --ui-track: #0d0907;
  --ui-button-bg: linear-gradient(180deg, #3d2c21, #23180f 58%, #1a110c); --ui-button-bg-hover: linear-gradient(180deg, #4f3a2a, #2d1f15 58%, #20160f);
  --ui-button-border: #95703f; --ui-button-border-hover: #e2b56f; --ui-button-text: #f3e7cf; --ui-ghost-text: #d9c8a8;
  --ui-modal-band: none; --ui-emblem: none; --ui-emblem-w: 0px; --ui-mana-text: #9fb8ee;
  width: auto; max-width: none; height: auto; max-height: none; margin: 14px 20px 16px; overflow: hidden;
  border: 1px solid #8a6a40; border-radius: 4px; animation: fade-in 0.14s ease-out;
  background: linear-gradient(180deg, rgba(38, 28, 22, 0.95), rgba(19, 14, 11, 0.96));
  box-shadow: 0 0 0 1px #0d0907, inset 0 0 0 2px rgba(214, 170, 100, 0.12), 0 14px 40px rgba(0, 0, 0, 0.7);
}
.modal.modal-screen .modal-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 46px; padding: 0 10px 0 18px;
  background: linear-gradient(180deg, rgba(60, 44, 32, 0.9), rgba(30, 22, 17, 0.9)); border-bottom: 1px solid rgba(176, 136, 80, 0.45);
}
.modal.modal-screen .modal-title { grid-column: 2; flex: none; text-align: center; font: 700 21px/1.15 var(--font-title); color: #f6e7c8; text-shadow: 0 2px 3px #000; }
.modal.modal-screen .modal-title::before { display: none; }
.modal.modal-screen .modal-x.labeled {
  grid-column: 3; justify-self: end; width: auto; height: auto; min-height: 32px; padding: 3px 14px; border-radius: 3px;
  font: 600 14px/20px var(--font-title); color: #f3e7cf; border: 1px solid #95703f;
  background: linear-gradient(180deg, #3d2c21, #23180f 58%, #1a110c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 228, 175, 0.24), 0 1px 3px rgba(0, 0, 0, 0.65);
}
.modal.modal-screen .modal-x.labeled:hover { border-color: #e2b56f; color: #fff6e2; }
.modal.modal-screen .modal-body { flex: 1; padding: 22px 26px; }
.modal.modal-screen.has-hud-context .modal-head { display: none; }
.modal.modal-screen .btn { border-radius: 3px; font-family: var(--font-title); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 228, 175, 0.22), 0 1px 3px rgba(0, 0, 0, 0.6); }
.hero-cols { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 28px; align-items: start; }
.hero-col-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hero-col-side .section-title { margin-top: 0; }
.modal-screen .hero-head .portrait-lg { width: clamp(150px, 15vw, 240px); height: clamp(184px, 18.5vw, 296px); }
.modal-screen .hero-name { font-size: 32px; color: #f7ebd3; }
:root .modal.modal-screen .hero-level-badge { background: rgba(226, 181, 111, 0.18); color: #f0dcb4; border-color: #a07a48; }
@media (max-width: 980px) { .hero-cols { grid-template-columns: 1fr; } }

/* ───────────── hero panel & army editor ───────────── */
.hero-panel { display: flex; flex-direction: column; }
.hero-head { display: grid; grid-template-columns: auto 1fr; gap: 18px; }
.hero-head .portrait-lg { width: 180px; height: 220px; border-color: var(--accent, var(--ui-border-strong)); }
.hero-info { min-width: 0; }
.hero-name { font-size: 28px; color: var(--ui-text); line-height: 1.1; }
.hero-sub { color: var(--ui-heading); margin: 2px 0 6px; font-family: var(--font-title); font-size: 16px; }
.hero-owner { display: flex; align-items: center; gap: 6px; color: var(--ui-text-dim); font-size: 13px; margin-bottom: 6px; }
.hero-level { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; font-size: 12px; }
.hero-level-badge {
  padding: 2px 10px; border-radius: 10px; background: rgba(226, 181, 111, 0.18); border: 1px solid var(--ui-border-strong);
  color: var(--ui-heading); font-weight: 700; font-size: 13px;
}
.hero-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.hero-stats .stat-tile { min-width: 0; overflow: hidden; }
.hero-stats .stat-tile-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.02em; }
@media (max-width: 1440px) { .hero-stats .stat-tile-label { display: none; } .hero-stats .stat-tile { padding: 6px 2px; } }
.stat-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 6px;
  background: var(--ui-well); border: 1px solid var(--ui-border);
}
.stat-tile-value { font: 700 22px/1 var(--font-title); color: var(--ui-text); }
.stat-tile-label { font-size: 11px; color: var(--ui-text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-icon { width: 22px; height: 22px; display: block; }
.stat-icon-attack { background: linear-gradient(135deg, #f1dfb4, #a8834d 60%, #6d5230); clip-path: polygon(78% 0, 100% 22%, 38% 84%, 22% 100%, 0 78%, 16% 62%); }
.stat-icon-defense { background: linear-gradient(160deg, #8fb0e8, #3b5a9a 55%, #1c2b4d); clip-path: polygon(50% 0, 100% 14%, 92% 62%, 50% 100%, 8% 62%, 0 14%); }
.stat-icon-power { background: radial-gradient(circle, #ffe7a6, #c07be0 60%, #5b2a7a); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.stat-icon-knowledge { border-radius: 2px; background: linear-gradient(90deg, #f3ead6 0 46%, #6b4a2a 46% 54%, #f3ead6 54%); box-shadow: inset 0 0 0 2px #6b4a2a; }
.hero-specialty { margin-top: 10px; font-size: 13px; color: var(--ui-text); }
.hero-missing { padding: 20px; text-align: center; }

/* spellbook (Magic v1) */
.bar-mana .bar-fill { background: linear-gradient(90deg, #2b3f7a, #7fa2ec); }
.spellbook .bar-mana { max-width: 420px; }
.spellbook .bar-mana .bar-value { text-align: left; min-width: 64px; }
.spellbook-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 16px; margin-top: 6px; }
.spellbook-empty { margin: 4px 0 0; font-size: 13px; grid-column: 1 / -1; }
.spell-level-title { font: 600 14px var(--font-title); color: var(--ui-heading); margin: 2px 0 4px; letter-spacing: 0.04em; }
.spell-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.spell-item {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center;
  padding: 5px 8px; border-radius: 5px; background: var(--ui-well); border: 1px solid var(--ui-border);
}
.spell-main { display: flex; flex-direction: column; min-width: 0; }
.spell-name { color: var(--ui-text); font-weight: 700; font-size: 13px; }
.spell-text { color: var(--ui-text-dim); font-size: 12px; line-height: 1.3; }
.spell-cost { font-size: 12px; color: var(--ui-mana-text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.spell-short .spell-cost { color: var(--ui-text-faint); }
/* Magic v2 (QA 2026-11-29): the hero screen's spellbook is compact — one line per spell, the text in the tooltip,
   so the screen fits 1280×720 even with many spells */
.spellbook-compact .spellbook-body { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 10px; }
.spellbook-compact .spell-item { grid-template-columns: 20px 1fr auto auto; gap: 6px; padding: 3px 6px; }
.spellbook-compact .spell-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spellbook-compact .spell-level-title { font-size: 12px; margin: 0 0 2px; }
.spell-cast { padding: 1px 7px; font-size: 11px; line-height: 1.4; min-height: 0; white-space: nowrap; }
.spellbook-compact .spellbook-body { display: block; }
.spell-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 30px; gap: 4px 8px; }
.spell-circle { display: inline-block; min-width: 18px; margin-right: 5px; font: 600 10px var(--font-title); color: var(--ui-text-dim); }
.spellbook-pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 4px; font-size: 12px; }
.spellbook-pager .btn { min-width: 30px; padding: 0 8px; }
.spell-icon { width: 20px; height: 20px; margin-top: 1px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #e6ecff, #6f8fd8 55%, #24346a); }
.spell-icon-img { width: 28px; height: 28px; margin-top: 0; object-fit: contain; background: none; flex: none; pointer-events: none; }
.spell-icon-damage, .spell-icon-area, .spell-icon-massDamage { background: radial-gradient(circle at 40% 35%, #fff1c4, #e07a3a 55%, #6a2410); }
.spell-icon-buff, .spell-icon-massBuff { background: radial-gradient(circle at 40% 35%, #fbf4d6, #d6b15a 55%, #6d5230); }
.spell-icon-debuff, .spell-icon-stun { background: radial-gradient(circle at 40% 35%, #eadcff, #8a5ac6 55%, #331a55); }
.spell-icon-heal, .spell-icon-resurrect { background: radial-gradient(circle at 40% 35%, #effbe0, #7ea65a 55%, #2d4a1f); }

.army-editor { display: flex; flex-direction: column; gap: 8px; }
.army-row-label { font-size: 12px; color: var(--ui-text-dim); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.08em; }
.army-slots { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.army-slot {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px 5px; border-radius: 6px; cursor: pointer; min-height: 104px;
  background: linear-gradient(180deg, var(--ui-well), transparent), var(--ui-well);
  border: 1px solid var(--ui-border);
  transition: border-color 0.1s, box-shadow 0.1s, transform 0.08s;
}
.army-slot:hover { border-color: var(--ui-border-strong); }
.army-slot.empty { border-style: dashed; justify-content: center; cursor: default; }
.army-slot.empty:hover { border-color: var(--ui-border); }
.army-slot.selected { border-color: var(--ui-select); box-shadow: 0 0 0 1px var(--ui-select), 0 0 14px color-mix(in srgb, var(--ui-select) 40%, transparent); }
.army-slot.drop-target { border-color: var(--ui-good); box-shadow: 0 0 0 1px var(--ui-good); }
.army-slot.dragging { opacity: 0.45; }
.army-slot-name { font-size: 11px; line-height: 1.15; text-align: center; color: var(--ui-text-dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.army-slot-empty { font: 600 18px var(--font-title); color: var(--ui-text-faint); }
.army-actions { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.army-hint { font-size: 12px; color: var(--ui-text-dim); flex: 1; min-width: 240px; }
.army-buttons { display: flex; gap: 6px; }

.exchange-heads { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 12px; }
.exchange-head { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.exchange-arrows { font-size: 26px; color: var(--ui-heading); }
.hero-exchange .army-row + .army-row { margin-top: 6px; }

.hero-screen { display: grid; place-items: center; place-items: safe center; padding: 18px; overflow: auto; }
.hero-screen-box { width: min(96vw, 860px); padding: 16px 18px; }
.hero-screen-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.screen-title { font-size: 26px; color: var(--ui-heading); }

/* ───────────── main menu ───────────── */
.menu-screen { display: grid; place-items: center; overflow: auto; }
.menu-bg { position: absolute; inset: 0; pointer-events: none; background: var(--menu-art) center / cover no-repeat; }
.menu-bg-hellas, .menu-bg-hades { position: absolute; top: 0; bottom: 0; width: 60%; }
.menu-bg-hellas { left: 0; background: radial-gradient(ellipse at 10% 40%, rgba(59, 90, 154, 0.5), rgba(28, 43, 77, 0.25) 40%, transparent 70%); }
.menu-bg-hades { right: 0; background: radial-gradient(ellipse at 90% 60%, rgba(142, 42, 28, 0.5), rgba(62, 19, 12, 0.25) 40%, transparent 70%); }
.menu-bg.has-art .menu-bg-hellas, .menu-bg.has-art .menu-bg-hades { opacity: 0.35; }
/* With a picture behind it, darken the centre column so the title, buttons and footer stay readable. */
.menu-bg.has-art::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: radial-gradient(ellipse 34% 62% at 50% 52%, rgba(12, 9, 7, 0.82), rgba(12, 9, 7, 0.55) 55%, rgba(12, 9, 7, 0.08) 100%),
    linear-gradient(180deg, rgba(12, 9, 7, 0.35), transparent 30%);
}
.menu-bg.has-art::after { z-index: 2; }
.menu-bg { z-index: 0; } /* own stacking context: the overlays above stay under the menu frame */
.btn-icon { width: 18px; height: 18px; object-fit: contain; margin: -2px 0; flex: none; pointer-events: none; }
.menu-bg::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, rgba(236, 230, 218, 0.025) 0 2px, transparent 2px 120px),
    linear-gradient(180deg, transparent 70%, rgba(0, 0, 0, 0.55));
}
.menu-frame {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px;
  width: min(92vw, 800px); padding: 28px 24px 18px;
}
.menu-frame > .meander { align-self: stretch; height: 14px; background-size: 17px 14px; }
.menu-title {
  font-size: clamp(40px, 6vw, 68px); line-height: 1.05; text-align: center; letter-spacing: 0.05em;
  background: linear-gradient(180deg, #fff3d2, #e2b56f 45%, #9a6c3c); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.8));
}
.menu-tagline { color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.35em; font-size: 12px; margin-top: -6px; }
.menu-column { display: flex; flex-direction: column; gap: 10px; width: min(100%, 320px); margin-top: 10px; }
/* QA 29.11: nine menu buttons no longer fit 720 px in one column (the menu scrolled) — two columns on short screens;
   the first button («Вернуться к игре» / «Новая игра») spans both */
@media (max-height: 900px) {
  .menu-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(100%, 660px); gap: 8px 12px; }
  .menu-column > :first-child { grid-column: 1 / -1; justify-self: center; width: min(100%, 320px); }
  .menu-frame { padding-top: 16px; gap: 10px; }
}
.menu-about {
  margin-top: 10px; background: none; border: none; cursor: pointer; color: var(--text-faint); font-size: 12px;
  letter-spacing: 0.12em; text-transform: uppercase; text-decoration: underline dotted; text-underline-offset: 4px;
}
.menu-about:hover { color: var(--bronze-hi); }
.menu-footer { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; }
.about p { margin-bottom: 0.7em; }

/* ───────────── city selection ───────────── */
.menu-screen-cities { display: block; overflow: auto; }
.menu-screen-cities .menu-bg { position: fixed; }
.menu-screen-cities .menu-bg.has-art::before {
  background: linear-gradient(180deg, rgba(15, 11, 9, 0.82), rgba(15, 11, 9, 0.38) 38%, rgba(15, 11, 9, 0.7)),
    radial-gradient(ellipse at 50% 52%, rgba(15, 11, 9, 0.72), transparent 82%);
}
.menu-frame-cities { width: min(100%, 1184px); padding: 16px clamp(12px, 2.6vw, 30px) 30px; margin-inline: auto; gap: 24px; }
.menu-new { width: 100%; }
.city-menu-nav {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); align-items: center; gap: 8px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line); color: var(--marble);
}
.city-menu-brand {
  grid-column: 1 / -1; grid-row: 1; margin: 0; text-align: center; color: var(--bronze-hi);
  font: 600 clamp(18px, 3vw, 24px)/1.2 var(--font-title);
}
.city-menu-back { justify-self: start; }
.city-menu-back, .city-card-actions .btn { min-height: 44px; }
.menu-map {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-self: end; justify-content: flex-end;
  min-width: 0; margin: 0; color: var(--marble-2); font-size: 13px;
}
.menu-map strong { color: var(--marble); font-weight: 600; }
.menu-map select { max-width: 100%; min-height: 44px; background: var(--bg-0); border: 1px solid var(--bronze-lo); border-radius: 4px; padding: 4px 8px; }
.city-menu-intro { padding: clamp(17px, 2.6vw, 27px) 0 22px; text-align: center; }
.city-menu-heading { font-size: clamp(32px, 5vw, 52px); letter-spacing: 0.01em; }
.city-menu-heading:focus { outline: none; }
.city-menu-intro p { margin: 6px 0 0; color: var(--marble-2); text-shadow: 0 1px 5px #0d0b09; }
.city-grid { display: grid; gap: clamp(12px, 1.6vw, 20px); grid-template-columns: minmax(0, 1fr); }
.city-grid:empty { display: none; }
.city-other { margin-top: 26px; }
.city-other-title {
  display: flex; align-items: center; gap: 14px; margin: 0 0 12px;
  color: var(--marble); font-size: clamp(20px, 2.5vw, 24px); text-shadow: 0 1px 5px #0d0b09;
}
.city-other-title::after { content: ""; flex: 1; height: 8px; background: var(--meander) repeat-x right center / 12px 8px; opacity: 0.6; }
.city-card {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden; border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--city-accent) 54%, var(--bg-0));
  background: linear-gradient(155deg, color-mix(in srgb, var(--city-accent) 12%, var(--bg-2)), var(--bg-1) 78%);
  box-shadow: 0 9px 24px #0007; transition: border-color 0.16s ease;
}
.city-card:hover, .city-card:focus-within { border-color: var(--city-accent); }
.city-card-art {
  position: relative; aspect-ratio: 2 / 1; isolation: isolate;
  background: radial-gradient(ellipse at top, color-mix(in srgb, var(--city-accent) 34%, var(--bg-0)), var(--bg-0));
  border-bottom: 1px solid color-mix(in srgb, var(--city-accent) 48%, var(--bg-0));
}
.city-card-art::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(0deg, #0d0b09f5 0%, #0d0b09a6 25%, #0d0b091f 64%, transparent 84%);
}
.city-art-image { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 44%; }
.city-card-art .city-art-image { position: absolute; inset: 0; }
.city-art-lineup {
  position: absolute; inset: 6px 10px 28px; display: flex; align-items: flex-end; justify-content: flex-end; gap: 4px;
  pointer-events: none;
}
.city-art-unit {
  max-height: 100%; max-width: 38%; width: auto; height: auto; object-fit: contain; object-position: bottom center;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.72));
}
.city-card-title {
  position: absolute; z-index: 1; inset: auto 12px 12px; padding-left: 10px; border-left: 2px solid var(--city-accent);
  text-shadow: 0 2px 8px #0d0b09;
}
.city-card-title :is(h2, h3) { color: #fff4e1; font-size: clamp(22px, 2.4vw, 30px); line-height: 1.06; }
.city-grid-playable h2 { font-size: clamp(24px, 3vw, 36px); }
.city-grid-many h2 { font-size: clamp(21px, 2.2vw, 26px); }
.city-card-place { margin: 3px 0 0; color: var(--city-accent); font-size: 13px; }
.city-card-body { display: flex; flex: 1; flex-direction: column; gap: 9px; padding: 11px 12px 12px; }
.city-card-desc { flex: 1; margin: 0; color: var(--marble-2); }
.city-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.city-start { flex: 1 1 max-content; }
.city-card-actions .city-start { white-space: normal; }
.city-preview {
  flex: 1 1 max-content; justify-content: space-between; color: var(--marble);
  border-color: color-mix(in srgb, var(--city-accent) 31%, var(--bg-0)); background: #0d0b0960; box-shadow: none;
}
.city-preview span { color: var(--city-accent); font-size: 15px; }
.city-preview:hover:not(:disabled) { border-color: var(--city-accent); background: color-mix(in srgb, var(--city-accent) 13%, var(--bg-1)); }

.modal-city-roster { width: min(100%, 590px); max-height: calc(100dvh - 32px); }
.modal-city-roster .modal-body { padding: 0; }
.modal-city-roster .modal-title { color: var(--city-accent); }
.modal-city-roster .modal-x, .modal-city-roster .modal-foot .btn { min-height: 44px; }
.modal-city-roster .modal-x { width: 44px; flex: none; }
.city-roster-art { aspect-ratio: 2 / 1; border-bottom: 1px solid var(--line); }
.city-roster-desc { margin: 14px 16px 12px; color: var(--marble-2); }
.city-roster-heading { margin: 0 16px 7px; color: var(--marble); font-size: 19px; }
.city-roster-list { display: grid; gap: 6px; padding: 0; margin: 0 16px 16px; list-style: none; }
.city-roster-unit {
  display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 44px; padding: 4px 7px;
  border: 1px solid var(--line); border-radius: 4px; background: var(--ui-well);
}
.city-unit-tier { flex: 0 0 2.4em; color: var(--city-accent); font: 600 13px var(--font-title); text-align: center; }
.city-unit-name, .city-unit-role { display: block; }
.city-unit-role { color: var(--marble-2); font-size: 12px; }

@media (min-width: 480px) {
  .city-roster-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 640px) {
  .city-menu-nav { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 12px; }
  .city-menu-brand { grid-column: auto; grid-row: auto; }
  .city-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .city-grid-playable .city-card-art { aspect-ratio: 2.32 / 1; }
  .city-card-title { inset: auto 16px 14px; }
  .city-card-body { padding: 13px 16px 15px; }
}
@media (min-width: 960px) {
  .city-grid:not(.city-grid-playable),
  .city-grid-many { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .city-grid-many .city-card-art { aspect-ratio: 2.35 / 1; }
}
@media (prefers-reduced-motion: reduce) {
  .city-card, .city-card-actions .btn { transition: none; }
  .modal-city-roster, .modal-backdrop:has(.modal-city-roster) { animation: none; }
}

/* ───────────── saves ───────────── */
.save-list { display: flex; flex-direction: column; gap: 6px; }
.save-row {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 6px;
  background: var(--ui-well); border: 1px solid var(--ui-border);
}
.save-row.empty .save-desc { font-style: italic; }
.save-info { flex: 1; min-width: 0; }
.save-slot { font-weight: 700; }
.save-desc { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.save-buttons { display: flex; gap: 6px; }
.save-empty { padding: 10px; text-align: center; }
/* QA 29.11: the saves screen is a full screen (modal-screen), not a pop-up; confirmations live in the row */
.save-screen { width: min(100%, 760px); margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.save-title { margin: 0; text-align: center; font: 700 26px/1.2 var(--font-title); color: var(--ui-heading); }
.modal-screen:not(.has-hud-context) .save-title { display: none; } /* the screen's own band already shows the title */
.save-tabs { display: flex; justify-content: center; gap: 8px; }
.save-screen .save-row { padding: 12px 14px; }
.save-screen .save-slot { font-size: 16px; }
.save-screen .save-desc { font-size: 13px; }
.save-row.asking { border-color: var(--ui-accent); }
.save-ask { color: var(--ui-accent); font-weight: 600; }

/* ───────────── game over ───────────── */
.game-over { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.game-over-emblem {
  width: 96px; height: 96px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff1c2, #e2b56f 40%, #7a5530 75%);
  box-shadow: 0 0 30px rgba(226, 181, 111, 0.45), inset 0 0 0 4px rgba(0, 0, 0, 0.25);
}
.game-over.lost .game-over-emblem { background: radial-gradient(circle at 50% 40%, #d98a76, #8e2a1c 45%, #2a0c07 80%); box-shadow: 0 0 30px rgba(142, 42, 28, 0.5), inset 0 0 0 4px rgba(0, 0, 0, 0.35); }

/* ───────────── quick battle (fallback) ───────────── */
.qb-sides { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; margin-top: 8px; }
.qb-vs { align-self: center; font: 600 16px var(--font-title); color: var(--ui-heading); text-transform: uppercase; letter-spacing: 0.15em; }
.qb-side { padding: 10px; border-radius: 6px; background: var(--ui-well); border: 1px solid var(--ui-border); }
.qb-title { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.qb-strength { font-size: 12px; margin: 2px 0 8px; }
.qb-stacks { display: flex; flex-direction: column; gap: 4px; }
.qb-stack { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.qb-name { flex: 1; }
.qb-lost { color: var(--ui-bad); font-weight: 700; font-variant-numeric: tabular-nums; }
.qb-outcome { text-align: center; font: 600 30px var(--font-title); color: var(--ui-heading); }
.qb-outcome.lost { color: var(--ui-bad); }

/* ───────────── animations ───────────── */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ───────────── narrow screens ───────────── */
@media (max-width: 1100px) {
  .unit-card { grid-template-columns: 1fr; }
  .army-slots { gap: 5px; }
}

/* ───────────── «Панель проверки» (F2, src/ui/debug_panel.js) ───────────── */
.dbg-panel {
  position: absolute; top: calc(var(--hud-h) + 6px); right: 6px; bottom: 6px; width: 330px; z-index: 60;
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
  background: var(--ui-texture), var(--ui-panel-grad); border: 1px solid var(--ui-border-strong); box-shadow: var(--shadow);
}
.dbg-panel[hidden] { display: none; }
.dbg-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--ui-border); }
.dbg-head-title { font: 600 16px var(--ui-title-font); color: var(--ui-heading); letter-spacing: 0.04em; }
.dbg-key { font-size: 11px; border: 1px solid var(--ui-border); border-radius: 3px; padding: 1px 5px; }
.dbg-close { margin-left: auto; min-width: 28px; font-size: 16px; }
.dbg-status { padding: 6px 10px; font-size: 12px; line-height: 1.45; border-bottom: 1px solid var(--ui-border-soft); background: var(--ui-well); }
.dbg-body { flex: 1; overflow: auto; padding: 4px 10px 10px; }
.dbg-sec { padding: 6px 0 4px; border-bottom: 1px solid var(--ui-border-soft); }
.dbg-sec:last-child { border-bottom: 0; }
.dbg-title { font: 600 12px var(--font-title); color: var(--ui-heading); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 4px; }
.dbg-row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin: 4px 0; }
.dbg-row .btn { flex: 1 1 auto; }
.dbg-row .btn.active { border-color: var(--ui-select); color: var(--ui-select); box-shadow: 0 0 0 1px var(--ui-select) inset; }
.dbg-label { font-size: 12px; color: var(--ui-text-dim); }
.dbg-select, .dbg-num {
  min-height: 26px; border-radius: 4px; border: 1px solid var(--ui-border); background: var(--ui-input-bg); color: var(--ui-text);
  font: 13px var(--font-ui); padding: 2px 6px;
}
.dbg-select { flex: 1 1 150px; min-width: 0; }
.dbg-num { width: 70px; flex: none; }
.dbg-foot { padding: 6px 10px; font-size: 11px; border-top: 1px solid var(--ui-border); }
.dbg-busy .dbg-body { cursor: progress; }
.app.dbg-teleport .mapv-canvas { cursor: crosshair !important; }
.game-over-preview { font-size: 12px; margin-top: 8px; }

/* ───────────── sound control (src/ui/sound_control.js): HUD, main menu, test panel ───────────── */
.sound-ctl { position: relative; display: inline-flex; align-items: stretch; flex: none; }
.sound-toggle { gap: 5px; }
.sound-icon { font-size: 14px; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.sound-toggle.muted { color: var(--ui-bad); border-color: color-mix(in srgb, var(--ui-bad) 55%, var(--ui-border)); }
.sound-toggle.muted .sound-text { text-decoration: none; }
.btn.sound-more { background: transparent; border-color: var(--ui-border); box-shadow: none; color: var(--ui-ghost-text); }
.btn.sound-more:hover:not(:disabled) { background: var(--ui-hover); }
.sound-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 45; width: 250px; padding: 10px 12px 10px;
  display: flex; flex-direction: column; gap: 8px; font-size: 13px;
}
.sound-pop-title { font: 600 15px var(--ui-title-font); color: var(--ui-heading); letter-spacing: 0.04em; }
.sound-pop-row { display: flex; align-items: center; gap: 8px; }
.sound-pop-label { color: var(--ui-text-dim); font-size: 12px; }
.sound-range { flex: 1; min-width: 0; accent-color: var(--ui-accent); }
.sound-value { width: 38px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.sound-mute-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.sound-mute-row input { accent-color: var(--ui-accent); width: 15px; height: 15px; margin: 0; }
.sound-pop-note { font-size: 11.5px; }
.menu-footer { align-items: center; }
.btn.menu-sound { margin-top: 10px; min-height: 28px; padding: 4px 12px; font-size: 12px; background: rgba(0, 0, 0, 0.35); }
.dbg-row .btn.dbg-sound { flex: 0 0 auto; min-width: 112px; }

/* ───────────── faction details (Hellas / Hades) ───────────── */
/* Hellas («Афинеи»): clean architectural marble, subtle 1px limestone borders, flat Aegean buttons, dark graphite tooltips */
:root[data-faction="hellas"] .panel, :root[data-faction="hellas"] .modal {
  border-color: #C9B99C;
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow);
}
:root[data-faction="hellas"] .btn {
  box-shadow: none;
  border-radius: var(--radius-btn);
}
:root[data-faction="hellas"] .btn.primary {
  background: #2F5E8C;
  border-color: #244B73;
  color: #F8F4E8;
  text-shadow: none;
}
:root[data-faction="hellas"] .btn.primary:hover:not(:disabled) {
  background: #244B73;
  border-color: #1D3E60;
}
:root[data-faction="hellas"] .btn.danger {
  background: #C4573D;
  border-color: #9E3F29;
  color: #F8F4E8;
}
:root[data-faction="hellas"] .btn.danger:hover:not(:disabled) {
  background: #AD462E;
}
:root[data-faction="hellas"] .tooltip {
  background: #2B2B2B;
  color: #F8F4E8;
  border-color: #B56A2D;
  border-radius: 6px;
  padding: 8px 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.32);
}
:root[data-faction="hellas"] .hero-level-badge { background: rgba(47, 94, 140, 0.1); color: #244B73; border-color: #2F5E8C; }
:root[data-faction="hellas"] .portrait-count { background: rgba(43, 43, 43, 0.9); color: #F8F4E8; border-color: rgba(201, 185, 156, 0.65); }
:root[data-faction="hellas"] .modal-backdrop { background: rgba(28, 24, 18, 0.52); }
/* Hades («Эреб»): crisp obsidian panels, 1px old-bronze borders, crimson primary accents, clean HUD */
:root[data-faction="hades"] .modal, :root[data-faction="hades"] .dbg-panel {
  border-color: #92734C;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(196, 123, 54, 0.18);
}
:root[data-faction="hades"] .modal-head { border-bottom-color: #443A34; }
:root[data-faction="hades"] .btn.primary { box-shadow: inset 0 1px 0 rgba(255, 210, 160, 0.18); }
:root[data-faction="hades"] .hero-level-badge { background: rgba(128, 55, 43, 0.28); color: #E8DDC8; border-color: #92734C; }

/* ───────────── art skins (src/ui/ui_art.json → skins.<faction>; crisp modern frames + round portrait medallions) ───────────── */
/* Keep Hades dialogs cleanly framed with 1px old-bronze + subtle ember rim (matching the architectural Hades spec) */
:root[data-faction="hades"][data-skin-frame] :is(.bt-panel, .bt-book) {
  border-style: solid;
  border-width: 10px;
  border-color: transparent;
  border-image: var(--ui-skin-frame) 112 / 26px / 6px round;
  border-radius: 2px;
}
@media (forced-colors: active) {
  .btn, .panel, .modal { border: 1px solid CanvasText; }
  .btn.primary, .btn.active { border-color: Highlight; }
}
/* portrait frame: a round medallion over hero portraits (CORE + Town) */
:root[data-skin-portrait] :is(.portrait.hero-portrait, .tw-pic.hero-portrait) {
  border-radius: 50%;
  border-color: transparent;
  aspect-ratio: 1;
  height: auto;
  overflow: visible;
}
:root[data-skin-portrait] :is(.portrait.hero-portrait, .tw-pic.hero-portrait) > img {
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 18%;
  overflow: hidden;
}
:root[data-skin-portrait] :is(.portrait.hero-portrait, .tw-pic.hero-portrait) > :is(.portrait-initials, .tw-ini) {
  border-radius: 50%;
  overflow: hidden;
}
:root[data-skin-portrait] :is(.portrait.hero-portrait, .tw-pic.hero-portrait)::before {
  content: "";
  position: absolute;
  inset: -10%;
  z-index: 1;
  pointer-events: none;
  background: var(--ui-skin-portrait) center / contain no-repeat;
}
:root[data-skin-portrait] .portrait.hero-portrait.no-art::after { display: none; }

/* ───────────── hotseat privacy curtain (native modal <dialog>) ───────────── */
dialog.hs-curtain {
  border: none;
  padding: 0;
  background: transparent;
  color: var(--ui-text);
  max-width: min(500px, 92vw);
  width: 100%;
  margin: auto;
  overflow: visible;
}
dialog.hs-curtain:modal {
  overscroll-behavior: contain;
}
dialog.hs-curtain::backdrop {
  background: radial-gradient(circle at 50% 35%, #231c15 0%, #0b0907 76%);
  opacity: 1;
  overflow: hidden;
  overscroll-behavior: contain;
}
.hs-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 32px 28px;
  background: var(--ui-modal-bg);
  border: 2px solid var(--hs-color, var(--ui-border-strong));
  border-radius: var(--radius-panel);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.72);
}
.hs-date {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
}
.hs-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 999px;
  border: 1px solid var(--hs-color, var(--ui-border-strong));
  background: var(--ui-well);
  font-size: 13px;
  font-weight: 600;
  color: var(--ui-text);
}
.hs-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--hs-color, var(--ui-accent));
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.16);
}
.hs-title {
  margin: 4px 0 0;
  font: 700 clamp(22px, 3.2vw, 30px)/1.2 var(--ui-title-font);
  color: var(--ui-heading);
}
.hs-note {
  margin: 0;
  max-width: 38ch;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ui-text-dim);
}
.hs-actions {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  width: 100%;
}
.hs-start-btn {
  min-width: 210px;
}

/* ───────────── multiplayer lobby & room UI ───────────── */
.mp-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  text-align: left;
}
.mp-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mp-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--ui-border-strong);
  background: var(--ui-panel-2);
  color: var(--ui-text-dim);
  font: 600 14px/1.2 var(--font-ui);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.mp-tab:hover {
  color: var(--ui-text);
  border-color: var(--ui-accent);
}
.mp-tab.is-on {
  background: var(--ui-primary-bg);
  color: var(--ui-primary-text);
  border-color: var(--ui-primary-border);
}
.mp-tab-code {
  padding: 2px 7px;
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
}
.mp-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}
.mp-lead {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ui-text-dim);
}
.mp-config-grid {
  display: grid;
  grid-template-columns: minmax(190px, 260px) 1fr;
  gap: 14px;
  align-items: start;
}
.mp-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--ui-text-dim);
}
.mp-field > span {
  font-weight: 600;
  color: var(--ui-text);
}
.mp-field select,
.mp-input {
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--ui-border-strong);
  background: var(--ui-input-bg);
  color: var(--ui-text);
  font: 400 13.5px/1.3 var(--font-ui);
}
.mp-input:focus,
.mp-field select:focus {
  outline: 2px solid var(--ui-accent);
  outline-offset: 1px;
}
.mp-code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
}
.mp-nick-field {
  flex: 1 1 260px;
  max-width: 340px;
}
.mp-pvp-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.mp-pvp-opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 12px;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid var(--ui-border);
  background: var(--ui-well);
  color: var(--ui-text-dim);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.mp-pvp-opt strong {
  font-size: 13px;
  color: var(--ui-text);
}
.mp-pvp-opt span {
  font-size: 11.5px;
  line-height: 1.35;
}
.mp-pvp-opt:hover:not(:disabled) {
  border-color: var(--ui-accent);
}
.mp-pvp-opt.is-on {
  border-color: var(--ui-accent);
  background: var(--ui-hover);
  box-shadow: inset 0 0 0 1px var(--ui-accent);
}
.mp-pvp-opt:disabled {
  opacity: 0.65;
  cursor: default;
}
.mp-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.mp-sec-head h2,
.mp-lobby-chat h2,
.mp-card h2 {
  margin: 0;
  font: 600 16px/1.25 var(--ui-title-font);
  color: var(--ui-heading);
}
.mp-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--ui-border);
  background: var(--ui-well);
  color: var(--ui-text-dim);
}
.mp-pill.ok {
  border-color: var(--ui-good);
  color: var(--ui-good);
}
.mp-pill.warn {
  border-color: var(--ui-warn);
  color: var(--ui-warn);
}
.mp-seats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mp-seat-row {
  display: grid;
  grid-template-columns: minmax(140px, 190px) 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--ui-border);
  background: var(--ui-well);
}
.mp-seat-row.is-human {
  border-color: var(--ui-border-strong);
}
.mp-seat-row.is-me {
  border-color: var(--ui-accent);
  background: var(--ui-hover);
}
.mp-seat-fac {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--ui-text);
}
.mp-seat-occupant {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.mp-seat-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mp-inline-name {
  width: 160px;
  min-height: 30px;
  padding: 4px 8px;
  font-size: 12.5px;
}
.mp-online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ui-warn);
  flex: 0 0 auto;
}
.mp-online-dot.on {
  background: var(--ui-good);
  box-shadow: 0 0 6px var(--ui-good);
}
.mp-tag {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--ui-border-strong);
  color: var(--ui-accent);
}
.mp-tag.me {
  border-color: var(--ui-good);
  color: var(--ui-good);
}
.mp-entry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.mp-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--ui-border);
  background: var(--ui-well);
}
.mp-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}
.mp-card > button {
  margin-top: auto;
}
.mp-room-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--ui-border-strong);
  background: var(--ui-well);
}
.mp-room-id {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.mp-room-label {
  font-size: 12px;
  color: var(--ui-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mp-room-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
  letter-spacing: 0.16em;
  color: var(--ui-heading);
}
.mp-room-share {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.mp-lobby-cols {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.9fr);
  gap: 16px;
  align-items: start;
}
.mp-lobby-main,
.mp-lobby-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mp-chat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 120px;
  max-height: 210px;
  overflow-y: auto;
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--ui-border);
  background: var(--ui-input-bg);
  font-size: 12.5px;
  line-height: 1.4;
}
.mp-chat-msg {
  word-break: break-word;
  color: var(--ui-text);
}
.mp-chat-msg b {
  color: var(--ui-accent);
}
.mp-chat-empty {
  font-size: 12px;
}
.mp-chat-form {
  display: flex;
  gap: 6px;
}
.mp-footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--ui-border-soft);
}
.mp-ready-ok {
  color: var(--ui-good);
  font-weight: 600;
  font-size: 13px;
}
.btn.hud-mp-room {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.mp-room-modal {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: min(440px, 82vw);
}
.mp-seats-mini {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mp-seat-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--ui-border);
  background: var(--ui-well);
  font-size: 13px;
}
.mp-seat-mini.is-turn {
  border-color: var(--ui-accent);
}
@media (max-width: 820px) {
  .mp-config-grid,
  .mp-entry-grid,
  .mp-lobby-cols {
    grid-template-columns: 1fr;
  }
  .mp-seat-row {
    grid-template-columns: 1fr;
  }
}
