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

body {
  background: #000;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  color: #fff;
  user-select: none;
}

.hidden { display: none !important; }

/* ===== MAIN MENU ===== */
#main-menu {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.menu-bg {
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at center, #1a0a00 0%, #000 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Crect width='40' height='40' fill='%23110500'/%3E%3Crect x='0' y='0' width='1' height='40' fill='%23220a00' opacity='0.3'/%3E%3Crect x='0' y='0' width='40' height='1' fill='%23220a00' opacity='0.3'/%3E%3C/svg%3E");
}

.menu-content {
  position: relative;
  text-align: center;
  z-index: 1;
  padding: 40px;
  background: rgba(0,0,0,0.7);
  border: 2px solid #8b4513;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(139,69,19,0.5), inset 0 0 40px rgba(0,0,0,0.5);
  min-width: 400px;
}

.game-title {
  font-size: 52px;
  color: #ffd700;
  text-shadow: 0 0 20px #ff8c00, 2px 2px 4px #000;
  letter-spacing: 6px;
  margin-bottom: 4px;
}

.game-subtitle {
  font-size: 16px;
  color: #cd853f;
  letter-spacing: 4px;
  margin-bottom: 32px;
  text-transform: uppercase;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.menu-btn {
  padding: 14px 40px;
  font-size: 18px;
  font-family: 'Courier New', monospace;
  background: linear-gradient(180deg, #8b4513 0%, #5c2d0a 100%);
  color: #ffd700;
  border: 2px solid #cd853f;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  min-width: 220px;
  transition: all 0.2s;
  text-shadow: 1px 1px 2px #000;
}

.menu-btn:hover {
  background: linear-gradient(180deg, #cd853f 0%, #8b4513 100%);
  box-shadow: 0 0 15px rgba(255,215,0,0.4);
  transform: translateY(-2px);
}

.menu-btn.secondary {
  background: linear-gradient(180deg, #2d4a1a 0%, #1a2d0a 100%);
  border-color: #4a7a2d;
  color: #90ee90;
  font-size: 15px;
  padding: 10px 30px;
}

.menu-btn.secondary:hover {
  background: linear-gradient(180deg, #4a7a2d 0%, #2d4a1a 100%);
  box-shadow: 0 0 15px rgba(144,238,144,0.3);
}

.how-to-play {
  margin-top: 20px;
  text-align: left;
  background: rgba(0,0,0,0.5);
  border: 1px solid #4a4a4a;
  border-radius: 4px;
  padding: 16px;
}

.how-to-play h3 {
  color: #ffd700;
  margin-bottom: 10px;
  text-align: center;
  font-size: 14px;
}

.how-to-play ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.how-to-play li {
  font-size: 12px;
  color: #ccc;
  line-height: 1.4;
}

/* ===== GAME CONTAINER ===== */
#game-container {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #000;
}

/* ===== TOP HUD ===== */
#top-hud {
  height: 40px;
  background: linear-gradient(180deg, #1a1208 0%, #0d0904 100%);
  border-bottom: 2px solid #5c3d0a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
  z-index: 10;
}

.resource-panel {
  display: flex;
  gap: 20px;
  align-items: center;
}

.resource {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: #ffd700;
  font-weight: bold;
}

.res-icon {
  font-size: 16px;
}

.game-title-hud {
  font-size: 18px;
  color: #ffd700;
  letter-spacing: 3px;
  text-shadow: 0 0 10px #ff8c00;
  font-weight: bold;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #cd853f;
  font-size: 13px;
}

.hud-btn {
  padding: 4px 12px;
  background: #2d1a05;
  border: 1px solid #5c3d0a;
  color: #cd853f;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  border-radius: 2px;
  transition: all 0.2s;
}

.hud-btn:hover {
  background: #5c3d0a;
  color: #ffd700;
}

/* ===== GAME AREA ===== */
#game-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: default;
}

/* ===== MINIMAP ===== */
#minimap-container {
  position: absolute;
  bottom: 8px;
  right: 8px;
  border: 2px solid #5c3d0a;
  background: #000;
  border-radius: 3px;
  z-index: 10;
  overflow: hidden;
}

#minimap-canvas {
  display: block;
  cursor: crosshair;
}

#minimap-label {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: #5c3d0a;
  letter-spacing: 2px;
}

/* ===== BOTTOM PANEL ===== */
#bottom-panel {
  height: 120px;
  background: linear-gradient(180deg, #0d0904 0%, #1a1208 100%);
  border-top: 2px solid #5c3d0a;
  display: flex;
  align-items: center;
  gap: 0;
  flex-shrink: 0;
  z-index: 10;
}

#selection-info {
  width: 240px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-right: 1px solid #3d2205;
  height: 100%;
}

#unit-portrait {
  width: 64px;
  height: 64px;
  border: 2px solid #5c3d0a;
  background: #0d0904;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
  border-radius: 3px;
}

#unit-details {
  flex: 1;
}

#unit-name {
  font-size: 13px;
  color: #ffd700;
  font-weight: bold;
  margin-bottom: 4px;
}

#unit-stats {
  font-size: 11px;
  color: #cd853f;
  line-height: 1.6;
}

#unit-status {
  font-size: 10px;
  color: #90ee90;
  margin-top: 2px;
}

/* Health bars in stats */
.stat-bar {
  display: inline-block;
  width: 60px;
  height: 6px;
  background: #333;
  border-radius: 3px;
  vertical-align: middle;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.stat-bar-fill.health { background: #44cc44; }
.stat-bar-fill.health.low { background: #cc4444; }
.stat-bar-fill.health.mid { background: #cccc44; }

/* ===== ACTION BUTTONS ===== */
#action-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  padding: 8px;
  width: 220px;
  height: 100%;
  border-right: 1px solid #3d2205;
}

.action-btn {
  background: linear-gradient(180deg, #2d1a05 0%, #1a0d02 100%);
  border: 1px solid #5c3d0a;
  color: #ffd700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 3px;
  font-size: 20px;
  transition: all 0.15s;
  position: relative;
  padding: 2px;
}

.action-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #5c3d0a 0%, #3d2205 100%);
  border-color: #cd853f;
  box-shadow: 0 0 8px rgba(205,133,63,0.4);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.action-btn .btn-label {
  font-size: 8px;
  color: #cd853f;
  font-family: 'Courier New', monospace;
  text-align: center;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
}

.action-btn .btn-cost {
  font-size: 8px;
  color: #ffd700;
}

.action-btn.active {
  background: linear-gradient(180deg, #5c3d0a 0%, #3d2205 100%);
  border-color: #ffd700;
}

/* ===== SELECTION GROUP ===== */
#selection-group {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  padding: 8px;
  overflow: hidden;
}

.sel-icon {
  width: 36px;
  height: 36px;
  border: 1px solid #5c3d0a;
  background: #1a0d02;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s;
  position: relative;
}

.sel-icon:hover {
  border-color: #cd853f;
  background: #2d1a05;
}

.sel-icon.selected-primary {
  border-color: #ffd700;
}

.sel-icon .hp-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: #333;
  border-radius: 0 0 1px 1px;
}

.sel-icon .hp-bar-fill {
  height: 100%;
  background: #44cc44;
  border-radius: 0 0 1px 1px;
}

/* ===== ALERT BANNER ===== */
#alert-banner {
  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  border: 1px solid #cd853f;
  color: #ffd700;
  padding: 8px 24px;
  font-size: 14px;
  border-radius: 4px;
  z-index: 50;
  animation: alertSlide 0.3s ease;
}

@keyframes alertSlide {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== GAME OVER ===== */
#game-over {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#game-over-content {
  text-align: center;
  padding: 50px 70px;
  background: rgba(0,0,0,0.9);
  border: 3px solid #8b4513;
  border-radius: 8px;
  box-shadow: 0 0 60px rgba(139,69,19,0.5);
}

#game-over-title {
  font-size: 52px;
  margin-bottom: 10px;
  text-shadow: 0 0 20px currentColor;
}

#game-over-sub {
  font-size: 18px;
  color: #cd853f;
  margin-bottom: 30px;
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0d0904; }
::-webkit-scrollbar-thumb { background: #5c3d0a; border-radius: 3px; }

/* ===== PROGRESS BARS in canvas overlays ===== */
.progress-ring {
  position: absolute;
  border: 2px solid #ffd700;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
