/* WAR · strategic atlas UI */
:root {
  color-scheme: dark;
  --ink-950: #080c12;
  --ink-925: #0b1119;
  --ink-900: #0e151f;
  --ink-850: #121b27;
  --ink-800: #182330;
  --ink-750: #202d3c;
  --ink-700: #293748;
  --line: rgba(213, 224, 235, 0.12);
  --line-strong: rgba(213, 224, 235, 0.21);
  --paper: #e9e7de;
  --paper-deep: #dcd9cf;
  --paper-grid: rgba(29, 43, 51, 0.055);
  --text: #f3f5f5;
  --text-soft: #bac4cb;
  --text-muted: #7f8d98;
  --gold: #d6ad5c;
  --gold-bright: #f0ca7a;
  --gold-deep: #9b7435;
  --gold-wash: rgba(214, 173, 92, 0.14);
  --cyan: #62b7bd;
  --cyan-wash: rgba(98, 183, 189, 0.15);
  --red: #dd7169;
  --red-wash: rgba(221, 113, 105, 0.14);
  --green: #76b28c;
  --shadow-lg: 0 26px 72px rgba(0, 0, 0, 0.38);
  --shadow-md: 0 15px 38px rgba(0, 0, 0, 0.28);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 7px;
  --topbar-height: 58px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --font-ui: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-width: 300px;
  min-height: 100%;
  margin: 0;
}

html {
  background: var(--ink-950);
  font-family: var(--font-ui);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--ink-950);
}

body[data-app-state="game"] {
  overflow: hidden;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

button:not(:disabled),
select:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.34;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

svg {
  display: block;
}

[hidden] {
  display: none !important;
}

::selection {
  color: var(--ink-950);
  background: var(--gold-bright);
}

:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 10000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  color: var(--ink-950);
  background: var(--gold-bright);
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon-sprite symbol,
button svg,
.local-note svg,
.director-badge svg,
.view-selector > svg,
.active-tool-chip > svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell,
#main-content,
.screen {
  min-height: 100vh;
  min-height: 100dvh;
}

.screen {
  position: relative;
}

/* Main menu */
.menu-screen {
  isolation: isolate;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: calc(22px + var(--safe-top)) calc(38px + var(--safe-right)) calc(18px + var(--safe-bottom)) calc(38px + var(--safe-left));
  background:
    radial-gradient(circle at 17% 36%, rgba(50, 110, 116, 0.16), transparent 32%),
    radial-gradient(circle at 76% 73%, rgba(171, 126, 57, 0.09), transparent 31%),
    linear-gradient(138deg, #0b1119 0%, #080c12 54%, #0d131b 100%);
}

.menu-screen::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px);
  background-size: 88px 88px;
  mask-image: linear-gradient(90deg, #000, transparent 68%);
}

.menu-atmosphere,
.menu-grid {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
}

.menu-grid {
  opacity: 0.38;
  background-image:
    radial-gradient(circle at center, rgba(214, 173, 92, 0.55) 0 1px, transparent 1.5px),
    linear-gradient(35deg, transparent 49.8%, rgba(98, 183, 189, 0.05) 50%, transparent 50.2%);
  background-size: 44px 44px, 280px 280px;
  mask-image: radial-gradient(circle at 25% 52%, black, transparent 55%);
}

.menu-orbit {
  position: absolute;
  border: 1px solid rgba(205, 220, 224, 0.055);
  border-radius: 50%;
}

.menu-orbit::before,
.menu-orbit::after {
  position: absolute;
  width: 6px;
  height: 6px;
  content: "";
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 18px var(--gold);
}

.menu-orbit-one {
  top: -39vw;
  right: -34vw;
  width: 80vw;
  height: 80vw;
}

.menu-orbit-one::before {
  bottom: 20%;
  left: 9%;
}

.menu-orbit-two {
  right: -16vw;
  bottom: -43vw;
  width: 70vw;
  height: 70vw;
}

.menu-orbit-two::after {
  top: 14%;
  left: 19%;
  background: var(--cyan);
  box-shadow: 0 0 18px var(--cyan);
}

.menu-nav {
  z-index: 2;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  text-decoration: none;
}

.brand-mark {
  display: flex;
  align-items: end;
  gap: 2px;
  width: 20px;
  height: 18px;
}

.brand-mark i {
  display: block;
  width: 5px;
  background: var(--gold);
  transform: skew(-10deg);
}

.brand-mark i:nth-child(1) {
  height: 11px;
}

.brand-mark i:nth-child(2) {
  height: 18px;
}

.brand-mark i:nth-child(3) {
  height: 14px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--text-soft);
  background: transparent;
  border-radius: 9px;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.icon-button:not(:disabled):hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.icon-button:not(:disabled):active {
  transform: translateY(1px);
}

.quiet-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(12px);
}

.menu-layout {
  z-index: 1;
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: minmax(420px, 0.95fr) minmax(460px, 0.78fr);
  gap: clamp(56px, 8vw, 138px);
  align-items: center;
  width: min(1230px, 100%);
  margin: 0 auto;
  padding: 38px 16px 28px;
}

.hero-panel {
  max-width: 600px;
  animation: menu-rise 700ms var(--ease-out) both;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--gold-bright);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow > span {
  width: 27px;
  height: 1px;
  background: var(--gold);
}

.war-title {
  position: relative;
  display: flex;
  gap: 0.025em;
  width: max-content;
  margin: 7px 0 0 -0.04em;
  color: #f0f1ee;
  font-family: var(--font-display);
  font-size: clamp(7.2rem, 12vw, 11.8rem);
  font-stretch: condensed;
  font-weight: 900;
  letter-spacing: -0.08em;
  line-height: 0.84;
  text-shadow: 0 9px 40px rgba(0, 0, 0, 0.48);
}

.war-title::after {
  position: absolute;
  right: -26px;
  bottom: 0.085em;
  width: 7px;
  height: 7px;
  content: "";
  background: var(--gold-bright);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(240, 202, 122, 0.72);
}

.war-title span:nth-child(2) {
  color: transparent;
  -webkit-text-stroke: 2px rgba(240, 241, 238, 0.86);
}

.hero-copy {
  margin: 25px 0 17px;
  color: var(--text-soft);
  font-size: clamp(1.1rem, 2vw, 1.36rem);
  font-weight: 350;
  letter-spacing: -0.015em;
  line-height: 1.55;
}

.director-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  margin: 0 0 30px;
  padding: 7px 10px;
  color: #95a7af;
  border: 1px solid rgba(98, 183, 189, 0.2);
  background: rgba(98, 183, 189, 0.07);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.director-badge svg {
  width: 13px;
  height: 13px;
  color: var(--cyan);
}

.primary-actions {
  display: grid;
  gap: 10px;
  width: min(100%, 450px);
}

.action-button {
  position: relative;
  display: grid;
  grid-template-columns: 43px 1fr auto;
  gap: 13px;
  align-items: center;
  width: 100%;
  min-height: 66px;
  padding: 10px 17px 10px 12px;
  overflow: hidden;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  border-radius: 13px;
  text-align: left;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.13);
  transition: border-color 180ms ease, background 180ms ease, transform 180ms var(--ease-out), box-shadow 180ms ease;
}

.action-button::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0.07), transparent 34%);
  opacity: 0;
  transition: opacity 180ms ease;
}

.action-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.22);
  transform: translateY(-2px);
}

.action-button:hover::before {
  opacity: 1;
}

.action-button-primary {
  border-color: rgba(214, 173, 92, 0.4);
  background: linear-gradient(105deg, rgba(214, 173, 92, 0.19), rgba(214, 173, 92, 0.07));
}

.action-button-primary:hover {
  border-color: rgba(240, 202, 122, 0.67);
  background: linear-gradient(105deg, rgba(214, 173, 92, 0.27), rgba(214, 173, 92, 0.09));
}

.action-icon {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  color: var(--text-soft);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.16);
  border-radius: 10px;
}

.action-button-primary .action-icon {
  color: var(--gold-bright);
  border-color: rgba(214, 173, 92, 0.26);
  background: rgba(214, 173, 92, 0.11);
}

.action-icon svg {
  width: 20px;
  height: 20px;
}

.action-copy {
  display: grid;
  gap: 2px;
}

.action-copy strong {
  font-size: 0.88rem;
  letter-spacing: 0.005em;
}

.action-copy small {
  color: var(--text-muted);
  font-size: 0.68rem;
}

.action-arrow {
  color: var(--gold-bright);
  font-size: 1.1rem;
  transition: transform 180ms var(--ease-out);
}

.action-button:hover .action-arrow {
  transform: translateX(3px);
}

.saved-panel {
  position: relative;
  width: 100%;
  min-height: 410px;
  max-height: min(610px, 66vh);
  padding: 26px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(21, 31, 43, 0.9), rgba(12, 18, 26, 0.82));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), inset 0 1px rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(24px);
  animation: menu-rise 700ms 90ms var(--ease-out) both;
}

.saved-panel::before {
  position: absolute;
  top: -1px;
  left: 24px;
  width: 80px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.saved-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 0 1px 19px;
  border-bottom: 1px solid var(--line);
}

.saved-header .section-kicker {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.61rem;
}

.saved-header h2 {
  margin: 0;
  font-size: 1.12rem;
  letter-spacing: -0.025em;
}

.count-pill {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 23px;
  padding: 0 8px;
  color: var(--gold-bright);
  border: 1px solid rgba(214, 173, 92, 0.21);
  background: var(--gold-wash);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
}

.saved-games-list {
  display: grid;
  align-content: start;
  gap: 9px;
  max-height: calc(min(610px, 66vh) - 145px);
  min-height: 260px;
  padding: 14px 3px 5px 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: var(--ink-700) transparent;
  scrollbar-width: thin;
}

.empty-saves {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  min-height: 250px;
  padding: 24px;
  color: var(--text-muted);
  text-align: center;
}

.empty-saves-icon {
  display: grid;
  place-items: center;
  width: 59px;
  height: 59px;
  margin-bottom: 16px;
  color: #6f7e89;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 50%;
}

.empty-saves-icon svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
}

.empty-saves strong {
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: 0.84rem;
}

.empty-saves p {
  max-width: 270px;
  margin: 0;
  font-size: 0.69rem;
  line-height: 1.55;
}

.local-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 11px 0 0;
  color: #72818c;
  font-size: 0.62rem;
}

.local-note svg {
  width: 13px;
  height: 13px;
  color: var(--green);
}

.save-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px;
  min-width: 0;
  padding: 6px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.025);
  border-radius: 12px;
  transition: border-color 160ms ease, background 160ms ease;
}

.save-card:hover,
.save-card:focus-within {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.045);
}

.save-card-open {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.save-thumbnail {
  display: block;
  width: 78px;
  height: 50px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper-deep);
  border-radius: 7px;
}

.save-thumbnail canvas {
  width: 100%;
  height: 100%;
}

.save-meta {
  display: grid;
  min-width: 0;
}

.save-meta strong,
.save-meta small,
.save-meta time {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-meta strong {
  margin-bottom: 3px;
  font-size: 0.78rem;
}

.save-meta small,
.save-meta time {
  color: var(--text-muted);
  font-size: 0.61rem;
}

.save-meta time {
  margin-top: 4px;
  color: #687680;
}

.save-card-actions {
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 150ms ease;
}

.save-card:hover .save-card-actions,
.save-card:focus-within .save-card-actions {
  opacity: 1;
}

.save-card-actions button {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border-radius: 7px;
}

.save-card-actions button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.save-card-actions .danger-action:hover {
  color: var(--red);
  background: var(--red-wash);
}

.save-card-actions svg {
  width: 15px;
  height: 15px;
}

.menu-footer {
  z-index: 1;
  display: flex;
  flex: 0 0 auto;
  justify-content: space-between;
  color: #53616c;
  font-size: 0.61rem;
  letter-spacing: 0.035em;
}

.menu-footer b {
  color: var(--gold);
  font-weight: 800;
}

kbd {
  min-width: 20px;
  padding: 2px 5px;
  color: #84929b;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  border-radius: 4px;
  font-family: var(--font-ui);
  font-size: 0.58rem;
  line-height: 1;
  text-align: center;
}

@keyframes menu-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Game room */
.game-screen {
  position: fixed;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
}

.map-viewport {
  position: absolute;
  isolation: isolate;
  inset: 0;
  overflow: hidden;
  color: var(--ink-900);
  background:
    linear-gradient(90deg, var(--paper-grid) 1px, transparent 1px),
    linear-gradient(var(--paper-grid) 1px, transparent 1px),
    radial-gradient(circle at 50% 44%, #f0eee7 0%, var(--paper) 56%, #dcd9cf 100%);
  background-size: 40px 40px, 40px 40px, auto;
  cursor: default;
}

.map-viewport::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image: radial-gradient(circle at center, rgba(24, 35, 48, 0.1) 0 1px, transparent 1.2px);
  background-size: 8px 8px;
  opacity: 0.18;
  mix-blend-mode: multiply;
}

#map-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: 0;
}

#map-canvas[data-tool="pan"] {
  cursor: grab;
}

#map-canvas.is-panning {
  cursor: grabbing;
}

#map-canvas:focus-visible {
  box-shadow: inset 0 0 0 3px rgba(214, 173, 92, 0.72);
}

.map-empty-hint {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  width: min(440px, calc(100vw - 150px));
  padding: 26px;
  color: #607078;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -46%);
}

.map-empty-hint::before {
  position: absolute;
  z-index: -1;
  width: 400px;
  height: 220px;
  content: "";
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.78), transparent 70%);
}

.map-empty-hint .section-kicker {
  margin: 19px 0 8px;
  color: #8b7445;
}

.map-empty-hint h2 {
  margin: 0;
  color: #273640;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  font-weight: 850;
  letter-spacing: -0.025em;
  text-transform: uppercase;
}

.map-empty-hint > p:not(.section-kicker) {
  max-width: 360px;
  margin: 10px 0 14px;
  font-size: 0.75rem;
  line-height: 1.55;
}

.map-empty-hint strong {
  color: #374954;
}

.empty-map-emblem {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  color: #8b7445;
  border: 1px solid rgba(75, 86, 87, 0.19);
  border-radius: 50%;
}

.empty-map-emblem::before,
.empty-map-emblem::after,
.empty-map-emblem span {
  position: absolute;
  content: "";
  background: rgba(75, 86, 87, 0.17);
}

.empty-map-emblem::before {
  top: -15px;
  bottom: -15px;
  left: 50%;
  width: 1px;
}

.empty-map-emblem::after {
  top: 50%;
  right: -15px;
  left: -15px;
  height: 1px;
}

.empty-map-emblem span:first-child {
  inset: 8px;
  background: transparent;
  border: 1px dashed rgba(75, 86, 87, 0.2);
  border-radius: 50%;
}

.empty-map-emblem span:nth-child(2) {
  z-index: 1;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
}

.empty-map-emblem svg {
  z-index: 2;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}

.text-button {
  padding: 5px 3px;
  color: #806a3f;
  background: transparent;
  border-bottom: 1px solid rgba(128, 106, 63, 0.28);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  pointer-events: auto;
}

.text-button span {
  display: inline-block;
  margin-left: 5px;
  transition: transform 160ms ease;
}

.text-button:hover span {
  transform: translateX(3px);
}

.game-topbar {
  position: absolute;
  z-index: 50;
  top: calc(10px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  left: calc(10px + var(--safe-left));
  display: flex;
  align-items: stretch;
  height: var(--topbar-height);
  padding: 7px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(10, 15, 23, 0.94);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgba(8, 12, 18, 0.24), inset 0 1px rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(18px) saturate(125%);
}

.topbar-group {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.topbar-group + .topbar-group {
  margin-left: 8px;
  padding-left: 8px;
}

.topbar-group + .topbar-group::before {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 1px;
  content: "";
  background: var(--line);
}

.world-group {
  flex: 1 1 340px;
}

.topbar-button {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
}

.topbar-brand {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  margin: 0 10px 0 4px;
  color: var(--gold-bright);
  border: 1px solid rgba(214, 173, 92, 0.29);
  background: var(--gold-wash);
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 900;
}

.game-title-field {
  display: grid;
  min-width: 0;
}

#game-title-input {
  width: min(250px, 22vw);
  min-width: 110px;
  height: 21px;
  padding: 0 3px;
  overflow: hidden;
  color: var(--text);
  border: 0;
  background: transparent;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 750;
  text-overflow: ellipsis;
}

#game-title-input:hover,
#game-title-input:focus {
  background: rgba(255, 255, 255, 0.055);
  outline: 0;
}

.save-status {
  padding-left: 3px;
  color: #71808a;
  font-size: 0.57rem;
  line-height: 1.3;
}

.save-status[data-state="saving"] {
  color: var(--gold-bright);
}

.save-status[data-state="saved"] {
  color: var(--green);
}

.view-group {
  flex: 0 1 177px;
}

.view-selector {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 36px;
  color: var(--text-soft);
  border-radius: 8px;
}

.view-selector > svg:first-child {
  position: absolute;
  z-index: 1;
  left: 8px;
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.view-label {
  position: absolute;
  z-index: 1;
  left: 31px;
  color: var(--text-muted);
  font-size: 0.59rem;
  pointer-events: none;
  transform: translateY(-7px);
}

.view-selector select {
  width: 100%;
  height: 36px;
  padding: 10px 27px 0 31px;
  color: var(--text);
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  appearance: none;
  font-size: 0.68rem;
  font-weight: 700;
}

.view-selector select:hover,
.view-selector select:focus-visible {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
}

.select-chevron {
  position: absolute;
  right: 8px;
  width: 13px;
  height: 13px;
  color: var(--text-muted);
  pointer-events: none;
}

select option {
  color: var(--text);
  background: var(--ink-850);
}

.simulation-group {
  flex: 0 0 auto;
  gap: 2px;
}

.simulation-play {
  width: 35px;
  height: 35px;
  color: var(--ink-900);
  background: var(--gold-bright);
  border-radius: 9px;
}

.simulation-play:hover:not(:disabled) {
  color: var(--ink-950);
  background: #f6d792;
}

.simulation-play .pause-icon {
  display: none;
}

.simulation-play[aria-pressed="true"] .play-icon {
  display: none;
}

.simulation-play[aria-pressed="true"] .pause-icon {
  display: block;
}

.simulation-play[aria-pressed="true"] {
  color: #e7f3f4;
  background: #37787d;
  box-shadow: 0 0 0 3px rgba(98, 183, 189, 0.13);
}

.simulation-date {
  display: grid;
  min-width: 62px;
  padding: 0 7px;
  color: var(--text-muted);
  font-size: 0.56rem;
  line-height: 1.05;
  text-align: center;
}

.simulation-date strong {
  color: var(--text-soft);
  font-size: 0.67rem;
}

.speed-selector select {
  width: 42px;
  height: 28px;
  padding: 0 4px;
  color: var(--text-soft);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  border-radius: 7px;
  font-size: 0.62rem;
  font-weight: 750;
  text-align: center;
}

.file-group {
  flex: 0 0 auto;
}

.compact-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 750;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.compact-button:hover {
  border-color: rgba(214, 173, 92, 0.35);
  background: rgba(214, 173, 92, 0.11);
}

.compact-button:active {
  transform: translateY(1px);
}

.compact-button svg {
  width: 16px;
  height: 16px;
  color: var(--gold-bright);
}

.tool-rail {
  position: absolute;
  z-index: 45;
  top: calc(var(--topbar-height) + 24px + var(--safe-top));
  left: calc(10px + var(--safe-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 48px;
  padding: 5px;
  color: var(--text-soft);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(10, 15, 23, 0.94);
  border-radius: 13px;
  box-shadow: 0 10px 28px rgba(8, 12, 18, 0.22);
  backdrop-filter: blur(18px);
}

.tool-set {
  display: grid;
  gap: 3px;
}

.tool-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border-radius: 8px;
  transition: color 140ms ease, background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.tool-button > svg {
  width: 18px;
  height: 18px;
}

.tool-button > span,
.tool-button > kbd {
  position: absolute;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 130ms ease, transform 130ms ease, visibility 130ms;
}

.tool-button > span {
  top: 50%;
  left: 44px;
  width: max-content;
  max-width: 180px;
  padding: 8px 36px 8px 10px;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(10, 15, 23, 0.97);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-size: 0.66rem;
  font-weight: 700;
  transform: translate(4px, -50%);
}

.tool-button > kbd {
  z-index: 1;
  top: 50%;
  left: 44px;
  margin-left: calc(var(--tooltip-width, 0px));
  border-color: transparent;
  background: transparent;
  transform: translate(4px, -50%);
}

.tool-button:hover:not(:disabled),
.tool-button:focus-visible:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.tool-button:hover > span,
.tool-button:focus-visible > span {
  visibility: visible;
  opacity: 1;
  transform: translate(0, -50%);
}

.tool-button.is-active,
.tool-button[aria-pressed="true"] {
  color: var(--ink-950);
  background: var(--gold-bright);
  box-shadow: 0 5px 15px rgba(214, 173, 92, 0.22);
}

.tool-button.is-active:hover,
.tool-button[aria-pressed="true"]:hover {
  color: var(--ink-950);
  background: #f6d792;
}

.tool-divider {
  width: 22px;
  height: 1px;
  margin: 5px 0;
  background: var(--line);
}

.active-tool-chip {
  position: absolute;
  z-index: 40;
  top: calc(var(--topbar-height) + 24px + var(--safe-top));
  left: calc(68px + var(--safe-left));
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 10px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(10, 15, 23, 0.9);
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(8, 12, 18, 0.2);
  backdrop-filter: blur(14px);
}

.active-tool-chip > svg {
  width: 16px;
  height: 16px;
  color: var(--gold-bright);
}

.active-tool-chip > span {
  display: grid;
}

.active-tool-chip small {
  color: var(--text-muted);
  font-size: 0.48rem;
  text-transform: uppercase;
}

.active-tool-chip strong {
  font-size: 0.62rem;
}

.zoom-controls {
  position: absolute;
  z-index: 40;
  bottom: calc(35px + var(--safe-bottom));
  left: calc(10px + var(--safe-left));
  display: flex;
  align-items: center;
  height: 37px;
  padding: 4px;
  color: var(--text-soft);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(10, 15, 23, 0.9);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(8, 12, 18, 0.2);
  backdrop-filter: blur(14px);
}

.zoom-controls button {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  padding: 0;
  color: var(--text-soft);
  background: transparent;
  border-radius: 6px;
}

.zoom-controls button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

#map-help-btn {
  font-size: 0.72rem;
  font-weight: 900;
}

.zoom-controls svg {
  width: 15px;
  height: 15px;
}

#zoom-level {
  min-width: 43px;
  color: var(--text-muted);
  font-size: 0.58rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.zoom-divider {
  width: 1px;
  height: 19px;
  margin: 0 3px;
  background: var(--line);
}

.map-legend {
  position: absolute;
  z-index: 38;
  right: calc(12px + var(--safe-right));
  bottom: calc(35px + var(--safe-bottom));
  width: 220px;
  padding: 12px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(10, 15, 23, 0.9);
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(14px);
}

.map-legend header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.map-legend header p {
  margin: 0;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.legend-close {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border-radius: 5px;
}

.legend-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.legend-close svg {
  width: 14px;
  height: 14px;
}

.map-legend-content {
  display: grid;
  gap: 7px;
  padding-top: 9px;
  color: var(--text-soft);
  font-size: 0.62rem;
}

.inspector-toggle {
  position: absolute;
  z-index: 42;
  top: calc(var(--topbar-height) + 24px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 11px;
  color: var(--text-soft);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(10, 15, 23, 0.9);
  border-radius: 9px;
  box-shadow: 0 8px 24px rgba(8, 12, 18, 0.18);
  font-size: 0.63rem;
  font-weight: 750;
  backdrop-filter: blur(14px);
  transition: color 150ms ease, background 150ms ease, opacity 180ms ease;
}

.inspector-toggle:hover {
  color: var(--text);
  background: rgba(10, 15, 23, 0.98);
}

.inspector-toggle svg {
  width: 16px;
  height: 16px;
}

.inspector-toggle[aria-expanded="true"] {
  opacity: 0;
  pointer-events: none;
}

.inspector-panel {
  position: absolute;
  z-index: 55;
  top: calc(var(--topbar-height) + 24px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  bottom: calc(34px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 82px));
  overflow: hidden;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 15, 23, 0.96);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(22px) saturate(125%);
  transform: translateX(calc(100% + 24px));
  transition: transform 300ms var(--ease-out), visibility 300ms;
  visibility: hidden;
}

.inspector-panel:not(.is-collapsed),
.inspector-panel[aria-hidden="false"] {
  transform: translateX(0);
  visibility: visible;
}

.inspector-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 10px 12px 9px 14px;
  border-bottom: 1px solid var(--line);
}

.inspector-header .section-kicker {
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 0.55rem;
}

.inspector-header h2 {
  max-width: 265px;
  margin: 0;
  overflow: hidden;
  font-size: 0.92rem;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-close {
  width: 32px;
  height: 32px;
}

.inspector-content {
  flex: 1 1 auto;
  min-height: 0;
  padding: 13px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-color: var(--ink-700) transparent;
  scrollbar-width: thin;
}

.inspector-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 65%;
  padding: 26px;
  color: var(--text-muted);
  text-align: center;
}

.inspector-empty > span {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 15px;
  color: var(--gold);
  border: 1px solid rgba(214, 173, 92, 0.17);
  background: var(--gold-wash);
  border-radius: 50%;
}

.inspector-empty svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}

.inspector-empty h3 {
  margin: 0 0 7px;
  color: var(--text-soft);
  font-size: 0.79rem;
}

.inspector-empty p {
  max-width: 250px;
  margin: 0;
  font-size: 0.65rem;
  line-height: 1.55;
}

.inspector-panel > .inspector-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  padding: 12px 15px;
  border-top: 1px solid var(--line);
}

.inspector-content .inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0;
  border: 0;
}

.inspector-content .inspector-actions .button {
  min-width: 0;
  flex: 1 1 auto;
}

.inspector-route .inspector-section .inspector-actions .button {
  flex-basis: 100%;
  justify-content: flex-start;
  white-space: normal;
}

.map-statusbar {
  position: absolute;
  z-index: 35;
  right: calc(10px + var(--safe-right));
  bottom: calc(7px + var(--safe-bottom));
  left: calc(10px + var(--safe-left));
  display: flex;
  align-items: center;
  height: 21px;
  color: rgba(25, 39, 47, 0.6);
  font-size: 0.56rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.status-divider {
  width: 1px;
  height: 10px;
  margin: 0 9px;
  background: rgba(25, 39, 47, 0.18);
}

.status-hint {
  margin-left: auto;
}

/* Common injected inspector controls */
.inspector-section + .inspector-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.inspector-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.stat-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 9px;
}

.stat-card small,
.stat-card span {
  display: block;
  color: var(--text-muted);
  font-size: 0.56rem;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Modals and application overlays */
.modal-root {
  position: relative;
  z-index: 1000;
}

.modal-backdrop,
.modal-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(5, 8, 12, 0.72);
  backdrop-filter: blur(9px);
  animation: fade-in 150ms ease both;
  grid-template-columns: minmax(0, 1fr);
}

.modal-overlay > .modal {
  justify-self: center;
  width: min(560px, calc(100vw - 44px));
}

.modal-overlay > .modal.modal-wide {
  width: min(920px, calc(100vw - 44px));
}

.modal,
.modal-card,
dialog.app-dialog {
  width: min(560px, 100%);
  max-height: min(760px, calc(100dvh - 44px));
  margin: 0;
  padding: 0;
  overflow: hidden;
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: linear-gradient(145deg, rgba(23, 33, 46, 0.99), rgba(11, 17, 25, 0.99));
  border-radius: 18px;
  box-shadow: 0 35px 100px rgba(0, 0, 0, 0.57), inset 0 1px rgba(255, 255, 255, 0.035);
  animation: modal-in 220ms var(--ease-out) both;
}

.modal-wide {
  width: min(820px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 67px;
  padding: 15px 18px 14px 21px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2,
.modal-header h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.modal-header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.64rem;
}

.modal-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border-radius: 8px;
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.modal-close svg {
  width: 17px;
  height: 17px;
}

.modal-body {
  max-height: calc(100dvh - 190px);
  padding: 20px 21px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: var(--ink-700) transparent;
  scrollbar-width: thin;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-height: 64px;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field,
.form-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field-full {
  grid-column: 1 / -1;
}

.field > span,
.field > label,
.form-field > span,
.form-field > label,
.field-label {
  color: var(--text-soft);
  font-size: 0.65rem;
  font-weight: 700;
}

.field small,
.form-hint {
  color: var(--text-muted);
  font-size: 0.58rem;
  line-height: 1.45;
}

.field input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
.field select,
.field textarea,
.form-field input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
.form-field select,
.form-field textarea,
.text-input {
  width: 100%;
  min-height: 39px;
  padding: 9px 11px;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(4, 8, 13, 0.28);
  border-radius: 8px;
  outline: 0;
  font-size: 0.72rem;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.field textarea,
.form-field textarea {
  min-height: 90px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.text-input:focus {
  border-color: rgba(214, 173, 92, 0.55);
  background: rgba(4, 8, 13, 0.43);
  box-shadow: 0 0 0 3px rgba(214, 173, 92, 0.09);
}

input[type="color"] {
  width: 44px;
  height: 39px;
  padding: 3px;
  border: 1px solid var(--line);
  background: rgba(4, 8, 13, 0.28);
  border-radius: 8px;
}

.button,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  border-radius: 8px;
  font-size: 0.68rem;
  font-weight: 800;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.button:hover,
.secondary-button:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.075);
}

.primary-button {
  color: var(--ink-950);
  border-color: var(--gold-bright);
  background: var(--gold-bright);
}

.primary-button:hover {
  border-color: #f6d792;
  background: #f6d792;
}

.danger-button {
  color: #ffd1cd;
  border-color: rgba(221, 113, 105, 0.34);
  background: var(--red-wash);
}

.danger-button:hover {
  border-color: rgba(221, 113, 105, 0.58);
  background: rgba(221, 113, 105, 0.2);
}

.button:active,
.primary-button:active,
.secondary-button:active,
.danger-button:active {
  transform: translateY(1px);
}

.segmented-control,
.tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  background: rgba(4, 8, 13, 0.25);
  border-radius: 9px;
}

.segmented-control button,
.tabs button {
  flex: 1 1 0;
  min-height: 31px;
  padding: 0 9px;
  color: var(--text-muted);
  background: transparent;
  border-radius: 6px;
  font-size: 0.61rem;
  font-weight: 750;
}

.segmented-control button.is-active,
.segmented-control button[aria-selected="true"],
.tabs button.is-active,
.tabs button[aria-selected="true"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.toast-root {
  position: fixed;
  z-index: 2000;
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 52px;
  padding: 10px 12px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: rgba(12, 19, 28, 0.97);
  border-radius: 11px;
  box-shadow: var(--shadow-md);
  font-size: 0.68rem;
  pointer-events: auto;
  animation: toast-in 260ms var(--ease-out) both;
}

.toast::before {
  width: 7px;
  height: 7px;
  content: "";
  background: var(--gold-bright);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(240, 202, 122, 0.5);
}

.toast[data-kind="success"]::before,
.toast.is-success::before {
  background: var(--green);
}

.toast[data-kind="error"]::before,
.toast.is-error::before {
  background: var(--red);
}

.toast button {
  padding: 4px;
  color: var(--text-muted);
  background: transparent;
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
}

.noscript-message {
  position: fixed;
  z-index: 9999;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 13px 16px;
  color: var(--text);
  border: 1px solid rgba(221, 113, 105, 0.4);
  background: #29171a;
  border-radius: 9px;
  box-shadow: var(--shadow-md);
  font-size: 0.75rem;
  text-align: center;
}

/* Compact desktop */
@media (max-width: 1120px) {
  .menu-layout {
    grid-template-columns: minmax(350px, 0.9fr) minmax(400px, 0.8fr);
    gap: clamp(34px, 5vw, 70px);
  }

  .step-button,
  .view-label {
    display: none;
  }

  .view-selector select {
    padding-top: 0;
  }

  .view-group {
    flex-basis: 138px;
  }

  .world-group {
    flex-basis: 230px;
  }
}

@media (max-width: 920px) {
  .menu-screen {
    overflow-y: auto;
  }

  .menu-layout {
    grid-template-columns: 1fr;
    gap: 34px;
    width: min(650px, 100%);
    padding-top: 64px;
  }

  .hero-panel {
    max-width: none;
  }

  .war-title {
    font-size: clamp(7rem, 25vw, 10.5rem);
  }

  .saved-panel {
    min-height: 390px;
    max-height: none;
  }

  .saved-games-list {
    max-height: 430px;
  }

  .menu-footer {
    margin-top: 28px;
  }

  .save-status,
  .topbar-brand,
  .speed-selector {
    display: none;
  }

  .world-group {
    flex-basis: 155px;
  }

  #game-title-input {
    width: 145px;
  }
}

@media (max-width: 720px) {
  :root {
    --topbar-height: 52px;
  }

  .menu-screen {
    padding: calc(16px + var(--safe-top)) calc(18px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(18px + var(--safe-left));
  }

  .menu-layout {
    gap: 27px;
    padding: 51px 0 22px;
  }

  .war-title {
    margin-top: 9px;
    font-size: clamp(6.4rem, 32vw, 9rem);
  }

  .hero-copy {
    margin-top: 19px;
    font-size: 1.06rem;
  }

  .director-badge {
    margin-bottom: 23px;
  }

  .saved-panel {
    padding: 20px;
    border-radius: 18px;
  }

  .menu-footer {
    display: none;
  }

  .game-topbar {
    top: calc(6px + var(--safe-top));
    right: calc(6px + var(--safe-right));
    left: calc(6px + var(--safe-left));
    height: var(--topbar-height);
    padding: 5px;
    border-radius: 12px;
  }

  .topbar-group + .topbar-group {
    margin-left: 4px;
    padding-left: 4px;
  }

  .world-group {
    flex: 1 1 auto;
  }

  #game-title-input {
    width: min(32vw, 155px);
    min-width: 70px;
    font-size: 0.68rem;
  }

  .simulation-date,
  .compact-button span {
    display: none;
  }

  .compact-button {
    width: 36px;
    padding: 0;
  }

  .view-group {
    flex: 0 1 115px;
  }

  .view-selector > svg:first-child {
    left: 6px;
  }

  .view-selector select {
    padding-right: 20px;
    padding-left: 26px;
    font-size: 0.62rem;
  }

  .select-chevron {
    right: 4px;
  }

  .tool-rail {
    top: auto;
    right: calc(6px + var(--safe-right));
    bottom: calc(8px + var(--safe-bottom));
    left: calc(6px + var(--safe-left));
    flex-direction: row;
    justify-content: space-between;
    width: auto;
    height: 52px;
    padding: 5px;
    border-radius: 12px;
  }

  .tool-set {
    display: flex;
    gap: 2px;
  }

  .history-tools {
    margin-left: auto;
  }

  .tool-button {
    width: 38px;
    height: 40px;
  }

  .tool-button > span,
  .tool-button > kbd {
    display: none;
  }

  .tool-divider {
    width: 1px;
    height: 25px;
    margin: 0 4px;
  }

  .active-tool-chip {
    display: flex;
    top: calc(var(--topbar-height) + 16px + var(--safe-top));
    left: calc(7px + var(--safe-left));
  }

  .zoom-controls {
    bottom: calc(69px + var(--safe-bottom));
    left: calc(7px + var(--safe-left));
  }

  .inspector-toggle {
    top: calc(var(--topbar-height) + 16px + var(--safe-top));
    right: calc(7px + var(--safe-right));
  }

  .inspector-panel {
    top: calc(var(--topbar-height) + 16px + var(--safe-top));
    right: calc(7px + var(--safe-right));
    bottom: calc(69px + var(--safe-bottom));
    width: min(390px, calc(100vw - 14px - var(--safe-left) - var(--safe-right)));
  }

  .map-statusbar {
    display: none;
  }

  .map-legend {
    right: calc(7px + var(--safe-right));
    bottom: calc(69px + var(--safe-bottom));
  }

  .map-empty-hint {
    width: calc(100vw - 30px);
    transform: translate(-50%, -54%);
  }

  .modal-backdrop,
  .modal-overlay {
    align-items: end;
    padding: 8px;
  }

  .modal,
  .modal-card,
  dialog.app-dialog {
    width: 100%;
    max-height: calc(100dvh - 16px);
    border-radius: 17px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-full {
    grid-column: auto;
  }
}

@media (max-width: 470px) {
  .menu-layout {
    padding-top: 40px;
  }

  .war-title {
    font-size: clamp(5.8rem, 31vw, 7.7rem);
  }

  .war-title::after {
    right: -17px;
    width: 5px;
    height: 5px;
  }

  .action-button {
    grid-template-columns: 41px 1fr auto;
    padding-right: 12px;
  }

  .action-copy small {
    max-width: 205px;
  }

  .saved-panel {
    padding: 17px;
  }

  .game-title-field,
  .topbar-group + .view-group::before,
  .step-button,
  .file-group::before {
    display: none;
  }

  .world-group {
    flex: 0 0 auto;
  }

  .view-group {
    flex: 1 1 auto;
  }

  .simulation-group {
    flex: 0 0 auto;
  }

  .file-group {
    margin-left: 2px !important;
    padding-left: 2px !important;
  }

  .tool-rail {
    justify-content: center;
  }

  .tool-set:first-child {
    justify-content: space-around;
    width: 100%;
  }

  .tool-divider {
    display: none;
  }

  .map-empty-hint h2 {
    font-size: 1.55rem;
  }

  .toast-root {
    right: calc(8px + var(--safe-right));
    bottom: calc(67px + var(--safe-bottom));
    width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
  }
}

/* Runtime panels and simulation data */
.form-stack {
  display: grid;
  gap: 16px;
}

.button-primary {
  color: var(--ink-950);
  border-color: var(--gold-bright);
  background: var(--gold-bright);
}

.button-primary:hover {
  border-color: #f6d792;
  background: #f6d792;
}

.button-danger {
  color: #ffd1cd;
  border-color: rgba(221, 113, 105, 0.4);
  background: var(--red-wash);
}

.button-ghost {
  color: var(--text-soft);
  background: transparent;
}

.button-small {
  min-height: 31px;
  padding-inline: 11px;
  font-size: 0.62rem;
}

.icon-action {
  display: inline-grid;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  place-items: center;
  color: var(--text-muted);
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  font-size: 1.1rem;
}

.icon-action:hover {
  color: var(--text);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.055);
}

.notice {
  padding: 12px 14px;
  color: var(--text-soft);
  border: 1px solid rgba(98, 183, 189, 0.2);
  background: var(--cyan-wash);
  border-radius: 10px;
  font-size: 0.67rem;
  line-height: 1.55;
}

.notice.warning {
  color: #f3d5b0;
  border-color: rgba(214, 173, 92, 0.28);
  background: var(--gold-wash);
}

.workflow-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 16px;
}

.workflow-guide > div {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 10px;
}

.workflow-guide b {
  display: grid;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--ink-950);
  background: var(--gold-bright);
  border-radius: 50%;
  font-size: 0.61rem;
}

.workflow-guide span {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.workflow-guide strong {
  color: var(--text);
  font-size: 0.66rem;
}

.workflow-guide small {
  color: var(--text-muted);
  font-size: 0.58rem;
  line-height: 1.45;
}

.legend-action {
  width: 100%;
  margin-top: 9px;
}

.check-field {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  color: var(--text-soft);
  font-size: 0.68rem;
  line-height: 1.4;
}

.check-field input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 1px 0 0;
  accent-color: var(--gold-bright);
}

.check-field span {
  display: grid;
  gap: 2px;
}

.check-field strong {
  color: var(--text);
  font-size: 0.68rem;
}

.check-field small {
  color: var(--text-muted);
  font-size: 0.59rem;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 270px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.checkbox-grid legend {
  padding-inline: 6px;
  color: var(--text-soft);
  font-size: 0.63rem;
  font-weight: 800;
}

#control-summit-invitees {
  display: contents;
}

.war-side-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.war-side-picker .checkbox-grid {
  grid-template-columns: 1fr;
  max-height: 245px;
}

.settings-list {
  display: grid;
  gap: 13px;
  padding: 14px;
  border: 1px solid var(--line);
  background: rgba(4, 8, 13, 0.2);
  border-radius: 11px;
}

.panel-toolbar,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-toolbar {
  min-height: 46px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-toolbar > div,
.section-title > div {
  min-width: 0;
}

.panel-toolbar strong {
  color: var(--text);
  font-size: 0.9rem;
}

.panel-toolbar span {
  color: var(--text-muted);
  font-size: 0.63rem;
}

.panel-toolbar .panel-toolbar-actions {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.search-field {
  display: block;
  margin-bottom: 11px;
}

.search-field input {
  width: 100%;
  min-height: 39px;
  padding: 9px 12px;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(4, 8, 13, 0.3);
  border-radius: 9px;
  outline: 0;
  font-size: 0.7rem;
}

.batch-country-search {
  margin-bottom: 0;
}

.catalog-selection-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.63rem;
}

.catalog-selection-tools > span:last-child {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.catalog-country-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  max-height: min(430px, 46vh);
  padding: 2px;
  overflow-y: auto;
  scrollbar-color: var(--ink-700) transparent;
  scrollbar-width: thin;
}

.catalog-country-row {
  display: grid;
  grid-template-columns: 18px 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 57px;
  padding: 9px 11px;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.catalog-country-row:hover,
.catalog-country-row:has(input:checked) {
  border-color: rgba(214, 173, 92, 0.44);
  background: var(--gold-wash);
}

.catalog-country-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--gold-bright);
}

.catalog-country-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.catalog-country-copy strong,
.catalog-country-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.catalog-country-copy strong {
  font-size: 0.7rem;
}

.catalog-country-copy small {
  color: var(--text-muted);
  font-size: 0.58rem;
}

.entity-list,
.route-list,
.timeline-list,
.event-feed {
  display: grid;
  gap: 7px;
}

.entity-row,
.route-row {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 54px;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 10px;
  text-align: left;
}

.entity-row {
  grid-template-columns: 34px minmax(0, 1fr) auto auto;
}

.entity-row:hover,
.route-row:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.055);
}

.entity-row-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.entity-row-main strong {
  overflow: hidden;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entity-row-main span {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.59rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flag-mark,
.group-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 9px;
  font-size: 1rem;
}

.group-mark {
  color: #fff;
  border-color: color-mix(in srgb, var(--entity-color) 65%, white 12%);
  background: var(--entity-color);
  font-size: 0.68rem;
  font-weight: 900;
}

.color-dot {
  width: 10px;
  height: 10px;
  background: var(--entity-color);
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--entity-color) 22%, transparent);
}

.empty-state {
  display: grid;
  min-height: 190px;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 26px;
  color: var(--text-muted);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  text-align: center;
}

.empty-state.compact {
  min-height: 86px;
  padding: 16px;
}

.empty-state strong {
  color: var(--text-soft);
  font-size: 0.72rem;
}

.empty-state p {
  max-width: 440px;
  margin: 0;
  font-size: 0.62rem;
  line-height: 1.5;
}

.empty-state-mark {
  color: var(--gold);
  font-size: 1.5rem;
}

.dashboard-section {
  display: grid;
  gap: 12px;
  padding-block: 15px;
  border-top: 1px solid var(--line);
}

.dashboard-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.section-title h3 {
  margin: 2px 0 0;
  color: var(--text);
  font-size: 0.8rem;
}

.diplomacy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.war-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 13px;
  border: 1px solid rgba(221, 113, 105, 0.28);
  background: var(--red-wash);
  border-radius: 11px;
}

.war-card > div {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.war-card > div span {
  font-size: 1.15rem;
}

.war-card > div strong {
  font-size: 0.65rem;
  text-align: center;
}

.war-card p,
.war-card button {
  grid-column: 1 / -1;
}

.war-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.58rem;
  text-align: center;
}

.war-versus {
  color: var(--red);
  font-size: 0.57rem;
  font-weight: 900;
}

.timeline-row,
.event-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
}

.timeline-dot {
  width: 9px;
  height: 9px;
  margin-top: 4px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--gold-wash);
}

.timeline-row div,
.event-row div {
  display: grid;
  gap: 4px;
}

.timeline-heading {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.status-badge {
  padding: 3px 7px;
  color: var(--gold-bright);
  border: 1px solid rgba(214, 173, 92, 0.24);
  background: var(--gold-wash);
  border-radius: 999px;
  font-size: 0.54rem;
  font-weight: 800;
  white-space: nowrap;
}

.summit-row[data-summit-status="completed"] .timeline-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px var(--cyan-wash);
}

.summit-row .timeline-dot {
  display: inline-grid;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  place-items: center;
  color: var(--ink-950);
  font-size: 0.55rem;
  font-weight: 900;
}

.summit-row[data-summit-purpose="trade"][data-summit-status="completed"] .timeline-dot {
  background: var(--cyan);
}

.summit-row[data-summit-purpose="peace"][data-summit-status="completed"] .timeline-dot {
  background: var(--green);
}

.summit-row[data-summit-status="completed"] .status-badge {
  color: #b9ead3;
  border-color: rgba(75, 190, 139, 0.25);
  background: rgba(75, 190, 139, 0.1);
}

.timeline-actions {
  display: flex !important;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px !important;
}

.summit-participants-preview {
  padding: 10px 12px;
  color: var(--text-muted);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 9px;
  font-size: 0.6rem;
  line-height: 1.55;
}

.summit-participants-preview strong {
  color: var(--text-soft);
}

.summit-resolution-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line-strong);
  background: var(--cyan-wash);
  border-radius: 11px;
}

.summit-resolution-banner[data-purpose="trade"] {
  background: rgba(54, 183, 164, 0.1);
}

.summit-resolution-banner[data-purpose="peace"] {
  background: rgba(75, 190, 139, 0.1);
}

.summit-resolution-banner > span {
  display: inline-grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--ink-950);
  background: var(--gold-bright);
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 900;
}

.summit-resolution-banner > div {
  display: grid;
  gap: 3px;
}

.summit-resolution-banner small,
.summit-resolution-banner p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.59rem;
}

.summit-resolution-banner strong {
  color: var(--text);
  font-size: 0.78rem;
}

.summit-result {
  display: grid;
  gap: 14px;
}

.summit-effect-list {
  display: grid;
  gap: 0;
  padding: 0;
  margin: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.summit-effect-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 0.61rem;
}

.summit-effect-list li span {
  color: var(--text-muted);
}

.summit-effect-list li strong {
  color: var(--text);
  text-align: right;
}

.compact-summit-history {
  display: grid;
  gap: 6px;
}

.compact-summit-history button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 2px 8px;
  width: 100%;
  padding: 8px;
  color: var(--text-soft);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 8px;
  text-align: left;
}

.compact-summit-history button > span {
  grid-row: 1 / 3;
  align-self: center;
  color: var(--gold-bright);
  text-align: center;
  font-weight: 900;
}

.compact-summit-history button strong,
.compact-summit-history button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-summit-history button small {
  color: var(--text-muted);
  font-size: 0.52rem;
}

.timeline-row strong,
.event-row strong {
  color: var(--text);
  font-size: 0.68rem;
}

.timeline-row span,
.timeline-row p,
.event-row time,
.event-row p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.59rem;
  line-height: 1.45;
}

.route-row {
  grid-template-columns: 8px minmax(210px, 1.8fr) minmax(80px, 0.7fr) minmax(100px, 0.8fr) auto;
}

.route-status {
  width: 7px;
  height: 7px;
  background: var(--green);
  border-radius: 50%;
}

.route-row.is-blocked .route-status {
  background: var(--red);
}

.route-parties {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.route-parties strong {
  overflow: hidden;
  font-size: 0.64rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-parties > span,
.route-resource,
.route-state {
  color: var(--text-muted);
  font-size: 0.58rem;
}

.route-value {
  color: var(--text);
  font-size: 0.62rem;
  font-weight: 800;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 0.61rem;
}

.war-impact-cell {
  display: grid;
  gap: 2px;
  min-width: 125px;
  color: var(--red);
  white-space: normal;
}

.war-impact-cell small {
  color: var(--text-muted);
}

.data-table th,
.data-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.data-table th:first-child,
.data-table td:first-child {
  text-align: left;
}

.data-table th {
  color: var(--text-muted);
  background: rgba(4, 8, 13, 0.32);
  font-weight: 800;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.table-link {
  padding: 0;
  color: var(--text);
  background: transparent;
  font-size: 0.62rem;
  font-weight: 750;
  text-align: left;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 18px;
}

.modal:not(.modal-wide) .metric-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 11px;
}

.metric-card span,
.metric-card small {
  color: var(--text-muted);
  font-size: 0.57rem;
}

.metric-card strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.9rem;
  text-overflow: ellipsis;
}

.status-ok {
  color: var(--green);
}

.status-warn {
  color: var(--red);
}

.country-identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.country-flag,
.city-symbol {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  color: var(--country-color, var(--gold-bright));
  border: 1px solid color-mix(in srgb, var(--country-color, var(--gold)) 42%, transparent);
  background: color-mix(in srgb, var(--country-color, var(--gold)) 14%, transparent);
  border-radius: 12px;
  font-size: 1.45rem;
}

.country-identity h2 {
  margin: 2px 0;
  color: var(--text);
  font-size: 1rem;
}

.country-identity p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.61rem;
}

.inspector-country,
.inspector-city,
.inspector-route {
  display: grid;
  gap: 12px;
}

.stats-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 0;
}

.stats-list div {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 9px;
}

.stats-list dt {
  color: var(--text-muted);
  font-size: 0.55rem;
}

.stats-list dd {
  margin: 0;
  overflow: visible;
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.inspector-section {
  display: grid;
  gap: 8px;
}

.inspector-section h3 {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.64rem;
}

.inspector-note {
  margin: 0;
  padding: 10px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 9px;
  font-size: 0.58rem;
  line-height: 1.5;
}

.resource-bar {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.55rem;
}

.resource-bar i {
  height: 5px;
  overflow: hidden;
  background: var(--line);
  border-radius: 999px;
}

.resource-bar b {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.resource-bar strong {
  color: var(--text-soft);
  font-size: 0.54rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-list > span {
  padding: 4px 7px;
  color: var(--text-soft);
  border: 1px solid color-mix(in srgb, var(--tag-color) 35%, transparent);
  background: color-mix(in srgb, var(--tag-color) 12%, transparent);
  border-radius: 999px;
  font-size: 0.54rem;
}

.game-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.menu-command {
  display: grid;
  gap: 5px;
  min-height: 78px;
  padding: 14px;
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 11px;
  text-align: left;
}

.menu-command:hover {
  border-color: rgba(214, 173, 92, 0.35);
  background: var(--gold-wash);
}

.menu-command strong {
  font-size: 0.7rem;
}

.menu-command span {
  color: var(--text-muted);
  font-size: 0.58rem;
  line-height: 1.4;
}

.view-target-select {
  max-width: 190px;
  min-height: 30px;
  padding: 0 25px 0 8px;
  color: var(--text-soft);
  border: 1px solid var(--line);
  background: var(--ink-900);
  border-radius: 7px;
  font-size: 0.58rem;
}

.legend-entry {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
}

.legend-entry > i {
  width: 26px;
  height: 12px;
  background: var(--legend-color, var(--gold));
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 4px;
}

.legend-entry > i.legend-gradient[data-view="economy"] {
  background: linear-gradient(90deg, #26364a, #f6c85f);
}

.legend-entry > i.legend-gradient[data-view="population"] {
  background: linear-gradient(90deg, #20394b, #ef5b5b);
}

.legend-entry > i.legend-gradient[data-view="trade"] {
  background: linear-gradient(90deg, #e8b44f 0 45%, transparent 45% 58%, #ef6262 58%);
}

.legend-entry > i.legend-gradient[data-view="wars"] {
  background: linear-gradient(90deg, #647180 0 45%, #d84a4a 45%);
}

.legend-entry span {
  display: grid;
  gap: 3px;
}

.legend-entry strong {
  color: var(--text);
  font-size: 0.61rem;
}

.legend-entry small {
  color: var(--text-muted);
  font-size: 0.52rem;
  line-height: 1.35;
}

.active-tool-chip:has(.tool-readout) {
  display: flex;
  align-items: center;
  gap: 12px;
  width: auto;
  max-width: min(620px, calc(100vw - 210px));
}

.tool-readout {
  display: grid;
  gap: 2px;
  white-space: nowrap;
}

.tool-readout strong {
  color: var(--text);
  font-size: 0.62rem;
}

.tool-readout span,
.context-hint {
  color: var(--text-muted);
  font-size: 0.53rem;
}

.context-country {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  color: var(--text-soft);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 7px;
  font-size: 0.58rem;
}

.context-skip {
  flex: 0 0 auto;
  min-height: 28px;
  padding-inline: 9px;
}

.brush-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.54rem;
}

.brush-control input {
  width: 92px;
  accent-color: var(--gold-bright);
}

@media (max-width: 760px) {
  .war-side-picker {
    grid-template-columns: 1fr;
  }

  .checkbox-grid,
  .metric-grid,
  .diplomacy-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .route-row {
    grid-template-columns: 8px minmax(0, 1fr) auto;
  }

  .route-resource,
  .route-state {
    display: none;
  }

  .context-hint {
    display: none;
  }
}

@media (max-width: 520px) {
  .panel-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-toolbar .panel-toolbar-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .modal-footer .button {
    flex: 1 1 100%;
  }

  .workflow-guide {
    grid-template-columns: 1fr;
  }

  .catalog-country-list {
    grid-template-columns: 1fr;
  }

  .catalog-selection-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .catalog-selection-tools > span:last-child {
    justify-content: flex-start;
  }

  .summit-resolution-banner {
    align-items: flex-start;
  }

  .summit-effect-list li {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .summit-effect-list li strong {
    text-align: left;
  }

  .checkbox-grid,
  .metric-grid,
  .diplomacy-grid,
  .game-menu-grid {
    grid-template-columns: 1fr;
  }

  .modal-overlay > .modal,
  .modal-overlay > .modal.modal-wide {
    width: calc(100vw - 16px);
  }

  .active-tool-chip:has(.tool-readout) {
    max-width: calc(100vw - 105px);
    min-width: 0;
    overflow: hidden;
    gap: 7px;
  }

  .active-tool-chip .context-hint {
    display: none !important;
  }

  .active-tool-chip .tool-readout,
  .active-tool-chip .context-country {
    min-width: 0;
  }

  .active-tool-chip .context-country strong {
    max-width: 74px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .active-tool-chip .brush-control input {
    width: 58px;
  }
}

#game-title-input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

@media (max-height: 720px) and (min-width: 921px) {
  .menu-layout {
    padding-top: 16px;
    padding-bottom: 12px;
  }

  .war-title {
    font-size: clamp(6rem, 18vh, 8.4rem);
  }

  .hero-copy {
    margin-top: 17px;
    font-size: 1rem;
  }

  .director-badge {
    margin-bottom: 18px;
  }

  .saved-panel {
    min-height: 350px;
  }
}

@media (hover: none) {
  .save-card-actions {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --line: rgba(255, 255, 255, 0.25);
    --line-strong: rgba(255, 255, 255, 0.4);
    --text-muted: #a9b4bb;
  }
}

.control-country-hud,
.world-ranking-hud {
  position: absolute;
  z-index: 36;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 15, 23, 0.92);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(4, 8, 13, 0.26);
  backdrop-filter: blur(16px) saturate(120%);
}

.control-country-hud[hidden],
.world-ranking-hud[hidden] {
  display: none;
}

.control-country-hud {
  bottom: calc(84px + var(--safe-bottom));
  left: calc(10px + var(--safe-left));
  width: min(360px, calc(100vw - 20px));
  padding: 10px 12px;
}

.control-country-hud > header,
.world-ranking-hud > header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  font-size: 0.67rem;
}

.control-country-hud > header > span {
  font-size: 1rem;
}

.control-hud-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.control-hud-stats > span,
.mobilization-hud > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.control-hud-stats small,
.mobilization-hud small,
.ranking-columns > section > small {
  color: var(--text-muted);
  font-size: 0.49rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.control-hud-stats strong {
  overflow: hidden;
  font-size: 0.59rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.is-positive { color: var(--green); }
.is-negative { color: var(--red); }

.mobilization-hud {
  display: grid;
  grid-template-columns: auto minmax(80px, 1fr);
  gap: 10px;
  align-items: end;
  margin-top: 9px;
}

.mobilization-hud > span strong {
  font-size: 0.57rem;
}

.mobilization-hud > i {
  display: block;
  height: 7px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 999px;
}

.mobilization-hud > i > b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
  border-radius: inherit;
}

.world-ranking-hud {
  top: calc(var(--topbar-height) + 70px + var(--safe-top));
  right: calc(10px + var(--safe-right));
  width: min(390px, calc(100vw - 90px));
  padding: 10px;
}

.ranking-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ranking-columns > section {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.ranking-columns button {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 5px;
  align-items: center;
  min-height: 25px;
  padding: 3px 5px;
  color: var(--text-soft);
  background: transparent;
  border-radius: 5px;
  font-size: 0.51rem;
  text-align: left;
}

.ranking-columns button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.ranking-columns button > b {
  color: var(--gold-bright);
  text-align: center;
}

.ranking-columns button > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-columns button > strong {
  font-size: 0.49rem;
  white-space: nowrap;
}

.build-choice-grid {
  display: grid;
  gap: 10px;
}

.build-choice-grid > article {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  border-radius: 10px;
}

.build-choice-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--gold-bright);
  background: rgba(214, 173, 92, 0.12);
  border-radius: 50%;
  font-size: 1.15rem;
}

.build-choice-grid h3,
.build-choice-grid p {
  margin: 2px 0;
}

.build-choice-grid small,
.build-choice-grid p {
  color: var(--text-muted);
  font-size: 0.58rem;
}

.build-choice-grid strong {
  font-size: 0.66rem;
}

@media (max-width: 720px) {
  .control-country-hud {
    right: calc(7px + var(--safe-right));
    bottom: calc(68px + var(--safe-bottom));
    left: auto;
    width: min(330px, calc(100vw - 14px));
  }

  .world-ranking-hud {
    top: calc(var(--topbar-height) + 61px + var(--safe-top));
    right: calc(7px + var(--safe-right));
    width: min(330px, calc(100vw - 14px));
    max-height: 142px;
    overflow-y: auto;
  }

  .ranking-columns button:nth-of-type(n + 4) {
    display: none;
  }
}

@media (max-width: 520px) {
  .control-hud-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .build-choice-grid > article {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .build-choice-grid > article > .button {
    grid-column: 1 / -1;
  }
}
