/* =========================================================
   El Reto de Pipe — Pipe Gomitas
   ========================================================= */

:root {
  --sky: #00b4f0;
  --sky-deep: #0677c0;
  --navy: #14123a;
  --yellow: #f2f51f;
  --orange: #ff7a1a;
  --pink: #ff2e63;
  --red: #e8173f;
  --ink: #1d1530;
  --muted: #5d5873;
  --card: #ffffff;
  --radius: 26px;
  --font-display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --controls-h: calc(clamp(78px, 11dvh, 104px) + var(--safe-bottom));
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--sky);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

.app {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.25) 0 8%, transparent 9%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.18) 0 10%, transparent 11%),
    var(--sky);
}

.viewport {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.25);
}

/* Fondo fijo */
.scene {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #2a2350 url('../assets/bg/novena.webp') center bottom / cover no-repeat;
}

/* ---------- Pantallas ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.screen.is-active {
  display: flex;
  animation: screen-in 0.35s ease-out both;
}

@keyframes screen-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- Tipografía de marca ---------- */
.title-candy {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: #ff4f3a;
  text-align: center;
  text-shadow:
    3px 0 0 var(--yellow), -3px 0 0 var(--yellow), 0 3px 0 var(--yellow), 0 -3px 0 var(--yellow),
    2px 2px 0 var(--yellow), -2px 2px 0 var(--yellow), 2px -2px 0 var(--yellow), -2px -2px 0 var(--yellow),
    6px 0 0 #fff, -6px 0 0 #fff, 0 6px 0 #fff, 0 -6px 0 #fff,
    4px 4px 0 #fff, -4px 4px 0 #fff, 4px -4px 0 #fff, -4px -4px 0 #fff,
    0 9px 0 rgba(20, 18, 58, 0.35);
}

.title-candy--md {
  font-size: clamp(30px, 9vw, 40px);
}

/* ---------- Tarjetas y botones ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: 0 6px 0 rgba(20, 18, 58, 0.18), 0 18px 40px rgba(20, 18, 58, 0.35);
  border: 4px solid var(--yellow);
}

.card--center {
  text-align: center;
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.04em;
  color: #fff;
  transition: transform 0.08s ease, filter 0.15s ease, box-shadow 0.08s ease;
  user-select: none;
  -webkit-user-select: none;
}

.btn--primary {
  background: linear-gradient(180deg, #ff9a3c 0%, var(--orange) 35%, var(--pink) 100%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.45), 0 5px 0 #b3123f, 0 10px 18px rgba(179, 18, 63, 0.35);
  text-shadow: 0 2px 0 rgba(140, 10, 50, 0.45);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.45), 0 1px 0 #b3123f, 0 4px 10px rgba(179, 18, 63, 0.3);
}

.btn--primary:disabled {
  filter: grayscale(0.7) brightness(1.05);
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--xl {
  min-height: 60px;
  font-size: 26px;
}

.btn--ghost {
  background: transparent;
  color: var(--sky-deep);
  min-height: 44px;
  font-size: 17px;
}

.btn--ghost:active {
  transform: scale(0.97);
}

.link-btn {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  text-decoration: underline;
  padding: 8px;
}

.form-error {
  margin: 0;
  min-height: 0;
  color: var(--red);
  font-weight: 800;
  font-size: 14px;
  text-align: center;
}

.form-error:empty {
  display: none;
}

/* ---------- Carga ---------- */
.screen--loading {
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: var(--sky);
}

.loading__logo {
  width: min(70%, 300px);
  animation: bob 1.6s ease-in-out infinite;
}

.loading__bar {
  width: min(60%, 240px);
  height: 14px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.4);
  border: 3px solid #fff;
  overflow: hidden;
}

.loading__bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--orange), var(--pink));
  transition: width 0.2s ease;
}

.loading__text {
  margin: 0;
  color: #fff;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.03em;
}

@keyframes bob {
  50% { transform: translateY(-8px) rotate(-1deg); }
}

/* ---------- Registro ---------- */
.screen--register {
  padding: calc(10px + var(--safe-top)) 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(0, 180, 240, 0.92) 0%, rgba(0, 180, 240, 0.55) 38%, rgba(20, 18, 58, 0.15) 60%);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.register__hero {
  position: relative;
  flex: 1 1 auto;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
}

.register__logo {
  width: min(48%, 200px);
  filter: drop-shadow(0 4px 0 rgba(20, 18, 58, 0.25));
  animation: pop-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.register__title {
  margin-top: 8px;
  font-size: clamp(34px, 11vw, 50px);
  text-align: left;
  padding-left: 6px;
  animation: pop-in 0.5s 0.1s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.register__pipe {
  position: absolute;
  right: -6px;
  bottom: -26px;
  height: calc(100% + 26px);
  max-height: 340px;
  width: auto;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.35));
  animation: pipe-in 0.6s 0.15s cubic-bezier(0.2, 1.2, 0.4, 1) both;
  pointer-events: none;
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: none; }
}

@keyframes pipe-in {
  from { opacity: 0; transform: translateY(60px); }
  to { opacity: 1; transform: none; }
}

.register__card {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: card-up 0.45s 0.2s cubic-bezier(0.2, 1.1, 0.4, 1) both;
}

@keyframes card-up {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: none; }
}

.howto {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.howto li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 14px;
  background: #fff6d6;
  font-size: 12px;
  line-height: 1.1;
  text-align: center;
  color: var(--muted);
}

.howto img,
.howto__gift {
  height: 32px;
  width: auto;
  font-size: 26px;
  line-height: 32px;
}

.howto b {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 16px;
  color: var(--ink);
}

#register-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field__label {
  font-weight: 900;
  font-size: 14px;
  padding-left: 6px;
}

.field input {
  width: 100%;
  min-height: 50px;
  padding: 10px 16px;
  border: 3px solid #e4e1ef;
  border-radius: 16px;
  background: #faf9ff;
  font-size: 17px; /* ≥16px evita el zoom automático en iOS */
  font-weight: 800;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 4px rgba(0, 180, 240, 0.2);
}

.field input[aria-invalid='true'] {
  border-color: var(--red);
}

.field__error {
  min-height: 0;
  padding-left: 6px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.field__error:empty {
  display: none;
}

.privacy {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.welcome__hello {
  margin: 4px 0 0;
  font-size: 20px;
  font-weight: 800;
}

.welcome__best {
  margin: 0 0 4px;
  color: var(--muted);
  font-weight: 800;
}

/* ---------- Juego ---------- */
.screen--game {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.game__canvas {
  position: absolute;
  inset: 0;
  display: block;
}

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(232, 23, 63, 0.65) 100%);
}

.flash.is-on {
  animation: flash 0.45s ease-out;
}

@keyframes flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* HUD */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: 'score lives sound' 'level level level';
  align-items: center;
  gap: 6px 10px;
  padding: calc(10px + var(--safe-top)) 14px 0;
  pointer-events: none;
}

.hud__score {
  grid-area: score;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 118px;
  padding: 4px 16px 6px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ff9a3c, var(--pink));
  border: 3px solid var(--yellow);
  box-shadow: 0 4px 0 rgba(20, 18, 58, 0.35);
  color: #fff;
}

.hud__label {
  font-family: var(--font-body);
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 0.12em;
  opacity: 0.95;
}

.hud__value {
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(140, 10, 50, 0.45);
  font-variant-numeric: tabular-nums;
}

.hud__score.is-bump {
  animation: bump 0.22s ease-out;
}

.hud__score.is-hurt {
  animation: hurt 0.4s ease-out;
}

@keyframes bump {
  50% { transform: scale(1.1); }
}

@keyframes hurt {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

.hud__sound {
  grid-area: sound;
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 0 rgba(20, 18, 58, 0.3);
  color: #14123a;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hud__sound svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.hud__sound:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(20, 18, 58, 0.3);
}
.hud__sound-off,
.hud__sound[aria-pressed='true'] .hud__sound-on {
  display: none;
}
.hud__sound[aria-pressed='true'] .hud__sound-off {
  display: block;
}

.hud__lives {
  grid-area: lives;
  justify-self: end;
  display: flex;
  gap: 4px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 0 rgba(20, 18, 58, 0.3);
}

.heart {
  width: 30px;
  height: 30px;
  transition: transform 0.2s ease;
}

.heart path {
  fill: #ff2e4d;
  stroke: #b00f2f;
  stroke-width: 1.5;
  transition: fill 0.2s ease;
}

.heart.is-lost path {
  fill: #1d1530;
  stroke: #000;
}

.heart.is-losing {
  animation: heart-lose 0.5s ease-out;
}

@keyframes heart-lose {
  0% { transform: scale(1); }
  30% { transform: scale(1.5) rotate(-12deg); }
  100% { transform: scale(1); }
}

.hud__level {
  grid-area: level;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(20, 18, 58, 0.55);
  color: #fff;
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.hud__bar {
  width: 70px;
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.hud__bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--yellow), #ffc93c);
  transition: width 0.25s ease;
}

.hud__next {
  opacity: 0.9;
}

/* Toast de nivel */
.toast {
  position: absolute;
  top: calc(118px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 22px;
  box-shadow: 0 4px 0 rgba(20, 18, 58, 0.35);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.toast.is-on {
  animation: toast 1.4s ease-out;
}

@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -16px) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  25% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

/* Cuenta regresiva */
.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-family: var(--font-display);
  font-size: clamp(90px, 30vw, 140px);
  color: #ff4f3a;
  text-shadow:
    5px 0 0 var(--yellow), -5px 0 0 var(--yellow), 0 5px 0 var(--yellow), 0 -5px 0 var(--yellow),
    4px 4px 0 var(--yellow), -4px 4px 0 var(--yellow), 4px -4px 0 var(--yellow), -4px -4px 0 var(--yellow),
    9px 0 0 #fff, -9px 0 0 #fff, 0 9px 0 #fff, 0 -9px 0 #fff,
    7px 7px 0 #fff, -7px 7px 0 #fff, 7px -7px 0 #fff, -7px -7px 0 #fff,
    0 14px 0 rgba(20, 18, 58, 0.35);
}

.countdown:empty {
  display: none;
}

.countdown.is-tick {
  animation: tick 0.55s ease-out;
}

@keyframes tick {
  0% { transform: scale(1.8); opacity: 0; }
  30% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 1; }
}

/* Controles táctiles */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--controls-h);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 14px calc(10px + var(--safe-bottom));
  background: linear-gradient(180deg, rgba(20, 18, 58, 0) 0%, rgba(20, 18, 58, 0.55) 45%, rgba(20, 18, 58, 0.75) 100%);
}

.control {
  flex: 1 1 0;
  display: grid;
  place-items: center;
  border: 4px solid var(--yellow);
  border-radius: 28px;
  background: linear-gradient(180deg, #ff9a3c 0%, var(--orange) 30%, var(--pink) 100%);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.45), 0 6px 0 #b3123f;
  color: #fff;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.06s ease;
}

.control svg {
  width: clamp(34px, 9vw, 46px);
  height: clamp(34px, 9vw, 46px);
  fill: none;
  stroke: currentColor;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 0 rgba(140, 10, 50, 0.5));
}

.control.is-pressed {
  transform: translateY(5px) scale(0.97);
  box-shadow: inset 0 4px 0 rgba(255, 255, 255, 0.45), 0 1px 0 #b3123f;
  filter: brightness(1.15) saturate(1.1);
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  background: rgba(20, 18, 58, 0.55);
  animation: screen-in 0.25s ease-out both;
  overflow-y: auto;
}

.overlay > .card {
  width: 100%;
  max-width: 360px;
  margin: auto;
  animation: pop-in 0.4s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.overlay--pause .card p {
  margin: 12px 0 16px;
  color: var(--muted);
  font-weight: 800;
}

/* Premio */
.overlay--reward {
  background: radial-gradient(circle at 50% 40%, rgba(255, 46, 99, 0.55), rgba(20, 18, 58, 0.75));
}

.reward {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 110px 18px 18px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffbe0, #fff);
  border: 5px solid var(--yellow);
  box-shadow: 0 8px 0 rgba(20, 18, 58, 0.3), 0 20px 50px rgba(0, 0, 0, 0.4);
  text-align: center;
  animation: reward-in 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}

@keyframes reward-in {
  from { opacity: 0; transform: scale(0.4) rotate(-6deg); }
  to { opacity: 1; transform: none; }
}

.reward__burst {
  position: absolute;
  left: 50%;
  top: 10px;
  width: 260px;
  height: 260px;
  margin-left: -130px;
  margin-top: -110px;
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 201, 60, 0.55) 0 12deg, transparent 12deg 24deg);
  mask: radial-gradient(circle, #000 30%, transparent 70%);
  -webkit-mask: radial-gradient(circle, #000 30%, transparent 70%);
  animation: spin 8s linear infinite;
  pointer-events: none;
}

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

.reward__pipe {
  position: absolute;
  left: 50%;
  top: -90px;
  height: 190px;
  width: auto;
  transform: translateX(-50%);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.3));
  animation: jump 0.8s ease-in-out infinite;
}

@keyframes jump {
  50% { transform: translate(-50%, -10px); }
}

.reward__kicker {
  margin: 0;
  font-weight: 900;
  color: var(--pink);
  letter-spacing: 0.04em;
}

.reward__title {
  margin: 2px 0 6px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  color: var(--ink);
}

.reward__prize {
  margin: 0 auto 8px;
  display: inline-block;
  padding: 8px 18px;
  border-radius: 16px;
  background: linear-gradient(180deg, #ff9a3c, var(--pink));
  color: #fff;
  font-family: var(--font-display);
  font-size: 28px;
  border: 3px dashed #fff;
  box-shadow: 0 0 0 3px var(--pink);
  animation: bump 0.8s 0.5s ease-in-out 2;
}

.reward__msg,
.reward__keep {
  margin: 0 0 8px;
  font-weight: 800;
  font-size: 15px;
  color: var(--muted);
}

.reward__keep {
  color: var(--sky-deep);
  margin-bottom: 14px;
}

.reward__timer {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.5);
  overflow: hidden;
}

.reward__timer span {
  position: absolute;
  inset: 0;
  background: #fff;
  transform-origin: bottom;
  transform: scaleY(0);
}

.reward__timer span.is-running {
  animation: fill-up var(--reward-time, 3s) linear forwards;
}

@keyframes fill-up {
  to { transform: scaleY(1); }
}

/* Game over */
.overlay--gameover {
  background: rgba(20, 18, 58, 0.7);
}

.gameover {
  position: relative;
  padding-top: 70px;
  margin-top: 70px !important;
}

.gameover__pipe {
  position: absolute;
  left: 50%;
  top: -86px;
  height: 150px;
  width: auto;
  transform: translateX(-50%);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.3));
}

.gameover__title {
  font-size: clamp(38px, 12vw, 48px);
  animation: drop-in 0.6s 0.1s cubic-bezier(0.3, 1.6, 0.5, 1) both;
}

@keyframes drop-in {
  from { opacity: 0; transform: translateY(-40px) scale(1.3); }
  to { opacity: 1; transform: none; }
}

.gameover__label {
  margin: 12px 0 0;
  font-weight: 900;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 13px;
}

.gameover__score {
  margin: 0;
  font-family: var(--font-display);
  font-size: 58px;
  line-height: 1.05;
  color: var(--pink);
  font-variant-numeric: tabular-nums;
}

.gameover__newbest {
  margin: 0 0 6px;
  font-weight: 900;
  color: var(--orange);
  animation: bump 0.6s ease-in-out 3;
}

.gameover__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 10px;
}

.gameover__stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 6px;
  border-radius: 14px;
  background: #f3f1fb;
}

.gameover__stats span {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.gameover__stats b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
}

.prize-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff6d6, #ffe58a);
  border: 2px dashed var(--orange);
  text-align: left;
}

.prize-badge > span {
  font-size: 30px;
}

.prize-badge small {
  display: block;
  font-weight: 800;
  color: var(--muted);
}

.prize-badge b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  color: var(--pink);
}

.gameover .btn--xl {
  margin-top: 4px;
}

/* ---------- Ranking ---------- */
.screen--ranking {
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  background: rgba(20, 18, 58, 0.45);
}

.ranking {
  width: 100%;
  max-width: 380px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 22px;
  animation: card-up 0.4s cubic-bezier(0.2, 1.1, 0.4, 1) both;
}

.ranking__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  min-height: 0;
}

.ranking__row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background: #f3f1fb;
  font-weight: 800;
}

.ranking__pos {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--muted);
}

.ranking__row:nth-child(1) .ranking__pos { background: #ffd23a; color: #7a4b00; }
.ranking__row:nth-child(2) .ranking__pos { background: #dfe3ec; color: #4b5266; }
.ranking__row:nth-child(3) .ranking__pos { background: #f4b183; color: #6b3200; }

.ranking__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking__score {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  color: var(--pink);
  font-variant-numeric: tabular-nums;
}

.ranking__row.is-me {
  background: linear-gradient(180deg, #fff6d6, #ffe58a);
  outline: 3px solid var(--orange);
}

.ranking__row.is-me .ranking__name::after {
  content: ' (tú)';
  color: var(--orange);
}

.ranking__empty {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-weight: 800;
}

.ranking__empty:empty {
  display: none;
}

.ranking__me {
  padding-top: 8px;
  border-top: 2px dashed #e4e1ef;
}

.ranking__actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---------- Orientación ---------- */
.rotate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  background: var(--sky);
  color: #fff;
  text-align: center;
}

.rotate h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 34px;
}

.rotate p {
  margin: 0;
  font-weight: 800;
}

.rotate__phone {
  font-size: 64px;
  animation: rotate-hint 1.6s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 30% { transform: rotate(-90deg); }
  60%, 100% { transform: rotate(0deg); }
}

@media (orientation: landscape) and (max-height: 540px) {
  .rotate {
    display: flex;
  }
}

/* ---------- Ajustes por tamaño ---------- */
@media (max-height: 700px) {
  .register__pipe {
    max-height: 230px;
  }
  .howto {
    display: none;
  }
  .card {
    padding: 14px 14px 12px;
  }
  .gameover__score {
    font-size: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
