:root {
  --rn-death-bg: #040008;
  --rn-death-panel: rgba(26, 0, 24, .72);
  --rn-death-panel-deep: rgba(5, 0, 9, .78);
  --rn-death-pink: #ff2e8a;
  --rn-death-pink-hot: #f8207f;
  --rn-death-pink-soft: #ff72b1;
  --rn-death-line: #c91568;
  --rn-death-cream: #f1d8e3;
  --rn-death-muted: #c99caf;
  --rn-death-yellow: #fff100;
  --rn-death-ease: cubic-bezier(.2, .8, .2, 1);
}

.rn-death {
  position: fixed;
  inset: 0 auto 0 50%;
  z-index: 130;
  width: var(--rr-panel-width);
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  transform: translateX(-50%);
  background: #000;
  color: var(--rn-death-cream);
  font-family: 'Courier New', Courier, monospace;
  text-align: center;
  scrollbar-width: none;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.rn-death::-webkit-scrollbar { display: none; }
.rn-death.hidden { display: none; }

.rn-death__shell {
  position: relative;
  width: 100%;
  min-height: max(100dvh, 844px);
  padding: calc(18px + env(safe-area-inset-top)) clamp(15px, 5.13vw, 20px) calc(15px + env(safe-area-inset-bottom));
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(180deg, transparent 0 72%, rgba(4, 0, 8, .72) 100%),
    var(--rn-death-bg) url('./muerte-fondo@2x.png') top center / 100% auto no-repeat;
}

.rn-death__shell::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, .025) 0,
    rgba(255, 255, 255, .025) 1px,
    transparent 2px,
    transparent 4px
  );
  mix-blend-mode: overlay;
  opacity: .55;
}

.rn-death__sparkles {
  position: absolute;
  inset: 48px 10px auto;
  z-index: 0;
  height: 250px;
  pointer-events: none;
}

.rn-death__sparkles::before,
.rn-death__sparkles::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--rn-death-pink-soft);
  box-shadow:
    28px 18px 0 rgba(255, 114, 177, .72),
    312px 54px 0 rgba(255, 46, 138, .72),
    24px 173px 0 rgba(255, 241, 0, .58),
    326px 196px 0 rgba(255, 114, 177, .68),
    76px 89px 0 rgba(255, 46, 138, .54),
    272px 112px 0 rgba(255, 241, 0, .45);
  filter: drop-shadow(0 0 4px var(--rn-death-pink));
}

.rn-death__sparkles::after {
  right: 0;
  transform: rotate(180deg) scale(.72);
  opacity: .55;
}

.rn-death__header {
  position: relative;
  z-index: 3;
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rn-death__wordmark {
  margin: 0;
  color: var(--rn-death-pink);
  font: 700 28px/.9 Georgia, 'Times New Roman', serif;
  letter-spacing: -1.8px;
  text-shadow: 0 0 4px #ff3d92, 0 0 14px rgba(255, 46, 138, .72);
}

.rn-death__record-pill {
  display: flex;
  min-width: 95px;
  height: 28px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 11px;
  border: 1px solid var(--rn-death-pink);
  border-radius: 999px;
  background: rgba(7, 0, 12, .42);
  box-shadow: inset 0 0 12px rgba(255, 46, 138, .06), 0 0 10px rgba(255, 46, 138, .1);
  font-size: 8px;
  letter-spacing: .4px;
  white-space: nowrap;
}

.rn-death__record-pill img { width: 9px; height: 9px; }
.rn-death__record-pill strong { font-size: 9px; font-weight: 400; }

.rn-death__hero {
  position: relative;
  z-index: 2;
  margin-top: 8px;
}

.rn-death__portrait-orbit {
  position: relative;
  width: 158px;
  height: 154px;
  margin: 0 auto;
}

.rn-death__portrait-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 5px rgba(255, 46, 138, .7));
}

.rn-death__cat {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 2px;
  width: 139px;
  height: auto;
  transform: translateX(-50%);
  transform-origin: 50% 75%;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 6px rgba(255, 46, 138, .38));
}

.rn-death__reason {
  margin: 1px 0 6px;
  color: var(--rn-death-pink-soft);
  font-size: 9px;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.rn-death__title {
  margin: 0;
  color: #fff3f7;
  font: 700 20px/1.1 Georgia, 'Times New Roman', serif;
  letter-spacing: 1px;
  text-shadow: 0 0 4px #fff, 0 0 11px rgba(255, 46, 138, .45);
}

.rn-death__subtitle {
  margin: 6px 0 13px;
  color: #d6adbf;
  font-size: 9px;
}

.rn-death__score-panel {
  position: relative;
  z-index: 2;
  min-height: 169px;
  padding: 13px 12px;
  border: 1px solid var(--rn-death-line);
  border-radius: 12px;
  background: var(--rn-death-panel);
  box-shadow: inset 0 0 32px rgba(70, 0, 54, .18);
  overflow: hidden;
}

.rn-death__score-panel::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -30%;
  width: 22%;
  height: 190%;
  transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .11), transparent);
  pointer-events: none;
}

.rn-death__eyebrow {
  margin: 0;
  color: var(--rn-death-pink-soft);
  font-size: 8px;
  letter-spacing: 3px;
}

.rn-death__score {
  display: block;
  height: 61px;
  color: #fff;
  font: 700 54px/.98 Georgia, 'Times New Roman', serif;
  text-shadow: 0 0 20px rgba(255, 46, 138, .42);
}

.rn-death__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.rn-death__metric {
  min-width: 0;
  min-height: 42px;
  padding: 7px;
  border: 1px solid rgba(201, 21, 104, .75);
  border-radius: 8px;
  background: var(--rn-death-panel-deep);
}

.rn-death__metric span {
  display: block;
  margin-bottom: 3px;
  font-size: 7px;
  letter-spacing: 1.3px;
}

.rn-death__metric strong { color: var(--rn-death-pink-soft); font-size: 16px; }

.rn-death__goal-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 7px;
}

.rn-death__goal-row strong { color: var(--rn-death-yellow); white-space: nowrap; }

.rn-death__progress {
  position: relative;
  height: 6px;
  margin-top: 5px;
  overflow: hidden;
  border: 1px solid var(--rn-death-pink);
  background: rgba(5, 0, 9, .92);
}

.rn-death__progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--rn-death-pink-hot) 0 86%, var(--rn-death-yellow) 86% 100%);
  box-shadow: 0 0 8px var(--rn-death-pink);
  transition: width .78s var(--rn-death-ease);
}

.rn-death__retry {
  position: relative;
  z-index: 2;
  display: flex;
  width: 100%;
  min-height: 57px;
  margin-top: 10px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  overflow: hidden;
  border: 2px solid var(--rn-death-pink-soft);
  border-radius: 13px;
  background: linear-gradient(180deg, #fb2b87, #df1370);
  color: #17000f;
  cursor: pointer;
  box-shadow: 0 0 18px rgba(255, 46, 138, .52), inset 0 0 10px rgba(255, 255, 255, .25);
  font: 900 15px/1 'Courier New', Courier, monospace;
  letter-spacing: 2.5px;
  transition: transform .14s ease, filter .14s ease, box-shadow .14s ease;
}

.rn-death__retry::after {
  content: '';
  position: absolute;
  inset: -80% auto -80% -30%;
  width: 18%;
  transform: rotate(18deg);
  background: rgba(255, 255, 255, .34);
  filter: blur(2px);
  pointer-events: none;
}

.rn-death__retry img { width: 14px; height: 14px; }
.rn-death__retry:hover { filter: brightness(1.1) saturate(1.08); box-shadow: 0 0 27px rgba(255, 46, 138, .7), inset 0 0 12px rgba(255, 255, 255, .3); }
.rn-death__retry:active { transform: scale(.975); filter: brightness(.96); }
.rn-death__retry:disabled { cursor: not-allowed; opacity: .5; filter: grayscale(.45); box-shadow: none; }

.rn-death__retry:focus-visible,
.rn-death__home:focus-visible {
  outline: 2px solid var(--rn-death-yellow);
  outline-offset: 3px;
}

.rn-death__hint {
  position: relative;
  z-index: 2;
  margin: 10px 0 11px;
  color: #caa9b8;
  font-size: 8px;
}

.rn-death__hint strong { color: var(--rn-death-yellow); }

.rn-death__ranking {
  position: relative;
  z-index: 2;
  padding-top: 10px;
  border-top: 1px solid var(--rn-death-line);
}

.rn-death__ranking-head {
  display: flex;
  justify-content: space-between;
  padding: 0 12px 3px;
  color: var(--rn-death-pink-soft);
}

.rn-death__ranking h2,
.rn-death__ranking-head span {
  margin: 0;
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 3px;
}

.rn-death__records {
  width: 100%;
  margin: 0;
  padding: 0 12px;
}

.rn-death__records .rec {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 0;
  min-height: 20px;
  align-items: center;
  padding: 0;
  border-bottom: 1px dashed rgba(201, 21, 104, .5);
  text-align: left;
  font-size: 8px;
}

.rn-death__records .rec span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rn-death__records .rec b { color: var(--rn-death-pink-soft); text-align: right; font-size: 9px; }
.rn-death__records .rec b:first-child { text-align: left; }

.rn-death__home {
  position: relative;
  z-index: 2;
  min-width: 48px;
  min-height: 48px;
  margin-top: 1px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--rn-death-pink-soft);
  cursor: pointer;
  font: 400 8px/1 'Courier New', Courier, monospace;
  letter-spacing: 1.5px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.rn-death__home:hover { color: #fff; text-shadow: 0 0 8px var(--rn-death-pink); }
.rn-death__home:active { transform: translateY(1px); }

.rn-death__closing {
  position: absolute;
  right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 0;
  z-index: 2;
  margin: 0;
  color: #bd8fa5;
  font-size: 6px;
  letter-spacing: 2px;
}

/* La clase se añade cuando termina el impacto de muerte: todas las piezas
   entran por separado y el resultado vuelve a animarse en cada partida. */
.rn-death.is-visible { animation: rnDeathScreenIn .36s ease-out both; }
.rn-death.is-visible .rn-death__wordmark { animation: rnDeathLogoIn .52s var(--rn-death-ease) both; }
.rn-death.is-visible .rn-death__record-pill { animation: rnDeathPillIn .52s .07s var(--rn-death-ease) both; }
.rn-death.is-visible .rn-death__portrait-ring {
  animation: rnDeathRingIn .85s .12s var(--rn-death-ease) both, rnDeathRingTurn 12s 1.1s linear infinite;
}
.rn-death.is-visible .rn-death__cat {
  animation: rnDeathCatIn .62s .2s var(--rn-death-ease) both, rnDeathCatFloat 3s 1.1s ease-in-out infinite;
}
.rn-death.is-visible .rn-death__reason { animation: rnDeathReasonIn .42s .42s var(--rn-death-ease) both; }
.rn-death.is-visible .rn-death__title { animation: rnDeathTitleIn .58s .5s ease-out both; }
.rn-death.is-visible .rn-death__subtitle { animation: rnDeathFadeUp .35s .62s ease-out both; }
.rn-death.is-visible .rn-death__score-panel { animation: rnDeathPanelIn .5s .66s var(--rn-death-ease) both; }
.rn-death.is-visible .rn-death__score-panel::after { animation: rnDeathPanelSweep 1.2s 1s ease-in-out both; }
.rn-death.is-visible .rn-death__metric:first-child { animation: rnDeathMetricPop .38s .88s var(--rn-death-ease) both; }
.rn-death.is-visible .rn-death__metric:last-child { animation: rnDeathMetricPop .38s .97s var(--rn-death-ease) both; }
.rn-death.is-visible .rn-death__retry { animation: rnDeathRetryIn .48s 1.08s var(--rn-death-ease) both; }
.rn-death.is-visible .rn-death__retry::after { animation: rnDeathButtonShine 2.8s 1.65s ease-in-out infinite; }
.rn-death.is-visible .rn-death__hint { animation: rnDeathFadeUp .36s 1.2s ease-out both; }
.rn-death.is-visible .rn-death__ranking { animation: rnDeathFadeUp .42s 1.3s ease-out both; }
.rn-death.is-visible .rn-death__records .rec:nth-child(1) { animation: rnDeathRowIn .32s 1.44s var(--rn-death-ease) both; }
.rn-death.is-visible .rn-death__records .rec:nth-child(2) { animation: rnDeathRowIn .32s 1.53s var(--rn-death-ease) both; }
.rn-death.is-visible .rn-death__records .rec:nth-child(3) { animation: rnDeathRowIn .32s 1.62s var(--rn-death-ease) both; }
.rn-death.is-visible .rn-death__home { animation: rnDeathFadeUp .32s 1.68s ease-out both; }
.rn-death.is-visible .rn-death__closing { animation: rnDeathFadeUp .6s 1.78s ease-out both; }
.rn-death.is-visible .rn-death__sparkles::before { animation: rnDeathSparkle 1.8s .3s ease-in-out infinite alternate; }
.rn-death.is-visible .rn-death__sparkles::after { animation: rnDeathSparkle 2.2s .65s ease-in-out infinite alternate-reverse; }

@keyframes rnDeathScreenIn {
  from { opacity: 0; filter: saturate(.65) brightness(.65); }
  to { opacity: 1; filter: none; }
}

@keyframes rnDeathLogoIn {
  from { opacity: 0; transform: translate(-10px, -8px) skewX(-8deg); }
  70% { transform: translate(2px, 1px) skewX(2deg); }
  to { opacity: 1; transform: none; }
}

@keyframes rnDeathPillIn {
  from { opacity: 0; transform: translateX(14px) scale(.92); }
  to { opacity: 1; transform: none; }
}

@keyframes rnDeathRingIn {
  from { opacity: 0; transform: rotate(-45deg) scale(.7); }
  70% { transform: rotate(8deg) scale(1.04); }
  to { opacity: 1; transform: none; }
}

@keyframes rnDeathRingTurn { to { transform: rotate(360deg); } }

@keyframes rnDeathCatIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(.74) rotate(-7deg); }
  70% { transform: translateX(-50%) translateY(-3px) scale(1.04) rotate(2deg); }
  to { opacity: 1; transform: translateX(-50%); }
}

@keyframes rnDeathCatFloat {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-.6deg); }
  50% { transform: translateX(-50%) translateY(-3px) rotate(.8deg); }
}

@keyframes rnDeathReasonIn {
  from { opacity: 0; letter-spacing: 8px; transform: translateY(4px); }
  to { opacity: 1; letter-spacing: 4px; transform: none; }
}

@keyframes rnDeathTitleIn {
  0% { opacity: 0; transform: scale(.94); text-shadow: none; }
  32% { opacity: 1; }
  42% { opacity: .55; }
  53%, 100% { opacity: 1; transform: none; }
}

@keyframes rnDeathFadeUp {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

@keyframes rnDeathPanelIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@keyframes rnDeathPanelSweep {
  from { left: -30%; }
  to { left: 122%; }
}

@keyframes rnDeathMetricPop {
  from { opacity: 0; transform: translateY(8px) scale(.9); }
  70% { transform: translateY(-2px) scale(1.025); }
  to { opacity: 1; transform: none; }
}

@keyframes rnDeathRetryIn {
  from { opacity: 0; transform: translateY(12px) scale(.94); }
  70% { transform: translateY(-2px) scale(1.015); }
  to { opacity: 1; transform: none; }
}

@keyframes rnDeathButtonShine {
  0%, 38% { left: -30%; opacity: 0; }
  48% { opacity: .85; }
  62%, 100% { left: 118%; opacity: 0; }
}

@keyframes rnDeathRowIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}

@keyframes rnDeathSparkle {
  from { opacity: .25; transform: translateY(0) scale(.8); }
  to { opacity: .85; transform: translateY(-3px) scale(1.2); }
}

@media (max-width: 340px) {
  .rn-death__record-pill { min-width: 88px; padding-inline: 8px; }
  .rn-death__reason { font-size: 8px; letter-spacing: 3px; }
  .rn-death__title { font-size: 18px; }
  .rn-death__retry { font-size: 13px; letter-spacing: 1.8px; }
  .rn-death__ranking-head,
  .rn-death__records { padding-inline: 6px; }
  .rn-death__sparkles { transform: scale(.82); transform-origin: top center; }
}

@media (min-width: 600px) {
  .rn-death { box-shadow: 0 0 60px rgba(255, 46, 138, .18); }
}

@media (prefers-reduced-motion: reduce) {
  .rn-death *,
  .rn-death *::before,
  .rn-death *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
