:root {
  --ink: #351226;
  --berry: #b81f62;
  --rose: #ff5f96;
  --pink: #ff9fbd;
  --gold: #ffd166;
  --mint: #78d6b5;
  --shadow: 0 28px 80px rgba(116, 18, 68, 0.26);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.58), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 95, 150, 0.2)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='84' viewBox='0 0 96 84'%3E%3Cpath d='M24 25 C24 14 38 12 48 25 C58 12 72 14 72 25 C72 39 57 48 48 59 C39 48 24 39 24 25 Z' fill='none' stroke='white' stroke-opacity='.54' stroke-width='2.4'/%3E%3Cpath d='M-24 67 C-24 56 -10 54 0 67 C10 54 24 56 24 67 C24 81 9 90 0 101 C-9 90 -24 81 -24 67 Z' fill='none' stroke='white' stroke-opacity='.34' stroke-width='2.4'/%3E%3Cpath d='M72 67 C72 56 86 54 96 67 C106 54 120 56 120 67 C120 81 105 90 96 101 C87 90 72 81 72 67 Z' fill='none' stroke='white' stroke-opacity='.34' stroke-width='2.4'/%3E%3C/svg%3E"),
    linear-gradient(135deg, #ff73a8, #ffc4d8 48%, #ff8fb6);
  background-attachment: fixed;
}

button { font: inherit; }

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
}

.app {
  width: min(980px, 100%);
  display: grid;
  gap: 18px;
  padding: clamp(18px, 4vw, 38px);
  border: 2px solid rgba(255, 255, 255, 0.62);
  border-radius: 22px;
  background: rgba(255, 246, 251, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pill,
.stat {
  width: fit-content;
  padding: 9px 16px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--berry);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 12px 28px rgba(184, 31, 98, 0.12);
}

h1 {
  margin: 0;
  color: var(--berry);
  font-size: clamp(2.55rem, 8vw, 5.2rem);
  line-height: 0.88;
  letter-spacing: 0;
  text-wrap: balance;
}

p {
  margin: 0;
  max-width: 62ch;
  color: rgba(53, 18, 38, 0.78);
  font-size: clamp(1rem, 2.4vw, 1.12rem);
  line-height: 1.55;
  text-wrap: pretty;
}

.back-link,
.game-button,
.game-link {
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  color: var(--berry);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 24px rgba(184, 31, 98, 0.12);
  font-weight: 950;
  text-decoration: none;
  cursor: pointer;
}

.game-button.primary,
.game-link.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--berry), var(--rose));
}

.game-menu {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.game-card {
  min-height: 132px;
  display: grid;
  align-content: space-between;
  gap: 10px;
  padding: 14px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--berry);
  font-size: 0.9rem;
  font-weight: 950;
  text-align: left;
  text-decoration: none;
  box-shadow: 0 12px 24px rgba(184, 31, 98, 0.1);
  transition: transform 220ms var(--ease-bounce), box-shadow 220ms var(--ease-out), background 220ms var(--ease-out);
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 18px 34px rgba(184, 31, 98, 0.18);
  outline: none;
}

.game-card strong {
  color: var(--ink);
  font-size: clamp(1.1rem, 2.8vw, 1.35rem);
  line-height: 1.05;
}

.game-card span { display: block; }

.game-icon {
  width: 58px;
  height: 58px;
  align-self: center;
  justify-self: end;
  margin-block: -2px;
  filter: drop-shadow(0 8px 10px rgba(116, 18, 68, 0.14));
}

.secret-icon {
  opacity: 0.9;
}

.difficulty {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.difficulty.easy { background: linear-gradient(135deg, var(--mint), var(--rose)); }
.difficulty.medium { background: linear-gradient(135deg, var(--gold), var(--rose)); }
.difficulty.hard { background: linear-gradient(135deg, var(--berry), var(--ink)); }

.game-status {
  color: rgba(53, 18, 38, 0.62);
  font-size: 0.78rem;
  line-height: 1.25;
}

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

.stat strong {
  margin-left: 6px;
  color: var(--ink);
  font-size: 1rem;
}

.scorebar .stat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding-inline: 10px;
  white-space: nowrap;
}

.playfield {
  position: relative;
  min-height: min(58vh, 520px);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.68);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 14px 30px rgba(184, 31, 98, 0.12);
  touch-action: manipulation;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.catch-target {
  position: absolute;
  z-index: 2;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff, #ffe0ec);
  color: var(--berry);
  font-size: 1.6rem;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 12px 22px rgba(184, 31, 98, 0.18);
  transform: translate(-50%, -50%);
  transition: transform 120ms var(--ease-bounce), opacity 120ms var(--ease-out);
}

.catch-target.bad {
  color: rgba(53, 18, 38, 0.72);
  background: linear-gradient(135deg, #f0edf1, #fff);
}

.catch-target.hit {
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.45);
}

.score-pop {
  position: absolute;
  z-index: 6;
  left: var(--x);
  top: var(--y);
  color: var(--berry);
  font-size: 1rem;
  font-weight: 950;
  pointer-events: none;
  text-shadow: 0 4px 10px rgba(255, 255, 255, 0.88);
  transform: translate(-50%, -50%);
  animation: scorePop 680ms var(--ease-out) forwards;
}

.cloud-obstacle {
  position: absolute;
  z-index: 5;
  width: min(42vw, 210px);
  opacity: 0.94;
  pointer-events: none;
  filter: drop-shadow(0 14px 18px rgba(116, 18, 68, 0.18));
}

.cloud-obstacle.top {
  top: 15%;
  left: -230px;
  animation: cloudLeftToRight 7.8s linear infinite;
}

.cloud-obstacle.bottom {
  right: -230px;
  bottom: 18%;
  animation: cloudRightToLeft 9.4s linear infinite;
}

.love-field {
  min-height: min(58vh, 540px);
}

.love-stage {
  min-height: inherit;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  align-items: stretch;
  gap: clamp(12px, 3vw, 22px);
  padding: clamp(14px, 3.5vw, 30px);
}

.love-meter {
  position: relative;
  z-index: 5;
  display: grid;
  align-items: center;
  width: min(100%, 720px);
  min-height: 48px;
  justify-self: center;
  padding: 8px;
  border: 2px solid rgba(255, 255, 255, 0.74);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: 0 12px 24px rgba(184, 31, 98, 0.1);
}

.love-meter-track {
  position: relative;
  width: 100%;
  height: 30px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.4)),
    rgba(255, 255, 255, 0.52);
  box-shadow: inset 0 0 0 2px rgba(184, 31, 98, 0.14);
}

.thermometer-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--charge-percent, 0%);
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(255, 95, 150, 0.96), rgba(255, 209, 102, 0.92)),
    var(--rose);
  transition: width 180ms var(--ease-out);
}

.thermometer-fill[data-hot="true"] {
  background:
    linear-gradient(90deg, rgba(255, 95, 150, 0.98), rgba(184, 31, 98, 0.98) 54%, rgba(255, 241, 177, 0.96)),
    var(--rose);
}

.beat-area {
  position: relative;
  min-height: 350px;
  display: grid;
  place-items: center;
  isolation: isolate;
}

.sweet-spot {
  position: absolute;
  z-index: 1;
  width: min(54vw, 285px);
  aspect-ratio: 1;
  border: 5px solid rgba(38, 160, 120, 0.9);
  border-radius: 50%;
  background:
    radial-gradient(circle, transparent 58%, rgba(120, 214, 181, 0.16) 59% 65%, transparent 66%),
    rgba(255, 255, 255, 0.08);
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.82),
    0 12px 28px rgba(38, 160, 120, 0.16),
    inset 0 0 0 2px rgba(255, 255, 255, 0.56);
  transform: scale(var(--target-scale, 1));
  transition: transform 220ms var(--ease-bounce);
}

.sweet-spot::after {
  position: absolute;
  inset: 12px;
  border: 3px dashed rgba(38, 160, 120, 0.58);
  border-radius: 50%;
  content: "";
}

.beat-ring {
  position: absolute;
  z-index: 2;
  width: min(54vw, 285px);
  aspect-ratio: 1;
  border: 8px solid rgba(255, 255, 255, 0.9);
  border-top-color: var(--gold);
  border-right-color: var(--rose);
  border-radius: 50%;
  box-shadow:
    0 18px 34px rgba(184, 31, 98, 0.18),
    inset 0 0 24px rgba(255, 255, 255, 0.46);
  transform: scale(var(--ring-scale, 1.85));
  will-change: transform, opacity;
}

.heart-core {
  border: 8px solid rgba(255, 255, 255, 0.9);
  position: relative;
  z-index: 3;
  width: min(38vw, 190px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  appearance: none;
  color: #fff;
  background:
    radial-gradient(circle at 36% 28%, rgba(255, 255, 255, 0.55) 0 11%, transparent 12%),
    linear-gradient(135deg, var(--berry), var(--rose));
  font-size: clamp(2.5rem, 10vw, 5.2rem);
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 22px 42px rgba(184, 31, 98, 0.24);
  -webkit-tap-highlight-color: transparent;
  transition: transform 140ms var(--ease-bounce), box-shadow 140ms var(--ease-out), opacity 140ms var(--ease-out);
}

.heart-core:hover,
.heart-core:focus-visible {
  outline: none;
  box-shadow:
    0 24px 52px rgba(184, 31, 98, 0.28),
    0 0 0 5px rgba(255, 255, 255, 0.72);
}

.heart-core:active {
  transform: scale(0.96);
}

.heart-core:disabled {
  cursor: default;
  opacity: 0.78;
}

.heart-core.beat-hit {
  animation: heartBeat 320ms var(--ease-bounce);
}

.heart-core.pulse-perfect,
.heart-core.pulse-good,
.heart-core.pulse-close {
  animation: heartBeat 300ms var(--ease-bounce);
}

.heart-core.pulse-perfect {
  box-shadow: 0 24px 54px rgba(255, 209, 102, 0.44);
}

.feedback {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 4;
  min-width: 120px;
  min-height: 46px;
  display: grid;
  place-items: center;
  padding: 0 16px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--berry);
  font-weight: 950;
  transform: translateX(-50%);
  box-shadow: 0 12px 24px rgba(184, 31, 98, 0.12);
}

.feedback.show {
  animation: feedbackPop 320ms var(--ease-bounce);
}

.feedback.perfect {
  color: #8a5a00;
  background: rgba(255, 241, 177, 0.88);
}

.feedback.good,
.feedback.close {
  color: #17694f;
  background: rgba(212, 255, 235, 0.88);
}

.feedback.miss {
  color: rgba(53, 18, 38, 0.72);
  background: rgba(255, 255, 255, 0.68);
}

.bad-pop {
  color: rgba(53, 18, 38, 0.72);
}

.memory-grid {
  height: 100%;
  min-height: inherit;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.memory-card {
  min-height: 78px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--berry), var(--rose));
  color: #fff;
  font-size: clamp(1.7rem, 6vw, 2.7rem);
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 12px 22px rgba(184, 31, 98, 0.16);
  transition: transform 180ms var(--ease-bounce), background 180ms var(--ease-out);
}

.memory-card.revealed,
.memory-card.matched {
  color: var(--berry);
  background: rgba(255, 255, 255, 0.88);
  transform: rotateY(180deg);
}

.memory-card.matched {
  background: linear-gradient(135deg, rgba(120, 214, 181, 0.8), rgba(255, 255, 255, 0.92));
}

.memory-grid.shuffling .memory-card {
  animation: cardShuffle 780ms var(--ease-bounce) both;
  animation-delay: calc(var(--shuffle-index, 0) * 18ms);
}

.card-back-icon {
  width: min(70%, 42px);
  height: min(70%, 42px);
  pointer-events: none;
  filter: drop-shadow(0 5px 8px rgba(116, 18, 68, 0.18));
}

.panty-svg {
  width: min(86%, 62px);
  height: min(86%, 62px);
  pointer-events: none;
  filter: drop-shadow(0 6px 8px rgba(116, 18, 68, 0.16));
}

.panty-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.panty-card {
  min-height: 92px;
  padding: 6px;
  font-size: clamp(0.72rem, 2vw, 1rem);
  line-height: 1.05;
  word-break: normal;
}

.placeholder {
  min-height: inherit;
  display: grid;
  place-items: center;
  padding: 18px;
  color: var(--berry);
  font-size: clamp(3rem, 18vw, 7rem);
  font-weight: 950;
}

.countdown {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  color: var(--berry);
  font-size: clamp(3rem, 15vw, 7rem);
  font-weight: 950;
  text-shadow: 0 8px 20px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  animation: countdownPulse 620ms var(--ease-bounce) both;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(53, 18, 38, 0.24);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(8px);
  transition: opacity 220ms var(--ease-out);
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(460px, 100%);
  display: grid;
  justify-items: center;
  gap: 16px;
  padding: 28px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 22px;
  background: rgba(255, 250, 252, 0.96);
  box-shadow: var(--shadow);
  text-align: center;
}

.coupon {
  width: min(100%, 430px);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 22px;
  border: 3px dashed rgba(184, 31, 98, 0.42);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.34), rgba(255, 255, 255, 0.9)),
    rgba(255, 250, 252, 0.96);
  box-shadow: 0 20px 50px rgba(116, 18, 68, 0.2);
  text-align: center;
}

.coupon-title {
  color: var(--berry);
  font-size: clamp(2rem, 8vw, 3.4rem);
  font-weight: 950;
  line-height: 0.9;
}

.coupon-prize {
  color: var(--ink);
  font-size: clamp(1.1rem, 4vw, 1.45rem);
  font-weight: 950;
  line-height: 1.25;
}

.coupon-code {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.sparkle {
  position: fixed;
  left: var(--x);
  top: var(--y);
  z-index: 30;
  color: #fff;
  font-size: 1rem;
  font-weight: 950;
  pointer-events: none;
  text-shadow: 0 5px 14px rgba(184, 31, 98, 0.4);
  animation: sparkle 900ms var(--ease-out) forwards;
}

@keyframes sparkle {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(0); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(var(--spin)); }
}

@keyframes scorePop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.72); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 34px)) scale(1.16); }
}

@keyframes cloudLeftToRight {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 460px)); }
}

@keyframes cloudRightToLeft {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(-100vw - 460px)); }
}

@keyframes countdownPulse {
  0% { opacity: 0; transform: scale(0.72); }
  35% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes heartBeat {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes feedbackPop {
  0% { opacity: 0.45; transform: translateX(-50%) translateY(10px) scale(0.9); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@keyframes cardShuffle {
  0% { opacity: 0.35; transform: translate(var(--shuffle-x, 0), var(--shuffle-y, 0)) rotate(var(--shuffle-rotate, 0deg)) scale(0.82); }
  55% { opacity: 1; transform: translate(calc(var(--shuffle-x, 0) * -0.18), calc(var(--shuffle-y, 0) * -0.18)) rotate(calc(var(--shuffle-rotate, 0deg) * -0.25)) scale(1.05); }
  100% { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
}

@media (max-width: 520px) {
  .app {
    padding: 14px;
    border-radius: 18px;
  }

  .topbar,
  .actions {
    justify-content: center;
    text-align: center;
  }

  h1,
  p {
    text-align: center;
  }

  .game-menu {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .game-card {
    min-height: 104px;
    gap: 6px;
    padding: 8px;
    text-align: center;
  }

  .game-icon {
    width: 42px;
    height: 42px;
    justify-self: center;
  }

  .game-card strong {
    font-size: 0.84rem;
  }

  .difficulty {
    justify-self: center;
    padding: 5px 7px;
    font-size: 0.58rem;
  }

  .game-status {
    font-size: 0.66rem;
  }

  .playfield {
    min-height: 360px;
  }

  .love-field {
    min-height: 390px;
  }

  .love-stage {
    gap: 8px;
    padding: 10px;
  }

  .love-meter {
    min-height: 42px;
    padding: 6px;
  }

  .love-meter-track {
    height: 26px;
  }

  .thermometer-fill {
    width: var(--charge-percent, 0%);
  }

  .beat-area {
    min-height: 315px;
  }

  .sweet-spot,
  .beat-ring {
    width: min(62vw, 205px);
  }

  .heart-core {
    width: min(46vw, 154px);
    font-size: clamp(2.35rem, 13vw, 4rem);
  }

  .feedback {
    bottom: 8px;
    min-height: 40px;
  }

  .scorebar {
    gap: 5px;
  }

  .scorebar .stat {
    padding: 7px 5px;
    font-size: 0.58rem;
    letter-spacing: 0.04em;
  }

  .stat strong {
    margin-left: 3px;
    font-size: 0.8rem;
  }

  .memory-grid {
    gap: 7px;
    padding: 10px;
  }

  .memory-card {
    min-height: 62px;
  }

  .panty-grid {
    gap: 4px;
    padding: 6px;
  }

  .panty-card {
    min-height: 68px;
    padding: 3px;
    font-size: 0.58rem;
  }
}
