/* ═══════════════════════════════════════════
   RESPONSIVE — All @media queries (mobile-first)
   Decision 7: 5 mobile-first breakpoints
   Base: 0–479px (small phones)
   sm:  480px+
   md:  768px+
   lg:  1024px+
   xl:  1280px+
   ═══════════════════════════════════════════ */

/* ══════════════════════════════════════
   BASE (0–479px) — Mobile first defaults
   ══════════════════════════════════════ */

/* Game screen — single column on smallest screens */
@media (max-width: 479px) {
  .decision-buttons { gap: 0.42rem; }

  .btn-decision {
    font-size: 0.8125rem;
    padding: 0.52rem 0.42rem;
  }

  .title-main { font-size: 1.75rem; }
  .title-divider { margin: 1.25rem auto; }
  .title-tagline { font-size: 0.875rem; }
  .title-shell { padding: 2rem 1rem; }
  .title-shell-minimal { padding: 1.5rem 1rem; }
  .title-top-controls { top: 0.75rem; left: 0.75rem; right: 0.75rem; }
  .title-utility-cluster { gap: 0.35rem; }
  .title-screen-advance { width: 100%; padding-left: 0; padding-right: 0; }
  .title-screen-advance span { width: 100%; }

  .char-grid { grid-template-columns: 1fr; }
  .scenario-grid { grid-template-columns: 1fr; }

  .title-difficulty-panel { padding: 0.75rem; }
  .difficulty-pill { padding: 0.4rem 0.7rem; font-size: 0.8125rem; }

  /* Carousel — compact on smallest screens */
  .carousel-card { padding: 0.75rem 0.875rem; }
  .carousel-card-name { font-size: 0.9375rem; }
  .expedition-setup-shell { padding: 0 0.25rem; }

  .tutorial-meta { grid-template-columns: 1fr; }

  .theme-switcher { font-size: 0.75rem; padding: 0.3rem 0.38rem; }
  .lang-switch { padding: 0.16rem; }
  .lang-btn { font-size: 0.7rem; padding: 0.28rem 0.5rem; }

  /* Bottom-sheets on mobile */
  .bottom-sheet { display: block; }
  .bottom-sheet-watch-metrics { grid-template-columns: 1fr; }

  /* Debrief hero reduced height */
  .debrief-hero { min-height: 160px; padding: 2rem 1rem 1.5rem; }
  .debrief-stats-grid { grid-template-columns: 1fr; gap: 0.5rem; }

  /* Situation bar: smaller portrait on phones */
  .situation-portrait { width: 24px; height: 24px; }
  .situation-bar { padding: 0.35rem 0.65rem; gap: 0.5rem; }
  .situation-datetime { display: none; } /* compressed: day shown via turn */


  .mountain-main {
    padding: 0.65rem 0.65rem 0.85rem;
    gap: 0.62rem;
  }

  .mountain-main .narrative-text {
    font-size: 0.95rem;
    line-height: 1.92;
    max-width: 34ch;
  }

  .ambient-signal {
    font-size: 0.75rem;
    line-height: 1.5;
  }

  .onboard-intro,
  .tutorial-dialog li,
  .tutorial-faq-item p {
    line-height: 1.75;
  }
}

/* ══════════════════════════════════════
   SM — 480px+ (standard phones)
   ══════════════════════════════════════ */

@media (min-width: 480px) {
  .title-main { font-size: clamp(1.75rem, 6vw, 2.2rem); }
  .char-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .scenario-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .difficulty-pill-row { flex-wrap: nowrap; }
  .debrief-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .situation-datetime { display: initial; } /* restore if hidden at 479 */
}

/* ══════════════════════════════════════
   MD — 768px+ (tablets portrait)
   Carousel → grid switch for character (Decision 12)
   ══════════════════════════════════════ */

@media (min-width: 768px) {
  /* Hide mobile-only controls on tablets+ */
  .game-mobile-bar { display: none; }
  .bottom-sheet { display: none !important; }

  /* Character grid visible (Decision 12) */
  .char-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }

  /* Decision 12 — carousel hidden on tablet+ */
  .char-carousel-wrapper { display: none; }
  .char-grid-desktop { display: grid; }

  .scenario-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

  .title-main { font-size: clamp(2rem, 5vw, 2.8rem); }

  .tutorial-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .debrief-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .debrief-hero { min-height: 280px; }
}

/* ══════════════════════════════════════
   LG — 1024px+ (tablets landscape / laptops)
   ══════════════════════════════════════ */

@media (min-width: 1024px) {
  .title-shell { padding: 3rem 2rem; }

  .char-grid { grid-template-columns: repeat(3, 1fr); }

  .debrief-stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Hide flag emoji on desktop — rendering unreliable (emoji font fallback issues) */
  .char-flag {
    display: none;
  }
}

/* ══════════════════════════════════════
   XL — 1280px+ (wide desktop)
   ══════════════════════════════════════ */

@media (min-width: 1280px) {
  .title-main { font-size: 2.8rem; }

  .char-grid { max-width: 960px; }
  .scenario-grid { max-width: 960px; }
}

/* ══════════════════════════════════════
   HEIGHT-BASED helpers
   ══════════════════════════════════════ */

@media (max-height: 760px) {
  .decision-panel { padding: 0.6rem 0.75rem; }
  .log-entry { padding: 0.5rem 0; }
  .watch-section { margin-bottom: 0.7rem; }
  .signal-line { padding: 0.35rem 0.75rem; min-height: 1.8rem; }
  .watch-band .watch-cell { padding: 0.4rem 0.35rem; }
}

/* ══════════════════════════════════════
   SAFE AREA (notch / home indicator)
   ══════════════════════════════════════ */

@supports (padding: env(safe-area-inset-top)) {
  @media (max-width: 767px) {
    #screen-game {
      padding-bottom: env(safe-area-inset-bottom, 0px);
    }
  }
}


@media (max-width: 767px) {
  #screen-game .decision-panel {
    position: sticky;
    bottom: 0;
    z-index: 20;
    border-color: color-mix(in srgb, var(--stone) 32%, var(--border));
    box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.28);
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }

  #screen-game .decision-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #screen-game .btn-decision {
    min-height: 3.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #screen-game .btn-decision-main {
    width: 100%;
    justify-content: space-between;
  }

  #screen-game .game-mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    backdrop-filter: blur(10px);
  }
}

/* ══════════════════════════════════════
   DIFFICULTY — small screen tweaks
   ══════════════════════════════════════ */

@media (max-width: 767px) {
  .difficulty-pill-row {
    gap: 0.3rem;
  }

  .difficulty-pill {
    padding: 0.4rem 0.65rem;
    font-size: 0.8125rem;
  }
}


@media (orientation: landscape) {
  .splash-image {
    object-fit: contain;
    object-position: center center;
  }
}
