/* A result uses the available dialog height, independently of the finished board. */
@media (min-width:901px) and (pointer:fine) {
  #game-dialog[data-phase=result]:not(.is-expanded){height:min(720px,calc(100dvh - 32px));max-height:calc(100dvh - 32px);overflow:hidden}
}
#game-dialog[data-phase=result] .game-shell{display:flex;flex-direction:column;height:100%;min-height:0}
#game-dialog[data-phase=result] .game-header{flex-shrink:0}
#game-dialog[data-phase=result] :is(#game-hud,.game-bottom,#pause-game){display:none}
#game-dialog[data-phase=result] #play-region{flex:1;min-height:0;overflow:hidden}
#game-dialog[data-phase=result] #game-viewport{flex:1;height:100%;min-height:0;max-height:none;aspect-ratio:auto}
#game-dialog[data-phase=result] :is(#board-game,#game-canvas){visibility:hidden}
#game-dialog[data-phase=result] .game-overlay.has-result-screen{display:block;padding:0;overflow:hidden;background:#131b2d}
#game-dialog #result-screen{position:relative;display:flex;flex-direction:column;gap:16px;width:100%;height:100%;min-height:0;padding:24px;text-align:left;color:#f4f7ff;animation:result-arrive .2s ease-out}
#result-screen .result-main{display:grid;grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr);gap:26px;flex:1;min-height:0;overflow:auto;scrollbar-width:thin}
#result-screen .result-score-zone{display:flex;flex-direction:column;justify-content:center;min-width:0;padding:24px;border:1px solid #536894;border-radius:22px;background:radial-gradient(ellipse at 15% 0,#4264f52b,transparent 80%),#1c2943}
#result-screen[data-outcome=won] .result-score-zone{border-color:#d9f96f66;background:radial-gradient(ellipse at 10% 0,#d9f96f14,transparent 70%),#202d39}
#game-dialog #result-screen #replay-result{width:100%;margin:0;min-width:0}
#game-dialog #result-screen .subgame-result-name{font-size:.875rem;line-height:1.4;letter-spacing:.02em;color:#c2cfea!important;margin:0}
#game-dialog #result-screen .result-points{display:flex;flex-direction:column;gap:2px;margin:18px 0 12px;font-size:1rem!important;line-height:1.2;font-variant-numeric:tabular-nums}
#result-screen .result-points strong{display:block;font:700 clamp(3rem,7vw,5rem)/1 var(--display);letter-spacing:-.045em;overflow-wrap:anywhere}
#result-screen .result-points span{font-size:1rem;font-weight:600;color:#d4e1f4}
#game-dialog #result-screen .score-save-status{font-size:.875rem;line-height:1.4;margin:0;padding:0;color:#c2cfea}
#game-dialog #result-screen .score-save-status[data-state=error]{color:#ffb8c8}
#game-dialog #result-screen .score-save-status button{display:block;min-height:44px;margin:8px 0 0;font-size:.875rem}
#result-screen .result-message-zone{display:flex;flex-direction:column;justify-content:center;gap:16px;min-width:0}
#result-screen .result-heading{display:flex;align-items:flex-start;gap:12px}
#result-screen .result-symbol{display:grid;place-items:center;flex:0 0 42px;height:42px;border-radius:14px;border:1px solid #879ecd55;background:#96b6ff12;color:#d9f96f;font-size:1.75rem}
#game-dialog #result-screen #overlay-eyebrow{margin:0 0 6px;color:#b7cbed;font-size:.75rem;line-height:1.3;letter-spacing:.08em}
#game-dialog #result-screen #overlay-title{margin:0;font-size:clamp(1.5rem,3vw,2.25rem);line-height:1.12;letter-spacing:-.035em}
#game-dialog #result-screen #overlay-description{margin:0;max-width:none;font-size:1rem;line-height:1.45;color:#c2cfea}
#result-screen .result-continuation{display:flex;align-items:center;gap:10px;border-top:1px solid #485b8055;padding-top:14px}
#game-dialog #result-screen #replay-countdown{flex:1;min-width:0;font-size:.875rem;line-height:1.4;margin:0;color:#d5e1f7}
#game-dialog #result-screen #replay-stop{flex:0 0 auto;min-height:44px;margin:0;padding:8px 10px;border:1px solid #52678f;border-radius:10px;background:#25324b;font-size:.875rem;line-height:1.3;max-width:100px}
#game-dialog #result-screen .result-social{margin:12px 0 0;justify-content:flex-start}
#result-screen .result-social:empty{display:none}
#game-dialog #result-screen .challenge-result{justify-content:flex-start;font-size:.875rem;line-height:1.4;margin:0}
#result-screen .result-notice-zone:has(.account-prompt[hidden]),#result-screen .result-notice-zone:empty{display:none}
#game-dialog #result-screen .account-prompt{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:3px 16px;padding:12px 16px;margin:0;background:#20304c;border-color:#688fff66}
#result-screen .account-prompt strong{font-size:.875rem;line-height:1.35}
#result-screen .account-prompt p{font-size:.875rem;line-height:1.35;margin:0}
#result-screen .account-prompt>div{grid-column:2;grid-row:1/3;flex-wrap:nowrap}
#game-dialog #result-screen .result-actions{display:flex;align-items:stretch;gap:10px;flex-shrink:0;margin:0;padding:0}
#game-dialog #result-screen .result-actions>button{min-width:0;min-height:50px;margin:0;padding:12px 18px;border-radius:12px;font-size:1rem;line-height:1.3}
#game-dialog #result-screen #start-game{flex:1;justify-content:space-between;gap:14px;box-shadow:0 3px 0 #0b111d}
#game-dialog #result-screen #replay-fresh{flex:0 1 auto}
#result-screen .result-more{display:flex;align-items:center;justify-content:center;gap:12px}
#result-screen .result-more>span{font-size:1.5rem;line-height:1}
#result-screen .result-options-panel{position:absolute;inset:24px 24px 90px;z-index:3;display:flex;flex-direction:column;gap:16px;padding:22px;border:1px solid #60769f;border-radius:20px;background:#1b2841;box-shadow:0 12px 36px #080d1866;overflow:auto}
#result-screen .result-options-panel>header{display:flex;align-items:center;justify-content:space-between;gap:12px}
#result-screen .result-options-panel h4{margin:0;font-size:1.25rem;font-family:var(--display)}
#result-screen .result-options-panel [data-result-return]{min-height:44px;font-size:.875rem;white-space:normal;text-align:right}
#result-screen .result-options-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:auto 0;align-content:center}
#result-screen .result-tools{display:contents}
#game-dialog #result-screen .result-options-grid button{display:flex;align-items:center;justify-content:center;width:100%;min-height:64px;margin:0;padding:12px;border:1px solid #52678f;border-radius:12px;background:#263753;font-size:.9375rem;line-height:1.35;color:#eef4ff;text-align:center;white-space:normal}
#game-dialog #result-screen .result-options-grid button:hover{background:#354b70;border-color:#a9c6ff}
#result-screen :is(.result-main,.result-notice-zone)[inert]{visibility:hidden}
#result-screen button:focus-visible{outline:3px solid var(--lime-bright);outline-offset:-3px}
@media(max-width:600px) and (orientation:portrait){
  #game-dialog #result-screen{padding:12px;gap:8px}
  #result-screen .result-main{display:flex;flex-direction:column;gap:12px}
  #result-screen .result-score-zone{padding:12px 16px;border-radius:16px;flex-shrink:0}
  #game-dialog #result-screen #replay-result{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px 12px;align-items:center}
  #game-dialog #result-screen .subgame-result-name{grid-column:1/-1;font-size:.875rem}
  #game-dialog #result-screen .result-points{margin:0;gap:0;flex-direction:row;align-items:baseline;flex-wrap:wrap;column-gap:5px}
  #result-screen .result-points strong{font-size:2.5rem}
  #result-screen .result-points span{font-size:.875rem}
  #result-screen .result-message-zone{gap:8px;flex:1}
  #result-screen .result-symbol,#game-dialog #result-screen #overlay-eyebrow{display:none}
  #game-dialog #result-screen #overlay-title{font-size:1.5rem}
  #game-dialog #result-screen #overlay-description{font-size:.875rem;line-height:1.4}
  #result-screen .result-continuation{padding-top:8px;gap:8px}
  #game-dialog #result-screen .account-prompt{grid-template-columns:1fr;padding:10px 12px;gap:3px}
  #result-screen .account-prompt>div{grid-column:1;grid-row:auto;gap:6px;margin-top:3px}
  #result-screen .account-prompt .room-secondary{flex:1;padding:8px;font-size:.875rem}
  #game-dialog #result-screen .result-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  #game-dialog #result-screen .result-actions>button{min-height:44px;padding:10px;font-size:.875rem}
  #game-dialog #result-screen #start-game{grid-column:1/-1;min-height:48px;font-size:1rem}
  #result-screen .result-more{gap:6px}
  #result-screen .result-actions:has(#replay-fresh[hidden]) .result-more{grid-column:1/-1}
  #result-screen .result-options-panel{inset:12px 12px 120px;padding:14px;gap:10px;border-radius:16px}
  #result-screen .result-options-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  #game-dialog #result-screen .result-options-grid button{min-height:56px;padding:10px;font-size:.875rem}
}
@media(max-width:600px) and (max-height:650px) and (orientation:portrait){
  #game-dialog #result-screen{padding:10px;gap:6px}
  #result-screen .result-main{gap:8px}
  #result-screen .result-score-zone{padding:10px 12px}
  #result-screen .result-message-zone{gap:6px}
  #game-dialog #result-screen #overlay-title{font-size:1.375rem}
}
@media (max-height:540px) and (orientation:landscape){
  #game-dialog[data-phase=result] .game-header{min-height:48px;padding:2px 12px}
  #game-dialog #result-screen{padding:10px 16px;gap:8px}
  #result-screen .result-main{grid-template-columns:minmax(0,.8fr) minmax(0,1.2fr);gap:16px}
  #result-screen .result-score-zone{padding:12px 16px;border-radius:16px}
  #game-dialog #result-screen .result-points{margin:8px 0;flex-direction:row;align-items:baseline;gap:6px}
  #result-screen .result-points strong{font-size:2.75rem}
  #result-screen .result-message-zone{gap:8px}
  #result-screen .result-symbol,#game-dialog #result-screen #overlay-eyebrow{display:none}
  #game-dialog #result-screen #overlay-title{font-size:1.5rem}
  #game-dialog #result-screen #overlay-description{font-size:.875rem;line-height:1.35}
  #result-screen .result-continuation{padding-top:6px}
  #game-dialog #result-screen .result-actions>button{min-height:44px;padding:8px 14px;font-size:.9375rem}
  #game-dialog #result-screen .account-prompt{padding:7px 12px}
  #result-screen .result-options-panel{inset:10px 16px 62px;padding:12px 16px;gap:8px}
  #result-screen .result-options-grid{gap:8px}
  #game-dialog #result-screen .result-options-grid button{min-height:44px;padding:8px;font-size:.875rem}
}
@keyframes result-arrive{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
@media(prefers-reduced-motion:reduce){#game-dialog #result-screen{animation:none}}
