/* ============================================================
   Pup Patrol: Dogs vs Aliens — styles
   ============================================================ */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  background: #6fb86f;
  font-family: -apple-system, BlinkMacSystemFont, "Avenir Next", sans-serif;
  color: #2d2438;
}
canvas#game {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ============ HUD ============ */
.hud {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 12px;
  display: flex;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
  padding-top: 12px;
}
.hud-pill {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  padding: 8px 14px 8px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(40, 40, 60, 0.2);
  font-weight: 800;
  font-size: 20px;
  color: #2d2438;
  min-height: 40px;
}
.pill-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.coin-icon  { background: linear-gradient(135deg, #ffe06b, #f4b53a); }
.dog-icon   { background: linear-gradient(135deg, #f4b88a, #d49566); }
.heart-icon { background: linear-gradient(135deg, #ff9aa8, #ef6b80); }

/* Quest pill — shows current area / level / progress */
.quest {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(45, 36, 56, 0.85);
  color: white;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 10;
  margin-top: 12px;
  white-space: nowrap;
  pointer-events: none;
}

/* ============ UPGRADES ============ */
.upgrades {
  position: absolute;
  bottom: env(safe-area-inset-bottom, 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 10;
  padding-bottom: 12px;
}
.upgrade-btn {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(40, 40, 60, 0.2);
  font-weight: 700;
  font-size: 13px;
  color: #2d2438;
  min-width: 92px;
  transition: transform 0.12s ease, opacity 0.2s ease;
}
.upgrade-btn:active { transform: scale(0.95); }
.upgrade-btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.upgrade-emoji { font-size: 26px; line-height: 1; }
.upgrade-cost {
  background: #f4b53a;
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
}
.upgrade-cost::before { content: '🪙'; font-size: 11px; }

/* ============ OVERLAY (used for all full-screen screens) ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  transition: opacity 0.4s ease;
  overflow-y: auto;
}
.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Default backgrounds. Start screen gets a sky-to-sand gradient;
   the others sit on a blurred-dark backdrop so the canvas peeks through. */
#start-screen {
  background: linear-gradient(180deg, #b3e0ff 0%, #ffd9a3 100%);
}
#level-screen, #level-select-screen, #unlock-screen, #win-screen {
  background: rgba(45, 36, 56, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
}
#level-screen.show, #level-select-screen.show,
#unlock-screen.show, #win-screen.show { display: flex; }

/* ============ MENU CARD ============ */
.menu-card {
  background: white;
  border-radius: 28px;
  padding: 28px 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.menu-card.wide {
  max-width: 560px;
}
.menu-card h1 {
  font-size: clamp(36px, 7vw, 52px);
  font-weight: 900;
  margin: 0;
  color: #2d2438;
  letter-spacing: -0.02em;
  text-shadow: 2px 2px 0 #ffd76b;
}
.menu-card h2 {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 900;
  margin: 0 0 6px;
  color: #2d2438;
}
.menu-card .sub {
  font-size: clamp(16px, 2.4vw, 20px);
  font-weight: 700;
  color: #5a4a6e;
  margin: 4px 0 18px;
}

/* ============ DOG PICKER (8 dog grid) ============ */
.dog-picker-label {
  font-weight: 800;
  font-size: 18px;
  color: #2d2438;
  margin: 6px 0 10px;
}
.dog-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0 0 8px;
}
.dog-slot {
  position: relative;
  aspect-ratio: 1;
  border: 3px solid transparent;
  border-radius: 16px;
  background: #f3eef7;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  overflow: hidden;
  /* Each slot is at least 64x64 even at narrow widths */
  min-width: 64px;
  min-height: 64px;
}
.dog-slot:active { transform: scale(0.93); }
.dog-slot.selected {
  border-color: #f29849;
  background: #fff4e0;
  box-shadow: 0 4px 14px rgba(242, 152, 73, 0.4);
}
.dog-slot.locked {
  background: #ddd5e3;
  cursor: not-allowed;
}
.dog-slot canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.dog-slot .lock {
  position: absolute;
  inset: 0;
  background: rgba(45, 36, 56, 0.55);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  padding: 4px;
  line-height: 1.1;
}
.dog-slot .lock .lock-icon { font-size: 22px; }
.dog-selected-name {
  font-size: 22px;
  font-weight: 900;
  color: #2d2438;
  margin: 4px 0 14px;
  min-height: 28px;
}

/* ============ START BUTTONS ============ */
.start-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.start-actions .big-btn { min-width: 240px; }
.big-btn {
  background: linear-gradient(135deg, #ffd76b, #f29849);
  color: white;
  border: none;
  font-size: clamp(20px, 3vw, 24px);
  font-weight: 800;
  padding: 16px 36px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(242, 152, 73, 0.5),
              inset 0 2px 3px rgba(255, 255, 255, 0.4);
  transition: transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.big-btn:active { transform: scale(0.95); }

/* Secondary (muted) button */
.btn-secondary {
  background: #e6e1ea;
  color: #2d2438;
  border: none;
  font-size: 18px;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active {
  transform: scale(0.95);
  background: #d8d2dd;
}
.back-to-arcade { margin-top: 6px; }

/* ============ STATS (fun counters on menu) ============ */
.stats {
  font-size: 14px;
  color: #7a6e87;
  font-weight: 700;
  margin: 8px 0 12px;
  line-height: 1.5;
}
.stats .stat-num {
  color: #f29849;
  font-size: 16px;
  font-weight: 900;
}

/* ============ LEVEL SELECT ============ */
.level-select {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 14px 0 18px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px;
}
.area-block {
  background: #f3eef7;
  border-radius: 18px;
  padding: 12px;
}
.area-block.locked {
  opacity: 0.6;
}
.area-name {
  font-size: 18px;
  font-weight: 900;
  color: #2d2438;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.area-color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}
.level-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.level-btn {
  aspect-ratio: 1;
  min-width: 56px;
  min-height: 56px;
  border: none;
  border-radius: 14px;
  font-size: 22px;
  font-weight: 900;
  color: white;
  background: linear-gradient(135deg, #ffd76b, #f29849);
  cursor: pointer;
  transition: transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 12px rgba(242, 152, 73, 0.35);
}
.level-btn:active { transform: scale(0.92); }
.level-btn.locked {
  background: #c8bfd0;
  color: #8a7e9a;
  cursor: not-allowed;
  box-shadow: none;
}
.level-btn.boss {
  background: linear-gradient(135deg, #ff8aa3, #e94c75);
  box-shadow: 0 4px 12px rgba(233, 76, 117, 0.4);
}
.level-btn.boss.locked {
  background: #c8bfd0;
  color: #8a7e9a;
  box-shadow: none;
}

/* ============ UNLOCK / WIN PORTRAITS ============ */
.win-card {
  background: white;
  border-radius: 28px;
  padding: 28px 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.win-card h2 {
  font-size: 28px;
  margin: 8px 0;
  color: #2d2438;
}
.win-card p {
  color: #5a4a6e;
  font-weight: 600;
  margin: 0 0 16px;
}
.win-card .big-btn,
.win-card .btn-secondary {
  display: block;
  width: 100%;
  margin: 8px 0 0;
}
.confetti-row { font-size: 36px; }
#unlock-portrait, #win-portrait {
  width: 180px;
  height: 180px;
  background: #fff4e0;
  border-radius: 24px;
  margin: 10px auto;
  display: block;
  box-shadow: inset 0 0 0 4px #ffd76b;
}
.unlock-name {
  font-size: 26px;
  font-weight: 900;
  color: #2d2438;
  margin: 6px 0 6px;
}

/* ============ TOAST ============ */
.toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: white;
  border-radius: 20px;
  padding: 14px 24px;
  font-weight: 700;
  font-size: 18px;
  color: #2d2438;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ============ NAV BAR ============ */
.nav-bar {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  right: 12px;
  display: flex;
  gap: 12px;
  z-index: 11;
  padding-top: 12px;
}
.nav-bar.hidden { display: none; }
.nav-btn {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.92);
  border: none;
  border-radius: 50%;
  font-size: 28px;
  color: #2d2438;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(40, 40, 60, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn:active { transform: scale(0.9); }

/* ============ CONFIRM DIALOG ============ */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(45, 36, 56, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.confirm-backdrop.show { display: flex; }
.confirm-card {
  background: white;
  border-radius: 28px;
  padding: 28px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.confirm-card h2 {
  font-size: 26px;
  margin: 0 0 8px;
  color: #2d2438;
}
.confirm-card p {
  color: #5a4a6e;
  font-weight: 600;
  margin: 0 0 22px;
  font-size: 16px;
}
.confirm-card .big-btn,
.confirm-card .btn-secondary {
  display: block;
  width: 100%;
  margin: 0 0 12px;
}
.confirm-card .btn-secondary:last-child { margin-bottom: 0; }

/* ============ ANIMATIONS ============ */
@keyframes pop-in {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
