/* The owner's death artwork, graded and lit in layers. Only the details scroll; actions stay in view. */
#overlay.death {
  isolation: isolate;
  overflow: hidden;
  padding: 12px;
  border: 0;
  border-image: none;
  background: radial-gradient(ellipse at 50% 43%, rgb(19 5 3 / 48%) 8%, rgb(8 3 2 / 75%) 58%, rgb(0 0 0 / 94%) 100%);
  backdrop-filter: blur(2px) saturate(.48);
  -webkit-backdrop-filter: blur(2px) saturate(.48);
  -webkit-font-smoothing: antialiased;
  animation: death-reveal .5s ease-out both;
}
#overlay.death::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 88%, rgb(120 15 3 / 20%), transparent 51%), linear-gradient(0deg, rgb(0 0 0 / 48%), transparent 30%);
}
#overlay .death-card {
  position: relative;
  isolation: isolate;
  flex: none;
  width: min(840px, calc(100vw - 32px), calc((100dvh - 24px) * .93822));
  aspect-ratio: 1215 / 1295;
  max-width: none;
  padding: 0;
  border: 0;
  background: none;
  outline: none;
  text-align: center;
  transform: none;
  animation: death-arrive .65s cubic-bezier(.2, 0, 0, 1) both;
}
.death-aura {
  position: absolute;
  z-index: -1;
  inset: 7% 0 3%;
  border-radius: 45%;
  background: radial-gradient(ellipse at 50% 23%, rgb(145 29 9 / 35%), transparent 58%), radial-gradient(ellipse at 50% 80%, rgb(135 16 4 / 29%), transparent 64%);
  filter: blur(24px);
  animation: death-breathe 6s ease-in-out infinite alternate;
}
.death-art { position: absolute; inset: 0; pointer-events: none; }
.death-art img {
  display: block;
  width: 100%;
  height: auto;
  filter: saturate(.62) brightness(.66) contrast(1.12) drop-shadow(0 12px 24px rgb(0 0 0 / 70%)) drop-shadow(0 0 15px rgb(125 22 8 / 24%));
}
.death-shade {
  position: absolute;
  inset: 39% 17% 13%;
  pointer-events: none;
  background: radial-gradient(ellipse, rgb(8 5 4 / 92%) 15%, rgb(10 6 4 / 74%) 56%, transparent 74%);
}
#overlay .death-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.death-content {
  position: absolute;
  inset: 42.5% 22% 18.5%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(6px, 1.15vh, 11px);
  min-height: 0;
  color: #deccb0;
  text-shadow: 0 2px 4px #000;
  animation: death-reveal .65s .16s ease-out both;
}
.death-details { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #795034 transparent; padding: 0 5px; }
#overlay .death-cause { margin: 0 0 13px; color: #ead4b4; font-size: clamp(17px, 2.15vh, 23px); line-height: 1.22; text-wrap: balance; }
#overlay .death-cause b { font-weight: 600; color: #f0c59d; }
.death-loss { display: flex; align-items: center; justify-content: center; gap: 13px; margin: 22px auto; padding: 12px 0; background: radial-gradient(ellipse, rgb(88 23 10 / 18%), transparent 70%); }
.death-loss > img { width: 40px; height: 40px; object-fit: contain; filter: saturate(.65) brightness(.85); }
#overlay .death-loss p { display: grid; gap: 4px; margin: 0; text-align: left; }
.death-loss span { color: #b7a081; font-size: 15px; line-height: 1.2; }
.death-loss strong { color: #eb9675; font: 400 clamp(26px, 3.6vh, 36px)/1 'Cinzel', Georgia, serif; font-variant-numeric: tabular-nums; text-shadow: 0 0 18px rgb(194 50 20 / 24%), 0 2px 4px #000; }
.death-loss-none strong { color: #b5c6a1; text-shadow: 0 2px 4px #000; }
.death-loss-none { background: none; }
#overlay .death-note { margin: 10px 4px 0; color: #b9a58b; font-size: clamp(13px, 1.65vh, 15px); line-height: 1.3; text-wrap: pretty; }
#overlay .death-counter b { color: #d7b481; font-weight: 600; }
.death-actions { flex: none; display: grid; justify-items: center; gap: 4px; }
#overlay #death-actions .mbtn {
  position: relative;
  display: grid;
  place-items: center;
  width: 80%;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-image: none;
  box-shadow: none;
  background: none;
  cursor: pointer;
  filter: saturate(.65) brightness(.82) drop-shadow(0 5px 7px rgb(0 0 0 / 65%));
  transition: filter .2s ease, transform .16s ease;
}
#overlay #death-actions .death-return { aspect-ratio: 2135 / 570; overflow: hidden; }
.death-return img { position: absolute; left: 0; top: -9.3%; width: 100%; height: auto; pointer-events: none; }
#overlay #death-actions .mbtn:hover { background: none; filter: saturate(.85) brightness(1) drop-shadow(0 0 11px rgb(177 36 11 / 47%)); }
#overlay #death-actions .mbtn:active { transform: scale(.96); }
#overlay #death-actions .mbtn:focus-visible, .death-details:focus-visible { outline: 1px solid #dfbb78; outline-offset: 4px; }
#overlay #death-actions .death-respawn { padding: 10px 14px; border: 1px solid #805331; background: linear-gradient(#422017, #1f100b); color: #f1d4a0; font-size: 14px; line-height: 1.25; letter-spacing: .03em; }
#overlay #death-actions:has(> :nth-child(2)) { grid-template-columns: 1fr 1fr; gap: 12px; align-items: center; }
#overlay #death-actions:has(> :nth-child(2)) .mbtn { width: 100%; }
#overlay .death-keyhint { flex: none; margin: 0; color: #a18b6f; font-size: 13px; line-height: 1.2; }
.death-embers { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.death-embers i { position: absolute; left: calc(var(--x) * 1%); top: calc(46% + var(--y) * .5%); width: 2px; height: 3px; border-radius: 50%; background: #b95228; box-shadow: 0 0 7px #bb3216; opacity: 0; animation: death-ember calc(var(--d) * 2) var(--delay) linear infinite; }
@keyframes death-reveal { from { opacity: 0; } to { opacity: 1; } }
@keyframes death-arrive { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes death-breathe { from { opacity: .55; transform: scale(.97); } to { opacity: .95; transform: scale(1.025); } }
@keyframes death-ember { 0%, 100% { opacity: 0; } 20%, 65% { opacity: .6; } 100% { transform: translate(25px, -130px); } }

/* Narrow screens retain the crest at its natural ratio above a readable, scrolling body. */
@media (max-width: 600px) {
  #overlay .death-card { width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); aspect-ratio: auto; display: flex; flex-direction: column; background: radial-gradient(ellipse at top, #25100b, #100b08 65%); box-shadow: 0 15px 60px #000, inset 0 0 0 1px rgb(164 110 56 / 28%); }
  .death-art { position: relative; inset: auto; width: 100%; aspect-ratio: 1215 / 545; overflow: hidden; flex: none; }
  .death-content { position: relative; inset: auto; padding: 5px 7% 22px; min-height: 0; gap: 12px; }
  .death-shade { display: none; }
  #overlay .death-cause { font-size: 19px; }
  .death-loss { margin: 16px auto; }
  #overlay #death-actions .mbtn { width: 94%; }
  #overlay .death-note { font-size: 14px; }
}
/* Landscape phones and short windows use the crest on the left, with the same facts and actions on the right. */
@media (max-height: 560px) and (min-width: 601px) {
  #overlay.death { padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  #overlay .death-card { width: min(860px, 100%); height: 100%; max-height: 420px; aspect-ratio: auto; background: radial-gradient(ellipse at 24% 48%, #2b110a, #100907 67%); box-shadow: 0 15px 70px #000, inset 0 0 0 1px rgb(164 110 56 / 26%); }
  .death-art { inset: 50% auto auto 1%; width: 43%; aspect-ratio: 1215 / 555; overflow: hidden; transform: translateY(-50%); }
  .death-aura { inset: 4% 45% 4% -5%; }
  .death-shade { display: none; }
  .death-content { inset: 18px 4% 18px 46%; gap: 8px; }
  #overlay .death-cause { font-size: 18px; margin-bottom: 10px; }
  .death-loss { margin: 10px auto; padding: 6px 0; }
  #overlay .death-note { font-size: 14px; }
  #overlay .death-keyhint { display: none; }
  #overlay #death-actions .death-return { width: min(88%, 280px); }
  #overlay #death-actions:has(> :nth-child(2)) .mbtn { width: 100%; }
}
body.mobile #overlay .death-keyhint { display: none; }
@media (prefers-reduced-motion: reduce) {
  #overlay.death, #overlay .death-card, .death-content, .death-aura, .death-embers i { animation: none; }
  #overlay #death-actions .mbtn { transition: none; }
}
.quest-reduced-motion #overlay.death, .quest-reduced-motion #overlay .death-card, .quest-reduced-motion .death-content, .quest-reduced-motion .death-aura, .quest-reduced-motion .death-embers i { animation: none; }
