/* Castle Defense — tower defense game styles */

.game-page {
  background: #0f0f1a;
  color: #e6e6f0;
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.site-header h1 {
  color: #e94560;
  text-shadow: 0 0 18px rgba(233, 69, 96, 0.6), 0 0 4px rgba(233, 69, 96, 0.9);
  margin: 0;
  font-size: 1.8rem;
}

.subtitle {
  color: #a0a0c0;
  font-size: 0.95rem;
}

.back-link {
  display: inline-block;
  padding: 8px 16px;
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  color: #eee;
  text-decoration: none;
  transition: all 0.2s;
}

.back-link:hover {
  background: #e94560;
  border-color: #e94560;
  color: white;
}

/* HUD */
.hud {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.hud-cell {
  flex: 1;
  min-width: 110px;
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 10px 14px;
  text-align: center;
}

.hud-label {
  color: #a0a0c0;
  font-size: 0.75rem;
  letter-spacing: 1.2px;
  margin-bottom: 4px;
}

.hud-value {
  color: #e94560;
  font-size: 1.4rem;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(233, 69, 96, 0.4);
}

/* Game area: map + sidebar */
.game-area {
  display: grid;
  grid-template-columns: minmax(640px, 1fr) 320px;
  gap: 16px;
  margin-bottom: 20px;
}

.map-wrap {
  position: relative;
  background: #16213e;
  border: 2px solid #2a2a4a;
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

#mapCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  cursor: crosshair;
}

/* Map overlay (start/end screens) */
.map-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 15, 26, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.3s;
}

.map-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  text-align: center;
  padding: 32px;
  max-width: 80%;
}

.overlay-content h2 {
  color: #e94560;
  font-size: 2rem;
  text-shadow: 0 0 16px rgba(233, 69, 96, 0.6);
  margin-bottom: 12px;
}

.overlay-content p {
  color: #c0c0d8;
  margin-bottom: 24px;
  font-size: 1.05rem;
}

.overlay-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Wave banner (shows when a wave starts) */
.wave-banner {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(233, 69, 96, 0.92);
  color: white;
  padding: 16px 36px;
  border-radius: 8px;
  font-size: 1.8rem;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 30px rgba(233, 69, 96, 0.7);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}

.wave-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-section {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 14px;
}

.sidebar-section h3 {
  color: #e94560;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  border-bottom: 1px solid #2a2a4a;
  padding-bottom: 6px;
}

/* Map picker */
.map-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.map-btn {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  background: #16213e;
  border: 1px solid #2a2a4a;
  color: #c0c0d8;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.map-btn:hover {
  background: #2a2a4a;
  color: white;
}

.map-btn.active {
  background: #e94560;
  color: white;
  border-color: #e94560;
}

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

/* Tower cards */
.tower-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.tower-card {
  background: #16213e;
  border: 2px solid #2a2a4a;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  color: #e6e6f0;
  font-family: inherit;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: center;
}

.tower-card:hover:not(:disabled) {
  border-color: #e94560;
  transform: translateY(-1px);
}

.tower-card.selected {
  border-color: #e94560;
  background: rgba(233, 69, 96, 0.18);
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.4);
}

.tower-card:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tower-icon {
  font-size: 1.6rem;
  grid-row: span 2;
}

.tower-name {
  font-weight: 700;
  color: #e94560;
  font-size: 0.95rem;
}

.tower-cost {
  font-size: 0.8rem;
  color: #ffc107;
}

.tower-desc {
  grid-column: 2;
  font-size: 0.78rem;
  color: #a0a0b8;
}

.tower-hint {
  margin-top: 10px;
  font-size: 0.85rem;
  color: #a0a0b8;
  text-align: center;
  padding: 6px;
  background: #16213e;
  border-radius: 4px;
  min-height: 30px;
}

/* Control buttons */
.control-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  padding: 10px 14px;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s;
}

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

.btn-primary {
  background: #e94560;
  border-color: #e94560;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #ff6b81;
  border-color: #ff6b81;
}

.btn-secondary {
  background: #16213e;
  color: #c0c0d8;
}

.btn-secondary:hover:not(:disabled) {
  background: #2a2a4a;
  color: white;
}

.btn-secondary.active {
  background: #4ecca3;
  color: #0f0f1a;
  border-color: #4ecca3;
}

.btn-danger {
  background: #16213e;
  color: #e94560;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(233, 69, 96, 0.18);
  border-color: #e94560;
}

/* Stats list */
.stats-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.85rem;
  color: #c0c0d8;
}

.stats-list span {
  color: #e94560;
  font-weight: 700;
}

/* Stats summary (in overlay) */
.stats-summary {
  margin-top: 24px;
  padding: 16px;
  background: #1a1a2e;
  border-radius: 8px;
  border: 1px solid #2a2a4a;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.9rem;
  color: #c0c0d8;
  text-align: left;
}

.stats-summary .v {
  color: #e94560;
  font-weight: 700;
}

/* Upgrade panel */
.upgrade-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  pointer-events: none;
}

.upgrade-card {
  pointer-events: auto;
  background: #1a1a2e;
  border: 2px solid #e94560;
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 0 30px rgba(233, 69, 96, 0.4);
  min-width: 320px;
  animation: panelIn 0.2s ease-out;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.upgrade-header {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #e94560;
  margin-bottom: 10px;
}

.upgrade-header > :nth-child(1) {
  font-size: 1.5rem;
}

.upgrade-header > :nth-child(2) {
  flex: 1;
}

.upgrade-close {
  background: transparent;
  border: none;
  color: #a0a0b8;
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.15s;
}

.upgrade-close:hover {
  background: rgba(233, 69, 96, 0.2);
  color: white;
}

.upgrade-info {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #c0c0d8;
}

.upgrade-info > div {
  background: #16213e;
  padding: 6px;
  border-radius: 4px;
  text-align: center;
}

.upgrade-info span {
  display: block;
  color: #e94560;
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 2px;
}

.upgrade-actions {
  display: flex;
  gap: 8px;
}

.upgrade-actions .btn {
  flex: 1;
}

/* Footer info */
.footer-info {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  color: #a0a0b8;
  text-align: center;
  margin-bottom: 16px;
}

/* Toast notifications */
.toast {
  position: fixed;
  top: 100px;
  right: 20px;
  background: #1a1a2e;
  border: 2px solid #e94560;
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  box-shadow: 0 0 20px rgba(233, 69, 96, 0.4);
  z-index: 100;
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.5s forwards;
  max-width: 280px;
  font-size: 0.9rem;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px); }
}

/* Mobile responsive */
@media (max-width: 900px) {
  .game-area {
    grid-template-columns: 1fr;
  }

  .map-wrap {
    max-width: 100%;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-section {
    flex: 1 1 200px;
  }
}

@media (max-width: 600px) {
  .hud-cell {
    min-width: 70px;
    padding: 8px 10px;
  }

  .hud-value {
    font-size: 1.1rem;
  }

  .upgrade-panel {
    left: 10px;
    right: 10px;
    transform: none;
    bottom: 10px;
  }

  .upgrade-card {
    min-width: 0;
  }
}
