/* P11-W12 — dedicated handset UX pass. Mobile gameplay is a first-class layout, not a scaled desktop canvas. */

/* Zone changes must inform without covering hazards or the runner. */
.p11-zone-banner {
  --zone-accent: var(--brand-flow-mint, #8fffd1);
  position: absolute;
  z-index: 18;
  top: max(104px, calc(env(safe-area-inset-top) + 92px));
  left: 50%;
  max-width: min(78vw, 340px);
  transform: translate(-50%, -8px) scale(.96);
  padding: 7px 14px;
  border: 1px solid color-mix(in srgb, var(--zone-accent) 46%, rgba(255,255,255,.14));
  border-radius: 999px;
  background: rgba(7, 21, 33, .78);
  color: var(--zone-accent);
  font: 800 11px/1 "Baloo 2", sans-serif;
  letter-spacing: 2px;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  opacity: 0;
  box-shadow: 0 10px 28px rgba(0,0,0,.24), 0 0 18px color-mix(in srgb, var(--zone-accent) 16%, transparent);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.p11-zone-banner.show {
  animation: p11ZoneBanner 1.45s ease both;
}

@keyframes p11ZoneBanner {
  0% { opacity: 0; transform: translate(-50%, -8px) scale(.96); }
  15%, 72% { opacity: .96; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -4px) scale(.98); }
}

/* Generic gameplay toasts are intentionally compact on small viewports. */
@media (max-width: 760px) {
  #toast {
    top: 19%;
    width: min(88vw, 360px);
    font-size: clamp(23px, 7vw, 34px);
    line-height: 1.05;
    letter-spacing: 2.4px;
    text-align: center;
    white-space: normal;
    text-wrap: balance;
    text-shadow: 0 0 24px rgba(255, 200, 60, .72), 0 3px 0 rgba(0,0,0,.34);
  }
}

/* ---------- portrait gameplay HUD ---------- */
@media (max-width: 760px) and (orientation: portrait) {
  #hud {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    display: grid;
    grid-template-columns: minmax(74px, .85fr) auto minmax(92px, 1fr) 44px;
    align-items: start;
    gap: 6px;
  }

  #hud .pill {
    min-width: 0;
    min-height: 44px;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 15px;
    font-size: 17px;
    line-height: 1;
    background: rgba(7, 21, 33, .72);
  }

  #hud .score-pill,
  #hud .coin-pill {
    min-width: 0;
  }

  #hud .pill .lbl {
    font-size: 8px;
    letter-spacing: 1.25px;
  }

  #hud .coin-dot {
    width: 12px;
    height: 12px;
    flex: 0 0 auto;
  }

  #flowHud {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    align-content: center;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 15px;
    background: rgba(7, 21, 33, .72);
  }

  #flowLabel {
    font-size: 8px;
    letter-spacing: .85px;
    white-space: nowrap;
  }

  .p11-flow-track {
    height: 5px;
  }

  #hud .hud-actions {
    margin: 0;
  }

  #hud #pauseBtn {
    width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 15px;
    margin: 0;
    background: rgba(7, 21, 33, .72);
  }

  .powerup-hud {
    top: 51px;
    left: 50%;
    min-height: 28px;
    max-width: min(72vw, 230px);
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 10px;
    letter-spacing: .65px;
    background: rgba(7, 21, 33, .74);
  }

  .p11-zone-banner {
    top: max(91px, calc(env(safe-area-inset-top) + 82px));
    padding: 6px 12px;
    font-size: 10px;
    letter-spacing: 1.7px;
  }

  /* Lobby must leave room for browser chrome and the bottom navigation. */
  .p11-lobby-shell {
    min-height: 100dvh;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(10px, env(safe-area-inset-left));
  }

  .p11-hero-stage {
    padding-top: 0;
    padding-bottom: 6px;
  }

  .p11-character-stage {
    height: min(39dvh, 360px);
  }

  .p11-hero-avatar {
    max-height: min(38dvh, 350px);
    max-width: min(72vw, 320px);
  }

  .p11-hero-nameplate {
    bottom: 0;
    min-width: 150px;
    padding: 7px 12px;
  }

  .p11-hero-nameplate strong { font-size: 16px; }
  .p11-hero-nameplate span { font-size: 8px; }

  .p11-hero-copy {
    gap: 7px;
  }

  .p11-hero-copy .logo {
    max-width: 94vw;
    font-size: clamp(40px, 10.8vw, 58px);
    line-height: .88;
    letter-spacing: -.045em;
    white-space: nowrap;
  }

  .p11-objective-chip {
    width: min(92vw, 390px);
    padding: 9px 12px;
  }

  #startBtn.p11-play-btn {
    min-width: min(310px, 82vw);
    min-height: 56px;
    padding: 12px 34px;
    font-size: 21px;
  }

  .p11-daily-btn {
    min-height: 38px;
  }

  .p11-bottom-nav {
    width: min(100%, 560px);
    gap: 3px;
    padding: 5px;
    border-radius: 18px;
  }

  .p11-nav-btn {
    min-height: 50px;
    padding: 4px 2px;
    font-size: 9px;
    letter-spacing: .45px;
  }

  .p11-nav-btn::before {
    font-size: 18px;
  }

  /* Hub surfaces use almost the full handset viewport without oversized desktop padding. */
  .p11-product-panel,
  .p11-event-panel,
  .p11-settings-panel,
  .p08-panel {
    width: min(calc(100vw - 14px), 560px);
    max-height: calc(100dvh - max(14px, env(safe-area-inset-top)) - max(14px, env(safe-area-inset-bottom)));
    padding: 15px;
    border-radius: 22px;
  }

  .p11-product-overlay,
  #eventOverlay,
  #settingsOverlay,
  #privacyOverlay {
    padding: max(7px, env(safe-area-inset-top)) max(7px, env(safe-area-inset-right)) max(7px, env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left));
  }

  .p11-product-head h2,
  .p11-settings-head h2 {
    font-size: 24px;
  }

  .p11-event-hero {
    min-height: 166px;
    padding: 16px;
  }

  .p11-event-hero h2 {
    font-size: clamp(30px, 10vw, 44px);
  }

  #eventCountdown {
    top: 12px;
    right: 12px;
    font-size: 8px;
  }

  #over.p11-over .p11-gameover-panel {
    width: min(calc(100vw - 14px), 520px);
    max-height: calc(100dvh - 14px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    padding: 14px;
    gap: 6px;
  }

  .p11-defeat-stage {
    min-height: 112px;
  }

  .p11-defeat-stage img {
    max-height: 126px;
  }

  .p11-result-title {
    font-size: clamp(27px, 9vw, 36px);
  }

  #retryBtn.p11-run-again {
    min-height: 54px;
    font-size: 19px;
  }

  #ftueCoach {
    bottom: max(74px, calc(env(safe-area-inset-bottom) + 62px));
    width: min(330px, calc(100vw - 24px));
    grid-template-columns: 44px 1fr;
    gap: 9px;
    padding: 9px 11px;
  }

  #ftueIcon {
    width: 42px;
    height: 42px;
    font-size: 22px;
  }
}

@media (max-width: 390px) and (orientation: portrait) {
  #hud {
    grid-template-columns: minmax(58px, .72fr) auto minmax(84px, 1fr) 44px;
    gap: 4px;
  }

  #hud .pill {
    padding-inline: 7px;
    font-size: 16px;
  }

  #hud .score-pill .lbl {
    display: none;
  }

  #flowHud {
    padding-inline: 7px;
  }

  .p11-character-stage {
    height: min(36dvh, 330px);
  }

  .p11-hero-avatar {
    max-height: min(35dvh, 320px);
  }

  .p11-objective-chip strong {
    font-size: 12px;
  }

  .p11-bottom-nav {
    border-radius: 16px;
  }

  .p11-nav-btn {
    font-size: 8px;
  }
}

/* ---------- handset landscape ---------- */
@media (max-height: 560px) and (orientation: landscape) {
  #hud {
    top: max(6px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    gap: 5px;
  }

  #hud .pill {
    min-height: 40px;
    padding: 5px 9px;
    font-size: 15px;
  }

  #flowHud {
    min-height: 40px;
    padding: 5px 8px;
  }

  #hud #pauseBtn {
    width: 42px;
    height: 42px;
  }

  .powerup-hud {
    top: 44px;
  }

  .p11-zone-banner {
    top: max(56px, calc(env(safe-area-inset-top) + 48px));
  }

  .p11-lobby-shell {
    padding-block: max(6px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-bottom));
  }

  .p11-bottom-nav {
    min-height: 48px;
  }

  .p11-product-panel,
  .p11-event-panel,
  .p11-settings-panel,
  .p08-panel,
  #over.p11-over .p11-gameover-panel {
    max-height: calc(100dvh - 12px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  .p11-zone-banner.show {
    animation: p11ZoneBannerReduced 1.1s linear both !important;
  }
}

@keyframes p11ZoneBannerReduced {
  0%, 100% { opacity: 0; transform: translate(-50%, 0); }
  12%, 82% { opacity: .96; transform: translate(-50%, 0); }
}
