:root {
  --bg: #050506;
  --bg-panel: #121317;
  --white: #f5f6f8;
  --dim: #8b8f9b;
  --red: #ff2e2e;
  --red-dim: #4d0f0f;
  --celeste: #75aadb;
  --dorado: #ffcc4d;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--white);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

body {
  display: flex;
  justify-content: center;
  padding: 32px 20px 64px;
  transition: background 0.4s ease;
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: inset 0 0 160px 40px rgba(255, 20, 20, 0.55);
}

body.panic {
  background: #1a0303;
}

body.panic .vignette {
  opacity: 1;
  animation: vignette-pulse 0.9s ease-in-out infinite;
}

@keyframes vignette-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.page {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  position: relative;
  z-index: 2;
}

.header {
  text-align: center;
}

.header h1 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: 1px;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--dim);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.timer-section {
  width: 100%;
  text-align: center;
  padding: 28px 10px;
  border-radius: 24px;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 70%);
}

.timer {
  font-family: "SF Mono", "Menlo", "Consolas", "Courier New", monospace;
  font-weight: 800;
  font-size: clamp(3rem, 16vw, 7.5rem);
  letter-spacing: 1px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--white);
  text-shadow: 0 0 40px rgba(255, 255, 255, 0.15);
  transition: color 0.2s ease;
}

.timer.panic {
  color: var(--red);
  animation: timer-shake 0.35s ease-in-out infinite;
  text-shadow: 0 0 50px rgba(255, 46, 46, 0.85), 0 0 12px rgba(255, 46, 46, 0.9);
}

/* Tiembla como si estuviera a punto de explotar, no solo "respira". */
@keyframes timer-shake {
  0%, 100% { transform: translate(0, 0) scale(1); }
  10% { transform: translate(-3px, 1px) scale(1.015); }
  20% { transform: translate(3px, -2px) scale(1.03); }
  30% { transform: translate(-4px, 0) scale(1.02); }
  40% { transform: translate(4px, 2px) scale(1.045); }
  50% { transform: translate(-3px, -1px) scale(1.03); }
  60% { transform: translate(3px, 1px) scale(1.02); }
  70% { transform: translate(-2px, -2px) scale(1.035); }
  80% { transform: translate(2px, 1px) scale(1.02); }
  90% { transform: translate(-1px, 0) scale(1.01); }
}

.timer-caption {
  margin: 10px 0 0;
  color: var(--dim);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.timer.panic + .timer-caption {
  color: var(--red);
}

.stats-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.stat {
  margin: 0;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-label {
  font-size: 0.72rem;
  letter-spacing: 1.2px;
  color: var(--dim);
  font-weight: 700;
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--dorado);
}

.save-btn {
  width: 100%;
  max-width: 420px;
  border: none;
  border-radius: 999px;
  padding: 22px 20px;
  background: linear-gradient(180deg, #ff4444 0%, #d40d0d 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(212, 13, 13, 0.5), inset 0 1px 0 rgba(255,255,255,0.25);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  animation: save-btn-glow 2s ease-in-out infinite;
}

.save-btn:hover {
  transform: translateY(-2px);
}

.save-btn:active {
  transform: translateY(0) scale(0.97);
}

.save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  animation: none;
}

@keyframes save-btn-glow {
  0%, 100% { box-shadow: 0 8px 24px rgba(212, 13, 13, 0.5), inset 0 1px 0 rgba(255,255,255,0.25); }
  50% { box-shadow: 0 8px 34px rgba(255, 40, 40, 0.85), inset 0 1px 0 rgba(255,255,255,0.25); }
}

.save-btn-main {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.save-btn-price {
  font-size: 1rem;
  font-weight: 700;
  opacity: 0.9;
}


.toast-stack {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  width: min(92vw, 460px);
  pointer-events: none;
}

.toast {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 12px 18px;
  text-align: center;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.25s ease, toast-out 0.3s ease 3.7s forwards;
}

.toast.hero {
  background: linear-gradient(135deg, #3a2400, #1a1200);
  border-color: var(--dorado);
  color: var(--dorado);
}

.toast .toast-title {
  display: block;
  font-size: 0.95rem;
}

.toast .toast-sub {
  display: block;
  margin-top: 2px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--dim);
}

.toast.hero .toast-sub {
  color: #e8c27a;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-8px); }
}

.ranking {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
}

.ranking h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  letter-spacing: 0.5px;
}

.ranking-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ranking-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  font-weight: 600;
}

.ranking-list li:nth-child(1) .ranking-count { color: var(--dorado); }

.ranking-rank {
  color: var(--dim);
  font-weight: 800;
  margin-right: 8px;
}

.ranking-count {
  color: var(--celeste);
  font-weight: 800;
}

.ranking-empty {
  color: var(--dim);
  font-weight: 500;
  justify-content: center !important;
}

/* ---------------------------------------------------------------- Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

/* [hidden] tiene que ganarle a "display: flex" de arriba, si no el
   atributo hidden del HTML queda sin efecto y el modal se ve siempre. */
.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 16px 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  z-index: 2;
}

.trophy-canvas {
  width: 100%;
  height: auto;
  border-radius: 14px;
  display: block;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-question {
  margin: 0;
  font-weight: 700;
  text-align: center;
}

.modal-optional {
  color: var(--dim);
  font-weight: 500;
}

.province-select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: #1c1e24;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 1rem;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
}

.btn-ghost {
  background: transparent;
  color: var(--dim);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-primary {
  background: var(--celeste);
  color: #06131f;
}

.share-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.share-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 4px;
  font-weight: 700;
  font-size: 0.78rem;
  color: #fff;
  cursor: pointer;
}

.share-btn--whatsapp { background: #25d366; color: #06210f; }
.share-btn--x { background: #111; border: 1px solid rgba(255,255,255,0.3); }
.share-btn--instagram { background: linear-gradient(135deg, #f58529, #dd2a7b, #8134af); }
.share-btn--tiktok { background: #010101; border: 1px solid rgba(255,255,255,0.3); }

.btn-download {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* ------------------------------------------------------------ Death screen */

.death-screen {
  position: fixed;
  inset: 0;
  background: #0a0000;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.death-screen[hidden] {
  display: none;
}

.death-content {
  max-width: 480px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.death-kicker {
  margin: 0;
  color: var(--red);
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 1.1rem;
}

.death-title {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 1px;
}

.death-stats {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.death-stat {
  display: flex;
  justify-content: space-between;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 16px;
}

.death-stat-label {
  color: var(--dim);
  font-weight: 600;
}

.death-stat-value {
  font-weight: 800;
  color: var(--dorado);
}

.btn-next-season {
  margin-top: 8px;
  padding: 16px 24px;
  border-radius: 999px;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  background: transparent;
  color: var(--dim);
  font-weight: 800;
  letter-spacing: 1px;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr;
  }

  .header h1 {
    font-size: 1.7rem;
  }
}
