* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #1a1a1a;
  color: #c8c0a8;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#topbar {
  background: linear-gradient(180deg, #2a2a1a 0%, #1e1e12 100%);
  border-bottom: 2px solid #4a4a2a;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 14px;
  flex-shrink: 0;
  height: 40px;
}

#title {
  font-size: 16px;
  font-weight: 700;
  color: #d4c48a;
  letter-spacing: 1px;
}

#date-display {
  color: #b8b088;
  font-family: 'Courier New', monospace;
  font-size: 15px;
}

#conscript-display {
  color: #8aba6a;
  font-size: 13px;
}

#conscript-count {
  font-weight: 700;
  font-size: 15px;
  color: #a0e080;
}

#status-display {
  color: #8a8878;
  font-size: 12px;
  margin-left: auto;
}

#zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
}

#zoom-controls button {
  background: #3a3a22;
  border: 1px solid #5a5a3a;
  color: #c8c0a8;
  width: 22px;
  height: 22px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#zoom-controls button:hover { background: #5a5a3a; }

#zoom-level {
  font-size: 11px;
  color: #8a8878;
  min-width: 36px;
  text-align: center;
  font-family: 'Courier New', monospace;
}

#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #2a2a1a;
  cursor: grab;
}

#map-container:active { cursor: grabbing; }

#game-canvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}

#tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: rgba(20, 20, 12, 0.92);
  border: 1px solid #6a6a4a;
  padding: 6px 10px;
  font-size: 12px;
  color: #c8c0a8;
  border-radius: 4px;
  z-index: 10;
  max-width: 220px;
}

/* ── Sidebar ── */

#sidebar {
  width: 240px;
  background: #1e1e12;
  border-left: 2px solid #3a3a22;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

#sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #8a8868;
  padding: 8px 12px 4px;
  border-bottom: 1px solid #2a2a18;
}

#unit-panel, #conscript-panel, #message-panel, #legend-panel {
  border-bottom: 1px solid #2a2a18;
}

#unit-detail {
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1.6;
  min-height: 60px;
}

#unit-detail .unit-name { font-weight: 700; color: #e0d8b0; font-size: 13px; }
#unit-detail .stat-label { color: #8a8878; }
#unit-detail .stat-bar-wrap { background: #2a2a1a; height: 6px; border-radius: 3px; margin: 2px 0 6px; overflow: hidden; }
#unit-detail .stat-bar { height: 100%; border-radius: 3px; transition: width 0.3s; }
#unit-detail .stat-bar.strength { background: linear-gradient(90deg, #8a3a3a, #4aaa4a); }
#unit-detail .stat-bar.morale { background: linear-gradient(90deg, #6a5a3a, #6aaa6a); }
#unit-detail .stat-bar.entrench { background: linear-gradient(90deg, #5a5a3a, #8a8a5a); }

#orders-panel {
  padding: 6px 12px 10px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.order-btn {
  background: #3a3a22;
  border: 1px solid #5a5a3a;
  color: #c8c0a8;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 1px;
  transition: all 0.15s;
}

.order-btn:hover { background: #5a5a3a; border-color: #8a8a5a; color: #e8e0c0; }
.order-btn.active { background: #4a6a3a; border-color: #6a9a4a; }
.order-btn.cancel { color: #aa6a6a; border-color: #6a3a3a; }
.order-btn.cancel:hover { background: #5a2a2a; color: #da8a8a; }

#conscript-panel {
  padding: 0 12px 10px;
}

#conscript-type {
  width: 100%;
  background: #2a2a18;
  border: 1px solid #4a4a2a;
  color: #c8c0a8;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 3px;
  margin-bottom: 6px;
}

#deploy-btn {
  width: 100%;
  background: #4a6a3a;
  border: 1px solid #6a9a4a;
  color: #e0e0c0;
  padding: 6px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 3px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.15s;
}

#deploy-btn:hover { background: #5a8a4a; }

#message-log {
  padding: 4px 12px 8px;
  max-height: 160px;
  overflow-y: auto;
}

.msg-entry {
  font-size: 11px;
  color: #a8a080;
  padding: 2px 0;
  border-bottom: 1px solid #1a1a0e;
  line-height: 1.3;
}

.msg-entry:last-child { border-bottom: none; }

#legend-panel { padding-bottom: 8px; }

.legend-item {
  font-size: 11px;
  padding: 2px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
}

/* ── Victory overlay ── */

#victory-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#victory-overlay.hidden { display: none; }

#victory-box {
  background: linear-gradient(180deg, #2a2a1a, #1a1a12);
  border: 3px solid #6a6a3a;
  border-radius: 12px;
  padding: 40px 60px;
  text-align: center;
  max-width: 500px;
}

#victory-title {
  font-size: 36px;
  margin-bottom: 16px;
  letter-spacing: 3px;
}

#victory-box.victory #victory-title { color: #a0d080; }
#victory-box.defeat #victory-title { color: #d06060; }

#victory-text {
  font-size: 14px;
  color: #a8a080;
  line-height: 1.6;
  margin-bottom: 24px;
}

#restart-btn {
  background: #4a6a3a;
  border: 2px solid #6a9a4a;
  color: #e0e0c0;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 1px;
}

#restart-btn:hover { background: #5a8a4a; }
