:root {
  --bg: #14171c;
  --panel: #1c2128;
  --border: #2d333b;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #ff8c1a;
  --accent-dim: #b8621088;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.screen { min-height: 100vh; }

/* Login */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 320px;
  text-align: center;
}

.login-card input {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
}

/* Dashboard */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

header h1 { margin: 0; font-size: 1.3rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  padding: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.card h2 {
  margin: 0 0 12px 0;
  font-size: 1.05rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card.wide { grid-column: span 2; }
@media (max-width: 700px) {
  .card.wide { grid-column: span 1; }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.card-header h2 { margin: 0; }

.section-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 10px 0 6px 0;
}
.section-label-clickable { cursor: pointer; user-select: none; }
.section-label-clickable:hover { color: var(--text); }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.error { color: var(--red); }

.state-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}
.state-running { background: #1b3a24; color: var(--green); }
.state-stopped { background: #3a2323; color: var(--red); }
.state-starting { background: #3a3220; color: var(--yellow); }
.state-unknown { background: #2d333b; color: var(--muted); }

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn {
  padding: 9px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #262c34;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:hover { background: #303842; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a1200; font-weight: 600; }
.btn-primary:hover { background: #ff9d3d; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: #2a1414; }
.btn-update { border-color: var(--yellow); color: var(--yellow); }
.btn-update:hover { background: #2a2414; }

.restart-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge-update {
  background: #3a3220;
  color: var(--yellow);
  border: 1px solid var(--yellow);
  cursor: help;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
}

button[type="submit"] {
  padding: 10px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #1a1200;
  font-weight: 600;
  cursor: pointer;
}

.stats-table { width: 100%; border-collapse: collapse; }
.stats-table td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.stats-table td:first-child { color: var(--muted); width: 40%; }

.bar {
  width: 100%;
  height: 8px;
  background: #2d333b;
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.4s; }

.file-list {
  max-height: 280px;
  overflow-y: auto;
  font-size: 0.88rem;
}

.file-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.file-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.file-row-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-row-meta {
  font-size: 0.74rem;
  color: var(--muted);
}

.file-row-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.file-row a, .file-action { color: var(--accent); text-decoration: none; cursor: pointer; font-size: 0.85rem; background: none; border: none; padding: 0; }
.file-row a:hover, .file-action:hover { text-decoration: underline; }
.file-action-danger { color: var(--red); }

.file-row.recent { background: rgba(255, 140, 26, 0.06); border-radius: 6px; padding-left: 8px; margin-bottom: 2px; }

.blueprint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
}

.blueprint-card {
  background: #20262e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.blueprint-card-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.blueprint-card-meta {
  font-size: 0.74rem;
  color: var(--muted);
}
.blueprint-card-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.blueprint-incomplete {
  border-color: var(--red);
}
.badge-incomplete {
  background: #3a2323;
  color: var(--red);
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 8px;
  align-self: flex-start;
}

.upload-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.upload-row input[type="file"] { flex: 1; font-size: 0.82rem; color: var(--muted); }

.badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--border);
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  vertical-align: middle;
}
.badge.badge-live { background: #1b3a24; color: var(--green); }

.map-card { grid-column: 1 / -1; }

.map-fallback { padding: 12px 0; }
.map-fallback a { color: var(--accent); }

#map-canvas-wrap {
  position: relative;
  max-width: 900px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
#map-image { width: 100%; display: block; }
#map-dots { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.player-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px var(--accent);
}
.player-label {
  position: absolute;
  transform: translate(-50%, -160%);
  font-size: 0.7rem;
  background: rgba(0,0,0,0.6);
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
}
