/* The result belongs to the final room. Both actor stages remain mounted so
   native death poses, integer pixel scales and the scenery's floor stay real. */
/* Desktop retains the combat grid, including invisible HUD/item rows. Changing
   those rows after death would resize the shared native pixel grid. */
.ended-layout .battle-scenery::after { --ending-floor: calc(var(--scene-top, 0px) + var(--scene-height, 100dvh) * .66); background: radial-gradient(ellipse at 50% 42%, #141b22e8, #141b2299 42%, #141b2240 78%), linear-gradient(to bottom, #141b2240, transparent 45%, #141b22e8); }
.ended-layout .fighter > :not(.actor-stage) { visibility: hidden; pointer-events: none; }
.ended-layout :is(.intent, .victory-loot) { display: none; }
.ending-panel { position: relative; z-index: 2; grid-column: 2; grid-row: 1; min-width: 0; width: min(100%, 420px); justify-self: center; align-self: center; text-align: center; color: #f1e6cc; }
.ending-heading { padding-bottom: 26px; text-shadow: 0 2px 12px #11181d; }
.ending-where { color: #c9bea3; font-size: 12px; line-height: 1.6; text-wrap: balance; }
.ending-heading h2 { max-width: 14ch; margin: 13px auto 0; font: 400 clamp(34px, 3.3vw, 44px)/1.12 Georgia, serif; letter-spacing: -.025em; text-wrap: balance; }
.ending-heading h2:focus { outline: none; }
.ending-emblem { color: #d9bb7f; margin-bottom: 14px; }
.ending-emblem .icon { width: 30px; height: 30px; }
.ending-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: auto auto; row-gap: 7px; margin: 0; padding: 19px 0 17px; border-block: 1px solid #d7c49a33; }
.ending-totals > div { display: grid; grid-row: 1 / span 2; grid-template-rows: subgrid; padding-inline: 8px; }
.ending-totals > div + div { border-inline-start: 1px solid #d7c49a26; }
.ending-totals dt { grid-row: 2; color: #d1c8b5; font-size: 10px; line-height: 1.5; letter-spacing: .04em; overflow-wrap: anywhere; }
.ending-totals dd { grid-row: 1; margin: 0; color: #e9d7b1; font-size: 27px; line-height: 1; font-weight: 500; font-variant-numeric: tabular-nums; }
.ending-word { margin-top: 24px; }
.ending-word > p { margin-bottom: 10px; color: #c1baa8; font-size: 12px; }
.ending-tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.ending-tile { display: grid; place-items: center; min-width: 36px; min-height: 40px; padding: 3px 6px; border: 1px solid #bbaa824a; border-bottom-width: 3px; border-radius: 2px; background: #303b40e6; color: #f0e7d2; font-size: 19px; font-weight: 650; }
.ending-tile.found { background: #415e42; border-color: #99b27e73; }
.ending-actions { display: grid; gap: 5px; margin-top: 26px; }
.ending-primary { width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 52px; padding: 12px 20px; border: 1px solid #eddaaa; border-bottom: 3px solid #9d804b; border-radius: 3px; background: #d8bd85; box-shadow: 0 3px 12px #10151b30; color: #292920; font-size: 15px; font-weight: 600; text-decoration: none; }
.ending-primary:hover { background: #e6cc94; border-color: #f6e4b8; border-bottom-color: #ad8e54; }
.ending-primary .icon { width: 18px; height: 18px; }
.ending-share { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: #ccc3af; font-size: 13px; text-decoration: none; }
.ending-share:hover { color: #f1e6cc; background: #e0ca9520; }
.ending-share .icon { width: 15px; height: 15px; }
.daily-reset { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; align-items: center; padding: 8px 0; text-align: start; }
.daily-reset span { color: #c9bea3; font-size: 12px; }
.daily-reset strong { grid-column: 2; grid-row: 1 / span 2; font-size: 23px; font-weight: 500; font-variant-numeric: tabular-nums; color: #e9d7b1; }
.daily-reset small { color: #aca695; font-size: 10px; }
.daily-gate [data-daily-next] { margin-top: 16px; }
.settings-daily { margin: 10px 0 20px; }
.settings-daily > p { color: var(--muted); font-size: 12px; line-height: 1.6; }
.ending-haul { margin-top: 22px; }
.ending-haul .loot-summary { justify-content: center; }
.ending-line { margin: 18px 0 12px; color: #c1baa8; font-size: 13px; }
/* A quiet, separate question after the player has seen their result. Both
   answers have equal weight, generous touch targets and normal keyboard focus. */
.stats-ask { margin-top: 4px; padding-top: 12px; border-top: 1px solid #d7c49a33; text-align: start; }
.stats-ask h3 { font-size: 13px; font-weight: 600; color: #d9ceba; }
.stats-ask p { margin: 7px 0 12px; font-size: 12px; line-height: 1.7; color: #bdb7aa; }
.stats-ask-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stats-ask-actions button { min-height: 44px; padding: 9px 12px; border: 1px solid #d7c49a4d; border-radius: 3px; background: #151e25a6; color: #ddd2bd; font-size: 13px; }
.stats-ask-actions button:hover { background: #d7c49a20; border-color: #d7c49a80; }
.stats-ask a { display: inline-block; padding-block: 12px 4px; color: #bdb7aa; font-size: 11px; text-underline-offset: 3px; }

@media (max-width: 900px) and (orientation: portrait), (max-width: 699px) {
  /* The actors occupy an actual grid row between the heading and the result;
     longer translations and the consent question cannot collide with them. */
  .ended-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(84px, 1fr) auto; padding-block: calc(var(--hud-space, 56px) + 24px) 28px; column-gap: 0; }
  /* Shade the result from the actual standing plane, so longer copy or the
     optional question cannot move the bright floor behind the small labels. */
  .ended-layout .battle-scenery::after { background: linear-gradient(to bottom, #141b22b8, #141b2259 calc(var(--ending-floor) - 100px), #141b228c var(--ending-floor), #141b22ed calc(var(--ending-floor) + 110px), #141b22fa calc(var(--ending-floor) + 240px)); }
  .ended-layout .combatants { grid-column: 1; grid-row: 2; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); height: auto; align-self: stretch; column-gap: 24px; padding: 0 20px; }
  .ended-layout .fighter { grid-row: 1; grid-template-rows: minmax(0, 1fr); }
  .ended-layout .actor-stage { grid-row: 1; margin: 0; --foot-inset: 0px; --art-clearance: 0px; }
  .ended-layout .fighter > :not(.actor-stage) { display: none; }
  .ended-layout .enemy-panel { grid-column: 2; }
  .ending-panel { grid-column: 1; grid-row: 1 / span 3; width: 100%; display: grid; grid-template-rows: subgrid; align-self: stretch; pointer-events: none; }
  .ending-heading { grid-row: 1; padding-bottom: 0; }
  .ending-heading h2 { font-size: clamp(32px, 9.2vw, 38px); }
  .ending-where { font-size: 11px; }
  .ending-body { grid-row: 3; width: min(100%, 420px); justify-self: center; padding-top: 24px; pointer-events: auto; }
  .ending-totals { padding-block: 17px; }
  .ending-totals dt { font-size: 10px; }
  .ending-totals dd { font-size: 27px; }
  .ending-word { margin-top: 22px; }
  .ending-actions { margin-top: 24px; }
}
:is(:lang(ar), :lang(hi), :lang(ja), :lang(zh), :lang(ko)) .ending-totals dt { font-size: 12px; letter-spacing: normal; }
@media (min-width: 700px) and (orientation: landscape) and (max-height: 640px) {
  .ended-layout { padding-block: calc(var(--hud-space, 48px) + 16px) 24px; grid-template-columns: minmax(0, 1fr) minmax(0, 360px) minmax(0, 1fr); column-gap: 16px; }
  .ending-heading { padding-bottom: 18px; }
  .ending-heading h2 { font-size: 32px; }
  .ending-totals { padding-block: 14px; }
  .ending-word, .ending-actions { margin-top: 18px; }
}

.stats-consent { margin-top: 8px; pointer-events: auto; }
.stats-consent > summary { min-height: 44px; padding: 12px 4px; color: #c9c0ad; font-size: 12px; cursor: pointer; }
/* Keep the result, answer and restart in the viewport on short screens.
   The arena takes the remaining space; text and controls retain real rows. */
@media (max-height: 760px) {
  .ending-heading { padding-bottom: 10px; }
  .ending-heading h2 { max-width: 100%; margin-top: 6px; font-size: 28px; }
  .ending-emblem { margin-bottom: 4px; }
  .ending-emblem .icon { width: 22px; height: 22px; }
  .ending-body { padding-top: 8px; }
  .ending-totals { padding-block: 8px; row-gap: 5px; }
  .ending-totals dd { font-size: 24px; }
  .ending-word, .ending-actions, .ending-haul { margin-top: 10px; }
  .ending-panel:not(.trial-ending) .ending-actions { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .ending-word > p { margin-bottom: 6px; }
  .ending-tile { min-width: 32px; min-height: 36px; }
  .ending-primary { min-height: 44px; padding: 8px 12px; }
  .ending-line { margin-block: 8px; }
}
@media (max-width: 900px) and (max-height: 760px), (max-height: 640px) {
  .ended-layout { padding-block: calc(var(--hud-space, 56px) + 6px) 8px; }
}
@media (min-width: 700px) and (orientation: landscape) and (max-height: 480px) {
  .ended-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 560px) minmax(0, 1fr); }
  .ending-heading h2 { font-size: 26px; }
  .ending-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
  .ending-totals { grid-column: 1; }
  .ending-word, .ending-haul { grid-column: 2; margin-top: 0; }
  .ending-actions, .stats-consent { grid-column: 1 / -1; margin-top: 0; }
  .ending-actions { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .ending-share { padding-inline: 6px; font-size: 12px; }
  .ending-where { font-size: 10px; }
}
