:root {
  --bg: #1a1a22;
  --panel-bg: #25252e;
  --panel-border: #3a3a44;
  --fg: #e8e8f0;
  --muted: #8a8a96;
  --accent: #ff6b3b;
  --accent-hover: #ff8a5b;
  --gs-accent: #9c4cc4;
  --success: #4caf50;
  --warning: #ffa03b;
  --danger: #e85e3b;

  --corridor: #3a3a4a;
  --room: #553b3b;
  --deployment: #3a4a5a;
  --entry: #5a3a5a;
  --objective: #7a3a3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.4;
  min-height: 100vh;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px;
}

header {
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}

h1 {
  margin: 0 0 4px;
  font-size: 20px;
  color: var(--accent);
}

h2 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-meta {
  font-size: 13px;
  color: var(--muted);
}

.header-meta span {
  color: var(--fg);
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.board-section {
  min-width: 0;
}

.board {
  display: grid;
  gap: 1px;
  background: #000;
  padding: 1px;
  border: 2px solid var(--panel-border);
  border-radius: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
}

.cell {
  aspect-ratio: 1;
  min-width: 30px;
  min-height: 30px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
  transition: filter 0.1s, transform 0.1s;
  user-select: none;
}

.cell:hover:not(.wall) {
  filter: brightness(1.25);
}

.cell.selected {
  outline: 2px solid var(--accent);
  z-index: 4;
}

.cell.target {
  outline: 2px solid var(--gs-accent);
  z-index: 4;
}

.cell.corridor { background: var(--corridor); }
.cell.room { background: var(--room); }
.cell.deployment { background: var(--deployment); }
.cell.entry { background: var(--entry); }
.cell.objective { background: var(--objective); }
.cell.wall {
  background: var(--bg) !important;
  cursor: default;
}
.cell.wall:hover { filter: none; }

.coord-label {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 7px;
  color: rgba(255, 255, 255, 0.3);
  font-family: monospace;
  pointer-events: none;
}

.square-char {
  font-size: 16px;
  opacity: 0.4;
  pointer-events: none;
}

.unit {
  position: absolute;
  width: 78%;
  height: 78%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
  color: white;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  z-index: 2;
  pointer-events: none;
}

.unit.sergeant { background: #ff6b3b; }
.unit.marine { background: #e85e3b; }
.unit.flamer-marine { background: #ffa03b; }
.unit.blip { background: #888; }
.unit.stealer { background: #9c4cc4; }
.unit.dead { background: #444; opacity: 0.4; }

.flame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: rgba(255, 100, 0, 0.4);
  z-index: 3;
  pointer-events: none;
}

.door {
  position: absolute;
  background: var(--accent);
  z-index: 5;
  pointer-events: none;
}

.door.horizontal {
  left: 5%;
  right: 5%;
  height: 4px;
}

.door.vertical {
  top: 5%;
  bottom: 5%;
  width: 4px;
}

.door.top { top: -2px; }
.door.bottom { bottom: -2px; }
.door.left { left: -2px; }
.door.right { right: -2px; }

.door.open {
  background: var(--success);
  opacity: 0.5;
}

.overwatch-marker {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  z-index: 3;
  pointer-events: none;
}

.legend-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sw {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}

.sw.corridor { background: var(--corridor); }
.sw.room { background: var(--room); }
.sw.deployment { background: var(--deployment); }
.sw.entry { background: var(--entry); }
.sw.objective { background: var(--objective); }
.sw.door-closed { background: var(--accent); }
.sw.door-open { background: var(--success); opacity: 0.5; }
.sw.flame { background: rgba(255, 100, 0, 0.6); }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
}

.status div {
  padding: 2px 0;
  font-size: 12px;
}

.muted { color: var(--muted); font-size: 12px; }
.win { color: var(--success); font-weight: bold; padding: 8px; text-align: center; background: rgba(76, 175, 80, 0.2); border-radius: 4px; }
.lose { color: var(--danger); font-weight: bold; padding: 8px; text-align: center; background: rgba(232, 94, 59, 0.2); border-radius: 4px; }

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 8px;
}

.action-btn,
.primary-btn,
.secondary-btn {
  font-family: inherit;
  font-size: 12px;
  padding: 7px 10px;
  border: 1px solid var(--panel-border);
  background: #15151a;
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.action-btn:hover,
.secondary-btn:hover {
  background: #25252e;
  border-color: var(--accent);
}

.action-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.primary-btn {
  width: 100%;
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  padding: 9px 12px;
  font-weight: 600;
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.primary-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.secondary-btn {
  width: 100%;
  margin-top: 5px;
}

#action-queue {
  margin: 0 0 8px;
  padding-left: 22px;
  font-size: 12px;
  min-height: 30px;
}

#action-queue li {
  padding: 3px 0;
  font-family: monospace;
  color: #c8c8d0;
}

#action-queue:empty::before {
  content: "No actions queued.";
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
  padding-left: 0;
  list-style: none;
}

#share-url {
  width: 100%;
  height: 60px;
  font-family: monospace;
  font-size: 10px;
  background: #15151a;
  color: var(--fg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 6px;
  resize: vertical;
  margin-bottom: 6px;
}

footer {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
}

footer details {
  margin-bottom: 8px;
}

footer summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  padding: 3px 0;
}

.help-content {
  padding: 6px 0 0;
  font-size: 12px;
}

.help-content ul {
  margin: 6px 0;
  padding-left: 18px;
}

.help-content li {
  padding: 2px 0;
}

.footer-meta {
  font-size: 11px;
  text-align: center;
  padding-top: 6px;
  border-top: 1px solid var(--panel-border);
}

#selection-content {
  font-size: 12px;
}

#selection-content p {
  margin: 4px 0;
}

#selection-content .unit-info {
  background: #15151a;
  padding: 6px 8px;
  border-radius: 4px;
  border-left: 3px solid var(--accent);
  margin: 6px 0;
}
