/* css/theme.css */
/* Setup Overlay */
#setup-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(0, 0, 0, 0.4);
  z-index: 30;
  pointer-events: none;
}

#setup-confirm,
#setup-difficulty {
  pointer-events: auto;
}

#setup-message {
  font-size: 24px;
  color: #ffd100;
  text-shadow: 0 0 10px #ffd100;
  letter-spacing: 2px;
}

#setup-confirm {
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #4488ff;
  color: #4488ff;
  padding: 10px 30px;
  cursor: pointer;
  text-shadow: 0 0 5px #4488ff;
}

#setup-confirm:hover {
  background: rgba(0, 30, 80, 0.6);
  box-shadow: 0 0 15px rgba(68, 136, 255, 0.4);
}

#setup-difficulty {
  display: flex;
  gap: 10px;
}

.diff-btn {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #aa8b00;
  color: #ffd100;
  padding: 8px 16px;
  cursor: pointer;
}

.diff-btn:hover {
  background: rgba(50.0, 41, 0, 0.6);
  text-shadow: 0 0 8px #ffd100;
  box-shadow: 0 0 10px rgba(255.0, 209, 0, 0.3);
}

.diff-btn[data-level="4"] { border-color: #cc9900; color: #ffcc00; }
.diff-btn[data-level="4"]:hover { text-shadow: 0 0 8px #ffcc00; }
.diff-btn[data-level="5"] { border-color: #cc2020; color: #ff2020; }
.diff-btn[data-level="5"]:hover { text-shadow: 0 0 8px #ff2020; }
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #000;
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
  color: #ffd100;
}

#game-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#ui-overlay > * { pointer-events: auto; }
#ui-overlay > #setup-overlay { pointer-events: none; }

.hidden { display: none !important; }
.intro-hidden { display: none !important; }

/* Tooltip */
#tooltip {
  position: fixed;
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #ffd100;
  padding: 8px 12px;
  font-size: 11px;
  max-width: 250px;
  z-index: 20;
}

.tt-name {
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 4px;
  color: #ffd100;
  text-shadow: 0 0 5px #ffd100;
}

.tt-row { color: #aa8b00; margin: 2px 0; }
.tt-placeholder { color: #554600; font-style: italic; }

/* Resource Bar */
#resource-bar {
  position: fixed;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #aa8b00;
  padding: 6px 12px;
  display: flex;
  gap: 15px;
  font-size: 12px;
  z-index: 10;
}

.resource { color: #ffd100; white-space: nowrap; }
.res-rate { font-size: 10px; color: #aa8b00; }
.res-water { color: #4488ff; }
.res-food { color: #ffcc00; }

/* DEFCON */
#defcon-indicator {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #ffd100;
  padding: 6px 12px;
  font-size: 14px;
  font-weight: bold;
  z-index: 10;
  text-shadow: 0 0 5px currentColor;
}

.defcon-critical {
  animation: defcon-pulse 0.5s ease-in-out infinite alternate;
}

@keyframes defcon-pulse {
  from { opacity: 1; }
  to { opacity: 0.4; }
}

/* Action Buttons */
#action-buttons {
  position: fixed;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 10;
}

.action-btn {
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #aa8b00;
  color: #ffd100;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  padding: 8px 16px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.btn-hint {
  font-size: 9px;
  opacity: 0.6;
  font-weight: normal;
}

.action-btn:hover {
  background: rgba(50.0, 41, 0, 0.6);
  text-shadow: 0 0 8px #ffd100;
  box-shadow: 0 0 10px rgba(255.0, 209, 0, 0.3);
}

.btn-build { border-color: #aa8b00; }
.btn-build:hover { border-color: #ffd100; }
.btn-research { border-color: #3366cc; color: #4488ff; }
.btn-research:hover { text-shadow: 0 0 8px #4488ff; box-shadow: 0 0 10px rgba(68, 136, 255, 0.3); }
.btn-gather { border-color: #cc9900; color: #ffcc00; }
.btn-gather:hover { text-shadow: 0 0 8px #ffcc00; box-shadow: 0 0 10px rgba(255, 204, 0, 0.3); }
.btn-attack { border-color: #cc2020; color: #ff2020; }
.btn-attack:hover { text-shadow: 0 0 8px #ff2020; box-shadow: 0 0 10px rgba(255, 32, 32, 0.3); }

/* Mini-Info */
#mini-info {
  position: fixed;
  bottom: 70px;
  left: 10px;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid #aa8b00;
  padding: 8px 12px;
  font-size: 11px;
  color: #aa8b00;
  line-height: 1.6;
  z-index: 10;
}

/* Modal */
#modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

#modal {
  background: #000;
  border: 2px solid #ffd100;
  outline: 1px solid #aa8b00;
  outline-offset: 3px;
  min-width: 350px;
  max-width: 500px;
}

#modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  border-bottom: 1px solid #aa8b00;
}

#modal-title {
  font-size: 14px;
  font-weight: bold;
  color: #ffd100;
  text-shadow: 0 0 5px #ffd100;
}

#modal-close {
  background: none;
  border: 1px solid #aa8b00;
  color: #aa8b00;
  font-family: 'Courier New', Courier, monospace;
  font-size: 10px;
  padding: 3px 8px;
  cursor: pointer;
}

#modal-close:hover {
  color: #ffd100;
  border-color: #ffd100;
  text-shadow: 0 0 5px #ffd100;
}

#modal-body {
  padding: 15px;
  min-height: 120px;
}

.modal-placeholder {
  color: #554600;
  font-size: 11px;
  line-height: 1.6;
  margin: 0;
}

/* CRT Overlay */
#crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

#crt-overlay::before {
  content: '';
  display: block;
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.3) 2px,
    rgba(0, 0, 0, 0.3) 4px
  );
}

#crt-overlay::after {
  content: '';
  display: block;
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 150px rgba(0, 0, 0, 0.7);
}

/* Global text glow */
body * {
  text-shadow: 0 0 5px currentColor;
}

/* Text transform */
#ui-overlay, #ui-overlay * {
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Loading state */
#game-canvas.loading {
  display: none;
}

.loading-text {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffd100;
  font-size: 16px;
  text-shadow: 0 0 10px #ffd100;
  z-index: 5;
}

/* Modal Grid */
.modal-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 5px 0;
}

.build-btn {
  background: rgba(0, 30, 0, 0.5);
  border: 1px solid #aa8b00;
  color: #ffd100;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  padding: 10px 15px;
  cursor: pointer;
  text-align: left;
  text-transform: uppercase;
}

.build-btn:hover:not(.disabled) {
  background: rgba(50.0, 41, 0, 0.6);
  border-color: #ffd100;
  text-shadow: 0 0 5px #ffd100;
}

.build-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #332a00;
}

.build-btn .cost {
  font-size: 10px;
  color: #aa8b00;
}

.modal-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #332a00;
  font-size: 11px;
  color: #aa8b00;
}

/* Gather Grid */
.gather-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.gather-icon { font-size: 14px; width: 20px; }
.gather-label { width: 50px; font-size: 11px; color: #ffd100; }
.gather-count { width: 20px; text-align: center; font-size: 13px; color: #ffd100; }
.gather-rate { font-size: 10px; color: #aa8b00; margin-left: auto; }

.gather-btn {
  background: rgba(0, 30, 0, 0.5);
  border: 1px solid #aa8b00;
  color: #ffd100;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gather-btn:hover {
  background: rgba(50.0, 41, 0, 0.6);
  border-color: #ffd100;
}

/* Research Grid */
.research-grid {
  display: flex;
  gap: 10px;
}

.research-branch {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.branch-title {
  font-size: 9px;
  font-weight: bold;
  text-align: center;
  padding-bottom: 4px;
  border-bottom: 1px solid #332a00;
  margin-bottom: 2px;
}

.tech-item {
  font-size: 9px;
  padding: 4px 6px;
  border: 1px solid #332a00;
  color: #443800;
  cursor: default;
}

.tech-item.completed {
  color: #ffd100;
  border-color: #aa8b00;
}

.tech-item.researching {
  color: #ffd100;
  border-color: #ffd100;
  animation: defcon-pulse 1s ease-in-out infinite alternate;
}

.tech-item.available {
  color: #aa8b00;
  border-color: #aa8b00;
  cursor: pointer;
}

.tech-item.available:hover {
  background: rgba(50.0, 41, 0, 0.5);
  color: #ffd100;
}

.tech-item.locked {
  color: #332a00;
  border-color: #221c00;
}

/* Attack List */
.attack-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.attack-btn {
  background: rgba(30, 0, 0, 0.5);
  border: 1px solid #cc2020;
  color: #ff2020;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  text-transform: uppercase;
}

.attack-btn:hover:not(.disabled) {
  background: rgba(50, 0, 0, 0.6);
  border-color: #ff2020;
  text-shadow: 0 0 5px #ff2020;
}

.attack-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  color: #882020;
}

/* Game Over */
#gameover-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  background: rgba(0, 0, 0, 0.8);
  z-index: 60;
}

#gameover-message {
  font-size: 28px;
  letter-spacing: 3px;
  text-shadow: 0 0 15px currentColor;
}

#gameover-message.victory { color: #4488ff; }
#gameover-message.defeat { color: #ff2020; }

#gameover-restart {
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #aa8b00;
  color: #ffd100;
  padding: 10px 25px;
  cursor: pointer;
}

#gameover-restart:hover {
  text-shadow: 0 0 8px #ffd100;
  box-shadow: 0 0 10px rgba(255.0, 209, 0, 0.3);
}

/* Notifications */
#notifications {
  position: fixed;
  top: 78px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 15;
  pointer-events: none;
}

.notification {
  background: rgba(0, 0, 0, 0.85);
  border: 1px solid #aa8b00;
  color: #ffd100;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  padding: 6px 12px;
  max-width: 300px;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s, transform 0.3s;
}

.notification.show {
  opacity: 1;
  transform: translateX(0);
}

.notification-warning { border-color: #cc9900; color: #ffcc00; }
.notification-danger { border-color: #cc2020; color: #ff2020; }
.notification-success { border-color: #ffd100; color: #ffd100; }

.info-idle { font-size: 10px; }
