:root {
  --paper-light: #e4e8ea;
  --paper: #cdd2d5;
  --paper-dark: #a0a6a9;
  --paper-shadow: #383c3f;
  --ink: #0a0c0e;
  --ink-faded: #14181c;
  --ink-soft: #1e2428;
  --red-stamp: #7a1f1f;
  --void: #07090a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--void);
  font-family: 'Special Elite', 'Courier New', monospace;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ── Paper base ─────────────────────────────────────────────── */

.paper {
  position: relative;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse 90% 70% at 50% 45%, var(--paper-light) 0%, var(--paper) 55%, var(--paper-dark) 100%);
  overflow: hidden;
}

.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 22%, rgba(30,35,40,.22) 0%, transparent 12%),
    radial-gradient(circle at 82% 78%, rgba(30,35,40,.18) 0%, transparent 14%),
    radial-gradient(circle at 70% 30%, rgba(20,25,30,.12) 0%, transparent  8%),
    radial-gradient(circle at 30% 78%, rgba(20,25,30,.10) 0%, transparent  6%);
  pointer-events: none;
  mix-blend-mode: multiply;
}

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: .28;
  mix-blend-mode: multiply;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(5,8,10,.38) 100%);
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,.07) 0px, rgba(0,0,0,.07) 1px,
    transparent 1px, transparent 3px
  );
  mix-blend-mode: multiply;
  animation: crt-flicker 4.2s infinite;
  /* Promote to its own GPU compositor layer so the looping opacity
     animation (crt-flicker) and the ::after background-position scroll
     don't repaint the page on every keyframe step. translateZ(0) is a
     well-supported hint; will-change names what's actually changing. */
  transform: translateZ(0);
  will-change: opacity;
}

/* Suppress the CRT scanline overlay on the game map — we want the
   hex map to read cleanly, without horizontal banding. The .no-scanlines
   class is applied/removed by showScreen() in script.js. */
.paper.no-scanlines .scanlines { display: none; }

.scanlines::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
    transparent 0%, transparent 47%,
    rgba(255,255,255,.06) 50%,
    transparent 53%, transparent 100%
  );
  background-size: 100% 220%;
  animation: crt-scan 6s linear infinite;
  mix-blend-mode: screen;
}

@keyframes crt-flicker {
  0%,100% { opacity: .96; }
  47%     { opacity: .96; }
  48%     { opacity: .86; }
  49%     { opacity: .96; }
  85%     { opacity: .96; }
  86%     { opacity: 1;   }
  87%     { opacity: .92; }
  88%     { opacity: .96; }
}

@keyframes crt-scan {
  0%   { background-position: 0 -110%; }
  100% { background-position: 0  110%; }
}

/* ── Screens ─────────────────────────────────────────────────── */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
  z-index: 1;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

/* Pause every CSS animation on inactive screens. Compositor still computes
   keyframe interpolation on paused descendants but skips the per-frame
   paint work — same effect as `display:none` without disrupting reflow.
   Targets the typewriter cursor blink (.btn-suffix), faction-list scroll
   effects, the map-popup slide-in, and any ::before/::after animations on
   inactive screens. The CRT scanlines on .paper are explicitly outside any
   .screen so they keep running (and are display:none'd via .no-scanlines
   on the game screen via screen.js). */
.screen:not(.active),
.screen:not(.active) *,
.screen:not(.active) *::before,
.screen:not(.active) *::after {
  animation-play-state: paused !important;
}

/* ── Shared header / footer ──────────────────────────────────── */

.dossier-header {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 3rem .75rem;
  font-size: .85rem;
  letter-spacing: .18em;
  color: var(--ink-faded);
  flex-shrink: 0;
}

.dossier-footer {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 1rem 3rem 1.75rem;
  font-size: .7rem;
  letter-spacing: .25em;
  color: var(--ink-faded);
  flex-shrink: 0;
}

.dossier-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .2rem;
}

.stamp {
  font-family: 'Stardos Stencil', 'Impact', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: .22em;
  padding: .3rem .85rem;
  border: 4px double var(--red-stamp);
  color: var(--red-stamp);
  opacity: .78;
  transform: rotate(-4deg);
  display: inline-block;
  transition: opacity .3s;
}

.redacted {
  color: var(--ink);
  letter-spacing: 0;
  font-size: .9rem;
}

/* ── Main menu ───────────────────────────────────────────────── */

/* ── OLD main-menu rules removed ────────────────────────────────
   The original #screen-menu markup (<.menu>, .menu-buttons,
   .menu-btn with .btn-prefix/.btn-label/.btn-suffix, .title-block,
   .title, .title-eyebrow, .title-rule, .title-subtitle) was replaced
   with the prototype's chrome (wordmark, .menu .menu-item, top/bot
   strips, compass, stamp-block) sourced from
   `dev-prototypes/alyrium menu v1/styles.css`. The orphaned rules
   were conflicting with the prototype's .menu rule (cascade order
   stretched the new nav to full viewport width). @keyframes blink
   was only used by the old .btn-suffix::after and was removed too
   — .tw-blink keyframe (line ~4182) is the typewriter cursor and
   is untouched. */

/* ── New main-menu overrides ─────────────────────────────────────
   - Hide the .paper > .scanlines CRT overlay when #screen-menu is
     active (the prototype menu has its own atmospheric .bg image
     that the scanlines were obscuring).
   - Force the [hidden] attribute to win against the prototype's
     `.menu-item { display: grid }` rule (without this, the platform-
     conditional Quit/Download buttons both stay visible).
   - Override --bg-url with a path relative to index.html (project
     root). The prototype CSS had `url("../../assets/...")` which
     resolves correctly under http:// but file:// protocol (used by
     Tauri / direct-file open) collapses the `../../` and 404s. */

/* Dark base fill: prevents the light .paper background from flashing
   through during opacity cross-fades between dark screens (settings →
   menu, load → menu). Both screens own a dark bg layer, but at low
   opacity the underlying .paper radial-gradient was visible as a brief
   beige flash mid-transition. */
#screen-menu { background: #07060a; }

.paper:has(#screen-menu.active) > .scanlines { display: none; }
.menu-item[hidden],
.menu-item-wrap[hidden] { display: none !important; }
/* (--bg-url override removed — bg image is now applied directly to
   .bg element via inline style in menu-chrome.js, so the path resolves
   against the document base URL under both http:// and file://.) */

/* Restore prototype's inheritable defaults inside ported overlays.
   Production's `html, body { color: var(--ink); font-family: 'Special
   Elite'; }` was leaking via inheritance into overlay containers that
   the prototype CSS didn't explicitly style (e.g. .lore-list-col,
   .panel-body, .fac-dossier). Result: amber text on dark amber-themed
   panels was rendering as dark grey on typewriter Courier. Setting
   these on `.overlay .panel` re-roots the inheritance chain to
   prototype's amber/serif defaults. */
.overlay .panel,
.overlay .ng-panel,
.overlay .confirm {
  color: #f3e9d2;
  font-family: "EB Garamond", Garamond, "Times New Roman", serif;
}

/* Fullscreen mode (F11 or Fullscreen API): auto-center the wordmark
   and menu, hide right-side decorations. Matches the manual
   `data-layout="center"` rules but applied automatically without
   persisting the user's layout preference. */
.stage.is-fullscreen .wordmark {
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}
.stage.is-fullscreen .wordmark .pre { justify-content: center; }
.stage.is-fullscreen .wordmark .sub { max-width: none; white-space: nowrap; }
.stage.is-fullscreen .menu {
  left: 50%;
  transform: translateX(-50%);
}
.stage.is-fullscreen .stamp-block,
.stage.is-fullscreen .compass { display: none; }

/* ── Difficulty selection ────────────────────────────────────── */

.difficulty-main {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 3rem 1rem;
  display: flex;
  flex-direction: column;
}

.difficulty-heading {
  font-family: 'Stardos Stencil', sans-serif;
  font-size: 1rem;
  letter-spacing: .22em;
  color: var(--ink-faded);
  font-weight: 400;
}

.difficulty-rule {
  height: 1px;
  background: var(--ink-faded);
  opacity: .25;
  margin: .6rem 0 .7rem;
}

.difficulty-subtitle {
  font-size: .75rem;
  letter-spacing: .1em;
  color: var(--ink-faded);
  margin-bottom: 1.5rem;
  opacity: .65;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.1rem;
  flex: 1;
  align-content: start;
}

.diff-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  padding: 1.1rem 1.1rem 1.2rem;
  background: rgba(10,12,14,.04);
  border: 1px solid rgba(10,12,14,.18);
  cursor: pointer;
  text-align: left;
  font-family: 'Special Elite', monospace;
  color: var(--ink);
  transition: background .15s, border-color .15s, box-shadow .15s;
}

.diff-card:hover {
  background: rgba(10,12,14,.08);
  border-color: rgba(10,12,14,.35);
}

.diff-card.is-selected {
  background: rgba(122,31,31,.05);
  border-color: var(--red-stamp);
  box-shadow: inset 0 0 0 1px var(--red-stamp);
}

.diff-card-code {
  font-size: .62rem;
  letter-spacing: .2em;
  color: var(--ink-faded);
  opacity: .55;
}

.diff-card-name {
  font-family: 'Stardos Stencil', sans-serif;
  font-size: 1.6rem;
  letter-spacing: .1em;
  color: var(--ink);
  line-height: 1;
}

.diff-card.is-selected .diff-card-name {
  color: var(--red-stamp);
}

.diff-card-tag {
  font-size: .68rem;
  letter-spacing: .2em;
  color: var(--red-stamp);
  opacity: .6;
  border-top: 1px solid rgba(122,31,31,.2);
  padding-top: .4rem;
  margin-top: .05rem;
}

.diff-card.is-selected .diff-card-tag {
  opacity: 1;
}

.diff-card-desc {
  font-size: .76rem;
  line-height: 1.6;
  color: var(--ink-faded);
  flex: 1;
  margin: 0;
}

@media (max-width: 860px) {
  .difficulty-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Faction selection ───────────────────────────────────────── */

.factions-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 0;
  padding: 0 2.5rem;
  gap: 0;
  position: relative;
  z-index: 5;
}

.faction-list {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding-right: 1.5rem;
  padding-bottom: 1rem;
  border-right: 1px solid var(--ink-faded);
  overflow-y: auto;
}

.faction-tab {
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: .78rem;
  letter-spacing: .14em;
  text-align: left;
  padding: .75rem 1rem;
  cursor: pointer;
  transition: all .15s ease;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  outline: none;
}

.faction-tab:hover,
.faction-tab:focus-visible {
  border-left-color: var(--ink-soft);
  color: var(--ink);
  background: rgba(20,23,26,.05);
}

.faction-tab.active {
  border-left-color: var(--ink);
  color: var(--ink);
  background: rgba(20,23,26,.08);
}

.tab-code {
  font-size: .65rem;
  letter-spacing: .25em;
  color: var(--ink-soft);
  opacity: .7;
}

.faction-tab.active .tab-code { opacity: 1; }

.tab-name {
  font-size: .82rem;
  letter-spacing: .1em;
}

/* ── Faction dossier panel ───────────────────────────────────── */

.faction-dossier {
  padding: 0 0 1rem 2.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-faded) transparent;
  min-width: 0;
}

.dossier-top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.stamp-sm {
  font-family: 'Stardos Stencil', 'Impact', sans-serif;
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .2em;
  padding: .2rem .6rem;
  border: 3px double var(--red-stamp);
  color: var(--red-stamp);
  opacity: .75;
  transform: rotate(-3deg);
  display: inline-block;
}

.dossier-code {
  font-size: .7rem;
  letter-spacing: .3em;
  color: var(--ink-soft);
  align-self: center;
}

.faction-title {
  font-family: 'Stardos Stencil', sans-serif;
  font-weight: 700;
  font-size: clamp(1.4rem, 3.5vw, 2.4rem);
  letter-spacing: .12em;
  color: var(--ink);
  line-height: 1.1;
  margin-bottom: .3rem;
  text-shadow:
    -1px 0 rgba(170,50,50,.18),
     1px 0 rgba(50,170,200,.18),
     1px 1px 0 rgba(0,0,0,.2);
}

.faction-full-name {
  font-size: .78rem;
  letter-spacing: .35em;
  color: var(--ink-soft);
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--ink-faded);
}

.dossier-section {
  margin-bottom: 1.25rem;
}

.section-label {
  font-size: .65rem;
  letter-spacing: .45em;
  color: var(--ink-soft);
  border-bottom: 1px solid rgba(20,24,28,.4);
  padding-bottom: .25rem;
  margin-bottom: .65rem;
}

.leader-row {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: .35rem;
  font-size: .9rem;
}

.leader-name {
  letter-spacing: .08em;
  color: var(--ink);
}

.leader-sep {
  color: var(--ink-soft);
  font-size: .7rem;
}

.leader-role {
  font-size: .75rem;
  letter-spacing: .1em;
  color: var(--ink-soft);
}

.faction-lore {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: .9rem;
  line-height: 1.75;
  color: var(--ink-faded);
  white-space: pre-line;
}

.faction-ally {
  font-size: .9rem;
  letter-spacing: .1em;
  color: var(--ink);
}

/* ── Stat bars ───────────────────────────────────────────────── */

.stats-grid {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.stat-row {
  display: grid;
  grid-template-columns: 6.2rem minmax(0, 1fr) 4.6rem;
  align-items: center;
  gap: .65rem;
  font-size: .72rem;
  letter-spacing: .18em;
  color: var(--ink-soft);
  min-width: 0;
}

.stat-bar-track {
  height: 6px;
  background: rgba(20,24,28,.2);
  position: relative;
  overflow: hidden;
}

.stat-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--ink);
  transition: width .6s ease;
}

.stat-val {
  text-align: right;
  color: var(--ink);
  font-size: .78rem;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Faction footer ──────────────────────────────────────────── */

.faction-footer {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .85rem 2.5rem 1.75rem;
  border-top: 1px solid rgba(20,24,28,.3);
  flex-shrink: 0;
}

.footer-file {
  font-size: .7rem;
  letter-spacing: .25em;
  color: var(--ink-faded);
}

.action-btn {
  font-family: inherit;
  font-size: .85rem;
  letter-spacing: .25em;
  background: transparent;
  border: 2px solid var(--ink);
  color: var(--ink);
  padding: .6rem 1.2rem;
  cursor: pointer;
  transition: background .18s, color .18s, transform .18s;
  outline: none;
}

.action-btn:hover,
.action-btn:focus-visible {
  background: var(--ink);
  color: var(--paper-light);
}

.btn-assume:hover,
.btn-assume:focus-visible { transform: translateX(4px); }

.btn-back:hover,
.btn-back:focus-visible  { transform: translateX(-4px); }

.action-btn:active { transform: scale(.97); }

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 700px) {
  .factions-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    padding: 0 1.25rem;
  }

  .faction-list {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--ink-faded);
    padding-right: 0;
    padding-bottom: .75rem;
    overflow-x: auto;
    overflow-y: visible;
  }

  .faction-tab { border-left: none; border-bottom: 3px solid transparent; }
  .faction-tab.active { border-bottom-color: var(--ink); }

  .faction-dossier { padding: 1rem 0 0; }
  .dossier-header, .dossier-footer, .faction-footer { padding-left: 1.25rem; padding-right: 1.25rem; }
  .menu-buttons { min-width: 0; width: 100%; max-width: 360px; }
}

/* ── Game screen ─────────────────────────────────────────────── */

.game-header {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .65rem 2rem;
  background: rgba(10,12,14,.92);
  border-bottom: 1px solid rgba(80,100,120,.22);
  flex-shrink: 0;
  gap: 1rem;
}

.game-header-left {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  font-family: 'Special Elite', monospace;
}

.game-header-label {
  font-size: .6rem;
  letter-spacing: .45em;
  color: rgba(180,200,220,.4);
}

.game-turn-num {
  font-size: 1.3rem;
  color: var(--paper-light);
}

.game-date {
  font-size: .78rem;
  letter-spacing: .2em;
  color: var(--paper);
  opacity: .7;
}

.game-header-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}

.game-campaign-title {
  font-family: 'EB Garamond', serif;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: .12em;
  color: var(--paper-light);
  white-space: nowrap;
  opacity: .72;
  padding: .22rem .9rem;
  border: 1px solid rgba(205, 210, 213, .28);
  box-shadow: 0 0 8px rgba(205, 210, 213, .12), inset 0 0 6px rgba(205, 210, 213, .04);
}

.game-header-right { display: flex; align-items: center; gap: .6rem; }

.action-btn--icon {
  padding: .5rem .65rem;
  font-size: 1rem;
  letter-spacing: 0;
  min-width: unset;
  opacity: .65;
}
.action-btn--icon:hover,
.action-btn--icon:focus-visible { opacity: 1; }

.action-btn--danger {
  border-color: rgba(180,60,50,.8);
  color: rgba(220,120,110,.95);
}
.action-btn--danger:hover,
.action-btn--danger:focus-visible {
  background: rgba(180,60,50,.85);
  color: var(--paper-light);
  border-color: rgba(200,70,60,.9);
}

.settings-game-actions {
  display: none;
  gap: .6rem;
  align-items: center;
}

/* ── Settings screen ─────────────────────────────────────────── */

.settings-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 3rem;
  gap: 1.4rem;
  overflow-y: auto;
}

.settings-title {
  font-family: 'Stardos Stencil', 'Courier New', monospace;
  font-size: 2.6rem;
  letter-spacing: .35em;
  color: var(--ink);
  margin-top: 1rem;
}

.settings-rule {
  width: min(440px, 60vw);
  height: 2px;
  background: var(--ink);
  margin: .25rem 0 1.5rem;
  opacity: .7;
}

.settings-group {
  width: min(640px, 80vw);
  border: 1px solid var(--ink-soft);
  padding: 1.4rem 1.6rem;
  background: rgba(10,12,14,.04);
}

.settings-group-label {
  font-family: 'Special Elite', monospace;
  font-size: .75rem;
  letter-spacing: .45em;
  color: var(--ink-soft);
  margin-bottom: 1.1rem;
  border-bottom: 1px solid rgba(10,12,14,.2);
  padding-bottom: .55rem;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: .55rem 0;
}

.setting-label {
  font-size: .95rem;
  letter-spacing: .12em;
  color: var(--ink);
  flex-shrink: 0;
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  justify-content: flex-end;
}

.setting-value {
  font-family: 'Special Elite', monospace;
  font-size: .85rem;
  letter-spacing: .1em;
  color: var(--ink);
  min-width: 3.4rem;
  text-align: right;
  border-left: 1px solid var(--ink-soft);
  padding-left: .8rem;
}

/* ── Settings toggle switch ──────────────────────────────── */
.setting-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}

.setting-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.setting-toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(10,12,14,.12);
  border: 1px solid var(--ink-soft);
  transition: background .2s, border-color .2s;
}

.setting-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--ink-soft);
  transition: transform .2s, background .2s;
}

.setting-toggle input:checked + .setting-toggle-slider {
  background: rgba(10,12,14,.3);
  border-color: var(--ink);
}

.setting-toggle input:checked + .setting-toggle-slider::before {
  transform: translateX(20px);
  background: var(--ink);
}

/* Range slider — typewriter aesthetic */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 280px;
  max-width: 50vw;
  height: 4px;
  background: var(--ink-soft);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--ink);
  border: 2px solid var(--paper-light);
  border-radius: 0;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--ink);
  border: 2px solid var(--paper-light);
  border-radius: 0;
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS SCREEN — New visual (matches main-menu stage aesthetic)
   Dark background · amber chrome · Cinzel / EB Garamond typography
   All old .settings-* / .setting-* classes remain in the file for
   other screens that still reference them (load, lore, tutorial).
   ═══════════════════════════════════════════════════════════════ */

/* Base fill — shows while bg image loads */
#screen-settings { background: #07060a; }

/* ── Background layers ── */
.sett-bg {
  position: absolute;
  inset: -2%;
  background: center / cover no-repeat;
  filter: brightness(.28) contrast(1.05) saturate(.7);
  z-index: 0;
  animation: bg-drift 60s ease-in-out infinite alternate;
}

.sett-flicker {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(55% 45% at 60% 42%, rgba(232,200,120,.07), transparent 65%);
  z-index: 1;
  animation: flicker 4.7s ease-in-out infinite;
}

/* ── Full-screen panel (no outer chrome) ── */
.sett-panel {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Panel header ── */
.sett-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 1rem 3rem .75rem;
  border-bottom: 1px solid rgba(232,200,120,.18);
  gap: 16px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.sett-head-left {
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.sett-num {
  font-family: "EB Garamond", Garamond, serif;
  font-size: 11px;
  letter-spacing: .3em;
  color: #c89a4a;
}
.sett-title {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: 30px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #f3e9d2;
  line-height: 1;
}
.sett-head-sub {
  font-family: "EB Garamond", Garamond, serif;
  font-size: 10px;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: rgba(201,187,154,.5);
}

/* ── Scrollable body ── */
.sett-body {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;          /* centre groups within full-width body */
  gap: 1.2rem;
  scrollbar-width: thin;
  scrollbar-color: #5a4220 transparent;
  position: relative;
  z-index: 2;
}
.sett-body::-webkit-scrollbar { width: 5px; }
.sett-body::-webkit-scrollbar-thumb { background: #5a4220; }

/* ── Settings groups ── */
.sett-group {
  width: min(640px, 80vw);      /* same width as old .settings-group */
  border: 1px solid rgba(232,200,120,.16);
  padding: 1.4rem 1.6rem;
  background: rgba(232,200,120,.025);
}
.sett-group-label {
  font-family: "EB Garamond", Garamond, serif;
  font-size: 10px;
  letter-spacing: .42em;
  text-transform: uppercase;
  color: #c89a4a;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(232,200,120,.1);
}
.sett-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(232,200,120,.07);
}
.sett-row:last-child { border-bottom: none; }
.sett-label {
  font-family: "EB Garamond", Garamond, serif;
  font-size: 15px;
  letter-spacing: .06em;
  color: #c9bb9a;
}
.sett-ctrl {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sett-val {
  font-family: "EB Garamond", Garamond, serif;
  font-size: 12px;
  letter-spacing: .15em;
  color: #e8c878;
  width: 38px;
  text-align: right;
}

/* ── Range inputs (amber) ── */
#screen-settings input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 200px;
  max-width: 40vw;
  height: 2px;
  background: rgba(232,200,120,.22);
  outline: none;
  cursor: pointer;
}
#screen-settings input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  background: #c89a4a;
  border: 1px solid #e8c878;
  border-radius: 0;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(232,200,120,.45);
}
#screen-settings input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  background: #c89a4a;
  border: 1px solid #e8c878;
  border-radius: 0;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(232,200,120,.45);
}

/* ── Toggle switch (amber) ── */
.sett-toggle {
  position: relative;
  display: inline-block;
  width: 44px; height: 22px;
  cursor: pointer;
  flex-shrink: 0;
}
.sett-toggle input {
  opacity: 0; width: 0; height: 0;
  position: absolute;
}
.sett-toggle-knob {
  position: absolute;
  inset: 0;
  background: rgba(232,200,120,.1);
  border: 1px solid rgba(232,200,120,.28);
  transition: background .2s, border-color .2s;
}
.sett-toggle-knob::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: rgba(201,187,154,.4);
  transition: transform .2s, background .2s;
}
.sett-toggle input:checked + .sett-toggle-knob {
  background: rgba(200,154,74,.18);
  border-color: #c89a4a;
}
.sett-toggle input:checked + .sett-toggle-knob::before {
  transform: translateX(22px);
  background: #c89a4a;
  box-shadow: 0 0 7px rgba(232,200,120,.45);
}

/* ── Dev section ── */
.sett-group--dev {
  border-color: rgba(220,130,80,.22);
  background: rgba(220,130,80,.03);
}
.sett-dev-label { color: rgba(220,150,90,.85); }
.sett-dev-row {
  flex-direction: column;
  align-items: flex-start;
  gap: .25rem;
  padding-top: 0;
}

/* Dev buttons: override ink-on-paper vars for dark context */
#screen-settings .dev-btn {
  border-color: rgba(232,200,120,.18);
  color: #c9bb9a;
}
#screen-settings .dev-btn-tab  { color: rgba(200,154,74,.7); }
#screen-settings .dev-btn-name { color: #c9bb9a; }
#screen-settings .dev-btn:hover,
#screen-settings .dev-btn:focus-visible {
  background: rgba(232,200,120,.07);
  box-shadow: 3px 3px 0 rgba(0,0,0,.4);
}
#screen-settings .dev-section-tag--victory { color: #7fbc6e; border-color: rgba(127,188,110,.35); }
#screen-settings .dev-section-tag--defeat  { color: #d97a5a; border-color: rgba(217,122,90,.35); }
#screen-settings .dev-section-hint { color: rgba(201,187,154,.45); }
#screen-settings .dev-hint         { color: rgba(201,187,154,.5); }

/* ── Footer ── */
.sett-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .85rem 3rem 1.75rem;
  border-top: 1px solid rgba(232,200,120,.18);
  flex-shrink: 0;
  gap: 10px;
  position: relative;
  z-index: 2;
}
.sett-game-actions {
  display: none;       /* shown via inline style by openSettings() when in-game */
  gap: 8px;
  align-items: center;
}

/* ── Buttons ── */
.sett-btn {
  font-family: "EB Garamond", Garamond, serif;
  font-size: 12px;
  letter-spacing: .26em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid rgba(232,200,120,.35);
  color: #c89a4a;
  padding: 7px 16px;
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s;
  outline: none;
  white-space: nowrap;
}
.sett-btn:hover,
.sett-btn:focus-visible {
  background: rgba(232,200,120,.09);
  border-color: #e8c878;
  color: #e8c878;
}
.sett-btn:active { opacity: .75; }

.sett-btn--back {
  border-color: rgba(232,200,120,.55);
  color: #e8c878;
}
.sett-btn--back:hover,
.sett-btn--back:focus-visible {
  background: rgba(232,200,120,.13);
  border-color: #e8c878;
}

.sett-btn--danger {
  border-color: rgba(217,122,90,.45);
  color: rgba(217,122,90,.9);
}
.sett-btn--danger:hover,
.sett-btn--danger:focus-visible {
  background: rgba(217,122,90,.1);
  border-color: #d97a5a;
  color: #d97a5a;
}

/* ── Load Game screen ───────────────────────────────────────── */

.load-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 3rem;
  gap: 1.4rem;
  overflow-y: auto;
  min-height: 0;
}

.load-slots {
  width: min(640px, 80vw);
  border: 1px solid var(--ink-soft);
  background: rgba(10,12,14,.04);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* When the slot list is empty (only contains .load-empty), centre that
   stamp vertically. With slot cards present, default top-aligned flow. */
.load-slots:has(> .load-empty:only-child) {
  justify-content: center;
  align-items: center;
}

.load-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem 2rem;
}

/* Top bar above the slot list: title on the left, IMPORT button on the right. */
.load-toolbar {
  width: min(640px, 80vw);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.load-import-btn {
  font-size: .68rem;
  letter-spacing: .25em;
  padding: .35rem .8rem;
}

/* In the load screen the separator must match the toolbar/slots width (640px),
   not the narrower settings-screen default (440px). Margins are handled by the
   flex gap so we zero them out to avoid the double-spacing. */
.load-main .settings-rule {
  width: min(640px, 80vw);
  margin: 0;
  flex-shrink: 0;
}

/* The settings-title carries a top margin for the settings screen context where
   it sits as the first item in a column. Inside the load-toolbar (a flex row)
   that margin shifts the title down and inflates the toolbar height. */
.load-toolbar .settings-title {
  margin-top: 0;
}

/* Save slot card — one per saved game. Two-column layout: map thumbnail
   on the left, metadata + actions on the right. Clicking LOAD restores
   the campaign; the × turns into CONFIRM? for 3 seconds before deleting. */
.save-slot {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: .9rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid rgba(10,12,14,.18);
  font-family: 'Special Elite', monospace;
  background: transparent;
  transition: background .12s ease;
}
.save-slot:last-child { border-bottom: none; }
.save-slot:hover     { background: rgba(10,12,14,.05); }

/* Map preview — fixed 8:5 aspect ratio (matches thumbnail capture).
   On narrow viewports the thumbnail shrinks but never below a usable size. */
.save-slot-thumb {
  flex: 0 0 auto;
  width: 144px;
  height: 90px;
  object-fit: cover;
  display: block;
  background: #1c2d3d;
  border: 1px solid rgba(10,12,14,.35);
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}

.save-slot-thumb.is-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(220,210,180,.55);
  font-size: .55rem;
  letter-spacing: .25em;
  font-family: 'Stardos Stencil', monospace;
  text-transform: uppercase;
}

/* Right-side stack — header, label, footer in a vertical column. */
.save-slot-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  min-width: 0;       /* allow long labels to truncate cleanly */
}

.save-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: .82rem;
}

.save-slot-faction {
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--ink);
  text-transform: uppercase;
}

.save-slot-meta {
  font-size: .7rem;
  letter-spacing: .15em;
  color: var(--ink-soft);
  opacity: .7;
}

.save-slot-label {
  font-size: .8rem;
  font-style: italic;
  color: var(--ink-soft);
  opacity: .85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-slot-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: .25rem;
}

.save-slot-stamp {
  font-size: .65rem;
  letter-spacing: .25em;
  color: var(--ink-soft);
  opacity: .55;
  text-transform: uppercase;
}

.save-slot-actions {
  display: inline-flex;
  gap: .4rem;
}

.save-slot-btn {
  font-family: 'Special Elite', monospace;
  font-size: .72rem;
  letter-spacing: .15em;
  padding: .3rem .8rem;
  background: transparent;
  border: 1px solid var(--ink-soft);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}

.save-slot-btn:hover { background: var(--ink); color: var(--paper-light); }

.save-slot-delete {
  padding: .25rem .55rem;
  font-size: .9rem;
  line-height: 1;
}

.save-slot.is-confirming-delete .save-slot-delete {
  background: var(--red-stamp);
  color: var(--paper-light);
  border-color: var(--red-stamp);
  font-size: .7rem;
  letter-spacing: .15em;
  padding: .3rem .6rem;
}

.save-slot-export {
  padding: .3rem .55rem;
  font-size: .9rem;
  line-height: 1;
}

/* Auto / imported saves get a left accent strip + a tiny inline badge so
   the player can spot which slot is which without reading the label. */
.save-slot.is-auto     { border-left: 3px solid #b89e3a; padding-left: calc(1rem - 3px); }
.save-slot.is-imported { border-left: 3px solid #3a7cc4; padding-left: calc(1rem - 3px); }

.save-slot-badge {
  display: inline-block;
  margin-left: .55rem;
  padding: .05rem .4rem;
  font-size: .55rem;
  letter-spacing: .25em;
  font-weight: 700;
  vertical-align: middle;
  border: 1px solid currentColor;
  text-transform: uppercase;
  opacity: .85;
}
.save-slot-badge--auto     { color: #8a7320; }
.save-slot-badge--imported { color: #1f4e80; }

/* Tiny toast for save/load errors. Positioned just above the slot list. */
.save-toast {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper-light);
  font-family: 'Special Elite', monospace;
  font-size: .75rem;
  letter-spacing: .12em;
  padding: .55rem 1rem;
  border: 1px solid var(--ink-soft);
  pointer-events: none;
  opacity: 0;
  transition: opacity .18s ease;
  z-index: 50;
}
.save-toast.is-visible { opacity: 1; }

.load-empty-stamp {
  font-family: 'Stardos Stencil', 'Courier New', monospace;
  font-size: 1.35rem;
  letter-spacing: .35em;
  color: var(--ink-soft);
  border: 3px solid var(--ink-soft);
  padding: .45rem 1.2rem;
  opacity: .55;
  transform: rotate(-2deg);
}

.load-empty-sub {
  font-family: 'Special Elite', monospace;
  font-size: .8rem;
  letter-spacing: .1em;
  color: var(--ink-soft);
  text-align: center;
  opacity: .7;
}

/* ── Load screen — dark/amber overrides (matches settings visual) ── */

#screen-load { background: #07060a; }

/* Load-main body inherits sett-panel flex-column; remove old centred padding */
#screen-load .load-main {
  padding: 1.5rem 3rem;
}

/* Slot list container */
#screen-load .load-slots {
  border-color: rgba(232,200,120,.16);
  background: rgba(232,200,120,.025);
  scrollbar-width: thin;
  scrollbar-color: #5a4220 transparent;
}
#screen-load .load-slots::-webkit-scrollbar { width: 5px; }
#screen-load .load-slots::-webkit-scrollbar-thumb { background: #5a4220; }

/* Individual save cards */
#screen-load .save-slot {
  border-bottom-color: rgba(232,200,120,.1);
  font-family: "EB Garamond", Garamond, serif;
}
#screen-load .save-slot:hover { background: rgba(232,200,120,.05); }
#screen-load .save-slot.is-auto     { border-left-color: #c89a4a; }
#screen-load .save-slot.is-imported { border-left-color: #6a9ed0; }

#screen-load .save-slot-thumb        { border-color: rgba(232,200,120,.2); background: rgba(0,0,0,.5); }
#screen-load .save-slot-thumb.is-empty { color: rgba(201,187,154,.4); }

#screen-load .save-slot-faction { color: #e8c878; }
#screen-load .save-slot-meta    { color: rgba(201,187,154,.6); opacity: 1; }
#screen-load .save-slot-label   { color: rgba(201,187,154,.55); opacity: 1; }
#screen-load .save-slot-stamp   { color: rgba(201,187,154,.4); opacity: 1; }

#screen-load .save-slot-badge--auto     { color: #c89a4a; }
#screen-load .save-slot-badge--imported { color: #6a9ed0; }

/* Action buttons inside slots */
#screen-load .save-slot-btn {
  border-color: rgba(232,200,120,.28);
  color: #c89a4a;
  font-family: "EB Garamond", Garamond, serif;
  background: transparent;
}
#screen-load .save-slot-btn:hover {
  background: rgba(232,200,120,.1);
  color: #e8c878;
}
#screen-load .save-slot-load {
  border-color: rgba(232,200,120,.45);
  color: #e8c878;
}
#screen-load .save-slot.is-confirming-delete .save-slot-delete {
  background: rgba(180,50,40,.7);
  border-color: #d97a5a;
  color: #f3e9d2;
}

/* Empty state */
#screen-load .load-empty-stamp {
  color: rgba(232,200,120,.4);
  border-color: rgba(232,200,120,.25);
  font-family: 'Cinzel', serif;
}
#screen-load .load-empty-sub {
  color: rgba(201,187,154,.45);
  font-family: "EB Garamond", Garamond, serif;
}

/* Save toast (error/confirm messages) */
#screen-load .save-toast {
  background: rgba(14,11,7,.95);
  border-color: rgba(232,200,120,.3);
  color: #c9bb9a;
  font-family: "EB Garamond", Garamond, serif;
}

/* ── Zoom context menu (right-click on the map) ──────────────── */

.zoom-menu {
  position: fixed;
  z-index: 200;
  display: none;
  flex-direction: column;
  min-width: 150px;
  background: rgba(8,10,12,.96);
  border: 1px solid rgba(180,200,220,.30);
  box-shadow: 0 6px 22px rgba(0,0,0,.55);
  font-family: 'Special Elite', monospace;
  letter-spacing: .12em;
}

.zoom-menu.visible { display: flex; }

.zoom-menu button {
  background: transparent;
  border: 0;
  color: var(--paper);
  text-align: left;
  font: inherit;
  font-size: .8rem;
  padding: .65rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(180,200,220,.10);
  letter-spacing: .15em;
}
.zoom-menu button:last-child { border-bottom: 0; }
.zoom-menu button:hover {
  background: rgba(220,225,230,.12);
  color: var(--paper-light);
}

/* End Turn button — light variant against the dark game header */
.game-header .action-btn {
  border-color: rgba(220,225,230,.85);
  color: var(--paper-light);
  background: rgba(220,225,230,.06);
}
.game-header .action-btn:hover,
.game-header .action-btn:focus-visible {
  background: var(--paper-light);
  color: var(--void);
  border-color: var(--paper-light);
}

.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 240px;
  grid-template-rows: 1fr;
  min-height: 0;
}

.map-container {
  position: relative;
  overflow: hidden;
  background: #1c2d3d;
  min-height: 0;
}

#map-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

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

/* ── Map contextual action popup ────────────────────────────── */
@keyframes map-popup-in {
  from { opacity: 0; transform: translate(-50%, calc(-100% + 6px)); }
  to   { opacity: 1; transform: translate(-50%, -100%); }
}
.map-action-popup {
  position: absolute;
  transform: translate(-50%, -100%);
  z-index: 60;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  background: rgba(7, 13, 20, 0.93);
  border: 1px solid rgba(180, 200, 220, 0.18);
  border-radius: 3px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0,0,0,.55);
  animation: map-popup-in .15s ease both;
}
.map-action-popup[hidden] { display: none !important; }

/* Pointer arrow pointing down at the hex */
.map-action-popup::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(180, 200, 220, 0.18);
}
.map-action-popup::before {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid rgba(7, 13, 20, 0.93);
  z-index: 1;
}

.map-popup-btn {
  font-family: 'Special Elite', monospace;
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  padding: .34rem .85rem;
  white-space: nowrap;
  cursor: pointer;
  border-radius: 2px;
  transition: background .12s, border-color .12s, color .12s;
  background: transparent;
}
.map-popup-btn--assault {
  color: rgba(255, 195, 75, .92);
  border: 1px solid rgba(255, 185, 60, .3);
}
.map-popup-btn--assault:hover {
  background: rgba(255, 185, 60, .12);
  border-color: rgba(255, 185, 60, .55);
  color: rgba(255, 210, 100, 1);
}
.map-popup-btn--coord {
  color: rgba(150, 195, 255, .82);
  border: 1px solid rgba(130, 180, 255, .22);
}
.map-popup-btn--coord:hover {
  background: rgba(130, 180, 255, .1);
  border-color: rgba(130, 180, 255, .45);
  color: rgba(170, 210, 255, 1);
}
/* Status label shown during attack-mode phases */
.map-popup-status {
  font-family: 'Special Elite', monospace;
  font-size: .58rem;
  letter-spacing: .08em;
  color: rgba(200, 220, 240, .55);
  text-align: center;
  padding: .15rem .4rem .1rem;
  pointer-events: none;
  user-select: none;
}
.map-popup-status--spent {
  color: rgba(200, 160, 100, .55);
  font-style: italic;
}
/* Cancel / back button — muted styling, distinct from assault/coord */
.map-popup-btn--cancel {
  color: rgba(200, 120, 120, .75);
  border: 1px solid rgba(200, 100, 100, .18);
}
.map-popup-btn--cancel:hover {
  background: rgba(200, 80, 80, .1);
  border-color: rgba(200, 100, 100, .4);
  color: rgba(230, 140, 140, 1);
}

/* Unit list rendered inside the map-action popup (above assault buttons). */
.map-popup-units {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 200px;
  max-height: 152px; /* ~5 compact rows before scroll kicks in */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(180,200,220,.2) transparent;
  padding-bottom: 4px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(180, 200, 220, 0.14);
}

/* Compact single-line unit row — checkbox · name · hp bar · hp num */
.map-popup-unit-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .2rem .4rem;
  background: rgba(220,225,230,.04);
  border: 1px solid rgba(180,200,220,.1);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.map-popup-unit-row:hover:not(.is-spent):not(.is-readonly) {
  background: rgba(220,225,230,.09);
  border-color: rgba(180,200,220,.28);
}
.map-popup-unit-row.is-readonly {
  cursor: default;
}
.map-popup-unit-row.is-spent {
  opacity: .45;
  cursor: default;
}
.map-popup-unit-row.is-special {
  border-left: 3px solid rgba(228,190,42,.75);
  background: rgba(228,190,42,.04);
}
.map-popup-unit-row.is-foreign-unit {
  border-left: 3px solid rgba(108,194,255,.6);
  background: rgba(108,194,255,.03);
}
.map-popup-unit-name {
  flex: 1;
  min-width: 0;
  font-size: .78rem;
  color: rgba(230,232,228,.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Unified coord-assault unit list — grouped by source region */
.map-popup-coord-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(180,200,220,.2) transparent;
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(180, 200, 220, 0.14);
}
.map-popup-coord-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.map-popup-coord-group-name {
  font-family: 'Special Elite', monospace;
  font-size: .55rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: rgba(228,190,42,.85);
  text-transform: uppercase;
  padding: .15rem .4rem 0;
}
.map-popup-unit-row.is-unchecked {
  opacity: .5;
}

#map-canvas.is-revealing {
  animation: mapFadeIn 1.8s ease-out forwards;
}

/* ── Cinematický loading overlay ─────────────────────────────── */

#map-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a2a38;
  opacity: 0;
  pointer-events: none;
  transition: opacity .45s ease;
}

#map-loading-overlay.is-active {
  opacity: 1;
}

.map-loading-text {
  color: rgba(160, 195, 225, 0.55);
  letter-spacing: .28em;
  font-size: .72rem;
  font-family: inherit;
}

/* ── Faction stats overlay (top-left of map) ─────────────────── */

.map-stats-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  min-width: 280px;
  padding: .85rem 1rem .9rem;
  background: rgba(8, 10, 12, .88);
  border: 1px solid rgba(220, 225, 230, .28);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .55);
  font-family: 'Special Elite', 'Courier New', monospace;
  color: var(--paper);
  pointer-events: none;       /* let map clicks pass through */
  backdrop-filter: blur(2px);
}

.map-stats-header {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid rgba(220, 225, 230, .22);
  padding-bottom: .55rem;
  margin-bottom: .65rem;
}

.map-stats-eyebrow {
  font-size: .55rem;
  letter-spacing: .35em;
  color: rgba(220, 225, 230, .55);
}

.map-stats-faction {
  font-size: .85rem;
  letter-spacing: .14em;
  color: var(--paper-light);
  margin-top: .15rem;
}

.map-stat-row {
  display: grid;
  grid-template-columns: 5.6rem 1fr 4.8rem;
  align-items: center;
  gap: .55rem;
  padding: .26rem 0;
}

.map-stat-label {
  font-size: .6rem;
  letter-spacing: .22em;
  color: rgba(220, 225, 230, .65);
}

.map-stat-bar {
  position: relative;
  height: 7px;
  background: rgba(220, 225, 230, .08);
  border: 1px solid rgba(220, 225, 230, .22);
  overflow: hidden;
}

.map-stat-fill {
  height: 100%;
  width: 0%;
  background: var(--paper-light);
  transition: width .35s ease;
}

.map-stat-val {
  font-size: .75rem;
  color: var(--paper-light);
  text-align: right;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}

/* Color-coded fills per stat — matches dossier visual language */
#stat-military-fill   { background: #d24a3a; }   /* military = red */
#stat-economic-fill   { background: #1c8a5a; }   /* economic = green */
#stat-diplomatic-fill { background: #3a7cc4; }   /* diplomatic = blue */
#stat-stability-fill  { background: #e0a823; }   /* stability = gold */

/* DP→EP swap button — re-enables pointer events that the panel disables. */
.map-stats-swap-btn {
  display: block;
  width: 100%;
  margin-top: .7rem;
  padding: .35rem 0;
  background: rgba(58, 124, 196, .12);
  border: 1px solid rgba(58, 124, 196, .55);
  color: var(--paper-light);
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: .58rem;
  letter-spacing: .22em;
  cursor: pointer;
  pointer-events: auto;
  transition: background .15s ease, border-color .15s ease;
}
.map-stats-swap-btn:hover {
  background: rgba(58, 124, 196, .25);
  border-color: rgba(58, 124, 196, .85);
}
.map-stats-swap-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

/* Swap modal — minimal styling, mirrors battle/event modals' visual language */
.swap-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 90;
  align-items: center;
  justify-content: center;
  font-family: 'Special Elite', 'Courier New', monospace;
}
.swap-modal.open { display: flex; }
.swap-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(2px);
}
.swap-modal-card {
  position: relative;
  z-index: 1;
  min-width: 380px;
  max-width: 480px;
  padding: 1.25rem 1.4rem 1.3rem;
  background: rgba(8, 10, 12, .95);
  border: 1px solid rgba(220, 225, 230, .35);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .65);
  color: var(--paper);
}
.swap-modal-close {
  position: absolute;
  top: .35rem;
  right: .55rem;
  background: transparent;
  border: none;
  color: rgba(220, 225, 230, .55);
  font-size: 1.4rem;
  cursor: pointer;
}
.swap-modal-close:hover { color: var(--paper-light); }
.swap-modal-eyebrow {
  font-size: .55rem;
  letter-spacing: .35em;
  color: rgba(58, 124, 196, .85);
}
.swap-modal-title {
  font-size: .9rem;
  letter-spacing: .14em;
  margin: .25rem 0 .9rem;
  color: var(--paper-light);
}
.swap-modal-rate {
  font-size: .7rem;
  letter-spacing: .1em;
  color: rgba(220, 225, 230, .7);
  padding-bottom: .7rem;
  border-bottom: 1px solid rgba(220, 225, 230, .18);
  margin-bottom: .8rem;
}
.swap-modal-input-label {
  display: block;
  font-size: .55rem;
  letter-spacing: .25em;
  color: rgba(220, 225, 230, .55);
  margin-bottom: .35rem;
}
#swap-amount-input {
  width: 100%;
  padding: .45rem .6rem;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(220, 225, 230, .35);
  color: var(--paper-light);
  font-family: inherit;
  font-size: .9rem;
  letter-spacing: .05em;
}
.swap-modal-preview {
  margin-top: .65rem;
  font-size: .8rem;
  letter-spacing: .08em;
  color: var(--paper-light);
}
.swap-modal-preview.invalid { color: #d24a3a; }
.swap-modal-actions {
  display: flex;
  gap: .6rem;
  margin-top: 1.05rem;
}
.swap-modal-confirm,
.swap-modal-cancel {
  flex: 1;
  padding: .5rem 0;
  background: rgba(58, 124, 196, .15);
  border: 1px solid rgba(58, 124, 196, .65);
  color: var(--paper-light);
  font-family: inherit;
  font-size: .65rem;
  letter-spacing: .22em;
  cursor: pointer;
  transition: background .15s ease;
}
.swap-modal-confirm:hover { background: rgba(58, 124, 196, .35); }
.swap-modal-confirm:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.swap-modal-cancel {
  background: rgba(220, 225, 230, .06);
  border-color: rgba(220, 225, 230, .35);
}
.swap-modal-cancel:hover { background: rgba(220, 225, 230, .14); }

/* ── Action dropdowns inside the stats panel ─────────────────── */

.map-actions-section {
  margin-top: .8rem;
  padding-top: .65rem;
  border-top: 1px solid rgba(220, 225, 230, .22);
  pointer-events: auto;          /* re-enable click — parent has none */
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.map-action-group { width: 100%; }

.map-action-group summary {
  list-style: none;
  cursor: pointer;
  padding: .35rem .55rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .65rem;
  letter-spacing: .22em;
  color: rgba(220, 225, 230, .85);
  background: rgba(220, 225, 230, .04);
  border: 1px solid rgba(220, 225, 230, .18);
  user-select: none;
  transition: background .15s, color .15s, border-color .15s;
}
.map-action-group summary::-webkit-details-marker { display: none; }
.map-action-group summary::marker { content: ''; }

.map-action-group summary:hover {
  background: rgba(220, 225, 230, .12);
  color: var(--paper-light);
  border-color: rgba(220, 225, 230, .35);
}

.map-action-chevron {
  font-size: .7rem;
  transition: transform .2s ease;
  display: inline-block;
}
.map-action-group[open] .map-action-chevron { transform: rotate(90deg); }

.map-action-list {
  list-style: none;
  margin: .25rem 0 .15rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .12rem;
}

.map-action-btn {
  width: 100%;
  font-family: inherit;
  font-size: .68rem;
  letter-spacing: .12em;
  text-align: left;
  padding: .32rem .55rem;
  background: transparent;
  border: 1px solid transparent;
  color: rgba(220, 225, 230, .78);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s, padding-left .12s;
}

.map-action-btn::before {
  content: "› ";
  opacity: .45;
  margin-right: .15rem;
}

.map-action-btn:hover {
  background: rgba(220, 225, 230, .10);
  color: var(--paper-light);
  border-color: rgba(220, 225, 230, .25);
  padding-left: .85rem;
}

.map-action-btn:active { transform: scale(.98); }

.map-sidebar-panel {
  background: rgba(8,10,12,.94);
  border-left: 1px solid rgba(80,100,120,.2);
  color: var(--paper-light);
  font-family: 'Special Elite', monospace;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem;
  gap: .75rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(80,100,120,.3) transparent;
}

.sb-section {
  border-bottom: 1px solid rgba(80,100,120,.18);
  padding-bottom: .75rem;
}

.sb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.sb-lore-btn {
  position: relative;
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  background: rgba(220,225,230,.06);
  border: 1px solid rgba(180,200,220,.35);
  cursor: pointer;
  padding: 0;
  font-size: 0;
  color: transparent;
  transition: background .15s, border-color .15s, transform .1s;
}

.sb-lore-btn::before,
.sb-lore-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  background: var(--paper-light);
}

.sb-lore-btn::before {
  width: 50%;
  height: 1.5px;
  transform: translate(-50%, -50%);
}

.sb-lore-btn::after {
  width: 1.5px;
  height: 50%;
  transform: translate(-50%, -50%);
}

.sb-lore-btn:hover {
  background: rgba(220,225,230,.16);
  border-color: rgba(220,225,230,.65);
}

.sb-lore-btn:active { transform: scale(.94); }

.sb-label {
  font-size: .6rem;
  letter-spacing: .45em;
  color: rgba(180,200,220,.4);
  margin-bottom: .4rem;
}

.sb-region-name {
  font-size: 1rem;
  letter-spacing: .1em;
  color: var(--paper-light);
  margin-bottom: .25rem;
}

.sb-detail {
  font-size: .75rem;
  letter-spacing: .08em;
  color: var(--paper);
  opacity: .65;
  margin-bottom: .1rem;
}

.sb-badge {
  display: inline-block;
  font-size: .72rem;
  letter-spacing: .18em;
  color: #fff;
  padding: .22rem .65rem;
  margin-top: .25rem;
}

/* ── Lore modal photo slots (.lm-photo) ────────────────────────
   Photo frames shown inside the province lore modal after the
   title. City gets a tall full-width shot; port/airport/base get
   compact thumbnails arranged in a flex row (.lm-photo-row).
   When the image file is missing, onerror hides it and the ghost
   (corner brackets + "NO PHOTOGRAPH ON FILE") stays visible.     */

.lore-modal-photos {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin: .2rem 0 1rem;
  empty-cells: hide;
}
.lore-modal-photos:empty { display: none; }

.lm-photo-row {
  display: flex;
  gap: .45rem;
}

.lm-photo {
  position: relative;
  /* No `flex: 1` here — it would set flex-basis:0 and collapse this
     to 0 height inside the column-flex .lore-modal-photos parent.
     `flex: 1` is only applied to .lm-photo when nested in a row. */
  height: 170px;
  background: rgba(10,13,16,0.6);
  border: 1px dashed rgba(180,200,220,.22);
  overflow: hidden;
}
.lm-photo-row .lm-photo { flex: 1; }   /* equal-width thumbnails */
.lm-photo--sm { height: 90px; }

.lm-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: sepia(.3) contrast(1.06) brightness(.80);
  opacity: 0;
  transition: opacity .4s ease;
}
.lm-photo img.lm-loaded { opacity: 1; }

/* Ghost (shown when image is missing) */
.lm-photo-ghost {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lm-photo-ghost::before,
.lm-photo-ghost::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: rgba(180,200,220,.2);
  border-style: solid;
}
.lm-photo-ghost::before { top: 6px;    left: 6px;    border-width: 1px 0 0 1px; }
.lm-photo-ghost::after  { bottom: 6px; right: 6px;   border-width: 0 1px 1px 0; }

.lm-photo-none {
  font-size: .44rem;
  letter-spacing: .44em;
  color: rgba(180,200,220,.18);
  text-align: center;
  pointer-events: none;
}

.lm-photo-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: .18rem .4rem;
  background: rgba(0,0,0,.6);
  font-size: .5rem;
  letter-spacing: .22em;
  color: rgba(200,210,220,.5);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-hint {
  font-size: .72rem;
  color: rgba(180,200,220,.35);
  letter-spacing: .08em;
  line-height: 1.65;
  border-bottom: none;
  padding-bottom: 0;
}

/* Contextual action dropdowns inside the sidebar (Recruit / Foreign / Build).
   Reuses .map-action-group typography from the old global panel; the wrapper
   stacks the three groups, the body slot styles the placeholder text. */
.sb-actions {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.sb-action-group { width: 100%; }

/* Disabled-state action rows (actionGroupHtml <details>) must match the
   height and typography of the active .sb-recruit-trigger buttons so all
   three RECRUIT / FOREIGN UNITS / BUILD rows stay visually equal. */
.sb-action-group summary {
  padding: .65rem .85rem;
  font-size: .8rem;
  letter-spacing: .28em;
  background: transparent;
  color: rgba(220,225,230,.45);
  border-color: rgba(180,200,220,.13);
}

.sb-action-body {
  font-size: .72rem;
  letter-spacing: .08em;
  color: rgba(220,225,230,.55);
  font-style: italic;
  padding: .4rem .6rem .15rem;
  line-height: 1.5;
}

.map-legend {
  margin-top: auto;
  padding-top: .75rem;
  border-top: 1px solid rgba(80,100,120,.18);
  font-size: .72rem;
  letter-spacing: .1em;
  color: rgba(180,200,220,.5);
}

.legend-title {
  font-size: .58rem;
  letter-spacing: .45em;
  color: rgba(180,200,220,.28);
  margin-bottom: .5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .22rem;
}

.ldot {
  display: inline-block;
  width: 10px; height: 10px;
  flex-shrink: 0;
}

.legend-sym {
  width: 14px;
  text-align: center;
  flex-shrink: 0;
  color: rgba(220,230,240,.6);
}

.legend-sep {
  height: 1px;
  background: rgba(80,100,120,.18);
  margin: .35rem 0;
}

.legend-svg {
  flex-shrink: 0;
  display: block;
  overflow: visible;
}

/* ── Lore modal ─────────────────────────────────────────────── */
.lore-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: 'Special Elite', monospace;
}

.lore-modal.open { display: flex; }

.lore-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4,6,8,.75);
  backdrop-filter: blur(2px);
}

.lore-modal-card {
  position: relative;
  width: min(640px, 92vw);
  max-height: 86vh;
  overflow-y: auto;
  background: rgba(14,18,22,.98);
  border: 1px solid rgba(180,200,220,.28);
  box-shadow: 0 20px 60px rgba(0,0,0,.6), 0 0 0 1px rgba(180,200,220,.06) inset;
  padding: 2rem 2.25rem 2.25rem;
  color: var(--paper-light);
  scrollbar-width: thin;
  scrollbar-color: rgba(80,100,120,.4) transparent;
}

.lore-modal-close {
  position: absolute;
  top: .55rem;
  right: .65rem;
  width: 1.9rem;
  height: 1.9rem;
  background: transparent;
  border: 1px solid rgba(180,200,220,.25);
  color: rgba(220,230,240,.7);
  font-family: 'Special Elite', monospace;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.lore-modal-close:hover {
  background: rgba(220,225,230,.1);
  color: var(--paper-light);
  border-color: rgba(220,225,230,.6);
}

.lore-modal-eyebrow {
  font-size: .62rem;
  letter-spacing: .5em;
  color: rgba(200,80,80,.85);
  margin-bottom: .6rem;
  text-transform: uppercase;
}

.lore-modal-title {
  font-family: 'Stardos Stencil', 'Special Elite', monospace;
  font-size: 1.7rem;
  letter-spacing: .12em;
  margin: 0 0 1.25rem;
  color: var(--paper-light);
  border-bottom: 1px solid rgba(180,200,220,.18);
  padding-bottom: .6rem;
}

.lore-modal-body {
  font-family: 'IM Fell English', 'Special Elite', serif;
  font-size: .98rem;
  line-height: 1.6;
  color: rgba(230,232,228,.86);
}

.lore-modal-body p {
  margin: 0 0 .9rem;
}

.lore-modal-body p:last-child { margin-bottom: 0; }

/* ── Event decision modal ─────────────────────────────────── */
@keyframes event-card-slidein {
  from { opacity: 0; transform: translateY(56px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes event-backdrop-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.event-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: 'Special Elite', monospace;
}

.event-modal.open { display: flex; }

.event-modal.open .event-modal-backdrop {
  animation: event-backdrop-fadein .18s ease-out both;
}

.event-modal.open .event-modal-card {
  animation: event-card-slidein .22s cubic-bezier(.22,.88,.36,1) both;
}

.event-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4,6,8,.82);
  backdrop-filter: blur(3px);
}

.event-modal-card {
  position: relative;
  width: min(720px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  background: rgba(14,18,22,.98);
  border: 1px solid rgba(180,200,220,.32);
  box-shadow: 0 24px 70px rgba(0,0,0,.7), 0 0 0 1px rgba(180,200,220,.06) inset;
  padding: 2rem 2.4rem 2.2rem;
  color: var(--paper-light);
  scrollbar-width: thin;
  scrollbar-color: rgba(80,100,120,.4) transparent;
}

.event-modal-eyebrow {
  font-size: .62rem;
  letter-spacing: .5em;
  color: rgba(200,80,80,.9);
  margin-bottom: .55rem;
  text-transform: uppercase;
}

.event-modal-title {
  font-family: 'Stardos Stencil', 'Special Elite', monospace;
  font-size: 1.7rem;
  letter-spacing: .1em;
  margin: 0 0 1rem;
  border-bottom: 1px solid rgba(180,200,220,.2);
  padding-bottom: .55rem;
}

.event-modal-body {
  font-family: 'IM Fell English', 'Special Elite', serif;
  font-size: 1rem;
  line-height: 1.55;
  color: rgba(230,232,228,.88);
  margin-bottom: 1.4rem;
}

.event-modal-prompt {
  font-size: .62rem;
  letter-spacing: .42em;
  color: rgba(180,200,220,.55);
  margin-bottom: .7rem;
  text-transform: uppercase;
}

.event-modal-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .65rem;
}

.event-choice {
  text-align: left;
  background: rgba(220,225,230,.04);
  border: 1px solid rgba(180,200,220,.28);
  color: var(--paper-light);
  padding: .8rem 1rem .85rem;
  font-family: 'Special Elite', monospace;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.event-choice:hover {
  background: rgba(220,225,230,.13);
  border-color: rgba(220,225,230,.6);
}

.event-choice:active { transform: scale(.985); }

.event-choice-label {
  font-size: .95rem;
  letter-spacing: .1em;
  color: var(--paper-light);
}

.event-choice-desc {
  font-family: 'IM Fell English', 'Special Elite', serif;
  font-size: .78rem;
  line-height: 1.4;
  color: rgba(220,225,228,.72);
}

.event-choice-effects {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .25rem;
  font-size: .65rem;
  letter-spacing: .12em;
}

.event-stat-chip {
  border: 1px solid rgba(180,200,220,.28);
  padding: .08rem .42rem;
}

.event-stat-chip.pos { color: #b8d840; border-color: rgba(184,216,64,.45); }
.event-stat-chip.neg { color: #d2664a; border-color: rgba(210,102,74,.45); }

@media (max-width: 600px) {
  .event-modal-choices { grid-template-columns: 1fr; }
}

/* ── Recruitment modal (full-screen unit gallery) ──────────── */
.recruit-modal {
  position: fixed;
  inset: 0;
  z-index: 9400;
  display: none;
  align-items: stretch;
  justify-content: stretch;
  font-family: 'Special Elite', monospace;
}

.recruit-modal.open { display: flex; }

.recruit-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8,10,12,.72);
  backdrop-filter: blur(2px);
}

.recruit-modal-shell {
  position: relative;
  margin: auto;
  width: min(1280px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: rgba(20,24,28,.97);
  border: 1px solid rgba(180,200,220,.28);
  box-shadow: 0 28px 80px rgba(0,0,0,.75);
  color: var(--paper-light);
}

.recruit-modal-header {
  position: relative;
  padding: 1.4rem 2rem 1.2rem;
  border-bottom: 1px solid rgba(180,200,220,.18);
  flex-shrink: 0;
}

.recruit-modal-eyebrow {
  font-size: .62rem;
  letter-spacing: .5em;
  color: rgba(200,80,80,.85);
  margin-bottom: .35rem;
  text-transform: uppercase;
}

.recruit-modal-title {
  font-family: 'Stardos Stencil', 'Special Elite', monospace;
  font-size: 1.55rem;
  letter-spacing: .12em;
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding-right: 2.5rem;
}

.recruit-modal-budget {
  font-family: 'Special Elite', monospace;
  font-size: .75rem;
  letter-spacing: .3em;
  color: rgba(200,210,220,.7);
}

.recruit-modal-budget strong {
  color: #ffe566;
  font-weight: 400;
  font-size: 1rem;
  letter-spacing: .08em;
}

.recruit-modal-close {
  position: absolute;
  top: 1rem;
  right: 1.1rem;
  width: 2.1rem;
  height: 2.1rem;
  background: transparent;
  border: 1px solid rgba(180,200,220,.28);
  color: rgba(220,230,240,.7);
  font-family: 'Special Elite', monospace;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.recruit-modal-close:hover {
  background: rgba(220,225,230,.1);
  color: var(--paper-light);
  border-color: rgba(220,225,230,.65);
}

.recruit-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
  padding: 1.4rem 2rem 2rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(80,100,120,.4) transparent;
}

.recruit-card {
  background: rgba(28,32,38,.96);
  border: 1px solid rgba(180,200,220,.22);
  padding: 1rem 1.05rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  transition: border-color .15s, transform .08s;
}

.recruit-card.is-disabled {
  opacity: .55;
}

.recruit-card-name {
  font-family: 'Stardos Stencil', 'Special Elite', monospace;
  font-size: 1.1rem;
  letter-spacing: .1em;
  color: var(--paper-light);
}

.recruit-card-role {
  font-size: .63rem;
  letter-spacing: .22em;
  color: rgba(200,210,220,.62);
  text-transform: uppercase;
  margin-top: -.15rem;
  line-height: 1.55;
}

.recruit-card-desc {
  font-family: 'IM Fell English', 'Special Elite', serif;
  font-size: .82rem;
  line-height: 1.5;
  color: rgba(220,225,228,.78);
  flex: 1;
}

.recruit-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .35rem;
  border-top: 1px solid rgba(180,200,220,.14);
  padding-top: .55rem;
}

.recruit-card-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .12rem;
  font-size: .62rem;
  letter-spacing: .22em;
  color: rgba(180,200,220,.55);
  padding: .25rem 0;
  border: 1px solid rgba(180,200,220,.16);
}

.recruit-card-stat-value {
  font-family: 'Stardos Stencil', monospace;
  font-size: 1.05rem;
  letter-spacing: .08em;
  color: var(--paper-light);
}

.recruit-card-stat.muted .recruit-card-stat-value {
  color: rgba(180,200,220,.3);
}

.recruit-card-meta {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  font-size: .68rem;
  letter-spacing: .15em;
  color: rgba(200,210,220,.65);
}

.recruit-card-meta-item {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.recruit-card-meta-label {
  font-size: .55rem;
  letter-spacing: .35em;
  color: rgba(180,200,220,.4);
  text-transform: uppercase;
}

.recruit-card-meta-value {
  font-family: 'Special Elite', monospace;
  font-size: .85rem;
  letter-spacing: .08em;
  color: var(--paper-light);
}

.recruit-card-meta-value.cost-mp { color: #ffe566; }
.recruit-card-meta-value.cost-dp { color: #6cc2ff; }
.recruit-card-meta-value.cost-ep { color: #b8d840; }

/* Foreign units: supplier ribbon at the top of each card so the player
   instantly sees who is selling. Allied (exclusive) suppliers wear a
   warmer tint than neutral arms exporters. */
.recruit-card-power {
  font-size: .58rem;
  letter-spacing: .28em;
  color: rgba(108,194,255,.82);
  text-transform: uppercase;
  border-bottom: 1px solid rgba(108,194,255,.25);
  padding-bottom: .38rem;
  margin-bottom: -.1rem;
}

.recruit-card-power.is-ally {
  color: rgba(255,200,108,.85);
  border-bottom-color: rgba(255,200,108,.32);
}

/* Diplomatic-themed sidebar trigger so the FOREIGN UNITS button reads
   visually distinct from RECRUIT (military). */
.sb-foreign-trigger { /* same shape as .sb-recruit-trigger, alternate accent */ }
.sb-foreign-trigger:hover:not(:disabled) {
  border-color: rgba(108,194,255,.55);
}

/* Construction-themed sidebar trigger — green tint to read as Economic. */
.sb-build-trigger { /* same shape as .sb-recruit-trigger, alternate accent */ }
.sb-build-trigger:hover:not(:disabled) {
  border-color: rgba(184,216,64,.55);
}

/* Construction Office modal — economic green accent throughout */
.build-modal .recruit-card {
  border-color: rgba(184,216,64,.18);
}
.build-modal .recruit-card:not(.is-disabled):hover {
  border-color: rgba(184,216,64,.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.build-modal .recruit-card-role {
  color: rgba(184,216,64,.78);
  letter-spacing: .18em;
}
.build-modal .recruit-card-power {
  color: rgba(184,216,64,.65);
  border-bottom-color: rgba(184,216,64,.22);
}
.build-modal .recruit-card-btn:not(:disabled) {
  background: rgba(100,160,30,.18);
  border-color: rgba(150,210,60,.55);
}
.build-modal .recruit-card-btn:not(:disabled):hover {
  background: rgba(100,160,30,.32);
  border-color: rgba(184,216,64,.9);
}
.build-modal .recruit-card-stats {
  border-top-color: rgba(184,216,64,.16);
}

/* Installations list — one row per finished building, demolish ×-button
   tucked at the right edge. Sized to match .sb-detail line height. */
.sb-installs-list {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  margin-top: .15rem;
}
.sb-install-row {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .78rem;
  color: var(--paper-light);
  line-height: 1.35;
}
.sb-install-glyph {
  color: rgba(255,229,102,.85);
  font-size: .9rem;
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}
.sb-install-name { flex: 1; }
.sb-install-demolish,
.sb-build-cancel {
  background: transparent;
  border: 1px solid rgba(255,255,255,.18);
  color: rgba(255,180,180,.7);
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 2px;
  cursor: pointer;
  font-size: .85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.sb-install-demolish:hover,
.sb-build-cancel:hover {
  background: rgba(210,74,58,.18);
  border-color: rgba(210,74,58,.6);
  color: #fff;
}
.sb-install-effect {
  font-size: .72rem;
  color: rgba(255,229,102,.60);
  padding: .05rem 0 .2rem 1.45rem;
  line-height: 1.3;
}

/* Reuse the recruit-queue look for the build queue — same visual shape,
   just a different label. .sb-build-queue is a subclass for future tweaks. */
.sb-build-queue { margin-top: .35rem; }

/* Foreign-contract tag inline in the garrison list and recruit queue.
   Diplomatic-blue to match the modal accent and contrast with the
   military-yellow MP highlight elsewhere. */
.sb-unit-foreign,
.sb-recruit-queue-foreign {
  display: inline-block;
  font-size: .55rem;
  letter-spacing: .2em;
  color: #6cc2ff;
  border: 1px solid rgba(108,194,255,.4);
  padding: 0 .35em;
  margin-left: .45em;
  vertical-align: middle;
  line-height: 1.4;
}

.recruit-card-btn {
  margin-top: .25rem;
  background: rgba(58,124,196,.18);
  border: 1px solid rgba(120,170,220,.55);
  color: var(--paper-light);
  font-family: 'Special Elite', monospace;
  font-size: .82rem;
  letter-spacing: .25em;
  padding: .55rem .85rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
  text-transform: uppercase;
}

.recruit-card-btn:hover:not(:disabled) {
  background: rgba(58,124,196,.32);
  border-color: rgba(160,200,240,.85);
}

.recruit-card-btn:active:not(:disabled) { transform: scale(.985); }

.recruit-card-btn:disabled {
  cursor: not-allowed;
  background: rgba(80,90,100,.12);
  border-color: rgba(120,130,140,.35);
  color: rgba(200,210,220,.45);
}

/* "RECRUIT" trigger button in the sidebar — replaces the dropdown */
.sb-recruit-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  border: 1px solid rgba(180,200,220,.22);
  color: var(--paper-light);
  font-family: 'Special Elite', monospace;
  font-size: .8rem;
  letter-spacing: .28em;
  padding: .65rem .85rem;
  margin-bottom: .55rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-align: left;
}

.sb-recruit-trigger:hover:not(:disabled) {
  background: rgba(220,225,230,.07);
  border-color: rgba(220,225,230,.5);
}

.sb-recruit-trigger:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.sb-recruit-trigger-chevron {
  color: rgba(200,210,220,.5);
}

/* ── Sidebar: garrison + actions (Phase A — combat UI) ──────── */

.sb-units-list {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-top: .35rem;
}

/* Each unit row is a 4-column grid:
   [checkbox] [name (flex)] [Mv N/M] [HP bar + num]
   Used as a <label> so clicking anywhere in the row toggles the checkbox
   (except the HP bar, which has no input). Spent / hostile rows omit the
   checkbox via a same-width pad span so the columns stay aligned. */
/* Garrison row layout: checkbox on the left (vertically centered),
   right-hand content stacks the unit name on top of a meta line
   (Mv badge + HP bar). The narrow sidebar can't fit name + Mv + HP
   on one line, so stacking lets the name keep the full row width
   without ever breaking a word mid-character. */
.sb-unit-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: .55rem;
  padding: .4rem .55rem;
  background: rgba(220,225,230,.04);
  border: 1px solid rgba(180,200,220,.12);
  font-size: .82rem;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.sb-unit-row:hover:not(.is-readonly):not(.is-spent) {
  background: rgba(220,225,230,.08);
  border-color: rgba(180,200,220,.32);
}
.sb-unit-row.is-spent {
  opacity: .5;
  cursor: default;
}
.sb-unit-row.is-readonly {
  cursor: default;
}

/* ── Unit tier accents ─────────────────────────────────────────
   A coloured left border mirrors the map-badge sidebar stripe so
   the player sees the same signal in both contexts.
   Gold  → faction special (elite / restricted unit)
   Blue  → foreign contract mercenary                           */
.sb-unit-row.is-special {
  border-left: 3px solid rgba(228,190,42,0.75);
  background: rgba(228,190,42,0.04);
}
.sb-unit-row.is-special:hover:not(.is-readonly):not(.is-spent) {
  background: rgba(228,190,42,0.09);
  border-color: rgba(228,190,42,0.95);
}
.sb-unit-row.is-foreign-unit {
  border-left: 3px solid rgba(108,194,255,0.60);
  background: rgba(108,194,255,0.03);
}
.sb-unit-row.is-foreign-unit:hover:not(.is-readonly):not(.is-spent) {
  background: rgba(108,194,255,0.08);
  border-color: rgba(108,194,255,0.90);
}

.sb-unit-check,
.sb-unit-check-pad {
  width: 1.1rem;
  height: 1.1rem;
}
.sb-unit-check {
  margin: 0;
  cursor: pointer;
  accent-color: #7ac96a;
}
.sb-unit-check:disabled {
  cursor: not-allowed;
  accent-color: #888;
}

.sb-unit-content {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  /* min-width: 0 lets the inner flex children wrap correctly inside the
     grid cell instead of pushing the cell wider than its 1fr allotment. */
  min-width: 0;
}

.sb-unit-name {
  color: rgba(230,232,228,.95);
  font-size: .85rem;
  line-height: 1.2;
  /* Wrap only on word boundaries — never split "Regular" into "R/eg/ula/r". */
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.sb-unit-role {
  font-size: .68rem;
  color: rgba(180,190,175,.52);
  letter-spacing: .03em;
  line-height: 1.2;
  font-style: italic;
  overflow-wrap: normal;
  word-break: normal;
}

.sb-unit-meta {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}

.sb-unit-mv,
.sb-unit-mv-pad {
  font-size: .68rem;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: .05rem .35rem;
  border-radius: 2px;
}
.sb-unit-mv {
  color: rgba(150,200,150,.92);
  border: 1px solid rgba(150,200,150,.42);
  background: rgba(150,200,150,.08);
}
.sb-unit-mv.is-spent {
  color: rgba(180,180,180,.65);
  border-color: rgba(180,180,180,.28);
  background: transparent;
}
.sb-unit-mv-pad {
  visibility: hidden;
  border: 1px solid transparent;
}

.sb-unit-hp {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  flex: 0 0 auto;
}

.sb-unit-hp-bar {
  display: inline-block;
  width: 60px;
  height: 6px;
  background: rgba(60,70,80,.55);
  border: 1px solid rgba(180,200,220,.15);
  position: relative;
  overflow: hidden;
}

.sb-unit-hp-fill {
  display: block;
  height: 100%;
  transition: width .25s ease, background .25s ease;
}

.sb-unit-hp-num {
  width: 26px;
  text-align: right;
  color: rgba(230,232,228,.7);
  font-size: .72rem;
}

.sb-recruit-queue {
  margin-top: .55rem;
  padding-top: .4rem;
  border-top: 1px dashed rgba(180,200,220,.18);
}

.sb-recruit-queue-label {
  font-size: .58rem;
  letter-spacing: .35em;
  color: rgba(200,80,80,.85);
  margin-bottom: .25rem;
}

.sb-recruit-queue-item {
  display: flex;
  justify-content: space-between;
  font-size: .76rem;
  color: rgba(230,232,228,.78);
  padding: .15rem .35rem;
}

.sb-recruit-eta {
  color: rgba(200,180,80,.85);
  font-weight: bold;
}

.sb-attack-btn {
  display: block;
  width: 100%;
  padding: .55rem .65rem;
  margin-bottom: .65rem;
  background: rgba(210,90,80,.18);
  border: 1px solid rgba(210,90,80,.55);
  color: #f0e8d0;
  font-family: 'Stardos Stencil', 'Special Elite', monospace;
  font-size: .82rem;
  letter-spacing: .15em;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.sb-attack-btn:hover {
  background: rgba(210,90,80,.32);
  border-color: rgba(220,120,100,.85);
}

.sb-attack-btn.sb-attack-cancel {
  background: rgba(180,180,180,.10);
  border-color: rgba(180,180,180,.35);
}

.sb-bomb-toggle {
  display: flex;
  align-items: center;
  gap: .45rem;
  width: 100%;
  padding: .35rem .55rem;
  margin-bottom: .35rem;
  border: 1px solid rgba(255,180,60,.30);
  background: rgba(255,180,60,.06);
  color: rgba(240,232,208,.65);
  font-family: 'Stardos Stencil', 'Special Elite', monospace;
  font-size: .74rem;
  letter-spacing: .12em;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  box-sizing: border-box;
}
.sb-bomb-toggle input[type="checkbox"] {
  accent-color: #e0a030;
  cursor: pointer;
}
.sb-bomb-toggle.is-active {
  background: rgba(255,160,40,.18);
  border-color: rgba(255,180,60,.70);
  color: #f0d060;
}

.sb-attack-prompt {
  background: rgba(120,200,255,.10);
  border: 1px solid rgba(120,200,255,.45);
  color: rgba(200,225,250,.95);
  font-size: .72rem;
  letter-spacing: .12em;
  padding: .45rem .55rem;
  margin-bottom: .45rem;
}

/* Inline notice on the sidebar (e.g. "select at least one unit"). */
.sb-flash {
  background: rgba(220,180,80,.14);
  border: 1px solid rgba(220,180,80,.55);
  color: rgba(245,225,150,.95);
  font-size: .72rem;
  letter-spacing: .1em;
  padding: .45rem .6rem;
  margin: 0 0 .65rem;
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
}
.sb-flash.is-visible { opacity: 1; }

/* ── Battle log modal ───────────────────────────────────────── */

.battle-modal {
  position: fixed;
  inset: 0;
  z-index: 9700;
  display: none;
  pointer-events: none;
  font-family: 'Special Elite', monospace;
}

.battle-modal.open    { display: block; }
.battle-modal.closing { display: block; }

/* Compact popup animations (slides up from bottom) */
@keyframes battle-slide-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes battle-slide-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to   { opacity: 0; transform: translateX(-50%) translateY(14px); }
}
/* Full battle panel animations (scales in from centre) */
@keyframes battle-scale-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(.96); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes battle-scale-out {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to   { opacity: 0; transform: translate(-50%, -50%) scale(.96); }
}

/* Compact mode (default) */
.battle-modal.open:not(.is-full)    .battle-modal-card { animation: battle-slide-in  .25s cubic-bezier(.22,.68,0,1.18) both; }
.battle-modal.closing:not(.is-full) .battle-modal-card { animation: battle-slide-out .18s ease-in both; }
/* Full battle mode */
.battle-modal.open.is-full          .battle-modal-card { animation: battle-scale-in  .28s cubic-bezier(.22,.68,0,1.18) both; }
.battle-modal.closing.is-full       .battle-modal-card { animation: battle-scale-out .18s ease-in both; }

/* Backdrop: invisible in compact mode, dim overlay in full mode */
.battle-modal-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: auto;
}
.battle-modal.is-full .battle-modal-backdrop {
  background: rgba(0,0,0,.58);
}

/* ── Compact card (default) — small popup pinned to bottom-centre */
.battle-modal-card {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(400px, 82vw);
  max-height: 44vh;
  overflow-y: auto;
  background: rgba(10,14,18,.97);
  border: 1px solid rgba(180,200,220,.24);
  border-bottom: 2px solid rgba(180,200,220,.14);
  box-shadow: 0 10px 48px rgba(0,0,0,.8), 0 0 0 1px rgba(180,200,220,.05) inset;
  padding: .6rem 1rem .75rem;
  color: var(--paper-light);
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(80,100,120,.3) transparent;
}

/* ── Full battle panel — large centred modal */
.battle-modal.is-full .battle-modal-card {
  top: 50%;
  bottom: auto;
  transform: translate(-50%, -50%);
  width: min(820px, 92vw);
  max-height: 86vh;
  border: 1px solid rgba(180,200,220,.18);
  border-top: 2px solid rgba(200,80,80,.5);
  border-bottom: none;
  box-shadow: 0 32px 100px rgba(0,0,0,.92), 0 0 0 1px rgba(180,200,220,.06) inset;
  padding: 1.5rem 1.8rem 1.8rem;
}

/* Close button — compact */
.battle-modal-close {
  position: absolute;
  top: .4rem; right: .6rem;
  background: transparent;
  border: 0;
  color: rgba(230,232,228,.45);
  font-size: 1.25rem;
  cursor: pointer;
  padding: .2rem .45rem;
  line-height: 1;
  transition: color .15s;
}
.battle-modal-close:hover { color: rgba(230,232,228,.95); }

/* Close button — full mode */
.battle-modal.is-full .battle-modal-close {
  top: .8rem; right: 1rem;
  border: 1px solid rgba(200,200,200,.15);
  font-size: 1.1rem;
  padding: .22rem .6rem;
  border-radius: 2px;
  transition: color .15s, border-color .15s, background .15s;
}
.battle-modal.is-full .battle-modal-close:hover {
  border-color: rgba(200,200,200,.4);
  background: rgba(255,255,255,.05);
}

/* Eyebrow — compact */
.battle-modal-eyebrow {
  font-size: .52rem;
  letter-spacing: .45em;
  color: rgba(200,80,80,.85);
  margin-bottom: .2rem;
  text-transform: uppercase;
}
/* Eyebrow — full */
.battle-modal.is-full .battle-modal-eyebrow {
  font-size: .6rem;
  letter-spacing: .55em;
  margin-bottom: .35rem;
}

/* Title — compact */
.battle-modal-title {
  font-family: 'Stardos Stencil', 'Special Elite', monospace;
  font-size: 1.05rem;
  letter-spacing: .1em;
  margin: 0 0 .35rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid rgba(180,200,220,.18);
}
/* Title — full */
.battle-modal.is-full .battle-modal-title {
  font-size: 1.6rem;
  letter-spacing: .07em;
  margin: 0 0 1.1rem;
  padding-bottom: .55rem;
  border-bottom-color: rgba(180,200,220,.14);
}

/* Body — compact */
.battle-modal-body {
  font-family: 'Special Elite', monospace;
  font-size: .76rem;
  line-height: 1.45;
}
/* Body — full */
.battle-modal.is-full .battle-modal-body {
  font-size: .87rem;
  line-height: 1.55;
}

/* ── Scoreboard ─────────────────────────────────────────────── */
.battle-scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  background: rgba(0,0,0,.38);
  border: 1px solid rgba(180,200,220,.1);
  border-radius: 3px;
  padding: 1.1rem 1.4rem;
  margin-bottom: 1.3rem;
}

.bs-side { text-align: center; }

.bs-label {
  font-size: .52rem;
  letter-spacing: .52em;
  text-transform: uppercase;
  opacity: .55;
  margin-bottom: .45rem;
}

.bs-score {
  font-family: 'Stardos Stencil', monospace;
  font-size: 2.6rem;
  line-height: 1;
  margin-bottom: .2rem;
}

.bs-sublabel {
  font-size: .48rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  opacity: .38;
}

.bs-atk .bs-score { color: rgba(255,190,75,.95); }
.bs-def .bs-score { color: rgba(100,175,245,.95); }

.bs-outcome {
  padding: .65rem 1rem;
  border: 2px solid;
  border-radius: 2px;
  font-family: 'Stardos Stencil', monospace;
  font-size: .8rem;
  letter-spacing: .12em;
  text-align: center;
  line-height: 1.5;
  white-space: nowrap;
}
.bs-outcome.win  {
  color: rgba(122,201,106,.95);
  border-color: rgba(122,201,106,.35);
  background: rgba(122,201,106,.07);
}
.bs-outcome.loss {
  color: rgba(210,74,58,.95);
  border-color: rgba(210,74,58,.35);
  background: rgba(210,74,58,.07);
}

/* ── Dice rounds table colouring ─────────────────────────────── */
.battle-table--rounds .td-atk { color: rgba(255,190,75,.92); }
.battle-table--rounds .td-def { color: rgba(100,175,245,.92); }
.battle-table--rounds .th-atk { color: rgba(255,190,75,.55) !important; }
.battle-table--rounds .th-def { color: rgba(100,175,245,.55) !important; }

/* ── Side-by-side unit grid ──────────────────────────────────── */
.battle-units-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
  margin-top: .9rem;
}

.battle-section--atk { color: rgba(255,190,75,.88) !important; }
.battle-section--def { color: rgba(100,175,245,.88) !important; }

.hp-loss-badge {
  font-family: 'Special Elite', monospace;
  font-size: .72em;
  letter-spacing: .05em;
  opacity: .65;
  font-weight: normal;
  text-transform: none;
}

/* ── HP bar ──────────────────────────────────────────────────── */
.hp-change {
  font-size: .82em;
  opacity: .88;
  letter-spacing: .03em;
}

.hp-bar-wrap {
  background: rgba(255,255,255,.08);
  border-radius: 2px;
  height: 3px;
  margin-top: 5px;
  overflow: hidden;
}

.hp-bar-fill { height: 100%; border-radius: 2px; }
.hp-bar-fill.survived  { background: rgba(122,201,106,.78); }
.hp-bar-fill.damaged   { background: rgba(255,165,40,.78); }
.hp-bar-fill.destroyed { background: rgba(210,74,58,.55); }

.status-destroyed {
  color: rgba(210,74,58,.92);
  font-size: .82em;
  letter-spacing: .06em;
}
.status-ok {
  color: rgba(122,201,106,.85);
  font-size: .82em;
}

/* ── Battle sequence (animated round-by-round reveal) ───────── */

.battle-seq { display: none; }

.bseq-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: .6rem 0 .5rem;
}
.bseq-hside { text-align: center; }
.bseq-h-label {
  font-size: .68rem;
  letter-spacing: .42em;
  text-transform: uppercase;
  opacity: .65;
  margin-bottom: .3rem;
}
.bseq-h-score {
  font-family: 'Stardos Stencil', monospace;
  font-size: 2.6rem;
  line-height: 1;
  letter-spacing: .02em;
  min-width: 5ch;
}
.bseq-hside--atk .bseq-h-score { color: rgba(255,190,75,.95); }
.bseq-hside--def .bseq-h-score { color: rgba(100,175,245,.95); }

@keyframes bseq-score-pulse {
  0%   { opacity: 1; }
  25%  { opacity: .35; }
  100% { opacity: 1; }
}
.bseq-flash { animation: bseq-score-pulse .38s ease both; }

.bseq-hcenter { text-align: center; }
.bseq-badge {
  font-size: .68rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: rgba(200,200,200,.62);
  white-space: nowrap;
}
.bseq-lead {
  font-size: .66rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  margin-top: .3rem;
  font-style: normal;
}
.bseq-lead--atk { color: rgba(255,190,75,.7); }
.bseq-lead--def { color: rgba(100,175,245,.7); }
.bseq-lead--even { color: rgba(200,200,200,.38); }

.bseq-hrule {
  height: 1px;
  background: rgba(180,200,220,.1);
  margin: .3rem 0 .7rem;
}

/* Round rows */
.bseq-rounds {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.bseq-round {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .26s ease, transform .26s ease;
  border: 1px solid rgba(180,200,220,.08);
  border-radius: 2px;
  padding: .5rem .75rem .38rem;
  background: rgba(0,0,0,.18);
}
.bseq-round--in { opacity: 1; transform: none; }

.bseq-round-body {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto 1fr;
  align-items: center;
  gap: .65rem;
}
.bseq-rnum {
  font-size: .7rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .55;
  white-space: nowrap;
}
.bseq-rdice {
  display: flex;
  align-items: center;
  gap: .4rem;
  opacity: .52;
  transition: opacity .2s;
}
.bseq-rdice--won { opacity: 1; }
.bseq-rdice--atk {
  justify-content: flex-end;
  color: rgba(255,190,75,.85);
}
.bseq-rdice--def {
  justify-content: flex-start;
  color: rgba(100,175,245,.85);
}
.bseq-rdice--atk.bseq-rdice--won { color: rgba(255,205,95,.98); }
.bseq-rdice--def.bseq-rdice--won { color: rgba(120,195,255,.98); }
.bseq-die {
  font-size: 1.45rem;
  line-height: 1;
}
.bseq-rscore {
  font-family: 'Stardos Stencil', monospace;
  font-size: 1.1rem;
  letter-spacing: .02em;
}
.bseq-rtick {
  font-size: .68rem;
  letter-spacing: .1em;
  text-align: center;
  white-space: nowrap;
  padding: .14rem .52rem;
  border-radius: 2px;
}
.bseq-rtick--atk {
  color: rgba(255,190,75,.92);
  background: rgba(255,190,75,.1);
  border: 1px solid rgba(255,190,75,.22);
}
.bseq-rtick--def {
  color: rgba(100,175,245,.92);
  background: rgba(100,175,245,.1);
  border: 1px solid rgba(100,175,245,.22);
}
/* Air strike tick — ✈ PASS (amber) and ▲ AA (red) variants */
.bseq-rtick--air {
  color: rgba(255,200,80,.98);
  background: rgba(255,180,50,.12);
  border: 1px solid rgba(255,190,70,.32);
}
.bseq-rtick--aa {
  color: rgba(220,90,80,.95);
  background: rgba(210,70,60,.1);
  border: 1px solid rgba(210,80,70,.28);
}
/* Momentum tick — brighter gold with subtle pulse */
@keyframes bseq-momentum-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,210,60,.0); }
  50%       { box-shadow: 0 0 6px 2px rgba(255,210,60,.35); }
}
.bseq-rtick--momentum {
  color: rgba(255,218,55,1) !important;
  background: rgba(255,200,40,.18) !important;
  border-color: rgba(255,210,60,.55) !important;
  animation: bseq-momentum-pulse 1.1s ease infinite;
}
/* Critical hit badge — compact red-orange pill */
.bseq-crit-badge {
  font-family: 'Special Elite', monospace;
  font-size: .52rem;
  letter-spacing: .14em;
  color: rgba(255,110,50,.98);
  background: rgba(255,90,30,.14);
  border: 1px solid rgba(255,110,50,.4);
  border-radius: 2px;
  padding: .08rem .3rem;
  line-height: 1;
  vertical-align: middle;
}
/* Crit die glow */
.bseq-rdice--crit .bseq-die {
  text-shadow: 0 0 8px rgba(255,130,50,.7);
}
/* Battle event banner */
.bseq-event-banner {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-wrap: wrap;
  margin: .45rem 0 0;
  padding: .38rem .7rem;
  background: rgba(255,200,80,.06);
  border: 1px solid rgba(255,190,60,.2);
  border-radius: 2px;
}
.bseq-event-label {
  font-family: 'Special Elite', monospace;
  font-size: .6rem;
  letter-spacing: .28em;
  color: rgba(255,190,60,.7);
  text-transform: uppercase;
  white-space: nowrap;
}
.bseq-event-name {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: .88rem;
  color: rgba(240,220,150,.9);
  white-space: nowrap;
}
.bseq-event-desc {
  font-family: 'Special Elite', monospace;
  font-size: .6rem;
  letter-spacing: .08em;
  color: rgba(220,200,130,.55);
  margin-left: auto;
}
.bseq-terrain-banner {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  flex-wrap: wrap;
  margin: .45rem 0 0;
  padding: .38rem .7rem;
  background: rgba(80,160,100,.07);
  border: 1px solid rgba(90,180,110,.22);
  border-radius: 2px;
}
.bseq-terrain-label {
  font-family: 'Special Elite', monospace;
  font-size: .6rem;
  letter-spacing: .28em;
  color: rgba(100,200,130,.7);
  text-transform: uppercase;
  white-space: nowrap;
}
.bseq-terrain-name {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: .88rem;
  color: rgba(160,230,180,.9);
  white-space: nowrap;
}
.bseq-terrain-desc {
  font-family: 'Special Elite', monospace;
  font-size: .6rem;
  letter-spacing: .08em;
  color: rgba(140,210,160,.55);
  margin-left: auto;
}
.bseq-rnarr {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: .9rem;
  color: rgba(210,218,228,.78);
  margin-top: .3rem;
  padding-top: .28rem;
  border-top: 1px solid rgba(180,200,220,.1);
  line-height: 1.45;
}

/* Skip button */
.bseq-skip-wrap {
  text-align: center;
  padding: .65rem 0 .25rem;
}
.bseq-skip-btn {
  background: transparent;
  border: 1px solid rgba(200,200,200,.22);
  color: rgba(200,200,200,.55);
  font-family: 'Special Elite', monospace;
  font-size: .72rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  padding: .3rem 1rem;
  cursor: pointer;
  border-radius: 2px;
  transition: color .15s, border-color .15s, background .15s;
}
.bseq-skip-btn:hover {
  color: rgba(200,200,200,.82);
  border-color: rgba(200,200,200,.32);
  background: rgba(255,255,255,.04);
}

/* Close button (shown after outcome) */
.bseq-close-wrap {
  text-align: center;
  padding: 1.1rem 0 .3rem;
}
.bseq-close-btn {
  background: transparent;
  border: 1px solid rgba(200,200,200,.28);
  color: rgba(220,225,232,.75);
  font-family: 'Special Elite', monospace;
  font-size: .78rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  padding: .42rem 2.2rem;
  cursor: pointer;
  border-radius: 2px;
  transition: color .15s, border-color .15s, background .15s;
}
.bseq-close-btn:hover {
  color: rgba(240,242,245,1);
  border-color: rgba(200,200,200,.55);
  background: rgba(255,255,255,.06);
}
.bseq-close-btn:active {
  background: rgba(255,255,255,.1);
}

/* Outcome section */
.bseq-outcome {
  opacity: 0;
  transform: scale(.97);
  transition: opacity .42s ease, transform .42s ease;
}
.bseq-outcome[hidden] { display: none !important; }
.bseq-outcome--in { opacity: 1; transform: none; }

.bseq-outcome-rule {
  height: 1px;
  background: rgba(180,200,220,.14);
  margin: .85rem 0 .8rem;
}
.bseq-verdict {
  font-family: 'Stardos Stencil', monospace;
  font-size: 1.2rem;
  letter-spacing: .14em;
  text-align: center;
  padding: .5rem 1.4rem;
  border-width: 2px;
  border-style: solid;
  border-radius: 2px;
  margin: 0 auto .65rem;
  display: flex;
  justify-content: center;
}
.bseq-verdict--win {
  color: rgba(122,201,106,.95);
  border-color: rgba(122,201,106,.35);
  background: rgba(122,201,106,.07);
}
.bseq-verdict--loss {
  color: rgba(210,74,58,.95);
  border-color: rgba(210,74,58,.35);
  background: rgba(210,74,58,.07);
}
.bseq-outcome-narr {
  font-family: 'IM Fell English', serif;
  font-style: italic;
  font-size: 1rem;
  text-align: center;
  color: rgba(210,218,228,.82);
  margin: 0 0 .7rem;
  line-height: 1.55;
}

/* ── Summary block (simple result kinds) & note ──────────────── */
.battle-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .35rem 1.2rem;
  margin-bottom: .9rem;
  font-size: .9rem;
}
.battle-summary > div:nth-child(3) { grid-column: 1 / -1; color: rgba(230,232,228,.92); }

.battle-note {
  background: rgba(120,200,255,.07);
  border-left: 3px solid rgba(120,200,255,.42);
  border-radius: 0 2px 2px 0;
  padding: .55rem .85rem;
  margin: .5rem 0 1rem;
  font-size: .83rem;
  color: rgba(200,225,250,.88);
}

/* ── Section headers ─────────────────────────────────────────── */
.battle-section {
  font-size: .57rem;
  letter-spacing: .42em;
  color: rgba(200,80,80,.85);
  margin: .9rem 0 .45rem;
  text-transform: uppercase;
}

/* ── Tables ──────────────────────────────────────────────────── */
.battle-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  margin-bottom: .35rem;
}

.battle-table th, .battle-table td {
  padding: .32rem .55rem;
  border-bottom: 1px solid rgba(180,200,220,.1);
  text-align: left;
}

.battle-table th {
  font-size: .57rem;
  letter-spacing: .22em;
  color: rgba(180,200,220,.58);
  text-transform: uppercase;
  border-bottom: 1px solid rgba(180,200,220,.22);
  padding-bottom: .42rem;
}

.battle-table td { color: rgba(230,232,228,.88); }

.battle-table tbody tr:hover { background: rgba(255,255,255,.025); }

.battle-table td:nth-child(n+2) { text-align: center; }
.battle-table th:nth-child(n+2) { text-align: center; }

/* In the units table, HP column stays left-aligned (has a bar) */
.battle-table--units td:nth-child(2),
.battle-table--units th:nth-child(2) { text-align: left; }


/* ═══════════════════════════════════════════════════════════════
   Settings → Dev Options
   Out-of-band controls inside the Settings screen. Same paper /
   typewriter aesthetic as the rest, with a red-stamp accent so
   the developer eye spots them at a glance.
   ═══════════════════════════════════════════════════════════════ */

.settings-group--dev {
  border-color: var(--red-stamp);
  background: rgba(122,31,31,.05);
  position: relative;
}

.settings-group--dev::before {
  content: "DEV";
  position: absolute;
  top: -.55rem;
  right: 1rem;
  background: var(--paper);
  padding: 0 .6rem;
  font-family: 'Stardos Stencil', 'Impact', sans-serif;
  font-size: .65rem;
  letter-spacing: .35em;
  color: var(--red-stamp);
  border: 1px solid var(--red-stamp);
}

.settings-group-label.dev-label {
  color: var(--red-stamp);
  border-bottom-color: rgba(122,31,31,.35);
}

.dev-row {
  flex-direction: column;
  align-items: flex-start;
  gap: .25rem;
  padding-top: 0;
}

.dev-hint {
  font-family: 'IM Fell English', 'Times New Roman', serif;
  font-style: italic;
  font-size: .85rem;
  letter-spacing: .04em;
  color: var(--ink-soft);
  opacity: .75;
}

.dev-ending-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .5rem;
  margin-top: .8rem;
}

.dev-btn {
  font-family: inherit;
  background: transparent;
  border: 1px solid var(--ink-soft);
  border-left: 4px solid var(--accent, var(--ink));
  color: var(--ink);
  padding: .65rem .9rem;
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: .8rem;
  row-gap: .15rem;
  align-items: center;
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
  outline: none;
  position: relative;
}

.dev-btn:hover,
.dev-btn:focus-visible {
  background: rgba(10,12,14,.06);
  transform: translateX(3px);
  box-shadow: 3px 3px 0 rgba(8,12,14,.25);
}

.dev-btn-tab {
  grid-column: 1;
  grid-row: 1;
  font-family: 'Special Elite', monospace;
  font-size: .65rem;
  letter-spacing: .35em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.dev-btn-name {
  grid-column: 1;
  grid-row: 2;
  font-family: 'Stardos Stencil', 'Impact', sans-serif;
  font-size: 1.1rem;
  letter-spacing: .12em;
  color: var(--ink);
}

.dev-btn-go {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-family: 'Special Elite', monospace;
  font-size: .7rem;
  letter-spacing: .3em;
  color: var(--accent, var(--ink));
  opacity: .7;
  align-self: center;
}

.dev-btn:hover .dev-btn-go,
.dev-btn:focus-visible .dev-btn-go { opacity: 1; }

/* Section header inside Dev Options. Splits the grid into VICTORY /
   DEFEAT bands so it's obvious which kind of ending is being triggered. */
.dev-ending-section {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  margin-top: .8rem;
}

.dev-section-label {
  display: flex;
  align-items: baseline;
  gap: .8rem;
  margin-top: .35rem;
  margin-bottom: .1rem;
}

.dev-section-tag {
  font-family: 'Stardos Stencil', 'Impact', sans-serif;
  font-size: .75rem;
  letter-spacing: .35em;
  padding: .2rem .55rem;
  border: 1px solid currentColor;
  text-transform: uppercase;
}

.dev-section-tag--victory { color: #1f6e3a; border-color: #1f6e3a; }
.dev-section-tag--defeat  { color: var(--red-stamp); border-color: var(--red-stamp); }

.dev-section-hint {
  font-family: 'IM Fell English', 'Times New Roman', serif;
  font-style: italic;
  font-size: .8rem;
  color: var(--ink-soft);
  opacity: .7;
}

/* Defeat dev buttons: muted card, dashed accent rail, "DEFEAT" badge
   stamped on top so you can't confuse them with the victory row. */
.dev-btn--defeat {
  background: rgba(122,31,31,.04);
  border-style: solid;
  border-color: rgba(122,31,31,.4);
  border-left-style: dashed;
  border-left-color: var(--accent, var(--red-stamp));
  position: relative;
}

.dev-btn--defeat::after {
  content: "DEFEAT";
  position: absolute;
  top: -.5rem;
  right: .55rem;
  font-family: 'Stardos Stencil', 'Impact', sans-serif;
  font-size: .55rem;
  letter-spacing: .25em;
  background: var(--paper);
  padding: 0 .35rem;
  color: var(--red-stamp);
  border: 1px solid var(--red-stamp);
  pointer-events: none;
}

.dev-btn--defeat:hover,
.dev-btn--defeat:focus-visible {
  background: rgba(122,31,31,.10);
  border-left-style: solid;
}

.dev-btn--defeat .dev-btn-name { color: var(--red-stamp); }
.dev-btn--defeat .dev-btn-go   { color: var(--red-stamp); }

/* ═══════════════════════════════════════════════════════════════
   Faction ending — cinematic slide-through

   Layout uses flex-start (NOT center) so long ending content
   scrolls naturally from the top instead of getting clipped at
   the dossier header. Vertical breathing room is provided by
   gap + padding, and the slide card caps width at 820px.

   Cinematic flow on entry:
     1. Fullscreen black curtain (instant) hides the screen swap.
     2. After ~380ms hold, curtain fades out over 1.5s.
     3. Header / title / card / progress / footer reveal with
        staggered keyframe animations driven by .is-cinematic-on.
     4. Subsequent slide changes only re-fade the card via
        .ending-card.is-fresh — header stays put.
   ═══════════════════════════════════════════════════════════════ */

.ending-main {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: .9rem 3rem .35rem;
  gap: .7rem;
  text-align: center;
  overflow: hidden;
  position: relative;
  z-index: 5;
}

.ending-main::before,
.ending-main::after { display: none; }

/* Grand title is the chapter heading — shown only on the intro
   (slide 0). On subsequent slides we hide it to give the slide
   card the room it needs. */
.ending-title-block {
  text-align: center;
  padding-bottom: .35rem;
  border-bottom: 1px solid rgba(10,12,14,.18);
  width: min(820px, 90vw);
  flex-shrink: 0;
}

#screen-ending:not(.is-intro) .ending-title-block {
  display: none;
}

.ending-eyebrow-top {
  font-size: .7rem;
  letter-spacing: .55em;
  color: var(--ink-soft);
  opacity: .6;
  margin-bottom: .35rem;
  text-transform: uppercase;
}

.ending-title-grand {
  font-family: 'Stardos Stencil', 'Impact', sans-serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 3.4vw, 2.6rem);
  letter-spacing: .22em;
  padding-left: .22em;
  color: var(--ink);
  line-height: 1.1;
  text-shadow:
    -1px 0 rgba(170,50,50,.20),
     1px 0 rgba(50,170,200,.20),
     1px 1px 0 rgba(0,0,0,.22);
}

.ending-card {
  width: min(820px, 90vw);
  background: rgba(10,12,14,.04);
  border-left: 4px solid var(--ending-accent, var(--ink));
  border-right: 1px solid var(--ink-soft);
  padding: 1rem 2.1rem 0.9rem;
  position: relative;
  text-align: left;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ending-card::before,
.ending-card::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -1px;
  height: 1px;
  background: var(--ink-soft);
}
.ending-card::before { top: -1px; }
.ending-card::after  { bottom: -1px; }

.ending-eyebrow {
  font-family: 'Special Elite', monospace;
  font-size: .75rem;
  letter-spacing: .42em;
  color: var(--ending-accent, var(--ink-soft));
  margin-bottom: .45rem;
  text-transform: uppercase;
  opacity: .85;
  flex-shrink: 0;
}

.ending-title {
  font-family: 'Stardos Stencil', 'Impact', sans-serif;
  font-weight: 700;
  font-size: clamp(1.3rem, 2.6vw, 1.95rem);
  letter-spacing: .18em;
  padding-left: .18em;
  color: var(--ink);
  margin-bottom: .5rem;
  line-height: 1.1;
  flex-shrink: 0;
}

.ending-body {
  font-family: 'IM Fell English', 'Times New Roman', serif;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  text-shadow: 0 0 1px rgba(0,0,0,.04);
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.ending-body p + p {
  margin-top: .6rem;
  text-indent: 1.4em;
}

.ending-progress {
  width: min(540px, 70vw);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.ending-progress-track {
  flex: 1;
  height: 4px;
  background: rgba(10,12,14,.18);
  border: 1px solid var(--ink-soft);
  position: relative;
  overflow: hidden;
}

.ending-progress-fill {
  position: absolute;
  inset: 0 100% 0 0;
  background: var(--ending-accent, var(--ink));
  transition: right .55s cubic-bezier(.22,.95,.35,1);
}

.ending-progress-text {
  font-family: 'Special Elite', monospace;
  font-size: .7rem;
  letter-spacing: .3em;
  color: var(--ink-soft);
  min-width: 4rem;
  text-align: right;
}

.ending-footer {
  position: relative;
  z-index: 10;
}

/* Stamp pulses faintly to mimic a CRT glow.
   Color is overridden via the --ending-accent CSS var. */
#ending-stamp {
  border-color: var(--ending-accent, var(--red-stamp));
  color: var(--ending-accent, var(--red-stamp));
  animation: ending-stamp-pulse 4.6s ease-in-out infinite;
}

@keyframes ending-stamp-pulse {
  0%,100% { opacity: .78; }
  50%     { opacity: 1;   }
}

/* ── Defeat: desaturace + vignetta ───────────────────────────
   Prohra je vizuálně odlišená — šedivá, tmavá, sevřená. */
#screen-ending.is-defeat {
  filter: saturate(0.28) brightness(0.84);
  box-shadow: inset 0 0 140px rgba(0,0,0,0.6);
  transition: filter 0s, box-shadow 0s;
}

/* ── Cinematic curtain ────────────────────────────────────────
   Full-screen black overlay sitting above the scanlines (z-index
   50) and below context menus (200+). Inline opacity + transition
   are written by script.js for tight cinematic timing. */
.ending-curtain {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 180;
  pointer-events: none;
  opacity: 0;
}

.ending-curtain.is-on { pointer-events: auto; }

/* ── Staggered reveal — fires once when curtain begins fading.
   Each element bobs up with a soft blur, mimicking a slow lens
   pulling into focus. */
@keyframes ending-reveal-up {
  0%   { opacity: 0; transform: translateY(18px); filter: blur(3px); }
  60%  { filter: blur(0); }
  100% { opacity: 1; transform: translateY(0); filter: blur(0); }
}

#screen-ending.is-cinematic-on .dossier-meta,
#screen-ending.is-cinematic-on .ending-title-block,
#screen-ending.is-cinematic-on .ending-card,
#screen-ending.is-cinematic-on .ending-progress,
#screen-ending.is-cinematic-on .ending-footer {
  animation: ending-reveal-up 1.1s cubic-bezier(.22,.95,.35,1) both;
}

#screen-ending.is-cinematic-on .dossier-meta       { animation-delay: 0.20s; }
#screen-ending.is-cinematic-on .ending-footer      { animation-delay: 0.55s; }
#screen-ending.is-cinematic-on .ending-title-block {
  animation-delay: 0.50s;
  animation-duration: 1.5s;
}
#screen-ending.is-cinematic-on .ending-card        { animation-delay: 1.00s; }
#screen-ending.is-cinematic-on .ending-progress    { animation-delay: 1.45s; }

/* ── Stamp: victory razítko sletí shora a dopadne, defeat těžce klesne ── */
@keyframes stamp-impact {
  0%   { opacity: 0; transform: translateY(-50px) rotate(-2deg) scale(1.3); filter: blur(5px); }
  52%  { opacity: 1; transform: translateY(6px) rotate(0.4deg) scale(0.95);  filter: blur(0); }
  68%  { transform: translateY(-4px) scale(1.03); }
  82%  { transform: translateY(2px)  scale(0.99); }
  100% { transform: translateY(0)    scale(1); }
}

@keyframes stamp-defeat {
  0%   { opacity: 0; transform: translateY(-28px) scale(1.12); filter: blur(4px); }
  65%  { opacity: 1; transform: translateY(4px) scale(0.97);   filter: blur(0); }
  100% { transform: translateY(0) scale(1); }
}

#screen-ending.is-cinematic-on:not(.is-defeat) #ending-stamp {
  animation: stamp-impact 0.82s cubic-bezier(.22,.95,.35,1) 0.05s both;
}
#screen-ending.is-cinematic-on.is-defeat #ending-stamp {
  animation: stamp-defeat 1.1s cubic-bezier(.4,0,.55,1) 0.05s both;
}

/* ── Defeat: elementy klesají dolů (z výšky), ne stoupají ── */
@keyframes ending-reveal-down {
  0%   { opacity: 0; transform: translateY(-16px); filter: blur(3px); }
  60%  { filter: blur(0); }
  100% { opacity: 1; transform: translateY(0); filter: blur(0); }
}

#screen-ending.is-cinematic-on.is-defeat .dossier-meta,
#screen-ending.is-cinematic-on.is-defeat .ending-title-block,
#screen-ending.is-cinematic-on.is-defeat .ending-card,
#screen-ending.is-cinematic-on.is-defeat .ending-progress,
#screen-ending.is-cinematic-on.is-defeat .ending-footer {
  animation-name: ending-reveal-down;
}

/* Per-slide card replace. Used when advancing slides 1..N — the
   header / footer stay put, only the slide card refreshes. */
@keyframes ending-card-replace {
  0%   { opacity: 0; transform: translateY(10px); filter: blur(1.5px); }
  100% { opacity: 1; transform: translateY(0);    filter: blur(0); }
}

@keyframes ending-card-replace-down {
  0%   { opacity: 0; transform: translateY(-8px); filter: blur(1.5px); }
  100% { opacity: 1; transform: translateY(0);    filter: blur(0); }
}

.ending-card.is-fresh {
  animation: ending-card-replace .65s cubic-bezier(.22,.95,.35,1) both;
}

#screen-ending.is-defeat .ending-card.is-fresh {
  animation-name: ending-card-replace-down;
}

/* ── Typewriter cursor ───────────────────────────────────────
   Added/removed via JS on eyebrow + title during slide reveal. */
@keyframes tw-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
.tw-cursor::after {
  content: '_';
  animation: tw-blink 0.65s step-end infinite;
}

/* ── Armistice pre-card ──────────────────────────────────────
   Full-overlay dramatic beat that covers .ending-main for ~3s
   before the slide text is revealed. Dismissed by JS via inline
   opacity + transition after the stagger animations settle. */
.ending-armistice {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-bg, #13110d);
  opacity: 0;
  pointer-events: none;
  /* opacity driven entirely by JS — no CSS transition here */
}

.armistice-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  text-align: center;
  padding: 2rem;
}

@keyframes armistice-item-up {
  0%   { opacity: 0; transform: translateY(16px); filter: blur(3px); }
  100% { opacity: 1; transform: translateY(0);    filter: blur(0); }
}

.armistice-stamp-echo {
  font-family: 'Stardos Stencil', serif;
  font-size: clamp(2.8rem, 8vw, 5.5rem);
  letter-spacing: 0.35em;
  color: var(--ending-accent, #7a1f1f);
  line-height: 1;
  animation: armistice-item-up 1s cubic-bezier(.22,.95,.35,1) 0.5s both;
}

.armistice-rule {
  width: 8rem;
  height: 1px;
  background: var(--ending-accent, #7a1f1f);
  opacity: 0.45;
  animation: armistice-item-up 1s cubic-bezier(.22,.95,.35,1) 0.9s both;
}

.armistice-date {
  font-family: 'Special Elite', monospace;
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  letter-spacing: 0.28em;
  color: var(--paper-text, #c8bc9e);
  opacity: 0.75;
  animation: armistice-item-up 1s cubic-bezier(.22,.95,.35,1) 1.1s both;
}

.armistice-faction {
  font-family: 'Special Elite', monospace;
  font-size: clamp(0.65rem, 1.5vw, 0.8rem);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  color: var(--ending-accent, #7a1f1f);
  opacity: 0.5;
  animation: armistice-item-up 1s cubic-bezier(.22,.95,.35,1) 1.35s both;
}

/* ── Lore screen ────────────────────────────────────────────── */

.lore-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .4rem 3rem 1rem;
  gap: .55rem;
  overflow: hidden;
}

/* Override shared settings-title margin when it appears inside lore-main */
.lore-main .settings-title {
  margin-top: 0;
}
.lore-main .settings-rule {
  margin-bottom: .75rem;
}

.lore-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  justify-content: center;
  margin-top: .25rem;
  margin-bottom: .35rem;
}

.lore-tab {
  font-family: 'Special Elite', monospace;
  font-size: .82rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  background: transparent;
  border: 2px solid var(--ink-faded);
  color: var(--ink-faded);
  padding: .55rem 1.2rem;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.lore-tab:hover {
  background: rgba(10,12,14,0.06);
  color: var(--ink);
  border-color: var(--ink);
}

.lore-tab.is-active {
  background: var(--ink);
  color: var(--paper-light);
  border-color: var(--ink);
}

.lore-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1rem;
  width: min(1100px, 96vw);
  height: 100%;
  min-height: 0;     /* let inner panes scroll */
  flex: 1;
}

/* List pane (left) — scrollable list of entries grouped by category. */
.lore-list {
  border: 1px solid var(--ink-faded);
  background: rgba(10,12,14,0.04);
  overflow-y: auto;
  padding: .55rem .55rem .9rem;
  font-family: 'Special Elite', monospace;
  scrollbar-width: thin;
}

.lore-list-group-label {
  font-size: .58rem;
  letter-spacing: .35em;
  text-transform: uppercase;
  color: var(--red-stamp);
  padding: .9rem .4rem .25rem;
}
.lore-list-group-label:first-child { padding-top: .25rem; }

.lore-list-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: .85rem;
  padding: .35rem .55rem;
  margin: .1rem 0;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.lore-list-item:hover {
  background: rgba(10,12,14,.07);
  border-color: var(--ink-faded);
}
.lore-list-item.is-active {
  background: var(--ink);
  color: var(--paper-light);
  border-color: var(--ink);
}

.lore-list-empty {
  padding: 1rem;
  font-style: italic;
  color: var(--ink-faded);
  text-align: center;
}

/* Detail pane (right) — full-width text dossier for the selected entry. */
.lore-detail {
  border: 1px solid var(--ink-faded);
  background: rgba(10,12,14,0.04);
  overflow-y: auto;
  padding: 1.4rem 1.8rem 2rem;
  scrollbar-width: thin;
}

.lore-detail-empty {
  font-style: italic;
  color: var(--ink-faded);
  text-align: center;
  padding: 2rem 1rem;
}

.lore-detail-eyebrow {
  font-size: .62rem;
  letter-spacing: .42em;
  text-transform: uppercase;
  color: var(--red-stamp);
  margin-bottom: .35rem;
}

.lore-detail-title {
  font-family: 'Stardos Stencil', 'Courier New', monospace;
  font-size: 1.85rem;
  letter-spacing: .12em;
  color: var(--ink);
  margin: 0 0 .2rem;
  line-height: 1.1;
}

.lore-detail-subtitle {
  font-family: 'Special Elite', monospace;
  font-size: .85rem;
  letter-spacing: .12em;
  color: var(--ink-faded);
  margin-bottom: 1rem;
}

.lore-detail-stats {
  font-family: 'Special Elite', monospace;
  font-size: .8rem;
  letter-spacing: .06em;
  color: var(--ink-soft);
  background: rgba(10,12,14,.06);
  border-left: 3px solid var(--red-stamp);
  padding: .55rem .8rem;
  margin: .25rem 0 1rem;
  font-variant-numeric: tabular-nums;
}

.lore-detail-body {
  font-family: 'IM Fell English', 'Special Elite', serif;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--ink);
}
.lore-detail-body p { margin: 0 0 .85rem; }
.lore-detail-body p:last-child { margin-bottom: 0; }

.lore-city-image {
  margin-top: 1.6rem;
  border-top: 1px solid var(--border, rgba(180,160,120,0.25));
  padding-top: 1.2rem;
}
.lore-city-image-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(140,120,80,0.30);
  filter: sepia(0.12) contrast(1.04);
}
.lore-city-image-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(140,120,80,0.06) 0px,
      rgba(140,120,80,0.06) 1px,
      transparent 1px,
      transparent 8px
    ),
    rgba(30,28,24,0.55);
  border: 1px solid rgba(140,120,80,0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.lore-city-image-placeholder::before,
.lore-city-image-placeholder::after {
  content: '';
  position: absolute;
  border: 1px solid rgba(140,120,80,0.20);
  inset: 6px;
  pointer-events: none;
}
.lore-city-image-placeholder::after {
  inset: 10px;
  border-style: dashed;
  border-color: rgba(140,120,80,0.12);
}
.lore-city-image-label {
  font-family: 'Special Elite', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.10em;
  color: rgba(180,160,110,0.55);
  text-transform: uppercase;
  text-align: center;
  padding: 0 1rem;
  pointer-events: none;
  user-select: none;
}

@media (max-width: 720px) {
  .lore-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(160px, 30vh) 1fr;
  }
  .lore-detail-title { font-size: 1.5rem; }
}

/* ── Loading screen ──────────────────────────────────────────── */

.loading-screen {
  background: #060809;
  overflow: hidden;
}

/* Background photograph — fades in once loaded */
.loading-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  filter: sepia(0.35) grayscale(0.55) brightness(0.52);
  transition: opacity 0.4s ease;
}
.loading-photo.ls-ready { opacity: 1; }

/* Gradient veil so text is always legible */
.loading-overlay {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.6rem 2.6rem 1.4rem;
  background:
    linear-gradient(to bottom, rgba(6,8,9,.78) 0%,    transparent 22%),
    linear-gradient(to top,    rgba(6,8,9,.88) 0%,    transparent 45%),
    radial-gradient(ellipse 78% 72% at 50% 50%, transparent 30%, rgba(6,8,9,.72) 100%);
}

.loading-top {
  display: flex;
  justify-content: flex-end;
}

.loading-stamp {
  font-family: 'Stardos Stencil', 'Impact', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .22em;
  padding: .22rem .72rem;
  border: 3px double var(--red-stamp);
  color: var(--red-stamp);
  opacity: .72;
  transform: rotate(3deg);
  display: inline-block;
}

/* Quote block — vertically centred in the lower half */
.loading-body {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 1.1rem;
}

.loading-quote {
  max-width: 54ch;
  text-align: center;
  margin: 0;
}

.loading-quote-text {
  font-family: 'IM Fell English', Georgia, serif;
  font-style: italic;
  font-size: 1.25rem;
  color: rgba(205,218,228,.9);
  line-height: 1.72;
  margin: 0 0 .75rem;
  text-shadow: 0 1px 8px rgba(0,0,0,.85);
}

.loading-quote-cite {
  display: block;
  font-family: var(--font-mono, 'Courier New', monospace);
  font-style: normal;
  font-size: .52rem;
  letter-spacing: .18em;
  color: rgba(155,180,200,.5);
  text-transform: uppercase;
}

/* Progress bar */
.loading-footer { padding-top: .6rem; }

.loading-bar-track {
  height: 1px;
  background: rgba(180,200,220,.14);
  margin-bottom: .5rem;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: rgba(180,200,220,.6);
}

.loading-label {
  font-family: var(--font-mono, 'Courier New', monospace);
  font-size: .35rem;
  letter-spacing: .35em;
  color: rgba(145,170,190,.38);
  text-align: right;
}


/* ── Language toggle buttons ─────────────────────────────────── */
.setting-control--lang {
  gap: .5rem;
}

.lang-btn {
  font-family: inherit;
  font-size: .75rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--ink-soft);
  color: var(--ink-faded);
  padding: .4rem 1rem;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.lang-btn:hover,
.lang-btn:focus-visible {
  border-color: var(--ink);
  color: var(--ink);
}

.lang-btn--active {
  background: var(--ink);
  color: var(--paper-light);
  border-color: var(--ink);
}

/* ── Newspaper overlay ──────────────────────────────────────────
   Between-turns dispatch. Fixed layout — never scrolls outer;
   only the two body columns scroll internally if content overflows.
   Feature article and footer always visible.                    */

#newspaper-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease-out;
}
#newspaper-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Newspaper — flex column so footer/feature are always anchored */
.newspaper {
  display: flex;
  flex-direction: column;
  background: #ede3c0;
  color: #1a0e00;
  border: 2px solid #2a1a00;
  max-width: 800px;
  width: 92%;
  max-height: 88vh;
  box-shadow: 0 12px 56px rgba(0,0,0,0.75), inset 0 0 80px rgba(0,0,0,0.05);
  filter: sepia(0.20);
  font-family: 'IM Fell English', serif;
  transform: translateY(56px);
  transition: transform 0.22s cubic-bezier(.22,.88,.36,1);
}
#newspaper-overlay.is-visible .newspaper {
  transform: translateY(0);
}

/* ── Masthead ─────────────────────────────────────────────────── */
.np-masthead {
  flex-shrink: 0;
  text-align: center;
  border-bottom: 3px double #2a1a00;
  padding: 0.85rem 1.5rem 0.55rem;
  background: #e3d5a0;
}
.np-title {
  font-family: 'Stardos Stencil', sans-serif;
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #1a0e00;
  line-height: 1;
}
.np-dateline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  font-family: 'Special Elite', monospace;
  font-size: 0.60rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #3a2800;
  border-top: 1px solid #2a1a00;
  margin-top: 0.28rem;
  padding-top: 0.2rem;
}
.np-motto {
  font-style: italic;
  font-family: 'IM Fell English', serif;
  font-size: 0.59rem;
  color: #5a3e10;
  text-transform: none;
  letter-spacing: 0;
  flex: 1;
  text-align: center;
}

/* ── Two-column body — takes all remaining height, columns scroll */
.np-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.np-col {
  padding: 0.7rem 1rem 0.7rem;
  border-right: 1px solid #2a1a00;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #8a6a30 transparent;
}
.np-col:last-of-type {
  border-right: none;
}
.np-col-head {
  font-family: 'Special Elite', monospace;
  font-size: 0.60rem;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: #1a0e00;
  border-bottom: 2px solid #2a1a00;
  padding-bottom: 0.22rem;
  margin-bottom: 0.55rem;
  position: sticky;
  top: 0;
  background: #ede3c0;
  z-index: 1;
}
.np-item {
  font-size: 0.82rem;
  line-height: 1.52;
  margin-bottom: 0.48rem;
  color: #1a0e00;
}
.np-item:last-child { margin-bottom: 0; }
.np-item strong { font-weight: bold; }
.np-item em     { font-style: italic; }
.np-ally {
  font-family: 'Special Elite', monospace;
  font-size: 0.60rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #5a3e10;
  display: block;
  margin-bottom: 0.1rem;
}
.np-quiet {
  font-style: italic;
  font-size: 0.79rem;
  color: #6a4e20;
  margin: 0;
}

/* AI faction declarations (leader quotes + signature-moment headlines).
   Pulled from state.aiNarrative; emitted by engine/ai.js _emitNarrative(). */
.np-decl {
  border-left: 3px solid #5a3e10;
  padding: 0.42rem 0.6rem 0.5rem;
  background: rgba(255, 240, 200, 0.45);
  margin-bottom: 0.7rem;
}
.np-decl-headline {
  font-family: 'Stardos Stencil', 'Special Elite', monospace;
  font-size: 0.86rem;
  line-height: 1.25;
  letter-spacing: 0.02em;
  color: #1a0e00;
  margin-bottom: 0.28rem;
}
.np-decl-quote {
  font-style: italic;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #2a1a00;
  margin-bottom: 0.18rem;
}
.np-decl-attrib {
  font-family: 'Special Elite', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: #5a3e10;
}
.np-decl-attrib em { font-style: italic; }

/* ── Feature article — fixed height, single column, always visible */
.np-feature {
  flex-shrink: 0;
  border-top: 3px double #2a1a00;
  padding: 0.6rem 1.1rem 0.65rem;
  background: #e6d9a5;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 1.1rem;
  align-items: start;
}
.np-feature-label {
  font-family: 'Special Elite', monospace;
  font-size: 0.56rem;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: #5a3e10;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  border-right: 1px solid #8a6a30;
  padding-right: 0.35rem;
  line-height: 1;
  align-self: stretch;
  display: flex;
  align-items: center;
}
.np-feature-content {}
.np-feature-headline {
  font-family: 'Stardos Stencil', sans-serif;
  font-size: 0.90rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #1a0e00;
  margin-bottom: 0.28rem;
  line-height: 1.2;
}
.np-feature-body {
  font-size: 0.80rem;
  line-height: 1.52;
  color: #2a1a00;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Footer ──────────────────────────────────────────────────── */
.np-footer {
  flex-shrink: 0;
  border-top: 2px solid #2a1a00;
  padding: 0.5rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #d8c990;
}
.np-footer-hint {
  font-family: 'Special Elite', monospace;
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6a4e10;
}
.np-dismiss-btn {
  font-family: 'Special Elite', monospace;
  font-size: 0.76rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: #2a1a00;
  color: #f0e5c0;
  border: 1px solid #1a0e00;
  padding: 0.38rem 1.5rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.np-dismiss-btn:hover,
.np-dismiss-btn:focus-visible {
  background: #f0e5c0;
  color: #1a0e00;
  outline: none;
}

@media (max-width: 620px) {
  .np-body { grid-template-columns: 1fr; }
  .np-col  { border-right: none; border-bottom: 1px solid #2a1a00; max-height: 30vh; }
  .np-title { font-size: 1.5rem; }
  .np-feature { grid-template-columns: 1fr; }
  .np-feature-label { display: none; }
}

/* ── Soundtrack player (bottom-left of map) ─────────────────── */

.map-music-player {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 5;
  padding: .55rem .85rem .6rem;
  background: rgba(8, 10, 12, .88);
  border: 1px solid rgba(220, 225, 230, .28);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .55);
  font-family: 'Special Elite', 'Courier New', monospace;
  color: var(--paper);
  backdrop-filter: blur(2px);
  user-select: none;
  min-width: 180px;
}

.map-music-eyebrow {
  font-size: .5rem;
  letter-spacing: .38em;
  color: rgba(220, 225, 230, .45);
  margin-bottom: .2rem;
}

.map-music-track {
  font-size: .72rem;
  letter-spacing: .08em;
  color: var(--paper-light);
  margin-bottom: .48rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.map-music-controls {
  display: flex;
  gap: .35rem;
  align-items: center;
}

.map-music-btn {
  background: rgba(220, 225, 230, .07);
  border: 1px solid rgba(220, 225, 230, .2);
  color: rgba(220, 225, 230, .8);
  font-size: .62rem;
  padding: .22rem .5rem;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  transition: background .12s ease, color .12s ease;
}

.map-music-btn:hover {
  background: rgba(220, 225, 230, .18);
  color: var(--paper-light);
}

.map-music-btn--playpause {
  padding: .22rem .75rem;
  background: rgba(220, 225, 230, .12);
  border-color: rgba(220, 225, 230, .32);
}

/* ── Intro splash overlay ─────────────────────────────────── */

#intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  /* Vignette baked into background: warm centre, dark edges */
  background: radial-gradient(ellipse 65% 65% at 50% 50%,
    #261c0f 0%, #1a1208 48%, #0c0906 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer; /* signals the overlay is clickable */
}

/* Grain — same fractal-noise SVG as the paper, screen-blended on dark bg */
.intro-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.15;
  mix-blend-mode: screen;
}

/* Centre column: wheel, wordmark, enter prompt */
.intro-center {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
}

/* Phase 1: wheel fades in statically */
.intro-wheel {
  width: 220px;
  height: 220px;
  filter: drop-shadow(0 0 28px rgba(212, 201, 139, 0.2));
  animation: intro-wheel-fadein 1s ease 0.2s forwards;
  opacity: 0;
}

/* Phase 2: spin triggered by JS adding .spinning class */
.intro-wheel.spinning {
  animation: intro-wheel-turn 3s cubic-bezier(0.37, 0, 0.63, 1) forwards;
  opacity: 1;
}

.intro-title {
  font-family: 'Cinzel', serif;
  font-size: 1.7rem;
  font-weight: 400;
  letter-spacing: 0.6em;
  padding-left: 0.6em;
  color: #d4c98b;
  opacity: 0;
  animation: intro-title-in 0.7s ease 0.9s forwards;
}

/* "CLICK TO ENTER" prompt — fades in, then pulses */
.intro-enter {
  font-family: 'Cinzel', serif;
  font-size: 0.58rem;
  letter-spacing: 0.55em;
  padding-left: 0.55em;
  color: rgba(212, 201, 139, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
  animation:
    intro-enter-in    0.8s ease          1.6s forwards,
    intro-enter-pulse 2.2s ease-in-out   2.4s infinite;
}

@keyframes intro-wheel-fadein {
  from { opacity: 0; transform: scale(0.93); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes intro-wheel-turn {
  /* Brief reverse wind-up, then main spin, then spring settle */
  0%   { transform: rotate(0deg);    animation-timing-function: ease-out; }
  8%   { transform: rotate(-6deg);   animation-timing-function: cubic-bezier(0.37, 0, 0.63, 1); }
  80%  { transform: rotate(230deg);  animation-timing-function: cubic-bezier(0.34, 1.48, 0.64, 1); }
  100% { transform: rotate(225deg); }
}

@keyframes intro-title-in {
  0%   { opacity: 0; transform: translateY(6px); }
  100% { opacity: 0.88; transform: translateY(0); }
}

@keyframes intro-enter-in {
  from { opacity: 0; }
  to   { opacity: 0.5; }
}

@keyframes intro-enter-pulse {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 0.8; }
}

@keyframes intro-overlay-out {
  to { opacity: 0; pointer-events: none; }
}
