/* =====================================================
   VARIABLES Y CONFIGURACIÓN GENERAL
===================================================== */

:root {
  --rosa-claro: #fff0f5;
  --rosa-medio: #ff85a2;
  --rosa-fuerte: #ff4d6d;
  --rojo: #c9184a;
  --vino: #800f2f;
  --blanco: #ffffff;
  --texto: #7a183c;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  overflow-x: hidden;

  font-family:
    "Segoe UI",
    Arial,
    Helvetica,
    sans-serif;

  color: var(--texto);

  background:
    radial-gradient(
      circle at 15% 20%,
      rgba(255, 182, 193, 0.65),
      transparent 28%
    ),
    radial-gradient(
      circle at 85% 80%,
      rgba(255, 105, 135, 0.4),
      transparent 30%
    ),
    linear-gradient(
      135deg,
      #fff0f5,
      #ffd6e0,
      #fff5f8
    );
}

button {
  font-family: inherit;
}

/* =====================================================
   MARCO DECORATIVO
===================================================== */

.heart-border {
  position: fixed;
  z-index: 50;
  pointer-events: none;
}

.heart-border.top,
.heart-border.bottom {
  left: 0;
  width: 100%;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: space-around;

  overflow: hidden;
}

.heart-border.top {
  top: 0;
}

.heart-border.bottom {
  bottom: 0;
}

.heart-border.left,
.heart-border.right {
  top: 0;
  width: 42px;
  height: 100%;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;

  overflow: hidden;
}

.heart-border.left {
  left: 0;
}

.heart-border.right {
  right: 0;
}

.border-heart {
  color: rgba(201, 24, 74, 0.72);
  font-size: 1.35rem;

  filter:
    drop-shadow(0 3px 4px rgba(128, 15, 47, 0.15));

  animation: borderHeartbeat 1.8s infinite ease-in-out;
}

.border-heart:nth-child(even) {
  color: rgba(255, 77, 109, 0.75);
  animation-delay: 0.4s;
}

.border-heart:nth-child(3n) {
  color: rgba(255, 133, 162, 0.85);
  animation-delay: 0.8s;
}

/* =====================================================
   CONTENIDO GENERAL
===================================================== */

.page {
  position: relative;
  z-index: 2;

  width: 100%;
  min-height: 100vh;

  display: flex;
  justify-content: center;
  align-items: center;

  padding: 65px;
}

.screen {
  display: none;
  width: 100%;
  max-width: 1100px;
}

.screen.active {
  display: block;
  animation: screenEnter 0.8s ease;
}

/* =====================================================
   PANTALLA INICIAL
===================================================== */

.intro-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  min-height: calc(100vh - 130px);

  text-align: center;
}

.special-message {
  position: relative;

  max-width: 850px;
  margin-bottom: 42px;
  padding: 26px 35px;

  color: var(--texto);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.35;

  text-shadow:
    0 3px 12px rgba(201, 24, 74, 0.12);
}

.special-message::before,
.special-message::after {
  content: "❤";

  position: absolute;
  top: 50%;

  color: var(--rosa-fuerte);
  font-size: 1.7rem;

  transform: translateY(-50%);
  animation: heartbeat 1.5s infinite;
}

.special-message::before {
  left: -5px;
}

.special-message::after {
  right: -5px;
}

/* =====================================================
   CARTA DE AMOR
===================================================== */

.love-letter-button {
  position: relative;

  width: min(360px, 90vw);
  height: 245px;

  border: none;
  background: transparent;

  cursor: pointer;
  perspective: 1200px;

  transition: transform 0.3s ease;
}

.love-letter-button:hover {
  transform: translateY(-10px) scale(1.025);
}

.envelope {
  position: absolute;
  inset: 0;

  overflow: hidden;

  border: 3px solid rgba(255, 255, 255, 0.65);
  border-radius: 22px;

  background:
    linear-gradient(
      145deg,
      #ff8fab,
      #ff4d6d
    );

  box-shadow:
    0 22px 50px rgba(128, 15, 47, 0.27),
    inset 0 0 30px rgba(255, 255, 255, 0.18);
}

.envelope::before {
  content: "";

  position: absolute;
  z-index: 2;

  top: 0;
  left: 0;

  width: 100%;
  height: 58%;

  clip-path: polygon(0 0, 100% 0, 50% 100%);

  background:
    linear-gradient(
      160deg,
      #ffb3c6,
      #ff758f
    );

  filter:
    drop-shadow(0 8px 7px rgba(128, 15, 47, 0.13));
}

.envelope::after {
  content: "";

  position: absolute;
  z-index: 1;

  left: 0;
  bottom: 0;

  width: 100%;
  height: 74%;

  clip-path:
    polygon(
      0 0,
      50% 58%,
      100% 0,
      100% 100%,
      0 100%
    );

  background:
    linear-gradient(
      145deg,
      #ff5d7d,
      #d91c4d
    );
}

.letter-preview {
  position: absolute;
  z-index: 3;

  left: 50%;
  bottom: 23px;

  width: 83%;
  min-height: 135px;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  padding: 20px;

  border-radius: 15px;

  color: var(--texto);

  background:
    repeating-linear-gradient(
      0deg,
      #fffafa 0,
      #fffafa 27px,
      #ffdce6 28px
    );

  box-shadow:
    0 8px 22px rgba(128, 15, 47, 0.18);

  transform: translateX(-50%);

  transition:
    bottom 0.45s ease,
    transform 0.45s ease;
}

.love-letter-button:hover .letter-preview {
  bottom: 45px;
  transform: translateX(-50%) rotate(-1deg);
}

.letter-preview span {
  font-size: 2.4rem;
  margin-bottom: 7px;
}

.letter-preview strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.wax-seal {
  position: absolute;
  z-index: 5;

  left: 50%;
  bottom: 38px;

  width: 58px;
  height: 58px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 4px double rgba(255, 255, 255, 0.5);
  border-radius: 50%;

  color: white;
  font-size: 1.7rem;

  background:
    radial-gradient(
      circle at 35% 30%,
      #ff6b85,
      #a4133c
    );

  box-shadow:
    0 8px 17px rgba(80, 0, 25, 0.35);

  transform: translateX(-50%);
}

.open-hint {
  margin-top: 25px;

  color: #8f2448;
  font-size: 1rem;
  font-weight: 600;

  animation: floatingText 1.8s infinite ease-in-out;
}

/* =====================================================
   PANTALLA DE CARTAS
===================================================== */

.game-content {
  min-height: calc(100vh - 130px);
  text-align: center;
}

.game-title {
  margin-bottom: 8px;

  color: var(--vino);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
}

.game-description {
  margin-bottom: 15px;

  color: #94254d;
  font-size: 1.1rem;
}

.selection-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;

  margin-bottom: 30px;
  padding: 11px 22px;

  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;

  color: var(--vino);
  font-weight: 700;

  background: rgba(255, 255, 255, 0.55);

  box-shadow:
    0 9px 25px rgba(128, 15, 47, 0.1);

  backdrop-filter: blur(10px);
}

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(145px, 1fr));
  gap: 18px;

  width: 100%;
}

.card {
  position: relative;

  min-height: 250px;

  border: none;
  border-radius: 25px;

  background: transparent;

  cursor: pointer;
  perspective: 1100px;

  transition:
    transform 0.25s ease,
    opacity 0.3s ease,
    filter 0.3s ease;
}

.card:hover:not(:disabled) {
  transform: translateY(-11px) scale(1.025);
}

.card:disabled {
  cursor: not-allowed;
}

.card-inner {
  position: absolute;
  inset: 0;

  width: 100%;
  height: 100%;

  transform-style: preserve-3d;

  transition:
    transform 0.75s
    cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card.revealed .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  padding: 18px;

  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 25px;

  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;

  box-shadow:
    0 18px 38px rgba(128, 15, 47, 0.2),
    inset 0 0 25px rgba(255, 255, 255, 0.15);
}

.card-front {
  overflow: hidden;

  color: white;

  background:
    linear-gradient(
      145deg,
      #ff758f,
      #c9184a
    );
}

.card-front::before {
  content: "";

  position: absolute;
  inset: 9px;

  border: 2px dashed rgba(255, 255, 255, 0.48);
  border-radius: 18px;
}

.card-front::after {
  content: "❤  ❤  ❤";

  position: absolute;

  left: 0;
  bottom: 13px;

  width: 100%;

  color: rgba(255, 255, 255, 0.48);
  font-size: 0.9rem;
  letter-spacing: 7px;
}

.main-heart {
  position: relative;
  z-index: 2;

  font-size: 5rem;
  line-height: 1;

  filter:
    drop-shadow(0 9px 8px rgba(100, 0, 30, 0.27));

  animation: heartbeat 1.7s infinite;
}

.card-number {
  position: relative;
  z-index: 2;

  margin-top: 17px;

  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.card-back {
  color: var(--vino);

  background:
    radial-gradient(
      circle at top,
      rgba(255, 182, 193, 0.5),
      transparent 45%
    ),
    linear-gradient(
      145deg,
      #ffffff,
      #ffe4ec
    );

  transform: rotateY(180deg);
}

.reward-icon {
  margin-bottom: 14px;
  font-size: 3.7rem;

  animation: rewardBounce 1.2s infinite ease-in-out;
}

.reward-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.locked {
  opacity: 0.3;
  filter: grayscale(0.55);
  transform: scale(0.95);
}

/* =====================================================
   RESULTADOS
===================================================== */

.results {
  min-height: 82px;
  margin-top: 30px;
}

.results-title {
  display: none;
  margin-bottom: 10px;

  color: var(--vino);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.results-title.visible {
  display: block;
}

.result-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.result-chip {
  padding: 11px 18px;

  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;

  color: var(--vino);
  font-size: 1.05rem;
  font-weight: 700;

  background: rgba(255, 255, 255, 0.68);

  box-shadow:
    0 8px 22px rgba(128, 15, 47, 0.12);

  animation: resultAppear 0.5s ease;
}

.restart-button {
  display: none;

  margin: 20px auto 0;
  padding: 14px 29px;

  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;

  color: white;
  font-size: 1.05rem;
  font-weight: 800;

  background:
    linear-gradient(
      135deg,
      var(--rosa-fuerte),
      var(--rojo)
    );

  cursor: pointer;

  box-shadow:
    0 13px 28px rgba(201, 24, 74, 0.26);

  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.restart-button.visible {
  display: block;
  animation: resultAppear 0.5s ease;
}

.restart-button:hover {
  transform: translateY(-4px);

  box-shadow:
    0 18px 33px rgba(201, 24, 74, 0.35);
}

.final-message {
  display: none;

  margin-top: 20px;

  color: var(--vino);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.final-message.visible {
  display: block;
  animation: resultAppear 0.6s ease;
}

/* =====================================================
   CORAZONES FLOTANTES
===================================================== */

.floating-heart {
  position: fixed;
  z-index: 1;

  bottom: -70px;

  color: rgba(255, 77, 109, 0.18);

  pointer-events: none;

  animation: floatUp linear forwards;
}

.explosion-heart {
  position: fixed;
  z-index: 100;

  pointer-events: none;

  transition:
    transform 1s ease-out,
    opacity 1s ease-out;
}

/* =====================================================
   ANIMACIONES
===================================================== */

@keyframes heartbeat {
  0%,
  100% {
    transform: scale(1);
  }

  15% {
    transform: scale(1.13);
  }

  30% {
    transform: scale(1);
  }

  45% {
    transform: scale(1.08);
  }
}

@keyframes borderHeartbeat {
  0%,
  100% {
    transform: scale(1) rotate(-4deg);
  }

  50% {
    transform: scale(1.18) rotate(4deg);
  }
}

@keyframes floatingText {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }

  12% {
    opacity: 1;
  }

  100% {
    transform: translateY(-120vh) rotate(360deg);
    opacity: 0;
  }
}

@keyframes screenEnter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes rewardBounce {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-7px);
  }
}

@keyframes resultAppear {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.94);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* =====================================================
   DISEÑO RESPONSIVE
===================================================== */

@media (max-width: 950px) {
  .cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 650px) {
  .page {
    padding: 60px 45px;
  }

  .special-message {
    padding: 22px 12px;
  }

  .special-message::before,
  .special-message::after {
    display: none;
  }

  .cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .card {
    min-height: 215px;
  }

  .heart-border.left,
  .heart-border.right {
    width: 30px;
  }

  .heart-border.top,
  .heart-border.bottom {
    height: 30px;
  }

  .border-heart {
    font-size: 1rem;
  }
}

@media (max-width: 400px) {
  .page {
    padding: 52px 36px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .card {
    min-height: 225px;
  }

  .love-letter-button {
    height: 220px;
  }
}
