/* Phones (Figma "Landscape phone – for review", 16:351). The full 3D game, held sideways.
   Upright phones get the "Turn your phone" message over the game; the game waits underneath. */

/* ---------- 1 · Turn your phone (upright phones only; tablets and laptops never see it) ---------- */
.turn-phone { display: none; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 600px) {
  .turn-phone { position: fixed; inset: 0; z-index: 100000; display: grid; place-items: center; padding: 24px; background: #000; color: #fff; text-align: center; }
  .turn-phone .tp-icon { display: block; font-size: 64px; line-height: 1; animation: tpTurn 2.4s ease-in-out infinite; }
  .turn-phone .tp-h { max-width: 8.5em; margin: 22px auto 12px; font: 400 40px / 1.1 'ivyora-display', Georgia, serif; }
  .turn-phone p { margin: 0 auto; max-width: 15em; font: 400 18px / 1.4 Inter, system-ui, sans-serif; }
  #preload { display: none; }
}
@keyframes tpTurn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }

/* the ☰ menu button and panel exist only on sideways phones */
.ph-menu-btn, .ph-panel { display: none; }

@media (orientation: landscape) and (max-height: 500px) {
  /* ---------- 2 · Title: title on the left, the three buttons on the right ---------- */
  /* the text starts 24px from the real screen edge, not the edge of the 16:9 stage (which leaves black bands on wide phones) */
  .tv-title { --u: calc(100cqw / 2752); left: calc(max(24px, env(safe-area-inset-left)) - (100vw - 100cqw) / 2); right: 5.5cqw; top: 19cqh; display: grid; grid-template-columns: 1fr max-content; column-gap: 4cqw; row-gap: 3cqh; align-items: start; }
  .tv-head { grid-column: 1; grid-row: 1; }
  .tv-intro { grid-column: 1; grid-row: 2; font-size: max(12px, calc(34.4 * var(--u))); }
  .tv-intro p { white-space: normal; max-width: 36ch; }
  /* three buttons the same size: as wide as the longest label plus 18px each side, 36px tall, so Adrian and Jaimy get more room */
  .tv-menu { grid-column: 2; grid-row: 1 / span 2; width: auto; padding-top: 0; gap: 8px; }
  .tv-btn { height: 36px; min-height: 0; box-sizing: border-box; padding: 0 18px; border-width: 2px; border-radius: 4px; font-size: 12px; filter: drop-shadow(0 3px 0 #000); }
  .tv-btn-primary img { width: 9px; height: 10px; }
  .tv-btn:focus-visible { outline: none; box-shadow: none; background-color: rgba(255, 255, 255, .12); }   /* Play gets focus on load; the white ring made it look bigger */
  .tv-btn-primary:focus-visible { background-color: #ffc46e; border-color: #ffc46e; }
  .tv-btn:not(.tv-btn-primary) { background: #000; }
  .tv-blue { display: none; }   /* it sat right behind the buttons */

  /* ---------- 3 · Intro card: three evenly spaced how-to rows that match the phone controls ---------- */
  .iw-how { display: none; }
  body.touch-ui .iw-how { display: flex; flex-direction: column; gap: 5px; margin: 0; padding: 0; list-style: none; font: 400 12px / 1.4 Inter, system-ui, sans-serif; color: #fff; opacity: .9; }
  .iw-count { font-size: 14px; }
  .iw-strength { display: none; }   /* an empty placeholder box from the intro design */
  .iw-card { width: 86cqw; }
  .iw-btn { height: 48px; font-size: 13px; }
  body.touch-ui .iw-how li { display: flex; gap: 10px; align-items: center; white-space: nowrap; }
  /* the icons in a fixed column, every row the joystick's height, so the three lines are evenly spaced */
  body.touch-ui .iw-ico { width: 28px; height: 26px; }
  body.touch-ui .iw-joy { width: 26px; }
  body.touch-ui .iw-tap { width: 20px; }
  body.touch-ui .iw-joy i { box-shadow: 0 0 0 1px #000; }
  body.touch-ui .iw-tap i { box-shadow: 0 0 0 1px #000, 0 0 0 3px rgba(255, 255, 255, .3); }
  body.touch-ui .iw-gem { height: 24px; filter: drop-shadow(0 0 3px rgba(0, 189, 140, .55)); }

  /* ---------- 4 · Galaxy map: the ☰ menu replaces "Meet the team" (it is in the menu) ---------- */
  body[data-screen="map"] .ph-menu-btn { display: grid; place-items: center; position: absolute; z-index: 40; top: 1.5cqw; right: calc(1.5cqw + 58px); width: 48px; height: 48px; padding: 0; box-sizing: border-box; font-size: 18px; line-height: 1; }
  body[data-screen="map"] #meetBtn { display: none; }
  /* the ☰ character drew short, thin lines: three 22 x 3px bars instead, closer to the weight of the sound icon */
  body[data-screen="map"] .ph-menu-btn { font-size: 0; }
  /* centred on its own (the hidden ☰ character was a second grid item that pushed the bars off centre); 2px bars, 6px apart */
  body[data-screen="map"] .ph-menu-btn::before { content: ''; position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 22px; height: 14px;
    background: linear-gradient(currentColor 0 0) 0 0 / 100% 2px no-repeat, linear-gradient(currentColor 0 0) 0 50% / 100% 2px no-repeat, linear-gradient(currentColor 0 0) 0 100% / 100% 2px no-repeat; }
  /* the compact map on every phone (wide phones such as the 16 Pro Max have a stage over 760px, which used to bring
     back the desktop labels with everyone's names): galaxy name only, one line, no "Pick a galaxy" box */
  body[data-screen="map"] .gx-who { display: none; }
  body[data-screen="map"] .gx-card, body[data-screen="map"] .gx-hq .gx-card { width: auto; min-width: 0; min-height: 36px; box-sizing: border-box; justify-content: center; gap: 2px; padding: 6px 10px; border-radius: 2px; white-space: nowrap; }   /* 6 Dec: 10px each side of the words on every box (was the galaxy's width with 6px) */
  body[data-screen="map"] .gx-name { font-size: 14px; line-height: 1.1; text-box: trim-both cap alphabetic; }   /* Ivyora has extra space under the letters, which made the names sit high in their boxes */
  /* the ring spread out from the middle (40% wider, 10% taller) so the galaxies use the whole phone; --cx/--cy is each
     icon's centre in % of the map (game.js), --ty an extra lift for single galaxies */
  body[data-screen="map"] .gx { translate: calc((var(--cx) - 50) * .4cqw) calc((var(--cy) - 45) * .056cqw + var(--ty, 0px)); }
  /* HQ: a shorter lock line and a little higher, so its label never touches the galaxies below it */
  body[data-screen="map"] .gx-hq { --ty: 9px; }   /* 6 Dec: 35px lower than before, now the ring is spread out */
  body[data-screen="map"] .gx-hq .gx-name { font-size: 13px; }
  body[data-screen="map"] .gx-hq.locked .gx-card::after { content: '🔒 Meet 4 of us to open'; margin-top: 2px; font-size: 11px; }
  .mute { width: 48px; height: 48px; padding: 0; display: grid; place-items: center; box-sizing: border-box; }
  .mute svg { width: 16px; height: 16px; }

  /* ---------- 5–8 · On a planet: the 3D world uses the whole screen, not a 16:9 strip ---------- */
  body.planet-3d[data-screen="planet"] #stage { width: 100vw; height: 100dvh; }
  body.planet-3d[data-screen="planet"] .planet-map { right: 70px; width: 48px; height: 48px; padding: 0; display: grid; place-items: center; box-sizing: border-box; }   /* 10px left of the 48px sound icon */
  body.planet-3d[data-screen="planet"] .next-person { right: max(12px, env(safe-area-inset-right)); bottom: 12px; min-height: 48px; padding-inline: 14px; }
  body.touch-ui.planet-3d .w3d-joy { left: max(14px, env(safe-area-inset-left)); bottom: 14px; width: 96px; }
  /* the faces row: smaller badges, so it never reaches the Next button */
  body[data-screen="planet"] .sb-bar.planet { bottom: 10px; padding: 4px 8px; }
  body[data-screen="planet"] :is(.sb-bar.planet, .sb-people) .sb-ava { width: 32px; height: 32px; }
  body[data-screen="planet"] .sb-bar.planet .sb-count { font-size: 12px; }
  body[data-screen="planet"] :is(.sb-bar.planet .sb-row, .sb-people) { gap: 0 8px; }
  /* 7 · talking: the conversation sits low, its bottom edge level with the joystick and the Next button, so it never
     covers the people (it used to sit mid-screen, over the player on short phones such as the Galaxy S23) */
  body.talk-demo .sb-speech { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); width: min(58vw, 520px); height: auto; min-height: 92px; transform: translate(-50%, 6px); }
  body.talk-demo .sb-speech.on { transform: translate(-50%, 0); }
  body.talk-demo .sb-face .sb-ava { width: 40px; height: 40px; }
  body.talk-demo .sb-words h3 { font-size: 20px; }
  body.talk-demo .sb-words p { font-size: 15px; line-height: 1.45; }
  body.talk-demo .sb-more:not([hidden]) { font-size: 18px; right: 12px; bottom: 8px; }
  body.talk-demo .sb-bar { top: 108px; left: 12px; }   /* 9px under the planet name box (it overlapped it by 7px) */
  body.talk-demo .sb-chips { gap: 6px; flex-wrap: wrap; }   /* five strengths fit the box on the smallest phones */
  /* 12 · planet complete card fits the short screen */
  .planet-done { width: min(78vw, 30em); padding: 16px 20px; font-size: 14px; }
  .planet-done .btn { min-height: 48px; padding-inline: 16px; }
  .planet-done #pdGo { background: #fcb24f; border-color: #fcb24f; color: #000; }

  /* ---------- 9 · 10 · 11 · the side panel (object card, quiz, menu): slides in from the right ---------- */
  .chat.obj-card, body.in-chat .chat, .ph-panel:not([hidden]) {
    position: absolute; z-index: 60; left: auto; right: min(0px, calc((100cqw - 100vw) / 2)); top: 0; bottom: 0; translate: none; transform: none;
    width: min(44vw, 400px); max-width: none; box-sizing: border-box; display: flex; flex-direction: column; gap: 12px;
    padding: 14px max(16px, env(safe-area-inset-right)) 14px 18px; overflow-y: auto;
    background: #1f1f1f; border: 0; border-radius: 16px 0 0 16px; box-shadow: -8px 0 30px rgba(0, 0, 0, .45); animation: phIn .25s ease-out both;
  }
  body.in-chat .chat { width: min(52vw, 460px); }   /* the quiz needs room for four answers */
  .ph-menu:not([hidden]) { width: min(46vw, 340px); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .55); }   /* dims the map behind the menu */
  /* "‹ Name": back to the chat (closes the panel, phone.js) */
  .chat.obj-card .chat-name, body.in-chat .chat .chat-name { align-self: flex-start; min-height: 48px; box-sizing: border-box; display: inline-flex; align-items: center; padding: 0 12px; border: 1.5px solid #fff; border-radius: 2px; color: #fff; font: 500 12px / 1 Inter, system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
  .chat.obj-card .chat-name::before, body.in-chat .chat .chat-name::before { content: '‹\00a0'; }
  .chat.obj-card .chat-x, body.in-chat .chat .chat-x, body .ph-x { position: absolute; top: 10px; right: max(12px, env(safe-area-inset-right)); width: 48px; height: 48px; }
  .obj-card .chat-row { gap: 14px; align-items: flex-start; }
  .obj-card .obj-icon { flex: none; width: 58px; height: 58px; display: grid; place-items: center; }
  .obj-vox { width: 52px; height: 52px; }
  .obj-card .obj-title { margin: 0 0 8px; font: 400 18px / 1.25 'ivyora-display', Georgia, serif; color: #fff; }
  .obj-card .chat-line { font-size: 13px; line-height: 1.5; color: rgba(255, 255, 255, .85); }
  .chat.obj-card .chat-replies, body.in-chat .chat .chat-replies { margin-top: auto; }
  .chat.obj-card .chat-btn, body.in-chat .chat .chat-replies.single .chat-btn { width: 100%; justify-content: center; padding: 11px 14px; border: 0; border-radius: 0; background: #fcb24f; color: #000; font: 500 12px / 1.2 Inter, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; filter: none; }
  /* 10 · the quiz: the question, then four answers in a 2 × 2 grid; right answer green, wrong pick red */
  body.in-chat .chat .chat-face { display: none; }
  body.in-chat .chat .chat-line { font: 400 16px / 1.3 'ivyora-display', Georgia, serif; color: #fff; padding-right: 40px; }
  body.in-chat .chat .chat-replies:not(.single) { margin-top: 4px; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; align-items: stretch; gap: 8px; }
  body.in-chat .chat .chat-replies:not(.single) .chat-btn { width: 100%; min-height: 48px; justify-content: flex-start; text-align: left; padding: 8px 10px; border: 1.5px solid transparent; border-radius: 0; background: #3a3a3a; color: #fff; font: 400 12px / 1.3 Inter, system-ui, sans-serif; text-transform: none; letter-spacing: 0; filter: none; }
  body.in-chat .chat .chat-btn kbd { display: none; }
  /* 11 · the menu */
  .ph-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
  .ph-head h2 { margin: 0; font: 400 19px / 1 'ivyora-display', Georgia, serif; color: #fff; }
  body .ph-head .ph-x { position: relative; top: auto; right: auto; }
  .ph-item { display: grid; place-items: center; min-height: 48px; padding: 8px 12px; box-sizing: border-box; border: 1.5px solid #fff; border-radius: 0; background: none; color: #fff; font: 500 12px / 1.2 Inter, system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; text-decoration: none; cursor: pointer; }
  .ph-item:active, .ph-item:focus-visible { background: rgba(255, 255, 255, .12); outline: none; }
  .ph-credit { margin: auto 0 0; font: 400 11px / 1.4 Inter, system-ui, sans-serif; color: rgba(255, 255, 255, .7); }
  /* one name in the talk box is enough: the nameplate over the person steps aside while they talk or a panel is open */
  body.sb-speaking .w3d-markers, body.sb-speaking .name-tag, body:has(.obj-card:not([hidden])) .name-tag, body.in-chat .name-tag,
  body:has(.obj-card:not([hidden])) :is(.sb-bar, .sb-people, .next-person), body.in-chat :is(.sb-bar, .sb-people, .next-person) { visibility: hidden; }
  #letsGo, #s-howto .btn { min-height: 48px; }
  body.in-chat .chat[data-round]::before { top: 22px; right: 70px; font-size: 11px; }
  /* a side panel covers the top-right buttons, so they step aside while it is open */
  body:has(.obj-card:not([hidden])) .mute, body.in-chat .mute, body.ph-menu-open .mute, body.ph-menu-open .ph-menu-btn,
  body:has(.obj-card:not([hidden])) .planet-map, body.in-chat .planet-map, body:has(.obj-card:not([hidden])) .wk-btn, body.in-chat .wk-btn { visibility: hidden; }

  /* ---------- the corners: the same 12px from the screen edge on every screen (the title and map stage is a 16:9 box
     narrower than a wide phone, so its corner buttons used to sit ~100px in) ---------- */
  body:is([data-screen="title"], [data-screen="map"], [data-screen="planet"], [data-screen="howto"], [data-screen="board"]) .mute { right: calc(12px - (100vw - 100cqw) / 2); top: 12px; }
  body:is([data-screen="welcome"], [data-screen="intro"], [data-screen="finale"]) .mute { right: 8px; top: 8px; }   /* these keep the 16:9 stage, which clips anything outside it */
  body[data-screen="map"] .ph-menu-btn { right: calc(12px - (100vw - 100cqw) / 2 + 58px); top: 12px; }   /* 10px left of the sound button */
  body[data-screen="map"] #mapHud { left: calc(12px - (100vw - 100cqw) / 2); top: 12px; }
  body.planet-3d[data-screen="planet"] .planet-map { top: 12px; }
  /* map: the faces row centred, pictures only (the names ran into each other) */
  #s-map .faces { left: 50%; translate: -50% 0; bottom: 6px; }
  #s-map .face .nm { display: none; }
  body[data-screen="map"] #mapHud, body[data-screen="map"] #mapHud span { font-size: 12px; }
  .planet-hud .eyebrow { font-size: 11px; }
  /* the planet name box sits 8px under the People met box (it overlapped it by 4px on the Galaxy S23) */
  body.sb-on[data-screen="planet"] .planet-hud { top: 54px; }
  body.in-chat .chat .chat-replies:not(.single) { gap: 10px; }
  /* How to play: the floating window fits between the top buttons and the bottom, scrolling inside; the credits are in
     the ☰ menu on phones, so the bottom line is hidden here */
  #s-howto .howto { top: calc(50% + 14px); width: min(86vw, 720px); max-height: calc(100dvh - 76px); padding: 14px 18px 16px; font-size: 13px; }
  #s-howto .step-pic { height: 7em; }
  .howto-credits { display: none; }
  #s-howto kbd { display: none; }
  /* small text made readable */
  .sb-st small { font-size: 11px; }
  .ph-credit { font-size: 11px; padding-bottom: 4px; }
  /* side panels hug their content instead of leaving the bottom half empty */
  .chat.obj-card, body.in-chat .chat { bottom: auto; max-height: 100%; border-radius: 0 0 0 16px; padding-bottom: 18px; }
  .chat.obj-card .chat-replies, body.in-chat .chat .chat-replies { margin-top: 8px; }
  body.in-chat .chat[data-round]::before { top: 23px; }

  /* ---------- touch targets (gate, 4 Dec): everything you tap is at least 48 × 48 with 8px or more between, nothing is
     cut off, no box sits on another box, and no box covers the person you are talking to ---------- */
  /* How to play and the leaderboard use the whole screen, not the 16:9 box with black bars either side */
  body:is([data-screen="howto"], [data-screen="board"]) #stage { width: 100vw; height: 100dvh; }
  /* How to play fits without scrolling: no step pictures, the × clear of the heading, the window left of the sound button */
  #s-howto .howto { left: max(12px, env(safe-area-inset-left)); right: calc(max(12px, env(safe-area-inset-right)) + 58px); top: 50%; width: auto; max-height: calc(100dvh - 24px); transform: translateY(-50%); padding: 12px 16px 14px; }
  #s-howto .howto-x { top: 8px; right: 8px; width: 48px; height: 48px; }
  #s-howto .eyebrow, #s-howto h1 { margin-inline: 56px; }
  #s-howto h1 { font-size: 22px; }
  #s-howto .howto-story { margin-top: 6px; max-width: none; }
  #s-howto .steps { margin: 10px 0 8px; gap: 14px; }
  #s-howto .step-pic { display: none; }
  #s-howto .steps h2 { font-size: 15px; }
  #s-howto .steps p { max-width: none; }
  #s-howto .win { margin: 0 0 8px; }
  /* the intro's Skip: tall enough to tap, and no Esc key badge on a phone */
  #skipIntro { min-height: 48px; min-width: 96px; justify-content: center; }
  #skipIntro kbd { display: none; }
  /* the finale and the leaderboard */
  #s-finale .tv-btn { min-height: 48px; }
  #s-board .board { inset: 12px calc(max(12px, env(safe-area-inset-right)) + 58px) 12px max(12px, env(safe-area-inset-left)); gap: 12px; }
  #s-board .board .panel { max-height: calc(100dvh - 24px); box-sizing: border-box; overflow-y: auto; padding: 12px 14px; }
  #s-board .name-row { gap: 12px; }
  #s-board .name-row input, #s-board .name-row .btn, #s-board .board-actions .btn { min-height: 48px; box-sizing: border-box; }
  #s-board .name-row .btn { min-width: 64px; justify-content: center; }
  #s-board .board-actions { gap: 12px; margin-top: 8px; }
  #s-board .board-you form { margin-top: 10px; }
  .board-top li { padding: 3px 8px; font-size: 13px; }
  .board-top li b { font: 700 13px / 1.4 Inter, system-ui, sans-serif; letter-spacing: 0; }   /* the pixel font made 15,000 read as 18,000 */
  /* the map: the 15 faces can't fit a phone at a tappable size, so they live in the ☰ menu ("Meet the team", phone.js) */
  #s-map > .faces { display: none; }
  /* HQ: a narrower button and a smaller airship, so its tap area no longer runs into the four galaxies round it */
  body[data-screen="map"] .gx-hq { width: calc(270 * var(--fx)); margin-left: calc(135.5 * var(--fx)); }
  body[data-screen="map"] .gx-hq .gx-icon { width: calc(400 * var(--fx)); height: calc(400 * var(--fx)); }
  /* Branding and Marketing a little higher, clear of the long "Sustainability" label below them */
  body[data-screen="map"] :is([data-galaxy="branding"], [data-galaxy="marketing"]) { --ty: -26px; }
  /* Adrian's tip on phones: one line in the bottom-left corner ("Pick a galaxy", or why HQ is locked) */
  #s-map .map-tip { display: flex; align-items: center; gap: 8px; left: calc(max(12px, env(safe-area-inset-left)) - (100vw - 100cqw) / 2); right: auto; top: auto; bottom: max(12px, env(safe-area-inset-bottom)); translate: none; width: max-content; max-width: calc(100vw - 24px); box-sizing: border-box; font-size: 12px; white-space: nowrap; }
  #s-map .map-tip:not(:has(.tip-say)) { min-height: 36px; box-sizing: border-box; padding: 6px 10px; background: rgba(0, 0, 0, .75); border: 2px solid #fff; border-radius: 4px; }
  #s-map .map-tip b { display: inline; margin: 0 8px 0 0; font-size: 14px; text-box: trim-both cap alphabetic; }
  #s-map .map-tip .tip-face { width: 32px; height: 32px; }
  #s-map .map-tip .tip-say { display: flex; align-items: center; height: 36px; box-sizing: border-box; padding: 0 10px; font-size: 0; border-width: 2px; border-radius: 2px; background: rgba(0, 0, 0, .75); }   /* the same box as the galaxy names */
  #s-map .map-tip .tip-say b { margin: 0; }
  #s-map .map-tip .tip-say::before { display: none; }
  body.ph-menu-open #s-map :is(.map-labels, .map-tip) { visibility: hidden; }   /* the menu is a sheet over the map */
  /* the ☰ menu: narrower (clear of HQ on the Galaxy S23), its buttons two to a row so all of them fit without scrolling */
  .ph-menu:not([hidden]) { width: min(40vw, 320px); display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 10px; }
  .ph-menu > :is(.ph-head, .ph-credit, .faces) { grid-column: 1 / -1; }
  .ph-menu .ph-credit { margin-top: 2px; }
  .ph-item { text-align: center; }
  /* "Meet the team": the faces in the menu, 48px each */
  .ph-menu.team :is(.ph-item, .ph-credit) { display: none; }
  .ph-menu .faces { position: static; display: grid; grid-template-columns: repeat(5, 48px); justify-content: center; gap: 10px 8px; padding: 0; background: none; border: 0; translate: none; }
  .ph-menu .face { width: 48px; height: 48px; display: grid; place-items: center; }
  .ph-menu .face .pic { width: 44px; height: 44px; border-radius: 4px; }
  .ph-menu .face .initial { font-size: 18px; }
  .ph-menu .face :is(.nm, .tip) { display: none; }
  .ph-menu .face .tick { right: -4px; top: -4px; }
  /* the planet's corner buttons and the people strip */
  body.planet-3d[data-screen="planet"] .planet-map img { height: 30px; }
  body[data-screen="planet"] .sb-go { display: grid; place-items: center; width: 48px; height: 48px; }
  body[data-screen="planet"] .sb-bar.planet .sb-row { flex-wrap: wrap; row-gap: 2px; }
  body[data-screen="planet"] .sb-bar.planet .sb-count { order: -1; flex-basis: 100%; }   /* "Digital: 2 of 6 people" above the faces */
  /* the "Go to <name>" badges over people: an invisible 48px tap area round each badge */
  .w3d-mark::before { content: ''; position: absolute; left: -24px; top: calc(var(--s) * -.92 - 24px); width: 48px; height: 48px; border-radius: 50%; }
  .w3d-mark.edge::before { top: -24px; }
  /* the "Now landing" card sits clear of the people strip, and says tap, not key, on a touch screen */
  .w3d-title { bottom: calc(100px + env(safe-area-inset-bottom)); }
  body.touch-ui .w3d-title span { font-size: 0; }
  body.touch-ui .w3d-title span::after { content: 'Tap to skip'; font-size: 12px; }
  /* the planet-complete card sits low, like the talk box, so it never covers the person you just met */
  .planet-done { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); }
  /* the object card and the quiz slide in from the left: the camera keeps the person you face right of centre */
  /* 6 Dec: a floating card 12px off the left and top edges, rounded all round, the VS Code title-bar grey; it used to be a
     panel glued to the corner, which read as part of the screen rather than a pop-up */
  .chat.obj-card, body.in-chat .chat { left: max(12px, env(safe-area-inset-left)); right: auto; top: 12px; max-height: calc(100% - 24px); width: min(40vw, 340px);
    border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); padding: 12px 14px 14px; gap: 10px; animation-name: phInL; }
  body.in-chat .chat { width: min(50vw, 440px); }
  .chat.obj-card .chat-name, body.in-chat .chat .chat-name { min-height: 36px; padding: 0 10px; }
  .chat.obj-card .chat-x, body.in-chat .chat .chat-x { top: 12px; right: 12px; width: 36px; height: 36px; }
  /* the object card on phones: no "‹ Name" button, a small close in the corner, and the site as a text link (the
     ↗ is in the label), so the card is only as tall as its words */
  .chat.obj-card .chat-name { display: none; }
  .chat.obj-card { width: min(36vw, 290px); padding: 10px 12px 12px; gap: 8px; }
  .chat.obj-card .chat-x { top: 6px; right: 6px; width: 24px; height: 24px; border: 0; background: none; }   /* a plain ×, no box */
  .chat.obj-card .chat-x::before, .chat.obj-card .chat-x::after { width: 12px; }
  .chat.obj-card .obj-words { padding-right: 18px; }
  .chat.obj-card .chat-row { gap: 10px; }
  .chat.obj-card .obj-icon { width: 40px; height: 40px; }
  .chat.obj-card .obj-vox { width: 36px; height: 36px; min-width: 0; min-height: 0; }
  .chat.obj-card .obj-title { margin-bottom: 4px; font-size: 16px; }
  .chat.obj-card .chat-btn.link { width: auto; height: auto; padding: 2px 0; border: 0; background: none; filter: none; color: #fcb24f;
    font: 600 13px / 1.3 Inter, system-ui, sans-serif; letter-spacing: 0; text-transform: none; justify-content: flex-start; }
  .chat.obj-card .chat-btn.link:is(:hover, :focus-visible) { text-decoration: underline; }
  .chat.obj-card .chat-replies { justify-content: flex-start; padding-left: 50px; }   /* lines up with the words, not the icon */
  /* the same button as the title screen: 36px tall, 2px border, 4px corners, 12px caps, hard black shadow */
  .chat.obj-card .chat-btn, body.in-chat .chat .chat-replies.single .chat-btn { height: 36px; min-height: 0; box-sizing: border-box; padding: 0 18px; border: 2px solid #fcb24f; border-radius: 4px;
    font: 600 12px / 1.3 Inter, system-ui, sans-serif; letter-spacing: .04em; filter: drop-shadow(0 3px 0 #000); }
  body:has(.obj-card:not([hidden])) :is(.planet-hud, .sb-score), body.in-chat :is(.planet-hud, .sb-score, .w3d-joy) { visibility: hidden; }

  /* ---------- round 2 of the gate (4 Dec) ---------- */
  /* "Next planet: Sustainability ›" wraps to two lines, so it never reaches the people strip; and Next steps aside while
     someone is talking, like the strip (the talk box filled the space between it and the joystick on an iPhone) */
  body.planet-3d[data-screen="planet"] .next-person { max-width: 150px; white-space: normal; line-height: 1.25; text-align: center; padding-inline: 12px; }
  body.sb-speaking .next-person { visibility: hidden; }
  /* iPhones: everything stays clear of the notch and the home bar (env() is 0 on Android, so nothing moves there) */
  body.planet-3d[data-screen="planet"] .next-person { bottom: max(12px, env(safe-area-inset-bottom)); }
  body.touch-ui.planet-3d .w3d-joy { bottom: max(14px, env(safe-area-inset-bottom)); }
  body.talk-demo .sb-bar, body[data-screen="planet"] :is(.sb-score, .planet-hud) { left: max(12px, env(safe-area-inset-left)); }
  body:is([data-screen="title"], [data-screen="map"], [data-screen="planet"], [data-screen="howto"], [data-screen="board"]) .mute { right: calc(max(12px, env(safe-area-inset-right)) - (100vw - 100cqw) / 2); }
  body[data-screen="map"] .ph-menu-btn { right: calc(max(12px, env(safe-area-inset-right)) - (100vw - 100cqw) / 2 + 58px); }
  body[data-screen="map"] #mapHud { left: calc(max(12px, env(safe-area-inset-left)) - (100vw - 100cqw) / 2); }
  body.planet-3d[data-screen="planet"] .planet-map { right: calc(max(12px, env(safe-area-inset-right)) + 58px); }
  body[data-screen="planet"] .wk-btn { right: calc(max(12px, env(safe-area-inset-right)) + 116px); }
  /* the welcome card's line readable on a phone (it was 10px) */
  #welcome-h { font-size: 13px; line-height: 1.4; }
  #s-welcome .iw-card { margin-top: 8px; }   /* 10px under the sound button, so a slightly missed tap on it doesn't skip the card */
  /* counts in Inter, like the leaderboard: the pixel font's 5 reads as an S ("0/15" looked like "0/1S") */
  body[data-screen="map"] #mapHud .n, body[data-screen="planet"] .sb-score b { font: 700 13px / 1 Inter, system-ui, sans-serif; letter-spacing: 0; }
  .sb-head .n { font-family: Inter, system-ui, sans-serif; font-weight: 700; letter-spacing: 0; }

  /* ---------- round 3 of the gate (4 Dec) ---------- */
  /* the intro caption: a small box at the bottom left, sized to its text (the heading and the line being read, not
     space kept for lines still to come), so the picture the narrator describes stays in view */
  #s-intro .intro-text { left: 12px; right: auto; bottom: 12px; max-width: 45cqw; padding: 10px 14px 12px; }
  #s-intro .intro-text h2 { font-size: 18px; line-height: 1.15; margin-bottom: 6px; }
  #s-intro .intro-text p { font-size: 13px; margin-top: 0; }
  #s-intro .intro-text p:not(.on), #s-intro .intro-text p.on:has(+ p.on) { display: none; }
  #s-intro .intro-text p.on { animation: rise .6s ease-out both; }
  #skipIntro { bottom: max(10px, env(safe-area-inset-bottom)); }
  /* the planet-complete card: one low strip (words left, the two buttons right), so it never covers the person you just met */
  .planet-done { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 16px; width: min(calc(100vw - 2 * max(14px, env(safe-area-inset-left))), 760px); padding: 10px 12px 10px 18px; text-align: left; }
  .planet-done .pd-eyebrow { margin: 0 0 4px; font-size: 16px; }
  .planet-done #pdText { margin: 0; line-height: 1.35; }
  .planet-done .pd-row { grid-column: 2; grid-row: 1 / span 2; flex-wrap: nowrap; gap: 10px; }
  .planet-done .btn { padding-inline: 14px; }
  /* the joystick steps aside under an object card too (a card with a "Visit their site" button reached it on 360px phones) */
  body:has(.obj-card:not([hidden])) .w3d-joy { visibility: hidden; }
  /* the blinking ▶▶ never prints over the last word: room for it at the end of the line */
  body.talk-demo .sb-words p::after { content: ''; display: inline-block; width: 36px; }
  /* the people strip already names the planet, so the planet name box goes and the strengths box moves up into its place */
  body.sb-on[data-screen="planet"] .planet-hud { display: none; }
  body.talk-demo .sb-bar { top: 54px; }

  /* ---------- round 4 of the gate (4 Dec) ---------- */
  /* iPhones: the people strip stays above the home bar, level with the joystick and the Next button */
  body[data-screen="planet"] .sb-bar.planet, body[data-screen="planet"] .sb-people { bottom: max(10px, env(safe-area-inset-bottom)); }
  /* the quiz and the strength names readable on a phone: a slightly wider quiz panel (it still stops short of the person
     you face, who stands right of centre), so bigger answers fit the short screen */
  body.in-chat .chat { width: min(54vw, 480px); }
  body.in-chat .chat .chat-replies:not(.single) .chat-btn { padding-block: 7px; font-size: 13px; line-height: 1.25; }
  body.in-chat .chat[data-round]::before { font-size: 12px; }
  .sb-st small { font-size: 13px; }
  body.talk-demo .sb-speech { width: min(62vw, 540px); }   /* room for five 13px names in one row (two rows reached the person's feet) */
}
/* an empty subtitles box drew a small empty frame under the intro card */
.captions:empty { display: none; }
/* the planet-complete card replaces the speech box, every screen size */
body:has(#planetDone:not([hidden])) :is(.sb-speech, .w3d-markers, .name-tag, .sb-bar, .sb-people, .next-person, .w3d-joy, #talkBtn) { visibility: hidden; }
/* quiz answers, every screen size: the right one green, a wrong pick red */
.chat-btn.right { border-color: #00bd8c !important; background: rgba(0, 189, 140, .25) !important; }
.chat-btn.wrong { border-color: #e5484d !important; background: rgba(229, 72, 77, .25) !important; }
@keyframes phIn { from { transform: translateX(40px); opacity: 0; } }
@keyframes phInL { from { transform: translateX(-40px); opacity: 0; } }
/* How to play: the keyboard line on keyboards, the joystick line on touch screens */
.touch-only { display: none; }
body.touch-ui .touch-only { display: inline; }
body.touch-ui .kb-only { display: none; }
@media (prefers-reduced-motion: reduce) { .turn-phone .tp-icon { animation: none; } }

/* 6 Dec: on a phone held sideways every dialogue is one wide, short strip along the bottom (the user's reference: a
   phone game's talk box): #1f1f1f, 15px white words, the speaker's name (or the strength) as a tab on the top edge.
   It replaces the speech bubble over the head (4 Dec) and the corner card. Placed last so it wins over the talk-demo and
   side-panel rules above. */
@media (orientation: landscape) and (max-height: 500px) {
  body.touch-ui .sb-speech { left: 50%; right: auto; top: auto; bottom: max(12px, env(safe-area-inset-bottom)); width: min(62vw, 560px); max-width: none; height: auto; min-height: 0;
    box-sizing: border-box; display: block; padding: 14px 40px 11px 16px; background: #1f1f1f; border: 1px solid rgba(255, 255, 255, .16); border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45); transform: translate(-50%, 6px); }
  body.touch-ui .sb-speech.on { transform: translate(-50%, 0); }
  body.touch-ui .sb-speech :is(.sb-face, .sb-role) { display: none; }
  body.touch-ui .sb-speech h3 { position: absolute; left: 12px; top: -11px; margin: 0; padding: 4px 8px 3px; background: #0b0b0e; border: 2px solid #fcb24f; border-radius: 4px;
    color: #fcb24f !important; font: 400 11px / 1 var(--font-pixel); letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
  body.touch-ui .sb-speech .sb-words p { font-size: 15px; line-height: 1.4; color: #fff; }
  body.touch-ui .sb-speech .sb-words p::after { width: 0; }
  body.touch-ui .sb-speech .sb-more:not([hidden]) { right: 12px; bottom: 9px; font-size: 13px; }
  /* the strip takes the bottom middle: the people row and the "go to" badges step aside while someone talks */
  body.touch-ui.sb-speaking :is(.w3d-markers, .sb-people, .sb-bar.planet) { visibility: hidden; }

  /* the object card: the same strip, icon on the left, the site as a text link under the words */
  .chat.obj-card { left: 50%; right: auto; top: auto; bottom: max(12px, env(safe-area-inset-bottom)); translate: -50% 0; width: min(62vw, 560px); max-height: 70%;
    padding: 12px 36px 12px 14px; gap: 6px; background: #1f1f1f; border: 1px solid rgba(255, 255, 255, .16); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); animation: none; }
  .chat.obj-card .obj-words { padding-right: 0; }
  .chat.obj-card .obj-title { font-size: 17px; }
  .chat.obj-card .chat-line { font-size: 14px; line-height: 1.45; color: #fff; }
  .chat.obj-card .chat-replies { margin-top: 0; }

  /* every phone button has the title screen's proportions: 36px tall, one line, 18px each side, 12px text, 4px corners
     (6 Dec: the menu's two-line buttons left "↗" on a line of its own) */
  :is(.iw-btn, #letsGo, #s-howto .btn, .planet-done .btn, #s-board .name-row .btn, #s-board .board-actions .btn, #s-finale .tv-btn, .ph-item) {
    height: 36px; min-height: 0; padding-block: 0; padding-inline: 18px; box-sizing: border-box; border-radius: 4px; font-size: 12px; white-space: nowrap; }
  #s-board .name-row input { height: 36px; min-height: 0; }
  .ph-item { display: flex; align-items: center; justify-content: center; border-width: 2px; font-weight: 600; letter-spacing: .04em; }
  .ph-menu:not([hidden]) { width: min(48vw, 380px); gap: 8px; }
  body .ph-head .ph-x { width: 28px; height: 28px; border: 0; background: none; }   /* the same small plain × as the object card */
}
