/* The stage or native dialog bounds the sheet. Only the score details scroll. */
#app:has(#result-panel:not([hidden])) #control-area,
#stage:has(#result-panel:not([hidden])) #hud { display: none; }

#overlay:has(#result-panel:not([hidden])) {
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  padding: clamp(8px, 2vmin, 22px);
}
#overlay #result-panel:not([hidden]), dialog.result-dialog[open] {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
}
#overlay #result-panel {
  width: min(392px, 100%);
  max-height: 100%;
  text-align: start;
}
#result-panel:focus, #result-title:focus { outline: none; }
dialog.result-dialog[open] {
  width: min(430px, calc(100% - 20px));
  max-height: calc(100% - 20px);
  max-height: calc(100dvh - max(10px, env(safe-area-inset-top)) - max(10px, env(safe-area-inset-bottom)));
}
.result-body {
  flex: 0 1 auto;
  min-height: 0;
  padding: 16px 18px 12px;
  overflow: auto;
  overscroll-behavior: contain;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}
.result-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.result-heading > div:first-child { flex: 1; min-width: 0; }
#result-panel .result-heading h2 { margin: 2px 0 0; line-height: 1.16; }
#result-panel .result-heading .eyebrow { margin: 0; }
#result-panel .result-score { flex-wrap: wrap; gap: 4px; min-width: 0; }
#result-panel .result-score strong { font-size: clamp(30px, 5vw, 44px); }
#result-panel .result-heading .close-button {
  position: static;
  flex: none;
  align-self: flex-start;
  width: 44px;
  height: 44px;
}
#result-panel :is(.each, .bouts) {
  justify-content: flex-start;
  max-height: none;
  overflow: visible;
}
#result-record:not(:empty) + #result-best { display: none; }
#submit-status:not(:empty) { border-inline-start: 2px solid var(--accent); padding-inline-start: 8px; }
.result-footer {
  flex: none;
  padding: 8px 12px 5px;
  border-top: 1px solid var(--line);
}
.result-footer :is(.actions, .result-actions, .share-actions) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
}
.result-footer button {
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  height: auto;
  margin: 0;
  padding: 6px 8px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
}
#result-panel .result-footer .result-ranks {
  margin: 2px 0 0;
  background: transparent;
  border: 0;
  color: var(--accent);
}
.result-dialog .share-actions { margin: 2px 0 0; }
.result-dialog .result-footer .text-button { width: 100%; }
.result-dialog #share-fallback { max-width: 100%; box-sizing: border-box; }
@media (max-aspect-ratio: 1/1) {
  #overlay:has(#result-panel:not([hidden])) { place-items: end center; }
}
@media (max-height: 450px) and (min-width: 480px) {
  #result-panel .result-footer {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 6px;
    padding: 6px 8px;
  }
  #result-panel .result-footer .result-ranks { margin: 0; }
  .result-body { padding: 9px 12px; }
}
