:root {
  color-scheme: dark;
  --panel-bg: rgba(20, 18, 28, 0.78);
  --text: #eef5fb;
  --muted: #9bb0c2;
  --accent: #8fd0ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0f1115;
  font-family: "Segoe UI", "Trebuchet MS", "Helvetica Neue", Arial, sans-serif;
}

body {
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  appearance: none;
}

.hidden {
  display: none !important;
}

#app {
  min-height: 100vh;
}

#entryScreen {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: auto;
}

#entryBackdrop {
  position: absolute;
  inset: 0;
  background: var(--statehood-start-bg-image, url("/assets/ui/start-screen-bg.png")) center/cover no-repeat, radial-gradient(120% 90% at 20% 10%, rgba(255, 177, 102, 0.5), rgba(255, 177, 102, 0) 45%), radial-gradient(110% 90% at 75% 5%, rgba(105, 125, 231, 0.4), rgba(105, 125, 231, 0) 50%), linear-gradient(180deg, #4b4a8f 0%, #7b5a7b 26%, #8f6a57 50%, #304b5f 100%);
  filter: saturate(1.08) contrast(1.05);
}

#entryBackdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent 35%, transparent 65%, rgba(0, 0, 0, 0.35)), linear-gradient(180deg, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0.18) 26%, rgba(0, 0, 0, 0.42));
}

#entryFrame {
  position: relative;
  width: min(860px, 100vw - 36px);
  max-width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(255, 224, 167, 0.35);
  background: rgba(8, 9, 14, 0.46);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 22px;
}

.entryView {
  display: block;
  color: #f2eadf;
}

.entryView h2 {
  margin: 0 0 10px;
  text-align: center;
  color: #ffdda4;
}

.brandLogo {
  width: min(980px, 100%);
  max-height: min(520px, 58vh);
  max-width: 100%;
  position: relative;
  left: 50%;
  transform: translateX(-50%);
  object-fit: contain;
  display: block;
  margin: 0 0 10px;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.35));
}

#entryLogin {
  max-width: 440px;
  margin: 0 auto;
}

#entryLogin label {
  display: block;
  font-size: 13px;
  margin: 9px 0 6px;
  color: #f2dcb4;
}

#entryLogin input {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f5f8ff;
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

#loginError {
  min-height: 20px;
  margin-top: 8px;
  color: #ff9f90;
  font-size: 13px;
}

.entryActions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.brushDefs {
  position: absolute;
}

.brushButton {
  --brush-fill-a: rgba(50, 71, 145, 0.96);
  --brush-fill-b: rgba(39, 50, 96, 0.96);
  --brush-text: #f9eedf;
  --brush-shadow: rgba(0, 0, 0, 0.28);
  --brush-rotate: 0deg;
  --brush-shift-x: 0px;
  --brush-shift-y: 0px;
  --brush-shadow-blur: 22px;
  --brush-shadow-y: 10px;
  --brush-label-rotate: 0deg;
  --brush-label-shift-x: 0px;
  --brush-label-shift-y: 0px;
  --brush-label-spacing: 0.03em;
  position: relative;
  display: inline-block;
  min-width: 170px;
  padding: 1.1rem 2.2rem;
  border: 0;
  background: transparent;
  color: var(--brush-text);
  cursor: pointer;
  box-shadow: none;
  overflow: visible;
  isolation: isolate;
  transition: transform 160ms ease, filter 160ms ease;
}

.brushButtonArt {
  position: absolute;
  top: -10px;
  left: -14px;
  width: calc(100% + 28px);
  height: calc(100% + 30px);
  z-index: 0;
  pointer-events: none;
  overflow: visible;
  filter: drop-shadow(0 var(--brush-shadow-y) var(--brush-shadow-blur) var(--brush-shadow));
  transform: translate(var(--brush-shift-x), var(--brush-shift-y)) rotate(var(--brush-rotate)) translateZ(0);
}

.brushButtonArt__shape {
  shape-rendering: geometricPrecision;
}

.brushButtonArt__texture {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brushButtonArt__texture--light {
  stroke: rgba(255, 255, 255, 0.22);
}

.brushButtonArt__texture--shadow {
  stroke: rgba(14, 16, 26, 0.18);
}

.brushButtonArt__edge {
  fill: none;
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 0.008;
  vector-effect: non-scaling-stroke;
}

.brushButtonArt__dropTail {
  fill: none;
  stroke: var(--brush-fill-b);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brushButtonArt__dropHead {
  fill: var(--brush-fill-b);
}

.brushButtonArt__dropHighlight {
  fill: rgba(255, 255, 255, 0.26);
}

.brushButton:hover,
.brushButton:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.brushButton:active {
  transform: translateY(1px) scale(0.99);
}

.brushButton:focus-visible {
  outline: 2px solid rgba(255, 229, 171, 0.88);
  outline-offset: 2px;
}

.brushButton--blue {
  --brush-fill-a: rgba(67, 95, 188, 0.98);
  --brush-fill-b: rgba(32, 47, 102, 0.98);
}

.brushButton--ember {
  --brush-fill-a: rgba(198, 92, 56, 0.98);
  --brush-fill-b: rgba(116, 37, 28, 0.98);
}

.brushButton--ghost {
  --brush-fill-a: rgba(69, 84, 112, 0.95);
  --brush-fill-b: rgba(35, 44, 66, 0.95);
  --brush-text: #edf2fb;
}

.brushButtonLabel {
  position: relative;
  z-index: 1;
  font-size: 2rem;
  text-transform: uppercase;
  margin: 0;
  color: white;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  filter: drop-shadow(0 0 2px black);
  white-space: nowrap;
  letter-spacing: var(--brush-label-spacing);
  transform: translate(var(--brush-label-shift-x), var(--brush-label-shift-y)) rotate(var(--brush-label-rotate));
}

#startScreen {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: auto;
}

#startBackdrop {
  position: absolute;
  inset: 0;
  background: var(--statehood-start-bg-image, url("/assets/ui/start-screen-bg.png")) center/cover no-repeat, radial-gradient(120% 90% at 20% 10%, rgba(255, 177, 102, 0.5), rgba(255, 177, 102, 0) 45%), radial-gradient(110% 90% at 75% 5%, rgba(105, 125, 231, 0.4), rgba(105, 125, 231, 0) 50%), linear-gradient(180deg, #4b4a8f 0%, #7b5a7b 26%, #8f6a57 50%, #304b5f 100%);
  filter: saturate(1.08) contrast(1.05);
}

#startBackdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), transparent 35%, transparent 65%, rgba(0, 0, 0, 0.35)), linear-gradient(180deg, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0.18) 26%, rgba(0, 0, 0, 0.42));
}

#startFrame {
  position: relative;
  width: min(1400px, 100vw - 36px);
  max-width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(255, 224, 167, 0.35);
  background: rgba(8, 9, 14, 0.4);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 16px 18px 18px;
}

#startHeader {
  text-align: center;
  color: #fff5db;
  margin-bottom: 10px;
}

#startHeader h1 {
  margin: 2px 0 4px;
  font-size: clamp(38px, 6vw, 72px);
  letter-spacing: 3px;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25), 0 0 30px rgba(255, 195, 121, 0.45);
  background: linear-gradient(180deg, #ffe9b8 0%, #e7b567 52%, #b9782f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#startHeader p {
  margin: 0;
  font-size: clamp(12px, 1.4vw, 20px);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  opacity: 0.93;
}

#startLayout {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(280px, 0.85fr);
  gap: 14px;
  align-items: stretch;
}

.startPanel {
  position: relative;
  border-radius: 14px;
  border: 1px solid rgba(255, 210, 142, 0.35);
  background: linear-gradient(165deg, var(--panel-bg), rgba(16, 16, 24, 0.75));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 14px 30px rgba(0, 0, 0, 0.3);
  padding: 14px 14px 12px;
  color: #f2eadf;
}

.startPanel h2 {
  margin: 0 0 12px;
  text-align: center;
  font-size: clamp(18px, 1.9vw, 30px);
  letter-spacing: 1px;
  color: #ffdda4;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.sectionTitle {
  margin: 14px 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #b3bfd1;
}

.slot-list {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.localePicker {
  display: grid;
  gap: 6px;
  width: min(220px, 100%);
}

.localePicker--inline {
  margin-bottom: 12px;
}

.localePicker__label {
  font-size: 13px;
  color: #f2dcb4;
}

.localePicker__select {
  --locale-arrow-color: rgba(179, 191, 209, 0.85);
  width: 100%;
  min-height: 44px;
  padding: 10px 40px 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(45deg, transparent 50%, var(--locale-arrow-color) 50%) calc(100% - 18px) calc(50% - 2px)/6px 6px no-repeat, linear-gradient(135deg, var(--locale-arrow-color) 50%, transparent 50%) calc(100% - 12px) calc(50% - 2px)/6px 6px no-repeat, rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  box-shadow: none;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.localePicker__select:hover,
.localePicker__select:focus-visible {
  --locale-arrow-color: #f3f7fc;
  border-color: rgba(255, 255, 255, 0.2);
}

.localePicker__select:focus-visible {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.localePicker__select option {
  color: #f3f7fc;
  background: #132133;
}

.biomeHexLayout {
  display: grid;
  gap: 12px;
  margin: 10px auto 2px;
  max-width: 720px;
}

.biomeHexRow {
  display: grid;
  gap: 12px;
  justify-content: center;
}

.biomeHexRow:nth-child(1),
.biomeHexRow:nth-child(3) {
  grid-template-columns: repeat(2, minmax(180px, 240px));
}

.biomeHexRow:nth-child(2) {
  grid-template-columns: repeat(3, minmax(180px, 240px));
}

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

.biome-label {
  font-size: 13px;
  color: var(--muted);
}

.biome-select {
  width: 100%;
}

.mainBiomePicker {
  max-width: 420px;
}

.biome-select__control {
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.biome-select__value-container {
  min-height: 44px;
}

.biome-select__single-value,
.biome-select__input-container {
  font-size: 14px;
}

.setupNote {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
}

.setupNote p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.setupNote p:last-child {
  margin-bottom: 0;
}

.setupField {
  display: grid;
  gap: 8px;
  max-width: 420px;
}

.setupField label {
  font-size: 13px;
  color: #f2dcb4;
}

.setupField input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f5f8ff;
  background: rgba(255, 255, 255, 0.07);
  outline: none;
}

.setupField input:focus-visible {
  border-color: rgba(255, 229, 171, 0.8);
  box-shadow: 0 0 0 2px rgba(255, 229, 171, 0.18);
}

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

.setupFieldError {
  font-size: 12px;
  color: #ff9f90;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}

.controls button {
  flex: 0 0 auto;
}

.statusLine {
  min-height: 18px;
  margin-top: 8px;
  font-size: 12px;
  color: #78dba9;
}

#startActions {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

#startGame {
  min-width: 210px;
}

#gameScreen {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: #061019;
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  border: 0;
}

.gameHud {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 21;
  width: min(320px, 100vw - 36px);
  border-radius: 18px;
  border: 1px solid rgba(255, 224, 167, 0.35);
  background: rgba(8, 9, 14, 0.72);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 14px;
  color: #f2eadf;
}

.gameHud__title {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffdda4;
}

.gameHud__stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 13px;
}

.gameHud__stats div:nth-child(odd) {
  color: var(--muted);
}

.gameHud__actions {
  display: flex;
  margin-top: 14px;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.gameHud__actions--secondary {
  margin-top: 10px;
}

.gameHud__sectionLabel {
  margin: 14px 0 8px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #ffdda4;
}

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

.gameHud__unitButton {
  min-width: 0;
  padding: 0.72rem 0.95rem;
}

.gameHud__unitButton--exhausted {
  opacity: 0.5;
}

.gameHud__unitButton .brushButtonLabel {
  font-size: 0.95rem;
  text-align: center;
}

.gameHud__combatPanel {
  margin-top: 14px;
}

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

.gameHud__combatColumn {
  border-radius: 12px;
  border: 1px solid rgba(255, 224, 167, 0.18);
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
}

.gameHud__combatSubhead {
  margin-bottom: 8px;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffdda4;
}

.gameHud__combatRow {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
}

.gameHud__combatRow span:last-child {
  text-align: right;
  color: #d9e3ef;
}

.gameHud__combatSummary {
  margin-top: 8px;
  font-size: 12px;
  color: #bfcadb;
}

.gameHud__actions .brushButton:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.gameHud__status {
  min-height: 18px;
  margin-top: 12px;
  color: #bfcadb;
  font-size: 12px;
  line-height: 1.45;
}

.gameHud__inspectionPanel {
  margin-top: 12px;
}

.gameHud__inspectionGrid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 12px;
}

.gameHud__inspectionGrid div:nth-child(odd) {
  color: var(--muted);
}

.gameHud__inspectionGrid div:nth-child(even) {
  color: #d9e3ef;
}

.gameHud__combatLog {
  margin-top: 12px;
}

.gameHud__combatLogEntries {
  display: grid;
  gap: 6px;
}

.gameHud__combatLogEntry {
  border-radius: 10px;
  border: 1px solid rgba(255, 224, 167, 0.12);
  background: rgba(255, 255, 255, 0.035);
  padding: 8px 10px;
  color: #d9e3ef;
  font-size: 12px;
  line-height: 1.45;
}

.gameHud__combatLogEntry--empty {
  color: #9eacbf;
  font-style: italic;
}

@media (max-width: 600px) {
  .gameHud__combatGrid {
    grid-template-columns: 1fr;
  }
  #entryScreen {
    place-items: start center;
    padding: 10px;
  }
  #entryFrame {
    width: calc(100vw - 20px);
    max-width: 420px;
    margin: 0 auto;
    padding: 14px;
  }
  .brandLogo {
    width: min(520px, 96%);
    max-height: min(260px, 34vh);
    position: static;
    left: auto;
    transform: none;
    margin: 0 auto 8px;
  }
  .entryActions {
    margin-top: 8px;
  }
}
@media (max-width: 1080px) {
  #startLayout {
    grid-template-columns: 1fr;
  }
  #startActions button {
    min-width: 160px;
  }
}
@media (max-width: 840px) {
  .biomeHexLayout {
    max-width: 100%;
  }
  .biomeHexRow:nth-child(1),
  .biomeHexRow:nth-child(2),
  .biomeHexRow:nth-child(3) {
    grid-template-columns: 1fr;
  }
}
