/* Cat Defense Game - CSS Stylesheet */

:root {
  --font-family: 'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --bg-dark: #121826;
  --bg-panel: rgba(20, 28, 45, 0.92);
  --primary-gold: #ffb800;
  --primary-orange: #ff7700;
  --primary-green: #2ecc71;
  --primary-red: #e74c3c;
  --primary-blue: #3498db;
  --text-light: #ffffff;
  --text-muted: #a0aec0;
  --shadow-heavy: 0 12px 36px rgba(0, 0, 0, 0.6);
  --border-radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-dark);
  color: var(--text-light);
  font-family: var(--font-family);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Global Hidden Class */
.hidden {
  display: none !important;
}

/* Main Container maintaining 16:9 Aspect Ratio */
#game-container {
  position: relative;
  width: 100vw;
  height: 56.25vw; /* 16:9 ratio */
  max-width: 177.78vh;
  max-height: 100vh;
  box-shadow: var(--shadow-heavy);
  border-radius: 8px;
  overflow: hidden;
  background-color: #000;
}

/* Canvas */
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  cursor: pointer;
}

/* Loading Overlay */
#loading-screen {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #1a202c, #0d1117);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.5s ease;
}

.loader-logo {
  max-width: 280px;
  margin-bottom: 24px;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.progress-bar-container {
  width: 340px;
  height: 24px;
  background-color: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--primary-gold);
  border-radius: 12px;
  overflow: hidden;
  padding: 3px;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ff7700, #ffb800);
  border-radius: 8px;
  transition: width 0.2s ease-out;
}

.loading-text {
  margin-top: 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-gold);
  letter-spacing: 1px;
}

/* UI Overlay Layer */
#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

/* HUD Header */
.hud-header {
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.stat-group {
  display: flex;
  gap: 16px;
  align-items: center;
  pointer-events: auto;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-panel);
  border: 2px solid rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.stat-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.castle-hp-bar {
  width: 180px;
  height: 16px;
  background: rgba(0,0,0,0.5);
  border: 2px solid #fff;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.castle-hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #e74c3c, #2ecc71);
  transition: width 0.3s ease;
}

/* Controls Top Right */
.hud-controls {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.btn-icon {
  width: 44px;
  height: 44px;
  background: var(--bg-panel);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  font-weight: bold;
  font-size: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  pointer-events: auto;
  transition: transform 0.15s ease, background-color 0.2s ease;
}

.btn-icon:hover {
  transform: scale(1.1);
  background: var(--primary-orange);
}

.btn-icon:active {
  transform: scale(0.95);
}

/* Bottom Deploy Bar (Cat Summon Cards) */
.deploy-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  background: var(--bg-panel);
  padding: 8px 16px;
  border-radius: 16px;
  border: 2px solid rgba(255, 184, 0, 0.4);
  box-shadow: var(--shadow-heavy);
  pointer-events: auto;
}

.cat-card {
  position: relative;
  width: 72px;
  height: 90px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
}

.cat-card:hover:not(.disabled) {
  transform: translateY(-6px);
  border-color: var(--primary-gold);
  background: rgba(255, 184, 0, 0.15);
}

.cat-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(80%);
}

.cat-card.active {
  border-color: var(--primary-green);
  box-shadow: 0 0 12px var(--primary-green);
}

.cat-card-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  pointer-events: none;
}

.cat-card-cost {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-gold);
  pointer-events: none;
}

.cat-card-cooldown {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  font-weight: bold;
  color: var(--primary-gold);
  pointer-events: none;
}

/* Modals (Menu, Shop, Win, Lose, Level Select) */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 500;
  pointer-events: auto;
}

.modal-content {
  background: #1a2336;
  border: 3px solid var(--primary-gold);
  border-radius: 20px;
  padding: 28px 36px;
  width: 90%;
  max-width: 680px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8);
  position: relative;
  pointer-events: auto;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-size: 32px;
  font-weight: 900;
  color: var(--primary-gold);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* Level Map Grid */
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin: 24px 0;
  pointer-events: auto;
}

.level-card {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  padding: 16px 8px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.level-card:hover:not(.locked) {
  transform: translateY(-4px);
  border-color: var(--primary-gold);
  background: rgba(255, 184, 0, 0.15);
}

.level-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(100%);
}

.level-number {
  font-size: 24px;
  font-weight: 900;
  color: var(--text-light);
}

/* Shop Upgrades List */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 20px 0;
  pointer-events: auto;
}

.shop-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shop-item-info {
  text-align: left;
}

.shop-item-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary-gold);
}

.shop-item-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* Common Action Buttons */
.btn-primary {
  background: linear-gradient(180deg, #ff9d00 0%, #e65c00 100%);
  border: 2px solid #ffca68;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  padding: 12px 32px;
  border-radius: 24px;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 6px 16px rgba(230, 92, 0, 0.4);
  transition: transform 0.15s ease, filter 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 10px 24px;
  border-radius: 20px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.25);
}
