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

body {
  background: #0a0e17;
  color: #c8d6e5;
  font-family: 'Rajdhani', sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

#hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(10,14,23,0.95) 0%, rgba(10,14,23,0.6) 80%, transparent 100%);
  z-index: 10;
  pointer-events: none;
}

#hud-top > * { pointer-events: all; }

#turn-counter {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: #5f7a9a;
  min-width: 80px;
}

#turn-indicator {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #e8a838;
  text-shadow: 0 0 20px rgba(232,168,56,0.4);
  transition: color 0.5s, text-shadow 0.5s;
}

#turn-indicator.enemy {
  color: #b456e8;
  text-shadow: 0 0 20px rgba(180,86,232,0.4);
}

#hud-buttons {
  display: flex;
  gap: 8px;
}

#btn-end-turn, #btn-menu {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  border: 1.5px solid #e8a838;
  background: rgba(232,168,56,0.1);
  color: #e8a838;
  padding: 6px 14px;
  cursor: pointer;
  clip-path: polygon(8px 0%, 100% 0%, calc(100% - 8px) 100%, 0% 100%);
  transition: background 0.2s;
}

#btn-end-turn:hover, #btn-menu:hover {
  background: rgba(232,168,56,0.25);
}

#btn-end-turn.disabled {
  opacity: 0.3;
  pointer-events: none;
}

#btn-menu {
  border-color: #5f7a9a;
  color: #5f7a9a;
  background: rgba(95,122,154,0.1);
  padding: 6px 10px;
}

/* Unit Info Panel */
#unit-info-panel {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(10,14,23,0.92);
  border: 1px solid rgba(95,122,154,0.3);
  border-left: 3px solid #3ae8c8;
  padding: 10px 14px;
  display: flex;
  gap: 12px;
  z-index: 10;
  min-width: 220px;
  backdrop-filter: blur(8px);
}

#unit-info-panel.hidden { display: none; }

#unit-portrait {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  border: 1px solid rgba(58,232,200,0.3);
  background: rgba(58,232,200,0.05);
  flex-shrink: 0;
}

#unit-portrait img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

#unit-details { display: flex; flex-direction: column; gap: 4px; }

#unit-name {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  letter-spacing: 1px;
}

#unit-hp-bar {
  width: 140px;
  height: 10px;
  background: #1a1f2e;
  border: 1px solid #2a3040;
  position: relative;
  overflow: hidden;
}

#unit-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #e83838, #3ae868);
  transition: width 0.3s;
}

#unit-hp-text {
  position: absolute;
  top: -1px;
  left: 4px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  color: #fff;
  text-shadow: 0 0 4px #000;
}

#unit-stats {
  display: flex;
  gap: 10px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  color: #5f7a9a;
}

#unit-stats b {
  color: #c8d6e5;
  margin-left: 2px;
}

/* Army Panel */
#army-panel {
  position: absolute;
  top: 56px;
  right: 8px;
  background: rgba(10,14,23,0.88);
  border: 1px solid rgba(95,122,154,0.2);
  padding: 8px;
  z-index: 10;
  width: 120px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  backdrop-filter: blur(8px);
}

#army-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #5f7a9a;
  margin-bottom: 6px;
  text-align: center;
}

.army-unit {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  cursor: pointer;
  border-left: 2px solid transparent;
  margin-bottom: 2px;
  transition: background 0.15s;
}

.army-unit:hover { background: rgba(58,232,200,0.08); }
.army-unit.acted { opacity: 0.35; }
.army-unit.selected { border-left-color: #3ae8c8; background: rgba(58,232,200,0.1); }

.army-unit-icon {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

.army-unit-name {
  font-size: 11px;
  color: #c8d6e5;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.army-unit-hp {
  width: 30px;
  height: 4px;
  background: #1a1f2e;
  border-radius: 1px;
  overflow: hidden;
}

.army-unit-hp-fill {
  height: 100%;
  background: #3ae868;
  transition: width 0.3s;
}

/* Action Menu */
#action-menu {
  position: absolute;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(10,14,23,0.95);
  border: 1px solid rgba(95,122,154,0.4);
  padding: 6px;
  backdrop-filter: blur(8px);
}

#action-menu.hidden { display: none; }

.action-btn {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 1px;
  border: 1px solid rgba(58,232,200,0.3);
  background: rgba(58,232,200,0.05);
  color: #3ae8c8;
  padding: 6px 16px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.action-btn:hover { background: rgba(58,232,200,0.15); }
.action-btn.disabled { opacity: 0.25; pointer-events: none; }

/* Menu Overlay */
#menu-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,14,23,0.85);
  backdrop-filter: blur(12px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

#menu-modal {
  background: rgba(20,26,40,0.95);
  border: 1px solid rgba(95,122,154,0.3);
  padding: 30px 40px;
  text-align: center;
  min-width: 280px;
}

#menu-modal h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #3ae8c8;
  margin-bottom: 20px;
}

.menu-btn {
  display: block;
  width: 100%;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 2px;
  border: 1px solid rgba(95,122,154,0.3);
  background: rgba(95,122,154,0.08);
  color: #c8d6e5;
  padding: 10px 20px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.menu-btn:hover {
  background: rgba(58,232,200,0.12);
  border-color: rgba(58,232,200,0.4);
  color: #fff;
}

#menu-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  text-align: left;
  font-size: 14px;
  color: #5f7a9a;
}

#menu-settings label { cursor: pointer; display: flex; align-items: center; gap: 8px; }
#menu-settings input[type="checkbox"] { accent-color: #3ae8c8; }

#save-load-area {
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.save-slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid rgba(95,122,154,0.2);
  margin-bottom: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.save-slot:hover { background: rgba(58,232,200,0.08); }
.save-slot-info { color: #5f7a9a; font-family: 'Share Tech Mono', monospace; font-size: 10px; }

/* Victory Overlay */
#victory-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,14,23,0.9);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

#victory-content { text-align: center; }

#victory-title {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 12px;
  margin-bottom: 20px;
}

#victory-title.win {
  color: #e8a838;
  text-shadow: 0 0 40px rgba(232,168,56,0.5);
}

#victory-title.lose {
  color: #e83838;
  text-shadow: 0 0 40px rgba(232,56,56,0.5);
}

#victory-stats {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  color: #5f7a9a;
  margin-bottom: 24px;
  line-height: 1.8;
}

footer {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
}

footer a {
  color: #2a3040;
  font-size: 11px;
  text-decoration: none;
  font-family: 'Share Tech Mono', monospace;
}

footer a:hover { color: #5f7a9a; }

@media (max-width: 640px) {
  #army-panel { display: none; }
  #unit-info-panel { left: 6px; right: 6px; bottom: 6px; min-width: unset; }
  #turn-indicator { font-size: 14px; letter-spacing: 1px; }
  #btn-end-turn { font-size: 11px; padding: 5px 10px; }
}