:root {
  color-scheme: dark;
  --ink: #f4ead6;
  --muted: #b8ad98;
  --panel: rgba(26, 31, 28, 0.94);
  --panel-2: #242b27;
  --line: #4d584f;
  --accent: #c99b4d;
  --danger: #bd5b4b;
  --union: #5487ba;
  --confederate: #a66755;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #151916;
  font: 16px/1.45 Inter, system-ui, sans-serif;
}
button, input, select { font: inherit; }
button {
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: .65rem 1rem;
  color: #17130c;
  background: var(--accent);
  font-weight: 700;
  cursor: pointer;
}
button.secondary { color: var(--ink); background: transparent; border-color: var(--line); }
button.danger { color: white; background: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: .72rem;
  color: var(--ink);
  background: #121613;
}
.shell { max-width: 1100px; margin: auto; padding: 2rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { margin: 0; font-family: Georgia, serif; letter-spacing: .02em; }
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; }
.muted { color: var(--muted); }
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
  background: var(--panel);
}
.auth-card { width: min(440px, calc(100% - 2rem)); margin: 12vh auto; text-align: center; }
.auth-card #auth { margin-top: 1.5rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.battle-card { display: flex; flex-direction: column; gap: .7rem; }
.battle-card h2 { margin: 0; font: 1.35rem Georgia, serif; }
.battle-card .actions { display: flex; gap: .5rem; margin-top: auto; }
.create-row { display: grid; grid-template-columns: 1fr auto; gap: .75rem; margin: 2rem 0; }
.badge { display: inline-block; border-radius: 999px; padding: .2rem .55rem; background: var(--panel-2); color: var(--muted); font-size: .8rem; }
.badge.active { background: #315b3c; color: #d9f3de; }
.error { color: #ff9d8d; }

.editor { height: 100vh; display: grid; grid-template-columns: 340px 1fr; }
.sidebar { overflow-y: auto; padding: 1.25rem; background: var(--panel); border-right: 1px solid var(--line); z-index: 1000; }
.sidebar h1 { margin: .2rem 0; font: 1.6rem Georgia, serif; }
.sidebar section { padding: 1rem 0; border-top: 1px solid var(--line); }
.sidebar .stack { display: grid; gap: .65rem; }
.sidebar label { color: var(--muted); font-size: .85rem; }
.map-panel { position: relative; min-width: 0; min-height: 0; }
#map { width: 100%; height: 100%; background: #242a25; }
.map-search {
  position: absolute;
  z-index: 1000;
  top: 12px;
  left: 50%;
  display: grid;
  grid-template-columns: minmax(220px, 430px) auto;
  width: min(620px, calc(100% - 150px));
  transform: translateX(-50%);
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, .55));
}
.map-search input {
  min-width: 0;
  border-color: #777;
  border-radius: 5px 0 0 5px;
  color: #222;
  background: #fff;
}
.map-search button {
  border-color: #777;
  border-radius: 0 5px 5px 0;
  padding-inline: 1rem;
}
.map-search-message {
  grid-column: 1 / -1;
  justify-self: center;
  margin-top: 5px;
  border-radius: 4px;
  padding: .2rem .5rem;
  color: #222;
  background: rgba(255, 255, 255, .92);
  font-size: .78rem;
}
.map-search-message:empty { display: none; }
.map-search-message.error { color: #8f2016; }
.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;
}
.status-line { min-height: 1.4em; color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.stat { padding: .65rem; background: var(--panel-2); border-radius: 5px; }
.stat strong { display: block; font-size: 1.25rem; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #202722; color: var(--ink); }
.center-boundary-control .center-boundary-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #222;
  background: #fff;
  font: 700 24px/1 Georgia, serif;
  text-decoration: none;
}
.center-boundary-control .center-boundary-button:hover,
.center-boundary-control .center-boundary-button:focus {
  color: #111;
  background: #f4f4f4;
}

@media (max-width: 760px) {
  .editor { grid-template-columns: 1fr; grid-template-rows: auto 65vh; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .map-search { width: calc(100% - 24px); }
}
