* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f1923;
  color: #e0e0e0;
  min-height: 100vh;
  overflow: hidden;
}

/* ===== AUTH ===== */
#auth-section {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}

.auth-card {
  background: #16213e; border-radius: 12px; padding: 2rem;
  width: 100%; max-width: 400px; margin: 1rem;
}

.auth-card h1 { color: #f5a623; text-align: center; margin-bottom: 1.5rem; font-size: 1.8rem; }

input {
  display: block; width: 100%; padding: 0.75rem; margin-bottom: 0.75rem;
  border: 1px solid #333; border-radius: 6px;
  background: #0f3460; color: #e0e0e0; font-size: 1rem;
}

button {
  padding: 0.75rem 1.5rem; border: none; border-radius: 6px;
  background: #f5a623; color: #1a1a2e; font-size: 1rem; font-weight: bold; cursor: pointer;
}
button:hover { background: #e09520; }

.auth-buttons { display: flex; gap: 0.5rem; }
.auth-buttons button { flex: 1; }
#btn-register { background: #533483; color: #e0e0e0; }
#btn-register:hover { background: #6a42a0; }
.error { color: #e74c3c; margin-top: 0.5rem; font-size: 0.9rem; }

/* ===== GAME HEADER ===== */
#game-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 1rem; background: #16213e; border-bottom: 1px solid #1e3a5f;
}

#game-header h1 { color: #f5a623; font-size: 1.2rem; }

#game-meta {
  display: flex; gap: 1.5rem; font-size: 0.85rem; color: #8a8a8a;
}
#game-meta strong { color: #f5a623; }

/* ===== RESOURCE BAR ===== */
#resource-bar {
  display: flex; gap: 0.5rem; padding: 0.5rem 1rem;
  background: #121e2e; border-bottom: 1px solid #1e3a5f;
  overflow-x: auto; flex-wrap: wrap;
}

.resource-item {
  display: flex; gap: 0.3rem; padding: 0.25rem 0.5rem;
  background: #1a2d42; border-radius: 4px; font-size: 0.8rem; white-space: nowrap;
}
.res-name { color: #f5a623; }
.res-value { color: #e0e0e0; }

/* ===== MAP ===== */
#game-layout {
  display: flex; height: calc(100vh - 90px);
}

#map-container {
  flex: 1; overflow: hidden; cursor: grab; background: #0a1628;
}

.game-map { width: 100%; height: 100%; }

.region {
  fill: #2a3a4a; stroke: #0f1923; stroke-width: 0.5;
  transition: fill 0.2s, opacity 0.2s;
  vector-effect: non-scaling-stroke;
}
.region:hover, .region.hovered { opacity: 0.8; stroke: #f5a623; stroke-width: 1.5; }
.region.selected { stroke: #fff; stroke-width: 2; }
.region.player-owned { fill: #2196f3; }

.region-marker {
  fill: transparent; stroke: none; cursor: pointer;
}
.region-marker:hover { fill: rgba(245, 166, 35, 0.3); }

.region-label {
  font-size: 3px; fill: #e8e8e8; text-anchor: middle; pointer-events: none;
  opacity: 0.9; font-weight: 600;
  paint-order: stroke; stroke: #0a1020; stroke-width: 0.6px;
}
.region-label.label-player {
  fill: #fff; opacity: 1; font-weight: 700; font-size: 3.5px;
}
.region-label.country-label {
  fill: #f0f0f0; opacity: 1; font-weight: 700;
}

.owner-player { color: #2196f3; font-size: 0.85rem; }
.owner-country { color: #8a8a8a; font-size: 0.85rem; }

.label { color: #8a8a8a; }
.value { color: #e0e0e0; }

/* ===== SIDEBAR ===== */
#sidebar {
  width: 320px; background: #16213e; border-left: 1px solid #1e3a5f;
  padding: 1rem; overflow-y: auto;
}

.sidebar-header h3 { color: #f5a623; font-size: 1.1rem; margin-bottom: 0.3rem; }

.sidebar-section { margin-top: 1rem; }
.sidebar-section h4 { color: #f5a623; font-size: 0.95rem; margin-bottom: 0.5rem; }

.pop-bar-container {
  position: relative; height: 24px; background: #0f1923; border-radius: 4px; overflow: hidden;
}
.pop-bar {
  height: 100%; background: linear-gradient(90deg, #2196f3, #4caf50); border-radius: 4px;
  transition: width 0.3s;
}
.pop-text {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 0.75rem; color: #fff; white-space: nowrap;
}

.sidebar-resources { list-style: none; }
.sidebar-resources li {
  display: flex; justify-content: space-between;
  padding: 0.25rem 0; border-bottom: 1px solid #1a2d42; font-size: 0.85rem;
}
.rate-strong { color: #4caf50; }
.rate-weak { color: #666; }

.focus-buttons { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.focus-btn {
  padding: 0.4rem 0.6rem; font-size: 0.75rem; border-radius: 4px;
  background: #1a2d42; color: #8a8a8a; border: 1px solid #2a3a4a; cursor: pointer;
}
.focus-btn:hover { background: #2a3a4a; color: #e0e0e0; }
.focus-btn.active { background: #f5a623; color: #1a1a2e; border-color: #f5a623; font-weight: bold; }

.chain-list { list-style: none; }
.chain-list li {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.4rem 0; border-bottom: 1px solid #1a2d42; font-size: 0.8rem;
}
.chain-name { font-weight: bold; }
.chain-recipe { color: #8a8a8a; font-size: 0.75rem; }
.chain-status { font-size: 0.7rem; }
.chain-active .chain-status { color: #4caf50; }
.chain-inactive .chain-status { color: #555; }
.chain-inactive { opacity: 0.5; }

.trend-positive { color: #4caf50; }
.trend-negative { color: #e74c3c; }

#no-game {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: calc(100vh - 90px); gap: 1rem;
}

/* ===== BUILDINGS ===== */
.building-row {
  padding: 0.4rem 0; border-bottom: 1px solid #1a2d42;
}
.building-info { display: flex; flex-direction: column; gap: 0.2rem; }
.building-name { font-size: 0.85rem; font-weight: 600; color: #e0e0e0; }
.building-status { font-size: 0.75rem; }
.building-constructing { color: #f5a623; }
.building-stopped { color: #e74c3c; }

.util-buttons { display: flex; gap: 0.2rem; margin-top: 0.2rem; }
.util-btn {
  padding: 0.15rem 0.4rem; font-size: 0.65rem; border-radius: 3px;
  background: #1a2d42; color: #8a8a8a; border: 1px solid #2a3a4a; cursor: pointer;
}
.util-btn:hover { background: #2a3a4a; color: #e0e0e0; }
.util-btn.active { background: #2196f3; color: #fff; border-color: #2196f3; }

.build-btn {
  padding: 0.25rem 0.5rem; font-size: 0.7rem; border-radius: 4px;
  background: #f5a623; color: #1a1a2e; border: none; cursor: pointer;
  font-weight: bold; margin-top: 0.2rem; align-self: flex-start;
}
.build-btn:hover { background: #e09520; }

.build-cost-info {
  font-size: 0.65rem; color: #8a8a8a; margin-top: 0.1rem;
}

.build-progress-wrap {
  position: relative; height: 18px; background: #1a2d42; border-radius: 3px;
  overflow: hidden; margin-top: 0.2rem;
}
.build-progress-bar {
  height: 100%; background: #f5a623; border-radius: 3px;
  transition: width 0.3s ease;
}
.build-progress-text {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; color: #e0e0e0; font-weight: 600;
}

/* ===== SPECIALIZATION ===== */
.specialization-list { display: flex; flex-direction: column; gap: 0.2rem; }
.spec-item {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.85rem; padding: 0.15rem 0;
}
.spec-name { color: #e0e0e0; }
.spec-stars { letter-spacing: 1px; }
.stars-1 { color: #555; }
.stars-2 { color: #8a8a8a; }
.stars-3 { color: #f5a623; }
.stars-4 { color: #ff9800; }
.stars-5 { color: #ffd700; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #game-layout { flex-direction: column; }

  #map-container { height: 60vh; }

  #sidebar {
    width: 100%; height: 40vh;
    border-left: none; border-top: 1px solid #1e3a5f;
  }

  #game-meta { gap: 0.75rem; font-size: 0.75rem; }

  #resource-bar { font-size: 0.75rem; }
}
