:root {
  --bg: #0f1720;
  --panel: #1b2734;
  --panel-2: #223246;
  --text: #e8edf2;
  --muted: #9fb0c1;
  --ok: #5ac983;
  --warn: #f0b44f;
  --bad: #f17575;
  --accent: #68b7ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  background: radial-gradient(circle at 15% 20%, #1d344c 0%, var(--bg) 50%);
  color: var(--text);
  min-height: 100vh;
}

.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 16px;
}

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid #34506a;
  border-radius: 14px;
  padding: 20px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0 0 20px;
  color: var(--muted);
}

label { display: block; margin-bottom: 8px; }

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

input, button {
  border-radius: 8px;
  border: 1px solid #466888;
  background: #122030;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

button {
  background: #1f3d59;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.status.info { border-color: #6384a4; background: #172a3c; }
.status.ok { border-color: #4e9d6e; background: #14271d; }
.status.warn { border-color: #b08c4b; background: #2a2315; }
.status.bad { border-color: #b26060; background: #311d1d; }

.meta {
  margin-top: 16px;
  border-top: 1px solid #3a5269;
  padding-top: 14px;
}

.meta h2 { margin: 0 0 12px; font-size: 1.1rem; }

.meta dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.meta div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
}

.meta dt { color: var(--muted); }

.actions { margin-top: 14px; }

.viewer {
  margin-top: 20px;
  border-top: 1px solid #3a5269;
  padding-top: 16px;
}

.viewer h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.viewer-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.viewer-controls select {
  border-radius: 8px;
  border: 1px solid #466888;
  background: #122030;
  color: var(--text);
  padding: 8px;
  font: inherit;
}

#timeline-slider {
  width: 100%;
  margin-bottom: 12px;
}

.viewer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.viewer-card {
  margin-top: 10px;
  border: 1px solid #3a5269;
  border-radius: 10px;
  padding: 10px;
  background: #172536;
}

.viewer-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.viewer-card dl {
  margin: 0;
  display: grid;
  gap: 6px;
}

.viewer-card dl div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
}

.viewer-card dt {
  color: var(--muted);
}

.entity-table {
  max-height: 260px;
  overflow: auto;
  border: 1px solid #3a5269;
  border-radius: 8px;
}

.entity-table table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

.entity-table th,
.entity-table td {
  border-bottom: 1px solid #2a4157;
  padding: 6px 8px;
  text-align: left;
}

.empty {
  padding: 10px;
  color: var(--muted);
}

.json-view {
  margin: 0;
  max-height: 320px;
  overflow: auto;
  background: #102133;
  border: 1px solid #324f69;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.8rem;
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid #3a5269;
  background: radial-gradient(circle at 20% 20%, #1c3146 0%, #0f1720 55%, #0b1118 100%);
  overflow: hidden;
  --token-size: 3%;
}

.board-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(transparent 95%, rgba(255, 255, 255, 0.05) 96%),
    linear-gradient(90deg, transparent 95%, rgba(255, 255, 255, 0.05) 96%);
  background-size: 12.5% 12.5%;
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}

.board-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.line-supply {
  stroke: rgba(110, 255, 180, 0.75);
  stroke-width: 2.5;
}

.line-target {
  stroke: rgba(255, 120, 120, 0.7);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.line-inactive {
  stroke: rgba(0, 0, 0, 0.8);
  stroke-width: 2.5;
}

.token {
  position: absolute;
  z-index: 2;
  width: var(--token-size);
  height: var(--token-size);
  min-width: 8px;
  min-height: 8px;
  max-width: 26px;
  max-height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

@media (max-width: 600px) {
  .board {
    --token-size: 1.8%;
  }

  .token {
    min-width: 6px;
    min-height: 6px;
    max-width: 16px;
    max-height: 16px;
    font-size: 0.5rem;
  }
}

.token.destroyed::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: rgba(200, 40, 40, 0.35);
  border: 2px solid rgba(255, 70, 70, 0.7);
}

.token.host {
  background: radial-gradient(circle, rgba(88, 170, 255, 0.95) 0%, rgba(26, 74, 122, 0.95) 70%);
}

.token.guest {
  background: radial-gradient(circle, rgba(255, 220, 96, 0.95) 0%, rgba(138, 104, 22, 0.95) 70%);
}

.token.unknown {
  background: radial-gradient(circle, rgba(170, 170, 170, 0.9) 0%, rgba(90, 90, 90, 0.9) 70%);
}

.hidden { display: none; }

.recent {
  margin-top: 24px;
  border-top: 1px solid #3a5269;
  padding-top: 16px;
}

.recent h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
}

.recent-status {
  margin: 0 0 10px;
  color: var(--muted);
}

.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.recent-list li {
  padding: 8px 10px;
  border: 1px solid #3a5269;
  border-radius: 10px;
  background: #172536;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.recent-list a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.recent-meta {
  color: var(--muted);
  font-size: 0.9rem;
}
