/* =================================================================
   Empire Simulator 3 — editorial dark theme.

   All UI styling flows through the tokens at :root. Map rendering
   is deliberately NOT styled here — the layer bakes in src/render
   carry their own saturated palette and should stay vivid.
   ================================================================= */

:root {
  /* ---- Colour -------------------------------------------------- */
  /* Aligned with the v3 "Command Console" handoff: teal accent for
     "you / active", red for danger, amber for waiting/cooldown.
     Panels use a softer, more transparent background under blur so
     the map breathes through the chrome. */
  --bg:            #04080f;
  --panel-bg:      rgba(12,16,22,0.82);
  --panel-bg-solid:rgba(12,16,22,0.94);
  --panel-border:  rgba(255,255,255,0.09);
  --panel-shadow:  0 8px 24px rgba(0,0,0,0.30);
  --panel-shadow-lg: 0 12px 40px rgba(0,0,0,0.50);
  --hairline:      rgba(255,255,255,0.08);

  --fg:            #e6ebf2;    /* primary text */
  --fg-dim:        rgba(230,235,242,0.58);  /* labels, secondary */
  --fg-very-dim:   rgba(230,235,242,0.32);  /* captions, hints */

  --accent:        #5eead4;     /* teal — you / active / primary */
  --accent-soft:   rgba(94,234,212,0.12);
  --accent-border: rgba(94,234,212,0.28);
  --accent-hover:  rgba(94,234,212,0.18);
  --accent-active: rgba(94,234,212,0.28);

  --positive:      #7bc48a;
  --negative:      #f87171;
  --warn:          #eab308;     /* amber — cooldown progress */
  --cooldown:      rgba(234,179,8,0.20);  /* legacy full-width amber wash (empire panel buttons) */
  --cooldown-bar:  rgba(234,179,8,0.95);  /* solid amber for 2px progress bars (HUD dock) */

  --war:           #f87171;
  --war-bg:        rgba(248,113,113,0.12);
  --war-border:    rgba(248,113,113,0.32);

  /* ---- Typography --------------------------------------------- */
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --fs-caption:    11px;       /* small labels, hints */
  --fs-body:       12px;       /* panel body text */
  --fs-value:      14px;       /* inline values */
  --fs-title:      15px;       /* panel titles */
  --fs-stat:       22px;       /* the headline stat numbers */

  /* ---- Size / rhythm ----------------------------------------- */
  --tap:           28px;       /* min tap-target, square */
  --tap-wide:      34px;       /* primary buttons */
  --radius:        8px;
  --radius-sm:     4px;
  --pad-panel:     14px;
  --pad-panel-tight: 10px;
  --gap-xs:        4px;
  --gap-sm:        6px;
  --gap:           8px;
  --gap-lg:        14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: var(--fs-body)/1.4 var(--font-sans);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

main {
  flex: 1;
  position: relative;
  min-height: 0;
  padding: 0;
}

canvas#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #05070a;
  image-rendering: auto;
  /* Prevent the browser from stealing touch drags as page scroll/zoom. */
  touch-action: none;
}

#globe-preview {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 240px;
  height: 240px;
  pointer-events: none;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.7));
}
#globe-preview canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  /* Parent is pointer-events:none so children opt back in, and touch-action:none
     stops mobile from interpreting a drag as a page scroll. */
  pointer-events: auto;
  touch-action: none;
}

/* Status line — historically floated at the bottom of the screen
   during long bakes. Now hidden globally; the boot-overlay carries
   the loading state, and post-boot the message has nothing to say
   that the player needs to read. */
#status { display: none; }

/* =================================================================
   Panels (shared surface)
   ================================================================= */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  color: var(--fg);
  font: var(--fs-body)/1.4 var(--font-sans);
  padding: var(--pad-panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Shared entrance/exit animation. Any panel that toggles visibility
   via `.is-open` should include `.anim-panel` in its class list — the
   system then animates opacity + translateY on both enter and exit.
   Uses pointer-events instead of display:none so transitions fire on
   both directions; visibility flips after the fade to remove from tab
   order cleanly. */
.anim-panel {
  opacity: 0;
  transform: translateY(6px) scale(0.99);
  transform-origin: top right;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 180ms ease-out,
    transform 180ms ease-out,
    visibility 0s linear 180ms;
}
.anim-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  pointer-events: auto;
  transition:
    opacity 180ms ease-out,
    transform 180ms ease-out,
    visibility 0s linear 0s;
}
/* Small entrance accent for panels that come from the bottom-left
   stack (settings) — feels more natural growing upward. */
.anim-panel--from-bottom-left {
  transform-origin: bottom left;
  transform: translateY(-6px) scale(0.99);
}
.anim-panel--from-bottom-left.is-open { transform: translateY(0) scale(1); }

.panel-title {
  font-size: var(--fs-title);
  font-weight: 600;
  letter-spacing: -0.005em;
  margin-bottom: 10px;
}

.panel-section-title {
  color: var(--fg-dim);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 14px 0 6px;
}

.panel-divider {
  border-top: 1px solid var(--hairline);
  padding-top: 12px;
  margin-top: 6px;
}

/* =================================================================
   Buttons
   ================================================================= */
.btn {
  font: var(--fs-body)/1 var(--font-sans);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  background: var(--accent-soft);
  color: var(--fg);
  border: 1px solid var(--accent-border);
  padding: 6px 12px;
  min-height: var(--tap);
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:active:not(:disabled) { background: var(--accent-active); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  min-height: var(--tap-wide);
  padding: 8px 16px;
  font-weight: 500;
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.btn-ghost {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid transparent;
  padding: 6px 10px;
  min-height: var(--tap);
  border-radius: var(--radius-sm);
  font: var(--fs-body)/1 var(--font-sans);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.btn-ghost:hover { color: var(--fg); background: var(--accent-soft); }
.btn-ghost.is-active {
  background: var(--accent-active);
  color: var(--fg);
  border-color: var(--accent-border);
}

.btn-nudge {
  font: var(--fs-value)/1 var(--font-sans);
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.btn-nudge:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--fg);
  border-color: var(--accent-border);
}
.btn-nudge:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-close {
  background: transparent;
  color: var(--fg-dim);
  border: 0;
  cursor: pointer;
  padding: 4px 8px;
  min-width: var(--tap); min-height: var(--tap);
  font-size: 22px; line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.12s ease, background 0.12s ease;
}
.btn-close:hover { color: var(--fg); background: var(--accent-soft); }

.btn-war {
  padding: 4px 10px;
  min-height: var(--tap);
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--warn);
  cursor: pointer;
  transition: background 0.12s ease;
}
.btn-war:hover { background: rgba(245,167,66,0.08); }
.btn-war.is-at-war {
  background: var(--war-bg);
  color: var(--war);
  border-color: var(--war-border);
}
.btn-war.is-at-war:hover { background: rgba(200,60,60,0.22); }

/* Cooldown-animated button. Fill slides from full (just pressed) to
   zero (ready). Text stays readable via position:relative. */
.btn-cd { position: relative; overflow: hidden; }
.btn-cd__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: var(--cooldown);
  pointer-events: none;
  transition: width 60ms linear;
}
.btn-cd__text {
  position: relative;
  pointer-events: none;
}

/* =================================================================
   Layer switcher (top-left)
   Desktop: inline row of buttons, trigger hidden.
   Mobile:  single "Layer: X ▾" trigger opens a dropdown of buttons.
   ================================================================= */
/* Dropdown anchored below the HUD ≡ button. Hidden unless .is-open. */
.layer-switcher {
  position: absolute; top: 100px; right: 16px; z-index: 12;
  padding: 6px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-width: 180px;
  display: none;
}
.layer-switcher.is-open { display: block; }
.layer-switcher__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.layer-switcher__list .btn-ghost { justify-content: flex-start; }

/* =================================================================
   Sim controls (bottom-left)
   ================================================================= */
.sim-controls {
  position: absolute; bottom: 16px; left: 16px; z-index: 5;
  display: flex; align-items: center; gap: var(--gap-lg);
  padding: 8px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font: var(--fs-body)/1 var(--font-sans);
}
.sim-tick {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.sim-tick__year { color: var(--fg); font-weight: 500; }
.sim-tick__day  { color: var(--fg-dim); }
.sim-tick__sep  { color: var(--fg-very-dim); }
.sim-tick__empires { color: var(--fg-very-dim); }
.sim-controls__mob,
.sim-controls__empire {
  white-space: nowrap;
}
.sim-controls__mob { padding: 6px 12px; min-height: var(--tap); font-weight: 500; }

/* =================================================================
   Settings panel (bottom-left stack)
   ================================================================= */
.settings-panel {
  position: absolute; bottom: 76px; left: 16px; z-index: 6;
  width: 340px;
  display: flex; flex-direction: column;
  gap: 4px;
}

/* =================================================================
   Empire panel (bottom-right on desktop)
   ================================================================= */
.empire-panel {
  position: absolute; bottom: 76px; right: 16px; z-index: 8;
  width: 360px;
  display: flex; flex-direction: column;
  gap: var(--gap);
}
/* Read-only state — shown when in play mode and inspecting an empire
   that isn't the player's. Stats stay at full brightness; interactive
   controls dim so the player knows they can't meddle. */
.empire-panel.is-readonly .alloc-row__label,
.empire-panel.is-readonly .tax-row__label,
.empire-panel.is-readonly .mobilize-row__hint,
.empire-panel.is-readonly .budget-row,
.empire-panel.is-readonly .alloc-row,
.empire-panel.is-readonly .tax-row,
.empire-panel.is-readonly .mobilize-row { opacity: 0.55; }
.empire-panel.is-readonly .panel-section-title { opacity: 0.7; }

/* Stat row — big numbers, small labels underneath. This is the
   pedagogical heart of the panel; deliberately typographic. */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--gap);
}
.stat-cell {
  display: flex; flex-direction: column;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--hairline);
}
.stat-cell__value {
  font: 600 var(--fs-stat)/1.1 var(--font-mono);
  color: var(--fg);
  letter-spacing: -0.01em;
}
.stat-cell__label {
  font-size: 10px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.stat-cell__delta {
  font: var(--fs-caption)/1 var(--font-mono);
  color: var(--fg-very-dim);
  margin-top: 4px;
  min-height: 1em;
}
.stat-cell__delta.is-positive { color: var(--positive); }
.stat-cell__delta.is-negative { color: var(--negative); }

/* Allocation rows. Label sits left, nudge + value + nudge + cost on the right. */
.alloc-row {
  display: grid;
  grid-template-columns: 1fr var(--tap) 36px var(--tap) 48px;
  align-items: center;
  gap: var(--gap-sm);
}
.alloc-row__label   { color: var(--fg-dim); }
.alloc-row__value   { text-align: center; font-family: var(--font-mono); color: var(--fg); }
.alloc-row__cost    { text-align: right; font-size: 10px; color: var(--fg-very-dim); font-family: var(--font-mono); }

.tax-row {
  display: grid;
  grid-template-columns: 1fr var(--tap) 40px var(--tap);
  align-items: center;
  gap: var(--gap-sm);
}
.tax-row__label { color: var(--fg-dim); }
.tax-row__value { text-align: center; font-family: var(--font-mono); color: var(--fg); }

.budget-row {
  display: flex; justify-content: space-between; align-items: baseline;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
}
.budget-row__value { color: var(--fg); }

.empire-header {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 4px;
}
.empire-header__swatch {
  width: 12px; height: 12px; border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.5);
  flex-shrink: 0;
}
.empire-header__title {
  flex: 1;
  font-size: var(--fs-title);
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.005em;
}

.mobilize-row {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.mobilize-row .btn-primary { flex: 1 1 auto; min-width: 0; }
/* Visual differentiation for the inverse action: thinner, muted. */
.btn-secondary {
  background: transparent;
  border-color: var(--hairline);
  color: var(--fg-dim);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--fg);
  border-color: var(--accent-border);
}
.mobilize-row__hint {
  color: var(--fg-very-dim);
  font-size: var(--fs-caption);
}

.war-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 10px;
  align-items: center;
}
.war-row__swatch {
  width: 10px; height: 10px; border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.5);
}
.war-row__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg);
  font-size: var(--fs-caption);
}

/* =================================================================
   War / diplomacy panel
   ================================================================= */
.war-panel {
  position: absolute;
  bottom: 76px;
  right: calc(360px + 32px);  /* sit to the left of empire panel on desktop */
  z-index: 9;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.war-panel__header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.war-panel__subtitle {
  color: var(--fg-dim);
  font-size: var(--fs-caption);
}
.war-panel__hint {
  color: var(--fg-dim);
  font-size: var(--fs-caption);
  line-height: 1.5;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--hairline);
}
.war-panel__list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 45vh;
  overflow-y: auto;
}
.war-panel__empty {
  color: var(--fg-very-dim);
  font-style: italic;
  padding: 8px 4px;
  font-size: var(--fs-caption);
}

/* War row reused across empire-panel button stub and war-panel list. */
.war-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--hairline);
}
.war-row__swatch {
  width: 12px; height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.5);
}
.war-row__info { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.war-row__name {
  color: var(--fg);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.war-row__meta {
  color: var(--fg-very-dim);
  font-family: var(--font-mono);
  font-size: 10px;
}

/* =================================================================
   Leaderboard (top-right, below mini globe)
   ================================================================= */
.leaderboard {
  position: absolute;
  top: calc(16px + 240px + 12px);
  right: 16px;
  z-index: 5;
  width: 240px;
  max-height: 40vh;
  overflow-y: auto;
  /* Solid bg instead of backdrop-filter blur — the leaderboard is
     always visible over the rotating globe, and animated content
     under a blurred surface forces the browser compositor to
     re-rasterize the blur every frame. Solid bg is a free render. */
  background: var(--panel-bg-solid);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 8px 0 6px;
  font: var(--fs-caption)/1.3 var(--font-sans);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--panel-shadow);
}
.leaderboard::-webkit-scrollbar { width: 6px; }
.leaderboard::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 3px; }

.leaderboard__topbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 6px 12px;
  border-bottom: 1px solid var(--hairline);
}
.leaderboard__title {
  flex: 1;
  font-size: var(--fs-title);
  font-weight: 600;
  color: var(--fg);
}

.leaderboard__header {
  display: grid;
  grid-template-columns: 18px 14px 1fr 52px 48px;
  gap: 8px;
  padding: 4px 12px 6px;
  color: var(--fg-dim);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 4px;
}
.leaderboard__row {
  display: grid;
  grid-template-columns: 18px 14px 1fr 52px 48px;
  gap: 8px;
  align-items: center;
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.1s ease;
  min-height: var(--tap);
}
.leaderboard__row:hover { background: var(--accent-soft); }
.leaderboard__row.is-selected { background: var(--accent-active); }
.leaderboard__rank { color: var(--fg-very-dim); text-align: right; font-family: var(--font-mono); }
.leaderboard__swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.5);
}
.leaderboard__name {
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaderboard__pop,
.leaderboard__cells {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--fg-dim);
}

/* =================================================================
   Tournament scoreboard — live archetype standings, tournament mode only
   ================================================================= */
.tscore {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  width: 220px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 8px 0 6px;
  font: var(--fs-caption)/1.3 var(--font-sans);
  color: var(--fg);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform-origin: top left;
}
.tscore__title {
  font-size: var(--fs-title);
  font-weight: 600;
  padding: 2px 12px 6px;
  border-bottom: 1px solid var(--hairline);
}
.tscore__header {
  display: grid;
  grid-template-columns: 14px 1fr 44px 52px;
  gap: 8px;
  padding: 4px 12px 6px;
  color: var(--fg-dim);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 4px;
}
.tscore__row {
  display: grid;
  grid-template-columns: 14px 1fr 44px 52px;
  gap: 8px;
  align-items: center;
  padding: 4px 12px;
}
.tscore__swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.5);
}
.tscore__name {
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tscore__rank {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--fg-dim);
}

/* =================================================================
   Inspector (hover readout)
   ================================================================= */
.inspector {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font: var(--fs-caption)/1.4 var(--font-mono);
  padding: 8px 10px;
  max-width: 260px;
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* =================================================================
   Start screen (mode picker)
   ================================================================= */
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* Two-tone radial: a faint teal halo at the top-third, fading to
     near-black. Matches the handoff's "map breathing under the
     console" feel without committing to a specific map colour. */
  background:
    radial-gradient(ellipse 70% 60% at 50% 30%, rgba(94,234,212,0.06), transparent 70%),
    radial-gradient(ellipse at center, rgba(20,28,40,0.88), rgba(4,8,15,0.98));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 280ms ease-out;
}
.start-screen.is-open    { opacity: 1; }
.start-screen.is-closing { opacity: 0; }

.start-screen__card {
  max-width: 540px;
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--panel-shadow-lg);
  padding: 28px 28px 22px;
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.start-screen__title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
  margin-bottom: 6px;
}
.start-screen__subtitle {
  font-size: 10px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.start-screen__links {
  font-size: 14px;
  color: var(--fg-dim);
  margin-bottom: 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.start-screen__links a {
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding: 1px 0;
  transition: color 0.14s ease, border-color 0.14s ease;
}
.start-screen__links a:hover {
  color: var(--accent);
  border-color: var(--accent-border);
}
.start-screen__links-sep {
  color: var(--fg-very-dim);
}
/* Update log under the mode buttons — collapsed by default; opens to
   a short list of recent changes. Intentionally low-contrast so it
   doesn't pull focus from the main Play / Sandbox buttons. */
.start-screen__updates {
  margin-top: 14px;
  color: var(--fg-dim);
  font-size: 12px;
}
.start-screen__updates > summary {
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  color: var(--fg-dim);
  list-style: none;
  display: inline-block;
}
.start-screen__updates > summary::-webkit-details-marker { display: none; }
.start-screen__updates > summary::before {
  content: "▸ ";
  font-size: 10px;
  opacity: 0.6;
}
.start-screen__updates[open] > summary::before { content: "▾ "; }
.start-screen__updates > summary:hover { color: var(--fg); }
.update-log {
  list-style: none;
  margin: 6px 0 0 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
}
.update-log li {
  padding: 4px 0;
  border-top: 1px solid rgba(255,255,255,0.05);
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
  align-items: baseline;
}
.update-log li:first-child { border-top: none; padding-top: 6px; }
.update-log__date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-very-dim);
  white-space: nowrap;
}
.update-log__text {
  color: var(--fg-dim);
  line-height: 1.35;
}

.start-screen__modes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.start-mode {
  display: block;
  text-align: left;
  padding: 14px 18px;
  background: rgba(255,255,255,0.02);
  color: var(--fg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}
.start-mode:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  transform: translateY(-1px);
}
.start-mode:active:not(:disabled) { transform: translateY(0); }
.start-mode:disabled { opacity: 0.4; cursor: not-allowed; }
.start-mode--primary {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.start-mode__name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 3px;
}
.start-mode__sub {
  font-size: var(--fs-caption);
  color: var(--fg-dim);
  line-height: 1.4;
}
.start-screen__hint {
  color: var(--fg-very-dim);
  font-size: var(--fs-caption);
  font-family: var(--font-mono);
  margin-top: 10px;
}
.start-screen__hint b { color: var(--fg-dim); font-weight: 600; }

/* Two-step wizard: only .is-active card is visible. Parent overlay
   holds both, crossfades via opacity. */
.start-step {
  position: absolute;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.start-step.is-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  position: relative;
}

/* Opponent-count stepper. */
.setup-opponents {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 10px 0 6px;
}
.setup-step-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--fg);
  border: 1px solid var(--accent-border);
  font-size: 22px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s ease, transform 0.14s ease;
}
.setup-step-btn:hover { background: var(--accent-hover); }
.setup-step-btn:active { transform: scale(0.96); }
.setup-opponents__count {
  min-width: 72px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 40px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.02em;
}
.setup-opponents__hint {
  color: var(--fg-dim);
  font-size: var(--fs-caption);
  line-height: 1.5;
  margin-bottom: 18px;
  padding: 0 8px;
}
.setup-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
}
.setup-back {
  background: transparent;
  color: var(--fg-dim);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  transition: color 0.14s ease, border-color 0.14s ease;
}
.setup-back:hover { color: var(--fg); border-color: var(--accent-border); }
.setup-start {
  flex: 1;
  background: var(--accent);
  color: #08131a;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.14s ease, transform 0.14s ease;
}
.setup-start:hover { filter: brightness(1.08); }
.setup-start:active { transform: translateY(1px); }

@media (max-width: 768px) {
  .start-screen__card { padding: 20px; }
  .start-screen__title { font-size: 24px; }
}

/* =================================================================
   Action floaters (transient text over empire capitals)
   ================================================================= */
.action-floaters {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 11;
}
.action-float {
  position: fixed;
  top: 0; left: 0;
  transform: translate(-9999px, -9999px);   /* off-screen until positioned */
  /* Label origin: just-above the capital (negative Y = up). Shift it
     horizontally so text doesn't jam into the city marker. */
  margin-top: -18px;
  margin-left: 10px;
  padding: 4px 9px 4px 10px;
  background: rgba(11,13,17,0.88);
  border-left: 3px solid var(--float-color, var(--accent));
  border-radius: 3px;
  color: var(--fg);
  font: 500 11px/1.1 var(--font-sans);
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 80ms ease-out;
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* =================================================================
   Training panel (shown during evolutionary training runs)
   ================================================================= */
.training-panel {
  position: fixed;
  top: 80px;
  right: 14px;
  z-index: 30;
  min-width: 280px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.training-panel__config {
  font: 400 11px/1.3 var(--font-sans);
  color: var(--fg-dim);
  letter-spacing: 0.01em;
}
.training-panel__genline {
  font: 500 12px/1.3 var(--font-sans);
  margin-bottom: 6px;
}
.training-panel__bar {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.training-panel__bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 200ms ease-out;
}
.training-panel__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font: 400 12px/1.3 var(--font-sans);
  color: var(--fg-dim);
}
.training-panel__stats b {
  color: var(--fg);
  font-weight: 600;
  margin-left: 4px;
}
.training-panel__chart {
  width: 100%;
  border-radius: 4px;
  border: 1px solid var(--panel-border);
  background: rgba(10,13,18,0.6);
}
.training-panel__actions {
  display: flex;
  gap: 8px;
}
.training-panel__actions button {
  flex: 1;
  padding: 6px 10px;
  font: 500 12px/1 var(--font-sans);
  color: var(--fg);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  cursor: pointer;
}
.training-panel__actions button:hover:not(:disabled) {
  background: rgba(255,255,255,0.08);
}
.training-panel__actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.training-panel__autodl {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 400 11px/1.3 var(--font-sans);
  color: var(--fg-dim);
  cursor: pointer;
  user-select: none;
}
.training-panel__autodl input {
  accent-color: var(--accent);
}
.training-panel__done {
  font: 500 12px/1.3 var(--font-sans);
  color: var(--accent);
}

/* =================================================================
   Transient notifications (war declared on you, rebellion, etc.)
   ================================================================= */
.notifications {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  z-index: 40;
  pointer-events: none;
  max-width: 92vw;
}
.notification {
  --notif-color: var(--accent);
  pointer-events: auto;
  cursor: pointer;
  min-width: 240px;
  max-width: 420px;
  padding: 10px 14px 11px 16px;
  background: rgba(14,17,22,0.92);
  border: 1px solid var(--panel-border);
  border-left: 3px solid var(--notif-color);
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
  color: var(--fg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.notification.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.notification__title {
  font: 600 13px/1.25 var(--font-sans);
  letter-spacing: 0.01em;
  color: var(--notif-color);
  margin-bottom: 2px;
}
.notification__body {
  font: 400 12px/1.35 var(--font-sans);
  color: var(--fg-dim);
}

/* =================================================================
   Loading indicators
   ================================================================= */

/* Shared spinner — a ring that rotates. Two sizes. */
.spinner {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--accent);
  animation: spinner-rot 0.9s linear infinite;
}
.spinner--sm {
  width: 14px; height: 14px; border-width: 2px;
}
@keyframes spinner-rot { to { transform: rotate(360deg); } }

/* Full-screen boot overlay. Removed from DOM once main() completes. */
.boot-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg);
  color: var(--fg);
  transition: opacity 320ms ease;
}
.boot-overlay.is-hiding { opacity: 0; pointer-events: none; }
.boot-overlay__title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin-top: 8px;
}
.boot-overlay__status {
  font: var(--fs-caption)/1 var(--font-mono);
  color: var(--fg-dim);
  max-width: 80vw;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Small bake-in-progress badge. Floats top-center while a layer is
   being rendered for the first time; hidden otherwise. */
.bake-indicator {
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  box-shadow: var(--panel-shadow);
  font: var(--fs-caption)/1 var(--font-mono);
  color: var(--fg-dim);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}
.bake-indicator[hidden] { display: none; }

/* Range sliders — thin, neutral, accent thumb. */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  height: 28px;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
}
input[type=range]::-moz-range-track {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: -5.5px;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--accent-border);
}
input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

/* =================================================================
   Mobile / narrow viewport — full-screen sheets for panels.
   ================================================================= */
@media (max-width: 768px) {
  :root {
    --tap: 40px;
    --tap-wide: 44px;
    --pad-panel: 16px;
    --pad-panel-tight: 12px;

    --fs-caption: 12px;
    --fs-body:    13px;
    --fs-value:   15px;
    --fs-title:   17px;
    --fs-stat:    24px;
  }

  #globe-preview {
    width: 120px; height: 120px;
    top: 12px; right: 12px;
  }

  /* Mobile: anchor the layer dropdown below the HUD, full-width.
     Safe-area aware so it clears the notch on iOS. */
  .layer-switcher {
    top: calc(8px + env(safe-area-inset-top, 0px) + 56px);
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    min-width: 0;
    max-height: 60vh;
    overflow-y: auto;
  }
  .layer-switcher__list .btn-ghost {
    padding: 10px 12px;
    min-height: var(--tap);
  }

  /* Mobile leaderboard: anchored top-right under the HUD strip, narrow
     so it doesn't crowd the map. The bottom-anchored action dock
     reserves ~140px of bottom area, so the leaderboard's max-height
     keeps it well clear. Safe-area aware. */
  .leaderboard {
    top: calc(8px + env(safe-area-inset-top, 0px) + 56px + 8px);
    right: calc(8px + env(safe-area-inset-right, 0px));
    width: 168px;
    max-height: calc(100vh - 56px - 160px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    font-size: 11px;
  }

  /* Tournament scoreboard moves below the top strip on the left side,
     out of the way of both the HUD chrome and the leaderboard. */
  .tscore {
    top: calc(8px + env(safe-area-inset-top, 0px) + 56px + 8px);
    left: calc(8px + env(safe-area-inset-left, 0px));
    width: 168px;
    font-size: 11px;
    max-height: calc(100vh - 56px - 160px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
  }

  /* Enemy info opens centered on the phone screen — easier to read at
     a glance than a bottom-anchored sheet competing with the action
     dock. Tapping the map outside the panel dismisses it (wired in
     main.js). The .anim-panel base sets a transform for the fade
     animation; we combine the centring translate with the entrance
     offset so both work together (otherwise .is-open's
     transform: translateY(0) wins and the panel sits at the top-left
     edge of the centre point). */
  .enemy-info-panel {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    width: calc(100vw - 24px);
    max-width: 360px;
    max-height: calc(100vh - 96px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    padding: 12px 14px !important;
  }
  .enemy-info-panel.anim-panel        { transform: translate(-50%, calc(-50% + 12px)) !important; }
  .enemy-info-panel.anim-panel.is-open { transform: translate(-50%, -50%) !important; }

  /* Trim content density. Drop the prose details row (scout-level
     extras) but keep the 6-column alloc grid — knowing where an
     enemy invested is core scouting info worth two lines of vertical
     space. Cells get tighter on mobile so the grid stays single-row. */
  .enemy-info__details { display: none; }
  .enemy-info__header { padding-bottom: 8px; margin-bottom: 8px; }
  .enemy-info__title  { font-size: 16px; }
  .enemy-info__stats  { gap: 6px; margin-bottom: 10px; }
  .enemy-info__stat        { padding: 4px 6px; }
  .enemy-info__stat-value  { font-size: 15px; }
  .enemy-info__stat-label  { font-size: 9.5px; }
  /* Compact alloc grid: 6 columns, smaller font, no border boxes. */
  .enemy-info__alloc {
    gap: 2px;
    margin: 8px 0;
  }
  .enemy-info__alloc-col {
    padding: 4px 0;
    gap: 1px;
  }
  .enemy-info__alloc-value { font-size: 14px; }
  .enemy-info__alloc-label { font-size: 8.5px; letter-spacing: 0.04em; }
  .enemy-info__war { padding: 12px; font-size: 14px; }
  .enemy-info__diplomacy { font-size: 11.5px; margin-top: 8px; }

  /* Research popover anchors between the HUD top strip and the action
     dock — the player just tapped Research in the dock, the popover
     fills the available middle area, scroll if it overflows. */
  .research-popover {
    top: calc(8px + env(safe-area-inset-top, 0px) + 56px + 8px);
    bottom: calc(8px + env(safe-area-inset-bottom, 0px) + 132px);
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    width: auto;
    transform: none;
    max-width: none;
    max-height: none;
    overflow-y: auto;
  }
  .leaderboard__header,
  .leaderboard__row {
    grid-template-columns: 16px 10px 1fr 42px 36px;
    padding: 4px 10px;
    gap: 6px;
  }

  .sim-controls {
    bottom: 12px; left: 12px; right: 12px;
    padding: 8px 10px;
    gap: 8px;
  }
  .sim-controls .btn-primary,
  .sim-controls__mob { flex: 1 1 auto; }
  .sim-controls .sim-tick { display: none; }

  /* Full-screen sheets for empire / settings / war panels. */
  .empire-panel,
  .settings-panel,
  .war-panel {
    position: fixed !important;
    inset: 0 !important;
    width: auto !important;
    max-width: none !important;
    height: 100% !important;
    max-height: none !important;
    border-radius: 0;
    border: 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    overflow-y: auto;
    z-index: 20;
    background: rgba(11,13,17,0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  /* On mobile, sheets come up from the bottom rather than fading down.
     The .anim-panel base transition still handles opacity + timing. */
  .empire-panel.anim-panel,
  .settings-panel.anim-panel,
  .war-panel.anim-panel {
    transform: translateY(14px);
    transform-origin: center;
  }
  .empire-panel.anim-panel.is-open,
  .settings-panel.anim-panel.is-open,
  .war-panel.anim-panel.is-open {
    transform: translateY(0);
  }

  /* Give the mobilize row + stats more vertical space on sheets. */
  .empire-panel { gap: 12px; }

  /* Allocation rows can afford wider touch zones on mobile. */
  .alloc-row {
    grid-template-columns: 1fr var(--tap) 44px var(--tap) 52px;
    gap: var(--gap);
    padding: 2px 0;
  }
  .tax-row {
    grid-template-columns: 1fr var(--tap) 48px var(--tap);
    gap: var(--gap);
    padding: 2px 0;
  }

  .inspector { font-size: 11px; max-width: 200px; padding: 6px 8px; }

  #status {
    bottom: auto;
    top: 12px;
    left: 12px;
    transform: none;
    font-size: 10px;
  }
}

/* ===== Player HUD ======================================================= */
/* Top-centered strip for the player empire. Content-sized so the HUD
   isn't a horizon-wide bar — we tighten the individual pieces enough
   that everything fits comfortably. */
.player-hud {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;           /* children re-enable */
  max-width: calc(100vw - 24px);
}
.player-hud__indicators,
.player-hud__dock {
  display: flex;
  gap: 2px;
  background: var(--panel-bg-solid);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--panel-shadow-lg);
  padding: 6px;
  pointer-events: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
/* --- Indicators ---
   Layout matches the handoff: tiny mono "POP" label on top, larger
   tabular value below. Cells are separated by hairlines instead of
   pill backgrounds — the whole row reads like a stat strip. */
.hud-indicator {
  min-width: 80px;
  padding: 4px 12px;
  display: flex;
  flex-direction: column-reverse;   /* DOM order is [value, label]; flip to render label on top */
  justify-content: center;
  gap: 2px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  text-align: left;
  cursor: default;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  position: relative;
}
.hud-indicator + .hud-indicator::before {
  content: "";
  position: absolute;
  left: -1px; top: 4px; bottom: 4px;
  border-left: 1px solid var(--panel-border);
}
.hud-indicator:not(:disabled) { cursor: pointer; }
.hud-indicator:not(:disabled):hover { background: var(--accent-soft); }
.hud-indicator__value {
  font-size: 18px;
  font-weight: 600;
  font-feature-settings: "tnum";
  letter-spacing: -0.01em;
  line-height: 1.1;
}
/* Stable cell widths — pinned on Pop / Treasury / Army where the
   value can swing 1–6 chars and adjacent cells would otherwise
   reflow as the formatted number changes. Wars is just a count
   (1 char), no need. tabular-nums above keeps digits same-advance. */
.hud-indicator--pop .hud-indicator__value,
.hud-indicator--treasury .hud-indicator__value,
.hud-indicator--army .hud-indicator__value {
  min-width: 60px;
  display: inline-block;
  text-align: left;
}
.hud-indicator__label {
  font-size: 10px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-family: var(--font-mono);
}
/* Default (desktop): show the full label, hide the short variant.
   Mobile media query flips both. */
.hud-indicator__label--short { display: none; }
.hud-indicator.is-warn   .hud-indicator__value { color: var(--warn); }
.hud-indicator.is-danger .hud-indicator__value { color: var(--war); }
.hud-indicator.is-active {
  background: var(--war-bg);
  border-color: var(--war-border);
}
.hud-indicator.is-active .hud-indicator__value { color: var(--war); }

/* --- Action dock ---
   Mirror the handoff `.es-action`: centered label, mono "state" line
   underneath, amber 2px progress bar at the bottom edge while in
   cooldown. Buttons sit on a transparent base; hover surfaces an
   accent wash. */
.hud-action {
  position: relative;
  min-width: 88px;
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  font-family: var(--font-sans);
  transition: background 0.12s ease;
}
.hud-action:hover:not(:disabled) { background: rgba(255,255,255,0.04); }
.hud-action:disabled { opacity: 0.55; cursor: not-allowed; }
.hud-action__fill {
  /* Cooldown progress: 2px amber bar at the bottom edge.
     `width` is set inline by the JS (frac × 100%). */
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--cooldown-bar);
  pointer-events: none;
  width: 0%;
  transition: width 120ms linear;
}
.hud-action__title {
  position: relative;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.005em;
}
.hud-action__hint {
  position: relative;
  font-size: 10px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.hud-action.is-warn .hud-action__title { color: var(--warn); }
.hud-action.is-warn .hud-action__hint  { color: var(--warn); }
.hud-action.is-danger {
  background: rgba(248,113,113,0.10);
}
.hud-action.is-danger .hud-action__title { color: var(--war); }

.hud-details {
  width: 28px;
  min-width: 28px;
  padding: 0;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.02);
  color: var(--fg-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.hud-details:hover { color: var(--fg); background: var(--accent-soft); }

/* Mobile playability — the action dock detaches from the top stack and
   anchors to the bottom of the screen so the eight primary actions are
   thumb-reachable. The dock wraps to two rows of four so all controls
   are visible without horizontal scroll on a 360 px-wide phone. The top
   strip stays at the top, but it's the secondary surface (status +
   utilities + Play). The mini globe is hidden — the main globe is the
   same view, so it's redundant on small screens. */
@media (max-width: 768px) {
  .player-hud {
    /* Safe-area aware top inset so the HUD clears the notch / status
       bar on iOS and Android phones held in portrait. */
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    transform: none;
    width: auto;
    max-width: none;
    align-items: stretch;
  }
  .player-hud__top {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .player-hud__top::-webkit-scrollbar { display: none; }
  .player-hud__indicators {
    justify-content: flex-start;
    padding: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .player-hud__indicators::-webkit-scrollbar { display: none; }

  /* Bottom-anchored action dock: fixed-position so it escapes the
     top-mounted .player-hud parent. Wraps to two rows × four buttons,
     stretches edge to edge for predictable widths, respects the home
     indicator on devices with a bottom safe area. */
  .player-hud__dock {
    position: fixed;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    z-index: 11;
    flex-wrap: wrap;
    justify-content: stretch;
    padding: 6px;
    gap: 4px;
    /* Solid-alpha fill instead of backdrop-blur — perf > looks on
       mobile, and a 0.85 opacity dark fill reads similarly without
       the GPU re-rasterization cost of a 14 px blur. */
    background: rgba(8, 12, 18, 0.86);
  }
  /* Dock action buttons compressed. !important on each property since
     a `@media (max-width: 360px)` block further down sets a higher
     min-height; without !important it wins on small screens. */
  .player-hud__dock .hud-action {
    flex: 1 1 calc(25% - 4px) !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 4px 4px !important;
    min-height: 30px !important;
    height: 30px !important;
    gap: 0 !important;
  }
  .player-hud__dock .hud-action .hud-action__title {
    font-size: 12px !important;
    line-height: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .player-hud__dock {
    padding: 3px !important;
    gap: 3px !important;
  }
  /* Mobile-only Play/Pause inside the dock. Full width on its own row
     (after the wrapped 4-col action grid) so it's the prominent
     thumb-target. Gets the teal accent like the desktop Play. */
  .hud-play--dock {
    flex: 1 1 100%;
    min-height: 48px;
    margin-top: 2px;
    padding: 12px 16px;
    font-size: 15px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #08131a;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
  }
  .hud-play--dock.is-playing {
    background: rgba(255,255,255,0.10);
    color: var(--fg);
  }
  .hud-indicator { min-width: 70px; padding: 4px 10px; flex: 0 0 auto; }
  .hud-indicator__value { font-size: 16px; }
  .hud-indicator__label { font-size: 9.5px; }
  .hud-action__title { font-size: 12px; }
  .hud-action__hint { font-size: 9.5px; }
  .hud-name__label { max-width: 110px; }
  .hud-clock { padding: 4px 8px; }
  .hud-clock__time { font-size: 12px; }
  .hud-clock__empires { font-size: 9.5px; }
  .hud-util { width: 36px; height: 36px; min-height: 36px; font-size: 14px; }
  .hud-util--text { padding: 0 10px; height: 36px; min-height: 36px; }
  .hud-play { min-width: 64px; padding: 8px 14px; min-height: 36px; font-size: 14px; }
  .player-hud__util { padding: 0 6px; }
  /* The rate stepper is a power-user nicety — it eats space the player
     needs more on phones. Hide it; tick rate is also exposed in the
     settings sheet. */
  .hud-rate { display: none; }

  /* Mobile strip on the top bar. We keep the resource pulse the player
     watches moment-to-moment (Pop / Treasury / Army / Wars) and drop
     everything ornamental. !important everywhere because base styles
     for these classes appear later in the file (single-class
     specificity, last-rule-wins). */
  .hud-indicator--unrest { display: none !important; }
  .hud-indicator { min-width: 52px !important; padding: 4px 8px !important; }
  /* Swap full → short labels on mobile. Both live in the DOM; show
     the short, hide the full. */
  .hud-indicator__label--full  { display: none !important; }
  .hud-indicator__label--short { display: inline !important; }
  /* The treasury short label is just a "$" glyph — bump it up so it
     reads as a coin/money cue rather than a tiny digit. */
  .hud-indicator--treasury .hud-indicator__label--short {
    font-size: 13px !important;
    letter-spacing: 0 !important;
    color: var(--fg-dim);
  }
  /* Empire-name pill is hidden on mobile entirely — the colour swatch
     was using top-bar real estate without a clear payoff. Tap-to-
     focus-capital can come back via a different gesture if needed. */
  .hud-name { display: none !important; }
  /* Drop the clock on phones — year/day rarely matters in mobile play. */
  .hud-clock { display: none !important; }

  /* Hide the ▲/▼ tick-rate stepper on mobile. Use !important since
     base .hud-rate { display: flex } below the media query overrides
     same-specificity. Speed is editable via the settings sheet. */
  .hud-rate { display: none !important; }

  /* Play/Pause as a small discrete circular button floating above the
     dock at bottom-right. Inline SVG inside (▶/⏸ as line-art, not
     emoji glyphs). position:fixed escapes the dock's flex flow.
     Bottom anchored well above the dock so even if dock height grows
     we don't collide. Top-bar Play hidden on mobile. */
  .player-hud__top .hud-play { display: none !important; }
  .hud-play--dock {
    display: grid !important;
    place-items: center;
    position: fixed !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 96px);
    right: calc(env(safe-area-inset-right, 0px) + 12px);
    width: 38px !important;
    height: 38px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: rgba(8, 12, 18, 0.72) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    color: var(--fg) !important;
    flex: none !important;
    margin: 0 !important;
    z-index: 12;
    box-shadow: 0 2px 6px rgba(0,0,0,0.32);
  }
  .hud-play--dock.is-playing { color: var(--fg-dim) !important; }

  /* Action button hints (the small mono subtitle, e.g. "0.30 → 0.35"
     under "Tax ↑") clutter mobile dock buttons without giving real
     value at thumb size — the title alone is enough on the
     player-already-knows-what-this-does dock. */
  .hud-action__hint { display: none !important; }

  /* Tighter Pop / Treasury / Army values on mobile — desktop's 60 px
     reserve was generous; phones don't need that much slack since the
     5-char max ("12.3M") fits comfortably in 44 px at the 16 px font. */
  .hud-indicator--pop      .hud-indicator__value,
  .hud-indicator--treasury .hud-indicator__value,
  .hud-indicator--army     .hud-indicator__value { min-width: 44px !important; }

  /* Mobile hamburger + cog: flat icon buttons (no border, no fill).
     The SVG sizing + stroke styling lives outside the media query so
     the same icons also render correctly on desktop. */
  .hud-util,
  .hud-util--text {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 0 !important;
    color: var(--fg) !important;
    font-size: 0 !important;     /* hide any leftover text content */
  }
  .hud-util:hover,
  .hud-util--text:hover { background: transparent !important; }

  /* Placement prompt sized for fingers; lifted off the chrome so the
     "Tap a land cell" call-to-action is the visual focus pre-founding. */
  .player-hud__prompt {
    margin-top: 80px;
    padding: 18px 16px;
    font-size: 14px;
  }
}

/* Hide the redundant mini globe on phones — the main view IS the
   globe, the picture-in-picture loses its purpose on small screens
   and just steals real estate from the HUD. */
@media (max-width: 768px) {
  #globe-preview { display: none; }
}

/* Drop ALL backdrop-filter blurs everywhere — desktop AND mobile.
   Each blurred surface forces a separate GPU pass that re-rasterizes
   the content behind it; with ~30 blurred panels stacking, even
   desktop GPUs spend non-trivial frame time on it for no real visual
   payoff. The panels' solid-alpha backgrounds still read as panels. */
* {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Very narrow (≤ 360 px, e.g. iPhone SE / small Android): tighten so
   the 4-button dock row still fits comfortably. */
@media (max-width: 360px) {
  .player-hud__dock {
    bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    left: 6px;
    right: 6px;
    padding: 4px;
  }
  .player-hud__dock .hud-action {
    padding: 6px 2px 8px;
    min-height: 48px;
  }
  .hud-action__title { font-size: 11px; }
  .hud-action__hint { font-size: 9px; }
}

/* HUD utility icons (layers, settings) on the right of the indicator row. */
.player-hud__util {
  display: flex; gap: 4px;
  align-self: center; align-items: center;
  padding: 0 8px;
  position: relative;
}
.player-hud__util::before {
  content: "";
  position: absolute;
  left: -1px; top: 4px; bottom: 4px;
  border-left: 1px solid var(--panel-border);
}
.hud-util {
  width: 32px;
  height: 32px;
  min-height: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0;             /* hide any text fallback; icon is SVG */
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s ease;
}
.hud-util:hover  { color: var(--accent); background: transparent; }
/* Inline-SVG icons inside utility buttons (hamburger / cog) and the
   mobile play floater. Sized + stroked here once so desktop and
   mobile pick up the same minimalist line-art rendering. */
.hud-util svg,
.hud-util--text svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.hud-play--dock svg {
  width: 14px;
  height: 14px;
  stroke: none;
  fill: currentColor;
  pointer-events: none;
}
.hud-util.is-active {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

/* Expand button, when on at peace, reads as an accented/active toggle. */
.hud-action.is-active {
  background: var(--accent-soft);
}
.hud-action.is-active:hover { background: var(--accent-hover); }
.hud-action.is-active .hud-action__title,
.hud-action.is-active .hud-action__hint { color: var(--accent); }

/* HUD placement prompt: shown before founding. Matches the panel
   chrome of the rest of the HUD so it feels like part of the console. */
.player-hud__prompt {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--panel-shadow);
  padding: 14px 20px;
  color: var(--fg);
  font-size: 13px;
  letter-spacing: -0.005em;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Start-screen play setup: name + color + opponents form. */
.setup-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}
.setup-field__label {
  font-size: var(--fs-caption);
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.setup-name {
  padding: 8px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font: var(--fs-value)/1.2 var(--font-sans);
  outline: none;
}
.setup-name:focus {
  border-color: var(--accent-border);
  background: rgba(255,255,255,0.06);
}
.setup-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.setup-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 120ms ease, border-color 120ms ease;
}
.setup-swatch:hover { transform: scale(1.08); }
.setup-swatch.is-active {
  border-color: var(--fg);
  box-shadow: 0 0 0 2px var(--bg) inset;
}

/* Graphics quality picker on the play setup step. Three side-by-side
   buttons; the active one is highlighted with the accent border. */
.setup-quality {
  display: flex;
  gap: 6px;
}
.setup-quality-btn {
  flex: 1 1 0;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  color: var(--fg-dim);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.setup-quality-btn:hover { color: var(--fg); }
.setup-quality-btn.is-active {
  color: var(--fg);
  background: rgba(255,255,255,0.08);
  border-color: var(--accent-border);
}

/* Research popover — anchored below the HUD Research button.
   Reuses .alloc-row from the empire panel for row layout. */
.research-popover {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  width: 360px;
  max-width: calc(100vw - 24px);
  padding: 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.research-popover__title {
  font-size: var(--fs-title);
  font-weight: 600;
  margin-bottom: 6px;
}
.research-popover__budget {
  font-family: var(--font-mono);
  font-size: var(--fs-value);
  color: var(--fg);
  margin-bottom: 8px;
}
.research-popover__invest {
  width: 100%;
  margin-bottom: 4px;
}
.research-popover__hint {
  margin-top: 10px;
  font-size: var(--fs-caption);
  color: var(--fg-dim);
}

/* Enemy info panel — anchored bottom-right, same silhouette as the old
   empire panel so the player knows where to look, but read-only + one
   big diplomatic button. */
.enemy-info-panel {
  position: absolute;
  bottom: 76px;
  right: 16px;
  z-index: 9;
  width: 300px;
  max-width: calc(100vw - 32px);
}
.enemy-info__header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.enemy-info__swatch {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  flex: 0 0 auto;
}
.enemy-info__title {
  flex: 1;
  font-size: var(--fs-title);
  font-weight: 600;
}
.enemy-info__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.enemy-info__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
}
.enemy-info__stat-value {
  font-family: var(--font-mono);
  font-size: var(--fs-value);
  font-weight: 600;
  color: var(--fg);
}
.enemy-info__stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-dim);
}
.enemy-info__details {
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  color: var(--fg-dim);
  margin-bottom: 8px;
}
.enemy-info__alloc {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin-bottom: 12px;
  padding: 6px 4px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--panel-soft, rgba(0,0,0,0.15));
}
.enemy-info__alloc-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.enemy-info__alloc-value {
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  color: var(--fg);
  font-weight: 600;
}
.enemy-info__alloc-label {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--fg-dim);
  text-transform: uppercase;
}
.enemy-info__war {
  width: 100%;
  min-height: var(--tap-wide);
  font-weight: 600;
}
.enemy-info__war.is-war {
  background: var(--war-bg);
  border-color: var(--war-border);
  color: var(--war);
}
.enemy-info__war.is-war:hover:not(:disabled) {
  background: rgba(200,60,60,0.22);
}
.enemy-info__diplomacy {
  margin-top: 10px;
  font-size: var(--fs-caption);
  color: var(--fg-dim);
}

/* HUD empire header — color swatch + name, shown above the indicators. */
.player-hud__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
  align-self: center;
  pointer-events: auto;
}
.player-hud__swatch {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
  flex: 0 0 auto;
}
.player-hud__name {
  font-size: var(--fs-value);
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.01em;
}

/* ------ Unified HUD top row ------------------------------------------ */
/* Compact strip sized to its contents. Every piece is tight enough
   (indicators 68px, name/clock content-sized, utility icons minimal)
   that the whole row fits on a typical viewport without scrolling. */
.player-hud__top {
  display: flex;
  align-items: stretch;
  gap: 2px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--panel-shadow);
  padding: 4px;
  pointer-events: auto;
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.player-hud__top::-webkit-scrollbar { display: none; }

.hud-name {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  /* Shrinkable so a long empire name doesn't push utility / Play / rate
     controls off the right edge of the centred top bar. The label inside
     already has its own ellipsis; this just lets the surrounding flex
     row claim the space back. */
  flex: 0 1 auto;
  min-width: 0;
  position: relative;
}
.hud-name::before {
  /* Hairline separator on the left, mirroring the design's vertical
     dividers between top-strip sections. */
  content: "";
  position: absolute;
  left: -1px; top: 4px; bottom: 4px;
  border-left: 1px solid var(--panel-border);
}
.hud-name__swatch {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 0;
  box-shadow: 0 0 6px currentColor;
  flex: 0 0 auto;
}
.hud-name__label {
  font-size: var(--fs-value);
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  max-width: 160px;
  /* min-width:0 with flex shrinking on the parent lets ellipsis kick in
     when the row is space-constrained, instead of growing past the cap. */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Play button — filled teal "primary" affordance. Pause flips to a
   muted grey state so the user can read mode at a glance. */
.hud-play {
  min-width: 60px;
  padding: 6px 16px;
  border: 0;
  background: var(--accent);
  color: #08131a;
  border-radius: var(--radius-sm);
  font: 600 13px/1 var(--font-sans);
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.12s ease;
}
.hud-play:hover { filter: brightness(1.08); }
.hud-play.is-playing {
  background: rgba(255,255,255,0.08);
  color: var(--fg);
}

/* Year/day + empire count block. Lives in its own segment with a
   hairline separator on the left, matching the handoff's `.es-clock`. */
.hud-clock {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 4px 12px;
  font-family: var(--font-mono);
  color: var(--fg);
  flex: 0 0 auto;
  position: relative;
}
.hud-clock::before {
  content: "";
  position: absolute;
  left: -1px; top: 4px; bottom: 4px;
  border-left: 1px solid var(--panel-border);
}
.hud-clock__time {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.hud-clock__empires {
  font-size: 10px;
  color: var(--fg-dim);
  letter-spacing: 0.06em;
}

/* Drop the old indicators-row styling now that everything lives in .top. */
.player-hud__indicators { display: none; }
.player-hud__header { display: none; }

/* Mobile-only Play in the dock — hidden on desktop where the top-bar
   Play handles it. The mobile media query above un-hides it. */
.hud-play--dock { display: none; }

/* Collapse the old bottom bar since its contents live in the HUD now. */
.sim-controls { display: none !important; }

/* Idle transparency was confusing — HUD stays full opacity. */

/* ------ Updated HUD top row layout ----------------------------------- */
/* Name pill is a real button now: swatch + name, clickable. */
.hud-name {
  padding: 0 10px;
  cursor: pointer;
  color: var(--fg);
  font: inherit;
  outline: none;
}
.hud-name:hover { background: var(--accent-soft); }
.hud-name:active { background: var(--accent-active); }

/* Tick-rate stepper — two tiny stacked buttons, ▲ over ▼. */
.hud-rate {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 auto;
  align-self: center;
  margin-left: 4px;
}
.hud-rate__btn {
  padding: 0 8px;
  min-height: 14px;
  height: 13px;
  font-size: 9px;
  line-height: 1;
  color: var(--fg-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.hud-rate__btn:hover { color: var(--fg); background: rgba(255,255,255,0.10); }

/* Layers text variant of the utility button. */
.hud-util--text {
  width: auto;
  min-width: 0;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: 0.04em;
  font-family: var(--font-sans);
}

/* Play button pushed to far right, slightly beefier. */
.hud-play {
  margin-left: 4px;
  min-width: 76px;
}

/* Custom instant tooltip (see src/ui/tooltip.js). Position is set in
   JS; we only style the appearance here. `white-space: pre-line` so
   the two-line "description \n live hint" format renders correctly. */
.es3-tip {
  position: fixed;
  z-index: 1000;
  max-width: 280px;
  padding: 6px 10px;
  background: rgba(11,13,17,0.96);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--panel-shadow);
  color: var(--fg);
  font: var(--fs-caption)/1.35 var(--font-sans);
  white-space: pre-line;
  pointer-events: none;
}
.es3-tip[hidden] { display: none; }

/* Loading-screen links below the boot status. */
.boot-overlay__links {
  margin-top: 24px;
  font-size: var(--fs-caption);
  color: var(--fg-dim);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.boot-overlay__links a {
  color: var(--fg-dim);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: color 120ms ease, background 120ms ease;
}
.boot-overlay__links a:hover {
  color: var(--fg);
  background: rgba(255,255,255,0.04);
}
.boot-overlay__sep { color: var(--fg-very-dim); }
