/* ===== TORRE BRASIL — TOWER DEFENSE (Cartoon Theme) ===== */

:root {
  --bg: #03A9F4;
  --surface: #F5E6D0;
  --surface-container: #EDE0CC;
  --surface-high: #E8D8C0;
  --primary: #FF5722;
  --primary-dim: #E64A19;
  --secondary: #FFC107;
  --tertiary: #E74C3C;
  --accent-gold: #FF8F00;
  --on-surface: #3E2723;
  --on-surface-light: #5D4037;
  --outline: #8D6E63;
  --border-thick: 3px solid #8D6E63;
  --shadow-bottom: 0 4px 0 #5D4037;
  --font-display: 'Nunito', sans-serif;
  --font-body: 'Nunito', sans-serif;
  --font-ui: 'Nunito', sans-serif;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-body);
  font-weight: 700;
  background: var(--bg);
  color: var(--on-surface);
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
  user-select: none;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgba(255,255,255,0.12) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* ── Top Bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.8rem;
  background: var(--surface);
  border-bottom: var(--border-thick);
  box-shadow: var(--shadow-bottom);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.btn-back {
  color: var(--primary);
  text-decoration: none;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-xs);
  transition: background 0.2s;
}
.btn-back:hover { background: rgba(255, 87, 34, 0.12); }

.game-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(0.85rem, 2.5vw, 1.15rem);
  color: var(--primary);
  text-shadow: 2px 2px 0 #5D4037, 0 0 0 transparent;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.stats {
  display: flex;
  gap: 0.6rem;
}

.score-box {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-container);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-xs);
  border: var(--border-thick);
  box-shadow: 0 2px 0 #5D4037;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1rem;
}

.score-icon { font-size: 0.9rem; }
.score-value { color: var(--accent-gold); font-size: 1.1rem; font-weight: 800; }

/* ── Game Container ── */
.game-container {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
}

#game-canvas {
  flex: 1;
  width: 100%;
  display: block;
  image-rendering: pixelated;
}

/* ── Tower Panel (bottom) ── */
.tower-panel {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--surface);
  border-top: var(--border-thick);
  box-shadow: 0 -3px 0 #5D4037;
  flex-shrink: 0;
  z-index: 5;
}

.tower-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 3px solid #8D6E63;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--surface-container);
  box-shadow: 0 3px 0 #5D4037;
  min-width: 48px;
}

.tower-option:hover,
.tower-option.selected {
  border-color: var(--primary);
  background: #FFE0B2;
  transform: translateY(-3px);
  box-shadow: 0 5px 0 #5D4037;
}

.tower-option:active {
  transform: translateY(0);
  box-shadow: 0 1px 0 #5D4037;
}

.tower-option.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.tower-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #5D4037;
  box-shadow: 0 2px 0 #3E2723;
}

.tucano-icon { background: linear-gradient(135deg, #FFB300, #FF6F00); }
.arara-icon { background: linear-gradient(135deg, #EF5350, #42A5F5); }
.onca-icon { background: linear-gradient(135deg, #FFD54F, #FF8F00); }
.jacare-icon { background: linear-gradient(135deg, #66BB6A, #2E7D32); }
.capivara-icon { background: linear-gradient(135deg, #A1887F, #6D4C41); }
.sucuri-icon { background: linear-gradient(135deg, #4CAF50, #1B5E20); }

.tower-cost {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--accent-gold);
  text-shadow: 1px 1px 0 #5D4037;
}

/* ── Tower Info (upgrade/sell) ── */
.tower-info {
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.8rem;
  background: var(--surface);
  border: 3px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: 0 4px 0 #5D4037, 0 8px 20px rgba(0,0,0,0.15);
  z-index: 6;
}

.info-name {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--primary);
}

.info-level {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--secondary);
}

.btn-action {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0.3rem 0.6rem;
  border: 3px solid var(--outline);
  border-radius: var(--radius-xs);
  cursor: pointer;
  background: var(--surface-container);
  color: var(--on-surface);
  box-shadow: 0 2px 0 #5D4037;
  transition: all 0.15s;
}

.btn-action:active {
  transform: translateY(2px);
  box-shadow: none;
}

.btn-upgrade { border-color: #4CAF50; color: #2E7D32; background: #C8E6C9; }
.btn-upgrade:hover { background: #A5D6A7; }
.btn-sell { border-color: #FFC107; color: #FF8F00; background: #FFF8E1; }
.btn-sell:hover { background: #FFECB3; }
.btn-close { border-color: var(--tertiary); color: var(--tertiary); background: #FFCDD2; }
.btn-close:hover { background: #EF9A9A; }

/* ── Modal Overlay ── */
.modal-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 50;
  backdrop-filter: blur(6px);
}

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

.glass-modal {
  background: var(--surface);
  border: 4px solid #8D6E63;
  border-radius: 20px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow:
    0 6px 0 #5D4037,
    0 20px 50px rgba(0, 0, 0, 0.25);
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.modal-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  color: var(--primary);
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 0 #5D4037;
  letter-spacing: 0.5px;
}

.modal-subtitle {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--on-surface-light);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.overlay-score {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--accent-gold);
  text-shadow: 1px 1px 0 #5D4037;
  margin-bottom: 1rem;
}

.btn {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1.2rem;
  padding: 0.7rem 2rem;
  border: 3px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: var(--primary);
  border-color: #BF360C;
  color: #fff;
  box-shadow: 0 4px 0 #BF360C;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #BF360C;
}
.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #BF360C;
}

.btn-whatsapp {
  background: #25d366;
  border-color: #128C7E;
  color: #fff;
  box-shadow: 0 4px 0 #128C7E;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}
.btn-whatsapp:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #128C7E;
}
.btn-whatsapp:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #128C7E;
}

/* ── Game Info Section ── */
.game-info {
  display: none;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .topbar { padding: 0.3rem 0.5rem; }
  .game-title { font-size: 0.7rem; }
  .score-box { padding: 0.2rem 0.35rem; font-size: 0.85rem; }
  .score-value { font-size: 0.9rem; }
  .tower-panel { gap: 0.2rem; padding: 0.3rem; }
  .tower-option { padding: 0.2rem 0.35rem; min-width: 40px; }
  .tower-icon { width: 24px; height: 24px; }
  .tower-cost { font-size: 0.75rem; }
  .tower-info { bottom: 60px; gap: 0.3rem; padding: 0.4rem 0.5rem; }
  .btn-action { font-size: 0.8rem; padding: 0.2rem 0.4rem; }
}

@media (max-width: 360px) {
  .stats { gap: 0.3rem; }
  .btn-back { font-size: 0.9rem; padding: 0.2rem 0.4rem; }
}

@media (min-width: 769px) {
  .game-info {
    display: block;
    max-width: 800px;
    margin: 1rem auto;
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: var(--border-thick);
    box-shadow: var(--shadow-bottom);
  }
  .game-info h2 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 0.8rem;
    text-shadow: 1px 1px 0 #5D4037;
  }
  .game-info p, .game-info li {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--on-surface);
    font-weight: 700;
  }
  .game-info ul {
    padding-left: 1.2rem;
    margin-top: 0.5rem;
  }
  .game-info li { margin-bottom: 0.3rem; }

  html, body { overflow: auto; }
}
