@font-face {
  font-family: "Press Start 2P";
  src: url("./fonts/press-start-2p.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Silkscreen";
  src: url("./fonts/silkscreen-400.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Silkscreen";
  src: url("./fonts/silkscreen-700.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "VT323";
  src: url("./fonts/vt323.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Rajdhani";
  src: url("./fonts/rajdhani-500.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Rajdhani";
  src: url("./fonts/rajdhani-600.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Rajdhani";
  src: url("./fonts/rajdhani-700.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Barlow";
  src: url("./fonts/barlow-400.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Barlow";
  src: url("./fonts/barlow-500.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Barlow";
  src: url("./fonts/barlow-600.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("./fonts/jetbrains-mono-500.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("./fonts/jetbrains-mono-600.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}

:root {
  --bg-deep: #120d09;
  --soil-1: #6e4a2a;
  --soil-2: #5c3c22;
  --soil-3: #49301b;
  --soil-4: #371f12;
  --soil-deep: #281609;
  --hud-bg: rgba(28, 23, 17, 0.82);
  --hud-bg-solid: #1c130b;
  --hud-panel: rgba(36, 30, 23, 0.88);
  --hud-panel-strong: rgba(26, 21, 15, 0.94);
  --hud-line: rgba(244, 234, 210, 0.18);
  --hud-line-strong: rgba(255, 199, 64, 0.42);
  --hud-text: #f4ead2;
  --hud-muted: #c3ad84;
  --hud-soft: #8d7757;
  --accent: #ffc740;
  --accent-strong: #ffd76b;
  --accent-green: #5fd6c4;
  --accent-ok: #7fc54a;
  --accent-red: #e0563f;
  --accent-blue: #5fd6c4;
  --accent-amber: #f59324;
  --night-top: #241a37;
  --night-mid: #3b2b46;
  --dusk: #7a4631;
  --ink: #1a120b;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.48), inset 1px 1px 0 rgba(255, 236, 205, 0.12);
  --shadow-inset: inset 0 1px 0 rgba(255, 236, 205, 0.08), inset 0 -1px 0 rgba(0, 0, 0, 0.42);
  --radius: 8px;
  --gap: 10px;
  /* ---- Command design: chrome surfaces ---- */
  --panel: rgba(26, 21, 15, 0.94);
  --panel-2: rgba(34, 27, 19, 0.97);
  --panel-solid: #1a150f;
  --raise: rgba(48, 40, 30, 0.9);
  --line: rgba(255, 236, 205, 0.1);
  --line-2: rgba(255, 236, 205, 0.18);
  --line-3: rgba(255, 236, 205, 0.28);
  /* ---- Command design: text ---- */
  --text: #f3ebda;
  --dim: #beac8a;
  --faint: #8c7d63;
  /* ---- Command design: accents ---- */
  --gold: #f4b740;
  --gold-soft: #ffd884;
  --gold-deep: #7a521a;
  --teal: #46cdba;
  --teal-soft: #8eeadd;
  --teal-deep: #1c7468;
  --rival: #ef6647;
  --rival-soft: #f6a08b;
  --rival-deep: #9a3320;
  --ok: #8fcb56;
  /* ---- Command design: type ---- */
  --f-disp: "Rajdhani", system-ui, sans-serif;
  --f-ui: "Barlow", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", monospace;
  --cmd-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  --cmd-shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.4);
  --r: 12px;
  --r-sm: 9px;
  color-scheme: dark;
  font-family: "Segoe UI", Arial, sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #090b0a;
  color: var(--hud-text);
}

body {
  user-select: none;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#game-shell,
#hud-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#game-shell {
  isolation: isolate;
  background:
    radial-gradient(120% 90% at 50% 0%, #1c150f 0%, #060403 100%);
}

#game-shell::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.18) 3px,
      rgba(0, 0, 0, 0.18) 3px
    ),
    radial-gradient(120% 130% at 50% 50%, transparent 56%, rgba(0, 0, 0, 0.5) 100%);
  mix-blend-mode: multiply;
}

#hud-root {
  pointer-events: none;
  z-index: 20;
}

.is-hidden {
  display: none !important;
}

canvas,
canvas.game-canvas,
#game-canvas,
.game-stage canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: radial-gradient(circle at 50% 30%, #2c1d10 0, #120d09 58%, #060403 100%);
  image-rendering: pixelated;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  color: var(--hud-text);
  background: #040201;
  pointer-events: auto;
  isolation: isolate;
  overflow: hidden;
}

#loading-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.2) 3px,
      rgba(0, 0, 0, 0.2) 3px
    ),
    radial-gradient(120% 130% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.62) 100%);
  mix-blend-mode: multiply;
}

#loading-screen .loading-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--bg-deep);
  overflow: hidden;
}

#loading-screen .loading-sky {
  position: absolute;
  inset: 0 0 auto;
  height: 30%;
  background: linear-gradient(180deg, var(--night-top) 0%, var(--night-mid) 58%, var(--dusk) 100%);
  overflow: hidden;
}

#loading-screen .loading-stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 28% 50%, #ffe9b0 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 46% 16%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 62% 40%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 24%, #ffe9b0 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 52%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 36% 70%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 70% 66%, #fff 50%, transparent 51%);
  animation: hud-twinkle 4s steps(2) infinite;
}

#loading-screen .loading-moon {
  position: absolute;
  right: 14%;
  top: 18%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 26px 6px rgba(255, 215, 107, 0.35);
}

#loading-screen .loading-moon::after {
  content: "";
  position: absolute;
  right: -6px;
  top: -3px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--night-mid);
}

#loading-screen .loading-horizon {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(30% - 14px);
  z-index: 3;
  height: 16px;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 5px,
      #3c5a23 5px 6px,
      transparent 6px 11px,
      #4d6e2c 11px 12px
    );
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 55%);
  mask-image: linear-gradient(180deg, transparent 0, #000 55%);
}

#loading-screen .loading-ground {
  position: absolute;
  left: 0;
  right: 0;
  top: 30%;
  bottom: 0;
  background:
    linear-gradient(180deg, var(--soil-1) 0%, var(--soil-2) 26%, var(--soil-3) 55%, var(--soil-4) 80%, var(--soil-deep) 100%);
}

#loading-screen .loading-ground::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(0, 0, 0, 0.22) 1px, transparent 1.4px),
    radial-gradient(rgba(255, 220, 150, 0.1) 1px, transparent 1.4px);
  background-position: 0 0, 3px 3px;
  background-size: 6px 6px, 6px 6px;
  mix-blend-mode: overlay;
  opacity: 0.7;
}

#loading-screen .loading-tunnels {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

#loading-screen .loading-tunnel,
#loading-screen .loading-chamber {
  position: absolute;
  display: block;
  background: var(--soil-deep);
  box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.5), inset 0 -2px 0 rgba(255, 200, 120, 0.06);
}

#loading-screen .loading-tunnel {
  border-radius: 2px;
}

#loading-screen .loading-tunnel-main {
  left: 50%;
  top: 30%;
  width: 5px;
  height: 28%;
}

#loading-screen .loading-tunnel-left {
  left: 22%;
  top: 45%;
  width: 28%;
  height: 4px;
}

#loading-screen .loading-tunnel-right {
  left: 51%;
  top: 41%;
  width: 26%;
  height: 4px;
}

#loading-screen .loading-chamber {
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #1c1308 0%, var(--soil-deep) 70%);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.45), inset 0 3px 6px rgba(0, 0, 0, 0.6);
}

#loading-screen .loading-chamber-left {
  left: 15%;
  top: 51%;
  width: 42px;
  height: 28px;
}

#loading-screen .loading-chamber-right {
  right: 16%;
  top: 48%;
  width: 38px;
  height: 26px;
}

#loading-screen .loading-crown-room {
  position: absolute;
  left: 50%;
  top: 56%;
  z-index: 3;
  width: 84px;
  height: 60px;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 45%, #4a2f14 0%, #2a1809 70%);
  box-shadow: inset 0 0 0 2px rgba(255, 199, 64, 0.45), 0 0 30px 8px rgba(255, 199, 64, 0.2);
}

#loading-screen .loading-room-glow {
  position: absolute;
  inset: -30%;
  background: radial-gradient(circle, rgba(255, 199, 64, 0.3) 0%, transparent 60%);
  animation: hud-pulse 3.4s ease-in-out infinite;
}

#loading-screen .loading-queen {
  position: relative;
  width: 26px;
  height: 14px;
  border-radius: 50%;
  background: #2a1c10;
  box-shadow: 0 0 0 2px #160d06, 8px 0 0 -2px #2a1c10, -8px 0 0 -3px #2a1c10;
}

#loading-screen .loading-queen::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #221608;
  box-shadow: 0 0 0 2px #160d06;
}

#loading-screen .loading-queen::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -16px;
  width: 8px;
  height: 8px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px 3px rgba(255, 199, 64, 0.6);
  animation: hud-pulse 2.2s ease-in-out infinite;
}

#loading-screen .loading-ant {
  position: absolute;
  z-index: 4;
  width: 13px;
  height: 5px;
  pointer-events: none;
}

#loading-screen .loading-ant i {
  position: absolute;
  top: 0;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #20140a;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}

#loading-screen .loading-ant i:nth-child(1) {
  left: 0;
  top: 1px;
  width: 3px;
  height: 3px;
}

#loading-screen .loading-ant i:nth-child(2) {
  left: 4px;
}

#loading-screen .loading-ant i:nth-child(3) {
  left: 9px;
}

#loading-screen .loading-ant b {
  position: absolute;
  left: 4px;
  top: -2px;
  width: 6px;
  height: 9px;
  border-left: 1px solid #20140a;
  border-right: 1px solid #20140a;
  animation: hud-scuttle 0.18s steps(2) infinite;
}

#loading-screen .loading-ant-surface {
  top: calc(30% - 5px);
  animation: hud-walk-right 11s linear infinite;
}

#loading-screen .loading-ant-tunnel {
  top: 68%;
  animation: hud-walk-left 12s linear infinite;
  animation-delay: -7s;
}

#loading-screen .loading-ui {
  position: relative;
  z-index: 10;
  width: min(380px, calc(100vw - 36px));
  min-height: min(720px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  align-items: start;
  justify-items: center;
  padding: 26px 22px 22px;
  box-sizing: border-box;
  text-align: center;
}

#loading-screen .loading-badge {
  padding: 5px 10px;
  color: var(--hud-muted);
  background: rgba(8, 5, 2, 0.45);
  box-shadow: inset 0 0 0 2px rgba(244, 234, 210, 0.18);
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
}

#loading-screen .loading-badge b {
  color: var(--accent-green);
}

#loading-screen .loading-crown {
  position: relative;
  align-self: end;
  width: 54px;
  height: 30px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 10px rgba(255, 199, 64, 0.5));
}

#loading-screen .loading-crown-band,
#loading-screen .loading-crown-spike,
#loading-screen .loading-crown-jewel {
  position: absolute;
  display: block;
}

#loading-screen .loading-crown-band {
  left: 0;
  bottom: 0;
  width: 54px;
  height: 9px;
  background: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent-amber), inset 0 2px 0 var(--accent-strong);
}

#loading-screen .loading-crown-spike {
  bottom: 7px;
  width: 10px;
  background: var(--accent);
  box-shadow: inset 0 2px 0 var(--accent-strong), inset -2px 0 0 var(--accent-amber);
}

#loading-screen .loading-crown-spike.s1 {
  left: 0;
  height: 14px;
}

#loading-screen .loading-crown-spike.s2 {
  left: 22px;
  height: 22px;
}

#loading-screen .loading-crown-spike.s3 {
  right: 0;
  height: 14px;
}

#loading-screen .loading-crown-jewel {
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  box-shadow: 0 0 8px 2px rgba(95, 214, 196, 0.7);
}

#loading-screen .loading-crown-jewel.j1 {
  left: 2px;
  bottom: 16px;
}

#loading-screen .loading-crown-jewel.j2 {
  left: 24px;
  bottom: 26px;
  background: var(--accent-red);
  box-shadow: 0 0 8px 2px rgba(224, 86, 63, 0.6);
}

#loading-screen .loading-crown-jewel.j3 {
  right: 2px;
  bottom: 16px;
}

#loading-screen h1,
#loading-screen .loading-logo {
  margin: 0;
  max-width: 88vw;
  color: var(--accent);
  font-family: "Press Start 2P", "Lucida Console", monospace;
  font-size: 1.6rem;
  line-height: 1.18;
  text-transform: uppercase;
  text-shadow: 0 3px 0 var(--accent-amber), 0 6px 0 #6b3d10, 0 9px 14px rgba(0, 0, 0, 0.65);
}

#loading-screen .loading-logo span {
  display: block;
}

#loading-screen .loading-logo span + span {
  margin-top: 9px;
}

#loading-screen p,
#loading-screen .loading-tagline,
#loading-screen .loading-status {
  margin: 0;
}

#loading-screen .loading-tagline {
  max-width: 26ch;
  color: var(--hud-text);
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.9;
  text-transform: uppercase;
}

#loading-screen .loading-status {
  color: var(--hud-muted);
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.title-screen {
  position: fixed;
  inset: 0;
  z-index: 74;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--hud-text);
  background: #040201;
  pointer-events: auto;
  isolation: isolate;
}

.title-screen.is-hidden {
  display: none;
}

.title-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 36;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.22) 3px,
      rgba(0, 0, 0, 0.22) 3px
    ),
    radial-gradient(120% 130% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.62) 100%);
  mix-blend-mode: multiply;
}

#title-screen .title-scene {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--bg-deep);
  overflow: hidden;
}

.title-sky {
  position: absolute;
  inset: 0 0 auto;
  height: 30%;
  background: linear-gradient(180deg, var(--night-top) 0%, var(--night-mid) 58%, var(--dusk) 100%);
  overflow: hidden;
}

.title-stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 28% 50%, #ffe9b0 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 46% 16%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 62% 40%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 24%, #ffe9b0 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 52%, #fff 50%, transparent 51%);
  animation: hud-twinkle 4s steps(2) infinite;
}

.title-moon {
  position: absolute;
  right: 14%;
  top: 18%;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 26px 6px rgba(255, 215, 107, 0.35);
}

.title-moon::after {
  content: "";
  position: absolute;
  right: -6px;
  top: -3px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--night-mid);
}

.title-horizon {
  position: absolute;
  left: 0;
  right: 0;
  top: 28%;
  height: 5%;
  background: linear-gradient(180deg, rgba(229, 137, 77, 0.55), rgba(79, 48, 31, 0.15));
}

.title-ground {
  position: absolute;
  inset: 30% 0 0;
  background:
    linear-gradient(180deg, var(--soil-1) 0 16%, var(--soil-2) 16% 34%, var(--soil-3) 34% 62%, var(--soil-4) 62% 100%),
    repeating-linear-gradient(0deg, transparent 0 35px, rgba(0, 0, 0, 0.16) 36px, transparent 37px),
    repeating-linear-gradient(90deg, transparent 0 35px, rgba(0, 0, 0, 0.1) 36px, transparent 37px);
}

.title-ground::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(rgba(244, 234, 210, 0.12) 1px, transparent 1.4px),
    radial-gradient(rgba(0, 0, 0, 0.22) 1px, transparent 1.4px);
  background-position: 0 0, 3px 3px;
  background-size: 7px 7px;
  mix-blend-mode: overlay;
}

.title-tunnels,
.title-crown-room,
.title-ant,
.title-tunnel,
.title-chamber {
  position: absolute;
}

.title-tunnels {
  inset: 0;
  z-index: 2;
}

.title-tunnel {
  background: #211207;
  box-shadow: inset 0 0 0 1px rgba(255, 220, 160, 0.05), 0 0 0 2px rgba(0, 0, 0, 0.18);
}

.title-tunnel-main {
  left: 49%;
  top: 30%;
  width: 5px;
  height: 26%;
}

.title-tunnel-left {
  left: 20%;
  top: 44%;
  width: 30%;
  height: 4px;
}

.title-tunnel-right {
  left: 51%;
  top: 40%;
  width: 26%;
  height: 4px;
}

.title-tunnel-low {
  left: 18%;
  top: 68%;
  width: 58%;
  height: 4px;
}

.title-chamber {
  background: #1b0e06;
  border-radius: 50%;
  border: 2px solid #3a2515;
  box-shadow: inset 0 0 0 2px #0c0703;
}

.title-chamber-left {
  left: 12%;
  top: 50%;
  width: 36px;
  height: 25px;
}

.title-chamber-right {
  left: 72%;
  top: 48%;
  width: 34px;
  height: 24px;
}

.title-chamber-low {
  left: 52%;
  top: 70%;
  width: 38px;
  height: 26px;
}

.title-crown-room {
  left: 50%;
  top: 54%;
  z-index: 4;
  width: 82px;
  height: 58px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, rgba(255, 199, 64, 0.22), rgba(35, 19, 8, 0.95) 62%);
  border: 2px solid #6b451f;
  box-shadow: 0 0 26px rgba(255, 199, 64, 0.18), inset 0 0 0 3px #211207;
}

.title-room-glow {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 199, 64, 0.48), transparent 62%);
  animation: hud-pulse 2.6s ease-in-out infinite;
}

.title-queen {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 24px;
  height: 13px;
  transform: translate(-50%, -15%);
  border-radius: 50%;
  background: #2a1c10;
  box-shadow: 0 0 0 2px #160d06;
}

.title-queen::before {
  content: "";
  position: absolute;
  left: -11px;
  top: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #221608;
  box-shadow: 0 0 0 2px #160d06;
}

.title-queen::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -15px;
  width: 7px;
  height: 7px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px 3px rgba(255, 199, 64, 0.65);
}

.title-ant {
  z-index: 5;
  width: 18px;
  height: 8px;
  animation: hud-walk-right 11s linear infinite;
}

.title-ant i {
  position: absolute;
  top: 2px;
  width: 6px;
  height: 5px;
  border-radius: 50%;
  background: #110a05;
}

.title-ant i:nth-child(1) {
  left: 0;
}

.title-ant i:nth-child(2) {
  left: 6px;
}

.title-ant i:nth-child(3) {
  left: 12px;
}

.title-ant b {
  position: absolute;
  left: 2px;
  top: 0;
  width: 14px;
  height: 8px;
  border-top: 1px solid #050302;
  border-bottom: 1px solid #050302;
  animation: hud-scuttle 0.18s steps(2) infinite;
}

.title-ant em {
  position: absolute;
  right: -3px;
  top: 1px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.title-ant-surface {
  top: calc(30% - 5px);
}

.title-ant-tunnel {
  top: 68%;
  animation-name: hud-walk-left;
  animation-delay: -6s;
}

.title-ui {
  position: relative;
  z-index: 12;
  width: min(380px, calc(100vw - 32px));
  min-height: min(720px, calc(100vh - 30px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: start;
  justify-items: center;
  padding: 22px 18px 18px;
  box-sizing: border-box;
}

.title-badge {
  padding: 5px 10px;
  color: var(--hud-muted);
  background: rgba(8, 5, 2, 0.48);
  box-shadow: inset 0 0 0 1px rgba(244, 234, 210, 0.18);
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
}

.title-badge b {
  color: var(--accent-green);
}

.title-wordmark {
  align-self: center;
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.title-crown {
  position: relative;
  width: 54px;
  height: 30px;
  filter: drop-shadow(0 0 10px rgba(255, 199, 64, 0.5));
}

.title-crown-band,
.title-crown-spike,
.title-crown-jewel {
  position: absolute;
  display: block;
}

.title-crown-band {
  left: 0;
  bottom: 0;
  width: 54px;
  height: 9px;
  background: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent-amber), inset 0 2px 0 var(--accent-strong);
}

.title-crown-spike {
  bottom: 7px;
  width: 10px;
  background: var(--accent);
  box-shadow: inset 0 2px 0 var(--accent-strong), inset -2px 0 0 var(--accent-amber);
}

.title-crown-spike.s1 {
  left: 0;
  height: 14px;
}

.title-crown-spike.s2 {
  left: 22px;
  height: 22px;
}

.title-crown-spike.s3 {
  right: 0;
  height: 14px;
}

.title-crown-jewel {
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  box-shadow: 0 0 8px 2px rgba(95, 214, 196, 0.7);
}

.title-crown-jewel.j1 {
  left: 2px;
  bottom: 16px;
}

.title-crown-jewel.j2 {
  left: 24px;
  bottom: 26px;
  background: var(--accent-red);
  box-shadow: 0 0 8px 2px rgba(224, 86, 63, 0.6);
}

.title-crown-jewel.j3 {
  right: 2px;
  bottom: 16px;
}

.title-wordmark h1 {
  margin: 0;
  color: var(--accent);
  font-family: "Press Start 2P", "Lucida Console", monospace;
  font-size: clamp(1.4rem, 7vw, 1.9rem);
  line-height: 1.18;
  text-transform: uppercase;
  text-shadow: 0 3px 0 var(--accent-amber), 0 6px 0 #6b3d10, 0 9px 14px rgba(0, 0, 0, 0.65);
}

.title-wordmark h1 span {
  display: block;
}

.title-wordmark h1 span + span {
  margin-top: 9px;
}

.title-wordmark p {
  margin: 0;
  max-width: 26ch;
  color: var(--hud-text);
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-size: 0.62rem;
  line-height: 1.9;
  text-transform: uppercase;
}

.title-menu {
  width: 100%;
  max-width: 340px;
  display: grid;
  gap: 10px;
}

.title-menu-grid,
.title-panel-actions,
.title-difficulty-row {
  display: grid;
  gap: 9px;
}

.title-menu-grid,
.title-panel-actions {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.title-button,
.title-difficulty-row button,
.title-settings-list button,
.title-panel-head button {
  min-height: 44px;
  border: 1px solid var(--hud-line);
  border-radius: var(--radius);
  color: var(--hud-text);
  background: rgba(36, 30, 23, 0.86);
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
}

.title-button {
  width: 100%;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  text-align: left;
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.title-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  box-shadow: inset 0 0 0 1px rgba(244, 234, 210, 0.1);
}

.title-button-primary {
  color: var(--ink);
  background: var(--accent);
  border-color: rgba(26, 18, 11, 0.32);
  box-shadow: inset 2px 2px 0 var(--accent-strong), inset -3px -3px 0 var(--accent-amber), 0 3px 0 #7a4a0c;
}

.title-button-ghost {
  background: rgba(20, 13, 7, 0.62);
}

a.title-button {
  text-decoration: none;
}

.title-glyph {
  color: var(--accent);
  text-align: center;
}

.title-button-primary .title-glyph {
  color: var(--ink);
}

.title-key {
  padding: 2px 6px;
  border: 1px solid rgba(244, 234, 210, 0.26);
  border-radius: 5px;
  font-size: 0.62rem;
}

.title-savebar {
  min-height: 18px;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--hud-muted);
  font-family: "VT323", "Lucida Console", monospace;
  font-size: 1rem;
}

.title-panel-scrim {
  position: absolute;
  inset: 0;
  z-index: 42;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(4, 2, 1, 0.74);
}

.title-panel-scrim.is-open {
  display: grid;
}

.title-panel {
  width: min(390px, 100%);
  max-height: min(86vh, 680px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--hud-line);
  border-radius: var(--radius);
  background: rgba(26, 21, 15, 0.96);
  box-shadow: var(--shadow);
}

.title-panel-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--hud-line);
  background: rgba(36, 30, 23, 0.92);
}

.title-panel-head h2 {
  margin: 0;
  color: var(--accent);
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.title-panel-head button {
  width: 44px;
  min-height: 44px;
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-weight: 700;
}

.title-panel-body {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 13px;
  padding: 14px;
  color: var(--hud-text);
  font-family: "VT323", "Lucida Console", monospace;
  font-size: 1.08rem;
  line-height: 1.35;
}

.title-panel-body p {
  margin: 0;
  color: var(--hud-muted);
}

.title-difficulty-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.title-difficulty-row button {
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 8px 4px;
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-size: 0.62rem;
  text-transform: uppercase;
}

.title-difficulty-row button span {
  color: var(--hud-muted);
  font-family: "VT323", "Lucida Console", monospace;
  font-size: 0.92rem;
  text-transform: none;
}

.title-difficulty-row button.is-selected {
  color: var(--ink);
  background: var(--accent);
}

.title-difficulty-row button.is-selected span {
  color: rgba(26, 18, 11, 0.72);
}

.title-how-list div {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(36, 30, 23, 0.78);
  box-shadow: var(--shadow-inset);
}

.title-how-list b {
  color: var(--ink);
  background: var(--accent);
  border-radius: 5px;
  padding: 4px 5px;
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-size: 0.54rem;
  text-align: center;
  text-transform: uppercase;
}

.title-how-list span,
.title-credit-block span,
.title-credit-block small {
  color: var(--hud-muted);
}

.title-settings-list button {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  font-family: "Silkscreen", "Lucida Console", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.title-settings-list button b {
  color: var(--hud-muted);
  font-weight: 700;
}

.title-settings-list button.is-on b {
  color: var(--accent-green);
}

.title-credit-block {
  justify-items: center;
  text-align: center;
}

.title-credit-block b {
  color: var(--accent);
  font-family: "Press Start 2P", "Lucida Console", monospace;
  font-size: 0.92rem;
  text-transform: uppercase;
}

.title-screen.reduce-motion .title-stars,
.title-screen.reduce-motion .title-room-glow,
.title-screen.reduce-motion .title-ant,
.title-screen.reduce-motion .title-ant b {
  animation: none;
}

.title-screen.no-scanlines::after {
  background: radial-gradient(120% 130% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.62) 100%);
}

@media (max-width: 420px) {
  .title-ui {
    min-height: min(680px, calc(100vh - 24px));
    padding: 18px 14px 14px;
  }

  .title-wordmark h1 {
    font-size: 1.35rem;
  }

  .title-menu {
    gap: 8px;
  }

  .title-button {
    min-height: 44px;
    font-size: 0.68rem;
  }
}

.loading-mark {
  display: none;
}

@keyframes hud-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes hud-twinkle {
  50% {
    opacity: 0.45;
  }
}

@keyframes hud-scuttle {
  50% {
    transform: scaleY(0.7);
  }
}

@keyframes hud-walk-right {
  0% {
    left: -16px;
    transform: scaleX(1);
  }

  100% {
    left: 102%;
    transform: scaleX(1);
  }
}

@keyframes hud-walk-left {
  0% {
    left: 102%;
    transform: scaleX(-1);
  }

  100% {
    left: -16px;
    transform: scaleX(-1);
  }
}

@keyframes hud-pulse {
  50% {
    opacity: 0.72;
    transform: translateY(2px);
  }
}

button {
  font: inherit;
}

.panel-heading,
.colony-title,
.resource-label,
.hud-control-button,
.speed-button,
.modal-close,
.build-label,
.placement-title,
.placement-build,
.placement-cancel,
.command-tab,
.command-close,
.command-new-colony,
.action-title,
.status-label,
.objective-label,
.priority-label,
.priority-slider-label,
.guide-label,
.mobile-guide-mode,
.mobile-action-button,
.mobile-action-chip {
  font-family: var(--f-disp);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.build-hotkey {
  font-family: var(--f-mono);
}

.hud-shell {
  font-family: var(--f-ui);
}

.ui-icon {
  width: 17px;
  height: 17px;
  display: inline-block;
  vertical-align: middle;
  pointer-events: none;
}

.resource-icon .ui-icon {
  width: 14px;
  height: 14px;
}

.colony-mark .ui-icon {
  width: 19px;
  height: 19px;
}

.hud-control-button .ui-icon {
  width: 18px;
  height: 18px;
}

.build-icon .ui-icon {
  width: 17px;
  height: 17px;
}

.hud-shell {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  display: grid;
  grid-template-columns: minmax(240px, 318px) 1fr;
  grid-template-rows: auto 1fr auto;
  gap: var(--gap);
  padding: 12px;
  box-sizing: border-box;
}

.hud-resource-bar,
.build-panel,
.placement-bar,
.status-panel,
.command-sheet,
.help-modal,
.toast {
  pointer-events: auto;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--cmd-shadow-sm);
}

.toast {
  pointer-events: none;
}

.hud-resource-bar,
.build-panel,
.command-sheet {
  position: relative;
}

.hud-resource-bar::before,
.build-panel::before,
.command-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 236, 205, 0.05);
}

.hud-resource-bar > *,
.build-panel > *,
.command-sheet > * {
  position: relative;
  z-index: 1;
}

.hud-resource-bar {
  grid-column: 1 / -1;
  min-height: 88px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--r);
  background: var(--panel);
}

.mission-ribbon {
  grid-column: 1 / -1;
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 11px;
  min-height: 28px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-sm);
  background: var(--panel);
}

.mission-tag,
.mission-progress {
  font-family: var(--f-disp);
  font-weight: 700;
  text-transform: uppercase;
}

.mission-tag {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 5px;
  color: #231603;
  background: var(--gold);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  line-height: 1;
}

.mission-copy {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-family: var(--f-ui);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.15;
}

.mission-progress {
  color: var(--teal-soft);
  font-family: var(--f-mono);
  font-size: 0.75rem;
  font-weight: 600;
}

.mission-endgame {
  min-width: 0;
  max-width: 44ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gold);
  font-family: var(--f-mono);
  font-size: 0.72rem;
  font-weight: 600;
}

.mission-ribbon.is-complete {
  border-left-color: var(--teal);
}

.mission-ribbon.is-complete .mission-tag {
  background: var(--teal);
  color: #06201c;
}

.colony-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 118px;
  padding: 7px 12px 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: var(--cmd-shadow-sm);
}

.colony-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.colony-mark,
.resource-icon,
.build-icon {
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  border: 0;
  background: rgba(255, 236, 205, 0.06);
  color: var(--gold);
  font-weight: 700;
}

.colony-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--gold);
  border: 1px solid var(--gold-deep);
  background: linear-gradient(160deg, #3a2a14, #241708);
  font-family: var(--f-disp);
  font-size: 0.7rem;
  box-shadow: inset 0 1px 0 rgba(255, 216, 132, 0.2);
}

.colony-title {
  color: var(--dim);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}

.colony-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-family: var(--f-disp);
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.resource-list {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.resource-item {
  flex: 0 0 auto;
  min-width: 88px;
  position: relative;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 8px;
  border-radius: var(--r-sm);
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}

.resource-item.is-low {
  border-color: rgba(239, 102, 71, 0.4);
}

.resource-item.is-low .resource-icon {
  color: var(--rival);
  background: rgba(239, 102, 71, 0.12);
}

.resource-item.is-low .resource-value {
  color: var(--rival-soft);
}

.resource-icon {
  width: 24px;
  height: 24px;
  color: var(--gold);
  background: rgba(255, 236, 205, 0.06);
  font-size: 0.56rem;
}

.resource-item[data-resource="queenHealth"],
.resource-item[data-resource="territory"],
.resource-item[data-resource="rival"] {
  min-width: 122px;
  grid-template-columns: minmax(0, 1fr);
  align-self: stretch;
  padding: 6px 10px 13px;
}

.resource-item[data-resource="queenHealth"] .resource-icon,
.resource-item[data-resource="territory"] .resource-icon,
.resource-item[data-resource="rival"] .resource-icon {
  display: none;
}

.resource-item[data-resource="queenHealth"]::after,
.resource-item[data-resource="territory"]::after,
.resource-item[data-resource="rival"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 6px;
  height: 4px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--resource-gauge, var(--gold)) var(--resource-percent, 0%), #0c0805 0);
}

.resource-item[data-resource="queenHealth"] {
  --resource-gauge: var(--gold);
}

.resource-item[data-resource="territory"] {
  --resource-gauge: var(--teal);
}

.resource-item[data-resource="rival"] {
  --resource-gauge: var(--rival);
}

.resource-item[data-resource="queenHealth"] .resource-copy,
.resource-item[data-resource="territory"] .resource-copy,
.resource-item[data-resource="rival"] .resource-copy {
  flex-direction: row;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.resource-item[data-resource="queenHealth"] .resource-value,
.resource-item[data-resource="territory"] .resource-value,
.resource-item[data-resource="rival"] .resource-value {
  font-family: var(--f-mono);
  font-size: 0.82rem;
}

.resource-item[data-resource="queenHealth"] .resource-value {
  color: var(--gold-soft);
}

.resource-item[data-resource="territory"] .resource-value {
  color: var(--teal-soft);
}

.resource-item[data-resource="rival"] .resource-value {
  color: var(--rival-soft);
}

.resource-copy {
  min-width: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  line-height: 1;
}

.resource-label {
  color: var(--faint);
  font-size: 0.54rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.resource-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--f-disp);
  font-size: 1.02rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}

.hud-controls,
.speed-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hud-control-button,
.speed-button,
.modal-close {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--dim);
  background: var(--panel);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.08s;
}

.hud-control-button:hover,
.speed-button:hover,
.modal-close:hover {
  border-color: var(--line-2);
  color: var(--text);
  background: var(--raise);
}

.hud-control-button:active,
.speed-button:active {
  transform: translateY(1px);
}

.hud-control-button.is-active {
  color: #231603;
  background: var(--gold);
  border-color: var(--gold-soft);
  box-shadow: 0 0 16px rgba(244, 183, 64, 0.4);
}

.speed-group {
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
}

.speed-button {
  min-width: 34px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: var(--f-disp);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.speed-button + .speed-button {
  border-left: 1px solid var(--line);
}

.speed-button.is-active {
  color: #06201c;
  background: var(--teal);
}

.hud-control-button.sound-toggle.is-muted {
  color: var(--faint);
  opacity: 0.55;
}

.build-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 19;
  max-width: min(640px, 62vw);
  overflow: visible;
  display: block;
  border: 0;
  border-radius: var(--r);
  background: transparent;
  box-shadow: none;
}

.panel-heading {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 13px;
  border-bottom: 1px solid var(--line);
  color: var(--gold-soft);
  background: linear-gradient(180deg, rgba(58, 42, 20, 0.5), transparent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.panel-hint {
  color: var(--faint);
  font-weight: 700;
}

.build-panel .panel-heading {
  display: none;
}

.build-list {
  min-height: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.build-list::-webkit-scrollbar {
  display: none;
}

.build-button {
  position: relative;
  flex: 0 0 auto;
  width: 80px;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: start;
  gap: 5px;
  padding: 26px 6px 8px;
  color: var(--text);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-2);
  cursor: pointer;
  box-shadow: var(--cmd-shadow-sm);
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
}

.build-button:hover {
  color: var(--text);
  border-color: var(--line-3);
  background: var(--raise);
  transform: translateY(-2px);
}

.build-button:active {
  transform: translateY(0);
}

.build-button.is-selected {
  border-color: var(--gold-soft);
  background: linear-gradient(180deg, rgba(244, 183, 64, 0.22), rgba(244, 183, 64, 0.08));
  box-shadow: 0 0 18px rgba(244, 183, 64, 0.3), inset 0 0 0 1px rgba(244, 183, 64, 0.3);
}

.build-button.is-selected .build-icon {
  color: var(--gold-soft);
  background: rgba(244, 183, 64, 0.18);
}

.build-button.is-locked,
.build-button.is-unavailable,
.build-button:disabled {
  cursor: pointer;
  opacity: 0.5;
}

.build-button.is-locked .build-icon,
.build-button.is-unavailable .build-icon {
  color: var(--faint);
}

.build-hotkey {
  position: absolute;
  top: 5px;
  left: 6px;
  display: inline-grid;
  place-items: center;
  width: auto;
  height: auto;
  padding: 1px 4px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  color: var(--faint);
  background: transparent;
  font-size: 0.56rem;
  font-weight: 600;
}

.build-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-family: var(--f-disp);
  font-size: 0.82rem;
}

.build-copy {
  min-width: 0;
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 4px;
}

.build-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.build-description {
  display: none;
}

.build-cost {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  font-family: var(--f-mono);
  font-size: 0.66rem;
  line-height: 1.2;
}

.placement-bar {
  position: fixed;
  left: auto;
  right: 18px;
  bottom: 132px;
  z-index: 28;
  width: min(620px, 56vw);
  transform: none;
  min-height: 60px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) minmax(92px, auto);
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  box-sizing: border-box;
  border: 1px solid var(--gold-deep);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-sm);
  background: var(--panel-2);
  box-shadow: var(--cmd-shadow-sm);
}

.placement-bar.is-hidden {
  display: none;
}

.placement-bar.is-valid {
  box-shadow: var(--cmd-shadow-sm), 0 0 0 1px rgba(244, 183, 64, 0.45);
}

.placement-bar.is-invalid {
  border-color: var(--rival-deep);
  border-left-color: var(--rival);
  box-shadow: var(--cmd-shadow-sm), 0 0 0 1px rgba(239, 102, 71, 0.45);
}

.placement-cancel,
.placement-build {
  min-height: 40px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  color: var(--dim);
  background: var(--raise);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.placement-cancel {
  width: 36px;
}

.placement-cancel:hover {
  color: var(--text);
  background: #3c3324;
}

.placement-build {
  min-width: 92px;
  padding: 0 14px;
  color: #231603;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: var(--gold-soft);
  box-shadow: 0 4px 16px rgba(244, 183, 64, 0.28);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.placement-build:hover {
  background: linear-gradient(180deg, #ffe6a8, var(--gold-soft));
}

.placement-build:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  color: var(--dim);
  background: var(--raise);
  border-color: var(--line-2);
  box-shadow: none;
}

.placement-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.placement-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gold-soft);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.placement-status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 500;
}

.command-backdrop {
  position: fixed;
  inset: 0;
  z-index: 36;
  border: 0;
  background: rgba(4, 2, 1, 0.5);
  pointer-events: auto;
}

.command-backdrop.is-hidden {
  display: none;
}

.command-sheet {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 38;
  width: min(440px, 40vw);
  max-height: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 0;
  border-left: 1px solid var(--line-2);
  border-radius: 0;
  background: var(--panel-solid);
  box-shadow: -14px 0 40px rgba(0, 0, 0, 0.5);
}

.command-sheet.is-hidden {
  display: none;
}

.command-sheet-header {
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  padding: 14px 13px 8px;
  border-bottom: 1px solid var(--line);
  background: transparent;
  touch-action: none;
}

.command-tabs {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
}

.command-sheet-handle,
.command-tab,
.command-close {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--dim);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.command-sheet-handle {
  display: none;
  place-items: center;
  width: 38px;
  padding: 0;
}

.command-sheet-handle span {
  width: 22px;
  height: 4px;
  border-radius: 99px;
  background: #4a3a22;
}

.command-tab {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 6px;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

.command-tab:hover,
.command-close:hover {
  color: var(--text);
  border-color: var(--line-2);
}

.command-close {
  background: var(--raise);
  border-color: var(--line-2);
}

.command-tab.is-active {
  color: #231603;
  background: var(--gold);
  border-color: var(--gold-soft);
}

.command-sheet-body {
  min-height: 0;
  overflow: hidden;
}

.command-sheet.is-expanded .command-sheet-body {
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.command-pane,
.command-objectives-stack {
  display: none;
  max-height: 100%;
  overflow-y: auto;
}

.command-pane.is-active,
.command-objectives-stack.is-active {
  display: grid;
}

.command-objectives-stack {
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 6px;
}

.command-objectives-stack .alert-list {
  max-height: 112px;
  border-top: 1px solid var(--hud-line);
}

.command-status-stack {
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 8px;
}

.command-overview-map {
  position: relative;
  margin: 12px 13px 0;
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #0c0805;
  isolation: isolate;
}

.command-overview-map::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, var(--night-mid) 0 26%, transparent 26%),
    linear-gradient(180deg, transparent 0 26%, var(--soil-2) 26%, var(--soil-deep) 100%);
  opacity: 0.82;
}

.command-overview-map::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image:
    radial-gradient(rgba(255, 220, 150, 0.12) 1px, transparent 1.4px),
    radial-gradient(rgba(0, 0, 0, 0.22) 1px, transparent 1.4px);
  background-position: 0 0, 3px 3px;
  background-size: 6px 6px;
  mix-blend-mode: overlay;
}

.command-overview-map canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 94px;
  cursor: crosshair;
  touch-action: manipulation;
}

.overview-map-label {
  position: absolute;
  right: 8px;
  bottom: 7px;
  z-index: 3;
  max-width: 45%;
  color: var(--faint);
  font-family: var(--f-disp);
  font-size: 0.56rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: right;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
}

.action-list {
  display: grid;
  gap: 8px;
  padding: 12px 13px 0;
}

.command-new-colony {
  min-height: 42px;
  margin: 12px 13px 0;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  color: var(--text);
  background: var(--raise);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.command-new-colony:hover,
.command-new-colony:focus-visible {
  border-color: var(--line-3);
  background: #3c3324;
}

.action-button,
.action-empty {
  min-width: 0;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--raise);
  color: var(--text);
}

.action-button {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
}

.action-button:hover {
  border-color: var(--line-3);
  background: #3c3324;
}

.action-button:active {
  transform: translateY(1px);
}

.action-button.is-disabled {
  border-color: var(--line);
  background: rgba(38, 31, 23, 0.55);
  color: var(--dim);
  opacity: 0.7;
}

.action-main {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.action-title,
.action-cost {
  font-weight: 700;
}

.action-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
}

.action-copy {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  font-family: var(--f-ui);
  font-size: 0.8rem;
  font-weight: 500;
}

.action-cost {
  max-width: 128px;
  color: var(--gold-soft);
  font-family: var(--f-mono);
  font-size: 0.68rem;
  font-weight: 600;
  text-align: right;
}

.action-empty {
  padding: 10px 11px;
  color: var(--dim);
  font-family: var(--f-ui);
  font-size: 0.8rem;
}

.status-panel.selection-panel {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 18;
  width: 360px;
  min-height: 0;
  max-height: min(56vh, 460px);
  grid-template-rows: auto auto minmax(0, 1fr);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--panel-2);
  box-shadow: var(--cmd-shadow);
  overflow: hidden;
  animation: rise 0.2s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.status-panel.selection-panel.is-hidden {
  display: none;
}

.selection-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.selection-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-heading .selection-close {
  min-width: 30px;
  height: 28px;
  flex: 0 0 auto;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--raise);
}

.selection-info {
  display: grid;
  gap: 3px;
  padding: 9px 13px;
  color: var(--dim);
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
}

.selection-info.is-hidden {
  display: none;
}

.selection-info-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selection-action-list {
  min-height: 0;
  overflow-y: auto;
  padding: 0 13px 13px;
  scrollbar-width: thin;
}

.status-dock {
  display: none;
}

.status-panel {
  min-height: 126px;
  max-height: 224px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: var(--r);
  background: var(--panel-2);
}

.status-list,
.objective-list,
.alert-list,
.priority-list,
.guide-list {
  min-height: 0;
  overflow-y: auto;
  padding: 12px 13px;
  scrollbar-width: thin;
}

.status-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 16px;
  padding: 6px 13px 12px;
}

.status-item {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  padding: 10px 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.status-label {
  display: block;
  color: var(--dim);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.status-value {
  display: block;
  margin-top: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gold-soft);
  font-family: var(--f-mono);
  font-size: 0.84rem;
  font-weight: 600;
  text-align: right;
}

.status-item.is-warning .status-value {
  color: var(--gold);
}

.status-item.is-danger .status-label,
.status-item.is-danger .status-value {
  color: var(--rival-soft);
}

.objectives-panel {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.objective-list {
  display: grid;
  gap: 7px;
}

.objective-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

.objective-item.has-target {
  cursor: pointer;
  border: 1px solid rgba(244, 183, 64, 0.34);
  background: var(--panel-2);
}

.objective-item.has-target:hover,
.objective-item.has-target:focus-visible {
  outline: none;
  background: var(--raise);
  border-color: rgba(244, 183, 64, 0.7);
}

.objective-check {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: var(--raise);
  box-sizing: border-box;
}

.objective-item.is-complete .objective-check {
  border-color: var(--ok);
  background: var(--ok);
}

.objective-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.objective-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--gold-soft);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.objective-item.is-complete .objective-label {
  color: var(--faint);
  text-decoration: line-through;
}

.objective-detail {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--dim);
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
}

.objective-progress,
.priority-meter {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: #0c0805;
}

.objective-progress span,
.priority-meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--gold);
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.alert-list {
  display: grid;
  gap: 6px;
  padding-top: 0;
}

.alert-list.is-empty {
  display: none;
}

.alert-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid rgba(244, 183, 64, 0.3);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  background: rgba(244, 183, 64, 0.08);
  color: var(--gold-soft);
  font-family: var(--f-ui);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
}

.alert-tone {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.alert-danger {
  border-color: rgba(239, 102, 71, 0.3);
  border-left-color: var(--rival);
  background: rgba(239, 102, 71, 0.1);
  color: var(--rival-soft);
}

.alert-danger .alert-tone {
  background: var(--rival);
}

.alert-success {
  border-color: rgba(70, 205, 186, 0.3);
  border-left-color: var(--teal);
  background: rgba(70, 205, 186, 0.1);
  color: var(--teal-soft);
}

.alert-success .alert-tone {
  background: var(--teal);
}

.priority-list {
  display: grid;
  gap: 7px;
}

.priority-button {
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(72px, 1fr) minmax(70px, 1fr) 32px;
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.priority-button:hover,
.priority-button.is-active {
  background: var(--raise);
  border-color: rgba(70, 205, 186, 0.45);
}

.priority-slider-row {
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(68px, 0.8fr) minmax(110px, 1fr) 44px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel);
}

.priority-slider-help {
  grid-column: 1 / -1;
  margin-top: -2px;
  color: var(--dim);
  font-family: var(--f-ui);
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.3;
}

.priority-slider-row.is-active {
  background: rgba(70, 205, 186, 0.08);
  border-color: rgba(70, 205, 186, 0.45);
}

.priority-slider {
  width: 100%;
  accent-color: var(--gold);
}

.priority-slider-label,
.priority-slider-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.priority-slider-value {
  text-align: right;
  color: var(--gold-soft);
  font-family: var(--f-mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.guide-list {
  display: grid;
  gap: 8px;
}

.guide-item {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 11px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.guide-item:last-child {
  border-bottom: 0;
}

.guide-label {
  color: var(--teal-soft);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.guide-copy {
  color: var(--dim);
  font-family: var(--f-ui);
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.45;
}

.priority-label,
.priority-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.priority-value {
  text-align: right;
  color: var(--gold-soft);
  font-family: var(--f-mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.toast-stack {
  position: fixed;
  left: 50%;
  right: auto;
  top: auto;
  bottom: 90px;
  transform: translateX(-50%);
  z-index: 45;
  display: grid;
  gap: 8px;
  justify-items: center;
  width: max-content;
  max-width: min(420px, calc(100vw - 28px));
  pointer-events: none;
}

.hud-shell.has-command-sheet .toast-stack {
  left: max(14px, calc(50% - min(220px, 20vw)));
  transform: none;
  z-index: 37;
}

.mobile-guide {
  display: none;
  position: relative;
  isolation: isolate;
}

.mobile-guide::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  box-shadow:
    inset 2px 2px 0 rgba(255, 220, 160, 0.16),
    inset -3px -3px 0 rgba(0, 0, 0, 0.6);
}

.mobile-guide > * {
  position: relative;
  z-index: 1;
}

.mobile-action-strip {
  display: none;
}

.toast {
  transform: translateY(14px);
  opacity: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--teal);
  border-radius: 10px;
  color: var(--text);
  background: rgba(13, 10, 7, 0.96);
  box-shadow: var(--cmd-shadow);
  font-family: var(--f-disp);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: opacity 0.18s, transform 0.18s;
}

.toast-compact {
  min-height: 0;
  max-width: min(320px, calc(100vw - 16px));
  box-sizing: border-box;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 12px;
  font-size: 0.74rem;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  border-left-color: var(--teal);
}

.toast-warning {
  border-left-color: var(--gold);
}

.toast-danger {
  border-left-color: var(--rival);
}

.state-overlay {
  position: fixed;
  inset: 0;
  z-index: 58;
  display: grid;
  place-items: center;
  padding: max(22px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  pointer-events: auto;
  background: rgba(4, 2, 1, 0.8);
}

.state-overlay.is-hidden {
  display: none;
}

.state-card {
  width: min(420px, calc(100vw - 28px));
  max-height: min(84vh, 680px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--panel-solid);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  animation: rise 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.state-banner {
  padding: 22px 22px 18px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  background: radial-gradient(120% 120% at 50% 0%, rgba(244, 183, 64, 0.12), transparent 70%);
}

.state-lost .state-banner {
  background: radial-gradient(120% 120% at 50% 0%, rgba(239, 102, 71, 0.14), transparent 70%);
}

.state-eyebrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--dim);
  background: transparent;
  font-family: var(--f-disp);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.state-banner h2 {
  margin: 12px 0 0;
  color: var(--gold);
  font-family: var(--f-disp);
  font-size: clamp(1.4rem, 7vw, 1.9rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.08;
  text-transform: uppercase;
  text-shadow: 0 2px 0 var(--gold-deep);
}

.state-lost .state-banner h2 {
  color: var(--rival);
  text-shadow: 0 2px 0 var(--rival-deep);
}

.state-banner p {
  margin: 13px auto 0;
  max-width: 42ch;
  color: var(--text);
  font-family: var(--f-ui);
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.5;
}

.state-body {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  gap: 13px;
  padding: 15px;
  overscroll-behavior-y: contain;
}

.state-meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #0c0805;
}

.state-meter span {
  display: block;
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
}

.state-lost .state-meter span {
  background: linear-gradient(90deg, var(--rival-deep), var(--rival));
}

.state-won .state-meter span {
  background: linear-gradient(90deg, var(--teal-deep), var(--teal));
}

.state-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.state-stat {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 13px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raise);
}

.state-stat span {
  color: var(--dim);
  font-family: var(--f-disp);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.state-stat b {
  min-width: 0;
  overflow: hidden;
  color: var(--gold-soft);
  font-family: var(--f-disp);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.state-action {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 15px;
  border: 1px solid var(--line-2);
  border-radius: 11px;
  color: var(--text);
  background: var(--raise);
  font-family: var(--f-disp);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.25;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s, box-shadow 0.15s, transform 0.08s;
}

.state-action:hover {
  background: #3c3324;
}

.state-action:active {
  transform: translateY(1px);
}

.state-action span {
  color: var(--gold);
}

.state-action-primary {
  color: #231603;
  border-color: var(--gold-soft);
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  box-shadow: 0 6px 20px rgba(244, 183, 64, 0.3);
}

.state-action-primary:hover {
  background: linear-gradient(180deg, #ffe6a8, var(--gold-soft));
  box-shadow: 0 8px 26px rgba(244, 183, 64, 0.4);
}

.state-action-primary span {
  color: #231603;
}

.state-action:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

@keyframes rise {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  pointer-events: auto;
  background: rgba(4, 2, 1, 0.72);
}

.modal-overlay.is-hidden {
  display: none;
}

.help-modal {
  width: min(680px, 100%);
  max-height: min(86vh, 680px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--line-2);
  background: var(--panel-solid);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  animation: rise 0.22s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: radial-gradient(120% 120% at 50% 0%, rgba(244, 183, 64, 0.1), transparent 70%);
}

.modal-heading h2 {
  margin: 0;
  color: var(--gold);
  font-family: var(--f-disp);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.help-grid div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--raise);
}

.help-grid strong {
  color: var(--gold-soft);
  font-family: var(--f-disp);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.help-grid span {
  color: var(--dim);
  font-family: var(--f-ui);
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.4;
}

@media (max-width: 980px) {
  .hud-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto;
  }

  .hud-resource-bar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .status-panel.selection-panel {
    width: min(340px, 46vw);
  }

  .build-panel {
    max-width: min(560px, 72vw);
  }

  .command-sheet {
    width: min(440px, 56vw);
  }
}

@media (max-width: 620px), (max-width: 980px) and (max-height: 620px) {
  .hud-shell {
    display: block;
    padding: 0;
  }

  .status-panel.selection-panel {
    display: none;
  }

  .hud-resource-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: 0;
    display: flex;
    flex-wrap: wrap;
    align-content: start;
    grid-template-columns: none;
    gap: 6px;
    padding: max(10px, env(safe-area-inset-top)) 13px 13px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background:
      linear-gradient(180deg, rgba(8, 5, 2, 0.94) 0%, rgba(8, 5, 2, 0.6) 76%, transparent 100%);
  }

  .hud-resource-bar::before {
    display: none;
  }

  .colony-badge {
    order: -2;
    flex: 1 1 auto;
    min-width: 0;
  }

  .mission-ribbon {
    /* Op telefoon staat dezelfde missie in de vaste guide onderaan.
       Dubbel tonen maakte de bovenbalk bij rijke kolonies drie regels te hoog. */
    display: none;
    order: 3;
    flex: 1 1 100%;
    min-width: 0;
    padding: 6px 11px;
    gap: 9px;
  }

  .mission-copy {
    font-size: 0.82rem;
  }

  .hud-controls {
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    margin-left: auto;
    order: -1;
  }

  .hud-control-button {
    min-width: 40px;
    height: 40px;
  }

  .speed-button {
    min-width: 34px;
    height: 40px;
  }

  .mobile-guide {
    position: fixed;
    top: auto;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 122px);
    left: 13px;
    right: 13px;
    z-index: 24;
    min-height: 38px;
    max-height: 84px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "mode copy primary"
      "actions actions actions";
    align-items: center;
    gap: 9px;
    padding: 8px 11px;
    overflow: hidden;
    pointer-events: none;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--panel);
    box-shadow: var(--cmd-shadow-sm);
  }

  .hud-shell.has-placement .mobile-guide,
  .hud-shell.has-command-sheet .mobile-guide {
    display: none;
  }

  .hud-shell.has-placement .mission-ribbon {
    display: none;
  }

  .hud-shell.has-placement .colony-badge {
    flex: 1 1 calc(100% - 170px);
    max-width: calc(100% - 170px);
    gap: 8px;
    padding: 6px 10px 6px 7px;
  }

  .hud-shell.has-placement .colony-copy {
    gap: 2px;
  }

  .hud-shell.has-placement .colony-mark {
    width: 28px;
    height: 28px;
  }

  .hud-shell.has-placement .colony-title {
    font-size: 0.54rem;
    letter-spacing: 0.14em;
  }

  .hud-shell.has-placement .colony-subtitle {
    font-size: 0.92rem;
  }

  .hud-shell.has-mobile-action .mobile-guide {
    max-height: 132px;
    overflow: visible;
  }

  .mobile-guide-mode {
    grid-area: mode;
    padding: 5px 8px;
    border-radius: 6px;
    color: #06201c;
    background: var(--teal);
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
  }

  .mobile-guide-copy {
    grid-area: copy;
    min-width: 0;
    max-height: 2.5em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: var(--dim);
    font-family: var(--f-ui);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.25;
  }

  .mobile-action-strip {
    grid-area: actions;
    display: flex;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    pointer-events: auto;
    scrollbar-width: none;
    padding-bottom: 1px;
  }

  .mobile-action-strip::-webkit-scrollbar {
    display: none;
  }

  .mobile-action-strip.is-hidden {
    display: none;
  }

  .mobile-action-chip {
    flex: 0 0 auto;
    max-width: 136px;
    min-height: 34px;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    padding: 0 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    background: var(--raise);
    font-size: 0.6rem;
    font-weight: 600;
  }

  .mobile-action-chip.is-disabled {
    color: var(--faint);
    background: rgba(38, 31, 23, 0.55);
    border-color: var(--line);
  }

  .mobile-action-button {
    grid-area: primary;
    max-width: 124px;
    min-height: 44px;
    border: 1px solid var(--gold-soft);
    border-radius: 9px;
    padding: 0 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: auto;
    color: #231603;
    background: linear-gradient(180deg, var(--gold-soft), var(--gold));
    font-size: 0.6rem;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(244, 183, 64, 0.28);
  }

  .mobile-action-button.is-hidden {
    display: none;
  }

  .mobile-action-button.is-disabled {
    color: var(--dim);
    background: var(--raise);
    border-color: var(--line-2);
    box-shadow: none;
  }

  .hud-control-button[aria-label="Help"] {
    display: none;
  }

  .resource-list {
    order: 2;
    flex: 1 0 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .resource-item[data-resource="royals"],
  .resource-item[data-resource="satellites"],
  .resource-item[data-resource="surfaceFood"],
  .resource-item[data-resource="population"],
  .resource-item[data-resource="threat"],
  .resource-item[data-resource="fungus"],
  .resource-item[data-resource="water"],
  .resource-item[data-resource="clay"],
  .resource-item[data-resource="leaves"],
  .resource-item[data-resource="eggs"],
  .resource-item[data-resource="larvae"] {
    display: none;
  }

  .resource-item {
    min-width: 0;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 6px;
    padding: 5px 8px;
  }

  .resource-item[data-resource="queenHealth"] {
    order: -3;
  }

  .resource-item[data-resource="territory"] {
    order: -2;
  }

  .resource-item[data-resource="rival"] {
    order: -1;
  }

  .resource-item[data-resource="queenHealth"],
  .resource-item[data-resource="territory"],
  .resource-item[data-resource="rival"] {
    width: auto;
    min-width: 0;
    padding: 5px 9px 12px;
  }

  .hud-shell.has-placement .resource-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hud-shell.has-placement .resource-item[data-resource="eggs"],
  .hud-shell.has-placement .resource-item[data-resource="larvae"] {
    display: none;
  }

  .resource-item[data-resource="queenHealth"] .resource-label,
  .resource-item[data-resource="territory"] .resource-label,
  .resource-item[data-resource="rival"] .resource-label {
    display: block;
    font-size: 0.52rem;
    color: var(--dim);
  }

  .resource-icon {
    width: 22px;
    height: 22px;
    font-size: 0.56rem;
  }

  .resource-label {
    font-size: 0.5rem;
  }

  .resource-value {
    font-size: 0.94rem;
    line-height: 1;
  }

  .build-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: 122px;
    display: block;
    touch-action: pan-x;
    border-radius: 0;
    background:
      linear-gradient(0deg, rgba(8, 5, 2, 0.95) 0%, rgba(8, 5, 2, 0.55) 72%, transparent 100%);
  }

  .build-panel::before {
    display: none;
  }

  .placement-bar {
    left: 13px;
    right: 13px;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 118px);
    width: auto;
    min-height: 60px;
    transform: none;
    grid-template-columns: 36px minmax(0, 1fr) minmax(88px, auto);
  }

  .hud-shell.has-placement .build-panel {
    display: none;
  }

  .hud-shell.has-placement .placement-bar {
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .build-panel .panel-heading {
    display: none;
  }

  .build-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(76px, 1fr);
    justify-content: start;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 13px max(10px, env(safe-area-inset-bottom));
    scrollbar-width: none;
    touch-action: pan-x;
  }

  .build-list::-webkit-scrollbar {
    display: none;
  }

  .build-button {
    width: auto;
    min-height: 0;
    grid-template-columns: 1fr;
    justify-items: center;
    align-content: start;
    gap: 5px;
    padding: 24px 5px 7px;
    text-align: center;
  }

  .build-icon {
    width: 30px;
    height: 30px;
    font-family: var(--f-disp);
    font-size: 0.78rem;
  }

  .build-copy {
    width: 100%;
    display: grid;
    justify-items: center;
    gap: 2px;
  }

  .build-label,
  .build-cost {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .build-label {
    font-size: 0.58rem;
    line-height: 1.15;
  }

  .build-description {
    display: none;
  }

  .build-cost {
    font-size: 0.64rem;
    line-height: 1.2;
  }

  .command-sheet {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    max-height: min(80vh, 560px);
    border: 0;
    border-top: 1px solid var(--line-2);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.55);
  }

  .command-sheet-header {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    padding: 9px 13px 8px;
  }

  .command-sheet-handle {
    display: grid;
  }

  .command-sheet.is-expanded {
    max-height: calc(100vh - max(96px, env(safe-area-inset-top) + 88px));
  }

  .command-sheet-body {
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .command-sheet .command-pane,
  .command-sheet .command-objectives-stack {
    max-height: none;
    overflow: visible;
  }

  .command-backdrop {
    background: rgba(4, 2, 1, 0.42);
  }

  .hud-shell.has-command-sheet .build-panel,
  .hud-shell.has-command-sheet .placement-bar,
  .hud-shell.has-command-sheet .status-dock {
    display: none;
  }

  .command-sheet .priority-list {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    grid-template-columns: 1fr;
    overflow-x: hidden;
    overflow-y: visible;
    padding-bottom: 14px;
  }

  .command-tab {
    min-height: 44px;
    padding: 0 4px;
    font-size: 0.62rem;
  }

  .action-button {
    min-height: 54px;
    padding: 8px;
    grid-template-columns: minmax(0, 1fr) minmax(58px, auto);
  }

  .action-copy {
    font-size: 0.9rem;
  }

  .action-cost {
    max-width: 96px;
    font-size: 0.86rem;
  }

  .priority-slider-row {
    min-height: 64px;
    grid-template-columns: minmax(0, 0.78fr) minmax(112px, 1fr) 40px;
    gap: 8px;
  }

  .priority-slider-help,
  .guide-copy {
    font-size: 0.9rem;
  }

  .priority-button {
    min-height: 44px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 5px auto;
    gap: 3px;
    justify-items: stretch;
    padding: 6px;
  }

  .priority-label,
  .priority-value {
    font-size: 0.64rem;
    text-align: center;
  }

  .priority-value {
    font-size: 0.92rem;
  }

  .status-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .objectives-panel {
    max-height: 154px;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  .toast-stack {
    left: 50%;
    right: auto;
    top: auto;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 184px);
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 26px);
    display: grid;
    justify-items: center;
    gap: 6px;
  }

  .hud-shell.has-placement .toast-stack {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 84px);
  }

  .hud-shell.has-command-sheet .toast-stack {
    left: 50%;
    transform: translateX(-50%);
    top: auto;
    bottom: calc(min(80vh, 560px) + 12px);
    z-index: 37;
  }

  .toast {
    display: block;
    min-height: 0;
    max-width: min(82vw, 340px);
    padding: 9px 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
    line-height: 1.25;
  }

  .placement-title,
  .placement-status {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    line-height: 1.18;
  }

  .placement-title {
    -webkit-line-clamp: 1;
  }

  .placement-status {
    -webkit-line-clamp: 2;
    max-height: 2.4em;
  }

  .command-sheet .status-list {
    grid-template-columns: 1fr;
  }

  .command-sheet .status-value {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.18;
    font-size: 0.86rem;
  }
}

@media (max-width: 520px) {
  #loading-screen .loading-ui {
    min-height: min(680px, calc(100vh - 28px));
    padding: 22px 18px 18px;
  }

  #loading-screen .loading-logo {
    font-size: 1.3rem;
  }

  #loading-screen .loading-tagline {
    max-width: 22ch;
  }
}

@media (prefers-reduced-motion: reduce) {
  #loading-screen .loading-stars,
  #loading-screen .loading-room-glow,
  #loading-screen .loading-queen::after,
  #loading-screen .loading-ant,
  #loading-screen .loading-ant b {
    animation: none;
  }
}

@media (max-width: 980px) and (max-height: 620px) {
  .mission-ribbon {
    display: none;
  }

  .mobile-guide {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 102px);
    min-height: 30px;
    max-height: 58px;
    padding: 6px 9px;
  }

  .hud-shell.has-mobile-action .mobile-guide {
    max-height: 104px;
  }

  .mobile-guide-copy {
    -webkit-line-clamp: 1;
    max-height: 1.25em;
  }

  .mobile-action-button {
    min-height: 34px;
    max-width: 118px;
  }

  .mobile-action-chip {
    min-height: 30px;
    max-width: 126px;
  }

  .build-panel {
    max-height: 102px;
  }

  .build-list {
    grid-auto-columns: minmax(72px, 1fr);
    padding: 6px 13px max(8px, env(safe-area-inset-bottom));
  }

  .build-button {
    padding: 20px 5px 6px;
  }

  .build-icon {
    width: 26px;
    height: 26px;
  }

  .placement-bar {
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 100px);
    min-height: 52px;
    grid-template-columns: 36px minmax(0, 1fr) minmax(82px, auto);
  }

  .command-sheet {
    max-height: min(78vh, 360px);
  }

  .command-sheet.is-expanded {
    max-height: calc(100vh - max(70px, env(safe-area-inset-top) + 62px));
  }

  .toast-stack {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 160px);
  }

  .hud-shell.has-placement .toast-stack {
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 72px);
  }

  .hud-shell.has-command-sheet .toast-stack {
    bottom: calc(min(78vh, 360px) + 12px);
  }
}

@media (max-width: 420px) {
  .hud-controls {
    gap: 5px;
  }

  .hud-control-button {
    min-width: 38px;
    height: 38px;
  }

  .speed-button {
    min-width: 30px;
    height: 38px;
  }
}
