/* Phone-only layout fixes, loaded after the Windows app's own styles (only shipped in the Android app).
   Everything is scoped to html.phone-app (set by phone-ui.js) and to phone widths, so a tablet or the
   Windows app keeps its own look. */

/* The Windows app hides Import / Export in windows under 760 px; on a phone they are the only way to move a library.
   (The in-round and host-flow rules that hide them use !important and still win.) */
.roster-head .actions :is(#import, #export) { display: inline-flex; }

/* Splash while the app starts (index.html, build-web.mjs): the logo and a moving bar, instead of the Library
   page showing underneath. It fades as soon as the title, Home or a screen of the app is up. */
#phone-splash { position: fixed; inset: 0; z-index: 400; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: #0b0b10; color: #f4f4f8; transition: opacity .35s ease, visibility 0s linear .35s; }
#phone-splash img { width: 64px; height: 64px; }
#phone-splash b { display: grid; text-align: center; font: 700 14px/1.1 system-ui, sans-serif; letter-spacing: 6px; }
#phone-splash b span { font-size: 34px; letter-spacing: 3px; color: #d4f88c; }
#phone-splash i { position: relative; width: 140px; height: 3px; overflow: hidden; background: rgba(255, 255, 255, .12); }
#phone-splash s { position: absolute; inset: 0; width: 40%; background: #d4f88c; animation: phone-splash-bar 1.1s ease-in-out infinite; }
#phone-splash small { font: 600 12px system-ui, sans-serif; letter-spacing: 2px; color: rgba(244, 244, 248, .6); text-transform: uppercase; }
@keyframes phone-splash-bar { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
body:is(.title-on, .home-on, .in-round, .host-flow, .library-page, .online-mode) #phone-splash { opacity: 0; visibility: hidden; pointer-events: none; }

/* Stream window: full screen inside the app, with a way back */
dialog.phone-stream { position: fixed; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg, #0b0b10); display: none; }
dialog.phone-stream[open] { display: flex; flex-direction: column; }
dialog.phone-stream::backdrop { background: #000; }
.phone-stream-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--ink); }
.phone-stream-bar button { min-height: 44px; }
.phone-stream iframe { flex: 1; width: 100%; border: 0; background: var(--bg, #0b0b10); }

/* Update available (phone-update.js): a quiet strip at the top of Home, and the version lines in About */
.phone-update { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--lime); background: var(--bg, #0b0b10); color: var(--ink); font-size: 14px; }
.phone-update-text { flex: 1 1 220px; }
.phone-update-actions { display: flex; align-items: center; gap: 8px; }
.phone-update-actions button { min-height: 44px; }
.phone-update-actions .close { min-width: 44px; }
.phone-version { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.phone-version .dialog-actions button { min-height: 44px; }
.phone-update-status:empty { display: none; }

/* ---------- 1.0.5 phone navigation (phone-nav.js) ---------- */
/* Bottom bar: Home, Library, History, Settings, outside rounds. */
.phone-tabbar { display: none; }
html.phone-tabbar-on .phone-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 4px 6px max(6px, env(safe-area-inset-bottom)); background: var(--bg, #0b0b10); border-top: 1px solid var(--line); }
.phone-tabbar button { position: relative; display: grid; justify-items: center; gap: 2px; min-height: 52px; padding: 6px 2px 4px; background: none; border: 0; color: var(--soft); font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; }
.phone-tabbar button[aria-current=page] { color: var(--lime); }
.phone-tabbar button[aria-current=page]::before { content: ''; position: absolute; top: -5px; left: 30%; right: 30%; height: 3px; background: var(--lime); }
.phone-tab-count { position: absolute; top: 2px; left: calc(50% + 8px); min-width: 18px; padding: 1px 5px; border-radius: 9px; background: var(--purple); color: var(--purple-ink, #120b1c); font-size: 10px; line-height: 14px; }
html.phone-tabbar-on body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
html.phone-tabbar-on .home .home-scroll { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
/* The text tabs under the logo, and the "?" and Quit buttons, are replaced by the bar and the menu. */
html.phone-tabbar-on .topbar .main-nav { display: none !important; }
html.phone-app body:is(.in-round, .host-flow):not(.home-on) .topbar #home-nav { display: none !important; }
html.phone-app .topbar .topbar-end > :is(#tour-open, #quit) { display: none; }
/* ☰ menu: a sheet from the right. */
.phone-menu-button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; background: none; border: 2px solid var(--line2, var(--line)); color: var(--ink); }
dialog.phone-menu { position: fixed; inset: 0 0 0 auto; width: min(300px, 82vw); height: 100dvh; max-height: none; margin: 0; padding: 0 0 env(safe-area-inset-bottom); border: 0; border-left: 1px solid var(--line); background: var(--bg, #0b0b10); color: var(--ink); }
dialog.phone-menu[open] { display: flex; flex-direction: column; }
dialog.phone-menu::backdrop { background: rgba(0, 0, 0, .55); }
.phone-menu-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px 18px; border-bottom: 1px solid var(--line); }
.phone-menu-head b { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--lime); }
.phone-menu-close { display: grid; place-items: center; width: 44px; height: 44px; background: none; border: 0; color: var(--ink); }
.phone-menu-item { display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 0 18px; background: none; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); color: var(--ink); font-size: 15px; font-weight: 600; text-align: left; }
.phone-menu-item svg { color: var(--lime); flex: none; }
.phone-menu-item:last-child { margin-top: auto; border-top: 1px solid var(--line); color: var(--soft); }
/* Ask panel: Ask / Log / Chat as icons with a small label. */
.notes .panel-tabs button[data-panel-tab] { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; }
.notes .panel-tabs button[data-panel-tab]::before { content: ''; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--tab-icon) center / contain no-repeat; mask: var(--tab-icon) center / contain no-repeat; }
.notes .panel-tabs [data-panel-tab=ask] { --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z'/%3E%3Cpath d='M10 9.5a2 2 0 1 1 2.8 1.8c-.5.3-.8.7-.8 1.2V13M12 16h.01'/%3E%3C/svg%3E"); }
.notes .panel-tabs [data-panel-tab=log] { --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01'/%3E%3C/svg%3E"); }
.notes .panel-tabs [data-panel-tab=chat] { --tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M4 5h11v8H8l-4 3z'/%3E%3Cpath d='M15 9h5v8l-3-2h-6v-2'/%3E%3C/svg%3E"); }

/* Settings > Report a problem (phone-ui.js): its own section, the tab across a full row of the section grid. */
.settings-nav .phone-report-tab { grid-column: 1 / -1; }
/* A red bar, so problems have one obvious place to go. */
.settings-nav button.phone-report-tab { position: relative; isolation: isolate; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; margin-top: 6px; color: #fff; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; background: none; border: 0; }
.settings-nav button.phone-report-tab::before { content: ''; position: absolute; inset: 0; z-index: -1; transform: skewX(var(--skew, -13deg)); background: linear-gradient(90deg, #d8323c, #a3141f); box-shadow: 4px 4px 0 #4a0a10; }
.settings-nav button.phone-report-tab::after { content: ''; order: -1; width: 18px; height: 18px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 21V4h11l-1.5 4L16 12H5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 21V4h11l-1.5 4L16 12H5'/%3E%3C/svg%3E") center / contain no-repeat; }
.settings-nav button.phone-report-tab.active::before { background: linear-gradient(90deg, #ff4b55, #c21a27); box-shadow: 4px 4px 0 #4a0a10, 0 0 0 2px #ffd0d3; }
.phone-menu-item.phone-menu-report { margin: 6px 12px; min-height: 50px; border: 0; color: #fff; background: linear-gradient(90deg, #d8323c, #a3141f); clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); }
.phone-menu-item.phone-menu-report svg { color: #fff; }
.phone-report { display: grid; gap: 12px; }
.phone-report p { margin: 0; }
.phone-report-field { display: grid; gap: 6px; font-weight: 700; }
.phone-report-field small { font-weight: 400; color: var(--soft); }
.phone-report :is(textarea, input[data-f=contact]) { width: 100%; padding: 10px; font: inherit; font-weight: 400; color: var(--ink); background: var(--field, rgba(255, 255, 255, .04)); border: 1px solid var(--line2, var(--line)); }
.phone-report textarea { min-height: 64px; resize: vertical; }
.phone-report input[data-f=contact] { min-height: 44px; }
.phone-report-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.phone-report-cats button { min-height: 40px; padding: 6px 12px; font-size: 12px; }
.phone-report-pics { display: grid; gap: 8px; }
.phone-report-label { font-weight: 700; }
.phone-report-label small { font-weight: 400; color: var(--soft); }
.phone-report-thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.phone-report-thumbs:empty { display: none; }
.phone-report-thumbs figure { position: relative; margin: 0; width: 86px; }
.phone-report-thumbs img { display: block; width: 86px; height: 140px; object-fit: cover; object-position: top; border: 1px solid var(--line); }
.phone-report-thumbs figcaption { margin-top: 4px; font-size: 11px; color: var(--soft); text-align: center; }
.phone-report-thumbs button { position: absolute; top: -8px; right: -8px; width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 2px solid var(--bg, #0b0b10); background: #d8323c; color: #fff; font-size: 18px; line-height: 1; }
.phone-report-add { justify-self: start; min-height: 44px; }
.phone-report-add[hidden] { display: none; }
.phone-report .phone-report-toggle input[type=checkbox] { width: 24px; height: 24px; }
.phone-report-toggle { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.phone-report-toggle small { color: var(--soft); }
.phone-report hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.phone-report-status:empty { display: none; }
.phone-report details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--soft); }
.phone-report pre { margin: 0; max-height: 260px; overflow: auto; padding: 10px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.4; color: var(--soft); background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.phone-report .dialog-actions { flex-wrap: wrap; gap: 8px; }
.phone-report .dialog-actions button { min-height: 44px; }

@media (max-width: 760px) {
  html.phone-app body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }

  /* Top bar: the brand is the Home link, give it a full tap height. */
  html.phone-app .topbar .brand { min-height: 44px; }

  /* Library / board media tabs: all five fit the width instead of running off the right edge. */
  html.phone-app .browse-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; width: 100%; }
  html.phone-app .browse-tabs button { min-width: 0; padding: 8px 2px; font-size: 10.5px; letter-spacing: .4px; line-height: 1.2; overflow-wrap: anywhere; }
  html.phone-app .browse-tabs button[hidden] { display: none; }

  /* Online results: a list down the page, not a sideways row cut off at the edge. */
  html.phone-app .online-results { display: grid; overflow: visible; padding-bottom: 8px; }
  html.phone-app .online-results li { flex: none; }
  html.phone-app .online-results b { white-space: normal; }

  /* Character tiles: names get two short lines instead of "CLOUD S…". */
  html.phone-app .character .copy h3 { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 12.5px; line-height: 1.15; overflow-wrap: anywhere; }

  /* Home: Daily, Blitz and Weekly cards put their button under the text, so the text is not squeezed into a strip. */
  html.phone-app .home-card { flex-wrap: wrap; }
  html.phone-app .home-card > :is([id$="-action"], .cta) { flex: 1 1 100%; }
  html.phone-app .home-card > [id$="-action"] .cta { width: 100%; }
  html.phone-app .home-card .kicker { letter-spacing: 2px; }
  html.phone-app .home-pool-open { min-width: 44px; }

  /* Host flow and Solo: the bottom bar is solid, so the page under it does not show through. */
  html.phone-app :is(.step-track, .profile-dialog .dialog-actions) { background: var(--bg, #0b0b10); }
  html.phone-app .flow-foot { background: var(--bg, #0b0b10); padding-bottom: max(10px, env(safe-area-inset-bottom)); }

  /* Pick step: the "versus" mark between the slots sat on top of the first slot's text; a phone leaves it out. */
  html.phone-app #seams .seam { display: none; }
  /* Pick slots: shorter (two players took 600 px before the roster even started), and the character's
     name wraps between words at a size that fits ("CLOUD STRIF" was cut off). */
  html.phone-app .slot { height: 236px; }
  html.phone-app .slot-body, html.phone-app .slot:not(:last-child) .slot-body { left: 16px; bottom: 16px; width: 56%; }
  html.phone-app .slot h3 { font-size: clamp(20px, min(8.5cqi, 13cqh), 32px); line-height: .95; overflow-wrap: normal; word-break: normal; -webkit-line-clamp: 3; }
  html.phone-app .slot.is-empty h3 { font-size: clamp(18px, min(7cqi, 10cqh), 26px); }
  html.phone-app .slot p { font-size: 12.5px; line-height: 1.3; }

  /* Send step: Share is the main action (full width), Copy and Save sit under it. */
  html.phone-app .send-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  html.phone-app .send-actions .phone-share { grid-column: 1 / -1; order: -1; }
  html.phone-app .send-actions button { min-height: 44px; min-width: 0; }
  html.phone-app .private-actions { display: flex; flex-wrap: wrap; gap: 8px; }
  html.phone-app .private-actions .phone-share { flex: 1; }

  /* Settings: the section buttons wrap onto rows instead of a sideways strip cut at "H…". */
  html.phone-app .settings-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; overflow: visible; }
  html.phone-app .settings-nav button { min-height: 44px; padding: 6px 4px; font-size: 14px; text-align: center; }
  html.phone-app .settings-dialog :is([aria-label^="Use colour"], .pack-colour) { min-width: 40px; min-height: 40px; }
  html.phone-app .settings-dialog input[type=range] { min-height: 44px; }

  /* How to play chapters wrap too. */
  html.phone-app .howto-chapters { flex-wrap: wrap; overflow: visible; }
  html.phone-app .howto-chapters button { min-height: 44px; }

  html.phone-app dialog input[type=checkbox] { width: 24px; height: 24px; }

  /* Ask panel in a round: a split view. The panel takes the bottom part of the screen (about 45%, drag its top
     bar to change it, phone-ui.js), the board stays in view and scrolls above it, so you can see who is left
     while you build the next question. Before, the panel covered the whole board. */
  html.phone-app body.in-round.notes-open .notes { height: var(--phone-sheet-h, 45dvh) !important; min-height: 0; padding-top: 0; }
  html.phone-app body.in-round.notes-open main { padding-bottom: calc(var(--phone-sheet-h, 45dvh) + 8px); }
  html.phone-app body.in-round.notes-open #library-section .toolbar { position: static; }
  html.phone-app body.in-round .notes { background: var(--bg, #0b0b10) !important; }
  html.phone-app body.in-round .notes #sheet-bar { min-height: 36px; touch-action: none; cursor: ns-resize; }
  html.phone-app body.in-round.notes-open .notes #sheet-bar { min-height: 26px; height: 26px; padding-block: 0; overflow: hidden; }
  html.phone-app body.in-round .notes .panel-tabs button { min-height: 38px; padding-block: 6px; }
  html.phone-app body.in-round .notes .panel-final { padding-block: 6px; }
  html.phone-app body.in-round .notes .panel-final .final-hint { display: none; }
  html.phone-app body.in-round .notes #round-final { min-height: 44px; }
  /* The question builder and Ask come first; Solo's mystery card and clue buttons, and the idea box, after. */
  html.phone-app body.in-round .notes .qa-compose { display: flex; flex-direction: column; gap: 10px; }
  html.phone-app body.in-round .notes .qa-compose > .ask-compose { order: 1; gap: 8px; }
  html.phone-app body.in-round .notes .qa-compose > .solo-clues { order: 2; }
  html.phone-app body.in-round .notes .qa-compose > .idea-box { order: 3; }
  html.phone-app body.in-round .notes .ask-note { font-size: 12.5px; margin: 0; }
  html.phone-app body.in-round .notes .solo-mystery .ch-portrait { max-height: 120px; }
  html.phone-app body.in-round .notes .ask-send { min-height: 44px; }

  /* Answer window (online, when someone asks you): the question and Yes / No / … come first, your card and its
     traits under them to check. Before, the answer buttons were about 1,150 px down, below the card. */
  html.phone-app #answer-window[open] { display: flex; flex-direction: column; }
  html.phone-app #answer-window > .answer-window-head { order: 1; }
  html.phone-app #answer-window > .answer-question { order: 2; margin-bottom: 14px; }
  html.phone-app #answer-window > .answer-held { order: 3; }
  html.phone-app #answer-window .answer-choices .yn { min-height: 44px; flex: 1 1 30%; }

  /* First-time tips: the same words in a compact box, so less of the screen (and its main button) is covered. */
  html.phone-app .tip-bubble { width: min(320px, calc(100vw - 24px)); gap: 4px; padding: 10px 12px; }
  html.phone-app .tip-bubble b { font-size: 14.5px; }
  html.phone-app .tip-bubble p { font-size: 13px; line-height: 1.4; }
  html.phone-app .tip-bubble .row { margin-top: 2px; }
  html.phone-app .tip-bubble .row button { min-height: 40px; }
  html.phone-app .tip-bubble .cta { font-size: 14px; padding: 4px 14px; }

  /* Keyboard shortcut labels mean nothing on a touch screen. */
  html.phone-app kbd { display: none; }

  /* Small "?" and text buttons: a full-size touch area around the same small look. */
  html.phone-app .term { position: relative; }
  html.phone-app .term::after { content: ''; position: absolute; inset: -12px; }
  html.phone-app :is(.linkish, .quiet) { min-height: 44px; }
  html.phone-app dialog :is(.seg button, .cta.small) { min-height: 44px; }

  /* Character profile header: long names and franchises break between words, never inside them ("Poké/mon"). */
  html.phone-app .profile-dialog :is(h1, h2, h3, .kicker, #read-media, #read-franchise) { word-break: normal; overflow-wrap: normal; hyphens: manual; }
  /* The franchise gets its own line; favourite, previous / next and close sit on the row under it. */
  html.phone-app .profile-fields > .dialog-head { flex-wrap: wrap; row-gap: 10px; }
  html.phone-app .profile-fields > .dialog-head > .profile-from { flex: 1 1 100%; min-width: 0; }
  html.phone-app #read-franchise { overflow-wrap: break-word; }
  html.phone-app .profile-fields > .dialog-head > .spacer { display: none; }
  html.phone-app .profile-fields > .dialog-head > .profile-browse { flex: 1 1 auto; min-width: 0; }
  /* One column in reading order: name, then franchise with favourite / previous / next / close, then the
     portrait, notes and traits, and the actions pinned at the bottom. (Before, close and browse sat under
     450 px of traits, so a profile could only be closed after scrolling.) */
  html.phone-app #detail-dialog .profile { display: flex; flex-direction: column; }
  html.phone-app #detail-dialog :is(.profile-art, .profile-fields) { display: contents; }
  html.phone-app #detail-dialog .profile-title { order: 1; }
  html.phone-app #detail-dialog .detail-portrait { order: 2; }
  html.phone-app #detail-dialog .profile-fields > .dialog-head { order: 3; margin: 12px 0 10px; }
  html.phone-app #detail-dialog #profile-read { order: 4; }
  html.phone-app #detail-dialog .trait-board { order: 5; }
  html.phone-app #detail-dialog .profile-fields > .fields { order: 6; }
  html.phone-app #detail-dialog #edit-note { order: 7; }
  /* The name, portrait and traits keep the profile's coloured card behind them. */
  html.phone-app #detail-dialog :is(.profile-title, .detail-portrait, .trait-board) { background: var(--lime); color: var(--lime-ink); margin-inline: 0; padding-inline: 18px; }
  html.phone-app #detail-dialog .profile-title { padding-top: 18px; }
  html.phone-app #detail-dialog .detail-portrait { padding-bottom: 14px; }
  html.phone-app #detail-dialog .trait-board { padding-block: 14px; margin-top: 14px; }
  /* Favourite, previous / next and close on one row under the franchise. */
  html.phone-app #detail-dialog .profile-fields > .dialog-head { flex-wrap: wrap; }
  html.phone-app #detail-dialog .profile-fields > .dialog-head > .profile-browse { flex: 1 1 0; }
  html.phone-app #detail-dialog .profile-fields > .dialog-head > :is(.close, #profile-fav) { flex: none; }
  html.phone-app #detail-dialog .profile-fields > .dialog-actions { order: 8; }

  /* ---------- Rounds: more of the screen for the board ---------- */
  /* Top bar: a slimmer strip in a round (the round has its own ← Leave). */
  html.phone-app body.in-round:not(.home-on) .topbar { padding-top: 6px; padding-bottom: 6px; min-height: 0; }
  html.phone-app body.in-round:not(.home-on) .topbar .brand :is(svg, img, .mark) { width: 32px; height: 32px; }
  /* One row on any phone font: in a round the logo alone is the Home link (the words made it wrap to two rows). */
  html.phone-app body.in-round:not(.home-on) .topbar { flex-wrap: nowrap; gap: 8px; }
  html.phone-app body.in-round:not(.home-on) .topbar .brand > span { display: none; }
  html.phone-app body.in-round:not(.home-on) .topbar .topbar-end { flex-wrap: nowrap; gap: 8px; margin-left: auto; }
  html.phone-app body.in-round:not(.home-on) .topbar :is(.topbar-end > *, #home-nav) { min-height: 40px; }
  /* Pinned panels are solid, so tiles scrolling under them never show through. */
  html.phone-app :is(#round-strip, #library-section .toolbar, .step-track, .flow-foot) { background: var(--bg, #0b0b10) !important; }
  /* The top bar too: on Home it was 96% solid, so the Character Library heading on the page under Home showed
     through it faintly. */
  html.phone-app .topbar, html.phone-app[data-pack] body.home-on .topbar { background: var(--bg, #0b0b10) !important; }
  /* Round panel: the same rows, closer together. */
  html.phone-app #round-strip { padding: 6px 12px; row-gap: 6px; }
  html.phone-app #round-strip :is(#round-leave, #round-mute, #round-emote) { min-width: 40px; width: 40px; min-height: 40px; height: 40px; padding: 0; }
  /* ← Leave, round, Your card, mute and emotes share one row (emotes used to wrap onto a row of their own). */
  html.phone-app #round-strip { column-gap: 6px; }
  html.phone-app #peek-card { padding: 6px 10px; font-size: 12px; min-height: 40px; }
  html.phone-app #turn-banner { padding: 7px 14px; font-size: 15px; min-height: 0; }
  /* The score, question count and strikes come first; the longer description fills what is left. */
  html.phone-app #round-meta { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
  html.phone-app #round-meta #round-stats { order: -1; flex: none; white-space: nowrap; color: var(--ink); }
  html.phone-app #round-meta #round-context { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Board toolbar: three short rows instead of five: tabs; search with Sort and Filter beside it;
     characters left, Hide crossed out, undo and redo. */
  html.phone-app body.board-on #library-section .toolbar {
    display: grid; grid-template-columns: minmax(68px, 1fr) auto auto auto; gap: 6px 4px; align-items: center; padding: 6px 0;
    grid-template-areas: "tabs tabs tabs tabs" "search search sort filter" "left hide undo redo";
  }
  html.phone-app body.board-on #library-section .toolbar > .browse-tabs { grid-area: tabs; }
  html.phone-app body.board-on #library-section .toolbar > .browse-tabs button { min-height: 40px; }
  html.phone-app body.board-on #library-section .toolbar > .search { grid-area: search; min-height: 44px; }
  html.phone-app body.board-on #board-tools, html.phone-app body.board-on #board-tools .board-menu { display: contents; }
  html.phone-app body.board-on #board-left { grid-area: left; justify-self: start; white-space: nowrap; padding: 0 4px; }
  html.phone-app body.board-on #board-hide { grid-area: hide; padding: 8px 7px; font-size: 10.5px; letter-spacing: 0; min-height: 40px; white-space: nowrap; }
  html.phone-app body.board-on #board-undo { grid-area: undo; }
  html.phone-app body.board-on #board-redo { grid-area: redo; }
  html.phone-app body.board-on #board-sort-open { grid-area: sort; }
  html.phone-app body.board-on #board-filter-open { grid-area: filter; }
  html.phone-app body.board-on :is(#board-sort-open, #board-filter-open) { min-height: 44px; padding: 6px 7px; font-size: 10.5px; letter-spacing: .2px; white-space: nowrap; width: 100%; }
  html.phone-app body.board-on :is(#board-undo, #board-redo) { min-width: 40px; min-height: 40px; justify-self: center; }

  /* While scrolling down the board the toolbar slides out of the way; scrolling up brings it back (phone-ui.js). */
  html.phone-app :is(#library-section .toolbar) { transition: transform .22s ease, opacity .22s ease; }
  html.phone-app.phone-tools-away #library-section .toolbar { transform: translateY(calc(-100% - 20px)); opacity: 0; pointer-events: none; }
  html.phone-app body.in-round .cards { gap: 6px; }

  /* One page in a round, as the Windows app does on tablets: the round panel stays pinned at the top, and the
     player panel (Correct / Wrong, "Pick a character for … to guess", online plates) and the board scroll
     together under it. Before, the panel never moved and the board was a small box below it. */
  html.phone-app body.in-round #library-section,
  html.phone-app body.in-round:not(.notes-open) #library-section { max-height: none; overflow: visible; }
  html.phone-app body.in-round #library-section .toolbar { top: var(--phone-strip-h, 0px); z-index: 34; }
  html.phone-app body.in-round main { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

  /* Library and Pick step toolbar: tabs; search with Favourites beside it; franchise and genre side by side. */
  html.phone-app body:not(.board-on) #library-section .toolbar {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; align-items: center; padding: 6px 0;
    grid-template-areas: "tabs tabs tabs tabs tabs tabs" "search search search search fav fav" "franchise franchise franchise genre genre genre";
  }
  html.phone-app body:not(.board-on) #library-section .toolbar > .browse-tabs { grid-area: tabs; }
  html.phone-app body:not(.board-on) #library-section .toolbar > .search { grid-area: search; min-height: 44px; }
  html.phone-app body:not(.board-on) #library-section .toolbar > #franchise { grid-area: franchise; min-width: 0; width: 100%; }
  html.phone-app body:not(.board-on) #library-section .toolbar > #genre { grid-area: genre; min-width: 0; width: 100%; }
  /* In a round (online card pick) Favourites and the franchise lists are not shown: search takes the row. */
  html.phone-app body.in-round:not(.board-on) #library-section .toolbar > .search { grid-column: 1 / -1; }
  html.phone-app body:not(.board-on) #library-section .toolbar > #favorites { grid-area: fav; min-height: 44px; padding: 6px 6px; font-size: 11px; letter-spacing: .4px; white-space: nowrap; width: 100%; overflow: hidden; text-overflow: ellipsis; }

  /* Home: the same cards, a little tighter, so more of Home fits on one screen. */
  html.phone-app .home-tile { padding: 16px 18px; gap: 6px; }
  html.phone-app .home-tile svg { width: 30px; height: 30px; }
  html.phone-app .home-tiles { gap: 10px; }

  /* ---------- Main tabs (Home, Library, History, Settings): one even row, nothing wraps ---------- */
  html.phone-app :is(body:not(.in-round, .host-flow), body.home-on) .main-nav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, auto); justify-content: space-between; gap: 2px; flex-wrap: nowrap; }
  html.phone-app .main-nav .nav { padding: 10px 6px; font-size: 12px; letter-spacing: .8px; white-space: nowrap; }
}

/* Library and Pick step: four columns at the normal screen zoom (the Windows app's phone layout had three),
   so more of the library is in view at once. */
@media (max-width: 760px) {
  html.phone-app body:not(.in-round) .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
}
/* Larger screen zoom on a narrow phone (layout 400 px or less): one column fewer everywhere, so names fit
   and tiles stay easy to tap. Board: small 4, normal 3, large 2. Library: 3. */
@media (max-width: 400px) {
  html.phone-app body:not(.in-round) .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html.phone-app body.in-round .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html.phone-app body.in-round[data-board-size=small] .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  html.phone-app body.in-round[data-board-size=large] .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 1.0.8 calm live game (phone-board.js) ---------- */
@media (max-width: 760px) {
  /* Board toolbar: one row (search, characters left, left only, Tools); the rest opens under it with Tools. */
  html.phone-app body.board-on #library-section .toolbar {
    grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; padding: 6px 0;
    grid-template-areas: "search left hide tools";
  }
  html.phone-app.phone-tools-open body.board-on #library-section .toolbar {
    grid-template-areas: "search left hide tools" "tabs tabs tabs tabs" "sort filter undo redo";
  }
  html.phone-app body.board-on #library-section .toolbar > .phone-tools-btn { grid-area: tools; }
  html.phone-app body.board-on #library-section .toolbar > .browse-tabs,
  html.phone-app body.board-on :is(#board-sort-open, #board-filter-open, #board-undo, #board-redo) { display: none; }
  html.phone-app.phone-tools-open body.board-on #library-section .toolbar > .browse-tabs { display: grid; }
  html.phone-app.phone-tools-open body.board-on :is(#board-sort-open, #board-filter-open, #board-undo, #board-redo) { display: inline-flex; align-items: center; justify-content: center; }
  html.phone-app body.board-on #board-left { font-size: 12px; padding: 0 2px; }
  /* "Left only": the app's Hide crossed out, as an eye button. */
  html.phone-app body.board-on #board-hide { grid-area: hide; width: 44px; min-width: 44px; height: 44px; padding: 0; font-size: 0; display: grid; place-items: center; }
  html.phone-app body.board-on #board-hide::after { content: ''; width: 22px; height: 22px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat; }
  html.phone-app body.board-on #board-hide[aria-pressed=true], html.phone-app body.board-on #cards.show-left ~ * #board-hide { color: var(--lime); border-color: var(--lime); }
  html.phone-app body.board-on #library-section .toolbar > .phone-tools-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 10px; font-size: 11px; }
  html.phone-app.phone-tools-open .phone-tools-btn { color: var(--lime); border-color: var(--lime); }
  /* The Library page keeps its own toolbar (tabs, search, favourites, franchise / genre): no Tools button there. */
  html.phone-app body:not(.board-on) .phone-tools-btn { display: none; }

  /* Round header: one slim row of controls and counts, the turn banner under it; the long description goes. */
  html.phone-app #round-strip { row-gap: 4px; padding-block: 4px; }
  html.phone-app #round-meta { order: 2; flex: 1 1 0; min-width: 0; }
  html.phone-app #round-meta #round-context { display: none; }
  html.phone-app #round-meta #round-stats { font-size: 11.5px; line-height: 1.2; white-space: normal; color: var(--soft); }
  html.phone-app #turn-banner { padding: 5px 12px; font-size: 14px; }
}

/* Fast-scroll handle on the right edge (phone-board.js): shows while scrolling a long board or library. */
.phone-scroller { position: fixed; right: 2px; top: calc(var(--phone-strip-h, 0px) + 84px); bottom: 90px; width: 30px; z-index: 35; pointer-events: none; opacity: 0; transition: opacity .25s; }
.phone-scroller.on.awake { opacity: 1; }
.phone-scroller.on .phone-scroller-thumb { pointer-events: auto; }
.phone-scroller-thumb { position: absolute; right: 2px; width: 26px; height: 54px; border-radius: 13px; background: var(--lime); box-shadow: 0 2px 10px rgba(0, 0, 0, .5); touch-action: none; }
.phone-scroller-thumb::before { content: ''; position: absolute; left: 8px; right: 8px; top: 21px; height: 12px; border-block: 2px solid var(--lime-ink, #111); }
.phone-scroller-bubble { position: absolute; right: 38px; top: 10px; display: none; max-width: 70vw; padding: 8px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--bg, #0b0b10); border: 2px solid var(--lime); color: var(--ink); font-weight: 700; font-size: 14px; }
.phone-scroller.dragging .phone-scroller-bubble { display: block; }
html:not(.phone-app) .phone-scroller { display: none; }

/* Settings > Sound: turn alerts (phone-alerts.js) */
.phone-alerts { display: grid; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.phone-alerts .phone-report-toggle input[type=checkbox] { width: 24px; height: 24px; }
.phone-alerts small { color: var(--soft); }
