@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

:root {
  --bg: #008080;
  --panel: #c0c0c0;
  --panel-2: #dfdfdf;
  --line-dark: #404040;
  --line-mid: #808080;
  --line-light: #ffffff;
  --title: #000080;
  --title-2: #1084d0;
  --text: #111;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

body {
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.08) 75%),
    linear-gradient(45deg, rgba(0, 0, 0, 0.08) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.08) 75%),
    var(--bg);
  background-size: 4px 4px;
  background-position: 0 0, 2px 2px;
  color: var(--text);
  font-family: Consolas, "Lucida Console", monospace;
}

.desktop {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: 100vh;
  padding: 10px;
}

.main-title {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.title-left {
  display: flex;
  align-items: center;
}

.brand {
  font-family: "Press Start 2P", Consolas, monospace;
  font-size: 15px;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}

.top-nav {
  display: inline-flex;
  gap: 8px;
  justify-self: center;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-family: "Press Start 2P", Consolas, monospace;
  font-size: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid #fff;
  padding: 3px 8px;
  cursor: pointer;
}

.nav-btn svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.status-lamp {
  padding: 2px 8px;
  border: 2px solid #000;
  background: #ffd166;
  color: #000;
  justify-self: end;
}

.status-lamp.online {
  background: #9cff9c;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 10px;
  min-height: 0;
}

.side-column {
  display: grid;
  grid-template-rows: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 10px;
  min-height: 0;
}

.window {
  border: 2px solid var(--line-mid);
  border-top-color: var(--line-light);
  border-left-color: var(--line-light);
  border-right-color: var(--line-dark);
  border-bottom-color: var(--line-dark);
  background: var(--panel);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.title-bar {
  background: linear-gradient(90deg, var(--title), var(--title-2));
  color: #fff;
  font-family: "Press Start 2P", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.4px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.zoom-controls {
  display: inline-flex;
  gap: 4px;
}

.zoom-btn,
.modal-close {
  width: 28px;
  height: 22px;
  border: 1px solid #000;
  background: #cfcfcf;
  color: #111;
  cursor: pointer;
}

.window-body {
  min-height: 0;
  padding: 8px;
  background: var(--panel-2);
}

.map-body {
  display: grid;
  min-height: 0;
}

.map-wrap {
  position: relative;
  min-height: 0;
  overflow: auto;
  border: 2px solid var(--line-mid);
  border-top-color: var(--line-dark);
  border-left-color: var(--line-dark);
  border-right-color: var(--line-light);
  border-bottom-color: var(--line-light);
  background: #4b4b4b;
  cursor: grab;
  touch-action: none;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.map-wrap:active {
  cursor: grabbing;
}

.map-wrap::-webkit-scrollbar {
  width: 0;
  height: 0;
}

#map-canvas {
  position: relative;
  z-index: 1;
  display: block;
  image-rendering: pixelated;
}

.table-body {
  overflow: auto;
  padding: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border: 1px solid #8a8a8a;
  padding: 4px;
  text-align: left;
}

th {
  background: #b5b5b5;
  position: sticky;
  top: 0;
}

.player-row {
  cursor: pointer;
  box-shadow: inset 3px 0 0 var(--player-accent, transparent);
  background: linear-gradient(90deg, var(--player-accent-fill, transparent), transparent 55%);
}

.player-row:hover {
  background: linear-gradient(90deg, var(--player-accent-fill, rgba(211, 211, 211, 0.4)), #d3d3d3 70%);
}

.player-name-cell {
  white-space: nowrap;
}

.owner-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid #555;
  background: var(--player-accent, #999);
  box-shadow: inset 0 0 0 1px var(--player-accent-fill, rgba(255, 255, 255, 0.3));
}

.logs-body {
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 4px;
}

.log-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  font-size: 12px;
  padding: 4px;
  background: #efefef;
  border: 1px solid #b0b0b0;
}

.log-time {
  color: #0a3b68;
}

.log-node {
  color: #5f1e1e;
}

.empty {
  color: #555;
  font-size: 12px;
  text-align: center;
  padding: 10px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  z-index: 80;
  padding: 12px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(560px, 100%);
  max-height: min(84vh, 820px);
  overflow: auto;
  border: 2px solid var(--line-mid);
  border-top-color: var(--line-light);
  border-left-color: var(--line-light);
  border-right-color: var(--line-dark);
  border-bottom-color: var(--line-dark);
  background: var(--panel);
}

.help-card {
  width: min(760px, 100%);
}

.modal-body {
  padding: 8px;
  background: var(--panel-2);
  font-size: 12px;
}

.player-card {
  display: grid;
  gap: 8px;
}

.cell-card {
  display: grid;
  gap: 8px;
}

.player-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 6px 7px;
  border: 1px solid #8f8f8f;
  background: linear-gradient(90deg, var(--player-accent-fill, #efefef), #efefef 68%);
  box-shadow: inset 4px 0 0 var(--player-accent, transparent);
}

.player-hero-copy {
  display: grid;
  gap: 4px;
}

.player-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 20px;
  border: 1px solid #8f8f8f;
  background: #fff;
}

.player-name,
.cell-title {
  font-family: "Press Start 2P", Consolas, monospace;
}

.player-name {
  font-size: 11px;
  line-height: 1.25;
}

.cell-title {
  font-size: 11px;
  line-height: 1.25;
}

.player-hero-tags,
.cell-hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.player-tag,
.cell-tag {
  display: inline-flex;
  align-items: center;
  min-height: 19px;
  padding: 2px 6px;
  border: 1px solid #7e7e7e;
  background: rgba(255, 255, 255, 0.85);
  font-size: 9px;
  text-transform: uppercase;
}

.cell-tag.accent {
  background: #d9f5df;
  color: #184425;
}

.cell-tag.danger {
  background: #f4d8d8;
  color: #6a1f1f;
}

.player-name .owner-swatch,
.cell-player-link .owner-swatch {
  margin-right: 8px;
}

.player-node,
.cell-subtitle {
  color: #333;
  font-size: 10px;
  line-height: 1.3;
}

.player-stats-grid,
.player-meta-grid,
.cell-info-grid {
  display: grid;
  gap: 6px;
}

.player-stats-grid,
.cell-info-grid {
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
}

.player-card-grid,
.cell-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.player-meta-grid {
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
}

.player-stat-box,
.player-meta-grid > div,
.cell-info-grid > div,
.player-panel,
.cell-section {
  border: 1px solid #8f8f8f;
  background: #efefef;
}

.player-stat-box,
.player-meta-grid > div,
.cell-info-grid > div {
  padding: 6px 7px;
}

.player-panel,
.cell-section {
  padding: 6px 7px;
}

.player-stat-box span,
.player-meta-grid span,
.panel-label,
.cell-info-grid span,
.cell-section > span {
  display: block;
  margin-bottom: 3px;
  color: #444;
  text-transform: uppercase;
  font-size: 9px;
  line-height: 1.2;
}

.player-stat-box strong,
.player-meta-grid strong,
.cell-info-grid strong {
  font-size: 12px;
  line-height: 1.3;
}

.player-building-list,
.cell-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.player-resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 6px;
}

.resource-pill {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 6px 7px;
  border: 1px solid #8f8f8f;
  background: #fff;
}

.resource-pill-emoji {
  font-size: 15px;
  line-height: 1;
}

.resource-pill-label {
  font-size: 10px;
  text-transform: uppercase;
  color: #333;
}

.resource-pill-value {
  font-size: 12px;
}

.cell-jump-btn,
.cell-player-link,
.cell-chip {
  border: 1px solid #8f8f8f;
  background: #fff;
  color: #111;
  font: inherit;
  padding: 4px 6px;
  font-size: 11px;
  line-height: 1.25;
}

.cell-jump-btn,
.cell-player-link {
  cursor: pointer;
}

.cell-player-link {
  background: linear-gradient(90deg, var(--player-accent-fill, #fff), #fff 72%);
  box-shadow: inset 3px 0 0 var(--player-accent, transparent);
}

.cell-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 6px 7px;
  border: 1px solid #8f8f8f;
  background: #efefef;
}

.cell-empty,
.player-building-empty {
  color: #555;
  font-size: 11px;
}

.help-modal-body {
  max-height: min(72vh, 700px);
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.help-section {
  border: 1px solid #8f8f8f;
  background: #efefef;
  padding: 8px;
}

.help-section-wide {
  grid-column: 1 / -1;
}

.help-section h4 {
  margin: 0 0 8px 0;
  font-family: "Press Start 2P", Consolas, monospace;
  font-size: 10px;
}

.help-section p {
  margin: 0 0 6px 0;
  font-size: 12px;
  line-height: 1.35;
}

.help-section p:last-child {
  margin-bottom: 0;
}

.help-section code {
  font-family: Consolas, "Lucida Console", monospace;
}

.help-node-badge {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid #8f8f8f;
  background: #d8ead3;
  color: #173b19;
  font-family: "Press Start 2P", Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 8px;
  }

  .side-column {
    grid-template-rows: minmax(150px, 28vh) minmax(120px, 20vh);
    gap: 8px;
  }

  .desktop {
    height: auto;
    min-height: 100vh;
    padding: 8px;
    gap: 8px;
  }

  .main-title {
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
  }

  .brand {
    font-size: 12px;
  }

  .top-nav {
    justify-self: center;
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .nav-btn {
    font-size: 9px;
    padding: 3px 6px;
    min-height: 26px;
  }

  .status-lamp {
    justify-self: end;
    width: 12px;
    height: 12px;
    min-width: 12px;
    min-height: 12px;
    padding: 0;
    border: 1px solid #000;
    background: #ff4d4d;
    color: transparent;
    font-size: 0;
    line-height: 0;
  }

  .status-lamp.online {
    background: #2ce86d;
  }

  .help-modal-body {
    grid-template-columns: 1fr;
  }

  .player-card-grid,
  .cell-card-grid,
  .cell-hero {
    grid-template-columns: 1fr;
  }

  .map-window .window-body.map-body {
    padding: 6px;
  }

  .map-window .map-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 260px;
    max-height: 58vh;
  }

  .table-body,
  .logs-body {
    min-height: 0;
    overflow: auto;
  }
}
