/* ============================================
   BSI AgentForge - Warcraft III Style CSS
   ============================================ */

/* CSS Custom Properties - WC3 Color Palette */
:root {
  /* Primary Backgrounds */
  --bg-dark: #1a1410;
  --bg-leather: #2d2419;
  --bg-stone: #3d3a35;
  --bg-stone-light: #4a4640;

  /* Gold Accents */
  --gold-primary: #c9a227;
  --gold-dark: #8b7320;
  --gold-light: #e8c84a;
  --gold-glow: rgba(201, 162, 39, 0.4);

  /* Status Colors */
  --status-green: #4a9c2d;
  --status-green-glow: rgba(74, 156, 45, 0.5);
  --status-amber: #d4a017;
  --status-amber-glow: rgba(212, 160, 23, 0.5);
  --status-red: #8b1a1a;
  --status-red-glow: rgba(139, 26, 26, 0.5);
  --status-blue: #2a5599;

  /* Text Colors */
  --text-cream: #e8dcc4;
  --text-muted: #a89b84;
  --text-dark: #1a1410;

  /* Fonts */
  --font-header: 'Cinzel', serif;
  --font-body: 'Crimson Text', serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Sizing */
  --panel-border-width: 4px;
  --button-size: 56px;
  --minimap-size: 180px;
  --portrait-size: 80px;
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
}

body {
  font-family: var(--font-body);
  color: var(--text-cream);
  font-size: 16px;
  line-height: 1.4;
}

/* ============================================
   Texture Overlays & Decorative Elements
   ============================================ */

/* Parchment texture effect */
.parchment-bg {
  background:
    linear-gradient(135deg, rgba(45, 36, 25, 0.9) 0%, rgba(26, 20, 16, 0.95) 100%),
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 2px,
      rgba(232, 220, 196, 0.02) 2px,
      rgba(232, 220, 196, 0.02) 4px
    );
}

/* Stone panel effect */
.stone-panel {
  background:
    linear-gradient(180deg, var(--bg-stone-light) 0%, var(--bg-stone) 50%, #2d2a26 100%);
  border: var(--panel-border-width) solid;
  border-image: linear-gradient(
    180deg,
    var(--gold-light) 0%,
    var(--gold-primary) 30%,
    var(--gold-dark) 70%,
    #5a4a18 100%
  ) 1;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Gold frame border */
.gold-frame {
  border: 3px solid var(--gold-primary);
  box-shadow:
    0 0 0 1px var(--gold-dark),
    inset 0 0 0 1px var(--gold-dark),
    0 0 10px var(--gold-glow);
}

/* ============================================
   Game Container
   ============================================ */

#game-container {
  width: 100vw;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(ellipse at center, var(--bg-leather) 0%, var(--bg-dark) 100%);
  position: relative;
}

/* ============================================
   Resource Bar (Top)
   ============================================ */

#resource-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 8px 24px;
  background:
    linear-gradient(180deg, #3a3530 0%, #2a2520 50%, #1a1510 100%);
  border-bottom: 3px solid;
  border-image: linear-gradient(90deg,
    transparent 0%,
    var(--gold-dark) 10%,
    var(--gold-primary) 50%,
    var(--gold-dark) 90%,
    transparent 100%
  ) 1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  position: relative;
  z-index: 100;
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(180deg, rgba(61, 58, 53, 0.8) 0%, rgba(45, 42, 38, 0.8) 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 4px rgba(0, 0, 0, 0.3);
}

.resource-icon {
  font-size: 20px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.resource-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  color: var(--gold-light);
  text-shadow: 0 0 8px var(--gold-glow);
  min-width: 48px;
  text-align: right;
}

.resource-label {
  font-family: var(--font-header);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* Idle Worker Alert */
#idle-alert {
  position: absolute;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(180deg, #5a3a1a 0%, #3a2510 100%);
  border: 2px solid var(--status-amber);
  border-radius: 4px;
  color: var(--text-cream);
  font-family: var(--font-header);
  font-size: 14px;
  cursor: pointer;
  animation: pulse-alert 1.5s ease-in-out infinite;
  box-shadow:
    0 0 12px var(--status-amber-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

#idle-alert:hover {
  background: linear-gradient(180deg, #6a4a2a 0%, #4a3520 100%);
  transform: scale(1.05);
}

#idle-alert.hidden {
  display: none;
}

@keyframes pulse-alert {
  0%, 100% { box-shadow: 0 0 12px var(--status-amber-glow); }
  50% { box-shadow: 0 0 24px var(--status-amber-glow), 0 0 36px rgba(212, 160, 23, 0.3); }
}

.alert-icon {
  font-size: 18px;
}

.alert-count {
  font-family: var(--font-mono);
  font-weight: bold;
  color: var(--status-amber);
}

/* ============================================
   Main Area
   ============================================ */

#main-area {
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Map Container */
#map-container {
  flex: 1;
  position: relative;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(74, 70, 64, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 70%, rgba(45, 36, 25, 0.5) 0%, transparent 50%),
    var(--bg-dark);
  overflow: hidden;
}

#game-map {
  width: 100%;
  height: 100%;
  display: block;
}

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

/* Selection Box */
.selection-box {
  position: absolute;
  border: 2px solid var(--status-green);
  background: rgba(74, 156, 45, 0.15);
  pointer-events: none;
}

/* Event Log Panel */
#event-log {
  width: 280px;
  background: linear-gradient(180deg, rgba(45, 36, 25, 0.95) 0%, rgba(26, 20, 16, 0.98) 100%);
  border-left: 3px solid var(--gold-dark);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, opacity 0.3s ease;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.4);
}

#event-log.collapsed {
  width: 40px;
}

#event-log.collapsed .panel-content,
#event-log.collapsed .panel-header h3 {
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--bg-stone-light) 0%, var(--bg-stone) 100%);
  border-bottom: 2px solid var(--gold-dark);
}

.panel-header h3 {
  font-family: var(--font-header);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold-light);
  text-shadow: 0 0 8px var(--gold-glow);
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

.panel-toggle {
  width: 28px;
  height: 28px;
  background: linear-gradient(180deg, var(--bg-stone) 0%, #2a2720 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  color: var(--gold-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-toggle:hover {
  background: linear-gradient(180deg, var(--bg-stone-light) 0%, var(--bg-stone) 100%);
  border-color: var(--gold-primary);
}

#event-log.collapsed .panel-toggle {
  transform: rotate(180deg);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  transition: opacity 0.3s ease;
}

#event-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.event-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px;
  background: rgba(61, 58, 53, 0.4);
  border: 1px solid rgba(139, 115, 32, 0.3);
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.event-item:hover {
  background: rgba(61, 58, 53, 0.7);
  border-color: var(--gold-dark);
}

.event-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.event-icon {
  font-size: 14px;
}

.event-text {
  flex: 1;
  color: var(--text-cream);
  word-wrap: break-word;
}

/* Event type colors */
.event-spawn .event-text { color: var(--status-green); }
.event-complete .event-text { color: var(--gold-light); }
.event-error .event-text { color: var(--status-red); }
.event-terminate .event-text { color: var(--text-muted); }

/* Scrollbar styling */
.panel-content::-webkit-scrollbar {
  width: 8px;
}

.panel-content::-webkit-scrollbar-track {
  background: var(--bg-dark);
}

.panel-content::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--gold-primary);
}

/* ============================================
   Bottom Panel
   ============================================ */

#bottom-panel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  padding: 8px 12px;
  background:
    linear-gradient(180deg, #2a2520 0%, #1a1510 100%);
  border-top: 3px solid;
  border-image: linear-gradient(90deg,
    transparent 0%,
    var(--gold-dark) 10%,
    var(--gold-primary) 50%,
    var(--gold-dark) 90%,
    transparent 100%
  ) 1;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5);
  position: relative;
  z-index: 100;
}

/* Minimap Section */
#minimap-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#minimap-container {
  width: var(--minimap-size);
  height: var(--minimap-size);
  position: relative;
  background: var(--bg-dark);
  border: 3px solid var(--gold-dark);
  box-shadow:
    inset 0 0 20px rgba(0, 0, 0, 0.8),
    0 0 10px var(--gold-glow);
}

#minimap {
  width: 100%;
  height: 100%;
  display: block;
}

#minimap-viewport {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.6);
  pointer-events: none;
}

/* Portrait Section */
#portrait-section {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: linear-gradient(180deg, rgba(61, 58, 53, 0.6) 0%, rgba(45, 42, 38, 0.6) 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 6px;
  margin: 0 auto;
  max-width: 400px;
}

#portrait-frame {
  width: var(--portrait-size);
  height: var(--portrait-size);
  flex-shrink: 0;
  position: relative;
  background:
    radial-gradient(circle at center, var(--bg-stone-light) 0%, var(--bg-dark) 100%);
  border: 3px solid var(--gold-primary);
  border-radius: 50%;
  box-shadow:
    0 0 0 2px var(--gold-dark),
    inset 0 0 15px rgba(0, 0, 0, 0.7),
    0 0 15px var(--gold-glow);
  overflow: hidden;
}

#portrait-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-placeholder {
  font-size: 36px;
  opacity: 0.5;
}

#unit-info {
  flex: 1;
  min-width: 0;
}

#unit-name {
  font-family: var(--font-header);
  font-size: 16px;
  color: var(--gold-light);
  text-shadow: 0 0 8px var(--gold-glow);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#unit-task {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#unit-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
}

.stat-row {
  display: flex;
  gap: 4px;
  font-size: 12px;
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-mono);
  color: var(--text-cream);
}

#progress-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

#progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-dark);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--status-green) 0%, #6acc4a 100%);
  box-shadow: 0 0 8px var(--status-green-glow);
  transition: width 0.3s ease;
}

#progress-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  min-width: 40px;
}

/* Command Section */
#command-section {
  display: flex;
  align-items: center;
}

#command-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  padding: 8px;
  background: linear-gradient(180deg, var(--bg-stone) 0%, #2a2720 100%);
  border: 3px solid var(--gold-dark);
  border-radius: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.4);
}

.cmd-btn {
  width: var(--button-size);
  height: var(--button-size);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background:
    linear-gradient(180deg, #4a4640 0%, #3a3530 40%, #2a2520 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  color: var(--text-cream);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.3);
}

.cmd-btn:hover {
  background:
    linear-gradient(180deg, #5a5650 0%, #4a4540 40%, #3a3530 100%);
  border-color: var(--gold-primary);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 10px var(--gold-glow);
}

.cmd-btn:active {
  background:
    linear-gradient(180deg, #2a2520 0%, #3a3530 40%, #4a4640 100%);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.4);
  transform: translateY(1px);
}

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

.cmd-btn::after {
  content: attr(data-key);
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--gold-dark);
}

.cmd-icon {
  font-size: 20px;
}

.cmd-label {
  font-family: var(--font-header);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================
   Tooltip
   ============================================ */

#tooltip {
  position: fixed;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(45, 36, 25, 0.98) 0%, rgba(26, 20, 16, 0.98) 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-cream);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 1000;
  max-width: 300px;
}

#tooltip.hidden {
  display: none;
}

/* ============================================
   Modal
   ============================================ */

#modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

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

#modal-content {
  min-width: 400px;
  max-width: 600px;
  max-height: 80vh;
  background: linear-gradient(180deg, var(--bg-stone) 0%, var(--bg-leather) 100%);
  border: 3px solid var(--gold-primary);
  border-radius: 8px;
  box-shadow:
    0 0 30px var(--gold-glow),
    0 10px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(180deg, var(--bg-stone-light) 0%, var(--bg-stone) 100%);
  border-bottom: 2px solid var(--gold-dark);
}

.modal-header h3 {
  font-family: var(--font-header);
  font-size: 18px;
  color: var(--gold-light);
  text-shadow: 0 0 10px var(--gold-glow);
}

#modal-close {
  width: 32px;
  height: 32px;
  background: linear-gradient(180deg, #5a3a3a 0%, #3a2020 100%);
  border: 2px solid var(--status-red);
  border-radius: 4px;
  color: var(--text-cream);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#modal-close:hover {
  background: linear-gradient(180deg, #7a4a4a 0%, #5a3030 100%);
  box-shadow: 0 0 10px var(--status-red-glow);
}

#modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 70px);
}

/* ============================================
   SVG Filter Applications
   ============================================ */

/* Apply stone noise to panels */
#resource-bar,
#bottom-panel,
.panel-header,
#command-card {
  filter: url(#stone-noise);
}

/* Apply parchment grain to main background */
#game-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  filter: url(#parchment-grain);
  z-index: 0;
}

/* Gold glow on hover for important elements */
.resource-value,
#unit-name,
.panel-header h3 {
  transition: filter 0.3s ease;
}

.resource-item:hover .resource-value {
  filter: url(#glow-gold);
}

/* Status-specific glows */
.event-spawn .event-icon svg {
  filter: url(#glow-green);
}

.event-error .event-icon svg {
  filter: url(#glow-red);
}

.event-complete .event-icon svg {
  filter: url(#glow-gold);
}

/* ============================================
   Enhanced Animations
   ============================================ */

/* Gold shimmer animation for headers */
@keyframes gold-shimmer {
  0%, 100% {
    text-shadow: 0 0 8px var(--gold-glow);
  }
  50% {
    text-shadow: 0 0 16px var(--gold-glow), 0 0 24px rgba(201, 162, 39, 0.3);
  }
}

.panel-header h3 {
  animation: gold-shimmer 4s ease-in-out infinite;
}

/* Breathing animation for portrait when selected */
@keyframes portrait-breathing {
  0%, 100% {
    box-shadow:
      0 0 0 2px var(--gold-dark),
      inset 0 0 15px rgba(0, 0, 0, 0.7),
      0 0 15px var(--gold-glow);
  }
  50% {
    box-shadow:
      0 0 0 2px var(--gold-dark),
      inset 0 0 15px rgba(0, 0, 0, 0.7),
      0 0 25px var(--gold-glow),
      0 0 35px rgba(201, 162, 39, 0.2);
  }
}

#portrait-frame.selected {
  animation: portrait-breathing 2s ease-in-out infinite;
}

/* Button press effect */
.cmd-btn:active {
  transform: translateY(2px) scale(0.98);
}

/* Danger button styling */
.cmd-btn--danger {
  border-color: var(--status-red);
}

.cmd-btn--danger:hover {
  border-color: #aa2a2a;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 0 10px var(--status-red-glow);
}

/* Status indicator animations */
@keyframes status-pulse-green {
  0%, 100% { box-shadow: 0 0 4px var(--status-green-glow); }
  50% { box-shadow: 0 0 12px var(--status-green-glow); }
}

@keyframes status-pulse-amber {
  0%, 100% { box-shadow: 0 0 4px var(--status-amber-glow); }
  50% { box-shadow: 0 0 12px var(--status-amber-glow); }
}

@keyframes status-pulse-red {
  0%, 100% { box-shadow: 0 0 4px var(--status-red-glow); }
  50% { box-shadow: 0 0 12px var(--status-red-glow); }
}

.status-pip.green { animation: status-pulse-green 2s ease-in-out infinite; }
.status-pip.amber { animation: status-pulse-amber 1.5s ease-in-out infinite; }
.status-pip.red { animation: status-pulse-red 1s ease-in-out infinite; }

/* Map region labels */
.map-region-label {
  position: absolute;
  font-family: var(--font-header);
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.6;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Corner ornaments for panels */
.panel-ornament {
  position: absolute;
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-dark) 100%);
  clip-path: polygon(0 0, 100% 0, 100% 30%, 30% 100%, 0 100%);
}

.panel-ornament--tl { top: -2px; left: -2px; }
.panel-ornament--tr { top: -2px; right: -2px; transform: scaleX(-1); }
.panel-ornament--bl { bottom: -2px; left: -2px; transform: scaleY(-1); }
.panel-ornament--br { bottom: -2px; right: -2px; transform: scale(-1); }

/* Resource item warning state */
.resource-item--warning .resource-value {
  color: var(--status-amber);
}

.resource-item--warning[data-value]:not([data-value="0"]) {
  animation: pulse-alert 2s ease-in-out infinite;
}

/* ============================================
   Utility Classes
   ============================================ */

.hidden {
  display: none !important;
}

.glow-text {
  text-shadow: 0 0 10px currentColor;
}

/* Visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Status indicator pips */
.status-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-pip.green {
  background: var(--status-green);
  box-shadow: 0 0 6px var(--status-green-glow);
}

.status-pip.amber {
  background: var(--status-amber);
  box-shadow: 0 0 6px var(--status-amber-glow);
}

.status-pip.red {
  background: var(--status-red);
  box-shadow: 0 0 6px var(--status-red-glow);
}

/* Worker status colors for various UI elements */
.worker-idle { color: var(--status-amber); }
.worker-working { color: var(--status-green); }
.worker-blocked { color: var(--status-red); }
.worker-complete { color: var(--gold-light); }

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 1024px) {
  #resource-bar {
    flex-wrap: wrap;
    gap: 12px;
  }

  .resource-item {
    padding: 4px 8px;
  }

  .resource-label {
    display: none;
  }

  #event-log {
    width: 220px;
  }

  :root {
    --minimap-size: 150px;
    --button-size: 48px;
  }
}

@media (max-width: 768px) {
  #bottom-panel {
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
  }

  #portrait-section {
    grid-column: 1 / -1;
    order: -1;
    max-width: 100%;
  }

  #event-log {
    position: absolute;
    right: 0;
    top: 0;
    height: calc(100% - 200px);
    z-index: 50;
  }

  #event-log.collapsed {
    width: 36px;
  }
}

/* ============================================
   WC3-Style Resource Bar Enhancements
   ============================================ */

.resource-gold .resource-value {
  color: #e8c84a;
  text-shadow: 0 0 8px rgba(232, 200, 74, 0.5);
}

.resource-lumber .resource-value {
  color: #a0522d;
  text-shadow: 0 0 8px rgba(160, 82, 45, 0.5);
}

.resource-supply .resource-value {
  color: var(--status-green);
}

.resource-supply.supply-warning .resource-value {
  color: var(--status-amber);
  animation: pulse-alert 1.5s ease-in-out infinite;
}

.resource-supply.supply-critical .resource-value {
  color: var(--status-red);
  animation: pulse-alert 0.8s ease-in-out infinite;
}

/* Upkeep Indicator */
.resource-upkeep {
  flex-direction: column;
  align-items: center;
  padding: 4px 12px;
}

.upkeep-level {
  font-family: var(--font-header);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.upkeep-multiplier {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: bold;
}

.resource-upkeep[data-upkeep="low"] .upkeep-level { color: var(--status-green); }
.resource-upkeep[data-upkeep="low"] .upkeep-multiplier { color: var(--status-green); }

.resource-upkeep[data-upkeep="medium"] .upkeep-level { color: var(--status-amber); }
.resource-upkeep[data-upkeep="medium"] .upkeep-multiplier { color: var(--status-amber); }

.resource-upkeep[data-upkeep="high"] .upkeep-level { color: #ff6b35; }
.resource-upkeep[data-upkeep="high"] .upkeep-multiplier { color: #ff6b35; }

.resource-upkeep[data-upkeep="critical"] .upkeep-level { color: var(--status-red); }
.resource-upkeep[data-upkeep="critical"] .upkeep-multiplier { color: var(--status-red); }

/* Day/Night Cycle */
.resource-cycle[data-phase="day"] .resource-value { color: #e8c84a; }
.resource-cycle[data-phase="evening"] .resource-value { color: #ff9f43; }
.resource-cycle[data-phase="night"] .resource-value { color: #6c7a89; }

/* Resource Divider */
.resource-divider {
  width: 2px;
  height: 32px;
  background: linear-gradient(180deg, transparent, var(--gold-dark), transparent);
  margin: 0 8px;
}

.resource-stats {
  opacity: 0.7;
}

.resource-stats .resource-value {
  font-size: 14px;
  min-width: 36px;
}

/* ============================================
   Game Panels (Tech Tree, Production, etc.)
   ============================================ */

.game-panel {
  position: absolute;
  background: linear-gradient(180deg, rgba(45, 36, 25, 0.98) 0%, rgba(26, 20, 16, 0.98) 100%);
  border: 3px solid var(--gold-dark);
  border-radius: 8px;
  box-shadow:
    0 0 30px rgba(0, 0, 0, 0.6),
    0 0 10px var(--gold-glow);
  z-index: 200;
  min-width: 300px;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
}

.game-panel .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--bg-stone-light) 0%, var(--bg-stone) 100%);
  border-bottom: 2px solid var(--gold-dark);
}

.game-panel .panel-header h3 {
  font-family: var(--font-header);
  font-size: 16px;
  color: var(--gold-light);
  text-shadow: 0 0 8px var(--gold-glow);
  margin: 0;
}

.panel-close {
  width: 28px;
  height: 28px;
  background: linear-gradient(180deg, #5a3a3a 0%, #3a2020 100%);
  border: 2px solid var(--status-red);
  border-radius: 4px;
  color: var(--text-cream);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-close:hover {
  background: linear-gradient(180deg, #7a4a4a 0%, #5a3030 100%);
  box-shadow: 0 0 10px var(--status-red-glow);
}

.game-panel .panel-content {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(80vh - 60px);
}

/* Production Panel */
#production-panel {
  top: 60px;
  left: 20px;
}

.production-building {
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(61, 58, 53, 0.4);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
}

.production-building-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.production-building-icon {
  font-size: 24px;
}

.production-building-name {
  font-family: var(--font-header);
  font-size: 14px;
  color: var(--gold-light);
}

.production-queue {
  display: flex;
  gap: 4px;
}

.queue-slot {
  width: 44px;
  height: 44px;
  background: var(--bg-dark);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.queue-slot.active {
  border-color: var(--status-green);
  box-shadow: 0 0 8px var(--status-green-glow);
}

.queue-slot .unit-icon {
  font-size: 20px;
}

.queue-slot .queue-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--bg-dark);
}

.queue-slot .queue-progress-fill {
  height: 100%;
  background: var(--status-green);
  transition: width 0.1s linear;
}

.queue-slot .cancel-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  background: var(--status-red);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 10px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.queue-slot:hover .cancel-btn {
  opacity: 1;
}

/* Tech Tree Panel */
#tech-tree-panel {
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  max-width: 90vw;
}

.tech-tree-tiers {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tech-tier {
  padding: 12px;
  background: rgba(61, 58, 53, 0.3);
  border: 1px solid rgba(139, 115, 32, 0.3);
  border-radius: 4px;
}

.tier-header {
  font-family: var(--font-header);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(139, 115, 32, 0.3);
}

.tech-nodes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tech-node {
  width: 80px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(61, 58, 53, 0.8) 0%, rgba(45, 42, 38, 0.8) 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tech-node:hover {
  border-color: var(--gold-primary);
  box-shadow: 0 0 10px var(--gold-glow);
}

.tech-node.unlocked {
  border-color: var(--status-green);
  background: linear-gradient(180deg, rgba(74, 156, 45, 0.2) 0%, rgba(45, 42, 38, 0.8) 100%);
}

.tech-node.researching {
  border-color: var(--status-amber);
  animation: pulse-alert 1.5s ease-in-out infinite;
}

.tech-node.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.tech-node-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.tech-node-name {
  font-size: 10px;
  color: var(--text-cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tech-node-cost {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--gold-light);
  margin-top: 4px;
}

/* Research Progress */
#research-progress {
  margin-top: 16px;
  padding: 12px;
  background: rgba(61, 58, 53, 0.5);
  border: 1px solid var(--status-amber);
  border-radius: 4px;
}

.research-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

#research-name {
  font-family: var(--font-header);
  font-size: 12px;
  color: var(--gold-light);
}

#research-time {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

/* Hero Panel */
#hero-panel {
  top: 60px;
  right: 300px;
  width: 320px;
}

.hero-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.hero-portrait-large {
  width: 80px;
  height: 80px;
  background:
    radial-gradient(circle at center, var(--bg-stone-light) 0%, var(--bg-dark) 100%);
  border: 3px solid var(--gold-primary);
  border-radius: 50%;
  position: relative;
  box-shadow:
    0 0 0 2px var(--gold-dark),
    0 0 15px var(--gold-glow);
}

.hero-level-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 28px;
  height: 28px;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold-primary) 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-header);
  font-size: 14px;
  font-weight: bold;
  color: var(--text-dark);
}

.hero-attributes {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attr-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.attr-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 50px;
}

.attr-bar {
  flex: 1;
  height: 12px;
  background: var(--bg-dark);
  border: 1px solid var(--gold-dark);
  border-radius: 2px;
  overflow: hidden;
}

.attr-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.health-bar .attr-fill {
  background: linear-gradient(90deg, #8b1a1a 0%, #cc2a2a 100%);
}

.mana-bar .attr-fill {
  background: linear-gradient(90deg, #2a5599 0%, #4a85d9 100%);
}

.xp-bar .attr-fill {
  background: linear-gradient(90deg, var(--gold-dark) 0%, var(--gold-light) 100%);
}

.attr-value {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-cream);
  min-width: 50px;
  text-align: right;
}

/* Hero Inventory */
.hero-inventory h4 {
  font-family: var(--font-header);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.inventory-slot {
  aspect-ratio: 1;
  background: var(--bg-dark);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.inventory-slot:hover {
  border-color: var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-glow);
}

.inventory-slot.filled {
  background: linear-gradient(180deg, rgba(61, 58, 53, 0.8) 0%, rgba(45, 42, 38, 0.8) 100%);
}

.inventory-slot .item-icon {
  font-size: 28px;
}

/* Item rarity borders */
.inventory-slot.common { border-color: #888; }
.inventory-slot.uncommon { border-color: #1eff00; }
.inventory-slot.rare { border-color: #0070dd; }
.inventory-slot.legendary { border-color: #ff8000; box-shadow: 0 0 10px rgba(255, 128, 0, 0.5); }

/* Build Menu Panel */
#build-menu-panel {
  bottom: 200px;
  right: 20px;
  width: 280px;
}

.build-categories {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.build-category {
  flex: 1;
  padding: 6px 8px;
  background: rgba(61, 58, 53, 0.5);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  color: var(--text-muted);
  font-family: var(--font-header);
  font-size: 10px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.build-category:hover,
.build-category.active {
  background: rgba(201, 162, 39, 0.2);
  border-color: var(--gold-primary);
  color: var(--gold-light);
}

.build-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.build-option {
  aspect-ratio: 1;
  background: linear-gradient(180deg, rgba(61, 58, 53, 0.8) 0%, rgba(45, 42, 38, 0.8) 100%);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.build-option:hover {
  border-color: var(--gold-primary);
  box-shadow: 0 0 10px var(--gold-glow);
}

.build-option.selected {
  border-color: var(--status-green);
  box-shadow: 0 0 10px var(--status-green-glow);
}

.build-option.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.build-option .building-icon {
  font-size: 28px;
  margin-bottom: 2px;
}

.build-option .building-name {
  font-size: 9px;
  color: var(--text-muted);
}

.build-info {
  padding: 12px;
  background: rgba(61, 58, 53, 0.3);
  border: 1px solid rgba(139, 115, 32, 0.3);
  border-radius: 4px;
}

.build-info p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.build-info .building-desc {
  margin-bottom: 8px;
  color: var(--text-cream);
}

.build-info .building-cost {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.build-info .cost-gold { color: #e8c84a; }
.build-info .cost-lumber { color: #a0522d; }

/* Building Ghost (Placement Preview) */
#building-ghost {
  position: absolute;
  pointer-events: none;
  z-index: 150;
  transition: opacity 0.15s ease;
}

#building-ghost .ghost-icon {
  font-size: 48px;
  text-align: center;
  filter: drop-shadow(0 0 8px rgba(74, 156, 45, 0.6));
}

#building-ghost.invalid .ghost-icon {
  filter: drop-shadow(0 0 8px rgba(139, 26, 26, 0.6));
}

#building-ghost .ghost-grid {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 96px;
  height: 96px;
  border: 2px dashed var(--status-green);
  border-radius: 8px;
  opacity: 0.6;
}

#building-ghost.invalid .ghost-grid {
  border-color: var(--status-red);
}

/* ============================================
   Combat & Task Overlays
   ============================================ */

.combat-indicator {
  position: absolute;
  width: 60px;
  height: 8px;
  background: var(--bg-dark);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  overflow: hidden;
  transform: translateX(-50%);
}

.combat-indicator .hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b1a1a 0%, #cc2a2a 100%);
  transition: width 0.15s ease;
}

.damage-popup {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: bold;
  color: #ff4444;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  animation: damage-float 1s ease-out forwards;
}

@keyframes damage-float {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-30px);
  }
}

.xp-popup {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: bold;
  color: var(--gold-light);
  text-shadow: 0 0 8px var(--gold-glow);
  pointer-events: none;
  animation: xp-float 1.5s ease-out forwards;
}

@keyframes xp-float {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-20px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateY(-40px) scale(0.8);
  }
}

/* Victory Banner */
.victory-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 32px 64px;
  background: linear-gradient(180deg, rgba(45, 36, 25, 0.98) 0%, rgba(26, 20, 16, 0.98) 100%);
  border: 4px solid var(--gold-primary);
  border-radius: 8px;
  box-shadow:
    0 0 50px var(--gold-glow),
    0 20px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  z-index: 1000;
  animation: victory-appear 0.5s ease-out;
}

@keyframes victory-appear {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.victory-banner h2 {
  font-family: var(--font-header);
  font-size: 32px;
  color: var(--gold-light);
  text-shadow: 0 0 20px var(--gold-glow);
  margin-bottom: 16px;
}

.victory-banner .victory-type {
  font-size: 18px;
  color: var(--text-cream);
  margin-bottom: 8px;
}

.victory-banner .victory-stats {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-muted);
}
