/* ============================================================================
   MK ARENA - RESPONSIVE LAYER                               MG-819, 27 Oct 2026
   ----------------------------------------------------------------------------
   Loaded LAST on every themed Arena page, after theme, brand and motion. The
   theme file is never edited; this sheet fills the gaps it leaves.

   WHY THIS EXISTS
   Raj: "do the responsive design for all the pages size and browsers and apps
   and mobile screens and laptops screens and tablet screens.. make it more
   fantastic responsive."

   WHAT WAS ACTUALLY WRONG - measured, not assumed
   The theme has exactly two layout bands: one column up to 899px, then the
   laptop layout at 900px and over (with two cosmetic tweaks at 479px and
   599px). So:

     1. THE TABLET HOLE, 600 to 899px. An iPad in portrait is 820px wide and
        got the PHONE layout - one game tile per row, a 70-character line of
        text, and half the screen empty down both sides. This is the band Raj
        is most likely looking at, and it was never designed.
     2. LANDSCAPE PHONE. A phone turned sideways is about 390px TALL. The
        headline sizes are clamped on vw only, so 7vw of 844px asks for 59px
        of headline on a 390px-tall screen, the sticky header takes 70 more,
        and nothing of the game is left. Height was never in the question.
     3. NOTHING ABOVE 1180px. The wrap stops there and the tile grid stops at
        3 across, so a 1920px monitor shows a 1180px strip with 740px of empty
        ground. A desk screen should get more board, not more margin.
     4. THE FOLD AND THE OLD ANDROID, under 360px. 16px of gutter each side
        out of 320px leaves 288px for a game.
     5. IN-APP BROWSERS. Instagram's and Facebook's webviews are where the
        carry hop (save.html) players arrive from. They inflate text on
        rotate, they put a toolbar over the bottom of the screen, and in a
        PWA on a notched phone the sticky header lands under the notch.

   WHAT THIS SHEET DOES NOT DO
   It adds no feature, hides no content and moves nothing between pages. Every
   band shows the same things in a shape that fits the glass. A reader at any
   width sees one Arena.

   HOUSE RULE, carried from the theme file: never write a star next to a slash
   inside a comment. That closes the comment and the browser drops the next
   rule.
   ============================================================================ */


/* ------------------------------------------------------------ 1. THE FLOOR
   Four things that are true at every width, and three of them are about a
   browser rather than a size. */

/* An in-app webview (Instagram, Facebook) and iOS Safari both inflate text
   when the phone is rotated, which breaks every clamp below. Pinning the
   adjust keeps the type scale the one that was designed. The player can
   still zoom - this only stops the browser doing it unasked. */
html{ -webkit-text-size-adjust:100%; text-size-adjust:100%; }

/* No page may scroll sideways. The theme already gives .ca-hub and .ca-rail
   children min-width:0 on the hub page only; every grid and flex child that
   can hold a long word, a number or a table needs it, or the child refuses to
   shrink and pushes the page wider than the glass.
   overflow-x is deliberately NOT clipped on the body: the sticky header and
   the win card's trophy (which hangs 78px above its card) both depend on an
   unclipped page. The fix belongs on the children. */
.ca .ca-hub > *, .ca .ca-rail > *, .ca .ca-hub-main > *,
.ca .ca-tiles > *, .ca .ca-stats > *, .ca .ca-game > *,
.ca .ca-tile .body, .ca .ca-win .rows{ min-width:0; }

/* a nickname is whatever the player typed. It may be one long word. */
.ca .ca-player .name, .ca .ca-tile .ca-h2, .ca .ca-stat .sub,
.ca .board .nick, .ca .me .nick{ overflow-wrap:anywhere; }

/* On a touch screen a tap on a button waited 300ms while the browser decided
   whether it was a double-tap-to-zoom, and left a grey flash behind. Both are
   wrong on something meant to feel like a game. */
.ca .ca-btn, .ca .ca-tile, .ca .ca-chip, .ca .kid{
  touch-action:manipulation; -webkit-tap-highlight-color:transparent;
}

/* Reading measure. A line of text 1100px wide cannot be read, and no clamp
   fixes that because the type size is right - it is the COLUMN that is wrong.
   Headings and figures keep the full width; running text does not. */
.ca .ca-lede, .ca .honest p, .ca .ca-card > p:not([class]),
.ca .ca-marquee p{ max-width:66ch; }
.ca .ca-center .ca-lede, .ca .sv .ca-lede{ margin-inline:auto; }


/* ------------------------------------------------------------ 2. THE FOLD AND THE OLD ANDROID (< 360px)
   A Galaxy Fold shut is 280px; a Galaxy A-series and an iPhone SE are 320 to
   360. The theme's gutter is clamp(16px,3vw,32px), so 16px each side. Here the
   content matters more than the margin, and the header gives up its wordmark
   (the theme already hides .ca-player's name under 480px). */
@media (max-width:359px){
  .ca .ca-wrap{ padding-inline:10px; }
  .ca .ca-page{ padding-block:10px 32px; }
  .ca .ca-card, .ca .ca-field{ padding:14px 12px; border-radius:var(--ca-r-md); }
  .ca .ca-brand .name{ font-size:.9375rem; }
  .ca .ca-brand .name small{ display:none; }       /* the mark still says whose app this is */
  .ca .ca-brand img, .ca .ca-brand svg{ width:34px; height:34px; }
  .ca .ca-top-in{ min-height:56px; gap:8px; }
  .ca .ca-stats{ gap:6px; }
  .ca .ca-stat .lbl{ font-size:.75rem; letter-spacing:.06em; }
  .ca .acts .ca-btn, .ca .ca-controls > .ca-btn{ flex:1 1 100%; }   /* one button per row, full width */

  /* Times Treasure's board bleeds into the gutter on purpose, to win width for its
     ten columns - it asks for -13px, which is the theme's 16px gutter less its own
     3px of rim. This band narrows the gutter to 10px, so the old bleed hung 3px of
     board off each edge of a 320px screen and the whole page scrolled sideways.
     Neither rule was wrong; the combination was. The bleed tracks the gutter. */
  .ca .board{ margin-inline:-7px; }
}


/* ------------------------------------------------------------ 3. THE TABLET HOLE (600 - 899px)
   The band that was never designed. A big phone in landscape, a small tablet
   in portrait, an iPad mini, an iPad in portrait, a Chromebook in split view.
   Two across is the honest answer: three across at 700px gives a 210px tile,
   which is narrower than the tile's own art. */
@media (min-width:600px) and (max-width:899px){
  .ca .ca-tiles{ grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }

  /* the tile turns from a row into a small poster, the same anatomy the
     laptop band uses, so a player moving between the two sees one design */
  .ca .ca-tile{ grid-template-columns:1fr; padding:14px; align-content:start; }
  .ca .ca-tile .art{ width:100%; height:112px; }
  .ca .ca-tile .art .ca-ball{ --sz:42px; }
  .ca .ca-tile .body{ padding:12px 4px 2px; padding-right:4px; }
  .ca .ca-tile .go{ top:auto; bottom:16px; margin-top:0; }

  /* the hero stops being a tall stack: the ball cluster comes in beside the
     words, as it does on a laptop, because there is width for it now */
  .ca .ca-marquee{ padding-right:210px; min-height:220px; }
  .ca .ca-marquee p{ max-width:40ch; }
  .ca .ca-cluster{ right:60px; bottom:auto; top:50%; transform:translateY(-50%);
                   width:160px; height:160px; opacity:1; }
  .ca .ca-cluster .b2, .ca .ca-cluster .b4{ display:inline-grid; }
  .ca .ca-cluster .b1{ left:0; top:26px; --sz:52px; }
  .ca .ca-cluster .b3{ left:84px; top:44px; --sz:62px; }
  .ca .ca-marquee .ca-kidoo{ right:14px; top:50%; transform:translateY(-50%); width:84px; height:84px; }

  /* a game board and its stats, centred rather than stretched - a 860px-wide
     grid of balls is a thumb journey, not a game */
  .ca .ca-stats, .ca .ca-meter, .ca .ca-controls, .ca .ca-field{
    max-width:600px; margin-inline:auto; width:100%;
  }
  /* the crest wall, the board and the parent list read better two up */
  .ca .lad li{ height:34px; }
  .ca .acts .ca-btn{ flex:1 1 calc(50% - 10px); }
}


/* ------------------------------------------------------------ 4. LAPTOP, UNCHANGED (900 - 1439px)
   The theme owns this band and it is right: tiles 3 across with a 320px rail,
   the board left and a sticky rail right, the win card in two columns. Nothing
   is restated here - this note only marks that the silence is deliberate. */


/* ------------------------------------------------------------ 5. THE DESK SCREEN (>= 1440px)
   The wrap stopped at 1180px, so a 1920px monitor showed a strip. A desk
   screen gets more Arena, not more margin: a wider wrap, a wider rail and a
   fourth tile in the row. The reading measure in section 1 keeps the text
   columns honest while the boards and tiles take the new room. */
@media (min-width:1440px){
  .ca{ --ca-wrap:1340px; }
  .ca .ca-tiles{ grid-template-columns:repeat(4,minmax(0,1fr)); gap:22px; }
  .ca .ca-tile .art{ height:140px; }
  .ca .ca-hub{ grid-template-columns:minmax(0,1fr) 360px; gap:32px; }
  .ca .ca-game{ grid-template-columns:minmax(0,1fr) 360px; gap:28px; }
  .ca .ca-stats, .ca .ca-meter, .ca .ca-controls{ max-width:640px; }
  .ca .ca-marquee{ min-height:300px; padding-right:360px; }
  .ca .ca-cluster{ right:150px; width:230px; height:210px; }
}
@media (min-width:1800px){
  .ca{ --ca-wrap:1520px; }
  .ca .ca-tiles{ gap:26px; }
}


/* ------------------------------------------------------------ 6. THE PHONE TURNED SIDEWAYS
   Keyed on HEIGHT, which is the thing that is actually short. A phone in
   landscape is about 390px tall and the sticky header plus a 56px headline
   plus 40px of page padding leaves nothing. Children do turn the phone
   sideways to play, so this band has to work, not merely survive.

   This is also the band a browser's own chrome creates: a short window on a
   laptop hits it too, which is correct - the fix is about height either way. */
@media (max-height:560px) and (orientation:landscape){
  .ca{
    --ca-fs-hero:clamp(1.5rem,3.2vh + 1vw,2rem);
    --ca-fs-h1:clamp(1.25rem,2.6vh + 1vw,1.625rem);
    --ca-fs-h2:1.125rem;
  }
  .ca .ca-top::before{ height:4px; }
  .ca .ca-top-in{ min-height:48px; padding-block:4px; }
  .ca .ca-brand img, .ca .ca-brand svg{ width:32px; height:32px; }
  .ca .ca-brand .name small{ display:none; }
  .ca .ca-page{ padding-block:8px 16px; }
  .ca .ca-card, .ca .ca-field{ padding:12px 14px; }
  .ca .ca-card + .ca-card, .ca .ca-tiles{ margin-top:10px !important; }

  /* the win card is the screen that breaks first: it is tall by design, with a
     trophy hanging above it. Side by side instead, and the trophy comes back
     inside so nothing is cut off the top of a 390px-tall window. */
  .ca .ca-winwrap{ min-height:0; padding:8px 0; }
  .ca .ca-win{ width:min(100%,620px); display:grid; grid-template-columns:1fr 1fr;
               gap:0 20px; text-align:left; padding:16px 20px 14px; }
  .ca .ca-win .trophy{ width:72px; height:72px; margin:0 0 4px; grid-column:1; }
  .ca .ca-win .ca-d, .ca .ca-win .sub, .ca .ca-win .score, .ca .ca-win .ca-starrow{ grid-column:1; }
  .ca .ca-win .rows{ grid-column:2; grid-row:1 / span 5; align-self:center; margin:0;
                     max-height:60vh; overflow:auto; overscroll-behavior:contain; }
  .ca .ca-win .acts{ grid-column:1 / -1; grid-template-columns:1fr 1fr; }
  .ca .ca-starrow svg{ width:34px; height:34px; }

  /* the board gets the width it just gained */
  .ca .ca-game{ grid-template-columns:minmax(0,1fr) 280px; gap:14px; align-items:start; }
  .ca .ca-stats{ gap:8px; }
  .ca .ca-stat .lbl{ font-size:.75rem; }
  .ca .ca-modes{ padding-bottom:6px; }
}


/* ------------------------------------------------------------ 7. INSTALLED AS AN APP
   Only inside a PWA or a full-screen webview, where the page owns the whole
   glass and the operating system draws its clock and camera notch OVER the
   top of it. In an ordinary browser tab the browser has already laid the page
   out below the notch, so adding the inset there would open a gap - which is
   exactly why this is guarded by display-mode and not applied everywhere.
   The theme already pads .ca-page's bottom with the bottom inset. */
@media (display-mode:standalone), (display-mode:fullscreen), (display-mode:minimal-ui){
  .ca .ca-top{ padding-top:env(safe-area-inset-top, 0px); }
  .ca .ca-wrap{
    padding-left:max(clamp(16px,3vw,32px), env(safe-area-inset-left, 0px));
    padding-right:max(clamp(16px,3vw,32px), env(safe-area-inset-right, 0px));
  }
  /* a sticky rail must clear the notch too, or it hides under the clock */
  .ca .ca-game .side{ top:calc(84px + env(safe-area-inset-top, 0px)); }
}


/* ------------------------------------------------------------ 8. THE OLD BROWSER FLOOR
   Everything above is grid, clamp, dvh and env - all widely supported, and
   all of them DEGRADE rather than break: a browser that does not understand a
   declaration drops that line and keeps the theme's own value. The one case
   that does not degrade safely is a grid with no fallback, so the two grids
   this sheet introduces are checked.
   A browser without grid gets the theme's single column, which is a real
   layout, not a broken one. */
@supports not (display:grid){
  .ca .ca-tiles, .ca .ca-hub, .ca .ca-game, .ca .ca-stats{ display:block; }
  .ca .ca-tiles > *, .ca .ca-stats > *{ margin-bottom:14px; }
}

/* A browser that has dvh gets it everywhere a page asked for vh. iOS Safari
   and every in-app webview shrink the visible area when their toolbar slides
   in, so 100vh is taller than the glass and the bottom of a board is cut off.
   The page sheets that use vh are corrected at source; this is the floor for
   anything added later. */
@supports (height:100dvh){
  .ca .ca-full{ height:100dvh; }
}


/* ------------------------------------------------------------ 9. MOTION OFF, AGAIN
   The theme and the motion sheet both stop their animations under reduced
   motion. This sheet adds only two transitions of its own, and they stop too. */
@media (prefers-reduced-motion:reduce){
  .ca .kid{ transition:none; }
  .ca .iq-meter i{ transition:none; }
}
