/* ============================================================
   End-of-ride screens on the kit (#428)
   ============================================================
   Game over, victory, demo end, versus results and the Garage each hold a
   <uf-sheet open dismissible="false" headline> (the game still shows/hides the
   overlay divs and handles B). The sheet draws the scrim, the card, the toned
   headline and the action row; this file only lays out what's inside. The old
   overlay rules (inline <style>) keep positioning the wrappers; the wrappers'
   own backgrounds and padding are neutralised so the sheet's scrim is the one. */

#gameover-overlay, #victory-overlay, #demo-end-overlay, #versus-results, #sling-garage, #sling-results,
#tutorial-complete, #disconnect-overlay, #stoker-cta-overlay {
  background: transparent !important; padding: 0 !important;
}
/* The game shows these with display:flex/grid on the wrapper; the sheet is fixed
   inside it, so the wrapper needs no layout of its own. */
#victory-overlay.visible { display: block !important; }
#tutorial-complete.visible { display: block !important; }

/* ── The result screen's action row (#459 item 15) ──
   One row for every end screen, in the markup's order (js/ui-shell.js reads
   it the same way for the pad): the primary action first, then the other ride
   actions, RETURN TO ROOM, END RIDE, then the extras. Centred, wrapping on
   phones; every button in a line shares that line's height. */
uf-sheet .uf-sheet__actions > div[slot="actions"] { display: contents; }
/* .uf-sheet__card in the selector: the kit's own rule (flex-end) is injected
   after this file loads, so an equal-specificity override would lose. */
uf-sheet .uf-sheet__card > .uf-sheet__actions { justify-content: center; align-items: stretch; }
uf-sheet .uf-sheet__actions uf-button { margin: 0 !important; width: auto; }
uf-sheet .uf-sheet__actions uf-button[hidden] { display: none; }

/* Tutorial complete, partner left and the stoker's CTA: centred bodies. */
#tutorial-complete-sheet .uf-sheet__body, #disconnect-sheet .uf-sheet__body, #stoker-cta-sheet .uf-sheet__body { justify-items: center; text-align: center; }
#tutorial-complete-sheet #tutorial-complete-stats { margin: 0; font-size: var(--uf-size-md); line-height: 1.6; }
#tutorial-complete-sheet #steering-feel-wrap { margin: 0; max-width: 24em; }
#tutorial-complete-sheet #steam-cta { margin: 0 !important; width: 100%; }
#disconnect-sheet #disconnect-sub { margin: 0; }
/* A notice, not a win: a sentence at the 2xl size, not the shouted result
   headline (whose "DISCONNECTED" ran off a phone). */
#disconnect-sheet .uf-sheet__title { font-size: var(--uf-size-2xl); text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; }

/* Victory: destination video + stats side by side on wide screens.
   #512: the finish tally has to fit WITHOUT scrolling on a laptop / Steam Deck
   (1280×800) and a TV (1920×1080, where the kit's type is 60 % bigger). So:
   the stats grid is tighter (smaller type, 8.5em cells, 3-4 across) with the
   crash / geese / restart counts inside it; the token ledger is a compact
   two-column block (label left, value right, small type) that sits UNDER the
   destination video in the left column, beside the stats; the action row is
   the sheet's own footer. A short viewport (phone landscape) still scrolls,
   and says so (the fade + "▼ more" below). */
#victory-body { display: grid; gap: var(--uf-space-3) var(--uf-space-4); align-items: start; }
#victory-body #victory-left, #victory-body #victory-right { display: grid; gap: var(--uf-space-2); width: 100%; align-items: start; justify-items: center; }
#victory-body #victory-video { width: min(220px, 50vw); height: auto; aspect-ratio: 1; border-radius: var(--uf-radius-lg); }
#victory-body #victory-destination { margin: 0; font: 800 var(--uf-size-lg)/1.2 var(--uf-font-ui); color: var(--uf-color-fg); }
#victory-body #victory-stats { display: grid; gap: var(--uf-space-2); width: 100%; max-width: none; margin-bottom: 0; }   /* #517: the old overlay's 32px pushed a first finish's unlocks below the fold; max-width: the old overlay's 280px made the grid one column on a phone */
.victory-stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5em, 1fr)); gap: var(--uf-space-2) var(--uf-space-3); width: 100%; }
#victory-stats uf-stat .ust-value { font-size: var(--uf-size-lg); }
#victory-stats uf-stat .ust-icon { font-size: var(--uf-size-lg); }
#victory-stats uf-stat .ust-label { font-size: var(--uf-size-xs); }
/* A word value ("Adventurous", "Phone tilt") at the number size ran into the next cell on a TV: smaller, and it may wrap. */
#victory-stats uf-stat[data-words] .ust-value { font-size: var(--uf-size-md); overflow-wrap: anywhere; white-space: normal; }
#victory-stats uf-stat { min-width: 0; }
/* D-3 · the share strip: what SHARE RESULT copies, at the kit's type sizes (11px was unreadable on a TV). */
#victory-body #daily-strip, #gameover-sheet #daily-strip { font-size: var(--uf-size-sm); max-width: none; padding: var(--uf-space-2) var(--uf-space-3); }
#victory-stats .victory-stat { font-size: var(--uf-size-sm) !important; }
#victory-stats .victory-perfect { font-size: var(--uf-size-md) !important; }
/* The ledger (uf-ledger): compact rows, the heading at body size. */
#victory-body #victory-coins, #gameover-coins { width: 100%; max-width: 22em; justify-self: center; }
#victory-coins uf-ledger, #gameover-coins uf-ledger { gap: 0; }
#victory-coins uf-ledger .ul-head, #gameover-coins uf-ledger .ul-head { font-size: var(--uf-size-md); margin-bottom: var(--uf-space-1); }
#victory-coins uf-ledger .ul-row, #gameover-coins uf-ledger .ul-row { font-size: var(--uf-size-xs); padding: .12em 0; }
#victory-coins uf-ledger .ul-total, #gameover-coins uf-ledger .ul-total { font-size: var(--uf-size-sm); }
#victory-coins uf-ledger .ul-balance, #gameover-coins uf-ledger .ul-balance { margin-top: 0; }
/* Short viewports (phone held sideways, ~390px tall): the sheet's chrome
   shrinks (padding, headline, buttons), the picture goes, and the body is two
   columns — stats left, the ledger right — so the numbers come first and most
   of the tally is in view before any scrolling. */
@media (max-height: 520px) {
  #victory-sheet > .uf-sheet__card, #gameover-sheet > .uf-sheet__card {
    padding: var(--uf-space-3) var(--uf-space-4); gap: var(--uf-space-2);
    max-height: calc(100dvh - 2 * var(--uf-space-3)); width: min(var(--_w), calc(100% - 2 * var(--uf-space-3)));
  }
  #victory-sheet[headline] .uf-sheet__title, #gameover-sheet[headline] .uf-sheet__title { font-size: var(--uf-size-xl); }
  #victory-sheet .uf-sheet__actions, #gameover-sheet .uf-sheet__actions { gap: var(--uf-space-2); }
  #victory-sheet .uf-sheet__actions uf-button, #gameover-sheet .uf-sheet__actions uf-button { font-size: var(--uf-size-sm); min-height: 36px; padding-top: var(--uf-space-1); padding-bottom: var(--uf-space-1); }
  #victory-body #victory-video { display: none; }
  #victory-body { grid-template-columns: minmax(0, 1fr) minmax(15em, 18em); grid-template-areas: "dest ledger" "stats ledger" "unlocked unlocked" "pair pair"; grid-template-rows: auto 1fr auto auto; gap: var(--uf-space-2) var(--uf-space-3); }
  #victory-body #victory-left { display: none; }
  #victory-body #victory-right { display: contents; }
  #victory-body #victory-destination { grid-area: dest; justify-self: start; font-size: var(--uf-size-md); }
  #victory-body #victory-stats { grid-area: stats; gap: var(--uf-space-1); }
  #victory-body #victory-coins { grid-area: ledger; align-self: start; max-width: none; }
  #victory-body #pair-panel { grid-area: pair; }
  #victory-body #victory-unlocked { grid-area: unlocked; }
  #victory-stats .victory-stat, #victory-stats .victory-perfect { font-size: var(--uf-size-sm) !important; }
  #victory-stats uf-stat .ust-value { font-size: var(--uf-size-md); }   /* "Adventurous" fits its cell */
}
/* An end sheet that has to scroll says so: a fade and "▼ more" at the foot of
   the body until it is scrolled to the end (data-scroll is set by
   Game._markSheetScroll). */
#victory-sheet .uf-sheet__body, #gameover-sheet .uf-sheet__body { scrollbar-gutter: stable; }
#victory-sheet .uf-sheet__body[data-scroll="yes"]::after, #gameover-sheet .uf-sheet__body[data-scroll="yes"]::after {
  content: '▼ more'; position: sticky; bottom: 0; z-index: 1; display: block; text-align: center;
  padding-top: 1.8em; margin-top: -1.8em; font: 700 var(--uf-size-xs)/1.4 var(--uf-font-ui); color: var(--uf-color-fg-muted);
  background: linear-gradient(to bottom, transparent, var(--uf-color-surface) 60%); pointer-events: none;
}
@media (min-width: 1024px) {
  /* video | destination
     video | stats
     ledger| stats          (#victory-right is display: contents so its children take areas) */
  #victory-body { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "video dest" "video stats" "ledger stats" "unlocked unlocked" "pair pair"; grid-template-rows: auto auto 1fr auto auto; }
  #victory-body #victory-left { grid-area: video; align-self: start; }
  #victory-body #victory-right { display: contents; }
  #victory-body #victory-destination { grid-area: dest; justify-self: start; }
  #victory-body #victory-stats { grid-area: stats; }
  #victory-body #victory-coins { grid-area: ledger; align-self: start; max-width: none; }
  #victory-body #pair-panel { grid-area: pair; }
  #victory-body #victory-unlocked { grid-area: unlocked; }
  /* #517: four across on a TV (a first Grandma's finish unlocks ten). */
  #victory-body #victory-unlocked { grid-template-columns: repeat(auto-fill, minmax(11em, 1fr)); }
  /* The gold list is "unlocked this ride": one line per badge, no "Unlocked!" under each. */
  .end-unlocked uf-achievement .ua-new { display: none; }
  .end-unlocked uf-achievement .ua-icon { grid-row: auto; }
  .end-unlocked uf-achievement { align-content: center; }
}

/* Game over / demo end: centred body. */
#gameover-sheet .uf-sheet__body, #demo-end-sheet .uf-sheet__body { justify-items: center; text-align: center; }
#demo-end-sheet p { margin: 0; color: var(--uf-color-fg-muted); font-size: var(--uf-size-md); }

/* Garage / slingshot results bodies (filled by js/slingshot-ui.js). */
#sling-garage-body, #sling-results-body { display: grid; gap: var(--uf-space-3); justify-items: center; text-align: center; }
#sling-garage-body .sling-list { max-width: none; width: 100%; }
#sling-garage-body .sling-buttons, #sling-results-body .sling-buttons { max-width: 28em; }

/* The old #victory-buttons rule (an id) stacks the buttons; the sheet's action row lays them out. */
#victory-buttons { display: contents !important; }
/* Record / perfect-ride lines at the kit's sizes. */
#victory-stats .victory-stat { font-size: var(--uf-size-md) !important; text-align: center; }
#victory-stats .victory-perfect { font-size: var(--uf-size-lg) !important; color: var(--uf-color-accent-2); }
/* Achievements unlocked this ride. */
.end-unlocked { display: grid; grid-template-columns: repeat(auto-fill, minmax(14em, 1fr)); gap: var(--uf-space-2); width: 100%; }
.end-unlocked[hidden] { display: none; }
/* What the list is (a lone badge read as "all your achievements", Steam playtest 2026-11-07). */
/* More than 10 unlocked in one ride: icons only, a tight row (achievements.js END_LIST_NAMES_MAX). */
/* #736 · the next bike to earn, last in the unlocked list */
.end-unlocked:not(:has(uf-achievement))::before { content: none; }   /* only the next-bike line: no heading */
.end-unlocked .end-bike-goal { grid-column: 1 / -1; order: 99; margin: var(--uf-space-2) 0 0; font-size: var(--uf-size-sm); color: var(--uf-color-fg-muted); text-align: center; }
#victory-body #victory-unlocked.icons-only, .end-unlocked.icons-only { grid-template-columns: repeat(auto-fill, minmax(3.4em, 1fr)); }
.end-unlocked.icons-only uf-achievement { grid-template-columns: 1fr; justify-items: center; padding: var(--uf-space-2); }
.end-unlocked.icons-only uf-achievement .ua-name, .end-unlocked.icons-only uf-achievement .ua-new { display: none; }
.end-unlocked.icons-only uf-achievement .ua-icon { grid-row: auto; font-size: var(--uf-size-xl); }
.end-unlocked::before { content: 'Unlocked this ride'; grid-column: 1 / -1; font: 700 var(--uf-size-sm)/1.2 var(--uf-font-ui); color: var(--uf-color-accent-2); letter-spacing: .04em; text-transform: uppercase; }
/* The floating toast is now a kit badge: the wrapper only animates it. */
.achievement-toast { padding: 0 !important; background: none !important; border: none !important; backdrop-filter: none !important; }
/* #482: the kit's own uf-achievement[state="new"] fill is a 10% tint over
   surface-3 (4% white), right on a panel but see-through over the road; its
   rule ties this one on specificity and loads later, so name the state too.
   Same tint, over the solid panel colour. */
.achievement-toast uf-achievement,
.achievement-toast uf-achievement[state] {
  background: color-mix(in srgb, var(--uf-color-accent-2) 10%, var(--uf-color-surface));
  min-width: 15em;
}
/* #666 · a demo guest's held full-game achievements: one line across the sheet, in the unlocked list's accent. */
.end-held { grid-column: 1 / -1; margin: 0; width: 100%; text-align: center; font: 700 var(--uf-size-sm)/1.35 var(--uf-font-ui); color: var(--uf-color-accent-2); }
.end-held[hidden] { display: none; }

/* ── #657 · the share sheet: a QR to the phone page, POST TO DISCORD ── */
#share-sheet { z-index: 70; }   /* over the result screen it opens from */
#share-sheet .share-body { display: grid; justify-items: center; gap: var(--uf-space-3); text-align: center; }
#share-sheet .share-status { margin: 0; font-weight: 700; color: var(--uf-color-success-fg, #7be38a); }
#share-sheet .share-phone { display: grid; justify-items: center; gap: var(--uf-space-2); }
#share-sheet .share-note { margin: 0; color: var(--uf-color-fg-muted); font-size: var(--uf-size-sm); max-width: 30em; }

/* #802 · Map Tourist's end screen: the picture of the place, taken from the top of the arrival's rise */
#victory-stats .tourist-postcard { margin: 0; width: 100%; display: grid; gap: var(--uf-space-1); }
#victory-stats .tourist-postcard img { display: block; width: 100%; max-height: 32vh; object-fit: cover; border-radius: var(--uf-radius-lg); border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0,0,0,.35); box-sizing: border-box; }
#victory-stats .tourist-postcard figcaption { display: flex; justify-content: space-between; gap: var(--uf-space-2); align-items: baseline; font: 600 var(--uf-size-sm)/1.3 var(--uf-font-ui); color: var(--uf-color-fg); }
#victory-stats .tourist-postcard figcaption span { font-weight: 400; font-size: 10px; opacity: .7; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
