:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f7fb;
  color: #18212f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #ef4f2f;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 16px;
}

#runButton {
  border: 0;
  border-radius: 8px;
  background: #111827;
  color: white;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
}

.controls,
.map-controls,
.preset-bar,
.manual-runner,
.world-tools,
.scenario-tools,
.preview-panel,
.metrics,
.layout {
  display: grid;
  gap: 12px;
}

.preset-bar {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  margin-bottom: 12px;
}

.manual-runner {
  grid-template-columns: minmax(180px, 1.4fr) minmax(100px, 0.7fr) repeat(3, minmax(130px, 1fr));
  align-items: end;
  margin-bottom: 12px;
}

.world-tools,
.scenario-tools {
  grid-template-columns: minmax(150px, 0.8fr) repeat(3, minmax(130px, 1fr)) minmax(130px, 0.8fr);
  align-items: end;
  margin-bottom: 12px;
}

.scenario-tools {
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 0.7fr) minmax(180px, 1fr) minmax(130px, 0.7fr);
}

.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
}

.checkline input {
  width: auto;
}

.ghost {
  border: 1px solid #d6dce8;
  border-radius: 8px;
  background: #ffffff;
  color: #18212f;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
}

.ghost.danger {
  border-color: #fecaca;
  color: #b91c1c;
}

.preview-panel {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #eff6ff;
  margin-bottom: 12px;
  padding: 12px;
}

.preview-panel strong,
.preview-panel span {
  display: block;
}

.preview-panel span {
  margin-top: 3px;
  color: #475569;
  font-size: 13px;
}

#submitPreview {
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: white;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

#submitPreview:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.controls {
  grid-template-columns: repeat(10, minmax(110px, 1fr));
  margin-bottom: 12px;
}

.map-controls {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #526071;
}

input,
select {
  width: 100%;
  border: 1px solid #d6dce8;
  border-radius: 8px;
  background: white;
  padding: 10px;
  color: #18212f;
}

.metrics {
  grid-template-columns: repeat(9, minmax(110px, 1fr));
  margin-bottom: 12px;
}

.metric,
.panel {
  border: 1px solid #e1e5ee;
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 24px rgba(20, 31, 50, 0.06);
}

.metric {
  padding: 14px;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
}

.layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.panel {
  padding: 14px;
}

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

#mapMeta {
  color: #687589;
  font-size: 13px;
  font-weight: 700;
}

.map-stack {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 8px;
  overflow: hidden;
  background: #d8deea;
}

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

.tile-layer {
  overflow: hidden;
}

.map-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  object-fit: cover;
}

.grid {
  display: grid;
  gap: 2px;
}

.tile {
  min-width: 0;
  min-height: 0;
  background: rgba(238, 241, 246, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.35);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.tile:hover {
  transform: scale(1.2);
  filter: brightness(1.08);
  z-index: 2;
}

.tile.preview-path {
  outline: 2px solid #111827;
  outline-offset: -2px;
  box-shadow: inset 0 0 0 999px rgba(17, 24, 39, 0.18);
}

.tile.preview-enclosed {
  box-shadow: inset 0 0 0 999px rgba(34, 197, 94, 0.32);
}

.tile.preview-point {
  outline: 3px solid #f97316;
  outline-offset: -3px;
}

.tile.draw-mode,
.tile.paint-mode {
  cursor: crosshair;
}

.tile.paint-mode:hover {
  outline: 3px solid #0f766e;
  outline-offset: -3px;
}

.side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.row,
.event {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #edf0f6;
  padding: 9px 0;
  font-size: 13px;
}

.row:last-child,
.event:last-child {
  border-bottom: 0;
}

.dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 99px;
  margin-top: 4px;
}

.runner {
  display: flex;
  gap: 8px;
}

.muted {
  color: #6b7586;
}

@media (max-width: 900px) {
  .controls,
  .map-controls,
  .preset-bar,
  .manual-runner,
  .world-tools,
  .scenario-tools,
  .preview-panel,
  .metrics,
  .layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}
