/* Atlantic Race wide screens (2026-11-03), linked last on Options, Profile, Controls, How to play,
   Credits, Licences, Exit and the seven mode (stage) pages.
   On screens 1400px wide and more (and 620px tall), the pages that used one ~1000px column in the
   middle spread across the screen:
   - Options: the tab bar becomes a sticky side rail on the left, the settings fill the rest.
   - Profile: the racer card, career and buttons in a sticky side column; modes, medals and racer
     details on the right.
   - Controls: the drawing with its numbered list beside it; special actions and menus side by side.
   - How to play: the lessons card is a sticky side rail; basics and lessons on the right.
   - Licences: contents as a side rail, the licences two by two.
   - Mode pages: the mode and the stages use the full width, with taller stage cards.
   - Exit: centred, the message and the buttons side by side (all computer screens).
   Narrower screens keep their layouts: the .wd-side / .wd-body wrappers are display: contents there.
   Only menu-polish's --mp-* tokens are used, so both looks (Storm and Coast Daylight) follow. */

.wd-side, .wd-body { display: contents; }

@media (min-width: 1400px) and (min-height: 620px) {
  :root { --wd-gutter: clamp(40px, 3.4vw, 72px); --wd-rail: clamp(270px, 17vw, 330px); }
  .topbar { padding-inline: var(--wd-gutter); }

  /* every column page: as wide as the screen allows, up to 1840px */
  .page-main, .lic-main { width: min(1840px, 100%); padding-inline: var(--wd-gutter); }
  .page-head h1 { font-size: clamp(3.4rem, 3.6vw, 4.4rem); }
  .page-head p { max-width: 90ch; font-size: 1.04rem; }

  /* a side rail (left) and a body (right) */
  .settings-page .page-main:has(.st-tabbar),
  .settings-page .page-main:has(.tu-top),
  .profile-page .page-main,
  .licenses-page .page-main {
    grid-template-columns: var(--wd-rail) minmax(0, 1fr); column-gap: clamp(24px, 2vw, 40px); align-items: start;
  }
  .page-main > .page-head { grid-column: 1 / -1; }
  .wd-side, .wd-body { display: grid; gap: 20px; align-content: start; min-width: 0; }
  .wd-side { position: sticky; top: 16px; }
  .wd-body { grid-column: 2; }

  /* ---------------- Options ---------------- */
  .st-tabbar {
    grid-column: 1; position: sticky; top: 16px; align-self: start;
    grid-template-columns: 1fr 1fr; grid-template-areas: 'tabs tabs' 'q e'; gap: 10px; padding: 10px;
  }
  .st-tabbar > .st-shoulder:first-child { grid-area: q; justify-self: start; }
  .st-tabbar > .st-shoulder:last-child { grid-area: e; justify-self: end; }
  .st-tabbar > .st-shoulder { padding: 2px 6px 4px; }
  .st-tabs { grid-area: tabs; flex-direction: column; gap: 4px; overflow: visible; }
  .st-tabs [role='tab'] {
    flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 15px 18px; text-align: left; font-size: .9rem;
  }
  .st-tabs [role='tab']::after { content: '›'; font-size: 1.3rem; line-height: 0; opacity: 0; transform: translateX(-6px); transition: opacity .18s ease, transform .18s ease; }
  .st-tabs [role='tab']:hover::after, .st-tabs [role='tab'][aria-selected='true']::after { opacity: 1; transform: none; }
  .settings-page .wd-body .st-panel { gap: 20px; }
  #panel-gameplay > .card, #panel-access > .card { max-width: none; }
  .settings-page .wd-body > .note { text-align: left !important; }

  /* ---------------- Profile ---------------- */
  .profile-page .pf-hero { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 18px; padding-block: 26px; text-align: center; }
  .profile-page .pf-hero .player-card { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 16px; text-align: center; }
  .profile-page .pf-hero .avatar-big { width: 132px; }
  .profile-page .pf-hero .pf-who { justify-items: center; }
  .profile-page .pf-hero .player-name { font-size: clamp(1.7rem, 1.7vw, 2.2rem); overflow-wrap: anywhere; }
  .profile-page .pf-ring { width: 124px; height: 124px; }
  .profile-page .pf-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-page .wd-side > .card:not(.pf-hero) { padding-bottom: 20px; }
  .profile-page .pf-modes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  @media (min-width: 1700px) { .profile-page .pf-modes { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
  .profile-page .wd-body > .note { text-align: left !important; }
  @media (min-width: 2200px) { .profile-page .pf-modes { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
  /* the buttons under the side column read as a list */
  .profile-page .page-actions { justify-content: flex-start; }

  /* ---------------- Controls ---------------- */
  .settings-page .page-main.lc-main:not(:has(.tu-top)) { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; align-items: stretch; }
  .lc-main:not(:has(.tu-top)) > .card:has(#modes), .lc-main:not(:has(.tu-top)) > .card:has(.lc-stage) { grid-column: 1 / -1; }
  .lc-modes { gap: 12px; }
  .lc-stage { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: clamp(20px, 2vw, 40px); align-items: center; }
  .lc-figure { width: min(100%, 1040px); }
  .lc-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: center; gap: 8px; }
  .lc-moves { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

  /* ---------------- How to play ---------------- */
  .tu-top {
    grid-column: 1; position: sticky; top: 16px; align-self: start;
    grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start;
  }
  .tu-jump { flex-direction: column; flex-wrap: nowrap; gap: 6px; }
  .tu-jump a { display: flex; width: 100%; box-sizing: border-box; }
  .tu-jump a.read::after { margin-left: auto; }
  .tu-switches { justify-items: stretch; padding-top: 16px; border-top: 1px solid var(--mp-stroke); }
  .tu-switch { justify-content: space-between; }
  .tu-switches .ghost-btn { justify-content: center; }
  /* the six basics: two full rows of four columns (wide cards take two) */
  .tu-intro { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }

  /* ---------------- Licences ---------------- */
  .lic-toc { grid-column: 1; position: sticky; top: 16px; align-self: start; }
  .lic-toc ul { flex-direction: column; flex-wrap: nowrap; }
  .lic-toc a { display: block; border-radius: 10px; padding: 10px 14px; }
  .lic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .lic-grid .lic-card { display: flex; flex-direction: column; }
  .lic-grid .lic-text { flex: 1; max-height: 520px; }
  .licenses-page .lic-end { grid-column: 2; }

  /* ---------------- Credits, plain view (the roll stays a centred film roll) ---------------- */
  html[data-cr-view='plain'] .cr-main { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  html[data-cr-view='plain'] .cr-main > * { grid-column: span 3; }
  html[data-cr-view='plain'] .cr-main > :is(#cr-type, #cr-light, #cr-sound) { grid-column: span 2; align-self: stretch; }
  html[data-cr-view='plain'] .cr-main > :is(.cr-title, .cr-end, #cr-places, #cr-built) { grid-column: 1 / -1; }
  html[data-cr-view='plain'] .cr-places { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* ---------------- Mode (stage) pages ---------------- */
  .arena { width: min(1840px, 100%); padding-inline: var(--wd-gutter); grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr); gap: clamp(40px, 4vw, 96px); }
  .arena .about { font-size: 1.1rem; max-width: 60ch; }
  .arena .stages { padding: clamp(20px, 1.4vw, 28px); }
  .arena .stage-grid { gap: 14px; }
  .arena .stage { min-height: clamp(150px, 15vh, 210px); padding: 16px 18px; }
  .arena .stage .city { font-size: 1.36rem; }
  .arena .ways li { padding: 12px 14px; }
}

/* laptop-size screens (1100-1399px): the column uses the whole width, same layouts */
@media (min-width: 1100px) and (max-width: 1399.98px) {
  .page-main, .lic-main { width: 100%; }
}

/* the largest screens: a little more air */
@media (min-width: 2200px) and (min-height: 1000px) {
  .page-main, .lic-main, .arena { width: min(2160px, 100%); }
  .page-main { gap: 26px; }
}

/* ---------------- Exit: centred on every computer screen ---------------- */
@media (min-width: 900px) {
  body:has(.exit-card) .page-main { width: min(1100px, 100%); justify-items: center; align-content: center; min-height: calc(100vh - 220px); }
  body:has(.exit-card) .page-head { text-align: center; justify-items: center; display: grid; }
  body:has(.exit-card) .page-head h1::after { margin-inline: auto; background: linear-gradient(90deg, transparent, var(--accent), transparent); }
  body:has(.exit-card) .exit-card {
    width: 100%; max-width: 960px; box-sizing: border-box; margin-top: 8px;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: center; column-gap: 36px; padding: 30px 34px;
  }
  body:has(.exit-card) .exit-card > :not(.race-btn, .exit-actions, [data-exit='stop']) { grid-column: 1; }
  body:has(.exit-card) .exit-card > :is(.race-btn, [data-exit='stop']) { grid-column: 2; justify-self: stretch; text-align: center; }
  body:has(.exit-card) .exit-card > [data-exit='stop'] { grid-row: 2; display: grid; }
  body:has(.exit-card) .exit-card > [data-exit='stop'][hidden] { display: none; }
  body:has(.exit-card) .exit-card > [data-exit='stop'] .ghost-btn { width: 100%; }
  body:has(.exit-card) .exit-card > .race-btn { grid-row: 1; min-width: 0; }
}

/* ================= Phones sideways (2026-11-04): every page on one screen =================
   On a phone held sideways (landscape, at most 500 px high) the pages were long scrolls: the Back
   button, the logo, a big title and an intro line took half the screen before any content, and
   How to play ran to 11,500 px. Now each page is one screen, like an app:
   - a slim fixed header row: Back on the left, the page title in the middle, the logo on the right;
   - below it the page's own panel scrolls (the page itself never does);
   - Options, Profile, How to play and Licences get the side rail of the wide-screen layout (tabs,
     racer card, lessons, contents) beside their content;
   - mode pages: the mode and Start Race on the left, the stages on the right, the mode switcher as
     a slim row of icons along the bottom (the current mode shows its name);
   - Exit: the message and the buttons side by side.
   Credits keep their film roll (it scrolls by design); only their header is slimmer. */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --ph-bar: 56px; --ph-l: max(14px, env(safe-area-inset-left)); --ph-r: max(14px, env(safe-area-inset-right)); }

  /* ---- the header row (every page with the shared topbar) ---- */
  body:not([data-home-page]):not(.drive) > .topbar {
    min-height: var(--ph-bar); box-sizing: border-box; gap: 12px;
    padding: max(6px, env(safe-area-inset-top)) var(--ph-r) 6px var(--ph-l);
  }
  body:not([data-home-page]):not(.drive) > .topbar .back { min-height: 44px; padding: 6px 14px 6px 10px; font-size: .85rem; }
  body:not([data-home-page]):not(.drive) > .topbar .back kbd { display: none; }
  body:not([data-home-page]):not(.drive) > .topbar .brand { width: 92px; }

  /* ---- one screen: the header, then a panel that scrolls on its own ---- */
  body:is(.settings-page, .profile-page, .licenses-page):has(> main.page-main),
  body:has(> main.arena) {
    height: 100svh; min-height: 0; overflow: hidden;
  }
  body:is(.settings-page, .profile-page, .licenses-page):has(> main.page-main) { grid-template-rows: auto minmax(0, 1fr); }
  body:is(.settings-page, .profile-page, .licenses-page) > main.page-main {
    width: 100%; height: 100%; min-height: 0; box-sizing: border-box; gap: 12px;
    padding: 2px var(--ph-r) 16px var(--ph-l); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  }
  /* the title moves up into the header row, the intro line is left out */
  body:is(.settings-page, .profile-page, .licenses-page) .page-head {
    position: fixed; z-index: 3; top: max(6px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; height: 44px; max-width: calc(100vw - 2 * (130px + var(--ph-l)));
    pointer-events: none; animation: none;
  }
  body:is(.settings-page, .profile-page, .licenses-page) .page-head h1 { font-size: 1.35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: .2em; }
  body:is(.settings-page, .profile-page, .licenses-page) .page-head p { display: none; }
  body:is(.settings-page, .profile-page, .licenses-page) .page-head h1::after { display: none; }
  body:is(.settings-page, .profile-page, .licenses-page) > .topbar .counter { display: none; }
  .page-main .card { padding: 14px 16px; }

  /* ---- a side rail (left) and the content (right) ---- */
  .settings-page .page-main:has(.st-tabbar),
  .settings-page .page-main:has(.tu-top),
  .profile-page .page-main,
  .licenses-page .page-main {
    grid-template-columns: clamp(180px, 30vw, 250px) minmax(0, 1fr); column-gap: 14px; align-items: start;
  }
  .wd-side, .wd-body { display: grid; gap: 12px; align-content: start; min-width: 0; }
  .wd-body { grid-column: 2; }
  /* the rails stay put while the content scrolls, and scroll themselves when taller than the screen */
  :is(.wd-side, .st-tabbar, .tu-top, .lic-toc) {
    grid-column: 1; position: sticky; top: 0; align-self: start;
    max-height: calc(100svh - var(--ph-bar) - 18px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  }

  /* Options: the tabs as a list */
  .st-tabbar { grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 8px; }
  .st-tabbar > .st-shoulder { display: none; }
  .st-tabs { flex-direction: column; gap: 4px; overflow: visible; }
  .st-tabs [role='tab'] { flex: none; display: flex; align-items: center; min-height: 44px; padding: 8px 14px; text-align: left; font-size: .82rem; }
  #panel-gameplay > .card, #panel-access > .card { max-width: none; }

  /* Profile: the racer card stacked in the rail */
  .profile-page .pf-hero { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 10px; padding-block: 14px; text-align: center; }
  .profile-page .pf-hero .player-card { grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 8px; text-align: center; }
  .profile-page .pf-hero .avatar-big { width: 72px; height: 72px; }
  .profile-page .pf-hero .pf-who { justify-items: center; }
  .profile-page .pf-hero .player-name { font-size: 1.3rem; overflow-wrap: anywhere; }
  .profile-page .pf-ring { width: 92px; height: 92px; }
  .profile-page .pf-ring b { font-size: 1.4rem; }
  .profile-page .pf-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-page .pf-modes { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
  .profile-page .page-actions { justify-content: flex-start; }

  /* How to play: the lessons list as the rail */
  .tu-top { grid-template-columns: minmax(0, 1fr); gap: 10px; align-items: start; padding: 12px; }
  .tu-jump { flex-direction: column; flex-wrap: nowrap; gap: 4px; }
  .tu-jump a { display: flex; width: 100%; box-sizing: border-box; min-height: 44px; }
  .tu-jump a.read::after { margin-left: auto; }
  .tu-switches { justify-items: stretch; padding-top: 10px; border-top: 1px solid var(--mp-stroke); }
  .tu-switch { justify-content: space-between; }
  .tu-intro { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
  .tu-intro .card.wide { grid-column: auto; }

  /* Licences: the contents as the rail */
  .lic-toc ul { flex-direction: column; flex-wrap: nowrap; gap: 4px; }
  .lic-toc a { display: flex; align-items: center; min-height: 44px; box-sizing: border-box; border-radius: 10px; padding: 6px 12px; }
  .licenses-page .lic-end { grid-column: 2; }

  /* ---- Exit: one screen, the message and the buttons side by side ---- */
  body:has(.exit-card) { height: 100svh; min-height: 0; overflow: hidden; grid-template-rows: auto minmax(0, 1fr); }
  body:has(.exit-card) .page-main { width: 100%; box-sizing: border-box; min-height: 0; align-content: center; gap: 10px; padding: 0 var(--ph-r) 12px var(--ph-l); overflow-y: auto; }
  body:has(.exit-card) .page-head h1 { font-size: 1.7rem; }
  body:has(.exit-card) .page-head h1::after { margin-top: 6px; }
  body:has(.exit-card) .page-head p { margin-top: 6px; font-size: .9rem; }
  body:has(.exit-card) .exit-card {
    width: 100%; max-width: none; box-sizing: border-box; margin-top: 0; padding: 14px 18px;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: center; column-gap: 20px; row-gap: 10px;
  }
  body:has(.exit-card) .exit-card > :not(.race-btn, .exit-actions, [data-exit='stop']) { grid-column: 1; }
  body:has(.exit-card) .exit-card > :is(.race-btn, [data-exit='stop']) { grid-column: 2; justify-self: stretch; text-align: center; }
  body:has(.exit-card) .exit-card > [data-exit='stop'] { grid-row: 2; display: grid; }
  body:has(.exit-card) .exit-card > [data-exit='stop'][hidden] { display: none; }
  body:has(.exit-card) .exit-card > .race-btn { grid-row: 1; min-width: 0; padding: 14px 20px; }

  /* ---- mode pages: the mode and Start on the left, the stages on the right ---- */
  body:has(> main.arena) { grid-template-rows: auto minmax(0, 1fr) auto; }
  body:has(> main.arena) > .arena {
    width: 100%; height: 100%; min-height: 0; box-sizing: border-box; align-items: stretch;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 12px; padding: 0 var(--ph-r) 8px var(--ph-l);
  }
  .arena > .hero { display: flex; flex-direction: column; gap: 5px; min-height: 0; overflow-y: auto; scrollbar-width: none; }
  .arena > .hero .mode-logo { width: min(100%, 180px); flex: none; }
  .arena > .hero .tag { margin: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .arena > .hero .about { display: none; }
  .arena > .hero > .stats { margin: 0; padding: 6px 12px; gap: 4px 16px; grid-template-columns: repeat(2, auto); }
  .arena > .hero .stat dd { margin-top: 3px; }
  .arena > .hero .stat dd i { width: 12px; height: 8px; }
  .arena > .hero .stat.racers dd { font-size: 1.1rem; }
  .arena > .hero > .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
  .arena > .hero .race-btn { width: 100%; min-width: 0; padding: 12px 20px; }
  .arena > .hero .picked { display: none; }   /* the picked stage is lit up in the list beside it */
  .arena > .hero .learn-link { min-height: 40px; margin: 0; }
  .arena > .stages { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 12px; border-radius: 14px; }
  .arena .stages h2 { margin-bottom: 10px; }
  .arena .stage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .arena .stage { min-height: 82px; padding: 10px 12px; }
  .arena .stage .city { font-size: 1.05rem; }
  /* the mode switcher: a slim row of icons, the current mode with its name */
  body:has(> main.arena) > .rail { gap: 6px; padding: 6px var(--ph-r) max(6px, env(safe-area-inset-bottom)) var(--ph-l); }
  .rail .step { width: 44px; font-size: 1.6rem; border-radius: 10px; }
  .rail .step kbd { display: none; }
  .rail-track { gap: 6px; padding: 2px; }
  .rail .panel { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; width: auto; min-width: 48px; min-height: 44px; box-sizing: border-box; padding: 6px 12px; border-radius: 10px; }
  .rail .panel .icon { width: 26px; height: 26px; }
  .rail .panel:not([aria-current='page']) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .rail .panel[aria-current='page'] span { font-size: 12px; white-space: nowrap; }
  .rail .panel:hover { transform: none; }
}
/* the smallest phones sideways (320-340 px high): the mode page keeps Start and the stage list */
@media (orientation: landscape) and (max-height: 340px) {
  .arena > .hero > :is(.stats, .tag) { display: none; }
  .arena > .hero .mode-logo { width: min(100%, 170px); }
}
