/* phone-layout.css — the oddlyplay phone shell. Active only when phone-layout.js adds .phone to <html>.
   The stage fills the visible screen between a slim title bar and a thumb-reach dock; secondary settings live in one sheet. */
/* The game fills the first screen; the rest of the page continues below it. The stage itself never scrolls the page. */
html.phone { padding: 0 !important; overscroll-behavior-y: none; }
/* Before the shell is built the page is not shown, only its paper: the desktop arrangement would paint first and then jump into
   the phone one, a layout shift of 0.3 to 0.7. visibility (not display) keeps the page laid out, so nothing is rebuilt when it
   appears. phone-layout.js adds .op-ready when the shell stands, or after the page has loaded if it never does. */
html.phone:not(.op-ready) body { visibility: hidden; }
html.phone body { margin: 0 !important; }
html.phone .op-hidden { display: none !important; }
/* a host page's own .wrap often sets a real `width` (not `max-width`), which `max-width: none` alone can't undo —
   override both, or the shell sits in a dead gutter instead of running edge to edge. */
html.phone .op-shell { width: auto !important; max-width: 100vw !important; min-width: 0 !important; margin: 0 !important; padding: 0 !important; gap: 0 !important;
  height: var(--app-h, 100dvh); height: 100dvh; display: grid !important; grid-template-rows: auto minmax(0, 1fr) auto; }
@supports not (height: 100dvh) { html.phone .op-shell { height: var(--app-h, 100vh); } }

/* the title bar: slim, clear of the notch */
html.phone .op-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: calc(env(safe-area-inset-top, 0px) + 6px) 10px 6px 14px; min-height: 52px; }
html.phone .op-bar h1, html.phone .op-title { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.25rem !important; margin: 0 auto 0 0 !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 0; min-width: 6ch; }
/* A bar that cannot fit its controls (320 px wide with Larger text) wraps them onto a second line instead of running past the screen,
   where overflow is clipped, not scrollable, and a control would simply be gone. The title's flex-basis of 0 means it never causes
   that wrap itself: it takes what is left and shortens with an ellipsis. */
html.phone .op-back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px 0 2px; margin-left: -6px; color: inherit; font-weight: 700; text-decoration: none; flex: none; }
html.phone .op-back:focus-visible { outline: 2px solid var(--focus, #15181F); outline-offset: 2px; border-radius: 10px; }
html.phone .op-bar .seg button, html.phone .op-bar .btn.toggle { min-height: 44px; padding: 0 11px; font-size: 0.88rem; }
html.phone .op-bar #viewToggle, html.phone .op-bar .seg { flex-wrap: nowrap; gap: 6px; }

/* the stage: every pixel that's left, no frame, no page scroll while you touch it */
html.phone .op-stage { position: relative; min-height: 0; min-width: 0; max-width: 100%; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; touch-action: none; overflow: hidden; }
html.phone .op-stage canvas { width: 100% !important; height: 100% !important; max-height: none !important; max-width: none !important; margin: 0 !important; aspect-ratio: auto !important; display: block; }
/* a game with a fixed composition scales to fit, never stretches */
html.phone .op-stage canvas.fit { object-fit: contain; }

/* the dock: within thumb reach, clear of the home indicator */
html.phone .op-dock { min-width: 0; max-width: 100%; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px); }
html.phone .op-dock > * { margin: 0 !important; }
html.phone .op-dock .btn.primary { flex: 1 1 auto; min-width: min(46%, 100%); }
/* The status line is one line in the dock, so the toy keeps the screen; a tap opens the rest (phone-layout.js) */
html.phone .op-dock .op-status { min-width: 0; justify-content: flex-start; text-align: start; }
html.phone .op-dock .op-status, html.phone .op-dock .op-status > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.phone .op-dock .op-status > * { min-width: 0; }
html.phone .op-dock .op-status > .dot { overflow: visible; }
html.phone .op-dock .op-status[data-cut] { cursor: pointer; }
html.phone .op-dock .op-status.is-open, html.phone .op-dock .op-status.is-open > * { white-space: normal; overflow: visible; }
/* The first hint and any error are what the person must read, so the text may take two lines before it is cut (a plain-text span:
   the grime meter's span, which holds a <progress>, stays one line). A pill under 44 px would be a small tap target once it opens. */
html.phone .op-dock .op-status { min-height: 44px; border-radius: 24px; }
html.phone .op-dock .op-status > span:not(.dot):not(:has(*)) { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; white-space: normal; }
html.phone .op-dock .op-status.is-open > span:not(.dot):not(:has(*)) { display: block; -webkit-line-clamp: unset; line-clamp: unset; }
/* a short portrait phone (360 x 640) keeps one line, so the toy keeps the screen; the chevron and the button role still say there is more */
@media (orientation: portrait) and (max-height: 700px) { html.phone .op-dock .op-status:not(.is-open) > span:not(.dot):not(:has(*)) { display: block; -webkit-line-clamp: unset; line-clamp: unset; white-space: nowrap; } }
/* a cut line says it opens: a chevron at the end, turned over while it is open */
html.phone .op-dock .op-status[data-cut]::after, html.phone .op-dock .op-status.is-open::after { content: ""; flex: none; width: 8px; height: 8px; margin-inline: auto 4px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
html.phone .op-dock .op-status.is-open::after { transform: rotate(-135deg); }
html.phone .op-dock .op-status:focus-visible { outline: 2px solid var(--focus, #15181F); outline-offset: 2px; border-radius: 6px; }
/* a short phone (a 360 x 640 screen) gives the stage the room the dock's own spacing was taking */
@media (orientation: portrait) and (max-height: 700px) { html.phone .op-dock { gap: 6px; padding-top: 6px; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6px); } html.phone .op-bar { min-height: 48px; padding-block: calc(env(safe-area-inset-top, 0px) + 2px) 2px; } }
html.phone .op-dock .row, html.phone .op-dock .status, html.phone .op-dock > p { flex: 1 1 100%; justify-content: center; text-align: center; }
html.phone .op-dock .row .btn.primary { flex: 1 1 auto; }
/* a phone held sideways has little height to spare: the dock packs onto as few lines as fit instead of one per control */
/* Landscape is the other way round: height is what is scarce and width is plentiful, so the dock moves to a column beside the stage
   (scrolling inside itself if it must) and the stage keeps everything between the title bar and the bottom edge. A clean screen
   drops the bar and dock, and its rule below puts the stage back to one full column. */
@media (orientation: landscape) and (max-height: 500px) {
  html.phone .op-shell { grid-template-columns: minmax(0, 1fr) minmax(240px, 36%); grid-template-rows: auto minmax(0, 1fr); }
  html.phone .op-bar { grid-column: 1 / -1; grid-row: 1; min-height: 48px; padding-top: calc(env(safe-area-inset-top, 0px) + 2px); padding-bottom: 2px; }
  html.phone .op-dock { grid-column: 2; grid-row: 2; min-height: 0; overflow-y: auto; align-content: center; padding: 6px calc(env(safe-area-inset-right, 0px) + 12px) calc(env(safe-area-inset-bottom, 0px) + 6px) 6px; }
  html.phone .op-dock .row, html.phone .op-dock .status, html.phone .op-dock > p { flex: 1 1 100%; }
  html.phone .op-dock .btn { min-width: 0 !important; }
}

/* the ⋯ button and its sheet */
.op-more { width: 44px; height: 44px; border-radius: 999px; border: 0; background: var(--surface, #FAFAF8); box-shadow: var(--shadow-1, 0 1px 2px rgba(21, 24, 31, 0.1)); color: var(--ink, #15181F); display: grid; place-items: center; cursor: pointer; flex: none; }
.op-scrim { position: fixed; inset: 0; background: rgba(10, 12, 15, 0.32); z-index: 40; }
.op-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 80dvh; overflow: auto; display: grid; gap: 14px;
  padding: 0 16px calc(env(safe-area-inset-bottom, 0px) + 16px); background: var(--surface, #FAFAF8); color: var(--ink, #15181F);
  border-radius: var(--r-4, 30px) var(--r-4, 30px) 0 0; box-shadow: var(--shadow-3, 0 -4px 16px rgba(21, 24, 31, 0.16));
  animation: op-rise 200ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.op-sheet[hidden], .op-scrim[hidden] { display: none; }
.op-sheet > * { margin: 0 !important; }
/* the top row stays in view while the sheet scrolls: title, Comfort shortcut, Done, with a grab handle above */
.op-sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 22px 0 10px; background: var(--surface, #FAFAF8); box-shadow: 0 1px 0 var(--line, rgba(21, 24, 31, 0.12)); }
.op-sheet-head::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line-strong, rgba(21, 24, 31, 0.3)); }
.op-sheet-title { flex: 1 1 auto; min-width: 0; margin: 0; font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.15rem; line-height: 1.2; }
.op-chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong, rgba(21, 24, 31, 0.3)); background: transparent; color: var(--ink, #15181F); font-family: inherit; font-weight: 700; font-size: 0.95rem; line-height: 1; cursor: pointer; }
.op-about { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 48px; padding: 0 4px; border: 0; background: none; color: var(--ink, #15181F); font-family: inherit; font-weight: 700; font-size: 1rem; text-align: left; cursor: pointer; }
.op-about[hidden] { display: none; }
.op-done { justify-self: stretch; min-height: 44px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--ink, #15181F); color: var(--paper, #F3F4F1); font-family: inherit; font-weight: 700; font-size: 1rem; line-height: 1; cursor: pointer; }
.op-more:focus-visible, .op-done:focus-visible, .op-chip:focus-visible, .op-about:focus-visible { outline: 2px solid var(--focus, #15181F); outline-offset: 3px; }
@keyframes op-rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .op-sheet { animation: none; } }

/* recording: a clean screen hides the shell too. Some pages toggle the class on <body>, others on their own wrapper
   (e.g. a ".pb" root) — match both so this works regardless of which convention a given page uses. */
html.phone body.clean .op-bar, html.phone body.clean .op-dock,
html.phone .clean .op-bar, html.phone .clean .op-dock { display: none !important; }
html.phone body.clean .op-shell, html.phone .clean .op-shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }

/* ?audit: the live camera numbers, for checking a game on a real phone */
.op-audit { position: fixed; left: 8px; bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); z-index: 60; max-width: calc(100vw - 16px); padding: 6px 10px; border-radius: 10px; background: rgba(21, 24, 31, 0.86); color: #FFFFFF; font: 12px/1.35 ui-monospace, monospace; pointer-events: none; }
.op-upright { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 8px); transform: translateX(-50%); z-index: 55; display: flex; gap: 10px; align-items: center; padding: 8px 8px 8px 14px; border-radius: 999px; background: var(--surface, #FAFAF8); color: var(--ink, #15181F); border: 0; box-shadow: var(--shadow-2, 2px 3px 8px rgba(21, 24, 31, 0.14)); font-family: var(--font-text, "Atkinson Hyperlegible Next", system-ui, sans-serif); font-weight: 700; font-size: 0.9rem; line-height: 1.2; }
.op-upright[hidden] { display: none; }
.op-upright-x { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 0; background: var(--ink, #15181F); color: var(--paper, #F3F4F1); font-family: inherit; font-weight: 700; font-size: 0.9rem; line-height: 1; cursor: pointer; }

/* Comfort lives in the sheet on phones: always open there, laid out inline rather than as a header dropdown */
.op-sheet .op-comfort > summary { display: none; }
.op-sheet .op-comfort .panel { position: static !important; width: auto !important; max-width: none !important; max-height: none !important; overflow: visible !important; margin: 0 !important; padding: 0 !important; background: none !important; box-shadow: none !important; }
.op-sheet .op-comfort .panel .card { box-shadow: none; border: 0; padding: 0; background: none; }   /* the sheet is already the card: no box inside a box */
/* a host stylesheet's `.pb button { color: inherit }` outranks .op-done alone and left its label ink on ink */
.op-sheet .op-done { color: var(--paper, #F3F4F1); }
.op-sheet .op-chip, .op-sheet .op-about { color: var(--ink, #15181F); }
/* the Comfort shortcut scrolls the panel under the sticky top row, not behind it */
.op-sheet .op-comfort { scroll-margin-top: 84px; }
/* the phone shell is all play surface and controls: never flash, select or call out on touch */
html.phone .op-shell, html.phone .op-sheet { -webkit-tap-highlight-color: transparent; }
html.phone .op-stage, html.phone .op-stage *, html.phone .op-dock, html.phone .op-bar { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* a toy that failed to load (phone-layout.js): a plain note in the middle of the screen, over the empty page */
.op-fail { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 90; width: min(320px, calc(100vw - 32px)); display: grid; gap: 10px; justify-items: center; padding: 22px 20px; text-align: center; border-radius: var(--r-4, 30px); background: var(--surface, #FAFAF8); color: var(--ink, #15181F); box-shadow: var(--shadow-3, 0 4px 16px rgba(21, 24, 31, 0.2)); font-weight: 700; }
.op-fail p { margin: 0; }
.op-fail p:first-child { font-size: 1.15rem; }
