/* ===== DUNGEON CRAWLER — CARTOON THEME ===== */

:root {
  --bg: #37474F;
  --surface: #F5E6D0;
  --surface-container: #EDE0CC;
  --surface-high: #E8D8C0;
  --primary: #FF5722;
  --secondary: #8D6E63;
  --tertiary: #E53935;
  --accent-gold: #FFB300;
  --on-surface: #3E2723;
  --on-surface-light: #5D4037;
  --outline: #8D6E63;
  --border-shadow: #5D4037;
  --font-display: 'Nunito', sans-serif;
  --font-body: 'Nunito', sans-serif;
}

*, *::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 30% 20%, rgba(255, 87, 34, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(141, 110, 99, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Top Bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 3px solid var(--outline);
  box-shadow: 0 4px 0 var(--border-shadow);
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

.btn-back {
  color: var(--on-surface);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0.3rem 0.6rem;
  border-radius: 12px;
  border: 2px solid var(--outline);
  background: var(--surface-high);
  transition: background 0.2s, transform 0.15s;
}

.btn-back:hover {
  background: #D7CDB8;
  transform: translateY(-1px);
}

.game-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  text-shadow: 2px 2px 0 var(--border-shadow);
  letter-spacing: 1px;
}

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

.score-box {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-container);
  border: 3px solid var(--outline);
  border-radius: 16px;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 3px 0 var(--border-shadow);
}

.score-box.best {
  border-color: var(--accent-gold);
  box-shadow: 0 3px 0 #C68400;
}

.score-icon {
  font-size: 1rem;
}

.score-value {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--on-surface);
}

.neon-text {
  color: var(--primary);
  text-shadow: 1px 1px 0 var(--border-shadow);
}

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

#pixi-container {
  flex: 1;
  width: 100%;
  position: relative;
}

#pixi-container canvas {
  display: block;
}

/* ── Mobile Controls ── */
.mobile-controls {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.8rem 1.2rem 1.2rem;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 20;
  pointer-events: none;
  background: linear-gradient(transparent, rgba(55, 71, 79, 0.9) 30%);
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 4px;
  pointer-events: auto;
}

.dpad-btn {
  background: var(--surface);
  border: 3px solid var(--outline);
  border-radius: 14px;
  color: var(--on-surface);
  font-size: 1.2rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s, transform 0.1s;
  box-shadow: 0 3px 0 var(--border-shadow);
}

.dpad-btn:active {
  background: var(--surface-high);
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--border-shadow);
}

.dpad-center {
  background: transparent;
  border: none;
  pointer-events: none;
  box-shadow: none;
}

.attack-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #BF360C;
  color: white;
  font-size: 1.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 0 #BF360C, 0 6px 12px rgba(0, 0, 0, 0.3);
  transition: background 0.1s, transform 0.1s, box-shadow 0.1s;
}

.attack-btn:active {
  background: #E64A19;
  transform: translateY(3px);
  box-shadow: 0 1px 0 #BF360C;
}

/* ── Modal Overlay ── */
.modal-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity 0.3s;
}

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

.glass-overlay {
  background: rgba(55, 71, 79, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.glass-modal {
  background: var(--surface);
  border: 3px solid var(--outline);
  border-radius: 20px;
  padding: 2rem 2.5rem;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow:
    0 4px 0 var(--border-shadow),
    0 8px 24px rgba(0, 0, 0, 0.35);
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  text-shadow: 2px 2px 0 var(--border-shadow);
  margin-bottom: 0.5rem;
  letter-spacing: 1px;
}

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

.overlay-score {
  margin-bottom: 1rem;
}

.neon-score {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent-gold);
  text-shadow: 1px 1px 0 #C68400;
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 0.7rem 2rem;
  border: 3px solid transparent;
  border-radius: 16px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
}

.btn:active {
  transform: translateY(3px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: #BF360C;
  box-shadow: 0 4px 0 #BF360C;
}

.btn-primary:hover {
  background: #F4511E;
  box-shadow: 0 4px 0 #BF360C, 0 6px 12px rgba(255, 87, 34, 0.3);
}

.btn-primary:active {
  box-shadow: 0 1px 0 #BF360C;
}

.btn-whatsapp {
  background: #25d366;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0.5rem 1.5rem;
  border-color: #1DA851;
  box-shadow: 0 4px 0 #1DA851;
}

.btn-whatsapp:active {
  box-shadow: 0 1px 0 #1DA851;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .mobile-controls {
    display: flex;
  }

  .topbar {
    padding: 0.4rem 0.6rem;
  }

  .game-title {
    font-size: 1.1rem;
  }

  .score-box {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
  }

  .score-value {
    font-size: 0.95rem;
  }

  #pixi-container {
    flex: 1;
  }
}

@media (max-width: 400px) {
  .game-title {
    font-size: 0.95rem;
  }

  .btn-back {
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
  }

  .dpad {
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(3, 46px);
  }

  .attack-btn {
    width: 62px;
    height: 62px;
    font-size: 1.5rem;
  }

  .glass-modal {
    padding: 1.5rem;
  }

  .modal-title {
    font-size: 1.6rem;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .topbar {
    padding: 0.2rem 0.6rem;
  }

  .game-title {
    font-size: 1rem;
  }

  .mobile-controls {
    padding: 0.4rem 0.8rem 0.6rem;
  }

  .dpad {
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 40px);
  }

  .attack-btn {
    width: 56px;
    height: 56px;
    font-size: 1.3rem;
  }
}
