:root {
  color-scheme: light;
  --sidebar: #181512;
  --sidebar-soft: #2b211a;
  --bg: #e8e1d5;
  --panel: #fffdf7;
  --ink: #1f1a15;
  --muted: #6f6358;
  --line: #d5c6b3;
  --blue: #6b4528;
  --blue-soft: #f5eadb;
  --green: #476b3c;
  --amber: #b8872d;
  --red: #9f1f1f;
  --gold: #c7a052;
  --shadow: 0 8px 20px rgba(45, 32, 20, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  line-height: 1.35;
}

a {
  color: var(--blue);
  text-decoration: none;
}

h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 9px;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #3b2a1d;
}

.app-page {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background:
    linear-gradient(180deg, rgba(199, 160, 82, 0.12), transparent 170px),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.025) 0 2px, transparent 2px 8px),
    var(--sidebar);
  color: #fff;
  padding: 14px 11px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 3px solid #6b4528;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(199, 160, 82, 0.28);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #c7a052, #7a5524);
  color: #1b1510;
  font-weight: 800;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.24);
}

.brand {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

.brand-sub {
  color: #d2b56f;
  font-size: 11px;
}

.language-switcher {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.language-switcher a {
  display: grid;
  place-items: center;
  min-height: 24px;
  border: 1px solid rgba(199, 160, 82, 0.35);
  border-radius: 4px;
  color: #f5eadb;
  font-size: 10px;
  font-weight: 900;
}

.language-switcher a.active,
.language-switcher a:hover,
.language-switcher a:focus {
  background: #6b4528;
  color: #fff;
}

.side-nav {
  display: grid;
  gap: 3px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.side-nav span {
  margin: 9px 0 3px;
  color: #c7a052;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.side-nav a {
  color: #f5eadb;
  padding: 8px 10px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid transparent;
  display: grid;
  gap: 2px;
}

.side-nav a:hover,
.side-nav a:focus {
  background: #6b4528;
  border-color: rgba(199, 160, 82, 0.45);
  color: #fff;
}

.side-nav a.active {
  border-color: transparent;
  background: transparent;
  color: #f0cf7b;
  animation: sidebar-active-text-glow 1.8s ease-in-out infinite;
}

@keyframes sidebar-active-text-glow {
  0%, 100% {
    text-shadow:
      0 0 3px rgba(225, 194, 113, 0.42),
      0 0 7px rgba(225, 194, 113, 0.22);
  }
  50% {
    color: #ffe7a3;
    text-shadow:
      0 0 5px rgba(255, 231, 163, 0.8),
      0 0 12px rgba(225, 194, 113, 0.56);
  }
}

@media (prefers-reduced-motion: reduce) {
  .side-nav a.active {
    animation: none;
    text-shadow:
      0 0 4px rgba(255, 231, 163, 0.68),
      0 0 9px rgba(225, 194, 113, 0.4);
  }
}

.side-nav a small {
  color: #d2b56f;
  font-size: 10px;
  font-weight: 700;
}

.sidebar-admin {
  padding: 10px 8px;
  gap: 9px;
  background:
    linear-gradient(180deg, rgba(199, 160, 82, 0.16), transparent 190px),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.025) 0 2px, transparent 2px 8px),
    #241a13;
  border-right-color: #7a552f;
}

.sidebar-admin .brand-block {
  gap: 7px;
  padding-bottom: 7px;
}

.sidebar-admin .brand-mark {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.sidebar-admin .brand {
  font-size: 12px;
}

.sidebar-admin .brand-sub {
  font-size: 10px;
}

.sidebar-admin .side-nav span {
  margin: 10px 0 3px;
  font-size: 9px;
  line-height: 1.1;
}

.sidebar-admin .side-nav {
  gap: 3px;
  flex: 0 0 auto;
  max-height: none;
  overflow-y: visible;
}

.sidebar-admin .side-nav a {
  padding: 6px 8px;
  font-size: 12px;
}

.sidebar-admin .side-nav a small {
  display: none;
}

.admin-side-map-controls {
  margin-top: auto !important;
  padding-top: 8px;
}

.sidebar-admin .side-footer {
  margin-top: 0 !important;
}

.admin-minimap-shell {
  height: auto;
  cursor: pointer;
}

.admin-map-view-panel {
  padding: 6px;
}

.admin-map-scroll {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 190px);
  overflow: auto;
  border: 1px solid var(--line);
  background: #f7eddc;
  cursor: crosshair;
}

.admin-map-scroll.is-right-panning {
  cursor: grabbing;
  user-select: none;
}

.section-heading-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.snapshot-create-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}

.snapshot-create-form input {
  width: 220px;
  min-height: 30px;
}

.snapshot-create-form button {
  min-height: 30px;
  padding: 5px 9px;
}

.table td.actions-cell {
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}

.table td.actions-cell form,
.table td.actions-cell a,
.table td.actions-cell button {
  margin: 0;
}

.table td.actions-cell form {
  display: flex;
  align-items: center;
  height: 26px;
}

.mini-stat {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin: 1px 3px 1px 0;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbf6ec;
  font-size: 11px;
  font-weight: 800;
}

.danger-button {
  background: #8f1d1d;
  border-color: #8f1d1d;
  color: #fff;
}

.table td.actions-cell .icon-only-button {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  min-height: 26px;
  max-height: 26px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.snapshot-actions-cell {
  line-height: 0;
}

.snapshot-actions-inline {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  height: 26px;
  line-height: 0;
  vertical-align: middle;
}

.snapshot-actions-cell .inline-form {
  line-height: 0;
}

.snapshot-action-icon,
a.snapshot-action-icon,
button.snapshot-action-icon {
  box-sizing: border-box;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(105, 74, 45, 0.35);
  border-radius: 5px;
  text-decoration: none;
  vertical-align: top;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  appearance: none;
}

.snapshot-table th,
.snapshot-table td {
  vertical-align: middle;
}

.deadline-form {
  align-items: end;
}

.deadline-form input[type="date"],
.deadline-form input[type="time"],
.deadline-form select {
  min-height: 32px;
}

.deadline-current-time {
  align-self: center;
  white-space: nowrap;
}

.council-delta,
.finance-delta,
.citizen-delta {
  color: #9f1f1f;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}


.admin-map-scroll img {
  display: block;
  width: max-content;
  max-width: none;
  min-width: 1800px;
}

.sidebar-player {
  padding: 10px 8px;
  gap: 9px;
}

.sidebar-player .brand-block {
  gap: 7px;
  padding-bottom: 7px;
}

.sidebar-player .brand-mark {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.sidebar-player .brand {
  font-size: 12px;
}

.sidebar-player .brand-sub {
  font-size: 10px;
}

.sidebar-player .side-nav {
  gap: 2px;
}

.sidebar-player .side-nav span {
  margin: 6px 0 2px;
  font-size: 9px;
}

.sidebar-player .side-nav a {
  padding: 5px 7px;
  font-size: 12px;
}

.sidebar-player .side-nav a small {
  display: none;
}

.side-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.side-map-controls {
  flex: 0 0 auto;
  margin-top: 0;
  position: relative;
  display: grid;
  gap: 5px;
  padding: 6px;
  border: 1px solid rgba(199, 160, 82, 0.35);
  border-top: 3px solid #c7a052;
  border-radius: 4px;
  background: rgba(43, 33, 26, 0.95);
}

.side-map-controls + .side-footer {
  margin-top: 0;
}

.side-map-controls .map-select-control {
  color: #c7a052;
  min-width: 0;
}

.side-map-controls select {
  width: 100%;
  min-width: 0;
}

.side-map-title {
  color: #c7a052;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
}

.side-map-controls .map-tools-inline {
  display: grid;
  grid-template-columns: 28px 28px minmax(42px, 1fr) 28px 48px;
  gap: 4px;
  justify-content: stretch;
}

.side-map-controls .map-tools-inline button {
  min-width: 0;
  min-height: 28px;
  padding: 4px 5px;
  font-size: 11px;
}

.side-map-controls .map-config-button {
  min-width: 30px;
  font-size: 15px;
  line-height: 1;
  color: #f5eadb;
  background: rgba(199, 160, 82, 0.18);
}

.side-map-controls .badge {
  background: #f5eadb;
  color: #4a3323;
  display: grid;
  place-items: center;
  min-width: 0;
  padding-inline: 4px;
}

.side-map-config-popover {
  position: absolute;
  left: -18px;
  right: auto;
  bottom: calc(100% - 74px);
  width: 300px;
  max-width: calc(100vw - 24px);
  z-index: 70;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(199, 160, 82, 0.65);
  border-radius: 4px;
  background: #2b211a;
  box-shadow: 0 12px 28px rgba(18, 12, 7, 0.35);
}

.side-map-config-popover[hidden] {
  display: none;
}

.side-map-config-popover label {
  display: grid;
  gap: 4px;
  color: #c7a052;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.side-map-config-popover select {
  width: 100%;
  min-width: 0;
}

.side-map-config-title {
  color: #f5eadb;
  font-size: 12px;
  font-weight: 800;
}

.side-button {
  width: 100%;
  min-height: 30px;
  background: var(--sidebar-soft);
  border: 1px solid rgba(199, 160, 82, 0.35);
  color: #f5eadb;
  border-radius: 4px;
  font-size: 12px;
}

.main {
  min-width: 0;
}

.topbar {
  height: 44px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: #fffaf0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #4a3323;
  font-weight: 800;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #f8fafc;
  font-weight: 800;
}

.content {
  padding: 16px 18px 28px;
  background:
    linear-gradient(180deg, rgba(107, 69, 40, 0.11), transparent 210px),
    var(--bg);
  min-height: calc(100vh - 44px);
}

.content:has(.overview-map-panel) {
  padding: 8px 8px 12px;
}

.content:has(#exacte-orderverwerking) {
  max-width: calc(100vw - 218px);
  min-width: 0;
  overflow-x: hidden;
}

.content:has(#exacte-orderverwerking) > .panel {
  max-width: 100%;
  min-width: 0;
}

.content:has(.battle-history-panel) {
  max-width: calc(100vw - 218px);
  min-width: 0;
  overflow-x: clip;
}

.content:has(.battle-history-panel) > .panel {
  max-width: 100%;
  min-width: 0;
}

@media (max-width: 860px) {
  .content:has(#exacte-orderverwerking) {
    max-width: 100vw;
  }

  .content:has(.battle-history-panel) {
    max-width: 100vw;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.progress-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 26, 21, 0.42);
}

.progress-modal-backdrop[hidden] {
  display: none;
}

.progress-modal {
  width: min(520px, 100%);
  padding: 14px;
  border: 1px solid rgba(69, 52, 36, 0.28);
  border-top: 3px solid var(--gold);
  border-radius: 5px;
  background: #fffdf7;
  box-shadow: 0 18px 50px rgba(31, 26, 21, 0.28);
}

.progress-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.progress-modal-header h2 {
  margin: 0;
}

.progress-bar {
  height: 8px;
  margin-bottom: 12px;
  border: 1px solid rgba(93, 64, 38, 0.22);
  border-radius: 999px;
  overflow: hidden;
  background: #efe3ce;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #7b5a2d, #c7a052);
  transition: width 0.18s ease;
}

.progress-step-list {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.progress-step-list li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid rgba(93, 64, 38, 0.12);
  border-radius: 4px;
  background: #fbf6ec;
  color: #6f6358;
  font-size: 12px;
  font-weight: 800;
}

.progress-step-marker {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(93, 64, 38, 0.22);
  border-radius: 50%;
  background: #fffaf0;
  color: #6f6254;
  font-size: 10px;
  line-height: 1;
}

.progress-step-list li.active {
  border-color: rgba(199, 160, 82, 0.7);
  background: #fff8e8;
  color: #1f1a15;
}

.progress-step-list li.active .progress-step-marker {
  background: #c7a052;
  color: #1f1a15;
}

.progress-step-list li.done {
  color: #1f1a15;
}

.progress-step-list li.done .progress-step-marker {
  border-color: #476b3c;
  background: #476b3c;
  color: #fff;
}

.progress-modal-error .progress-bar span {
  background: #9f1f1f;
}

.admin-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.admin-action-bar .button,
.admin-action-bar button {
  min-height: 32px;
}

.admin-game-card {
  display: grid;
  gap: 8px;
}

.admin-game-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.admin-game-card h3 {
  margin: 0;
  font-size: 16px;
}

.admin-game-card .admin-action-bar {
  margin-top: 0;
}

.error-panel {
  border-top-color: #8f1d1d;
  background: #fff5f2;
}

.danger-panel {
  border-top-color: #8f1d1d;
  background: #fff8f6;
}

.panel details > summary {
  cursor: pointer;
  list-style: none;
}

.panel details > summary::-webkit-details-marker {
  display: none;
}

.panel details > summary h2 {
  display: inline-block;
  margin-bottom: 8px;
}

.player-collapsible-panel {
  padding: 0;
  overflow: hidden;
}

.player-collapsible-panel > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  color: var(--red);
  font-size: 13px;
  font-weight: 900;
}

.player-collapsible-panel > summary::-webkit-details-marker {
  display: none;
}

.player-collapsible-panel > summary::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid currentColor;
  flex: 0 0 auto;
  transition: transform 0.12s ease;
}

.player-collapsible-panel[open] > summary::before {
  transform: rotate(90deg);
}

.player-collapsible-panel > summary .badge {
  margin-left: auto;
}

.dashboard-error-summary .badge {
  display: inline-grid;
  place-items: center;
  height: 25px;
  min-width: 25px;
  padding: 0 7px;
  margin-left: 0;
}

.dashboard-error-summary form {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 0 auto;
}

.dashboard-error-summary .badge {
  margin-left: 0;
}

.dismiss-errors-button {
  width: 25px;
  height: 25px;
  padding: 0;
  min-height: 0;
}

.player-collapsible-panel[open] > summary {
  border-bottom: 1px solid var(--line);
  background: #f5eadb;
}

.player-collapsible-panel > table,
.player-collapsible-panel > h3,
.player-collapsible-panel > p {
  margin-left: 10px;
  margin-right: 10px;
}

.player-collapsible-panel > h3 {
  margin-top: 10px;
  margin-bottom: 5px;
  color: #3b2a1d;
  font-size: 12px;
  text-transform: uppercase;
}

.order-processing-details {
  margin: 12px 0 10px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: 4px;
  background: #fffaf0;
}

.processing-run-summary th {
  width: 90px;
  color: #3b2a1d;
  font-weight: 900;
}

.processed-orders-table .order-payload-cell {
  display: table-cell;
  min-width: 280px;
  vertical-align: top;
}

.processed-orders-table th,
.processed-orders-table td {
  vertical-align: top;
}

.processed-orders-table .order-payload-part {
  display: inline-flex;
}

.processed-order-list {
  display: grid;
  gap: 6px;
}

.processed-order-line {
  display: block;
}

.processed-order-summary {
  list-style: none;
  cursor: pointer;
}

.processed-order-summary::-webkit-details-marker {
  display: none;
}

.processed-order-summary.sequence-order-item.page-order-row-link {
  grid-template-columns: 25px minmax(210px, 0.55fr) minmax(320px, 1fr) auto;
}

.processed-order-caret {
  width: 25px;
  height: 25px;
  display: inline-grid;
  place-items: center;
  color: #6f6254;
  font-size: 0;
  transition: transform 0.12s ease;
}

.processed-order-caret::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid currentColor;
}

.processed-order-line[open] .processed-order-caret {
  transform: rotate(90deg);
}

.processed-order-result {
  margin: 0 0 4px 50px;
  padding: 7px 10px;
  border-left: 3px solid rgba(31, 26, 21, 0.22);
  background: #fffdf7;
  color: #1f1a15;
  font-size: 12px;
  line-height: 1.45;
}

.processed-order-detail-payload {
  margin-bottom: 6px;
}

.recruit-order-summary {
  display: inline-grid;
  gap: 6px;
  max-width: 100%;
  vertical-align: top;
}

.recruit-main-line,
.recruit-cost-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.recruit-cost-detail {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.recruit-total-cost > strong {
  min-width: 48px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.recruit-slot-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.recruit-slot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 6px;
  border: 1px solid rgba(93, 64, 38, 0.16);
  border-radius: 2px;
  background: #fff8e8;
  color: #5f4b35;
  font-size: 11px;
  line-height: 1.2;
}

.recruit-slot strong {
  color: var(--ink);
  font-size: 11px;
}

.recruit-slot small {
  color: #7d6b58;
  font-size: 10px;
}

.military-order-line {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.military-cohort-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 6px 2px 3px;
  border: 1px solid rgba(93, 64, 38, 0.16);
  border-radius: 2px;
  background: #fff8e8;
  color: #5f4b35;
  font-size: 11px;
  line-height: 1.25;
}

.military-cohort-chip span {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  border-radius: 2px;
  background: #5a3b24;
  color: #fff8e8;
  font-size: 10px;
  font-weight: 900;
}

.military-cohort-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  grid-column: 1 / -1;
}

.military-cohort-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.military-cohort-option span {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid rgba(93, 64, 38, 0.22);
  border-radius: 4px;
  background: #fffdf7;
  color: #5f4b35;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.military-cohort-option input:checked + span {
  border-color: #5a3b24;
  background: #5a3b24;
  color: #fff8e8;
}

.increase-men-depot {
  font-size: 11px;
  font-weight: 800;
}

.increase-men-unit-list {
  display: flex;
  flex-basis: 100%;
  flex-wrap: wrap;
  gap: 4px;
}

.processed-status-ok {
  color: #1f1a15;
}

.processed-status-partial {
  color: #a35f00;
}

.processed-status-failed {
  color: #8f1d1d;
}

.badge.processed-status-partial {
  border-color: rgba(163, 95, 0, 0.45);
  background: #fff7e5;
}

.badge.processed-status-failed {
  border-color: rgba(143, 29, 29, 0.45);
  background: #fff5f2;
}

.order-processing-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 6px 0 10px;
}

.order-processing-options-toggle {
  width: 25px;
  height: 25px;
  padding: 0;
  margin-left: 6px;
  border: 1px solid rgba(31, 26, 21, 0.2);
  border-radius: 4px;
  background: #fffdf7;
  color: #1f1a15;
  font-size: 14px;
  line-height: 1;
}

.admin-processing-panel {
  background: #fffaf0;
}

.admin-processing-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin: 8px 0 12px;
  padding: 9px;
  border: 1px solid rgba(31, 26, 21, 0.14);
  border-radius: 4px;
  background: #fbf5eb;
}

.admin-processing-filters label {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
}

.admin-processing-filters select {
  width: 100%;
}

.admin-processing-open-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid rgba(31, 26, 21, 0.16);
  border-radius: 4px;
  background: #fffdf7;
  color: #4f4030;
  cursor: pointer;
  white-space: nowrap;
}

.admin-processing-open-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.admin-processing-open-toggle .processed-order-caret {
  width: 20px;
  height: 20px;
}

.admin-processing-open-toggle input:checked + .processed-order-caret {
  transform: rotate(90deg);
  color: #5a3b24;
}

.admin-processing-list {
  max-height: 720px;
  overflow: auto;
  padding-right: 4px;
}

.admin-processing-line[hidden] {
  display: none;
}

.admin-processing-line .processed-order-summary.sequence-order-item.page-order-row-link {
  grid-template-columns: 25px minmax(250px, 0.55fr) minmax(380px, 1fr) auto;
}

.admin-processing-detail-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 4px 10px;
}

.admin-processing-detail-label {
  color: #6f6254;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.admin-processing-detail-message {
  min-width: 0;
  overflow-wrap: anywhere;
}

.status-error {
  border-color: rgba(143, 29, 29, 0.45);
  background: #fff5f2;
  color: #8f1d1d;
}

.order-result-error {
  color: #8f1d1d;
  font-weight: 800;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title-row h2 {
  margin: 0;
}

.panel-title-row form {
  margin: 0;
}

.order-entry-form {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  margin: 10px 0;
  background: #fbf6ec;
}

.order-entry-form h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 800;
}

.checkbox-line input {
  width: auto;
}

.inline-form {
  margin-top: 8px;
}

.orders-table {
  table-layout: fixed;
  width: 100%;
}

.orders-table th:nth-child(1) { width: 44px; }
.orders-table th:nth-child(2) { width: 115px; }
.orders-table th:nth-child(3) { width: 175px; }
.orders-table th:nth-child(4) { width: 92px; }
.orders-table th:nth-child(5) { width: 40%; }
.orders-table th:nth-child(6) { width: 16%; }
.orders-table th:nth-child(7) { width: 42px; }

.order-payload-cell {
  min-width: 360px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 11px;
  line-height: 1.25;
}

.muster-tile-mini {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 1px 8px 1px 0;
  border: 1px solid #3b2a1d;
  background: var(--tile-fill);
  color: var(--tile-text);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  vertical-align: middle;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.muster-tile-inline {
  width: 24px;
  height: 24px;
  margin: 0 6px 0 0;
  font-size: 9px;
}

.order-payload-part {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  margin: 0 6px 0 0;
  padding: 2px 6px;
  border: 1px solid rgba(93, 64, 38, 0.16);
  border-radius: 2px;
  background: #fff8e8;
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
}

.production-order-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
  flex-wrap: wrap;
}

.production-order-type {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 6px;
  border: 1px solid rgba(93, 64, 38, 0.18);
  border-radius: 2px;
  background: #fff8e8;
}

.production-order-type > span {
  color: var(--muted);
}

.production-order-type strong {
  color: #5e3217;
  font-size: 11px;
}

.production-order-location,
.production-order-workers {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 6px;
  border: 1px solid rgba(93, 64, 38, 0.14);
  border-radius: 2px;
  background: #fffdf7;
  color: var(--ink);
}

.order-depot-ref {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 5px 1px 2px;
  border: 1px solid #4f3420;
  border-radius: 4px;
  background: #5a3b24;
  color: #fff8e8;
  font-weight: 900;
}

.order-depot-ref .depot-icon {
  width: 20px;
  height: 20px;
  border-color: #2e1d12;
  background: #2e1d12;
  color: #fff8e8;
}

.page-order-list {
  display: grid;
  gap: 5px;
  font-size: 12px;
}

.page-order-section {
  padding: 0;
  overflow: hidden;
}

.page-order-section-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 900;
  color: var(--red);
}

.page-order-section-summary::before,
.page-order-row summary::before {
  content: "";
  width: 0;
  height: 0;
  flex: 0 0 auto;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid currentColor;
  transition: transform 0.12s ease;
}

.page-order-section[open] > .page-order-section-summary::before,
.page-order-row[open] > summary::before {
  transform: rotate(90deg);
}

.page-order-section-summary .badge {
  margin-left: auto;
}

.page-order-section-summary .badge + .table-button,
.page-order-section-summary .badge + .order-add-map-button {
  margin-left: 0;
}

.page-order-section-summary.static-summary {
  margin-bottom: 8px;
  cursor: default;
}

.page-order-section-summary.static-summary::before {
  display: none;
}

.population-order-section-summary .badge {
  margin-left: 0;
}

.page-order-section-summary .order-add-map-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.order-sequence-table .is-system-step {
  color: #6f6559;
  background: #fbf5eb;
}

.order-sequence-table .is-unused-step {
  color: #8a8177;
  opacity: 0.72;
}

.order-sequence-table .order-sequence-related-line {
  color: #5f5549;
  background: #fff9ef;
}

.order-sequence-panel {
  position: relative;
}

.order-sequence-options-toggle {
  width: 27px;
  height: 27px;
  min-height: 0;
  display: inline-grid;
  place-items: center;
  margin-left: auto;
  padding: 0;
  border: 1px solid rgba(199, 160, 82, 0.48);
  background: #efe0bd;
  color: #332616;
  font-size: 15px;
}

.order-sequence-options {
  position: absolute;
  z-index: 8;
  top: 43px;
  right: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(31, 26, 21, 0.25);
  border-radius: 5px;
  background: #fffaf0;
  box-shadow: 0 5px 16px rgba(31, 26, 21, 0.18);
}

.order-sequence-options .checkbox-line + .checkbox-line {
  margin-top: 7px;
}

.order-sequence-options[hidden] {
  display: none;
}

.sequence-empty-order-line,
.sequence-empty-order-row {
  display: none;
}

.order-sequence-empty-block-row {
  display: none;
}

.show-empty-order-blocks .order-sequence-empty-block-row {
  display: table-row;
}

.show-empty-order-lines .sequence-empty-order-line {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  min-height: 29px;
  padding: 3px 8px;
  border: 1px dashed rgba(31, 26, 21, 0.22);
  border-radius: 4px;
  background: rgba(255, 253, 247, 0.55);
  color: #8a8177;
  font-size: 12px;
}

.is-reordering .sequence-empty-order-line {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  min-height: 29px;
  padding: 3px 8px;
  border: 1px dashed rgba(31, 26, 21, 0.22);
  border-radius: 4px;
  background: rgba(255, 253, 247, 0.55);
  color: #8a8177;
  font-size: 12px;
}

.sequence-order-item.is-drop-target,
.sequence-order-details.is-drop-target,
.sequence-empty-order-line.is-drop-target,
.legacy-line-row.is-drop-target {
  outline: 2px solid rgba(176, 128, 31, 0.72);
  outline-offset: 1px;
  background: #fff0c7;
}

.show-empty-order-lines.show-empty-order-blocks .sequence-empty-order-row {
  display: table-row;
}

.sequence-empty-slot {
  font-weight: 800;
  text-align: right;
  padding-right: 6px;
}

.order-sequence-drop-row td {
  padding: 4px 8px 7px 46px;
  background: #f8f3e7;
}

.sequence-order-list,
.legacy-order-list {
  display: grid;
  gap: 6px;
}

.sequence-order-item,
.legacy-order-row {
  border: 1px solid rgba(31, 26, 21, 0.14);
  background: #fffdf7;
}

.sequence-order-details {
  display: block;
  min-width: 0;
}

.sequence-order-details > summary {
  list-style: none;
  cursor: pointer;
}

.sequence-order-details > summary::-webkit-details-marker {
  display: none;
}

.sequence-order-details[open] > summary {
  border-bottom-color: rgba(31, 26, 21, 0.22);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.sequence-order-detail-body {
  padding: 7px 8px 8px 58px;
  border: 1px solid rgba(31, 26, 21, 0.14);
  border-top: 0;
  background: #fffaf0;
}

.sequence-order-item {
  grid-template-columns: 25px minmax(185px, 0.55fr) minmax(320px, 1fr) auto auto;
}

.sequence-order-item .order-payload-cell,
.legacy-order-row .order-payload-cell {
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}

.legacy-order-row {
  grid-template-columns: minmax(185px, 0.55fr) minmax(320px, 1fr) auto;
}

.legacy-order-groups {
  display: grid;
  gap: 8px;
}

.legacy-order-group {
  display: grid;
  gap: 5px;
  padding: 7px;
  border: 1px solid rgba(31, 26, 21, 0.12);
  border-radius: 5px;
  background: #fbf5eb;
}

.legacy-order-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legacy-order-related-title {
  padding-left: 36px;
  color: #5f5549;
  font-size: 11px;
}

.sequence-order-item.is-dragging,
.legacy-order-row.is-dragging {
  opacity: 0.45;
}

.drag-handle {
  width: 25px;
  height: 25px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(31, 26, 21, 0.24);
  border-radius: 4px;
  background: #efe0bd;
  color: #1f1a15;
  cursor: grab;
  font-size: 13px;
  line-height: 1;
}

.drag-handle:active {
  cursor: grabbing;
}

.legacy-order-form {
  margin-bottom: 12px;
  font-size: 12px;
}

.legacy-order-form label {
  min-width: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 400;
}

.legacy-order-form select,
.legacy-order-form input,
.legacy-order-form button {
  min-height: 25px;
  padding: 4px 7px;
  font-size: 12px;
}

.legacy-order-form button {
  width: auto;
  font-weight: 700;
}

.legacy-dat-import {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.legacy-dat-dropzone {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px dashed rgba(155, 113, 30, 0.55);
  border-radius: 6px;
  background: rgba(255, 248, 226, 0.78);
  cursor: pointer;
  min-width: 0;
  font-size: 12px;
}

.legacy-dat-import.is-drag-over .legacy-dat-dropzone {
  border-color: #9b711e;
  background: #fff0c7;
}

.legacy-dat-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 28px;
  border-radius: 5px;
  background: #2f261b;
  color: #f9df9b;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.legacy-dat-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
}

.legacy-dat-text strong {
  font-weight: 400;
}

.legacy-dat-dropzone small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legacy-dat-dropzone input {
  display: none;
}

.legacy-dat-replace-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
}

@media (max-width: 820px) {
  .legacy-dat-import {
    grid-template-columns: 1fr;
  }

  .legacy-dat-text {
    align-items: flex-start;
    flex-direction: column;
    gap: 1px;
  }
}

.legacy-dat-import-notice {
  align-items: flex-start;
}

.legacy-dat-header-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
  margin-top: 0.35rem;
  font-size: 0.82rem;
}

.legacy-dat-header-summary > span {
  color: var(--muted);
}

.legacy-orders-panel > summary {
  text-transform: none;
}

.legacy-orders-content {
  padding: 2px 10px 10px;
}

.legacy-syntax-box {
  margin: 6px 0 8px;
  padding: 7px 9px;
  border: 1px solid rgba(199, 160, 82, 0.4);
  border-radius: 4px;
  background: #181715;
  color: #f5eadb;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
}

.depots-page-grid .depot-order-panel {
  order: -1;
}

.trade-centers-table th,
.trade-centers-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.trade-center-location {
  color: inherit;
  text-decoration: none;
}

.trade-center-location-tile {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 25px;
  padding: 2px 5px;
  border: 1px solid rgba(59, 42, 29, 0.72);
  border-radius: 4px;
  background: var(--tile-fill);
  color: var(--tile-text);
  font-size: 10px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.32);
}

.trade-centers-table tr.is-own-trade-center td {
  background: rgba(225, 194, 113, 0.14);
}

.trade-centers-table tr.is-own-trade-center td:first-child {
  box-shadow: inset 3px 0 0 #c7a052;
}

.own-trade-center-badge {
  margin-left: 5px;
  border-color: rgba(184, 135, 45, 0.48);
  background: #fff2c8;
  color: #6b4528;
}

.trade-center-actions {
  display: flex;
  gap: 4px;
}

.trade-buy-button {
  color: #315f35;
}

.trade-sell-button {
  color: #8f1d1d;
}

.legacy-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 8px;
}

.legacy-field-grid textarea {
  min-height: 34px;
}

.politics-relations-cell {
  min-width: 240px;
  font-size: 11px;
  line-height: 1.25;
}

.page-order-section-summary .map-picker-icon {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.page-order-section-summary::-webkit-details-marker {
  display: none;
}

.page-order-section[open] .page-order-section-summary {
  border-bottom: 1px solid var(--line);
  background: #f5eadb;
}

.page-order-section > .page-order-list,
.page-order-section > .page-order-launch-actions,
.page-order-section > .meta {
  margin: 8px 10px;
}

.page-order-launch-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.politics-order-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid rgba(47, 79, 79, 0.24);
  background: #f8f3e8;
  color: #2f3f39;
  font-size: 12px;
}

.politics-order-preview.is-warning {
  border-color: rgba(143, 29, 29, 0.36);
  background: rgba(143, 29, 29, 0.08);
  color: var(--red);
}

.politics-council-table {
  table-layout: fixed;
}

.politics-council-table th:nth-child(1),
.politics-council-table td:nth-child(1) {
  width: 150px;
  white-space: nowrap;
}

.politics-council-table th:nth-child(n+2):nth-child(-n+7),
.politics-council-table td:nth-child(n+2):nth-child(-n+7) {
  width: 42px;
  text-align: center;
  white-space: nowrap;
}

.politics-threshold-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.politics-relations-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 8px;
  font-size: 12px;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
}

.messenger-relations-table {
  min-width: 980px;
  table-layout: fixed;
}

.messenger-relations-table th:first-child,
.messenger-relations-table td:first-child {
  width: 210px;
  text-align: left;
}

.messenger-relations-table th:not(:first-child),
.messenger-relations-table td:not(:first-child) {
  width: 38px;
  text-align: center;
}

.realm-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.realm-icon {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 5px;
  border: 1px solid rgba(64, 50, 28, 0.28);
  background: #f4e6c9;
  color: #3b2c16;
  font-weight: 900;
  font-size: 12px;
  line-height: 1;
}

.realm-icon-small {
  min-width: 22px;
  height: 22px;
  padding: 0 4px;
  font-size: 11px;
}

.relation-chip {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(64, 50, 28, 0.24);
  background: #f6efe2;
  color: #3b2c16;
  font-weight: 900;
  font-size: 12px;
}

.relation-chip-war,
.relation-chip-counter_war {
  background: #f6d9d6;
  color: #7f1d1d;
}

.relation-chip-neutral {
  background: #e7e1d7;
  color: #4a4237;
}

.relation-chip-trade {
  background: #dfeeda;
  color: #2f5d33;
}

.relation-chip-military_alliance,
.relation-chip-friendship {
  background: #d9e8f4;
  color: #214a68;
}

.relation-chip-self {
  background: transparent;
  color: var(--muted);
}

.politics-spy-table {
  table-layout: fixed;
}

.politics-spy-table th:nth-child(1),
.politics-spy-table td:nth-child(1) { width: 34px; }
.politics-spy-table th:nth-child(2),
.politics-spy-table td:nth-child(2) { width: 42px; }
.politics-spy-table th:nth-child(3),
.politics-spy-table td:nth-child(3) { width: 34px; }
.politics-spy-table th:nth-child(4),
.politics-spy-table td:nth-child(4) { width: 54px; white-space: nowrap; }
.politics-spy-table th:nth-child(5),
.politics-spy-table td:nth-child(5) { width: 42px; }
.politics-spy-table th:nth-child(6),
.politics-spy-table td:nth-child(6) { width: 54px; }
.politics-spy-table th:nth-child(7),
.politics-spy-table td:nth-child(7) {
  width: auto;
}

.depot-realm-info-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 7px;
  margin-bottom: 8px;
}

.depot-realm-info-card {
  display: grid;
  gap: 2px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  background: #fffaf0;
}

.depot-realm-info-card span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.depot-realm-info-card strong {
  font-size: 13px;
}

.depot-realm-info-card.is-warning {
  border-color: rgba(143, 29, 29, 0.38);
  background: rgba(143, 29, 29, 0.08);
  color: var(--red);
}

.depot-realm-info-table {
  table-layout: fixed;
}

.depot-realm-info-table td:nth-child(2),
.depot-realm-info-table th:nth-child(2) {
  width: 190px;
  text-align: right;
  white-space: nowrap;
}

.depot-realm-info-table td:first-child,
.depot-realm-info-table th:first-child {
  width: 230px;
}

.depot-realm-info-table td:nth-child(3),
.depot-realm-info-table th:nth-child(3) {
  width: auto;
  padding-left: 22px;
}

.depot-realm-info-table .finance-delta {
  display: inline-block;
  min-width: 76px;
  margin-left: 4px;
  text-align: left;
}

.money-transfer-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid rgba(47, 79, 79, 0.24);
  background: #f8f3e8;
  color: #2f3f39;
  font-size: 12px;
}

.money-transfer-preview.is-warning {
  border-color: rgba(143, 29, 29, 0.36);
  background: rgba(143, 29, 29, 0.08);
  color: var(--red);
}

.page-order-row {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fffaf0;
  overflow: hidden;
}

.page-order-row-link {
  display: grid;
  grid-template-columns: minmax(185px, 0.55fr) minmax(320px, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 11px;
  line-height: 1.25;
}

.page-order-row-link:hover,
.page-order-row-link:focus,
.page-order-row-link.is-active {
  border-color: var(--gold);
  background: #f5eadb;
}

.page-order-row summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 38px;
  padding: 6px;
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  line-height: 1.25;
}

.page-order-row summary::-webkit-details-marker {
  display: none;
}

.page-order-row[open] summary {
  border-bottom: 1px solid var(--line);
  background: #f5eadb;
}

.page-order-main {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sequence-order-item .page-order-main {
  grid-template-columns: 34px 30px minmax(0, 1fr);
}

.page-order-main .badge {
  justify-content: center;
  width: 34px;
  padding-left: 0;
  padding-right: 0;
}

.sequence-filled-slot {
  display: inline-grid;
  place-items: center;
  width: 30px;
  min-height: 22px;
  border: 1px solid rgba(199, 160, 82, 0.45);
  border-radius: 4px;
  background: #f8edcf;
  color: #5e4632;
  font-size: 11px;
  font-weight: 800;
}

.page-order-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.page-order-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.order-inline-action {
  margin: 0;
}

.order-inline-action .icon-link {
  font-size: 11px;
  font-weight: 700;
}

.order-type-button,
.order-object-ref,
.movement-object {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  max-width: 100%;
  min-height: 24px;
  padding: 2px 6px 2px 3px;
  border: 1px solid rgba(93, 64, 38, 0.28);
  border-radius: 2px;
  background: #f4e6c9;
  color: #2f2419;
  font-size: 11px;
  line-height: 1.25;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.order-type-icon,
.order-object-icon,
.movement-object-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(47, 36, 25, 0.35);
  border-radius: 2px;
  background: #3b2a1d;
  color: #f9df9b;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.order-type-button-army,
.order-object-ref-army,
.movement-object-army {
  background: #f2dccf;
}

.order-type-button-caravan,
.order-object-ref-caravan,
.movement-object-caravan {
  background: #e7edd3;
}

.order-type-button-ship,
.order-object-ref-ship,
.movement-object-ship {
  background: #dcebf1;
}

.order-object-ref-depot {
  background: #f4e6c9;
}

.order-object-ref-trade-center,
.order-object-ref-merchant {
  background: #efe2bd;
}

.order-object-ref-commander,
.order-object-ref-spy,
.order-object-ref-treasury,
.order-object-ref-all,
.order-object-ref-object,
.movement-object-commander,
.movement-object-spy {
  background: #f4e6c9;
}

.order-type-button-trade {
  background: #efe2bd;
}

.order-type-button-production {
  background: #e7edd3;
}

.order-type-button-warning {
  background: #fff0d6;
}

.processing-control-panel {
  display: grid;
  gap: 9px;
}

.processing-runs-block {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(31, 26, 21, 0.14);
}

.appendix-panel {
  width: 100%;
}

.appendix-panel > summary {
  cursor: pointer;
}

.trade-order-summary,
.trade-order-part,
.trade-order-good {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  font-size: 11px;
  line-height: 1.25;
}

.trade-order-summary {
  flex-wrap: wrap;
  row-gap: 4px;
}

.trade-order-part > span:first-child {
  color: #6d6256;
}

.trade-order-arrow {
  color: #7c5f2c;
  font-weight: 700;
}

.trade-order-good {
  min-height: 24px;
  padding: 2px 6px;
  border: 1px solid rgba(93, 64, 38, 0.18);
  border-radius: 2px;
  background: #fff8e8;
}

.trade-order-note {
  color: #6d6256;
}

.page-order-detail {
  padding: 6px;
  background: #fbf6ec;
}

.page-order-inline-payload {
  min-width: 0;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.25;
}

.icon-link {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid rgba(69, 52, 36, 0.35);
  border-radius: 4px;
  background: #fffaf0;
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
}

.icon-link:hover,
.icon-link:focus {
  border-color: var(--gold);
  background: #f5eadb;
}

.icon-map-picker {
  background: #f8efe0;
  border-color: rgba(143, 29, 29, 0.45);
  color: var(--red);
}

.sequence-order-item.page-order-row-link {
  grid-template-columns: 25px minmax(210px, 0.55fr) minmax(320px, 1fr) auto auto auto;
  min-height: 38px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.sequence-order-item .drag-handle {
  width: 25px;
  height: 25px;
  min-height: 0;
  padding: 0;
  background: #efe0bd;
  color: #1f1a15;
}

.legacy-order-row.page-order-row-link {
  grid-template-columns: minmax(185px, 0.55fr) minmax(320px, 1fr) auto;
}

.legacy-order-header-row,
.legacy-order-row.legacy-order-grid-row {
  display: grid;
  grid-template-columns: var(--legacy-columns);
  align-items: center;
  gap: 4px;
}

.legacy-order-header-row {
  color: #1f1a15;
  font-size: 11px;
  font-weight: 800;
  padding: 0 6px;
}

.legacy-order-row.legacy-order-grid-row {
  min-height: 29px;
  padding: 3px 6px;
}

.legacy-order-row.legacy-order-grid-row .drag-handle {
  width: 25px;
  height: 25px;
  min-height: 0;
  padding: 0;
}

.legacy-order-cell {
  min-height: 23px;
  display: flex;
  align-items: center;
  padding: 2px 6px;
  border: 1px solid rgba(31, 26, 21, 0.16);
  border-radius: 3px;
  background: #fbf6ec;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legacy-lines-editor {
  display: grid;
  gap: 4px;
  max-width: min(100%, 1380px);
  margin: 8px 0;
  overflow-x: auto;
}

.legacy-lines-editor-recruit {
  min-width: 1040px;
}

.translation-page-group {
  margin: 10px 0;
  border: 1px solid rgba(101, 67, 33, 0.16);
  background: rgba(255, 255, 255, 0.45);
}

.translation-page-group > summary {
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 900;
  color: #2f241d;
}

.translation-table {
  table-layout: fixed;
}

.translation-key {
  width: 24%;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.translation-value {
  max-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.translation-value-long {
  white-space: normal;
}

.translation-edit-button {
  min-width: 30px;
  min-height: 28px;
  border: 1px solid rgba(47, 36, 29, 0.28);
  border-radius: 4px;
  background: #6f2f1d;
  color: #fff7e7;
  padding: 3px 7px;
  cursor: pointer;
  font-weight: 900;
}

.translation-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(47, 36, 29, 0.34);
  padding: 18px;
}

.translation-modal-backdrop[hidden] {
  display: none;
}

.translation-modal {
  width: min(760px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid rgba(47, 36, 29, 0.28);
  border-radius: 6px;
  background: #fffdf7;
  box-shadow: 0 18px 50px rgba(47, 36, 29, 0.28);
  padding: 12px;
}

.translation-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.translation-modal-head h2 {
  margin: 0;
}

.translation-modal-close {
  border: 1px solid rgba(47, 36, 29, 0.24);
  border-radius: 4px;
  background: #6f2f1d;
  color: #fff7e7;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  width: 30px;
  height: 30px;
}

.translation-modal-fields {
  display: grid;
  gap: 8px;
}

.translation-modal-fields label {
  display: grid;
  gap: 3px;
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  color: #6b5948;
}

.translation-modal-fields textarea {
  width: 100%;
  min-height: 38px;
  resize: vertical;
  border: 1px solid rgba(101, 67, 33, 0.18);
  border-radius: 4px;
  background: #fffdf7;
  padding: 6px 7px;
  font: inherit;
  line-height: 1.25;
}

.translation-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
}

.legacy-line-row {
  display: grid;
  grid-template-columns: var(--legacy-columns);
  align-items: center;
  gap: 4px;
}

.legacy-line-header {
  color: #1f1a15;
  font-size: 11px;
  font-weight: 800;
}

.legacy-line-number {
  text-align: right;
  padding-right: 2px;
  font-size: 12px;
  font-weight: 800;
}

.legacy-line-leading {
  display: grid;
  grid-template-columns: 25px minmax(20px, 1fr);
  align-items: center;
  gap: 5px;
}

.legacy-line-leading .drag-handle {
  width: 25px;
  height: 25px;
  min-height: 0;
  padding: 0;
}

.legacy-drag-spacer {
  width: 25px;
}

.legacy-line-row input {
  width: 100%;
  min-height: 23px;
  padding: 2px 5px;
  font-size: 12px;
}

.map-picker-icon {
  position: relative;
  width: 18px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 2px;
  background:
    linear-gradient(90deg, transparent 31%, currentColor 31%, currentColor 36%, transparent 36%, transparent 64%, currentColor 64%, currentColor 69%, transparent 69%),
    linear-gradient(145deg, transparent 0 43%, currentColor 44% 49%, transparent 50%),
    #fffaf0;
  box-shadow: inset 0 0 0 1px rgba(255, 250, 240, 0.7);
}

.map-picker-icon::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 2px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.icon-map-picker-form {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  align-self: end;
}

.order-row-actions {
  text-align: right;
  white-space: nowrap;
}

.inline-delete-form {
  display: none;
}

.link-danger,
.icon-danger {
  border: 1px solid rgba(143, 29, 29, 0.45);
  background: #fff4f0;
  color: var(--red);
  cursor: pointer;
}

.icon-danger {
  font-size: 16px;
  line-height: 1;
}

.order-delete-button {
  min-height: 34px;
  white-space: nowrap;
}

.muted-order-step {
  color: var(--muted);
  background: rgba(111, 99, 88, 0.06);
}

.muted-order-step td {
  opacity: 0.72;
}

.muted-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f3eee7;
  font-size: 11px;
  font-weight: 700;
}

.system-order-step {
  background: rgba(143, 29, 29, 0.04);
}

.system-order-step td {
  color: #5f5147;
}

.system-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px;
  border: 1px solid #d7c5aa;
  border-radius: 999px;
  color: #5f5147;
  background: #efe4d2;
  font-size: 11px;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
  align-items: start;
}

.report-panel .meta {
  min-height: 0;
  margin-bottom: 8px;
}

.report-text {
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbf6ec;
  padding: 9px;
  font: 12px/1.4 Consolas, "Courier New", monospace;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: end;
}

label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  min-width: 180px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
  font: inherit;
  font-size: 13px;
}

textarea {
  min-height: 74px;
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border: 1px solid var(--blue);
  border-radius: 4px;
  background: var(--blue);
  color: #fff;
  padding: 6px 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.button.secondary,
button.secondary {
  background: #f8fafc;
  color: var(--blue);
  border-color: var(--line);
}

.meta {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  border: 1px solid #ead7bd;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 6px 6px;
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.events {
  display: grid;
  gap: 10px;
}

.event {
  border-left: 4px solid var(--blue);
  padding: 7px 9px;
  background: #fbf6ec;
}

.notice {
  border-left: 4px solid var(--amber);
  background: #fff7ed;
  padding: 10px 12px;
  margin-bottom: 18px;
}

.notice.warning {
  border: 1px solid #d99b34;
  border-left: 4px solid #b05f00;
  background: #fff3d8;
  color: #6f3600;
}

.notice.success {
  border: 1px solid #8ba56d;
  border-left: 4px solid #55733f;
  background: #f1f7e8;
  color: #354b2b;
}

.inline-notice {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  margin: 6px 0 8px;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 700;
}

.notice-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #8f1d1d;
  color: #fffaf0;
  font-size: 12px;
  font-weight: 900;
  font-family: Georgia, "Times New Roman", serif;
}

.auth-page {
  min-height: 100vh;
  display: block;
  min-width: 0;
  overflow-x: hidden;
  background: #fff;
}

.auth-shell {
  width: min(440px, calc(100vw - 32px));
}

.auth-card {
  background: #fff;
  border-radius: 6px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
  padding: 22px;
}

.auth-brand {
  color: var(--ink);
  margin-bottom: 24px;
}

.portal-login {
  position: relative;
  width: 100%;
  max-width: 100vw;
  min-width: 0;
  min-height: 100vh;
  isolation: isolate;
  overflow: hidden;
  background: #fff;
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}

.portal-login::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0.82) 40%, rgba(255, 255, 255, 0.52) 68%, rgba(255, 255, 255, 0.34) 100%),
    repeating-linear-gradient(135deg, rgba(59, 42, 29, 0.035) 0 2px, transparent 2px 9px);
  pointer-events: none;
}

.portal-login-cover {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0.72;
  filter: contrast(1.12);
  overflow: hidden;
}

.portal-login-cover img {
  position: absolute;
  left: 0;
  bottom: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  background: #fff;
  border: 0;
  box-shadow: none;
}

.portal-login-title {
  position: absolute;
  top: 0;
  left: clamp(28px, 7vw, 112px);
  z-index: 2;
  width: min(760px, calc(100vw - 64px));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(44px, 8vh, 90px) 0 clamp(38px, 7vh, 74px);
  color: #3b2a1d;
  text-align: left;
}

.portal-login-title h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(48px, 7.4vw, 112px);
  line-height: 0.92;
  font-weight: 700;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 #fff,
    1px 0 0 #fff,
    -1px 0 0 #fff;
}

.portal-login-title p {
  position: fixed;
  left: clamp(24px, 6vw, 96px);
  top: clamp(18px, 4vh, 42px);
  bottom: auto;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: calc(100vw - 32px);
  min-height: 54px;
  margin: 0;
  padding: 12px 22px 13px;
  color: #fff;
  background: #111;
  border: 2px solid #111;
  border-radius: 999px;
  outline: 2px solid rgba(255, 255, 255, 0.92);
  outline-offset: -6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(21px, 3vw, 42px);
  line-height: 1.05;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-align: center;
  box-shadow: 0 14px 30px rgba(55, 38, 24, 0.22);
}

.portal-player-login {
  position: absolute;
  z-index: 3;
  top: auto;
  bottom: clamp(24px, 6vh, 72px);
  right: auto;
  left: clamp(24px, 6vw, 96px);
  width: min(430px, calc(100% - 48px));
  max-width: calc(100vw - 48px);
  min-width: 0;
  box-sizing: border-box;
  padding: 22px;
  color: #3b2a1d;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #9f886d;
  border-top: 4px solid #7a552f;
  box-shadow: 0 14px 34px rgba(55, 38, 24, 0.2);
  transform: none;
}

.portal-player-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-bottom: 18px;
  padding-bottom: 13px;
  border-bottom: 1px solid #bca98f;
}

.portal-player-heading h2 {
  margin: 0 0 3px;
  color: #3b2a1d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  text-transform: none;
}

.portal-player-heading p {
  margin: 0;
  color: #6b5948;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.portal-player-heading > div:last-child {
  min-width: 0;
}

.portal-login-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border: 1px solid #80623e;
  background: #3b2a1d;
  color: #d8b566;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-weight: 700;
}

.portal-player-login form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 10px;
}

.portal-player-login label,
.portal-admin-popover label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: #49382a;
  font-size: 12px;
  font-weight: 800;
}

.portal-player-login input,
.portal-admin-popover input {
  min-width: 0;
  width: 100%;
  height: 40px;
  border-color: #a99479;
  background: #fff;
  color: #2d2118;
}

.portal-player-login form > button {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 40px;
  margin-top: 2px;
  background: #6b4528;
}

.portal-admin-toggle {
  position: fixed;
  right: 20px;
  bottom: 18px;
  z-index: 8;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #6d5235;
  border-radius: 50%;
  background: #3b2a1d;
  color: #e1c271;
  font-size: 22px;
  box-shadow: 0 5px 16px rgba(55, 38, 24, 0.24);
}

.portal-admin-toggle:hover,
.portal-admin-toggle:focus {
  background: #6b4528;
  color: #fff;
}

.portal-admin-popover {
  position: fixed;
  right: 20px;
  bottom: 70px;
  z-index: 9;
  width: min(320px, calc(100vw - 32px));
  padding: 16px;
  background: #fff;
  border: 1px solid #8e765c;
  border-top: 3px solid #7a552f;
  box-shadow: 0 12px 30px rgba(55, 38, 24, 0.24);
}

.portal-admin-popover[hidden] {
  display: none;
}

.portal-admin-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #3b2a1d;
}

.portal-admin-heading button {
  width: 26px;
  height: 26px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #6b5948;
  font-size: 22px;
}

.portal-admin-popover form {
  display: grid;
  gap: 10px;
}

.portal-admin-popover form > button {
  width: 100%;
  min-height: 38px;
}

.admin-create-game {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(360px, 1.4fr);
  align-items: end;
  gap: 18px;
}

.admin-create-game form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

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

@media (max-width: 820px) {
  .portal-login::before {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0.78) 46%, rgba(255, 255, 255, 0.38) 100%),
      repeating-linear-gradient(135deg, rgba(59, 42, 29, 0.035) 0 2px, transparent 2px 9px);
  }

  .portal-login-title {
    top: 0;
    left: 50%;
    width: min(720px, calc(100vw - 48px));
    min-height: 100vh;
    align-items: center;
    padding-top: 42px;
    padding-bottom: 56vh;
    text-align: center;
    transform: translateX(-50%);
  }

  .portal-login-title h1 {
    font-size: clamp(38px, 10vw, 68px);
  }

  .portal-login-cover {
    opacity: 0.64;
  }

  .portal-login-cover img {
    height: 100%;
    object-position: center bottom;
  }

  .portal-player-login {
    top: auto;
    bottom: 76px;
    right: auto;
    left: 24px;
    width: min(430px, calc(100% - 32px));
    max-width: calc(100vw - 32px);
    transform: none;
  }
}

@media (max-width: 560px) {
  .portal-login-title {
    width: calc(100vw - 28px);
    min-height: 100svh;
    padding-top: 24px;
    padding-bottom: 58vh;
  }

  .portal-login-title h1 {
    font-size: clamp(34px, 11vw, 52px);
  }

  .portal-login-title p {
    bottom: 18px;
    min-height: 46px;
    padding: 11px 18px 12px;
    font-size: clamp(18px, 5vw, 28px);
    line-height: 1.08;
  }

  .portal-login-cover {
    opacity: 0.58;
  }

  .portal-player-login {
    top: auto;
    bottom: 72px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    padding: 16px;
    transform: none;
  }

  .portal-player-login form,
  .admin-create-game,
  .admin-create-game form {
    grid-template-columns: 1fr;
  }

  .portal-player-login form > button {
    grid-column: auto;
  }

  .portal-player-login input,
  .portal-player-login button {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
}

.map-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 10px;
  align-items: start;
}

.map-panel {
  min-width: 0;
}

.map-detail-panel {
  position: sticky;
  top: 54px;
  max-height: calc(100vh - 66px);
  overflow: auto;
}

.map-image-shell {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
  max-height: 76vh;
}

.map-tools {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.map-tools button {
  min-height: 28px;
  padding: 4px 8px;
}

.map-legend {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 7px;
}

.map-legend-under {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-top: 0;
  background: #fbf6ec;
  scrollbar-color: var(--red) #eadfc9;
}

.map-legend-row {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
  white-space: nowrap;
}

.map-legend-row[hidden],
.player-map-legend[hidden] {
  display: none;
}

.map-legend span {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  min-height: 21px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-size: 11px;
  font-weight: 800;
}

.map-legend i {
  width: 12px;
  height: 12px;
  border: 1px solid #475569;
}

.generated-map {
  display: block;
  width: 2328px;
  height: auto;
  cursor: crosshair;
  image-rendering: auto;
}

.overview-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(72px, 1fr));
  gap: 4px;
  margin-bottom: 0;
}

.overview-order-limits {
  margin-top: 8px;
  border-top: 1px solid rgba(199, 160, 82, 0.35);
  padding-top: 7px;
}

.overview-order-limits summary {
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.order-limit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 4px 8px;
  margin-top: 6px;
}

.order-limit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.72rem;
  line-height: 1.2;
  padding: 3px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.45);
}

.order-limit-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-limit-row strong {
  color: var(--muted);
  white-space: nowrap;
}

.order-limit-row.is-full {
  background: rgba(143, 29, 29, 0.08);
}

.order-limit-row.is-full strong {
  color: var(--red);
}

.stat-tile {
  display: grid;
  gap: 1px;
  min-height: 34px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.stat-tile span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-tile strong {
  font-size: 13px;
  line-height: 1.1;
}

.stat-tile:hover,
.stat-tile:focus {
  border-color: var(--blue);
}

.production-order-stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  grid-column: 6;
  background: #f5eadb;
}

.production-order-stat .map-picker-icon {
  flex: 0 0 18px;
  color: #6f421f;
}

.production-order-stat strong {
  color: #5e3217;
  white-space: nowrap;
}

.player-map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 10px;
  align-items: start;
}

.overview-map-grid {
  display: block;
}

.player-map-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.overview-map-panel .player-map-toolbar {
  margin-bottom: 0;
}

.player-map-toolbar label {
  min-width: 260px;
}

.panel-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-headline h2 {
  margin: 0;
}

.map-tools-inline {
  display: flex;
  align-items: center;
  gap: 5px;
}

.map-tools-inline button {
  min-width: 30px;
  padding: 6px 8px;
}

.player-map-shell {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
  height: clamp(650px, calc(100vh - 150px), 920px);
  scrollbar-color: var(--red) #eadfc9;
  scrollbar-width: auto;
}

.player-map-shell.is-right-panning {
  cursor: grabbing;
  user-select: none;
}

.map-pan-compass {
  position: absolute;
  z-index: 45;
  width: 170px;
  height: 170px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  color: #f8ead2;
  text-shadow: 0 2px 5px rgba(31, 26, 21, 0.55);
}

.pan-compass-ring {
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(91, 58, 34, 0.5);
  border-radius: 50%;
  background:
    conic-gradient(from 22.5deg,
      rgba(91, 58, 34, 0.1) 0deg 22.5deg,
      rgba(91, 58, 34, 0.54) 22.5deg 45deg,
      rgba(91, 58, 34, 0.1) 45deg 67.5deg,
      rgba(91, 58, 34, 0.54) 67.5deg 90deg,
      rgba(91, 58, 34, 0.1) 90deg 112.5deg,
      rgba(91, 58, 34, 0.54) 112.5deg 135deg,
      rgba(91, 58, 34, 0.1) 135deg 157.5deg,
      rgba(91, 58, 34, 0.54) 157.5deg 180deg,
      rgba(91, 58, 34, 0.1) 180deg 202.5deg,
      rgba(91, 58, 34, 0.54) 202.5deg 225deg,
      rgba(91, 58, 34, 0.1) 225deg 247.5deg,
      rgba(91, 58, 34, 0.54) 247.5deg 270deg,
      rgba(91, 58, 34, 0.1) 270deg 292.5deg,
      rgba(91, 58, 34, 0.54) 292.5deg 315deg,
      rgba(91, 58, 34, 0.1) 315deg 337.5deg,
      rgba(91, 58, 34, 0.54) 337.5deg 360deg),
    radial-gradient(circle, rgba(47, 42, 36, 0.22), rgba(47, 42, 36, 0.08) 54%, transparent 56%);
  clip-path: polygon(50% 0%, 58% 37%, 85% 15%, 63% 42%, 100% 50%, 63% 58%, 85% 85%, 58% 63%, 50% 100%, 42% 63%, 15% 85%, 37% 58%, 0% 50%, 37% 42%, 15% 15%, 42% 37%);
  box-shadow: 0 10px 28px rgba(31, 26, 21, 0.18);
}

.pan-compass-arrow {
  position: absolute;
  display: grid;
  place-items: center;
  width: 40px;
  height: 32px;
  border-radius: 3px;
  background: rgba(47, 42, 36, 0.48);
  font-weight: 900;
  font-size: 13px;
  line-height: 1.05;
  text-align: center;
}

.pan-compass-center {
  position: absolute;
  top: 69px;
  left: 65px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 32px;
  border-radius: 3px;
  background: rgba(47, 42, 36, 0.56);
  font-weight: 900;
  font-size: 12px;
  line-height: 1.05;
  text-align: center;
}

.pan-compass-n { top: 3px; left: 65px; }
.pan-compass-ne { top: 26px; right: 16px; }
.pan-compass-e { top: 69px; right: 1px; }
.pan-compass-se { right: 16px; bottom: 26px; }
.pan-compass-s { bottom: 3px; left: 65px; }
.pan-compass-sw { bottom: 26px; left: 16px; }
.pan-compass-w { top: 69px; left: 1px; }
.pan-compass-nw { top: 26px; left: 16px; }

.player-map-shell::-webkit-scrollbar {
  width: 18px;
  height: 24px;
}

.player-map-shell::-webkit-scrollbar-track {
  background: #eadfc9;
  border-top: 1px solid var(--line);
}

.player-map-shell::-webkit-scrollbar-thumb {
  background: var(--red);
  border: 4px solid #eadfc9;
  border-radius: 999px;
}

.player-map-shell::-webkit-scrollbar-thumb:hover {
  background: #641a18;
}

.player-overview-map {
  width: 2328px;
  height: auto;
  max-width: none;
  cursor: crosshair;
  pointer-events: auto;
}

.province-border-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  width: 2328px;
  height: auto;
  max-width: none;
  pointer-events: none;
}

.province-border-layer[hidden] {
  display: none;
}

.overview-map-title-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  margin-bottom: 4px;
}

.overview-map-title-row h2 {
  margin: 0;
}

.map-visual-options {
  position: relative;
  z-index: 20;
  display: inline-grid;
}

.map-option-buttons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.map-visual-toggle {
  display: inline-grid;
  align-content: center;
  justify-content: center;
  gap: 3px;
  width: 34px;
  height: 32px;
  min-height: 32px;
  padding: 0 7px;
  border: 1px solid #3b2a1d;
  border-radius: 4px;
  background: linear-gradient(#fff8ea, #ecd7b7);
  color: #3b2a1d;
  box-shadow: 0 5px 14px rgba(31, 26, 21, 0.18);
}

.map-visual-toggle:hover,
.map-visual-toggle:focus {
  border-color: var(--red);
  background: #fffaf0;
}

.map-option-slider {
  position: relative;
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #3b2a1d;
}

.map-option-slider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  border: 1px solid #3b2a1d;
  border-radius: 50%;
  background: #8f1d1d;
  transform: translateY(-50%);
}

.map-option-slider-top::after {
  left: 2px;
}

.map-option-slider-middle::after {
  right: 2px;
}

.map-option-slider-bottom::after {
  left: 7px;
}

.map-view-grid {
  width: 18px;
  height: 18px;
  border: 2px solid #3b2a1d;
  background:
    linear-gradient(90deg, transparent 43%, #3b2a1d 43%, #3b2a1d 57%, transparent 57%),
    linear-gradient(transparent 43%, #3b2a1d 43%, #3b2a1d 57%, transparent 57%);
}

.map-visual-panel {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  display: grid;
  gap: 5px;
  width: 205px;
  padding: 8px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: 4px;
  background: rgba(251, 246, 236, 0.98);
  box-shadow: 0 10px 28px rgba(31, 26, 21, 0.22);
}

.map-visual-panel[hidden] {
  display: none;
}

.map-visual-panel strong {
  margin-top: 2px;
  color: #3b2a1d;
  font-size: 10px;
  text-transform: uppercase;
}

.map-visual-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
}

.map-visual-panel input {
  width: 14px;
  height: 14px;
}

.map-option-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border: 1px solid rgba(31, 26, 21, 0.35);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.map-option-dot-depots { background: #c7a052; }
.map-option-dot-production_buildings { background: #7c9f61; }
.map-option-dot-armies { background: #c65f48; }
.map-option-dot-caravans { background: #9fbe8a; }
.map-option-dot-merchant_ships { background: #74a4c7; }
.map-option-dot-warships { background: #52677a; }
.map-option-dot-commanders { background: #d8c28d; }
.map-option-dot-spies { background: #3b2a1d; }
.map-option-dot-trade_centers { background: #d9b44a; }

.map-object-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  width: 2328px;
  height: 1242px;
  pointer-events: none;
}

.movement-path-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 8;
  pointer-events: none;
}

.movement-route-table th,
.movement-route-table td {
  padding: 3px 4px;
  font-size: 11px;
}

.movement-route-table th:nth-child(1),
.movement-route-table td:nth-child(1) {
  width: 26px;
}

.movement-route-table th:nth-child(5),
.movement-route-table td:nth-child(5) {
  width: 30px;
  text-align: right;
}

.movement-cost-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #d8c7a7;
  border-radius: 4px;
  background: #fbf5e8;
  color: #34261d;
  font-size: 12px;
}

.movement-cost-summary.is-invalid {
  border-color: #c06a4f;
  background: #fff0e8;
  color: #7d2e1b;
}

.movement-cost-table th,
.movement-cost-table td {
  padding: 3px 4px;
  font-size: 11px;
}

.movement-cost-table .is-invalid-row td {
  background: #fff0e8;
  color: #7d2e1b;
  font-weight: 800;
}

.api-error-preview {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  padding: 8px;
  border: 1px solid #d8c7a7;
  background: #fffaf0;
  color: #4b3527;
  font-size: 11px;
}

.map-layer-icon {
  position: absolute;
  display: inline-grid;
  place-items: center;
  width: 10px;
  min-width: 10px;
  height: 10px;
  min-height: 10px;
  margin-left: 0;
  margin-top: 0;
  padding: 0;
  box-sizing: border-box;
  border: 1px solid #1f1a15;
  border-radius: 50%;
  color: #1f1a15;
  background: #f5eadb;
  font-size: 0;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(31, 26, 21, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  pointer-events: auto;
}

.map-layer-icon:hover,
.map-layer-icon:focus {
  z-index: 2;
  border-color: var(--red);
  transform: scale(1.45);
}

.map-layer-icon-depots {
  background: #c7a052;
}

.map-layer-icon-production_buildings {
  background: #7c9f61;
}

.map-layer-icon-armies {
  background: #c65f48;
  color: #fff;
}

.map-layer-icon-caravans {
  background: #9fbe8a;
}

.map-layer-icon-merchant_ships {
  background: #74a4c7;
}

.map-layer-icon-warships {
  background: #52677a;
  color: #fff;
}

.map-layer-icon-commanders {
  background: #d8c28d;
}

.map-layer-icon-spies {
  background: #3b2a1d;
  color: #fff;
}

.map-layer-icon-trade_centers {
  background: #d9b44a;
}

.player-map-detail {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  background: #fbf6ec;
}

.overview-map-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.overview-map-summary {
  flex: 1 1 auto;
  min-width: 0;
}

.overview-map-header h2 {
  margin: 0;
  font-size: 18px;
}

.overview-map-controls {
  flex: 0 0 270px;
  padding: 6px;
  margin: 0;
  box-shadow: none;
}

.map-select-control {
  display: grid;
  gap: 3px;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
}

.overview-map-controls .player-minimap-shell {
  margin-bottom: 0;
}

.overview-map-panel {
  padding: 6px;
}

.player-summary-panel-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  margin-bottom: 6px;
}

.player-summary-panel-compact h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.1;
}

.player-summary-panel-compact .meta,
.player-summary-panel-compact p {
  margin: 0;
}

.tile-popup {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 30;
  width: min(460px, calc(100% - 20px));
  max-height: calc(100% - 20px);
  overflow: auto;
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: 4px;
  padding: 10px;
  background: rgba(251, 246, 236, 0.98);
  box-shadow: 0 10px 28px rgba(31, 26, 21, 0.22);
  cursor: move;
}

.tile-popup button,
.tile-popup a,
.tile-popup input,
.tile-popup select,
.tile-popup textarea,
.tile-popup label {
  cursor: initial;
}

.tile-popup-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  line-height: 1;
}

.tile-actions {
  display: grid;
  gap: 6px;
}

.tile-action {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fffaf0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.tile-action:hover,
.tile-action:focus {
  border-color: var(--red);
  color: var(--red);
}

.tile-action-with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.simple-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-radius: 4px;
  background: rgba(199, 160, 82, 0.12);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.simple-icon::before {
  content: "";
}

.simple-icon-add::before {
  content: "+";
}

.simple-icon-up::before {
  content: "↑";
}

.simple-icon-down::before {
  content: "↓";
}

.tile-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.tile-order-option {
  display: grid;
  gap: 7px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.tile-order-option h3 {
  margin: 0;
  color: #3b2a1d;
  font-size: 12px;
  text-transform: uppercase;
}

.condition-list {
  margin: 0;
  padding-left: 17px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.tile-action-form {
  margin: 0;
}

.tile-coordinate-form .tile-order-option {
  margin-top: 0;
}

.population-order-panel {
  grid-column: 1 / -1;
}

.population-order-grid {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(280px, 1fr);
  gap: 10px;
  align-items: start;
}

.condition-list-panel {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fffaf0;
}

.condition-list-panel strong {
  display: block;
  margin-bottom: 5px;
  color: #3b2a1d;
  font-size: 12px;
  text-transform: uppercase;
}

.population-order-form {
  display: grid;
  grid-template-columns: 80px 80px minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.population-order-form.has-coordinate-picker {
  grid-template-columns: 34px 80px 80px minmax(220px, 1fr) auto auto;
}

.production-order-form {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 8px;
}

.production-order-form label {
  min-width: 0;
}

.production-order-form .icon-map-picker-form {
  align-self: end;
}

.production-field-coordinate {
  flex: 0 0 70px;
}

.production-field-workers {
  flex: 0 0 118px;
}

.production-field-type {
  flex: 0 0 210px;
}

.production-field-note {
  flex: 1 1 320px;
  min-width: 260px;
}

.production-order-form button {
  flex: 0 0 auto;
  min-height: 34px;
}

.production-build-check {
  flex: 1 0 100%;
}

.production-build-check .inline-notice,
.production-build-check .order-block-reasons {
  margin: 0;
}

.production-province-depots {
  display: flex;
  flex: 1 0 100%;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fffaf0;
  font-size: 12px;
}

.production-province-depots > span:first-child {
  flex: 0 0 auto;
  color: #3b2a1d;
  font-weight: 400;
}

.production-province-depot-list {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 5px;
}

.production-province-depot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
  padding: 1px 7px 1px 2px;
  border: 1px solid rgba(143, 29, 29, 0.25);
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.production-province-depot .depot-icon {
  width: 21px;
  height: 21px;
}

.population-resource-depots {
  grid-column: 1 / -1;
}

.population-resource-depots .good-value {
  gap: 5px;
}

.caravan-build-stock {
  flex: 1 0 100%;
}

.caravan-build-stock .production-province-depot {
  flex-wrap: wrap;
}

.caravan-build-stock .good-value {
  gap: 5px;
}

.population-order-actions {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 8px;
}

.population-order-actions button {
  width: auto;
  white-space: nowrap;
}

.order-block-reasons {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #d7a6a0;
  border-left: 4px solid #8f1d1d;
  border-radius: 4px;
  background: #fff5f2;
}

.order-block-reasons strong {
  display: block;
  margin-bottom: 4px;
  color: #8f1d1d;
  font-size: 12px;
  text-transform: uppercase;
}

.player-minimap-shell {
  margin-bottom: 10px;
}

.map-marker {
  --marker-color: rgb(242, 201, 76);
  --marker-soft: rgba(242, 201, 76, 0.18);
  --marker-glow: rgba(242, 201, 76, 0.78);
  --marker-ring: rgba(242, 201, 76, 0.42);
  position: absolute;
  z-index: 8;
  border: 2px solid var(--marker-color);
  background: var(--marker-soft);
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(59, 42, 29, 0.55),
    0 0 0 2px rgba(255, 248, 220, 0.9),
    0 0 18px var(--marker-glow);
  animation: selected-cell-pulse 1.45s ease-in-out infinite;
}

.map-marker::before {
  content: "";
  position: absolute;
  inset: -12px;
  border: 2px solid var(--marker-ring);
  border-radius: 2px;
  pointer-events: none;
}

@keyframes selected-cell-pulse {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1px rgba(59, 42, 29, 0.5),
      0 0 0 2px rgba(255, 248, 220, 0.85),
      0 0 10px var(--marker-ring);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(59, 42, 29, 0.65),
      0 0 0 5px rgba(255, 248, 220, 1),
      0 0 28px var(--marker-glow);
  }
}

.map-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
  max-height: 72vh;
}

.map-grid {
  display: grid;
  grid-template-columns: 42px repeat(126, 36px);
  width: max-content;
  font-size: 12px;
}

.map-cell,
.map-head {
  min-height: 28px;
  border-right: 1px solid #e4ebf3;
  border-bottom: 1px solid #e4ebf3;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.map-click {
  min-height: 28px;
  border-top: 0;
  border-left: 0;
  border-radius: 0;
  color: var(--ink);
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.map-click:hover,
.map-click:focus {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.map-click.is-selected {
  outline: 3px solid var(--red);
  outline-offset: -3px;
  position: relative;
  z-index: 3;
}

.map-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f1f5f9;
  font-weight: 800;
}

.map-y {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #f1f5f9;
  font-weight: 800;
}

.terrain-B { background: #d8c28d; }
.terrain-D { background: #ecd9a2; }
.terrain-G { background: #b8b1a3; }
.terrain-H { background: #d5c08f; }
.terrain-K { background: #c9b68b; }
.terrain-Q { background: #c7d69a; }
.terrain-S { background: #a7c7b7; }
.terrain-W { background: #90ad79; }
.terrain-empty {
  background: #d7e4ec;
  color: #5c7380;
}

.tile-detail {
  display: grid;
  gap: 8px;
}

.tile-title {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tile-set {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.tile-set h3 {
  margin: 0 0 6px;
  font-size: 12px;
}

.tile-summary {
  border-top: 0;
  padding-top: 0;
}

.tile-summary h3 {
  font-size: 13px;
}

.map-control-block {
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
  padding-bottom: 10px;
}

.minimap-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 126 / 65;
  border: 1px solid var(--line);
  overflow: hidden;
  background: #fff;
  cursor: pointer;
}

.minimap-shell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.minimap-viewport {
  position: absolute;
  border: 2px solid var(--red);
  background: rgba(239, 35, 60, 0.12);
  pointer-events: none;
}

.compact-table th,
.compact-table td {
  padding: 5px 5px;
  font-size: 12px;
  vertical-align: top;
}

.compact-table th {
  width: 104px;
}

.depot-table-wrap {
  overflow-x: auto;
  width: 100%;
}

.depot-table {
  width: max-content;
  min-width: 100%;
}

.depot-main-panel,
.depot-order-panel,
.depot-production-panel {
  grid-column: 1 / -1;
}

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

.money-order-form {
  grid-column: 1 / -1;
}

.trade-load-order-form,
.market-order-form {
  grid-column: 1 / -1;
  width: 100%;
}

.market-order-center {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(155, 113, 30, 0.35);
  border-radius: 5px;
  background: rgba(255, 247, 222, 0.72);
}

.market-order-center-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.market-order-center-head > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.market-order-center-head > div span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.market-order-stock {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 5px 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(155, 113, 30, 0.24);
  font-size: 12px;
}

.market-order-stock span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.market-order-fields {
  display: grid;
  grid-template-columns: minmax(280px, 1.7fr) minmax(280px, 1.7fr) minmax(190px, 1fr) minmax(120px, 0.65fr);
  align-items: end;
}

.market-order-fields label,
.market-order-fields input,
.market-order-fields select {
  min-width: 0;
  width: 100%;
}

.market-price-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 6px 12px;
  padding: 8px 10px;
  border: 1px solid rgba(47, 79, 79, 0.24);
  border-radius: 4px;
  background: #f8f3e8;
  font-size: 12px;
}

.market-price-preview.is-warning {
  border-color: rgba(143, 29, 29, 0.36);
  background: rgba(143, 29, 29, 0.08);
  color: var(--red);
}

.money-order-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr)) minmax(150px, 220px);
  gap: 10px;
  align-items: start;
}

.money-order-grid select {
  min-width: 100%;
}

.order-help-line {
  display: flex;
  align-items: center;
  gap: 7px;
}

.depot-table th,
.depot-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.depot-table th {
  width: auto;
}

.good-head {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-align: center;
  white-space: nowrap;
}

.good-name-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1.05;
}

.good-number {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0;
}

.good-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(31, 26, 21, 0.25);
  border-radius: 50%;
  background: var(--good-color);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.good-value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.good-value + .good-value {
  margin-left: 10px;
}

.good-value.is-shortage {
  color: var(--red);
  font-weight: 900;
}

.good-value.is-shortage .good-dot {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(143, 29, 29, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.supply-shortage-row > td {
  background: rgba(143, 29, 29, 0.08);
  border-top-color: rgba(143, 29, 29, 0.28);
  border-bottom-color: rgba(143, 29, 29, 0.28);
}

.supply-shortage-row > td:first-child {
  box-shadow: inset 3px 0 0 var(--red);
}

.shortage-note {
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.map-object-icon-plague {
  border-color: rgba(143, 29, 29, 0.45);
  color: var(--red);
  background: #f7e7df;
}

.plague-table .muster-tile-mini {
  width: 26px;
  height: 26px;
  font-size: 10px;
}

.own-realm-row > td {
  background: rgba(199, 160, 82, 0.12);
}

.support-stock {
  display: inline-block;
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.rule-note {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid rgba(199, 160, 82, 0.35);
}

.map-object-icon {
  width: 25px;
  height: 25px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  border: 1px solid rgba(31, 26, 21, 0.3);
  color: #1f1a15;
  background: #f5eadb;
  font-size: 11px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.map-object-icon:hover,
.map-object-icon:focus {
  border-color: var(--blue);
  background: #fffdf7;
}

.map-object-icon-province {
  background: #d9c58b;
}

.map-object-icon-depot {
  background: #c7a052;
}

.map-object-icon-production {
  background: #7c9f61;
}

.map-object-icon-caravan {
  background: #9fbe8a;
}

.map-object-icon-merchant {
  background: #9ec1d7;
}

.table-button {
  min-height: 25px;
  padding: 4px 7px;
  font-size: 11px;
}

.production-row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.icon-row-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.table-icon-button {
  display: inline-grid;
  place-items: center;
  box-sizing: border-box;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #c7a052;
  border-radius: 4px;
  background: #fffaf0;
  color: var(--ink);
  text-decoration: none;
  line-height: 1;
  vertical-align: middle;
}

.table-icon-button:hover,
.table-icon-button:focus {
  border-color: var(--red);
  background: #fff3d8;
  color: var(--red);
}

.table-icon-button .simple-icon {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 18px;
}

.table-icon-button .army-order-icon {
  width: 18px;
  height: 18px;
}

.table-icon-button .map-picker-icon {
  box-sizing: border-box;
  width: 18px;
  height: 16px;
}

.icon-only-button {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(105, 74, 45, 0.35);
  border-radius: 5px;
  background: #fffaf0;
  color: var(--red);
  cursor: pointer;
  font-weight: 700;
}

.icon-only-button:hover,
.icon-only-button:focus {
  border-color: var(--red);
  background: #fff3d8;
}

.caravan-table th:nth-child(9),
.caravan-table th:nth-child(11),
.caravan-table th:nth-child(13),
.caravan-table td:nth-child(9),
.caravan-table td:nth-child(11),
.caravan-table td:nth-child(13) {
  min-width: 72px;
}

.caravan-table th:nth-child(10),
.caravan-table th:nth-child(12),
.caravan-table th:nth-child(14),
.caravan-table td:nth-child(10),
.caravan-table td:nth-child(12),
.caravan-table td:nth-child(14) {
  min-width: 54px;
  text-align: right;
}

.caravan-page-table th:nth-child(9),
.caravan-page-table th:nth-child(11),
.caravan-page-table th:nth-child(13),
.caravan-page-table td:nth-child(9),
.caravan-page-table td:nth-child(11),
.caravan-page-table td:nth-child(13) {
  width: 64px;
  min-width: 64px;
  padding-right: 3px;
  text-align: right;
  white-space: nowrap;
}

.caravan-page-table th,
.caravan-page-table td {
  vertical-align: middle;
}

.caravan-page-table .good-quantity,
.caravan-page-table .caravan-cargo-good,
.caravan-page-table .caravan-cargo-name {
  line-height: 1;
}

.caravan-page-table th:nth-child(10),
.caravan-page-table th:nth-child(12),
.caravan-page-table th:nth-child(14),
.caravan-page-table td:nth-child(10),
.caravan-page-table td:nth-child(12),
.caravan-page-table td:nth-child(14) {
  width: 82px;
  min-width: 82px;
  padding-left: 3px;
  text-align: left;
}

.caravan-page-table th:nth-child(15),
.caravan-page-table td:nth-child(15) {
  min-width: 76px;
  padding-right: 16px;
  text-align: right;
}

.caravan-table-with-depot th:nth-child(9),
.caravan-table-with-depot th:nth-child(11),
.caravan-table-with-depot th:nth-child(13),
.caravan-table-with-depot td:nth-child(9),
.caravan-table-with-depot td:nth-child(11),
.caravan-table-with-depot td:nth-child(13) {
  min-width: auto;
  text-align: inherit;
}

.caravan-table-with-depot th:nth-child(10),
.caravan-table-with-depot th:nth-child(12),
.caravan-table-with-depot th:nth-child(14),
.caravan-table-with-depot td:nth-child(10),
.caravan-table-with-depot td:nth-child(12),
.caravan-table-with-depot td:nth-child(14) {
  min-width: 72px;
  text-align: left;
}

.caravan-table-with-depot th:nth-child(11),
.caravan-table-with-depot th:nth-child(13),
.caravan-table-with-depot th:nth-child(15),
.caravan-table-with-depot td:nth-child(11),
.caravan-table-with-depot td:nth-child(13),
.caravan-table-with-depot td:nth-child(15) {
  min-width: 54px;
  text-align: right;
}

.caravan-cargo-cell {
  display: inline-grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 5px;
  width: 100%;
  white-space: nowrap;
}

.caravan-position-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.caravan-position-tile {
  flex: 0 0 auto;
}

.caravan-cargo-good {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.caravan-cargo-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.good-quantity {
  min-width: 44px;
  text-align: right;
  font-weight: 800;
}

.good-quantity.is-empty {
  color: var(--muted);
  font-weight: 500;
}

.depot-map-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--blue);
  font-weight: 900;
  text-decoration: none;
}

.depot-map-link:hover,
.depot-map-link:focus {
  color: var(--red);
}

.depot-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #8f1d1d;
  border-radius: 4px;
  background: #f5eadb;
  color: #8f1d1d;
  font-size: 12px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.dashboard-grid.depots-page-grid {
  grid-template-columns: minmax(0, 1fr);
}

.dashboard-grid.battles-page-grid {
  grid-template-columns: minmax(0, 1fr);
}

.battles-page-grid > .panel {
  grid-column: 1;
  min-width: 0;
}

.battles-page-grid > .panel.hidden {
  display: none;
}

.battle-log-list {
  display: grid;
  gap: 7px;
}

.battle-terrain-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}

.battle-terrain-controls label {
  display: grid;
  gap: 4px;
  min-width: 150px;
  font-size: 12px;
  font-weight: 800;
}

.battle-terrain-controls input,
.battle-terrain-controls select {
  min-height: 34px;
  border: 1px solid rgba(101, 67, 33, 0.25);
  border-radius: 4px;
  background: #fffdf7;
  padding: 5px 7px;
}

.battle-terrain-preview-grid {
  display: grid;
  gap: 12px;
}

.battle-terrain-card {
  overflow: hidden;
}

.battle-terrain-map {
  --sim-axis: 22px;
  display: grid;
  grid-template-columns: var(--sim-axis) repeat(30, minmax(16px, 1fr)) var(--sim-axis);
  grid-template-rows: var(--sim-axis);
  grid-auto-rows: minmax(16px, 1fr);
  gap: 1px;
  width: 100%;
  min-width: 820px;
  aspect-ratio: 32 / 52;
  padding: 5px;
  overflow: auto;
  background: #111;
  border: 1px solid rgba(101, 67, 33, 0.24);
}

.battle-terrain-cell {
  display: grid;
  place-items: center;
  container-type: size;
  min-width: 0;
  min-height: 0;
  background: #fffdf7;
  color: #2f241d;
  font-family: "Courier New", Consolas, monospace;
  font-size: 12px;
  font-size: clamp(9px, 38cqw, 17px);
  font-weight: 900;
  line-height: 1;
}

.battle-terrain-cell.strategic {
  outline: 2px solid #2f241d;
  outline-offset: -2px;
  background: #f7ead2;
}

.battle-terrain-cell.camp {
  background: #e5c49b;
}

.battle-log-row {
  border: 1px solid rgba(101, 67, 33, 0.22);
  background: rgba(255, 252, 245, 0.78);
}

.battle-log-summary {
  display: grid;
  grid-template-columns: 18px 82px 112px 150px minmax(180px, 1fr) minmax(170px, auto) 88px auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 8px;
  cursor: pointer;
  font-size: 12px;
}

.battle-history-panel {
  grid-column: 1 / -1;
  width: 100%;
}

.battle-losses {
  color: #7b2f24;
  font-weight: 700;
  white-space: nowrap;
}

.battle-filter-form {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.sim-pending-row {
  cursor: pointer;
}

.sim-pending-row:hover,
.sim-pending-row:focus {
  background: rgba(176, 123, 69, 0.14);
  outline: 1px solid rgba(176, 123, 69, 0.45);
}

.battle-log-summary::-webkit-details-marker {
  display: none;
}

.battle-log-summary::before {
  content: "▸";
  color: #7b4c21;
  font-weight: 700;
}

.battle-log-row[open] .battle-log-summary::before {
  content: "▾";
}

.battle-month,
.battle-location,
.battle-winner {
  color: #5e4632;
  white-space: nowrap;
}

.battle-location {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.battle-detail-body {
  border-top: 1px solid rgba(101, 67, 33, 0.18);
  padding: 9px;
  display: grid;
  gap: 8px;
  font-size: 12px;
  min-width: 0;
}

.battle-detail-body h3 {
  margin: 4px 0 0;
  font-size: 13px;
  color: #5e3217;
}

.battle-collapsible-section {
  border: 1px solid rgba(101, 67, 33, 0.18);
  border-radius: 6px;
  background: rgba(255, 248, 231, 0.58);
}

.battle-collapsible-section > summary {
  cursor: pointer;
  padding: 9px 10px;
  font-weight: 700;
  color: #5e3217;
}

.battle-collapsible-section > .battle-side-grid,
.battle-collapsible-section > .battle-round-table {
  margin: 0 10px 10px;
}

.battle-collapsible-section > table,
.battle-collapsible-section > div {
  margin: 0 10px 10px;
}

.battle-summary-text {
  margin: 0;
  color: #2f241d;
}

.battle-side-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(288px, 1fr));
  gap: 8px;
}

.battle-side-card {
  border: 1px solid rgba(101, 67, 33, 0.18);
  background: rgba(255, 255, 255, 0.58);
  padding: 7px;
}

.battle-side-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  color: #4b2f1d;
}

.battle-inner-table td,
.battle-round-table td,
.battle-round-table th {
  font-size: 11px;
}

.battle-unit-row td {
  color: #6a5a4c;
}

.sim-round-pages {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.sim-round-carousel {
  display: grid;
  gap: 10px;
  outline: none;
  min-width: 0;
}

.sim-round-carousel-toolbar {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  align-items: center;
  gap: 6px;
}

.sim-round-carousel-toolbar strong {
  text-align: center;
  color: #4b2f1d;
}

.sim-round-nav {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(101, 67, 33, 0.28);
  border-radius: 6px;
  background: #fff8e7;
  color: #4b2f1d;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.sim-round-nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.sim-round-page {
  border: 1px solid rgba(101, 67, 33, 0.18);
  background: rgba(255, 255, 255, 0.58);
  min-width: 0;
}

.sim-round-page[hidden] {
  display: none;
}

.sim-round-page > summary {
  cursor: pointer;
  padding: 8px 10px;
  font-weight: 700;
}

.sim-round-a4 {
  width: 100%;
  min-height: 0;
  margin: 0 0 12px;
  padding: 12px;
  background: #fffdf7;
  border: 1px solid rgba(47, 36, 29, 0.18);
  page-break-after: always;
  min-width: 0;
}

.sim-round-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}

.sim-round-header h4,
.sim-round-events h5,
.sim-round-a4 h5 {
  margin: 0;
}

.sim-round-layout {
  display: flex;
  flex-wrap: nowrap;
  align-items: start;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.sim-round-map-column {
  flex: 0 0 calc(56% - 5px);
  position: sticky;
  top: 10px;
  align-self: start;
  z-index: 1;
  width: calc(56% - 5px);
  max-width: calc(56% - 5px);
  min-width: 0;
  overflow: visible;
  box-sizing: border-box;
}

.sim-round-map {
  --round-axis: 18px;
  --round-cell-height: clamp(13px, calc((100vh - 96px) / 50), 17px);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: var(--round-axis) repeat(30, minmax(0, 1fr));
  grid-template-rows: var(--round-axis) repeat(50, var(--round-cell-height));
  gap: 1px;
  background: #111;
  border: 1px solid #111;
  overflow: hidden;
}

.sim-round-axis,
.sim-round-cell {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  font-size: clamp(7px, calc(var(--round-cell-height) * 0.52), 8px);
  line-height: 1;
}

.sim-round-axis {
  background: #fffdf7;
  color: #2f241d;
  font-weight: 700;
}

.sim-round-cell {
  position: relative;
  background: #f9f1dd;
  color: #6a5a4c;
}

.sim-round-cell.camp {
  background: #d8aa72;
}

.sim-round-cell.strategic {
  box-shadow: inset 0 0 0 1px #2f241d;
}

.sim-round-cell.has-unit {
  background: #fff8e7;
}

.sim-round-terrain {
  opacity: 0.45;
}

.sim-round-unit-label {
  position: absolute;
  inset: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-wrap: wrap;
  place-items: center;
  color: #111;
  font-size: 7px;
  font-weight: 800;
  line-height: 1;
  white-space: normal;
}

.sim-round-unit-token.enemy {
  color: #b31919;
}

.sim-round-total-losses {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0 0 3px;
  color: #4b2f1d;
  font-size: 9px;
  line-height: 1.15;
}

.sim-round-events {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.sim-round-events section {
  min-width: 0;
}

.sim-round-events h5 {
  font-size: 10px;
  line-height: 1.1;
}

.sim-round-events .table th,
.sim-round-events .table td {
  font-size: 9px;
  padding: 2px 3px;
}

.sim-round-sticky-panel {
  position: sticky;
  top: 10px;
  z-index: 3;
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  padding: 6px;
  border: 1px solid rgba(101, 67, 33, 0.34);
  background: #f3e3c9;
  box-shadow: 0 4px 12px rgba(47, 36, 29, 0.12);
}

.sim-round-side {
  flex: 0 0 calc(44% - 5px);
  display: grid;
  align-content: start;
  gap: 8px;
  position: relative;
  z-index: 2;
  width: calc(44% - 5px);
  max-width: calc(44% - 5px);
  min-width: 0;
  overflow: visible;
  box-sizing: border-box;
  background: #fffdf7;
}

.sim-round-realm-groups {
  border: 1px solid rgba(101, 67, 33, 0.18);
  background: rgba(255, 255, 255, 0.62);
  min-width: 0;
}

.sim-round-realm-groups > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 5px 7px;
  color: #4b2f1d;
  font-weight: 800;
  list-style: none;
}

.sim-round-realm-groups > summary::-webkit-details-marker {
  display: none;
}

.sim-round-realm-groups > summary::before {
  content: "";
  width: 0;
  height: 0;
  flex: 0 0 auto;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid currentColor;
  transition: transform 0.12s ease;
}

.sim-round-realm-groups[open] > summary::before {
  transform: rotate(90deg);
}

.sim-round-realm-groups .table {
  margin: 0;
}

.sim-round-realms-stack {
  display: grid;
  align-items: start;
  gap: 8px;
}

.sim-round-group-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 6px;
  padding: 6px;
}

.sim-round-group-card {
  border: 1px solid rgba(101, 67, 33, 0.16);
  background: rgba(255, 253, 247, 0.8);
}

.sim-round-group-card header {
  display: grid;
  grid-template-columns: 34px 40px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  border-bottom: 1px solid rgba(101, 67, 33, 0.14);
  color: #2f241d;
  font-size: 9px;
  font-weight: 800;
}

.sim-round-group-card header span {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sim-round-group-card header span:nth-child(4) {
  grid-column: 1 / 3;
}

.sim-round-group-card header span:last-child {
  grid-column: 3 / 4;
  color: #5f4a38;
  text-align: right;
}

.sim-round-group-damage {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 2px 4px;
  color: #6a4a32;
  font-size: 9px;
  font-weight: 800;
}

.sim-round-unit-table th,
.sim-round-unit-table td {
  font-size: 7px;
  padding: 1px 2px;
}

.sim-round-status-table td,
.sim-round-status-table th {
  font-size: 9px;
  padding: 2px 3px;
}

@media (max-width: 900px) {
  .sim-round-layout {
    flex-direction: column;
  }

  .sim-round-map-column {
    width: 100%;
    max-width: 100%;
    position: static;
  }

  .sim-round-side {
    width: 100%;
    max-width: 100%;
  }

  .sim-round-sticky-panel {
    position: static;
  }

}

@media print {
  .battle-filter-form,
  .battle-log-summary,
  .battle-side-grid,
  .battle-round-table,
  .battle-summary-text,
  .sim-round-page > summary,
  .battle-detail-body > h3:not(:has(+ .sim-round-pages)) {
    display: none !important;
  }

  .battle-log-row,
  .sim-round-page {
    border: 0;
  }

  .sim-round-page,
  .sim-round-page[open] {
    display: block;
  }

  .sim-round-a4 {
    width: 210mm;
    min-height: 297mm;
    border: 0;
    margin: 0;
    padding: 9mm;
    page-break-after: always;
  }
}

.simulated-round-list {
  display: grid;
  gap: 6px;
}

.simulated-round-detail {
  border: 1px solid rgba(101, 67, 33, 0.18);
  background: rgba(255, 255, 255, 0.5);
}

.simulated-round-detail summary {
  cursor: pointer;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #5e3217;
}

.simulated-round-detail h4 {
  margin: 6px 8px 4px;
  font-size: 12px;
  color: #5e4632;
}

.simulated-group-table {
  min-width: 980px;
  margin: 0 8px 8px;
}

.simulated-group-table th,
.simulated-group-table td {
  font-size: 10px;
  padding: 3px 4px;
  white-space: nowrap;
}

.simulated-group-table th {
  width: auto;
}

.sim-battle-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sim-battle-actions form {
  margin: 0;
}

.simulated-plan-panel {
  grid-column: 1 / -1;
}

.simulated-plan-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(101, 67, 33, 0.16);
  background: rgba(255, 255, 255, 0.45);
}

.sim-storage-table {
  display: none;
}

.simulated-plan-table {
  min-width: 2140px;
}

.sim-dat-upload-form {
  display: flex;
  align-items: end;
  gap: 12px;
  margin: 12px 0 16px;
  padding: 10px 12px;
  border: 1px solid rgba(101, 67, 33, 0.16);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.58);
}

.sim-dat-upload-form label {
  display: grid;
  gap: 4px;
  min-width: 220px;
  font-size: 12px;
  font-weight: 700;
}

.sim-dat-upload-form input[type="file"] {
  font-size: 12px;
}

.simulated-plan-table th,
.simulated-plan-table td {
  font-size: 11px;
  padding: 4px;
  vertical-align: middle;
}

.simulated-plan-table th {
  width: auto;
}

.tiny-input {
  width: 48px;
  min-height: 26px;
  padding: 2px 4px;
  border: 1px solid rgba(101, 67, 33, 0.28);
  border-radius: 4px;
  background: #fffdf7;
  font-size: 11px;
}

.coord-input-pair {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.sim-editor-foldout,
.sim-map-panel {
  border: 1px solid rgba(101, 67, 33, 0.18);
  background: rgba(255, 255, 255, 0.48);
  margin-bottom: 10px;
}

.sim-editor-foldout > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 900;
  color: #2f241d;
}

.sim-editor-foldout > summary::-webkit-details-marker {
  display: none;
}

.sim-editor-foldout > summary::before {
  content: "";
  width: 0;
  height: 0;
  flex: 0 0 auto;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid currentColor;
  transition: transform 0.12s ease;
}

.sim-editor-foldout[open] > summary::before {
  transform: rotate(90deg);
}

.sim-editor-foldout > summary span {
  min-width: 0;
}

.sim-editor-foldout > :not(summary) {
  margin: 0 8px 8px;
}

.sim-map-panel-wide {
  width: 100%;
}

.sim-map-panel > .sim-cohort-foldout {
  margin: 8px;
}

.sim-editor-head {
  position: relative;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px;
  margin-bottom: 0;
  overflow: visible;
}

.sim-editor-head .sim-round-control {
  flex: 1 1 420px;
  margin: 0;
  min-width: 260px;
}

.sim-plan-head-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.sim-plan-head-actions .button {
  padding: 6px 9px;
  min-height: 30px;
  font-size: 11px;
}

.sim-plan-head-actions .button.is-dirty {
  animation: sim-save-glow 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 2px rgba(242, 201, 76, 0.7), 0 0 16px rgba(242, 201, 76, 0.75);
  color: #fff5b8;
  text-shadow: 0 0 5px rgba(255, 245, 184, 0.85), 0 0 11px rgba(242, 201, 76, 0.9);
}

@keyframes sim-save-glow {
  0%,
  100% {
    box-shadow: 0 0 0 2px rgba(242, 201, 76, 0.55), 0 0 10px rgba(242, 201, 76, 0.45);
    text-shadow: 0 0 4px rgba(255, 245, 184, 0.75), 0 0 9px rgba(242, 201, 76, 0.65);
  }

  50% {
    box-shadow: 0 0 0 3px rgba(242, 201, 76, 0.9), 0 0 22px rgba(242, 201, 76, 0.85);
    text-shadow: 0 0 7px rgba(255, 245, 184, 1), 0 0 16px rgba(242, 201, 76, 0.95);
  }
}

.sim-map-options {
  position: relative;
  flex: 0 0 auto;
  z-index: 80;
}

.sim-icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(47, 36, 29, 0.35);
  border-radius: 4px;
  background: #6f2f1d;
  color: #fff7e7;
  cursor: pointer;
  font-weight: 900;
}

.sim-map-options-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 120;
  width: 240px;
  border: 1px solid rgba(47, 36, 29, 0.22);
  background: #fffdf7;
  box-shadow: 0 10px 24px rgba(47, 36, 29, 0.18);
  padding: 6px;
  border-radius: 6px;
}

.sim-map-options-menu[hidden] {
  display: none;
}

.sim-map-options-menu label {
  display: grid;
  grid-template-columns: 16px 1fr;
  align-items: center;
  column-gap: 7px;
  padding: 7px;
  border-radius: 4px;
  color: #2f241d;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
}

.sim-map-options-menu label:hover {
  background: #f7ead2;
}

.sim-map-options-menu input {
  margin: 0;
}

.sim-round-control {
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr);
  align-items: center;
  gap: 12px;
  margin: 0;
}

.sim-editor-head .sim-round-control,
.sim-editor-head .sim-plan-head-actions,
.sim-editor-head .sim-map-options {
  position: relative;
  z-index: 2;
}

.sim-editor-head .sim-map-options {
  z-index: 80;
}

.sim-editor-head {
  border: 1px solid rgba(101, 67, 33, 0.16);
  background: #fffaf0;
}

.sim-scenario-switch {
  display: grid;
  grid-template-columns: repeat(4, minmax(38px, auto));
  gap: 4px;
}

.sim-scenario-switch button {
  min-height: 28px;
  border: 1px solid rgba(47, 36, 29, 0.32);
  border-radius: 4px;
  background: #fff7e7;
  color: #2f241d;
  padding: 4px 7px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.sim-scenario-switch button.active {
  background: #6f2f1d;
  color: #fff7e7;
}

.sim-round-slider-wrap {
  position: relative;
  min-width: 0;
  padding-top: 18px;
}

.sim-round-control input[type="range"] {
  width: 100%;
}

.sim-round-slider-wrap output {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  min-width: 22px;
  border-radius: 4px;
  background: #2f241d;
  color: #fff7e7;
  padding: 2px 4px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  pointer-events: none;
}

.sim-map {
  --sim-axis: 22px;
  display: grid;
  grid-template-columns: var(--sim-axis) repeat(30, minmax(18px, 1fr)) var(--sim-axis);
  grid-template-rows: var(--sim-axis);
  grid-auto-rows: minmax(18px, 1fr);
  gap: 1px;
  width: 100%;
  min-width: 940px;
  aspect-ratio: 32 / 52;
  padding: 5px;
  border: 1px solid rgba(101, 67, 33, 0.24);
  background: #6f604d;
}

.sim-map-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  overflow: auto;
  padding: 0 8px 8px;
}

.sim-route-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.sim-map-cell {
  position: relative;
  container-type: size;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: #d9ccb7;
  cursor: crosshair;
  z-index: 1;
}

.sim-map-axis {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  background: #3d342b;
  color: #fff4df;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.sim-map-axis-y {
  position: sticky;
  left: 0;
  z-index: 6;
}

.sim-map-axis-y-right {
  position: sticky;
  right: 0;
  z-index: 6;
}

.sim-map-axis-x,
.sim-map-corner {
  position: sticky;
  top: 0;
  z-index: 7;
}

.sim-map-corner {
  left: 0;
  z-index: 8;
}

.sim-map-corner-right {
  right: 0;
  left: auto;
}

.sim-map-axis-x-bottom,
.sim-map-corner-bottom,
.sim-map-corner-bottom-right {
  position: sticky;
  bottom: 0;
  z-index: 7;
}

.sim-map-corner-bottom {
  left: 0;
  z-index: 8;
}

.sim-map-corner-bottom-right {
  right: 0;
  z-index: 8;
}

.sim-cell-symbols {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  gap: clamp(2px, 5cqw, 5px);
  pointer-events: none;
}

.sim-cell-symbols span {
  width: 3px;
  height: 3px;
  width: clamp(3px, 8cqw, 7px);
  height: clamp(3px, 8cqw, 7px);
  border-radius: 50%;
  background: rgba(47, 36, 29, 0.45);
}

.sim-map-cell.camp .sim-cell-symbols span {
  background: rgba(255, 247, 231, 0.78);
}

.sim-map-cell.strategic .sim-cell-symbols span {
  width: 4px;
  height: 4px;
  width: clamp(4px, 10cqw, 8px);
  height: clamp(4px, 10cqw, 8px);
  background: #2f241d;
}

.sim-terrain-symbol {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  font-family: "Courier New", Consolas, monospace;
  font-size: 12px;
  font-size: clamp(10px, 38cqw, 18px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  color: #2f241d;
  pointer-events: none;
  text-align: center;
}

.sim-map:not(.show-troops) .sim-map-cell.has-vb::before,
.sim-map:not(.show-troops) .sim-map-cell.has-vb::after {
  display: none;
}

.sim-map.show-terrain .sim-cell-symbols {
  display: none;
}

.sim-map.show-terrain .sim-terrain-symbol {
  display: grid;
}

.sim-map.show-grid-lines {
  background: #111;
  gap: 1px;
}

.sim-map-cell.route-cell {
  box-shadow: inset 0 0 0 2px rgba(34, 94, 168, 0.7);
}

.sim-map-cell.own-setup {
  background: #efe2c4;
}

.sim-map-cell.camp {
  background: #b07b45;
}

.sim-map-cell.strategic {
  box-shadow: inset 0 0 0 2px #2f241d;
}

.sim-map-cell.has-vb::after {
  content: attr(data-vb);
  position: absolute;
  inset: 2px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #5e3217;
  color: #fff7e7;
  font-size: 12px;
  font-size: clamp(10px, 42cqw, 20px);
  font-weight: 700;
  line-height: 1;
  z-index: 5;
}

.sim-map-cell.has-vb::before {
  content: attr(data-vb-title);
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  z-index: 2;
  overflow: hidden;
  color: #fff7e7;
  font-size: 8px;
  font-size: clamp(7px, 18cqw, 11px);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sim-map-cell.active-vb::after {
  background: #b94724;
}

.sim-map.legacy-map {
  border-color: transparent;
  background: #fffdf7;
}

.sim-map.legacy-map.show-grid-lines {
  background: #111;
}

.sim-map.legacy-map .sim-map-axis {
  background: #fffdf7;
  color: #2f241d;
}

.sim-map.legacy-map .sim-map-cell,
.sim-map.legacy-map .sim-map-cell.own-setup,
.sim-map.legacy-map .sim-map-cell.camp {
  background: #fffdf7;
}

.sim-map.legacy-map .sim-map-cell.route-cell,
.sim-map.legacy-map .sim-map-cell.strategic {
  box-shadow: none;
}

.sim-map.legacy-map .sim-cell-symbols span {
  background: #2f241d;
}

.sim-map.legacy-map .sim-terrain-symbol {
  color: #2f241d;
}

.sim-map.legacy-map .sim-map-cell.has-vb::after {
  inset: 1px;
  background: #fffdf7;
  border: 2px solid #2f241d;
  color: #2f241d;
}

.sim-map.legacy-map .sim-map-cell.has-vb::before {
  color: #2f241d;
}

.sim-plan-row {
  cursor: pointer;
}

.sim-plan-row.active {
  background: rgba(176, 123, 69, 0.18);
  outline: 1px solid rgba(176, 123, 69, 0.45);
}

.sim-unit-select {
  width: 120px;
  min-height: 26px;
  padding: 2px 4px;
  border: 1px solid rgba(101, 67, 33, 0.25);
  border-radius: 4px;
  background: #fffdf7;
  font-size: 11px;
}

.sim-cohort-tray {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
  margin-top: 8px;
  max-height: 360px;
  overflow: auto;
}

.sim-army-cohorts {
  border: 1px solid rgba(101, 67, 33, 0.14);
  background: rgba(255, 255, 255, 0.5);
  padding: 7px;
}

.sim-army-cohorts h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.sim-cohort-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.sim-cohort-chip,
.sim-slot-chip {
  border: 1px solid rgba(101, 67, 33, 0.24);
  border-radius: 4px;
  background: #fffdf7;
  color: #2f241d;
  font-size: 11px;
  padding: 4px 6px;
  cursor: grab;
}

.sim-cohort-chip.assigned {
  opacity: 0.42;
  filter: grayscale(0.85);
  cursor: not-allowed;
}

.sim-group-blocks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.sim-group-block {
  border: 1px solid rgba(101, 67, 33, 0.18);
  background: rgba(255, 255, 255, 0.56);
  padding: 7px;
}

.sim-group-block.active {
  outline: 2px solid rgba(185, 71, 36, 0.65);
}

.sim-group-block-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
}

.sim-slot-list {
  display: grid;
  gap: 4px;
}

.sim-slot {
  min-height: 30px;
  border: 1px dashed rgba(101, 67, 33, 0.28);
  background: rgba(255, 253, 247, 0.76);
  padding: 3px;
}

.sim-slot.drag-over {
  border-color: #b94724;
  background: rgba(185, 71, 36, 0.12);
}

.sim-slot.filled {
  border-style: solid;
}

.sim-order-popover {
  position: fixed;
  z-index: 40;
  right: 10px;
  bottom: 18px;
  width: min(430px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid rgba(47, 36, 29, 0.28);
  background: #fffdf7;
  box-shadow: 0 16px 40px rgba(47, 36, 29, 0.22);
  padding: 10px;
}

.sim-order-popover.popover-left {
  left: 10px;
  right: auto;
}

.sim-order-popover.popover-right {
  right: 10px;
  left: auto;
}

.sim-popover-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.sim-popover-layout section,
.sim-popover-foldout {
  border: 1px solid rgba(101, 67, 33, 0.14);
  background: #fffaf0;
  padding: 8px;
}

.sim-popover-layout h3,
.sim-popover-foldout summary {
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 800;
  color: #2f241d;
}

.sim-popover-foldout summary {
  cursor: pointer;
  list-style-position: inside;
}

.sim-popover-foldout:not([open]) {
  padding-bottom: 4px;
}

.sim-popover-foldout:not([open]) summary {
  margin-bottom: 0;
}

.sim-popover-layout label {
  display: grid;
  gap: 4px;
  margin-bottom: 7px;
  font-size: 12px;
}

.sim-popover-layout select {
  min-height: 30px;
  border: 1px solid rgba(101, 67, 33, 0.28);
  border-radius: 4px;
  background: #fffdf7;
  padding: 4px 6px;
  font-size: 12px;
}

.sim-popover-cohorts {
  display: grid;
  gap: 5px;
  margin-bottom: 8px;
}

.sim-popover-cohort {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid rgba(101, 67, 33, 0.2);
  background: #f7ead2;
  padding: 5px 7px;
  font-size: 11px;
}

.sim-popover-cohort button,
.sim-order-pill button {
  border: 0;
  background: #6f2f1d;
  color: #fff7e7;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
}

.sim-popover-drop {
  border: 1px dashed rgba(101, 67, 33, 0.38);
  background: rgba(247, 234, 210, 0.65);
  padding: 7px;
  margin-bottom: 8px;
  font-size: 12px;
}

.sim-popover-drop.drag-over {
  border-color: #6f2f1d;
  background: rgba(111, 47, 29, 0.14);
}

.sim-order-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -10px -10px 8px;
  padding: 8px 10px;
  background: #2f241d;
  color: #fff7e7;
}

.sim-popover-side-toggle {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(47, 36, 29, 0.35);
  border-radius: 4px;
  background: #fff7e7;
  color: #2f241d;
  cursor: pointer;
  font-weight: 900;
  flex: 0 0 auto;
}

.sim-popover-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sim-popover-actions .button {
  padding: 6px 9px;
}

.sim-order-popover-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.sim-order-popover label {
  display: grid;
  gap: 3px;
  font-size: 11px;
}

.sim-command-presets,
.sim-target-modes,
.sim-target-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.sim-target-list {
  display: grid;
  grid-template-columns: 1fr;
}

.sim-command-list {
  display: grid;
  gap: 8px;
}

.sim-command-row {
  display: grid;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px solid rgba(101, 67, 33, 0.14);
}

.sim-command-row-primary {
  padding: 8px;
  border: 1px solid rgba(111, 47, 29, 0.22);
  background: #fff4df;
}

.sim-target-list button[hidden] {
  display: none;
}

.sim-command-presets button,
.sim-target-modes button,
.sim-target-list button {
  border: 1px solid rgba(47, 36, 29, 0.4);
  border-radius: 4px;
  background: #6f2f1d;
  color: #fff7e7;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 700;
}

.sim-target-modes button.active,
.sim-target-list button.active {
  background: #2f5c8f;
  box-shadow: 0 0 0 2px rgba(242, 201, 76, 0.55);
}

.sim-current-orders {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.sim-order-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(47, 36, 29, 0.22);
  border-radius: 4px;
  background: #efe2c4;
  padding: 4px 5px;
  font-size: 11px;
}

.sim-legacy-preview {
  min-height: 180px;
  max-height: 430px;
  overflow: auto;
  margin: 0;
  padding: 8px;
  border: 1px solid rgba(101, 67, 33, 0.18);
  background: #2f241d;
  color: #fff4df;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre;
}

@media (max-width: 980px) {
  .sim-popover-layout {
    grid-template-columns: 1fr;
  }

  .sim-order-popover-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.depots-page-grid > .depot-main-panel {
  order: 4;
}

.depots-page-grid > .page-order-section {
  order: 1;
}

.depots-page-grid > .depot-order-panel {
  order: 2;
}

.depots-page-grid > .depot-realm-panel {
  order: 3;
}

.diplomacy-page-grid > .page-order-section {
  order: 0;
}

.diplomacy-page-grid > .production-order-panel {
  order: 1;
}

.population-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.population-table-panel {
  width: 100%;
}

.wide-panel {
  grid-column: span 2;
}

.accordion-list {
  display: grid;
  gap: 7px;
}

.army-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fffaf0;
  overflow: hidden;
}

.army-card summary,
.report-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.army-card summary {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 70px 70px 100px;
  gap: 8px;
  padding: 8px 10px;
  align-items: center;
}

.army-card table {
  margin: 0;
  border-top: 1px solid var(--line);
}

.military-page-grid {
  grid-template-columns: minmax(0, 1fr);
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.heading-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.section-heading-row h2 {
  margin: 0;
}

.military-commanders-table th,
.military-commanders-table td {
  white-space: nowrap;
}

.military-troop-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 6px;
}

.military-troop-grid label {
  min-width: 0;
}

.recruit-cost-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.45);
  font-size: 13px;
}

.recruit-cost-summary strong {
  margin-right: 4px;
}

.recruit-troop-table-block {
  margin-top: 12px;
}

.recruit-troop-table-block h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.recruit-troop-table {
  min-width: 980px;
}

.recruit-troop-table th,
.recruit-troop-table td {
  white-space: nowrap;
}

.army-report-card {
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 4px;
  background: #fffaf0;
  margin-bottom: 8px;
  overflow: hidden;
}

.army-report-header {
  display: grid;
  grid-template-columns: 28px minmax(180px, 1.2fr) minmax(98px, 0.7fr) repeat(4, minmax(58px, 0.4fr)) auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #f5eadb;
  font-size: 12px;
}

.army-order-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  white-space: nowrap;
}

.army-order-button {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid #c7a052;
  border-radius: 4px;
  background: #fffaf0;
  color: #5b3322;
  text-decoration: none;
}

.army-order-button:hover,
.army-order-button:focus {
  border-color: var(--red);
  color: var(--red);
  background: #fff3d8;
}

.army-order-button.danger {
  border-color: #b98a75;
  color: #8f1d1d;
}

.army-order-icon {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.army-order-icon::before {
  display: block;
}

.army-order-icon-move::before {
  content: ">";
  transform: rotate(-45deg);
}

.army-order-icon-add::before {
  content: "+";
}

.army-order-icon-group::before {
  content: "#";
}

.army-order-icon-men::before {
  content: "^";
}

.army-order-icon-exp::before {
  content: "*";
}

.army-order-icon-swap::before {
  content: "<>";
  font-size: 12px;
}

.army-order-icon-merge::before {
  content: "><";
  font-size: 12px;
}

.army-order-icon-disband::before {
  content: "X";
}

.formations-page-grid {
  grid-template-columns: minmax(0, 1fr);
}

.formation-assign-panel,
.formation-category-panel {
  overflow-x: auto;
}

.formation-assign-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px) auto;
  align-items: end;
  gap: 10px;
}

.formation-group {
  border-top: 1px solid rgba(105, 74, 45, 0.18);
  padding-top: 8px;
}

.formation-group + .formation-group {
  margin-top: 8px;
}

.formation-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  color: var(--brown);
  font-weight: 700;
}

.formation-group .inline-form {
  margin-top: 0;
}

.army-unit-lines {
  display: grid;
  gap: 0;
}

.army-unit-line {
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
  border-bottom: 1px solid #ead7bd;
}

.army-unit-line:last-child {
  border-bottom: 0;
}

.army-unit-slot {
  min-height: 34px;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 2px 5px;
  align-content: center;
  padding: 4px 6px;
  border-right: 1px solid #ead7bd;
  font-size: 11px;
}

.army-unit-slot:last-child {
  border-right: 0;
}

.army-unit-slot strong {
  font-size: 12px;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}

.army-unit-slot span:not(.army-slot-number) {
  grid-column: 2;
}

.army-unit-exp {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.army-slot-number {
  grid-row: 1 / span 3;
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #7f2a1d;
  color: #fffaf0;
  font-weight: 900;
  font-size: 10px;
}

.army-unit-slot.is-empty {
  color: var(--muted);
  background: rgba(234, 215, 189, 0.25);
}

.report-panel summary {
  display: grid;
  gap: 3px;
}


.tile-object-list {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.tile-object-list h3 {
  margin: 0;
  color: #3b2a1d;
  font-size: 11px;
  text-transform: uppercase;
}

.report-panel summary span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.report-page {
  display: grid;
  gap: 10px;
}

.report-document-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid #3b2a1d;
}

.report-document-head h2 {
  margin: 0 0 3px;
  color: #3b2a1d;
  font-size: 18px;
}

.report-document-meta,
.report-badges {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.report-document-meta span {
  font-size: 12px;
  font-weight: 900;
  color: #3b2a1d;
}

.report-selector {
  max-width: 360px;
}

.report-selector label {
  min-width: 0;
}

.report-selector-row {
  display: flex;
  align-items: end;
  gap: 8px;
}

.report-selector-row label {
  flex: 1 1 360px;
}

.report-selector-row .button {
  flex: 0 0 auto;
  min-height: 36px;
}

.report-sections {
  gap: 14px;
}

.report-section {
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.report-section h2 {
  margin: 0 0 7px;
  color: #3b2a1d;
  font-size: 15px;
}

.report-ruler-line {
  margin: 0 0 8px;
}

.report-table {
  font-size: 11px;
}

.report-table th,
.report-table td {
  padding: 4px 5px;
}

.movement-order-line {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 11px;
  line-height: 1.25;
}

.movement-object {
  font-size: 11px;
  white-space: nowrap;
}

.movement-object-icon {
  font-size: 11px;
}

.movement-point {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 6px 2px 2px;
  border: 1px solid rgba(93, 64, 38, 0.14);
  border-radius: 2px;
  background: #fffdf7;
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
}

.movement-step {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 6px;
  border: 1px solid rgba(93, 64, 38, 0.14);
  border-radius: 2px;
  background: #fff8e8;
  color: #5f4b35;
  font-size: 11px;
  line-height: 1.25;
}

.movement-arrow {
  color: #8b5e2a;
  font-weight: 900;
}

.rule-section-list {
  display: grid;
  gap: 14px;
}

.rule-section-text {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.rule-section-text pre {
  margin: 0;
  white-space: pre-wrap;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.report-wide-table {
  overflow-x: auto;
}

.report-armies-table th,
.report-armies-table td {
  white-space: nowrap;
}

@media (max-width: 860px) {
  .app-page {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content {
    padding: 12px;
  }

  .map-page-grid {
    grid-template-columns: 1fr;
  }

  .player-map-grid {
    grid-template-columns: 1fr;
  }

  .overview-map-header {
    display: grid;
  }

  .overview-map-controls {
    width: auto;
    flex: none;
  }

  .overview-stats {
    grid-template-columns: repeat(3, minmax(80px, 1fr));
  }

  .player-map-shell {
    height: clamp(420px, calc(100vh - 260px), 620px);
  }

  .depot-order-grid {
    grid-template-columns: 1fr;
  }

  .market-order-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .money-order-grid {
    grid-template-columns: 1fr;
  }

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

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

  .production-field-coordinate,
  .production-field-workers,
  .production-field-type,
  .production-field-note {
    min-width: 100%;
  }

  .wide-panel {
    grid-column: auto;
  }

  .population-province-header,
  .population-detail-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .army-card summary {
    grid-template-columns: 1fr 58px;
  }

  .map-detail-panel {
    position: static;
    max-height: none;
  }

  label {
    min-width: 100%;
  }
}
