/* results.css, owner: track E. Holds: hand summary, game over, meld summary lines (DESIGN_SPEC.md 9.9).
   Load order 14 of 15: base, primitives, frame, home, room, friends, center, table, rails, chat, coach, meld, peek, results, dialogs.
   Wave 2: the result is one panel, centered (a bottom sheet on a phone): head, body (the tally and the meld, scrolls), foot. The panel is a
   container (`result`), so it goes to two columns when it is 56 rem wide, whatever holds it. Until the table (D1) puts it on the live felt
   the container draws the felt itself; D1 sets `background: none` where it mounts it (track-e.md, needs). */

/* ---- The box that holds the panel ---- */
.scores-container {
  container: result / inline-size;
  display: flex; flex-direction: column; align-items: center; justify-content: safe center; flex: 1; min-height: 0;
  padding: var(--sp-4); overflow-y: auto; overscroll-behavior: contain;
  background: radial-gradient(ellipse 90% 70% at 50% 35%, var(--felt) 0%, var(--felt-edge) 100%);
}
.scores-container > .summary-card { flex: 0 1 auto; min-height: 0; }
/* The result is drawn where the page has no frame (the table): its controls take the one ring, --gold-strong (8.1, 11, AC-28), not the old gold. */
.scores-container :focus-visible:not(.btn--primary) { outline-color: var(--gold-strong); }
.scores-container :is(input, textarea, select):focus-visible { outline-offset: 1px; }
/* The window is the page while a result is up: #app keeps the window's height so the panel scrolls in its own body. */
body:has(#phase-root .scores-container) #app { flex: none; height: 100vh; height: 100dvh; min-height: 0; }
body:has(#phase-root .scores-container) #phase-root { overflow: hidden; padding-bottom: 0; }

.summary-card {
  display: flex; flex-direction: column; width: min(100%, 60rem); max-height: 100%; overflow-y: auto; overscroll-behavior: contain; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-2xl); box-shadow: var(--e-3);
}
@media (min-height: 1000px) and (min-width: 900px) { .summary-card { font-size: max(1.0625rem, 12px); } }

/* ---- Hand summary: head, banner ---- */
.result__head { display: grid; justify-items: center; gap: var(--sp-3); flex: none; padding: var(--sp-5) var(--sp-5) var(--sp-4); }
.result__title, .celebration-screen h2 { font: var(--t-title-1); letter-spacing: -0.01em; }
.result-banner {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-3); min-height: 2.5rem; max-width: 100%; padding: var(--sp-2) var(--sp-5);
  border-radius: var(--r-full); font-size: max(1.0625rem, 12px); font-weight: 700; line-height: 1.2;
}
.result-banner.is-made { background: var(--good-wash); color: var(--good); }
.result-banner.is-set { background: var(--bad-wash); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-edge); }
/* Build 33 (Concede): neither made nor set; a quiet gold banner (gold on the panel is the same pair the eyebrows use) */
.result-banner.is-conceded { background: var(--gold-wash); color: var(--gold-strong); }

/* ---- Hand summary: body (scrolls), the tally and the meld ---- */
.result__body { --fade: var(--sp-5); flex: 1; min-height: min(9rem, 30dvh); display: grid; align-content: start; gap: var(--sp-5); padding: var(--sp-2) var(--sp-5) 0; overflow: auto; overscroll-behavior: contain; text-align: left; }
/* The bottom edge of the scroll area fades into the panel while there is more below (the bottom padding is this strip: at the end of the scroll it covers nothing). */
.result__body::after { content: ""; position: sticky; bottom: 0; height: var(--fade); margin-top: calc(var(--sp-5) * -1); background: linear-gradient(to bottom, transparent, var(--panel)); pointer-events: none; }
.result__cols { display: grid; gap: var(--sp-5); }
@container result (min-width: 56rem) {
  .result__cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: var(--sp-6); align-items: start; }
}
.summary-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.summary-table th, .summary-table td { padding: var(--sp-3); text-align: right; }
.summary-table thead th { padding-bottom: var(--sp-3); font: var(--t-label); }
.summary-table th small { display: block; font: var(--t-caption); color: var(--text-dim); }
.summary-table tbody th { text-align: left; color: var(--text-dim); font: var(--t-small); }
.summary-table tbody tr + tr > * { border-top: 1px solid var(--hair); }
.summary-table tbody td { font-size: max(1.125rem, 12px); font-weight: 700; }
.summary-table tr.is-strong td { font-size: max(1.375rem, 12px); }
.summary-table tr.is-total > * { border-top: 1px solid var(--line); }
.summary-table tr.is-total td { font-size: max(1.75rem, 12px); font-weight: 800; }
.summary-table tr.is-total th { color: var(--text); font: var(--t-label); }
.summary-table .pos { color: var(--good); }
.summary-table .neg { color: var(--bad); }
.summary-table .progress { display: block; width: 100%; max-width: 8rem; margin: var(--sp-1) 0 0 auto; }   /* a block, or the bar has no width (6 px tall, 9.9) */
.summary-table .progress__bar { display: block; }
.result-math { margin-top: var(--sp-3); color: var(--text-dim); font: var(--t-body); text-align: center; text-wrap: pretty; }
.result__notes { display: grid; gap: var(--sp-2); justify-items: center; text-align: center; }
.result__notes .panel-hint { max-width: 60ch; }

/* The meld: one card per seat, a team-colored edge, the total at the right, the words (or the faces) under it. */
.meld-summary { display: grid; align-content: start; gap: var(--sp-3); text-align: left; }
.meld-summary-title { color: var(--text-dim); }
.meld-summary-line { display: block; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); background: var(--panel-2); border-left: 3px solid var(--c, var(--line)); }
.meld-summary-line.team-ns { --c: var(--team-ns); }
.meld-summary-line.team-ew { --c: var(--team-ew); }
.meld-summary-line > summary.meld-summary-head { display: flex; align-items: center; gap: var(--sp-3); list-style: none; padding-block: 0; cursor: pointer; }
.meld-summary-head::-webkit-details-marker { display: none; }
.meld-summary-head::after { color: var(--text-dim); }   /* (the chevron itself: table.css) */
.meld-summary-name { min-width: 3.5em; font-size: max(0.9375rem, 12px); font-weight: 700; color: var(--c, var(--text)); }
.meld-summary-total { margin-left: auto; font-size: max(1.125rem, 12px); font-weight: 800; font-variant-numeric: tabular-nums; }
.meld-summary-row { display: flex; align-items: flex-start; gap: var(--sp-3); padding-top: var(--sp-1); }
.meld-summary-parts { display: block; flex: 1; color: var(--text-dim); font: var(--t-caption); line-height: 1.5; min-width: 0; overflow-wrap: anywhere; }
.meld-faces { display: grid; flex: 1; gap: var(--sp-2); min-width: 0; }
.meld-faces[hidden], .meld-summary-parts[hidden] { display: none; }
.meld-faces-toggle { flex: none; margin-left: auto; }

/* ---- The foot: the secondary buttons at the left, the one primary at the right ---- */
.result__foot { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); flex: none; padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--hair); border-radius: 0 0 var(--r-2xl) var(--r-2xl); background: var(--ink-0); }
.result__foot .continue-btn { min-width: 14rem; margin-left: auto; }   /* fix round 1 M3: when the review buttons fill a row, Deal Next Hand still sits at the right, never alone at the left */
.review-links { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.review-links:empty { display: none; }
.result__foot .waiting-note { margin-left: auto; }
.waiting-note { color: var(--text-dim); font: var(--t-small); }
.summary-manage { grid-column: 1 / -1; width: 100%; padding: 0 var(--sp-5); text-align: left; border-top: 1px solid var(--hair); }
.summary-manage > summary { font-weight: 700; color: var(--text); }

/* ---- Game over: the same panel, with a cup ---- */
.celebration-screen { align-items: center; width: min(100%, 36rem); padding: var(--sp-6) var(--sp-5); gap: var(--sp-4); }
.celebration-screen > * { max-width: 100%; }
.celebration-screen h2.is-win { color: var(--gold-strong); }
.celebration-screen h2.is-loss { color: var(--text); }
.celebration-screen .trophy { display: flex; justify-content: center; color: var(--gold); }
.celebration-screen .trophy svg { width: 3rem; height: 3rem; }
/* The winners' picture (build 32; the app's WinnerTrophy has the same sizes): the cup over the burst, which is drawn at full strength and may reach a few px past the row. */
.celebration-screen .trophy-win { position: relative; display: grid; place-items: center; width: 112px; height: 100px; margin: 0 auto; }
.trophy-win > * { grid-area: 1 / 1; }
.trophy-win .trophy-burst { width: 112px; height: 112px; max-width: none; pointer-events: none; }
.trophy-win .trophy-cup { position: relative; display: block; width: auto; height: 62px; }
@media (min-width: 1024px) {
  .celebration-screen .trophy-win { width: 172px; height: 150px; }
  .trophy-win .trophy-burst { width: 172px; height: 172px; }
  .trophy-win .trophy-cup { height: 96px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .celebration-screen .trophy-win, .summary-card.can-split .trophy-win { width: 78px; height: 62px; margin: 0 auto; }
  .trophy-win .trophy-burst { width: 78px; height: 78px; }
  .trophy-win .trophy-cup { height: 44px; }
}
/* The burst eases in behind the cup and the cup settles; with Reduce Motion both just appear. */
@media (prefers-reduced-motion: no-preference) {
  .trophy-win .trophy-burst { animation: burst-in 0.9s ease-out 0.2s both; }
  .trophy-win .trophy-cup { animation: cup-in 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) 0.15s both; }
}
@keyframes burst-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cup-in { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
/* Facts (build 32): the line under the score and on waits. */
.fact-line { max-width: 34em; margin: var(--sp-1) auto 0; color: var(--text-dim); font: var(--t-caption); font-family: var(--font-serif); text-align: center; }
.fact-line b { color: var(--gold-strong); font-weight: 600; }
@media (max-height: 500px) and (orientation: landscape) { .hand-summary .fact-line { display: none; } }
/* The other side sees the four suits, not the winners' cup (as in the app). */
.celebration-screen .trophy-suits { font-size: max(2rem, 12px); color: var(--gold); letter-spacing: 0.2em; }
.final-scores { display: flex; justify-content: center; gap: var(--sp-3); }
.final-score { flex: 1; max-width: 12.5rem; padding: var(--sp-3); border-radius: var(--r-xl); background: var(--panel-2); display: flex; flex-direction: column; justify-content: space-between; gap: var(--sp-1); }
.final-score span { min-height: 2.4em; font: var(--t-caption); line-height: 1.2; color: var(--text-dim); overflow-wrap: anywhere; }   /* two lines high whether the name takes one or two, so the tiles match (fix round 3 m11) */
.final-score .final-who { font: var(--t-eyebrow); letter-spacing: 0.09em; text-transform: uppercase; }
.final-score .final-who.is-ns { color: var(--team-ns); }
.final-score .final-who.is-ew { color: var(--team-ew); }
.final-score b { font-size: max(2rem, 12px); font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.taunt { color: var(--text-dim); font-style: italic; }
.celebration-screen .dialog-actions { justify-content: center; }
/* A window too short for the card scrolls the card, and the one primary stays at the bottom edge (AC-07, AC-34). */
.celebration-screen .result__actions { position: sticky; bottom: 0; padding-block: var(--sp-2); background: var(--panel); }
.celebration-screen .review-links { justify-content: center; }
.celebration-screen .summary-manage { padding: 0; }

/* The end of a Learn to Play game (render/summary.js, build 24 3.7). */
.first-game { margin: 0 0 var(--sp-2); text-align: center; }
.first-game-eyebrow { color: var(--gold-strong); font: var(--t-eyebrow); letter-spacing: 0.09em; text-transform: uppercase; }
.first-game-title { margin: var(--sp-1) 0 var(--sp-2); font: var(--t-title-3); color: var(--text); }
.first-game-chips { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--sp-1); }
.first-game-chips span { padding: var(--sp-1) var(--sp-2); border: 1px solid var(--gold-line); border-radius: var(--r-md); color: var(--gold-strong); font: var(--t-eyebrow); animation: coach-fade 0.3s ease-out both; }

/* ---- Phone upright: the panel is a bottom sheet; phone on its side: two columns, so the buttons stay on screen (R-083) ---- */
@media (max-width: 599.98px) {
  .scores-container { padding: 0; justify-content: flex-end; }
  .scores-container > .summary-card { width: 100%; border-width: 1px 0 0; border-radius: var(--r-2xl) var(--r-2xl) 0 0; }
  .result__head { padding: var(--sp-4) var(--sp-4) var(--sp-2); }
  .result__title, .celebration-screen h2 { font-size: max(1.5rem, 12px); }
  .result__body { --fade: var(--sp-4); padding: var(--sp-2) var(--sp-4) 0; }
  .result__foot { flex-direction: column-reverse; align-items: stretch; padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + var(--safe-b)); }
  .result__foot .continue-btn { width: 100%; min-width: 0; }
  /* One row of secondaries, as the reference draws it: the three share the width, and a long name wraps inside its 44 px button. */
  .result__foot .review-links { flex-wrap: nowrap; justify-content: space-between; }
  .result__foot .review-links .btn { flex: 1 1 auto; min-width: 0; padding-inline: var(--sp-2); font-size: max(0.875rem, 12px); line-height: 1.15; white-space: normal; }
  .celebration-screen { padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + var(--safe-b)); }
}
.summary-group { display: contents; }
@media (max-height: 500px) and (orientation: landscape) {
  .scores-container { padding: var(--sp-2) var(--sp-3); justify-content: flex-start; }
  .scores-container > .summary-card { width: min(100%, 53.75rem); border-width: 1px; border-radius: var(--r-2xl); }
  .result__head { padding: var(--sp-3) var(--sp-4) var(--sp-2); grid-auto-flow: column; align-items: center; justify-content: center; }
  .result__cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-4); align-items: start; }
  .result__foot { flex-direction: row; align-items: center; padding: var(--sp-2) var(--sp-4); }
  .summary-card.can-split { width: min(100%, 53.75rem); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--sp-5); align-items: start; padding: var(--sp-3) var(--sp-4); }
  .summary-card.can-split .summary-group { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); min-width: 0; }
  .summary-card.can-split .summary-side { align-self: center; }
  .summary-card.can-split .trophy svg { width: 2rem; height: 2rem; }
}
