:root {
  color-scheme: dark;
  scrollbar-gutter: stable;
  --bg: #161814;
  --panel: #21241c;
  --inset: #191d16;
  --line: #3e412f;
  --gold: #e1bb75;
  --text: #f1e9d5;
  --muted: #bab7a3;
  --green: #b5bd89;
  --display: Georgia,"Times New Roman",serif;
  font-family:system-ui,sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: radial-gradient(ellipse at 50% 0,#292c20 0%,transparent 66%),var(--bg);
  min-height: 100vh;
}

button,input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: .52;
}

a {
  color: inherit;
  text-decoration: none;
}

button:focus-visible,a:focus-visible,input:focus-visible {
  outline: 2px solid #f1ce83;
  outline-offset: 3px;
}

.shell {
  width: min(1296px,calc(100% - 72px));
  margin-inline: auto;
}

.topbar {
  background: #171a14;
  border-bottom: 1px solid #363a2c;
}

.topbar-inner {
  min-height: 75px;
  display: flex;
  align-items: center;
  gap: 42px;
  justify-content:space-between;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 175px;
}

.crest {
  height: 42px;
  width: 42px;
  display: grid;
  place-items: center;
  color: #ecd49a;
  background: #303124;
  border: 1px solid #6b6040;
  font-size: 25px;
  clip-path: polygon(0 0,100% 0,100% 78%,50% 100%,0 78%);
}

.brand-materia,.brand-kingdoms {
  display: block;
  font-family: var(--display);
  text-transform: uppercase;
}

.brand-materia {
  font-size: .76rem;
  letter-spacing: .38em;
  color: var(--gold);
  line-height: 1.4;
}

.brand-kingdoms {
  font-size: 1.28rem;
  letter-spacing: .13em;
}

.topbar nav {
  display: flex;
  align-self:stretch;
  gap: 7px;
}

.topbar button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: #c0bfab;
  font-size: .94rem;
  padding: 0 21px;
}

.topbar button span {
  margin-left: 5px;
}

.topbar button:hover,.topbar button[aria-current] {
  background: #262a1e;
  color: var(--gold);
  border-bottom-color: #c5a265;
}

.realm {
  color: #c8c6b0;
  font-size: .88rem;
  white-space: nowrap;
}

.realm span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a1ad76;
  margin-right: 8px;
}

.resource-bar {
  background: #20231a;
  border-bottom: 1px solid var(--line);
}

.resources {
  display: grid;
  grid-template-columns: repeat(5,1fr);
  min-height: 73px;
}

.resource {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 19px;
  border-right: 1px solid #393c2b;
}

.resource:first-child {
  border-left: 1px solid #393c2b;
}

.icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid #57563b;
  background: #323522;
  border-radius: 4px;
  color: var(--gold);
  font-size: 1.18rem;
}

.wood {
  color: #dbac75;
}

.stone {
  color: #c3c5ae;
}

.iron {
  color: #b5c3c4;
}

.food {
  color: #d6ca73;
}

.gold {
  color: #f4cb62;
}

.resource-label {
  font-size: .8rem;
  color: var(--muted);
  display: block;
}

.resource-value {
  font-size: 1.08rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.resource-rate {
  color: var(--green);
  margin-left: auto;
  font-size: .79rem;
  white-space: nowrap;
  text-align: right;
}

.resource-fill {
  --fill-color: #9ba875;
  position: absolute;
  inset: auto 18px 8px;
  width: calc(100% - 36px);
  height: 6px;
  appearance: none;
  overflow: hidden;
  border-radius: 3px;
  background: #16190f;
}

.resource-fill::-webkit-meter-bar {
  border: 0;
  background: #16190f;
}

.resource-fill::-webkit-meter-optimum-value {
  background: var(--fill-color);
}

.resource-fill::-moz-meter-bar {
  background: var(--fill-color);
}

.resource-fill[data-full] {
  --fill-color: #efc873;
}

.resource:has(.resource-fill[data-full]) .resource-rate {
  color: #efc873;
  font-weight: 700;
}

.hero {
  margin: 25px 0 22px;
  padding: 24px 28px 23px;
  border: 1px solid #4c4938;
  border-radius: 6px;
  background: linear-gradient(90deg,#22261b 8%,#22261be8 33%,#22261b27 85%),url(/frontier.jpg) center 48%/cover;
  color: var(--text);
  box-shadow: inset 0 0 35px #14181050;
}

.hero p {
  margin: 0;
  color: #e0d6ba;
}

.hero p:first-child {
  color: #e9c785;
  text-transform: uppercase;
  letter-spacing: .17em;
  font-size: .76rem;
  font-weight: 700;
}

.hero h1 {
  font: normal clamp(2.25rem,5vw,3.4rem)/1.03 var(--display);
  margin: .28rem 0 .5rem;
}

.hero p:last-child {
  font-size: .9rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0,2.05fr) minmax(290px,1fr);
  gap: 20px;
  align-items:start;
  padding-bottom: 32px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 5px 18px #0002;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content:space-between;
  gap: 12px;
  padding: 15px 18px;
  background: #272a20;
  border-bottom: 1px solid var(--line);
}

h2,h3 {
  font-family: var(--display);
  font-weight: normal;
  margin: 0;
}

h2 {
  font-size: 1.38rem;
}

h3 {
  font-size: 1.18rem;
}

.panel-heading small,.muted {
  color: var(--muted);
  font-size: .86rem;
}

.panel-body {
  padding: 16px 18px;
}

.panel-body>p:first-child {
  margin-top: 0;
}

.panel-body>p:last-child {
  margin-bottom: 0;
}

.panel-stack {
  display: grid;
  gap: 15px;
}

.detail p {
  margin: 9px 0 14px;
  color: var(--muted);
  line-height: 1.5;
  font-size: .9rem;
}

.detail .reason {
  margin: 10px 0 0;
}

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

.tag {
  border: 1px solid #63563a;
  background: #322c1d;
  color: #e4c98a;
  border-radius: 3px;
  padding: 4px 7px;
  white-space: nowrap;
  font-size: .8rem;
}

.section-note {
  padding: 12px 18px;
  color: var(--muted);
  margin: 0;
  font-size: .88rem;
  border-top: 1px solid var(--line);
}

.lot {
  border: 0;
  background: #24271e;
  color: var(--text);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  font-size: .88rem;
}

.lot:hover,.lot[aria-pressed=true] {
  background: #343626;
}

.lot[aria-pressed=true] .icon {
  border-color: #ba9b60;
}

.lot small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.lot .icon {
  width: 29px;
  height: 29px;
}

.costs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 11px 0 13px;
}

.cost {
  white-space: nowrap;
  font-size: .86rem;
  color: var(--text);
  background: #191d16;
  border: 1px solid #414430;
  border-radius: 3px;
  padding: 5px 7px;
}

.cost span {
  margin-right: 3px;
}

.action {
  background: #d4af68;
  color: #211c12;
  border: 1px solid #e3bf7e;
  border-radius: 4px;
  padding: 9px 13px;
  font-weight: 700;
}

.action:hover:not(:disabled) {
  background: #e8c486;
}

.action.secondary {
  background: #303426;
  border-color: #52553e;
  color: var(--text);
}

.action.secondary:hover:not(:disabled) {
  background: #414531;
}

.detail .action {
  width: 100%;
  margin-top: 2px;
}

.feedback {
  color: #ffe2ab;
  background: #39311f;
  border: 1px solid #79613b;
  border-radius: 4px;
  margin-bottom: 15px;
  padding: 10px 15px;
}

.feedback button {
  margin-left: 8px;
}

.queue {
  margin: 0;
  padding: 0;
  list-style: none;
}

.queue li {
  display: flex;
  justify-content:space-between;
  gap: 9px;
  align-items: center;
  padding: 10px 0;
}

.queue li+li {
  border-top: 1px solid var(--line);
}

.queue li:first-child {
  padding-top: 0;
}

.queue li:last-child {
  padding-bottom: 0;
}

.queue-label {
  color: var(--muted);
  font-size: .83rem;
  display: block;
  margin-bottom: 3px;
}

.timer {
  color: var(--gold);
  font-size: .91rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.action-form label {
  display: flex;
  justify-content:space-between;
  gap: 15px;
  align-items: center;
  color: var(--muted);
  font-size: .9rem;
  margin: 10px 0;
}

.action-form input {
  width: 76px;
  background: var(--inset);
  border: 1px solid #62644a;
  border-radius: 3px;
  padding: 7px 8px;
  color: var(--text);
}

.world-mode .layout {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.world-toolbar, .world-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 14px;
  background: #25291f;
}

.world-toolbar {
  border-bottom: 1px solid #555441;
}

.world-controls, .world-jump, .world-jump label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.world-jump label {
  color: var(--muted);
  font-size: .76rem;
}

.world-toolbar :is(button, input) {
  min-height: 34px;
  border: 1px solid #5b5941;
  border-radius: 4px;
  color: var(--text);
  background: #1c2018;
}

.world-toolbar button {
  padding-inline: 9px;
  min-width: 34px;
}

.world-toolbar button:hover:not(:disabled) {
  border-color: var(--gold);
  background: #36382a;
}

.world-toolbar button:disabled { opacity: .42; }
.world-toolbar input { width: 4em; padding-inline: 5px; }

.world-viewport {
  height: clamp(340px, 50vh, 740px);
  position: relative;
  overflow: clip;
  touch-action: none;
  user-select: none;
  background: repeating-linear-gradient(135deg, #21271f 0 7px, #232b22 7px 8px);
  isolation: isolate;
  cursor: grab;
}

.world-viewport:focus-visible {
  outline-offset: -3px;
  z-index: 1;
}

.world-viewport.dragging, .world-viewport.dragging .tile { cursor: grabbing; }

.world-layer, .world-layer canvas, .world-grid {
  position: absolute;
  inset: 0;
}

.world-layer {
  transform-origin: top left;
}

.world-layer canvas {
  pointer-events: none;
}

.world-grid { display: grid; }

.world-position, .world-crosshair {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

.world-crosshair {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #fff2cabb;
  font: 600 1.1rem monospace;
  text-shadow: 0 1px 3px #11190e;
}

.world-position {
  bottom: 10px;
  left: 12px;
  padding: 5px 8px;
  color: #f8e7bc;
  background: #1a2119eb;
  border: 1px solid #d9c68c70;
  border-radius: 4px;
  font: .8rem ui-monospace, monospace;
}

.world-overview {
  flex-wrap: nowrap;
  border-block: 1px solid #555441;
}

.world-info { min-width: 0; }
.world-preview { color: var(--text); }
.world-population, .world-legend { color: var(--muted); font-size: .78rem; }
.world-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 8px 0; }
.world-legend span { display: inline-flex; gap: 5px; align-items: center; }
.world-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; }
.legend-density { background: #d39753; }
.legend-home { background: #fff1ac; }
.legend-core { background: #9fa2cc; }

.world-minimap {
  position: relative;
  flex: 0 0 auto;
  width: clamp(88px, 12vw, 110px);
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  border: 1px solid #a89c72;
  border-radius: 4px;
  background: #343c2c;
  cursor: crosshair;
}

.world-minimap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  image-rendering: pixelated;
}

.world-frame, .world-home-pin {
  position: absolute;
  pointer-events: none;
}

.world-frame {
  border: 1px solid #fff5d3;
  background: #fff9e31f;
  box-shadow: 0 0 0 1px #24291b;
}

.world-home-pin {
  width: 6px;
  height: 6px;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 1px solid #473a21;
  background: #fff1ac;
}

.resource-lots .building-nav { flex-wrap: wrap; }
.resource-lots .building-nav small { display: block; color: var(--muted); }
.world-profile-name { color: var(--gold); }

.scene-dialog.world-dialog {
  width: min(660px, calc(100% - 28px));
}

.scene-dialog.world-dialog::backdrop {
  background: #10161087;
  backdrop-filter: none;
}

.world-dialog .panel-heading {
  padding-block: 10px;
  padding-inline-end: 58px;
  min-height: 56px;
  background: linear-gradient(110deg, #323426, #272a20 75%);
}

.world-dialog .panel-heading small {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.world-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.world-card-title .sprite {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.world-target-body {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px 22px;
}

.world-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 19px;
  margin: 0 0 16px;
}

.world-facts:last-child { margin-bottom: 0; }
.world-facts dt { color: var(--muted); font-size: .78rem; }
.world-facts dd { margin: 3px 0 0; color: var(--text); overflow-wrap: anywhere; }
.world-facts > div { min-width: 0; }

.world-order {
  align-self: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--inset);
}

.world-dialog .text-field input { width: min(65%, 240px); }

@media (max-width: 585px) {
  .world-target-body { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 700px) {
  .world-viewport { height: clamp(270px, 39svh, 470px); }
  .world-toolbar, .world-overview { padding-inline: 9px; column-gap: 8px; }
  .world-toolbar input { width: 3.45em; }
}

@media (max-width: 410px) {
  .world-controls [data-world-control="home"] span { display: none; }
  .world-mode .topbar nav { gap: 2px; }
  .world-mode .topbar button { padding-inline: 3px; font-size: .73rem; }
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  color: #fce0a0;
  font-size: 1rem;
  border: 0;
  padding: 0;
  background: transparent;
}

.tile:is(:hover, [aria-pressed=true]) {
  box-shadow: inset 0 0 0 1px #e9d8a966;
}

.world-site {
  display: grid;
  place-items: center;
  width: 79%;
  height: 86%;
  border: 1px solid #d6aa69b3;
  border-radius: 46%;
  background: #24281fd9;
  box-shadow: 0 2px 7px #1b231bd9;
}

.world-site .map-sprite {
  width: 95%;
  height: 95%;
  object-fit: contain;
}

.world-site-still { display: none; }

@media (prefers-reduced-motion: reduce) {
  .world-site .map-sprite, .locations .list-sprite, .world-card-title .sprite { display: none; }
  .world-site-still { display: inline; }
}

.tile.owned::after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid #e5cf89;
  border-radius: 4px;
  box-shadow: inset 0 0 9px #1f2f1db0, 0 0 5px #232819a8;
}

.tile.home::after {
  border: 2px solid #ffe1a0;
}

.tile.foreign:hover, .tile.foreign[aria-pressed=true] {
  box-shadow: inset 0 0 0 2px #efcc8a;
  border-radius: 4px;
}

.tile.foreign.protected::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border: 1px solid #d7ebb9;
  border-radius: 50%;
  background: #62986b;
  box-shadow: 0 1px 3px #161b14;
}

.map-ranking {
  padding: 6px 10px;
  font-size: .84rem;
  white-space: nowrap;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.ranking-table :is(th, td) {
  padding: 8px 5px;
  border-bottom: 1px solid var(--line);
  text-align: right;
}

.ranking-table :is(th, td):nth-child(2) {
  text-align: left;
  overflow-wrap: anywhere;
}

.ranking-table thead {
  color: var(--muted);
  font-size: .78rem;
}

.ranking-table .own-rank {
  color: var(--gold);
  background: #303326;
}

.tile.poi:is(:hover, [aria-pressed=true]) .world-site {
  border-color: #ffe0a1;
  background: #655031;
  box-shadow: 0 0 0 2px #e5bd72a3, 0 3px 8px #232418b0;
}

.tile:focus-visible {
  outline-offset: -3px;
  z-index: 1;
}

.locations {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 1px;
  background: var(--line);
}

.locations .lot { padding-block: 7px; }
.locations .lot:focus-visible { outline-offset: -3px; }

.locations .list-sprite {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  object-fit: contain;
}

.locations .lot > span {
  overflow-wrap: anywhere;
}

.reports {
  list-style: none;
  margin: 0;
  padding: 0;
}

.reports li {
  padding: 14px 0;
}

.reports li:first-child {
  padding-top: 0;
}

.reports li+li {
  border-top: 1px solid var(--line);
}

.reports time {
  color: var(--muted);
  font-size: .83rem;
}

.reports p {
  margin: 7px 0;
  font-size: .9rem;
}

[hidden] {
  display: none!important;
}

@media(max-width: 950px) {
  .shell {
    width: calc(100% - 36px);
  }
  .resource {
    padding: 10px 10px 19px;
    gap: 8px;
  }
  .resource-fill {
    inset-inline: 10px;
    width: calc(100% - 20px);
  }
  .resource-rate {
    font-size: .71rem;
  }
  .topbar-inner {
    gap: 14px;
  }
  .topbar button {
    padding: 0 12px;
  }
  .layout {
    gap: 13px;
    grid-template-columns: minmax(0,1.65fr) minmax(260px,1fr);
  }
}

@media(max-width: 700px) {
  .shell {
    width: calc(100% - 24px);
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .topbar-inner {
    flex-wrap: wrap;
    padding-top: 10px;
    gap: 5px;
  }
  .topbar nav {
    min-height: 43px;
    order: 3;
    width: 100%;
    justify-content:space-between;
  }
  .topbar button {
    flex: 1;
    padding: 0 4px;
    font-size: .88rem;
  }
  .brand {
    min-width: 0;
  }
  .realm {
    font-size: .78rem;
  }
  .resources {
    min-height: 74px;
  }
  .resource {
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 1px;
    padding: 6px 2px 28px;
    text-align: center;
  }
  .resource .icon,.resource-rate {
    display: none;
  }
  .resource-fill {
    inset-inline: 5px;
    width: calc(100% - 10px);
  }
  .resource:has(.resource-fill[data-full]) .resource-rate {
    display: block;
    position: absolute;
    bottom: 16px;
    margin: 0;
    font-size: .62rem;
  }
  .resource-value {
    font-size: .94rem;
  }
  .resource-label {
    font-size: .72rem;
  }
  .hero {
    padding: 16px;
    margin: 15px 0;
  }
  .topbar button {
    padding-inline: 8px;
  }

  .topbar button span {
    margin-left: 2px;
  }
}

@media (max-width: 700px) {
  .hero:has(.city-switch:not([hidden])) {
    padding-right: 16px;
  }

  .city-switch {
    position: static;
    margin-top: 12px;
    max-width: 220px;
  }

  .city-switch select {
    width: 100%;
  }

  .topbar button span {
    margin-left: 0;
    display: block;
  }

  .topbar nav {
    min-height: 52px;
  }

}

.settlement-mode .layout {
  display: block;
}

:is(.settlement-mode, .world-mode) .hero {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 14px;
  row-gap: 7px;
  margin-block: 12px 9px;
  padding: 9px 13px;
}

:is(.settlement-mode, .world-mode) .hero:has(.city-switch:not([hidden])) {
  padding-right: 13px;
}

:is(.settlement-mode, .world-mode) .hero #region {
  display: none;
}

:is(.settlement-mode, .world-mode) .hero h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3.4vw, 2.12rem);
}

:is(.settlement-mode, .world-mode) .city-switch {
  position: static;
  display: flex;
  align-items: center;
  margin: 0 0 0 auto;
}

:is(.settlement-mode, .world-mode) .city-switch select {
  width: min(220px, 55vw);
}
.settlement-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #20241a;
  border-bottom: 1px solid #4d5140;
}

.district-switch {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: #171b14;
  border: 1px solid #444937;
  border-radius: 5px;
}

.district-switch button, .queue-trigger {
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  font-size: .875rem;
  white-space: nowrap;
}

.district-switch button > span {
  margin-right: 4px;
}

.district-switch button:hover, .queue-trigger:hover {
  color: var(--text);
  background: #343827;
}

.district-switch button[aria-pressed=true] {
  color: var(--gold);
  background: #343527;
  border-color: #625837;
}

.queue-trigger {
  border-color: #4f5140;
  background: #171b14;
}

.queue-trigger span {
  display: inline-block;
  min-width: 1.3rem;
  margin-left: 4px;
  padding-inline: 4px;
  border-radius: 3px;
  background: #3c3825;
  color: var(--gold);
  font-weight: 700;
}

.settlement-map {
  --camera: 1;
  --marker-scale: 1;
  --scene-height: max(460px, calc(100dvh - 232px));
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 560 / 300;
  max-height: max(325px, calc(100dvh - 294px));
  background: #465a3a;
}

.settlement-mode {
  overflow-x: clip;
  min-width: 0;
}

:root:has(.settlement-mode) {
  overflow-x: clip;
}

.settlement-mode :is(.topbar, .resource-bar, .hero, #side, .settlement-tools) {
  position: relative;
  z-index: 1;
}

/* Szene geladen: die Landschaft füllt die ganze Fensterbreite, Bedienelemente schweben darüber. */
.settlement-mode #view:has(.scene-ready) {
  overflow: visible;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.settlement-mode #view:has(.scene-ready) .settlement-tools {
  background: transparent;
  border-color: transparent;
}

.settlement-map.scene-ready {
  width: 100vw;
  max-height: none;
  margin-inline: calc(50% - 50vw);
  aspect-ratio: auto;
  height: min(78dvh, max(300px, 72vw));
  background: #1b2116;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}

.settlement-map.scene-ready[data-zoom=outskirts] {
  --scene-backdrop: url('/scenes/outskirts/terrain.jpg');
}

.settlement-map.scene-ready[data-zoom=center] {
  --scene-backdrop: url('/scenes/center/terrain.jpg');
}

.settlement-map.scene-ready::before {
  content: "";
  position: absolute;
  inset: -32px;
  background: linear-gradient(#1d25194d, #121911e8), var(--scene-backdrop) center / cover;
  filter: blur(22px) brightness(.62) saturate(.72);
  pointer-events: none;
}

.reserve-count {
  display: none;
  padding: 5px 9px;
  border: 1px solid #a891575c;
  border-radius: 4px;
  background: #232a1bee;
  color: #e2ceb0;
  font-size: .76rem;
  white-space: nowrap;
}

#view:has(.scene-ready[data-zoom=center]) .reserve-count {
  display: inline-block;
}

.settlement-map.scene-ready.is-dragging {
  cursor: grabbing;
}

.settlement-map.scene-ready.is-over-building:not(.is-dragging) {
  cursor: pointer;
}

@media (min-width: 850px) {
  .settlement-mode .layout {
    position: relative;
  }

  .settlement-mode #view:has(.scene-ready) {
    position: static;
    min-height: var(--scene-height);
  }

  .settlement-mode #view:has(.scene-ready) .settlement-tools {
    position: relative;
    z-index: 2;
    display: inline-flex;
    padding: 12px 0 0;
  }

  .settlement-map.scene-ready {
    position: absolute;
    z-index: 0;
    top: -12px;
    left: calc(50% - 50vw);
    margin: 0;
    height: calc(var(--scene-height) + 12px);
  }
}

.settlement-map[data-zoom=center]:not(.scene-ready) {
  --camera: 2.03;
  --marker-scale: .493;
}

.settlement-scene {
  width: 100%;
  height: 100%;
  position: relative;
  transform-origin: 50% 50%;
  transform: scale(var(--camera));
  transition: transform .55s cubic-bezier(.2,.75,.3,1);
}

.scene-ready .settlement-scene {
  transform: none;
  transition: none;
}

.settlement-scene > .fallback-map {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.scene-viewport {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  mask-image:
    linear-gradient(to right, transparent var(--fade-left, 0px), black calc(var(--fade-left, 0px) + var(--fade-left-width, 1px)),
      black calc(var(--fade-right, 100%) - var(--fade-right-width, 1px)), transparent var(--fade-right, 100%)),
    linear-gradient(to bottom, transparent var(--fade-top, 0px), black calc(var(--fade-top, 0px) + var(--fade-top-width, 1px)),
      black calc(var(--fade-bottom, 100%) - var(--fade-bottom-width, 1px)), transparent var(--fade-bottom, 100%));
  mask-composite: intersect;
}

.scene-viewport > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-ready .scene-viewport {
  opacity: 1;
}

.depot-label {
  position: absolute;
  z-index: 1;
  translate: -50% 8px;
  padding: 2px 5px;
  border: 1px solid #a891576e;
  border-radius: 3px;
  background: #232a1be8;
  color: #faeed3;
  font-size: clamp(.62rem, 1.2vw, .75rem);
  line-height: 1.15;
  white-space: nowrap;
  pointer-events: none;
}

.settlement-map.scene-ready :is([data-district], .city-gate) {
  left: var(--scene-x, 50%);
  top: var(--scene-y, 50%);
  transition: opacity .2s, visibility .2s;
}

.scene-ready .settlement-scene > .fallback-map,
.settlement-map.scene-ready::after {
  visibility: hidden;
}

.settlement-map [data-unbuilt] .map-marker-icon {
  border-style: dashed;
}

.map-marker[data-threat] .map-marker-icon {
  border-color: #ffc28d;
  background: #673b2a;
}

.settlement-map::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 55px 14px #121e1470;
}

.map-marker {
  position: absolute;
  left: var(--map-x);
  top: var(--map-y);
  z-index: 2;
  display: flex;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text);
  transform: translate(-50%, -50%) scale(var(--marker-scale));
  transition: transform .55s cubic-bezier(.2,.75,.3,1), opacity .2s, visibility .2s;
}

.map-marker[inert] {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.map-marker:focus-visible, .map-marker:hover {
  z-index: 3;
}

.map-marker-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #f4d895;
  border: 1px solid #c8ad73;
  border-radius: 50%;
  background: #272d20ed;
  box-shadow: 0 3px 9px #151b0fe0, inset 0 0 0 3px #67613f6b;
  font-size: 1.18rem;
}

.city-gate:hover .map-marker-icon,
.map-marker:focus-visible .map-marker-icon,
.map-marker[data-highlighted] .map-marker-icon {
  background: #e4c482;
  color: #282419;
}

.map-marker:is([data-building], .city-lot) {
  align-items: center;
}

.map-marker:is([data-building], .city-lot) .map-marker-icon {
  width: 30px;
  height: 30px;
  font-size: .95rem;
}

.map-marker[data-highlighted] .map-marker-icon {
  border-color: #f4d895;
  box-shadow: 0 0 8px #f5cf7899, inset 0 0 0 2px #a48d5a80;
}

.map-marker[data-construction] .map-marker-icon {
  border-style: dashed;
  border-color: #e5ae65;
}

.city-lot[data-vacant] .map-marker-icon {
  width: 26px;
  height: 26px;
  border-style: dashed;
  background: #353922e8;
  font-size: 1rem;
}

.building-preview {
  position: absolute;
  z-index: 4;
  display: grid;
  gap: 4px;
  width: max-content;
  max-width: min(250px, calc(100% - 12px));
  padding: 7px 9px;
  border: 1px solid #a8915799;
  border-radius: 5px;
  background: #232a1bf5;
  color: #faeed3;
  box-shadow: 0 2px 8px #141c13a8;
  font-size: .79rem;
  line-height: 1.25;
  cursor: default;
}

.building-preview[hidden] {
  display: none;
}

.building-preview::before {
  content: "";
  position: absolute;
  inset: -6px 0;
}

.building-preview small {
  color: #ded5b7;
  font-size: .73rem;
}

.building-preview .preview-threat {
  color: #ffc28d;
}

.building-preview .costs {
  gap: 3px 7px;
  margin: 0;
}

.building-preview .cost {
  padding: 0;
  border: 0;
  background: none;
  font-size: .72rem;
}

.map-marker-label {
  position: absolute;
  top: calc(100% + 5px);
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: max-content;
  padding: 4px 9px 5px;
  border-radius: 4px;
  border: 1px solid #a891576e;
  background: #232a1bee;
  box-shadow: 0 2px 8px #141c13a8;
  color: #faeed3;
  font-size: .84rem;
  line-height: 1.12;
}

.map-marker-label small {
  color: #d6d0ae;
  font-size: .71rem;
}

.city-gate {
  left: 50%;
  top: 48%;
}

.city-gate .map-marker-icon {
  background: #e0bb74;
  color: #30271a;
  border-color: #f5dfab;
}

.city-gate .map-marker-label {
  background: #303424f5;
  border-color: #c2ab70;
}

.map-zoom-controls {
  position: absolute;
  z-index: 3;
  right: 12px;
  bottom: 12px;
  display: flex;
  overflow: hidden;
  border: 1px solid #b29d68;
  border-radius: 4px;
  background: #252a20;
  box-shadow: 0 3px 10px #182017ba;
}

.map-zoom-controls button {
  width: 39px;
  height: 37px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--gold);
  font-size: 1.4rem;
}

.map-zoom-controls button + button {
  border-left: 1px solid #58563d;
}

.map-zoom-controls button:hover {
  background: #3c402a;
}

.map-zoom-controls button[aria-disabled=true] {
  color: #a5a58c;
  cursor: default;
}

:root:has(.scene-dialog[open]) {
  overflow: hidden;
}

.scene-dialog {
  position: fixed;
  inset: 0;
  width: min(540px, calc(100% - 28px));
  max-height: calc(100dvh - 30px);
  padding: 0;
  color: var(--text);
  background: #24291e;
  border: 1px solid #807859;
  border-radius: 9px;
  box-shadow: 0 20px 65px #080b08a6;
}

.scene-dialog[open] {
  animation: reveal-dialog .2s ease-out;
}

@keyframes reveal-dialog {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.scene-dialog::backdrop {
  background: #101610b0;
  backdrop-filter: blur(4px);
}

.lot-catalog {
  padding: 20px;
}

.lot-catalog h2 {
  margin: 0 42px 12px 0;
}

.lot-option {
  display: grid;
  grid-template-columns: clamp(55px, 18vw, 96px) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding-block: 14px;
  border-top: 1px solid #67613f;
}

.lot-option img {
  width: 100%;
  max-height: 95px;
  object-fit: contain;
}

.lot-option h3, .lot-option p {
  margin: 0 0 7px;
}

.building-portrait > .plot-portrait {
  position: absolute;
  right: 16px;
  bottom: 8px;
  width: 42%;
  height: 85%;
  object-fit: contain;
  object-position: right bottom;
}

.dialog-close {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #7b7250;
  border-radius: 6px;
  background: #20251ded;
  color: #f2d795;
  font-size: 1.6rem;
  line-height: 1;
}

.dialog-close:hover {
  background: #444638;
}

.building-portrait {
  position: relative;
  height: clamp(165px, 27vh, 235px);
  overflow: hidden;
  border-bottom: 1px solid #5c6249;
  background: #46553b;
}

.building-portrait canvas {
  width: 77%;
  height: 100%;
  margin-left: auto;
  display: block;
  object-fit: cover;
  image-rendering: pixelated;
}

.building-portrait::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,#1f261c 0%,#20281cd1 25%,#20281c00 62%),
    linear-gradient(0deg,#161f16c9 0%,#161f1600 55%);
  pointer-events: none;
}

.building-title {
  position: absolute;
  z-index: 1;
  left: 22px;
  bottom: 19px;
}

.building-title h2 {
  margin: 4px 0 10px;
  font-size: clamp(1.95rem, 5vw, 2.55rem);
  line-height: 1.05;
}

.building-location {
  color: #efe0a9;
  margin: 0;
  font-size: .8rem;
}

.building-body {
  padding: 14px 22px 20px;
}

.building-body h3 {
  font-size: 1.05rem;
}

.building-yield, .building-job {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #454b37;
  border-radius: 4px;
  background: #1c2119;
}

.building-body .building-yield strong {
  color: var(--green);
}

.building-cta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.building-body .action {
  width: auto;
}

.building-extra {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #444934;
}

.dialog-queue {
  padding: 20px 58px 20px 20px;
}

.dialog-queue h2 {
  margin-bottom: 16px;
}

.dialog-feedback {
  margin: 0 20px 16px;
}

@media (max-width: 700px) {
  :is(.settlement-mode, .world-mode) .city-switch {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .locations {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(125px, max-content);
    overflow-x: auto;
    scrollbar-color: #6e6748 var(--inset);
  }

  .locations .lot {
    padding-inline: 8px;
    font-size: .78rem;
  }

  .locations .list-sprite {
    width: 28px;
    height: 28px;
  }
  .district-switch button, .queue-trigger {
    padding: 6px 8px;
    font-size: .8rem;
  }

  .settlement-tools {
    padding: 8px;
  }

  .settlement-map::after {
    box-shadow: inset 0 0 18px 3px #121e1457;
  }

  .settlement-map {
    aspect-ratio: 3 / 2;
  }

  .map-marker, .map-marker-icon {
    width: 32px;
    height: 32px;
    font-size: .94rem;
  }

  .map-marker:is([data-building], .city-lot) .map-marker-icon {
    width: 24px;
    height: 24px;
    font-size: .78rem;
  }

  .map-marker-label {
    top: 100%;
    padding: 2px 4px;
    font-size: .67rem;
  }

  .map-marker-label small {
    display: none;
  }

  .settlement-map.scene-ready[data-zoom=center] .map-marker:not(:hover, :focus-visible) .map-marker-label {
    visibility: hidden;
  }

  .map-zoom-controls {
    right: 5px;
    bottom: 5px;
  }

  .map-zoom-controls button {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }

  .building-title {
    left: 14px;
  }

  .building-body {
    padding-inline: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .settlement-scene, .scene-viewport, .map-marker,
  .settlement-map.scene-ready :is([data-district], .city-gate) {
    transition: none;
  }

  .scene-dialog[open] {
    animation: none;
  }
}

.settlement-facts {
  margin: 0;
}

.settlement-facts > div {
  display: grid;
  grid-template-columns: 1fr minmax(0, 1.4fr);
  gap: 8px;
  align-items: baseline;
}

.settlement-facts > div + div {
  margin-top: 8px;
}

.settlement-facts dt {
  color: var(--muted);
}

.settlement-facts dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.building-nav {
  display: flex;
  gap: 5px;
  padding: 7px 14px 0;
  border-bottom: 1px solid var(--line);
  background: #20241b;
}

.building-nav button {
  padding: 9px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}

.building-nav button[aria-pressed=true] {
  color: var(--gold);
  border-bottom-color: #c5a265;
}

.building-nav button:hover {
  color: var(--text);
}

.barracks-units {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.barracks-unit {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  min-height: 46px;
  padding: 4px;
  background: var(--inset);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
}

.barracks-unit[aria-pressed=true] {
  background: #363729;
  border-color: #a88e58;
  color: var(--gold);
}

.barracks-unit:hover {
  border-color: #a88e58;
}

.recruitment-selection {
  margin-top: 12px;
}

.recruitment-selection .detail-header p {
  margin-block: 4px;
}

.barracks-units ~ .building-job {
  margin-top: 12px;
}

.building-body form .action {
  width: 100%;
}

@media (min-width: 850px) {
  .settlement-mode .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(225px, 21vw, 280px);
    gap: 14px;
  }

  .settlement-mode #side .panel-heading,
  .settlement-mode #side .panel-body {
    padding: 11px 13px;
  }

  .settlement-mode #side .panel-heading h2 {
    font-size: 1.15rem;
  }

  .settlement-mode #side .panel-body {
    font-size: .88rem;
  }

  .settlement-mode .queue-trigger {
    display: none;
  }
}

@media (max-width: 849px) {
  .settlement-mode #side {
    margin-top: 12px;
  }

  .settlement-tools {
    flex-wrap: wrap;
  }

  .reserve-count {
    order: 1;
  }

  .settlement-map[data-zoom=center] .depot-label {
    display: none;
  }
}

@media (max-width: 380px) {
  .settlement-tools {
    gap: 5px;
    padding-inline: 4px;
  }

  .district-switch button, .queue-trigger {
    padding-inline: 6px;
  }

  .settlement-map {
    aspect-ratio: 5 / 4;
  }

  .reserve-count {
    padding-inline: 4px;
    font-size: .65rem;
  }

  .depot-label {
    padding-inline: 3px;
    font-size: .58rem;
  }

  .barracks-unit {
    flex-direction: column;
    gap: 1px;
    font-size: .82rem;
  }
}

.item-loot {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0;
}

.item-chip {
  --rarity: #c7c0aa;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #505441;
  border-left: 2px solid var(--rarity);
  border-radius: 4px;
  background: #1b2118;
}

.rarity-uncommon { --rarity: #afce8a; }
.rarity-rare { --rarity: #9ec9ed; }
.rarity-epic { --rarity: #d9b1eb; }

.item-chip > span:first-child {
  color: var(--rarity);
}

.item-chip strong,
.item-chip small {
  display: block;
  color: var(--rarity);
}

.item-chip strong {
  font-size: .85rem;
}

.item-chip small {
  font-size: .73rem;
}

.inventory-list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.inventory-row {
  display: grid;
  grid-template-columns: minmax(145px, 1fr) minmax(105px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.inventory-row p {
  margin: 0;
}

.inventory-materials .costs {
  margin-top: 0;
}

.recipe {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #23291e;
}

.recipe h4 {
  margin: 0;
  font-size: .95rem;
}

.recipe p {
  margin: 6px 0;
}

.action-form .potion-option input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: #c2a768;
}

.action-form .potion-option small {
  display: block;
}

.hero-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-profile p {
  margin: 4px 0 8px;
  color: var(--muted);
}

.hero-outfit {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  object-fit: contain;
  image-rendering: pixelated;
}

#view .hero-profile .hero-outfit {
  width: clamp(75px, 16vw, 135px);
  height: clamp(75px, 16vw, 135px);
  background: radial-gradient(ellipse, #584934, transparent 72%);
}

.action-form .expedition-hero {
  justify-content: flex-start;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid #66583e;
  border-radius: 4px;
  background: #302c20;
  color: var(--text);
  cursor: pointer;
}

.expedition-hero .hero-outfit {
  width: 39px;
  height: 39px;
}

.expedition-hero small {
  display: block;
  color: var(--muted);
}

.action-form .expedition-hero input {
  width: 18px;
  height: 18px;
  margin-left: auto;
  flex: 0 0 auto;
  accent-color: #c2a768;
}

.unit-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 8px;
  padding: 12px;
}

.unit-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--inset);
  color: var(--text);
  text-align: left;
}

.unit-card[aria-pressed=true], .unit-card:hover {
  border-color: #a88e58;
  background: #363729;
}

.unit-card small {
  display: block;
  color: var(--muted);
}

.unit-card .sprite, .recruitment-selection .sprite, .barracks-unit .list-sprite, .research-card .list-sprite {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  object-fit: contain;
  image-rendering: pixelated;
}

.unit-card .emblem, .research-card .emblem {
  width: 40px;
  height: 40px;
  margin-left: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

@media (max-width: 480px) {
  .barracks-unit {
    flex-direction: column;
    font-size: .75rem;
  }

  .barracks-unit .list-sprite {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 700px) {
  .inventory-row {
    grid-template-columns: minmax(110px, 1fr) auto;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }

  .inventory-row > p {
    grid-row: 2;
    grid-column: 1 / -1;
  }
}

.map-level {
  position: absolute;
  top: 0;
  right: -2px;
  min-width: 15px;
  height: 15px;
  padding-inline: 2px;
  border: 1px solid #e9cd88;
  border-radius: 9px;
  background: #302b21;
  color: #f5dfac;
  font-size: .63rem;
  font-weight: 700;
  line-height: 13px;
}

.map-level:empty,
.map-marker-label small:empty {
  display: none;
}

/* Breite Bildschirme: Seitenleiste schwebt am rechten Fensterrand über der Szene,
   die Landschaft bleibt in der Mitte frei. */
@media (min-width: 1200px) {
  .settlement-mode .layout:has(.scene-ready) {
    grid-template-columns: minmax(0, 1fr);
  }

  .settlement-mode .layout:has(.scene-ready) #side {
    position: absolute;
    z-index: 1;
    top: 0;
    right: calc(50% - 50vw + 20px);
    width: clamp(250px, 16vw, 300px);
  }
}
