:root {
  color-scheme: dark;
  --bg: #101316;
  --panel: #171b20;
  --panel-2: #1f252b;
  --line: #303943;
  --text: #eef2f4;
  --muted: #aeb8c0;
  --accent: #d9a441;
  --accent-2: #61b884;
  --danger: #d66d5f;
  --city: #406c8b;
  --plain: #556b48;
  --forest: #2f6046;
  --mountain: #67625c;
  --castle: #75435a;
  --wall: #242a30;
  --log-height: 180px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

body.resizing-log {
  cursor: row-resize;
  user-select: none;
}

.hidden {
  display: none !important;
}

#app {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) var(--log-height);
  height: 100dvh;
  min-height: 0;
}

.desktop-only-notice {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11161a;
  color: var(--text);
  min-height: 36px;
}

input[type="range"] {
  min-height: 0;
  accent-color: var(--accent);
}

button {
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  color: #17130a;
  border-color: var(--accent);
  font-weight: 700;
}

button:disabled {
  color: #77818a;
  border-color: #26313a;
  cursor: not-allowed;
}

button.insufficient-action:disabled {
  background: #20252a;
  color: #8a939c;
  border-color: #303943;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 42px;
}

h2 {
  font-size: 16px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(rgba(18, 23, 27, 0.82), rgba(18, 23, 27, 0.86)),
    url("/images/back_ground/back_ground.png") center / cover fixed,
    #12171b;
}

.brand,
.clock,
.tabs,
.section-head,
.map-toolbar,
.exchange-row,
.division-form,
.debug-controls,
.log-toolbar,
.range-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand strong {
  font-size: 18px;
}

#statusBadge {
  padding: 3px 8px;
  border-radius: 999px;
  background: #2b333a;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  justify-content: center;
}

.tab.active {
  background: var(--panel-2);
  border-color: var(--accent);
}

.clock {
  justify-content: flex-end;
  color: var(--muted);
}

.clock button {
  min-height: 32px;
}

.clock span:first-child {
  color: var(--text);
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(8, 11, 13, 0.58), rgba(8, 11, 13, 0.76)),
    url("/images/back_ground/back_ground.png") center / cover fixed,
    var(--bg);
}

.main-pane,
.side-pane {
  min-height: 0;
  padding: 16px;
  overflow: auto;
}

.main-pane {
  border-right: 1px solid var(--line);
}

.side-pane {
  display: grid;
  align-content: start;
  gap: 18px;
  background: rgba(18, 23, 27, 0.88);
}

.start-screen {
  display: grid;
  place-items: center;
  min-height: 320px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(217, 164, 65, 0.13), rgba(97, 184, 132, 0.08)), var(--panel);
  text-align: center;
}

.start-screen p {
  color: var(--muted);
}

.start-screen.hidden {
  display: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.resources {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.resource,
.barracks-card,
.card,
.task,
.division-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.resource {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 96px;
  padding: 9px;
}

.currency-resource {
  grid-template-columns: 1fr;
  gap: 8px;
}

.currency-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.currency-item .resource-icon {
  width: 34px;
  height: 34px;
}

.resource-icon {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.42));
}

.resource-body {
  min-width: 0;
}

.resource span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.resource strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  line-height: 1.05;
}

.resource strong.negative-stock {
  color: #ff6b6b;
}

.resource small {
  display: block;
  margin-top: 2px;
  color: var(--accent-2);
  font-size: 12px;
}

.resource .resource-upkeep {
  color: #ff6b6b;
  font-weight: 700;
}

.resource .resource-upkeep-placeholder {
  visibility: hidden;
}

.currency-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.exchange-unit-toggle {
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
}

.resource-exchange {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 28px;
  margin-top: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.resource-exchange small {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.resource-exchange img {
  width: 13px;
  height: 13px;
  object-fit: contain;
}

.exchange-unit-choices {
  display: grid;
  gap: 8px;
}

.exchange-unit-choices label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14191e;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.exchange-unit-choices input {
  margin: 0;
}

.settings-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14191e;
  color: var(--text);
  font-weight: 700;
}

.settings-option input {
  margin: 0;
}

.placement-choice {
  display: inline-grid;
  grid-template-columns: auto minmax(140px, 1fr);
  align-items: center;
  gap: 8px;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.placement-choice select {
  min-height: 34px;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 8px;
}

.item-grid {
  display: grid;
  gap: 8px;
}

.card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.building-progress {
  display: grid;
  gap: 4px;
  min-width: 104px;
  color: var(--muted);
  font-size: 11px;
}

.building-progress strong {
  color: var(--text);
  font-size: 12px;
}

.building-progress .progress {
  min-width: 104px;
}

.building-progress.is-queued {
  place-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(20, 25, 30, 0.82);
}

.unit-card {
  grid-template-columns: 60px 1fr auto;
}

.train-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(48px, 1fr));
  gap: 5px;
}

.train-actions button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.unit-card-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 6px;
}

.card-title {
  font-weight: 700;
}

.unit-title,
.building-title {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.unit-ability-button,
.building-effect-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  min-height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  border-color: rgba(217, 164, 65, 0.6);
  background: rgba(217, 164, 65, 0.16);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.building-effect-button {
  min-width: 30px;
  border-color: rgba(98, 164, 126, 0.62);
  background: rgba(98, 164, 126, 0.18);
  color: #aee0bf;
}

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

.training-costs,
.building-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 7px;
}

.resource-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text);
  line-height: 1;
}

.resource-cost img {
  width: 17px;
  height: 17px;
  object-fit: contain;
}

.resource-cost strong,
.training-time {
  font-size: 11px;
  font-weight: 700;
}

.training-time {
  color: var(--muted);
}

.barracks-card {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
}

.barracks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.barracks-head h2 {
  margin: 0;
}

.barracks-head button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  font-weight: 700;
}

.special-actions {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.special-action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
}

.special-action-grid button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 58px;
  font-weight: 700;
  text-align: left;
}

.special-action-grid button > span:first-child,
.special-action-grid button > small {
  grid-column: 1;
}

.special-action-grid button > small {
  color: var(--muted);
  font-weight: 500;
}

.special-action-grid .diamond-cost {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-self: end;
}

.exchange-row select {
  flex: 1;
}

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

.division-form input {
  width: 96px;
  padding: 0 8px;
}

.unit-input {
  display: grid;
  grid-template-columns: 28px minmax(58px, 0.75fr) minmax(148px, 1.55fr) 42px 32px 32px;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11161a;
  color: var(--muted);
  font-size: 13px;
}

.unit-input-grid {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr;
  gap: 6px;
  width: 100%;
}

.unit-counts {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.unit-counts strong {
  color: var(--text);
  font-weight: 700;
}

.unit-input img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 4px;
}

.unit-input input {
  width: 42px;
  min-height: 28px;
  padding: 0 4px;
  border-color: transparent;
  background: rgba(246, 241, 220, 0.08);
  color: var(--text);
  text-align: center;
  pointer-events: none;
  font-size: 13px;
}

.unit-input.compact {
  grid-template-columns: 28px minmax(58px, 0.75fr) minmax(148px, 1.55fr) 42px 32px 32px;
}

.unit-input.compact img {
  width: 24px;
  height: 24px;
}

.unit-input.compact input {
  width: 42px;
}

.unit-step-button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  border-radius: 5px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.unit-step-button:hover {
  border-color: var(--accent);
}

#divisionName {
  width: 100%;
}

.edit-division-form {
  margin-top: 10px;
}

.edit-division-form select,
#editDivisionName {
  width: 100%;
}

.pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.pool-unit {
  display: inline-grid;
  grid-template-columns: 24px auto auto;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 8px 4px 5px;
  border: 1px solid rgba(218, 203, 166, 0.18);
  border-radius: 6px;
  background: rgba(246, 241, 220, 0.05);
  color: var(--text);
}

.pool-unit img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.pool-unit strong {
  color: var(--accent);
}

.pool-empty {
  color: var(--muted);
}

.debug-controls {
  margin-top: 6px;
  flex-wrap: wrap;
  gap: 4px;
}

.debug-controls button {
  flex: 1 1 44px;
  min-height: 26px;
  padding: 3px 6px;
  font-size: 0.75rem;
}

.debug-section {
  padding-bottom: 2px;
}

.debug-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.debug-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.75rem;
}

.pending-reorg {
  color: #d7a64e;
  font-size: 0.76rem;
  font-weight: 700;
}

.map-toolbar {
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.map-toolbar select {
  min-width: 180px;
}

.range-control {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11161a;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.range-control input {
  width: 118px;
}

.step-button {
  width: 28px;
  min-height: 28px;
  padding: 0;
  font-weight: 700;
}

.range-control strong {
  min-width: 44px;
  color: var(--text);
  font-size: 12px;
  text-align: right;
}

#selectionInfo {
  color: var(--muted);
}

.map-wrap {
  position: relative;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1114;
}

#hexMap {
  display: block;
  width: 1040px;
  height: 900px;
}

.hex {
  fill: transparent;
  stroke: rgba(10, 14, 16, 0.72);
  stroke-width: 2;
  cursor: pointer;
}

.hex-image,
.route-arrow,
.resource-site-marker,
.resource-site-icon,
.battle-effect {
  pointer-events: none;
}

.division-marker {
  cursor: help;
}

.map-tooltip {
  position: fixed;
  z-index: 40;
  max-width: min(230px, calc(100vw - 24px));
  padding: 5px 6px;
  border: 1px solid rgba(231, 190, 106, 0.72);
  border-radius: 7px;
  background: rgba(13, 17, 20, 0.94);
  color: var(--text);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.38);
  font-size: 7px;
  line-height: 1.35;
  white-space: pre-line;
  pointer-events: none;
}

.map-tooltip.hidden,
.ui-tooltip.hidden {
  display: none;
}

.ui-tooltip {
  position: fixed;
  z-index: 45;
  max-width: min(280px, calc(100vw - 24px));
  padding: 8px 10px;
  border: 1px solid rgba(231, 190, 106, 0.72);
  border-radius: 7px;
  background: rgba(13, 17, 20, 0.96);
  color: var(--text);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.38);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  white-space: pre-line;
  pointer-events: none;
}

.battle-effect {
  opacity: 0.86;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.wall-image {
  filter: brightness(0.43) saturate(0.82);
}

.resource-site-badge {
  fill: rgba(246, 241, 220, 0.82);
  stroke: rgba(39, 29, 18, 0.72);
  stroke-width: 1.8;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.58));
}

.resource-site-icon {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.68)) saturate(1.16) contrast(1.08);
}

.unoccupied-resource-site {
  opacity: 0.44;
}

.occupied-resource-site {
  opacity: 1;
}

.hex:hover {
  stroke: var(--accent);
  stroke-width: 3;
}

.selected-hex {
  stroke: var(--accent);
  stroke-width: 4;
}

.route-arrow {
  opacity: 0.92;
  filter: saturate(1.35) brightness(1.02) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

.player-route-arrow {
  filter: hue-rotate(175deg) saturate(1.75) brightness(1.08) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

.moving-route-arrow {
  opacity: 0.66;
}

.moving-route-arrow.player-route-arrow {
  filter: hue-rotate(175deg) saturate(1.45) brightness(0.95) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

.moving-route-arrow.demon-route-arrow {
  filter: saturate(1.55) brightness(1.02) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

.active-route-arrow {
  opacity: 0.98;
}

.active-route-arrow.player-route-arrow {
  filter: hue-rotate(185deg) saturate(2.05) brightness(1.18) drop-shadow(0 2px 2px rgba(0, 0, 0, 0.48));
}

.waypoint-hex {
  stroke: #f2d36b;
  stroke-width: 5;
}

.destination-hex {
  stroke: #ff8a6a;
  stroke-width: 5;
}

.selected-division-hex {
  stroke: #ff3f3f;
  stroke-width: 6;
}

.terrain-wall {
  cursor: not-allowed;
}

.terrain-wall:hover {
  stroke: #53606b;
}

.tasks,
.divisions {
  display: grid;
  gap: 8px;
}

.side-queue-section {
  display: grid;
  gap: 10px;
}

.side-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10, 13, 16, 0.55);
}

.side-tab {
  min-height: 32px;
  padding: 5px 6px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.side-tab.active {
  background: rgba(217, 164, 65, 0.2);
  color: var(--text);
}

.side-panel {
  display: none;
}

.side-panel.active {
  display: grid;
  gap: 10px;
}

.task,
.division-card {
  padding: 10px;
}

.task {
  display: grid;
  gap: 8px;
}

.task-head,
.task-actions,
.command-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-head {
  justify-content: space-between;
}

.task-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.task-cancel {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 0.78rem;
}

.selectable-task {
  cursor: pointer;
}

.selectable-task:hover {
  border-color: rgba(111, 78, 42, 0.45);
  box-shadow: 0 4px 12px rgba(59, 42, 24, 0.12);
}

.task-combat-units {
  display: grid;
  gap: 5px;
  margin: 2px 0 4px;
  color: #4a3925;
  font-size: 0.82rem;
  line-height: 1.35;
}

.combat-phase {
  width: max-content;
  padding: 2px 7px;
  border: 1px solid #56606a;
  border-radius: 6px;
  color: #d9e6ef;
  background: #19212a;
  font-size: 0.76rem;
  font-weight: 700;
}

.combat-location {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.task-combat-units > div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.combat-side-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 700;
}

.combat-command {
  flex: 0 0 auto;
  color: #755d38;
  font-weight: 700;
  font-size: 0.78rem;
}

.combat-retreat {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 3px 8px;
  border-color: #9b3d2e;
  color: #f7d9d2;
  background: #703126;
  font-size: 0.75rem;
}

.combat-retreat:disabled {
  opacity: 0.6;
  cursor: default;
}

.unit-composition {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.unit-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 42px;
  height: 26px;
  padding: 2px 5px 2px 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #10161a;
  color: var(--text);
  font-size: 11px;
  line-height: 1;
}

.unit-chip img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.unit-chip strong {
  font-size: 11px;
  font-weight: 800;
}

.diamond-cost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
}

.diamond-cost img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.player-division-card {
  cursor: pointer;
}

.player-division-card:hover {
  border-color: var(--accent);
}

.selected-division-card {
  border-color: var(--accent);
  background: #25261f;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #0d1114;
  margin-top: 8px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent-2);
}

.command-line {
  margin-top: 8px;
}

.command-line span {
  flex: 0 0 52px;
}

.command-gauge {
  height: 8px;
  flex: 1;
  overflow: hidden;
  border-radius: 999px;
  background: #0d1114;
}

.command-gauge > span {
  display: block;
  height: 100%;
}

.command-high > span {
  background: var(--accent-2);
}

.command-mid > span {
  background: var(--accent);
}

.command-low > span {
  background: var(--danger);
}

.log-pane {
  display: grid;
  grid-template-rows: 8px auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  border-top: 1px solid var(--line);
  background: #0d1114;
  padding: 0 16px 12px;
  overflow: hidden;
}

.log-resize-handle {
  height: 8px;
  margin: 0 -16px;
  cursor: row-resize;
  border-bottom: 1px solid transparent;
}

.log-resize-handle:hover,
.log-resize-handle:focus-visible,
body.resizing-log .log-resize-handle {
  border-bottom-color: var(--accent);
  background: rgba(217, 164, 65, 0.12);
  outline: none;
}

.log-toolbar {
  justify-content: space-between;
  min-height: 32px;
}

.log-height-value {
  color: var(--muted);
  font-size: 12px;
}

.logs {
  height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
  color: #d7dee3;
  font-size: 13px;
}

.error {
  color: var(--danger);
}

.command-menu {
  position: fixed;
  z-index: 20;
  display: grid;
  gap: 4px;
  min-width: 92px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(20, 25, 30, 0.97);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.38);
}

.command-menu.hidden {
  display: none;
}

.command-menu button {
  justify-content: flex-start;
  min-height: 30px;
  padding: 5px 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.command-menu button:hover:not(:disabled),
.command-menu button:focus-visible:not(:disabled) {
  background: rgba(217, 164, 65, 0.18);
  outline: none;
}

.command-menu button:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.55;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 10;
}

.modal-backdrop.hidden {
  display: none;
}

.modal {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.modal-wide {
  width: min(1060px, calc(100vw - 32px));
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.modal-body {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.modal-section {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #14191e;
}

.modal-section h3 {
  margin: 0;
  font-size: 15px;
}

#divisionModal .modal-body {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

#divisionModal .unit-input-grid {
  grid-template-columns: 1fr;
}

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

.confirm-skip {
  margin-right: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1000px) {
  .topbar,
  .layout,
  .columns {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-rows: minmax(0, 1fr) minmax(132px, 34%);
    overflow: hidden;
  }

  .topbar {
    height: auto;
    padding: 12px;
  }

  .clock,
  .tabs {
    justify-content: flex-start;
  }

  .main-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .main-pane,
  .side-pane {
    overflow: auto;
  }

  .resources {
    grid-template-columns: repeat(2, 1fr);
  }

  .barracks-head {
    align-items: stretch;
    flex-direction: column;
  }

  .special-action-grid {
    grid-template-columns: 1fr;
  }

  .range-control {
    width: 100%;
    justify-content: space-between;
  }

  .range-control input {
    flex: 1;
    min-width: 90px;
  }

  .unit-input-grid {
    grid-template-columns: 1fr;
  }

  #divisionModal .modal-body {
    grid-template-columns: 1fr;
  }

  .log-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 767px) {
  body {
    overflow: hidden;
  }

  #app {
    display: none;
  }

  .desktop-only-notice {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding: 24px;
    background:
      linear-gradient(rgba(16, 19, 22, 0.86), rgba(16, 19, 22, 0.92)),
      var(--bg-image, var(--bg));
    background-size: cover;
    background-position: center;
  }

  .desktop-only-notice > div {
    width: min(420px, 100%);
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(23, 27, 32, 0.94);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  }

  .desktop-only-notice h1 {
    margin-bottom: 12px;
    font-size: 28px;
  }

  .desktop-only-notice p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.7;
  }
}
