/* ===== GRAVITY PULSE — CARTOON THEME ===== */
/* Theme: Playful Cartoon — Bold Borders & 3D Shadows */

/* ── Tokens ── */
:root {
  --bg: #1A237E;
  --surface: #F5E6D0;
  --surface-container: #F5E6D0;
  --surface-high: #EDD8BF;
  --primary: #FF5722;
  --secondary: #FF9800;
  --tertiary: #FF5722;
  --on-surface: #3E2723;
  --on-surface-light: #5D4037;
  --outline: #8D6E63;
  --success: #4CAF50;
  --danger: #F44336;
  --border: #8D6E63;
  --shadow-hard: #5D4037;

  --font-display: 'Nunito', sans-serif;
  --font-body: 'Nunito', sans-serif;
}

/* ── Reset ── */
*, *::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;
}

/* ── Cartoon Background ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 40%, rgba(255, 152, 0, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 75% 25%, rgba(255, 87, 34, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(245, 230, 208, 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-container);
  border-bottom: 3px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 4px 0 var(--shadow-hard);
  position: relative;
  z-index: 10;
}

.btn-back {
  color: var(--on-surface);
  text-decoration: none;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.4rem 0.8rem;
  border: 3px solid var(--border);
  border-radius: 16px;
  background: #fff;
  white-space: nowrap;
  transition: all 0.2s;
  box-shadow: 0 3px 0 var(--shadow-hard);
}

.btn-back:hover {
  background: var(--surface-high);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--shadow-hard);
}

.btn-back:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--shadow-hard);
}

.game-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow:
    2px 2px 0 var(--shadow-hard),
    -1px -1px 0 rgba(255, 255, 255, 0.3);
}

.stats {
  display: flex;
  gap: 0.8rem;
  align-items: center;
}

.score-box {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--on-surface);
  background: #fff;
  padding: 0.25rem 0.6rem;
  border-radius: 16px;
  border: 3px solid var(--border);
  box-shadow: 0 3px 0 var(--shadow-hard);
}

.score-box.best {
  border-color: var(--primary);
  background: #FFF3E0;
  box-shadow: 0 3px 0 #BF360C;
}

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

.score-value {
  font-weight: 800;
  min-width: 1.5rem;
  text-align: center;
}

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

/* ── Game Container ── */
.game-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#pixi-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

#pixi-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* ── Modal Overlay ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(26, 35, 126, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

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

.modal {
  text-align: center;
  padding: 2.5rem 2rem;
  background: var(--surface);
  border: 3px solid var(--border);
  border-radius: 20px;
  box-shadow:
    0 6px 0 var(--shadow-hard),
    0 12px 24px rgba(0, 0, 0, 0.3);
  max-width: 90vw;
  width: 400px;
  animation: modalIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}

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

.modal-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(2px 2px 0 var(--shadow-hard));
}

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

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

.overlay-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 1rem;
  text-shadow: 2px 2px 0 var(--shadow-hard);
}

.neon-score {
  min-height: 0;
}

/* ── Buttons ── */
.btn {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1rem;
  padding: 0.7rem 2rem;
  border: 3px solid var(--shadow-hard);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: inline-block;
}

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

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #BF360C;
  background: #FF6E40;
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #BF360C;
}

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

.btn-whatsapp:hover {
  background: #2EE072;
  transform: translateY(-1px);
  box-shadow: 0 5px 0 #1B9E4B;
}

.btn-whatsapp:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #1B9E4B;
}

/* ── Game Controls (DOM buttons) ── */
.game-controls {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  gap: 12px;
}

.ctrl-game-btn {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.6rem 1.8rem;
  border: 3px solid;
  border-radius: 16px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: all 0.15s;
  color: #fff;
}

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

.ctrl-play:hover {
  background: #FF6E40;
  transform: translateY(-1px);
  box-shadow: 0 5px 0 #BF360C;
}

.ctrl-play:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #BF360C;
}

.ctrl-reset {
  background: var(--danger);
  border-color: #B71C1C;
  box-shadow: 0 4px 0 #B71C1C;
}

.ctrl-reset:hover {
  background: #EF5350;
  transform: translateY(-1px);
  box-shadow: 0 5px 0 #B71C1C;
}

.ctrl-reset:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #B71C1C;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .topbar {
    padding: 0.4rem 0.6rem;
  }

  .game-title {
    font-size: 1.1rem;
    letter-spacing: 0.04em;
  }

  .btn-back {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }

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

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

  .modal {
    padding: 1.8rem 1.2rem;
    width: 340px;
  }

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

  .modal-subtitle {
    font-size: 0.85rem;
  }
}

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

  .stats {
    gap: 0.4rem;
  }
}
