/* ==========================================================================
   Phone score sheet (Nov 2026). Markup: js/screens/score-sheet.js (PhoneScoreSheet).
   Portrait phones only, behind the phone query of mobile.css / fit.css / phone-focus.css plus portrait, so the TV,
   desktop players, tablets and landscape phones are untouched (the script does not mount there either).

   Arrow   a tab on the bottom edge, centred. Up arrow when the sheet is down, down arrow when it is up.
   Sheet   the standings, from just under the header to the bottom edge. The rows, chips and legend are the reveal
           board's (.pf-* in phone-focus.css) with a rank column and a "gained" figure added.
   Layers  scrim 44, sheet 45, arrow 46: above the strip, Ready and the reveal (30-32), below dialogs (50).
   ========================================================================== */
.qs-root { display: none; }

@media (hover: none) and (pointer: coarse) and (max-width: 932px) and (orientation: portrait) {
  .qs-root { display: contents; --qs-tab-h: 32px; --qs-gap: calc(max(56px, 9dvh) + env(safe-area-inset-top)); font-family: var(--ad-font-ui, system-ui, sans-serif); color: var(--ad-ink, #F7F2FF); }

  /* ---------- The arrow ---------- */
  .qs-arrow-button {
    position: fixed; z-index: 46; left: 50%; bottom: 0; translate: -50% 0; box-sizing: border-box;
    width: 76px; height: calc(var(--qs-tab-h) + env(safe-area-inset-bottom)); padding: 0 0 env(safe-area-inset-bottom); margin: 0;
    display: grid; place-items: center; cursor: pointer; touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none;
    border: 1px solid #ffffff2e; border-bottom: 0; border-radius: 16px 16px 0 0;
    background: var(--ad-night-3, #2A1B43); color: var(--ad-ink, #F7F2FF); box-shadow: 0 -4px 14px #0006;
  }
  /* The finger gets 44px of height; the tab itself stays low so it covers as little as possible. */
  .qs-arrow-button::before { content: ""; position: absolute; inset: -12px -6px 0; }
  .qs-arrow-button svg { display: block; transition: transform 260ms var(--ad-ease, ease); }
  .qs-root.is-open .qs-arrow-button svg { transform: rotate(180deg); }
  .qs-arrow-button:active { background: var(--ad-night-4, #3A2759); }
  .qs-arrow-button:focus-visible { outline: 3px solid var(--ad-lime, #D8FF36); outline-offset: 2px; }

  /* ---------- The gap above the sheet: tap to close ---------- */
  .qs-scrim { position: fixed; inset: 0; z-index: 44; background: rgba(18, 10, 31, .6); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 260ms ease, visibility 0s linear 260ms; }
  .qs-root.is-open .qs-scrim { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 260ms ease, visibility 0s linear 0s; }
  .qs-root.is-dragging .qs-scrim { opacity: var(--qs-p, 0); visibility: visible; transition: none; }

  /* ---------- The sheet ---------- */
  .qs-sheet {
    position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; top: var(--qs-gap); box-sizing: border-box;
    display: grid; grid-template-rows: auto minmax(0, 1fr); justify-items: center;
    padding: 8px max(12px, env(safe-area-inset-right)) calc(var(--qs-tab-h) + 12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-radius: 24px 24px 0 0; background: var(--ad-night-2, #1D1230); box-shadow: 0 -10px 30px #0008, inset 0 1px 0 #ffffff1f;
    touch-action: none; transform: translateY(100%); visibility: hidden;
    transition: transform 340ms var(--ad-ease, cubic-bezier(.16, 1, .3, 1)), visibility 0s linear 340ms;
  }
  .qs-root.is-open .qs-sheet { transform: none; visibility: visible; transition: transform 340ms var(--ad-ease, cubic-bezier(.16, 1, .3, 1)), visibility 0s linear 0s; }
  /* Under the finger: no easing, the sheet is exactly where the finger is. */
  .qs-root.is-dragging .qs-sheet { transform: translateY(var(--qs-y, 0px)); visibility: visible; transition: none; }
  .qs-grip { width: 44px; height: 5px; margin: 2px 0 8px; border-radius: 999px; background: #ffffff47; }

  .qs-board.pf-board { width: min(100%, 560px); min-height: 0; grid-template-rows: auto minmax(0, 1fr); gap: 10px; align-content: start; }
  .qs-head { display: grid; justify-items: center; gap: 8px; }
  .qs-head h2 { margin: 0; font-family: var(--ad-font-display, inherit); font-weight: 800; font-size: 24px; line-height: 1.1; letter-spacing: -.01em; }
  .qs-board .qs-rows { touch-action: pan-y; }
  .qs-board .qs-rows[data-qs-static] { touch-action: none; }

  /* Rows: the reveal board's, with the rank in front and the round's gain beside the total. */
  .qs-board .pf-row.qs-row { grid-template-columns: 18px 32px minmax(0, 1fr) auto auto; grid-template-areas: "rank who name gain total" "rank who chips chips chips"; }
  .qs-board.qs-plain .pf-row.qs-row { grid-template-columns: 18px 32px minmax(0, 1fr) auto; grid-template-areas: "rank who name total"; padding-block: 8px; }
  .qs-board.qs-plain .pf-row.qs-row .pf-who { align-self: center; }
  .qs-rank { grid-area: rank; align-self: center; text-align: center; font-family: var(--ad-font-display, inherit); font-weight: 800; font-size: 17px; line-height: 1; color: var(--ad-muted, #C3B3DA); font-variant-numeric: tabular-nums; }
  .qs-row.is-you .qs-rank { color: var(--ad-ink, #F7F2FF); }
  .qs-gain { grid-area: gain; align-self: center; font-family: var(--ad-font-display, inherit); font-weight: 800; font-size: 15px; line-height: 1; color: var(--ad-lime, #D8FF36); font-variant-numeric: tabular-nums; white-space: nowrap; opacity: 0; transform: translateY(4px); transition: opacity 200ms ease, transform 300ms var(--ad-ease, ease); }
  .qs-gain.is-in { opacity: 1; transform: none; }
  .qs-gain.is-loss { color: #FF7A6B; }
  .qs-board .pf-row.qs-row.is-blank .pf-chips { min-height: 24px; flex-wrap: wrap; }

  /* 6 to 10 players: two columns of tighter rows. Beyond that the reasons give way to their colours (the legend names them). */
  .qs-board:is(.pf-size-some, .pf-size-many) .pf-row.qs-row { grid-template-columns: 14px 26px minmax(0, 1fr) auto auto; grid-template-areas: "rank who name gain total" "chips chips chips chips chips"; }
  .qs-board.qs-plain:is(.pf-size-some, .pf-size-many) .pf-row.qs-row { grid-template-columns: 14px 26px minmax(0, 1fr) auto; grid-template-areas: "rank who name total"; padding-block: 7px; }
  .qs-board:is(.pf-size-some, .pf-size-many) .pf-row.qs-row .pf-chips { display: flex; grid-area: chips; grid-column: auto; grid-row: auto; }
  .qs-board:is(.pf-size-some, .pf-size-many) .qs-rank { font-size: 13px; }
  .qs-board:is(.pf-size-some, .pf-size-many) .qs-gain { font-size: 12px; }
  .qs-board:is(.pf-size-some, .pf-size-many) .qs-head h2 { font-size: 20px; }

  /* ---------- The page behind ---------- */
  /* Your corner piece floats above dialogs (70); under an open sheet it would sit on the rows. */
  body.qs-open .emoji-quick { visibility: hidden !important; }
  /* Where the player strip shows, it stands 30px taller so the arrow sits under the pieces, not on them. Ready
     measures the strip, so it rises with it. */
  body.qs-arrow .game-shell > .player-strip.player-strip { height: calc(var(--strip-h) + 30px) !important; min-height: calc(var(--strip-h) + 30px) !important; max-height: calc(var(--strip-h) + 30px) !important; flex: 0 0 calc(var(--strip-h) + 30px) !important; padding-bottom: 33px !important; }
  /* Where the strip is hidden (reveal, battle ready, battle result), Ready clears the arrow instead. */
  body.qs-arrow .game-shell > .ready-skip.ready-skip { bottom: calc(max(var(--ready-strip-h, 0px), 32px + env(safe-area-inset-bottom)) + 6px) !important; }
  /* After you answer, a long question scrolls far enough that its last answers end above the arrow. */
  body.qs-arrow .game-shell > .main-stage.main-stage:has(> .question-screen:not(.is-reveal)) { padding-bottom: calc(var(--qs-tab-h, 32px) + 10px + env(safe-area-inset-bottom)) !important; }
  /* Quick 5 reveal: the review box was capped at the stage height and its vote buttons spilled past the stage's bottom
     padding, under Ready and the arrow. Uncapped, the box grows, the stage scrolls, and its padding clears both. */
  body.qs-arrow .game-shell > .main-stage > .review-with-votes { max-height: none !important; }
  /* Same for an answered question whose answer list (14 players) is taller than the stage. */
  body.qs-arrow .game-shell > .main-stage > .question-screen:not(.is-reveal) { height: auto !important; min-height: 100% !important; max-height: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .qs-sheet, .qs-root.is-open .qs-sheet, .qs-scrim, .qs-root.is-open .qs-scrim, .qs-arrow-button svg, .qs-gain { transition: none !important; }
  .qs-gain { transform: none; }
}
