:root {
  color-scheme: light;
  --bg: #d4c3a7;
  --panel: #efe1c7;
  --panel-edge: rgba(61, 42, 24, 0.24);
  --card: rgba(255, 248, 236, 0.72);
  --ink: #2a2018;
  --muted: rgba(42, 32, 24, 0.68);
  --accent: #7d3d22;
  --accent-soft: #a06a43;
  --blue: #4f6570;
  --red: #8b4d43;
  --shadow: 0 22px 60px rgba(54, 38, 24, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Space Grotesk", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(125, 61, 34, 0.14), transparent 20%),
    radial-gradient(circle at 85% 20%, rgba(70, 53, 31, 0.12), transparent 24%),
    radial-gradient(circle at 50% 110%, rgba(255, 255, 255, 0.4), transparent 34%),
    linear-gradient(135deg, #d8cab0 0%, #cbb89a 50%, #b79f7f 100%);
  color: #241911;
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
  gap: 16px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 12px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 16px 40px rgba(54, 38, 24, 0.18);
  color: var(--ink);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 22%),
    repeating-linear-gradient(
      135deg,
      rgba(80, 56, 34, 0.04) 0 1px,
      transparent 1px 8px
    );
  opacity: 0.7;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: nowrap;
  position: relative;
  z-index: 1;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(61, 42, 24, 0.14);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.language-option {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 120ms ease, filter 120ms ease, opacity 120ms ease;
}

.language-option.is-active {
  filter: drop-shadow(0 0 5px rgba(125, 61, 34, 0.28));
  opacity: 1;
}

.language-option:hover {
  transform: translateY(-1px);
}

.language-option:not(.is-active) {
  opacity: 0.9;
}

.language-option:focus,
.language-option:focus-visible {
  outline: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
}

.lede {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

.support-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(125, 61, 34, 0.18);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 251, 244, 0.62), rgba(237, 223, 198, 0.82));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
  position: relative;
  z-index: 1;
}

.support-kicker,
.visitor-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.support-link {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 36px;
  margin: 5px 0;
  padding: 8px 12px;
  border: 1px solid rgba(42, 32, 24, 0.18);
  border-radius: 10px;
  background: linear-gradient(180deg, #4e3a2c, #2c2018);
  color: #f7eedf;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.support-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(54, 38, 24, 0.18);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--card);
  border: 1px solid rgba(61, 42, 24, 0.12);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48);
  position: relative;
  z-index: 1;
}

.compact ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.compact li + li {
  margin-top: 6px;
}

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

.section-title h2 {
  font-size: 1rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-title span {
  color: var(--muted);
  font-size: 0.84rem;
}

label {
  font-size: 0.86rem;
  color: var(--muted);
}

select,
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(61, 42, 24, 0.18);
  border-radius: 10px;
  background: rgba(255, 251, 243, 0.72);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

input[type="range"] {
  width: 100%;
}

.input-row {
  display: grid;
  gap: 8px;
}

.dimension-grid {
  display: grid;
  gap: 10px;
}

.dimension-block {
  display: grid;
  gap: 8px;
}

.is-hidden {
  display: none !important;
}

output,
.hint,
#selection-details {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.toggle-row input {
  margin: 0;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.selection-actions {
  display: flex;
  justify-content: flex-end;
}

.selection-actions--split {
  gap: 10px;
}

.selection-actions--split > * {
  flex: 1;
}

.team-button,
.ghost-button {
  border: 1px solid rgba(42, 32, 24, 0.16);
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.team-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.team-blue {
  color: #f4efe6;
  background: linear-gradient(135deg, #2f7fe0, #174f9a);
}

.team-red {
  color: #f4efe6;
  background: linear-gradient(135deg, #7b453d, #4c2f2a);
}

.ghost-button {
  background: rgba(255, 251, 243, 0.45);
  color: var(--ink);
}

.danger-button {
  border: 1px solid rgba(123, 61, 34, 0.22);
  border-radius: 10px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #7b453d, #4c2f2a);
  color: #f7eedf;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
}

.danger-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(54, 38, 24, 0.18);
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
  transform: none;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.board-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink);
}

.board-header h2 {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.board-meta {
  display: flex;
  gap: 10px;
}

.board-meta span {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(61, 42, 24, 0.08);
  border: 1px solid rgba(61, 42, 24, 0.12);
  color: var(--accent);
  font-weight: 700;
}

.board-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 250, 242, 0.72), rgba(223, 205, 176, 0.84));
  border: 1px solid rgba(61, 42, 24, 0.18);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.board {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 0;
  background: #111;
  aspect-ratio: 44 / 60;
  max-width: 100%;
  max-height: 100%;
}

.board img,
.terrain-layer,
.los-layer,
.units-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.board img {
  user-select: none;
  pointer-events: none;
  max-width: none;
  max-height: none;
}

.terrain-layer {
  pointer-events: none;
  opacity: 0;
}

.terrain-layer.is-visible {
  opacity: 1;
}

.terrain-rect {
  fill: rgba(255, 232, 92, 0.36);
  stroke: rgba(255, 232, 92, 0.95);
  stroke-width: 0.2;
  vector-effect: non-scaling-stroke;
}

.terrain-barricade {
  fill: rgba(255, 173, 73, 0.44);
  stroke: rgba(255, 173, 73, 0.98);
}

.terrain-crater {
  fill: rgba(255, 255, 255, 0.28);
  stroke: rgba(255, 255, 255, 0.95);
  stroke-dasharray: 0.45 0.18;
}

.terrain-rect-label {
  fill: rgba(255, 255, 255, 0.98);
  font-size: 1.02px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.85);
  stroke-width: 0.12px;
}

.los-layer {
  pointer-events: none;
}

#los-line {
  stroke: rgba(255, 234, 178, 0.95);
  stroke-width: 0.18;
  stroke-dasharray: 0.7 0.35;
  opacity: 0;
}

#los-label-bg {
  fill: rgba(17, 32, 31, 0.82);
  stroke: rgba(255, 234, 178, 0.55);
  stroke-width: 0.06;
  opacity: 0;
}

#los-label {
  fill: #fff7dc;
  font-size: 0.95px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
  opacity: 0;
}

.units-layer {
  touch-action: none;
}

.unit {
  appearance: none;
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  cursor: grab;
  transform: translate(-50%, -50%);
  user-select: none;
  border: 0;
  background-clip: padding-box;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.24),
    0 10px 18px rgba(0, 0, 0, 0.18);
}

.unit:active {
  cursor: grabbing;
}

.unit-blue {
  background: radial-gradient(circle at 30% 30%, #4fb0ff, #1558b8 70%);
}

.unit-red {
  background: radial-gradient(circle at 30% 30%, #c49b89, #6c3c33 70%);
}

.unit.selected {
  outline: 4px solid rgba(125, 61, 34, 0.55);
  outline-offset: 3px;
}

.unit-label {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(45, 32, 22, 0.92);
  color: #f8f0e2;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.selection-empty {
  opacity: 0.9;
}

.config-details {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-line;
}

.workspace {
  position: relative;
}

.workspace::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 18%),
    repeating-linear-gradient(
      0deg,
      rgba(61, 42, 24, 0.025) 0 1px,
      transparent 1px 6px
    );
  opacity: 0.35;
}


@media (max-width: 980px) {
  .shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    gap: 10px;
    padding: 8px;
  }

  .workspace {
    order: -1;
    flex: 0 0 auto;
    gap: 8px;
    min-height: 0;
  }

  .panel {
    gap: 10px;
    padding: 12px;
    border-radius: 20px;
  }

  .card {
    padding: 12px;
    border-radius: 16px;
  }

  .board-header {
    align-items: start;
    gap: 10px;
  }

  .board-meta span {
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  .workspace {
    height: auto;
  }

  .board-frame {
    min-height: 70dvh;
    padding: 4px;
    border-radius: 16px;
  }

  .board {
    width: 100% !important;
    height: auto !important;
  }

  .unit-label {
    font-size: 0.62rem;
    top: calc(100% + 6px);
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 6px;
    gap: 8px;
  }

  .board-header h2 {
    font-size: 1.4rem;
  }

  .board-frame {
    min-height: 68dvh;
  }

  .button-row {
    grid-template-columns: 1fr;
  }
}
