/* Result/rematch actions share a bounded responsive grid, including the status row. */
#result-modal{padding:16px;overflow:auto}
#result-modal .result-dialog{width:min(520px,100%);min-width:0;max-height:calc(100svh - 32px);max-height:calc(100dvh - 32px);overflow-y:auto;overflow-x:hidden}
#result-modal .result-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:1fr;gap:10px;margin-top:20px;min-width:0}
#result-modal .result-actions>.rematch-status{grid-column:1/-1;max-width:none;margin:0;align-self:center;overflow-wrap:anywhere}
#result-modal .result-actions>button{width:100%;min-width:0;min-height:48px;height:auto;padding:12px 14px;white-space:normal;overflow-wrap:anywhere;line-height:1.3;align-self:stretch}
@media(max-width:360px){#result-modal .result-dialog{padding:22px 16px}#result-modal .result-actions{grid-template-columns:minmax(0,1fr)}}
/* Captain's log: scoped to the final-result dialog, independent of board skin. */
#result-modal{background:rgb(15 32 61 / .24);backdrop-filter:none}
#result-modal .result-dialog{color:#172e57;background-color:#fffaf0;background-image:linear-gradient(#8daec013 1px,transparent 1px),linear-gradient(90deg,#8daec013 1px,transparent 1px);background-size:22px 22px;border:2px solid #233d65;border-radius:8px 5px 9px 4px;outline:1px solid #233d6570;outline-offset:-6px;padding:24px 28px;box-shadow:4px 7px 0 #142e5220;text-align:center}
#result-modal .result-icon{font-size:0;line-height:1;margin:0 auto;height:106px}
#result-modal .result-hero{display:grid;place-items:center;min-height:106px;margin:0 auto}
#result-modal .result-hero .result-icon{margin:0}
#result-modal .result-art{height:106px;width:147px;display:block;margin:auto;color:#233d65}
#result-modal #result-title{font:700 clamp(38px,5vw,52px)/1.05 ZarubaHand,"Segoe Print",cursive;margin:4px 0 12px;color:#172e57}
#result-modal p{font-family:system-ui,sans-serif;font-size:14px;line-height:1.5;overflow-wrap:anywhere}
#result-modal .result-players{display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:6px;margin:0 0 8px}
#result-modal #result-description{margin:0 auto 18px;max-width:42ch}
#result-modal .result-stats{background:#fffdf5b3;border:1px solid #29446b80;border-radius:3px 6px 2px 5px;padding:12px;margin:0;box-shadow:2px 2px 0 #29446b16}
#result-modal .result-stats h3{font:700 25px/1.1 ZarubaHand,"Segoe Print",cursive;margin:0 0 10px}
#result-modal .result-stats dl{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));margin:0;gap:12px 4px}
#result-modal .result-stats dl>div{min-width:0;border-left:1px solid #29446b25;padding:0 5px}
#result-modal .result-stats dl>div:nth-child(3n+1){border:0}
#result-modal .result-stats dt{font:12px/1.3 system-ui,sans-serif;color:#445774;overflow-wrap:anywhere}
#result-modal .result-stats dd{font:700 22px/1.4 system-ui,sans-serif;margin:3px 0 0;color:#172e57}
#result-modal .result-actions{grid-auto-rows:auto;align-items:stretch;margin-top:16px}
#result-modal .result-actions>button{font:600 15px/1.35 system-ui,sans-serif;border:1.5px solid #29446b;border-radius:3px 5px 2px 4px;background:#fffaf0;color:#172e57;box-shadow:1px 2px 0 #172e5720;min-height:48px}
#result-modal .result-actions>[data-rematch="request"],#result-modal .result-actions>[data-rematch="accept"]{background:#213b62;color:#fffaf0;box-shadow:2px 3px 0 #172e5730}
#result-modal .result-actions>#result-close,#result-modal .result-actions>[data-rematch="decline"],#result-modal .result-actions>[data-rematch="cancel"]{border-color:transparent;background:transparent;box-shadow:none;color:#4c5d75;text-decoration:underline;text-underline-offset:4px}
#result-modal .result-actions>button:hover{filter:brightness(.94)}
#result-modal button:focus-visible{outline:3px solid #a27929;outline-offset:3px}
@media(max-width:600px){#result-modal .result-dialog{padding:18px 20px}#result-modal .result-actions{grid-template-columns:minmax(0,1fr)}#result-modal .result-icon,#result-modal .result-art{height:84px}#result-modal .result-hero{min-height:84px}#result-modal .result-stats dl{gap:10px 0}}

/* Shared result rhythm: centered badges, paired actions, quiet dismiss action. */
#result-modal{z-index:1500}
#result-modal .result-icon{width:64px;height:64px;margin:0 auto 10px}
#result-modal #result-title{margin:0 0 12px}
#result-modal .result-badges{display:flex;align-items:stretch;justify-content:center;flex-wrap:wrap;gap:8px;margin:0 0 14px;max-width:100%;min-width:0}
#result-modal .result-badges>.mode-badge{display:inline-flex;align-items:center;justify-content:center;gap:6px;box-sizing:border-box;min-height:34px;margin:0;padding:6px 10px;border:1.5px solid currentColor;border-radius:var(--ui-radius,5px);font-size:14px;line-height:1.2;max-width:100%;white-space:normal;text-align:center}
#result-modal .result-badges .ui-icon{display:block;vertical-align:initial;margin:0;width:16px!important;height:16px!important;min-width:16px;flex:0 0 16px}
#result-modal .result-players{margin:0 0 10px}
#result-modal #result-description{margin:0 auto 16px}
#result-modal .result-actions{grid-auto-rows:1fr;gap:12px;margin-top:16px}
#result-modal #result-close.result-secondary{display:block;width:fit-content;max-width:100%;min-width:44px;min-height:44px;height:auto;margin:10px auto 0;padding:6px 12px;line-height:1.3;border:0;border-image:none;background:transparent;box-shadow:none;color:inherit;font-size:16px;text-decoration:underline;text-underline-offset:4px}

/* Post-game actions belong to canonical finished state, independently of the modal. */
.post-game-controls{display:flex;align-items:stretch;justify-content:center;flex-wrap:wrap;gap:12px;margin:16px auto 24px;padding:0 18px;max-width:780px}
.post-game-controls button{min-height:48px;padding:10px 16px;font:600 16px/1.3 var(--ui-body-font);color:var(--ui-text);background:var(--ui-paper);border:2px var(--ui-line) var(--ui-border);border-radius:var(--ui-radius);cursor:pointer}
.post-game-rematch{display:flex;gap:8px;align-items:center;justify-content:center;flex-wrap:wrap}
.post-game-rematch .rematch-status{flex-basis:100%;margin:0;text-align:center}
.post-game-controls button:focus-visible{outline:2px solid var(--ui-accent);outline-offset:3px}
@media(max-width:600px){.post-game-controls{gap:10px;padding:0 14px}.post-game-controls>button,.post-game-rematch{flex:1 1 100%}.post-game-rematch button{flex:1 1 auto}}

/* При поширенні прихована лише панель; спільний backdrop залишається видимим. */
#result-modal .result-dialog[hidden]{display:none!important}
