/* Blue Fox Games · Milky Way Defense (Defesa da Via Láctea)
 * Estilos da interface de combate espacial, HUD futurista e cockpit
 */
:root {
  --space-bg: #030814;
  --hud-cyan: #38b6ff;
  --hud-violet: #8b5cf6;
  --hud-amber: #f59e0b;
  --hud-danger: #ef4444;
  --hud-glass: rgba(11, 19, 43, 0.85);
  --hud-border: rgba(56, 182, 255, 0.25);
  --hud-glow: 0 0 16px rgba(56, 182, 255, 0.4);
}

* {
  box-sizing: border-box;
}

body.defense-page {
  margin: 0;
  padding: 0;
  background-color: var(--space-bg);
  color: #fff;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.defense-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header de Navegação ---------- */
.defense-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px clamp(16px, 3vw, 36px);
  background: rgba(3, 8, 20, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hud-border);
  z-index: 20;
}
.defense-nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.defense-back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: color 0.2s, transform 0.2s;
}
.defense-back-link:hover {
  color: #fff;
  transform: translateX(-2px);
}
.defense-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #fff 40%, var(--hud-cyan) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.defense-nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.defense-icon-btn {
  background: rgba(28, 37, 65, 0.7);
  border: 1px solid var(--hud-border);
  color: #fff;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.defense-icon-btn:hover {
  background: var(--hud-violet);
  border-color: var(--hud-cyan);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.4);
}

/* ---------- Container Principal do Jogo ---------- */
.game-viewport-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 10px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* HUD Superior (Cockpit) */
.cockpit-hud-top {
  width: 100%;
  max-width: 820px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  margin-bottom: 8px;
  background: var(--hud-glass);
  border: 1px solid var(--hud-border);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  gap: 12px;
  flex-wrap: wrap;
}

.hud-item {
  display: flex;
  flex-direction: column;
}
.hud-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hud-value {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
}
.hud-value.highlight {
  color: var(--hud-cyan);
  text-shadow: 0 0 8px rgba(56, 182, 255, 0.6);
}
.hud-lives {
  display: flex;
  gap: 4px;
  font-size: 1.1rem;
}

.hud-shields-bar {
  width: 100px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.hud-shields-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--hud-cyan), var(--hud-violet));
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Área do Canvas */
.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 820px;
  aspect-ratio: 4 / 3;
  max-height: calc(100vh - 180px);
  background: #000;
  border: 2px solid var(--hud-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 0 35px rgba(56, 182, 255, 0.25);
}

canvas#defenseCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

/* ---------- Overlays de Tela ---------- */
.overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(3, 8, 20, 0.92);
  backdrop-filter: blur(10px);
  z-index: 15;
  text-align: center;
  transition: opacity 0.3s ease;
}
.overlay-screen[hidden] {
  display: none;
}

/* Intro Crawl (História Estelar) */
/* Intro Crawl (História Estelar) */
.crawl-container {
  perspective: 500px;
  height: 75%;
  width: 95%;
  max-width: 760px;
  overflow: hidden;
  position: relative;
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 1) 45%, rgba(0, 0, 0, 0) 100%);
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 1) 45%, rgba(0, 0, 0, 0) 100%);
}
.crawl-content {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  transform-origin: 50% 100%;
  transform: rotateX(16deg);
  animation: crawlAnimation 42s linear infinite;
  text-align: center;
}
@keyframes crawlAnimation {
  0% {
    top: 100%;
  }
  100% {
    top: -190%;
  }
}
.crawl-title {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 900;
  color: var(--hud-amber);
  margin-bottom: 12px;
  letter-spacing: 0.12em;
  text-shadow: 0 0 24px rgba(245, 158, 11, 0.7);
}
.crawl-stardate {
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  color: var(--hud-cyan);
  font-weight: 800;
  letter-spacing: 0.14em;
  margin-bottom: 28px;
  text-shadow: 0 0 12px rgba(56, 182, 255, 0.6);
}
.crawl-text {
  font-size: clamp(1.25rem, 2.6vw, 1.55rem);
  line-height: 1.8;
  color: #f8fafc;
  margin: 16px 0;
  font-weight: 700;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95);
}

.crawl-controls {
  margin-top: 18px;
  display: flex;
  gap: 12px;
}

/* Briefing da Fase (Rápido e direto) */
.briefing-box {
  max-width: 520px;
  width: 100%;
  background: var(--hud-glass);
  border: 1px solid var(--hud-border);
  border-radius: 18px;
  padding: 18px 22px;
  box-shadow: 0 0 30px rgba(56, 182, 255, 0.2);
  text-align: left;
}
.briefing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.briefing-badge {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(56, 182, 255, 0.2);
  color: var(--hud-cyan);
  border: 1px solid rgba(56, 182, 255, 0.4);
}
.briefing-coords {
  font-size: 0.8rem;
  color: #94a3b8;
  font-family: monospace;
}
.briefing-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 4px 0;
  color: #fff;
}
.briefing-codename {
  font-size: 0.85rem;
  color: var(--hud-amber);
  margin-bottom: 10px;
  font-weight: 600;
}
.briefing-text {
  font-size: 0.95rem;
  line-height: 1.45;
  color: #e2e8f0;
  margin-bottom: 10px;
  font-weight: 500;
}
.briefing-pilot-quote {
  background: rgba(56, 182, 255, 0.08);
  border-left: 3px solid var(--hud-cyan);
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
  font-style: italic;
  font-size: 0.82rem;
  color: #bae6fd;
  margin-bottom: 14px;
}
.briefing-reward-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.35);
  padding: 8px 12px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.reward-icon {
  font-size: 1.6rem;
}
.reward-info h4 {
  margin: 0;
  font-size: 0.88rem;
  color: #c4b5fd;
}
.reward-info p {
  margin: 2px 0 0 0;
  font-size: 0.78rem;
  color: #cbd5e1;
}

/* Seletor de Fases do Sistema Solar (Mapa de Fases) */
.solar-map-container {
  width: 100%;
  max-width: 760px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 16px 8px;
}
.solar-stages-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.stage-solar-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  position: relative;
}
.stage-solar-card:not(.locked):hover {
  transform: translateY(-2px);
  border-color: var(--hud-cyan);
  box-shadow: 0 6px 18px rgba(56, 182, 255, 0.25);
}
.stage-solar-card.active {
  border-color: var(--hud-cyan);
  background: rgba(56, 182, 255, 0.12);
}
.stage-solar-card.locked {
  opacity: 0.45;
  filter: grayscale(0.6);
  cursor: not-allowed;
}
.stage-solar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.stage-solar-num {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--hud-cyan);
}
.stage-solar-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}
.stage-solar-codename {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* Botões de Ação */
.btn-defense-primary {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  padding: 12px 28px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--hud-cyan), var(--hud-violet));
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(56, 182, 255, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-defense-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.6);
}
.btn-defense-secondary {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: 12px;
  background: rgba(28, 37, 65, 0.8);
  color: #e2e8f0;
  border: 1px solid var(--hud-border);
  cursor: pointer;
  transition: background 0.2s;
}
.btn-defense-secondary:hover {
  background: rgba(56, 182, 255, 0.2);
  color: #fff;
}

/* ---------- Barra Inferior de Upgrades Ativos ---------- */
.cockpit-upgrades-bar {
  width: 100%;
  max-width: 820px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  margin-top: 8px;
  background: var(--hud-glass);
  border: 1px solid var(--hud-border);
  border-radius: 14px;
  font-size: 0.82rem;
  color: #94a3b8;
  flex-wrap: wrap;
  gap: 8px;
}
.active-upgrades-list {
  display: flex;
  gap: 8px;
}
.upgrade-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(56, 182, 255, 0.15);
  border: 1px solid rgba(56, 182, 255, 0.35);
  color: #e0f2fe;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ---------- Controles Virtuais Touch (Mobile) ---------- */
.touch-controls {
  display: none;
  width: 100%;
  max-width: 820px;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-top: 8px;
  gap: 16px;
}
@media (max-width: 850px), (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}
.touch-dpad {
  display: flex;
  gap: 12px;
}
.touch-actions {
  display: flex;
  gap: 12px;
}
.touch-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid var(--hud-border);
  color: #fff;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}
.touch-btn:active {
  background: var(--hud-cyan);
  color: #030814;
  transform: scale(0.92);
}
.touch-btn.fire {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.6);
  width: 70px;
  height: 70px;
  font-size: 1.6rem;
}
.touch-btn.fire:active {
  background: var(--hud-danger);
  color: #fff;
}
.touch-btn.bomb {
  background: rgba(245, 158, 11, 0.25);
  border-color: rgba(245, 158, 11, 0.6);
}
.touch-btn.bomb:active {
  background: var(--hud-amber);
}
