/* Home the recap in one landscape rail. History is an overlay in the same
   modal and does not reserve space or pause the live table. */
html body[data-mode=mabar] #result[data-round-recap][open],
html.game-landscape-rotated body[data-mode=mabar] #result[data-round-recap][open]{
 position:fixed;width:min(calc(var(--game-view-w,100vw) - 18px),940px);
 height:min(calc(var(--game-view-h,100dvh) - 16px),465px);
 grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto auto auto;
 grid-template-areas:"cap" "detail" "status" "error" "footer";
}
#result[data-round-recap] :is(#result-side,#round-review-history)[hidden]{display:none!important}
#result[data-round-recap] #result-side{
 /* Use the same flexible row as the hidden recap. A fixed bottom inset
    covered the footer when translated controls or system font scaling
    made it taller than one line. */
 grid-area:detail;position:relative;inset:auto;align-self:stretch;
 z-index:1;min-width:0;min-height:0;overflow:auto;
 border:1px solid #a77c54;border-radius:9px;background:#2b1b28;
 padding:7px;box-shadow:0 6px 25px #100712b3;
}
#result[data-history-open="true"] #result-body{visibility:hidden}
.recap-history-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:4px}
#result-history-close{padding:0;inline-size:35px;min-block-size:30px;font-size:1.15rem}
#result .recap-title{font-family:Georgia,serif;font-size:clamp(1rem,4vh,1.54rem);line-height:1.05}
#result .recap-table{display:grid;gap:2px;min-width:0;margin-block:3px 4px}
#result .recap-row{
 display:grid;grid-template-columns:minmax(46px,1.08fr) minmax(0,6fr) minmax(48px,.83fr) minmax(48px,.83fr);
 align-items:center;gap:4px;min-width:0;padding:1px 4px;border:1px solid #8b66527a;border-radius:5px;
 color:#fff0d6;background:#261821;font-size:clamp(.62rem,1.9vh,.82rem);line-height:1.03
}
#result .recap-row[data-winner=true]{border-color:#d5a967;background:#49322f}
#result .recap-head{background:none;border-color:transparent;color:#f7d38c;font-weight:750}
#result .recap-row > :nth-last-child(-n+2){min-width:0;text-align:end}
#result .recap-row .recap-player{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#result .recap-tiles{min-width:0;container-type:inline-size}
#result .recap-rack{
 display:flex;gap:3px;align-items:center;max-width:100%;min-width:0;
 overflow-x:auto;overscroll-behavior-inline:contain;scrollbar-width:thin;scrollbar-color:#bf9263 transparent;
}
#result .recap-rack :is(.recap-faces,.recap-exposed){display:inline-flex;gap:1px;flex:none}
#result .recap-exposed{padding-inline-start:2px;border-inline-start:1px solid #a68055}
#result .recap-rack .tile{
 flex:none;width:21px;width:clamp(13px,calc((100cqi - 15px) / var(--recap-count) - 1px),clamp(18px,6vh,27px));
 height:auto;min-width:0;aspect-ratio:88/122;padding:0;box-shadow:none
}
#result .recap-score{color:#fff0d4;font-weight:750;white-space:nowrap;font-variant-numeric:tabular-nums}
#result .recap-score[data-tone="gain"]{color:#a4e9ba}
#result .recap-score[data-tone="loss"]{color:#ffadb0}
#result .recap-no-data{color:#d6c2be;font-size:.73rem}
#result .recap-scoring{font-size:.77rem}
#result .recap-receipt{font-size:.72rem;border:none;padding:2px 0;margin:3px 0;background:none}
#result .recap-receipt summary{cursor:pointer;overflow-wrap:anywhere}
#result .recap-receipt ul{margin-block:3px}
/* Share the same tracks across the header, every round, and the total.
   The Details slot keeps its width even in rows with no action. */
#result .recap-history-columns{
 --recap-history-line:#d3a77363;
 --recap-history-tracks:64px minmax(92px,1.35fr) repeat(var(--recap-seats),minmax(64px,1fr)) clamp(66px,10vw,84px);
 min-inline-size:calc(64px + 92px + var(--recap-seats) * 64px + clamp(66px,10vw,84px) + 2px);
 border:1px solid var(--recap-history-line);border-radius:6px;
}
#result #result-history details.recap-history-entry{
 margin:0;padding:0;border:0;border-radius:0;background:transparent;
}
#result #result-history .recap-history-grid{
 display:grid;grid-template-columns:var(--recap-history-tracks);
 align-items:stretch;gap:0;padding:0;margin:0;min-block-size:30px;
 font-size:clamp(.68rem,2.3vh,.85rem);overflow-wrap:normal;
}
#result #result-history .recap-history-grid > *{
 box-sizing:border-box;align-content:center;min-inline-size:0;margin:0;padding:5px 7px;
 overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
#result .recap-history-grid > :is(.recap-history-player,.recap-score,:last-child){
 border-inline-start:1px solid var(--recap-history-line);
}
#result .recap-history-grid > :is(.recap-history-player,.recap-score){text-align:end}
#result .recap-history-grid > .recap-total-label{grid-column:span 2}
#result .recap-history-head{color:#f5d59e;font-weight:750}
#result .recap-history-total{background:#50352e60;font-weight:750}
#result #result-history .recap-history-columns > :not(:first-child){border-block-start:1px solid var(--recap-history-line)}
#result #result-history .recap-history-detail{text-align:center;color:#ffda92;text-decoration:underline;text-underline-offset:3px}
#result #result-history summary.recap-history-grid:hover{background:#4f342f70}
#result #result-history summary.recap-history-grid:focus-visible{outline:2px solid #ffdb91;outline-offset:-2px}
#result .recap-history-entry[open] > .recap-history-grid{color:#ffdda1;background:#4f342f70}
#result .recap-history-entry .recap-table{margin-inline:2px}
#result .recap-replay{margin:3px 0;min-height:30px;padding:2px 6px}

#result[data-round-recap]:has(#classic-rematch:not([hidden])){
 grid-template-rows:auto auto minmax(0,1fr) auto auto auto!important;
 grid-template-areas:"cap" "rematch" "detail" "status" "error" "footer"!important;
}
#classic-rematch{grid-area:rematch}
.classic-rematch{
 min-inline-size:0;border:1px solid #b88859;border-radius:8px;
 color:#fff0d6;background:#38252e;padding:4px 7px;font-size:clamp(.69rem,2.4vh,.83rem);
}
.classic-rematch-head{display:flex;align-items:center;gap:7px}
.classic-rematch-head output{margin-inline-start:auto;color:#f4d492;white-space:nowrap;font-variant-numeric:tabular-nums}
.classic-rematch-head button{min-height:28px;padding:2px 7px;white-space:nowrap}
.classic-rematch-seats{display:grid;grid-template-columns:repeat(auto-fit,minmax(70px,1fr));gap:4px;margin-top:4px}
.classic-rematch-seat{min-width:0;display:flex;flex-wrap:wrap;align-items:baseline;gap:1px 5px;padding:2px 4px;border:1px solid #76524e;border-radius:4px}
.classic-rematch-seat bdi{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;max-width:100%}
.classic-rematch-seat small{font-size:.78em;color:#d3b8ad}
.classic-rematch-seat[data-status=ready] small{color:#a9ebbf}

/* Both selected rules share the exact same five columns on the recap.
   Keep long names/formulas bounded without changing the hand rail. */
#result .recap-table[data-formula-table] .recap-row{
 grid-template-columns:minmax(40px,.95fr) minmax(0,5.6fr) minmax(77px,1.65fr) minmax(39px,.82fr) minmax(39px,.82fr);
}
#result [data-formula-table] .recap-head > :nth-child(n+3){white-space:normal;text-wrap:balance}
#result [data-formula-table] .recap-head > :nth-child(3){text-align:center}
#result [data-formula-table] .recap-player bdi{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
#result [data-formula-table] .recap-player:has(small){display:grid;gap:2px}
#result [data-formula-table] .recap-player small{font-size:.72em;color:#ebbc8d;overflow:hidden;text-overflow:ellipsis}
#result .recap-formula{
 display:grid;justify-items:center;gap:2px;min-width:0;text-align:center;color:#dfb898;
 font-variant-numeric:tabular-nums;
}
#result .recap-formula :is(bdi,small){max-inline-size:100%;overflow-wrap:anywhere}
#result .recap-formula small{font-size:.78em;color:#f1ca9f;line-height:1.05}
#result .recap-equation{padding:2px 3px;border-radius:4px;font-weight:750;unicode-bidi:isolate}
#result [data-winner-formula] .recap-equation{background:#edc58d;color:#33211d}
#result .recap-rule-badge{
 display:inline-block;margin-inline-start:.35em;padding:.08rem .42rem;
 border:1px solid #aa7e55;border-radius:5px;background:#493328;color:#f9d69b;
 font-size:.82em;white-space:nowrap;letter-spacing:.02em;
}
#result[data-round-countdown] #next-status{
 justify-self:right;max-inline-size:100%;margin:0;padding:.28em .62em;border:1px solid #bf9562;
 background:#4c312a;color:#ffdfa9;border-radius:6px;font-weight:720;line-height:1.12;
 text-align:right;font-variant-numeric:tabular-nums;font-size:clamp(.68rem,2vh,.84rem);
}
#result.solo-result[data-formula-solo]{
 width:min(940px,calc(var(--game-view-w,100dvw) - 18px - var(--solo-result-safe-inline,0px)));
}
/* Round advancement belongs to the physical lower-right even in RTL locales. */
#result.solo-result .lobby-tools{direction:ltr}
#result.solo-result .lobby-tools > #next{grid-column:-2;justify-self:right}
#result .result-footer:has(> #next:not([hidden])){direction:ltr}
#result .result-footer > #next:not([hidden]){order:1}
@media (max-width:520px) and (orientation:portrait){
 html:not(.game-landscape-rotated) #result .recap-table[data-formula-table] .recap-row{
  grid-template-columns:minmax(34px,.88fr) minmax(0,4fr) minmax(58px,1.3fr) 36px 36px;gap:2px;padding-inline:3px;
 }
}

.young-round-footer{display:flex;direction:ltr;flex-wrap:wrap;gap:6px}
.young-round-footer > #young-next{margin-left:auto}

/* Result presentation only. Keep rule formulas, hand rails and existing
   controls intact; the summary panes show only recorded match data. */
#result:is([data-round-recap],.solo-result) {
 --result-ink:#fff1db;
 --result-gold:#f6d298;
 --result-border:#946946;
 color:var(--result-ink);border-color:var(--result-border);
 background:linear-gradient(145deg,#4b2233 0%,#2b1320 51%,#22121a);
}
#result:is([data-round-recap],.solo-result) :is(#result-cap,#solo-result-cap) {
 padding:.36em .6em;border:1px solid #a87d53;border-radius:7px;
 color:var(--result-gold);background:linear-gradient(105deg,#532a37,#341926);
 font-family:Georgia,serif;font-weight:750;line-height:1.25;
}
#result:is([data-round-recap],.solo-result) #result-body {
 min-inline-size:0;color:var(--result-ink);
}
#result:is([data-round-recap],.solo-result) #result-body :is(h2,h3) {
 color:#ffe3b2;line-height:1.19;overflow-wrap:anywhere
}
#result:is([data-round-recap],.solo-result) #result-body :is(.result-winning-row,.solo-winning-row) {
 max-inline-size:100%;min-inline-size:0;padding-block:.25em;border-block:1px solid #b78b5b4d;
 background:#22121c;border-radius:6px
}
#result:is([data-round-recap],.solo-result) .recap-row {
 border-color:#9d76585d;background:#291821
}
#result:is([data-round-recap],.solo-result) .recap-row[data-winner=true] {
 border-color:#d6aa72;background:#53312f
}
#result:is([data-round-recap],.solo-result) .recap-head {
 border-color:transparent;background:transparent;color:var(--result-gold)
}
#result:is([data-round-recap],.solo-result) .recap-scoring {
 min-inline-size:0;border:1px solid #936745;border-radius:7px;background:#2b1722;
 padding:.35em .55em;margin-block:4px
}
#result:is([data-round-recap],.solo-result) .recap-scoring > summary {
 cursor:pointer;color:#ffe1ac;font-size:.86rem;font-weight:750;line-height:1.35
}
#result:is([data-round-recap],.solo-result) .result-list>span {
 color:#ffe7c4;background:#492832;border-color:#a878534f
}
#result:is([data-round-recap],.solo-result) :is(#match-summary,#match-final):not([hidden]) {
 align-self:start;min-inline-size:0;margin:4px 0;padding:.65em;
 background:linear-gradient(155deg,#512d36,#311b27);
 border:1px solid #ac8058;border-radius:8px;color:#ffe4b8;
 overflow-wrap:anywhere
}
#result #match-summary li {column-gap:.6em}
#result #match-summary :is(h3,ul,p),#result #match-final p {margin-block:0 .35em}
#result #match-final .deltas {display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
#result #match-final .deltas span {min-inline-size:0;overflow-wrap:anywhere}
#result #match-final .deltas span b {font-variant-numeric:tabular-nums}
#result:is([data-round-recap],.solo-result) :is(.result-footer,.lobby-tools) {
 padding-top:5px;border-top:1px solid #a97d5766
}
#result:is([data-round-recap],.solo-result) :is(.result-footer,.lobby-tools) :is(a,button):focus-visible,
#result:is([data-round-recap],.solo-result) .recap-scoring > summary:focus-visible {
 outline:2px solid var(--result-gold);outline-offset:2px
}
#result:is([data-round-recap],.solo-result) :is(#play-again,#solo-play-again,#next):not([hidden]):not(:disabled) {
 color:#321a1c;background:#ecc28c;border-color:#ffdda5
}
@media (min-width:760px) and (orientation:landscape) {
 #result[data-round-recap][data-match-final=true] #result-body:has(> #match-summary:not([hidden])),
 #result.solo-result .solo-result-scroll:has(> #match-final:not([hidden])) {
  display:grid;grid-template-columns:minmax(0,1fr) minmax(150px,28%);column-gap:9px;align-content:start
 }
 #result[data-round-recap][data-match-final=true] #result-body:has(> #match-summary:not([hidden])) > :not(#match-summary) {
  grid-column:1;min-inline-size:0
 }
 #result[data-round-recap][data-match-final=true] #result-body > #match-summary:not([hidden]) {
  grid-column:2;grid-row:1/span 5
 }
}
