/* 七つの結算面。盤の大きさ・皮膚・操作モードは従来の .game-overlay に従う。 */
.game-overlay[data-result-card] {
  --result-width: min(100%, 270px);
  gap: clamp(3px, calc((100% - 235px) / 6), 10px); padding: 12px min(5%, 20px); line-height: 1.45; color: var(--ink);
  container: result / size;
}
[data-result-card] > * { flex: none; max-width: 100%; }
.result-heading { display: flex; justify-content: center; align-items: center; gap: 8px; }
[data-result-card] .result-heading strong { font-size: 13px; font-weight: 800; color: var(--sub); }
[data-result-card] .new-best {
  background: var(--gold); color: var(--ink); border-radius: var(--radius-pill);
  padding: 1px 12px; font-size: 12px; font-weight: 900; letter-spacing: 0; white-space: nowrap;
}
[data-result-card] .final-score { font-size: min(46px, 17cqw); font-weight: 400; line-height: 1; color: var(--ink); }
[data-result-card].game-overlay p.result-meta {
  display: flex; flex-wrap: wrap; justify-content: center; column-gap: 8px;
  font-size: 12px; font-weight: 700; color: var(--sub); line-height: 1.35;
}
.result-meta > span { white-space: nowrap; }
.result-meta b, .result-standing { color: var(--ink); font-weight: 900; }
.result-meta > span:has(> [data-sprint-reached]:empty), .result-standing:empty, [data-result-card] [hidden] { display: none !important; }

/* 挑戦相手・題型の内訳。見出しだけの対決（時間の板で途中終了）も残す。 */
.result-info {
  width: var(--result-width); display: flex; flex-direction: column; gap: 2px;
  text-align: left; line-height: 1.35; transition: opacity .25s ease-out, transform .25s ease-out;
}
.result-info-row:is([hidden], :has(> b:is(:empty, [hidden]))) { display: none; }
.result-info:not(:has(.result-info-head, > .result-info-row:not([hidden]) > b:not(:empty):not([hidden]))) { display: none; }
.result-info-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12.5px; }
.result-info-row span { color: var(--sub); overflow-wrap: anywhere; }
.result-info-row b { color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
.result-info-bar { height: 6px; background: var(--soft); border-radius: var(--radius-pill); overflow: hidden; }
.result-info-bar i { display: block; height: 100%; background: var(--cta); border-radius: inherit; transition: width .5s ease-out; }

[data-result-card] .progress-result {
  width: var(--result-width); gap: 8px; padding: 0; border: 0; background: none;
  color: var(--sub); font-size: 11.5px;
}
[data-result-card] .progress-result .progress-bar { flex: 1 1 24px; min-width: 24px; width: 24px; max-width: none; height: 5px; }
[data-result-card] .progress-result span:last-child { flex: 0 1 auto; max-width: 64%; }

[data-result-card] .score-form {
  box-sizing: border-box; width: var(--result-width); max-width: none; height: 42px; margin-top: 6px;
  flex-direction: row; align-items: stretch; gap: 0; overflow: hidden;
  border: var(--stroke-w) solid var(--stroke); border-radius: var(--radius-inner); background: var(--surface);
}
[data-result-card] .score-form input {
  flex: 1; min-width: 0; padding: 0 12px; text-align: left; border: 0; border-radius: 0;
  background: transparent; color: var(--ink); font: inherit; font-size: 16px;
}
[data-result-card] .score-form input::placeholder { color: var(--muted); }
.result-register {
  flex: none; padding: 0 18px; border: 0; border-left: var(--stroke-w) solid var(--stroke);
  background: var(--gold); color: var(--ink); font: inherit; font-size: 15px; font-weight: 900;
}
[data-result-card] .share-row { width: var(--result-width); margin-top: 4px; }
[data-result-card] .share-row .primary-button {
  box-sizing: border-box; width: 100%; min-height: 50px; padding: 4px 10px;
  border: var(--stroke-w) solid var(--stroke); border-radius: var(--radius-pill); box-shadow: var(--shadow-solid);
  background: var(--cta); color: var(--brand-body); font-size: 17px; font-weight: 900; letter-spacing: 0; text-decoration: none;
}
.share-row :is(.result-short, [data-work-next]:disabled), .share-row .primary-button > svg { display: none; }

/* 原要素を 1 行に並べる。余った幅を間に分け、5 個のときは間と文字を先に詰める。 */
.result-actions {
  width: 100%; max-width: 350px; display: flex; justify-content: center; gap: 22px; margin-top: 2px;
}
[data-result-card] .result-actions > :is(button, a) {
  box-sizing: border-box; display: grid; justify-items: center; align-content: start; gap: 4px;
  flex: 0 1 auto; min-width: var(--result-hit, 40px); min-height: var(--result-hit, 40px); padding: 4px 0; border: 0; box-shadow: none;
  background: none; color: var(--ink); font: inherit; font-size: 11.5px; font-weight: 800; line-height: 1.35;
  letter-spacing: 0; text-decoration: none; white-space: nowrap;
}
.result-actions svg {
  display: block; margin-inline: auto; box-sizing: border-box; width: 42px; height: 42px; padding: 9px; background: var(--soft); border-radius: 50%;
}
.result-actions .result-full, body:not(.is-challenge) [data-result-card] .result-actions [data-result-leave] { display: none; }
@media (min-width: 561px) {
  [data-skin="plain"] .result-actions { --result-hit: max(40px, calc(40px / var(--scale, 1))); }
  [data-result-card] .result-actions [data-stage-pick] { display: none; }
}
.result-actions:has(> :nth-child(4 of :not([hidden]))) { gap: clamp(0px, calc((100cqw - 254px) / 4), 22px); }
@container result (max-width: 305px) {
  .result-actions .result-short { font-size: clamp(9px, 3.6cqw, 11.5px); }
}

/* 対決では差・相手・名次も載る。短い盤では比較の棒を数字の横に置く。 */
.game-overlay[data-result-card]:has(.result-info-head) { row-gap: 3px; }
@container result (max-height: 360px) {
  .result-info:has(.result-info-head) { display: grid; grid-template-columns: 1fr minmax(20px, 25%); align-items: center; }
  .result-info-head, .result-info-row:not(:has(+ .result-info-bar)) { grid-column: 1 / -1; }
  .result-info .result-info-head { gap: 0; padding: 0; }
  .result-info .result-info-head strong { font-size: 14px; }
  .result-info-head span, .result-info-row { font-size: 11px; }
  .result-info-bar { height: 4px; }
}

/* 送る前に名前を聞く窓（ui/ask-name.js）。 */
.ask-name { display: flex; flex-direction: column; align-items: stretch; gap: 10px; min-width: min(300px, 80vw); text-align: center; }
.ask-name p { margin: 0; font-size: 13px; color: var(--sub); }
.ask-name input { font: inherit; font-size: 15px; padding: 9px 12px; border: var(--stroke-w) solid var(--stroke); border-radius: var(--radius); background: var(--surface); color: var(--ink); }

.game-overlay[data-result-moment="plain"] [data-new-best] { display: none !important; }
.game-overlay[data-result-step="count"] .new-best { visibility: hidden; }
.game-overlay[data-result-step="stamp"] .new-best { animation: result-stamp .25s ease-out; }
.game-overlay:is([data-result-step="count"], [data-result-step="stamp"]) :is(.result-info, .result-standing) { opacity: 0; }
.game-overlay:is([data-result-step="count"], [data-result-step="stamp"]) .result-info-bar i { width: 0 !important; }
.game-overlay[data-result-step="done"] .share-row .primary-button { animation: result-bounce .4s ease-out; }
@keyframes result-stamp { 0% { scale: 1.5; opacity: 0; } 70% { scale: .95; opacity: 1; } 100% { scale: 1; } }
@keyframes result-bounce { 0%, 100% { translate: 0 0; } 40% { translate: 0 -4px; } }
@media (prefers-reduced-motion: reduce) {
  .game-overlay .new-best, .game-overlay .share-row .primary-button { animation: none !important; }
  .result-info, .result-info-bar i { transition: none; }
}

@media (max-height: 600px) {
  .game-overlay[data-result-card] { gap: clamp(1px, calc((100% - 245px) / 6), 5px); padding-block: 6px; }
  [data-result-card] .final-score { font-size: 34px; }
  [data-result-card] .score-form, [data-result-card] .share-row { margin-top: 0; }
  [data-result-card] .share-row .primary-button { min-height: 42px; }
  [data-result-card] .result-actions > :is(button, a) { padding: 0; gap: 1px; }
  .result-actions svg { width: 32px; height: 32px; padding: 6px; }
}
/* 細い盤（作品の 360×640 など）。絵の丸と釦を詰め、XP の行のミッション名は出さない。 */
@container result (max-width: 305px) {
  [data-result-card] .progress-result span:last-child { display: none; }
  [data-result-card] .score-form input { padding: 0 6px; }
  .result-register { padding: 0 11px; }
}
@container result (max-width: 235px) {
  [data-result-card] .result-heading { gap: 4px; }
  [data-result-card] .result-heading strong { font-size: 12px; }
  [data-result-card] .new-best { padding: 1px 7px; font-size: 11px; }
  [data-result-card] .final-score { font-size: 32px; }
  [data-result-card] .share-row, .result-actions { margin-top: 0; }
  [data-result-card] .share-row .primary-button { min-height: 42px; }
  [data-result-card] .result-actions > :is(button, a) { padding: 0; gap: 1px; }
  .result-actions svg { width: 32px; height: 32px; padding: 6px; }
}
@container result (max-height: 280px) {
  [data-result-card] .score-form { height: 32px; margin-top: 0; }
  [data-result-card] .share-row, .result-actions { margin-top: 0; }
  [data-result-card] .result-info-head { flex-direction: row; flex-wrap: wrap; justify-content: center; column-gap: 6px; }
}
.game-overlay[data-result-card][data-progress-tight] { row-gap: 1px; }
