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

body {
  background: #1a1a2e;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: 'Georgia', serif;
  color: #e8d5b0;
  overflow: hidden;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#phase-banner {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #8b7355;
  border-radius: 4px;
  padding: 8px 24px;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  pointer-events: none;
}

#phase-banner.positioning {
  color: #b090f0;
  border-color: #b090f0;
}

#phase-banner.planning {
  color: #7ec8e3;
  border-color: #7ec8e3;
}

#phase-banner.executing {
  color: #e8a838;
  border-color: #e8a838;
}

#exec-timer-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
  display: none;
}

#phase-banner.executing #exec-timer-bar {
  display: block;
}

#exec-timer-fill {
  height: 100%;
  width: 100%;
  background: #e8a838;
  border-radius: 2px;
  transition: width 0.12s linear;
}

#scenario-switcher {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 4px;
  pointer-events: all;
}

#control-toggle {
  position: absolute;
  top: 54px;
  left: 16px;
  pointer-events: all;
}

.scenario-tab {
  background: rgba(0, 0, 0, 0.75);
  color: #6a7860;
  border: 1px solid #3a4030;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 13px;
  font-family: 'Georgia', serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.scenario-tab:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: #6a7860;
  color: #b8c898;
}

.scenario-tab.active {
  background: rgba(20, 40, 15, 0.85);
  border-color: #4a8a2a;
  color: #a8d878;
}

#top-right-hud {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
}
#turn-counter, #zoom-display {
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #8b7355;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 14px;
}

#casualty-tracker {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #8b7355;
  border-radius: 4px;
  padding: 8px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  pointer-events: none;
  white-space: nowrap;
}

.casualty-label {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #8b7355;
  text-align: center;
}

.faction-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.faction-name {
  width: 55px;
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
}

.human-name {
  color: #7ec8e3;
}

.orc-name {
  color: #e87040;
}

.morale-bar-wrap {
  width: 80px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}

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

.morale-bar-human {
  background: #7ec8e3;
}

.morale-bar-orc {
  background: #e87040;
}

.strength-label {
  font-size: 11px;
  color: #888;
  flex-shrink: 0;
  min-width: 38px;
}

.casualty-killed {
  color: #e85050;
}

.casualty-injured {
  color: #e8c040;
}

.casualty-captured {
  color: #9080a8;
}

.casualty-fled {
  color: #70a8c0;
}

#victory-casualties {
  font-size: 20px;
  color: #c8b88a;
  text-align: center;
  line-height: 1.8;
}

#unit-info-panel {
  position: absolute;
  bottom: 80px;
  left: 16px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #8b7355;
  border-radius: 4px;
  padding: 12px 16px;
  width: 300px;
  min-width: 300px;
  max-width: 300px;
  pointer-events: none;
  display: none;
}

#unit-info-name {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 6px;
  border-bottom: 1px solid #8b7355;
  padding-bottom: 4px;
}

#unit-info-soldiers {
  font-size: 13px;
  margin-bottom: 4px;
  color: #c8b88a;
}

#unit-info-stats {
  font-size: 12px;
  color: #a09070;
}

#unit-info-debug {
  font: 11px monospace;
  color: #c0b090;
  margin-top: 6px;
  border-top: 1px solid #5a4a30;
  padding-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
}

#end-turn-btn {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: #2a4a1a;
  color: #a8d878;
  border: 2px solid #4a8a2a;
  border-radius: 6px;
  padding: 12px 28px;
  font-size: 16px;
  font-family: 'Georgia', serif;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  pointer-events: all;
  transition: background 0.15s, border-color 0.15s;
}

#end-turn-btn:hover {
  background: #3a6a28;
  border-color: #6aaa3a;
}

#end-turn-btn:active {
  background: #1a3a10;
}

#end-turn-btn:disabled {
  background: #1a2a14;
  color: #506040;
  border-color: #304020;
  cursor: not-allowed;
}

#victory-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 24px;
  pointer-events: all;
}

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

#victory-text {
  font-size: 48px;
  text-shadow: 0 0 20px currentColor;
}

#victory-text.victory {
  color: #7ec8e3;
}

#victory-text.defeat {
  color: #e83838;
}

#restart-btn {
  background: #2a2a4a;
  color: #a8c8f8;
  border: 2px solid #4a4a8a;
  border-radius: 6px;
  padding: 12px 32px;
  font-size: 18px;
  font-family: 'Georgia', serif;
  cursor: pointer;
  transition: background 0.15s;
}

#restart-btn:hover {
  background: #3a3a6a;
}

#unit-exec-log {
  margin-top: 8px;
  border-top: 1px solid #5a4a30;
  padding-top: 6px;
  pointer-events: all;
}

.unit-log-header {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #8b7355;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.unit-log-header button {
  background: none;
  border: none;
  color: #8b7355;
  cursor: pointer;
  font-size: 10px;
  pointer-events: all;
  line-height: 1;
}

#unit-log-entries {
  min-height: 60px;
  max-height: 220px;
  overflow-y: auto;
  font: 11px monospace;
  line-height: 1.6;
  pointer-events: all;
  user-select: text;
}

.ulog-turn   { color: #e8c840; font-weight: bold; margin-top: 4px; }
.ulog-move   { color: #aabfff; }
.ulog-combat { color: #ffaa66; }
.ulog-dealt  { color: #60d080; }
.ulog-took   { color: #e86060; }
.ulog-loss   { color: #e85050; }
.ulog-state  { color: #ff88cc; }

#debug-log-panel {
  position: fixed; top: 56px; right: 8px; width: 300px;
  background: rgba(0,0,0,0.82); border: 1px solid #444;
  border-radius: 4px; font: 11px monospace; color: #ccc; z-index: 100;
  pointer-events: all;
}
.debug-log-header { padding: 4px 8px; background: #222; display: flex; justify-content: space-between; }
.debug-log-header button { background: none; border: none; color: #aaa; cursor: pointer; font: 11px monospace; }
#debug-log { max-height: 180px; overflow-y: auto; padding: 4px 8px; }
.log-tick    { color: #8af; font-weight: bold; margin-top: 3px; }
.log-combat  { color: #fa8; }
.log-ranged  { color: #8fa; }
.log-move    { color: #aaf; }
.log-warn    { color: #ff8; }
.log-phase   { color: #f8f; }

#battalion-btn {
  position: absolute;
  top: 92px;
  left: 16px;
  pointer-events: all;
}

#orc-battalion-btn {
  position: absolute;
  top: 126px;
  left: 16px;
  pointer-events: all;
}

#debug-toggle {
  position: absolute;
  top: 164px;
  left: 16px;
  pointer-events: all;
}

#battalion-builder {
  position: absolute;
  inset: 0;
  background: rgba(10,10,20,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: all;
}
#battalion-builder.hidden { display: none; }

#battalion-builder-inner {
  background: #12122a;
  border: 1px solid #7ec8e3;
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
#battalion-builder-inner h2 { color: #7ec8e3; margin: 0; }

#battalion-canvas { cursor: default; }

#battalion-builder-footer { display: flex; gap: 10px; }
#battalion-save-btn, #battalion-cancel-btn {
  padding: 8px 20px;
  border: 1px solid #7ec8e3;
  background: #1a1a2e;
  color: #7ec8e3;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-family: 'Georgia', serif;
}
#battalion-save-btn:hover { background: #7ec8e3; color: #1a1a2e; }
