/* ==========================================================================
   Planet Clicker - responsive overrides.

   Loaded last on purpose. Media queries add no specificity, so a breakpoint
   rule in an earlier file loses to an identical selector in a later one. Keeping
   every breakpoint here means responsive rules always win, and there is one
   place to look when a layout misbehaves at a given width.

   Breakpoints:
     1080px  desktop -> narrow desktop, sidebar tightens
      860px  tablet  -> phone, board stacks into a bottom sheet
      560px  narrow phone, stat strip becomes an equal four-column grid
     landscape phones with very little height
   ========================================================================== */

/* ---- from layout.css ---- */

@media (max-width: 1080px) {
  .board { grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); }
  .stat--wide { display: none; }
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "stats stats";
    gap: 10px 12px;
    padding: 10px 14px;
  }

  .topbar__brand { grid-area: brand; font-size: 0.95rem; }
  .topbar__actions { grid-area: actions; }
  .stats {
    grid-area: stats;
    justify-content: space-between;
    gap: 8px;
    padding-top: 2px;
  }

  .stat--primary .stat__value { font-size: 1.24rem; }
  .stat__value { font-size: 0.9rem; }
  .stat--wide { display: flex; }

  /* The planet takes the space it needs, but the shop sheet is guaranteed
     enough room to show real content rather than just its tabs. */
  .board {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, auto) minmax(250px, 1fr);
  }

  .stage {
    padding: 12px 16px 14px;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
  }

  /* A smaller planet on phones: still a large touch target, but it no longer
     pushes the shop off the bottom of the screen. */
  .clicker__button { width: clamp(150px, min(30vh, 52vw), 280px); }

  .stage__heading { display: flex; flex-direction: column; gap: 2px; }
  .stage__planet { font-size: clamp(1.3rem, 5.4vw, 1.7rem); }

  .meta-pill { padding: 5px 11px; }
  .meta-pill__label { font-size: 0.55rem; }
  .meta-pill__value { font-size: 0.82rem; }

  .sidebar {
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.45);
  }

  /* A grab handle to signal the sheet scrolls. */
  .sidebar::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: var(--surface-3);
    margin: 8px auto 2px;
    flex-shrink: 0;
  }

  .btn--sm span:not(.btn__icon) { display: none; }
  .player-chip__rank { display: none; }
}

@media (max-width: 560px) {
  .stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
  }

  .stat { min-width: 0; }

  .stat__value {
    font-size: 0.85rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stat--primary .stat__value { font-size: 1.1rem; }

  /* The full label stays in the accessibility tree; only its glyphs collapse. */
  .stat__label { font-size: 0; letter-spacing: 0; }

  .stat__label::after {
    content: attr(data-short);
    font-size: 0.56rem;
    letter-spacing: 0.08em;
  }

  /* The wordmark is the first thing to go: the planet mark still reads as the
     logo, and the space it frees is what stops the top bar clipping at 375px. */
  .topbar { gap: 8px 10px; padding: 10px 12px; }
  .topbar__name { display: none; }
  .topbar__actions { gap: 6px; }
  .player-chip { max-width: 132px; padding-right: 8px; }
  .player-chip__name { max-width: 62px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .board { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
  .stage__heading, .stage__meta { display: none; }
}

/* ---- from components.css ---- */

@media (max-width: 860px) {
  .toasts { bottom: auto; top: 96px; }
  .podium { gap: 6px; }
  .podium__slot { padding: 12px 4px 10px; }
  .podium__name { font-size: 0.76rem; }
  .podium__score { font-size: 0.7rem; }
  .podium__medal { font-size: 1.4rem; }
  .modal__footer { grid-template-columns: auto auto 1fr; row-gap: 4px; }
  .your-rank__score { grid-column: 3; text-align: right; }
  .ranks__head, .ranks__row { grid-template-columns: 44px 1fr auto; padding: 9px 11px; gap: 8px; }
  .world { grid-template-columns: 50px 1fr auto; }
  .world__art { width: 50px; }
}

/* ---- loading screen ad slots ---- */

/* A 728x90 will not fit a phone; let the slot shrink instead of overflowing. */
@media (max-width: 782px) {
  .ad-slot--banner .ad-slot__inner { min-height: 60px; }
  .ad-slot--rectangle .ad-slot__inner { min-height: 200px; }
}

/* Only drop the second slot when the screen is genuinely too short for it -
   landscape phones, essentially. A normal 667px-tall phone keeps both. */
@media (max-height: 560px) {
  .ad-slot--rectangle { display: none; }
  .loading__planet { display: none; }
}
