:root {
  color-scheme: dark;
  --paper: #ece6d6;
  --ink: #e8e4d8;
  --muted: #b8b9a8;
  --accent: #ddc27a;
  font:
    15px/1.6 system-ui,
    "PingFang SC",
    sans-serif;
  background: #292e29;
  color: var(--ink);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button,
select,
input {
  background: #40473d;
  color: var(--ink);
  border: 1px solid #74785f;
  border-radius: 6px;
  padding: 0.5rem 0.8rem;
}
button {
  cursor: pointer;
}
button:hover:not(:disabled),
button.selected {
  border-color: var(--accent);
  background: #5e6244;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
a {
  color: var(--accent);
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid #727457;
  background: #232820;
}
header nav,
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
small,
.muted {
  color: var(--muted);
}
small {
  display: block;
}
h1,
h2,
h3,
p {
  margin: 0.6em 0;
}
h1 {
  font-size: clamp(1.6rem, 3vw, 3rem);
}
.banner {
  padding: 5px 20px;
  background: #514a32;
  color: #fff0c4;
  font-size: 13px;
}
.entry {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 40px;
  padding: 6vh 5vw;
  max-width: 1200px;
  margin: auto;
}
.cover {
  width: 100%;
  max-height: 500px;
  object-fit: contain;
}
.entry form,
.entry section {
  display: grid;
  gap: 12px;
  align-content: center;
}
.entry label {
  display: grid;
  gap: 6px;
}
.primary {
  background: #78683d;
  border-color: #d5bc73;
}
.status {
  padding: 10px 18px;
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}
.status b {
  color: var(--accent);
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0;
}
.map-scroll {
  overflow: auto;
  overscroll-behavior: contain;
  height: calc(100dvh - 180px);
  background: #bebfb0;
  touch-action: pan-x pan-y;
  position: relative;
}
.map {
  display: block;
  width: 100%;
  min-width: 1100px;
  height: auto;
}
.map.zoomed {
  min-width: 2100px;
}
.hex-hit {
  fill: transparent;
  stroke: none;
  cursor: pointer;
}
.hex-hit.target {
  fill: #f7db5470;
  stroke: #fff1a3;
  stroke-width: 4;
}
.hex-hit.chosen {
  fill: #ffd83277;
  stroke: #fff;
  stroke-width: 5;
}
.counter {
  cursor: pointer;
  filter: drop-shadow(1px 3px 3px #0009);
}
.counter.selected {
  filter: drop-shadow(0 0 8px #ffea00);
}
.counter rect {
  fill: none;
  stroke: #ffdf62;
  stroke-width: 5;
}
.map .label {
  paint-order: stroke;
  stroke: #292c23;
  stroke-width: 4;
  fill: white;
  font: 22px system-ui;
}
.sidebar {
  max-height: calc(100dvh - 180px);
  overflow: auto;
  padding: 14px;
  background: #30372e;
  border-left: 1px solid #74765c;
}
.tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
}
.chit {
  width: 66px;
  height: 66px;
  object-fit: contain;
}
.unit-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 190px;
  overflow: auto;
}
.unit-pick {
  padding: 3px;
  width: 70px;
  text-align: center;
  font-size: 11px;
}
.unit-pick img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}
.controls {
  padding: 12px 16px;
  background: #252c24;
  border-top: 1px solid #797d5f;
  position: sticky;
  bottom: 0;
  z-index: 10;
  box-shadow: 0 -8px 18px #0003;
}
.controls h2 {
  font-size: 16px;
  margin: 0 0 8px;
}
.controls label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
}
.controls select {
  max-width: 220px;
}
.controls .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.controls .help {
  font-size: 13px;
  color: var(--muted);
  margin: 3px 0 8px;
}
.controls .options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.logs {
  font-size: 12px;
  color: var(--muted);
  padding-left: 20px;
}
.logs li {
  margin-bottom: 7px;
}
.selected-detail {
  padding: 8px 0;
  border-bottom: 1px solid #647058;
}
dialog {
  width: min(740px, 94vw);
  max-height: 90dvh;
  overflow: auto;
  color: var(--ink);
  background: #30372e;
  border: 1px solid #a29e7b;
  border-radius: 12px;
  padding: 24px;
}
dialog::backdrop {
  background: #0009;
}
dialog .close {
  float: right;
}
dialog img {
  max-width: 160px;
  image-rendering: auto;
}
#toast {
  position: fixed;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 12px 20px;
  border-radius: 8px;
  background: #211f18;
  color: white;
  box-shadow: 0 5px 25px #0008;
  z-index: 100;
  display: none;
}
#toast.show {
  display: block;
}
.counter-stack-inspector {
  background: #30372e;
  color: var(--ink);
}
.counter-stack-face img {
  width: 100px;
  height: 100px;
  object-fit: contain;
}
.empty {
  padding: 30px;
}
.preview-banner {
  padding: 5px 20px;
  background: #544c30;
}
.legend {
  font-size: 12px;
}
.report {
  border: 1px solid #b19050;
  padding: 12px;
}
.finished {
  text-align: center;
  background: #4b4b2f;
  padding: 18px;
}
@media (max-width: 760px) {
  header {
    padding: 8px 12px;
    flex-wrap: wrap;
  }
  header strong {
    font-size: 13px;
  }
  header a {
    font-size: 12px;
  }
  .entry {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 18px;
  }
  .entry .cover {
    max-height: 250px;
  }
  .workspace {
    display: block;
  }
  .map-scroll {
    height: 53dvh;
  }
  .map {
    min-width: 1350px;
  }
  .sidebar {
    max-height: none;
    border: 0;
    padding: 8px 12px;
  }
  .sidebar .logs {
    display: none;
  }
  .sidebar h3 {
    font-size: 14px;
  }
  .status {
    gap: 8px;
    font-size: 12px;
    padding: 6px 12px;
  }
  .controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 38dvh;
    overflow: auto;
    padding: 10px 12px;
  }
  .controls select {
    max-width: 170px;
  }
  .controls .help {
    line-height: 1.35;
  }
  .controls button {
    min-height: 42px;
  }
  .sidebar {
    padding-bottom: 36dvh;
  }
  .unit-list {
    max-height: 110px;
  }
  .chit {
    width: 52px;
    height: 52px;
  }
  .selected-detail {
    font-size: 13px;
  }
}
.entry label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}
.entry details summary {
  cursor: pointer;
}
.entry fieldset {
  border: 1px solid #74785f;
  display: grid;
  gap: 8px;
}
