:root {
  --pink-soft: #ffe3ee;
  --pink: #f8bbd0;
  --pink-deep: #e57aa0;
  --cream: #fff8fb;
  --text: #5a3346;
  --shadow: 0 10px 30px rgba(229, 122, 160, 0.22);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, #fff0f6 0%, #ffe3ee 50%, #ffd2e3 100%);
}

#app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.screen.active {
  display: flex;
}

.card {
  background: var(--cream);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 90vw;
  width: 360px;
  position: relative;
  z-index: 2;
}

.title {
  font-size: 28px;
  color: var(--pink-deep);
  margin-bottom: 8px;
  font-weight: 700;
}

.title .emoji {
  display: inline-block;
  animation: pulse 1.4s ease-in-out infinite;
}

.subtitle {
  font-size: 18px;
  color: var(--text);
  margin-bottom: 16px;
  font-weight: 500;
}

.instructions {
  font-size: 14px;
  color: #7a4a5e;
  margin-bottom: 24px;
  line-height: 1.5;
}

.signature {
  margin-top: 16px;
  font-size: 13px;
  color: #a06880;
  font-style: italic;
}

/* ============= Botones ============= */
.btn-primary,
.btn-secondary {
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
  width: 100%;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--pink) 0%, var(--pink-deep) 100%);
  color: white;
  box-shadow: 0 6px 18px rgba(229, 122, 160, 0.4);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 8px rgba(229, 122, 160, 0.4);
}
.btn-primary:disabled {
  background: #e8c8d6;
  color: #fff;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.7;
}

.btn-secondary {
  background: white;
  color: var(--pink-deep);
  border: 2px solid var(--pink);
  box-shadow: 0 4px 12px rgba(229, 122, 160, 0.15);
}
.btn-secondary:active {
  transform: translateY(2px);
}

.final-locked .lock {
  margin-right: 4px;
}

/* ============= HUB ============= */
.hub-content {
  width: 100%;
  max-width: 420px;
  text-align: center;
  z-index: 2;
  padding: 30px 6px 20px;
}

.hub-title {
  font-size: 24px;
  color: var(--pink-deep);
  margin-bottom: 6px;
  font-weight: 700;
}
.hub-subtitle {
  font-size: 14px;
  color: #7a4a5e;
  margin-bottom: 24px;
}

.gifts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 24px;
}

@media (min-width: 480px) {
  .gifts-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.gift-card {
  background: var(--cream);
  border: 2px solid var(--gift-color, var(--pink));
  border-radius: 20px;
  padding: 20px 16px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 6px 18px rgba(229, 122, 160, 0.18);
  position: relative;
  font-family: inherit;
  color: var(--text);
}
.gift-card:active {
  transform: translateY(3px) scale(0.98);
  box-shadow: 0 2px 8px rgba(229, 122, 160, 0.18);
}

.gift-icon {
  font-size: 42px;
  margin-bottom: 8px;
  display: block;
  animation: float 3s ease-in-out infinite;
}

.gift-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--pink-deep);
  margin-bottom: 4px;
}
.gift-desc {
  font-size: 12px;
  color: #7a4a5e;
  line-height: 1.4;
}

.gift-card.completed {
  background: linear-gradient(135deg, #fff8fb 0%, #ffeaf2 100%);
}
.gift-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  background: var(--pink-deep);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
}

/* ============= HUD del juego ============= */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 12px 16px;
  background: rgba(255, 248, 251, 0.92);
  backdrop-filter: blur(8px);
  z-index: 3;
  border-bottom: 1px solid rgba(229, 122, 160, 0.18);
}

.back-btn {
  background: white;
  border: 2px solid var(--pink);
  color: var(--pink-deep);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  flex-shrink: 0;
}
.back-btn:active {
  transform: scale(0.95);
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
}
.hud-label {
  color: #a06880;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
  margin-bottom: 2px;
}
.hud-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--pink-deep);
}

.game-screen {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}
#catch-canvas,
#tap-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ============= Clicker de Amor ============= */
.clicker-layout {
  flex-direction: column;
}

.clicker-body {
  position: absolute;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 14px;
  gap: 10px;
  overflow: hidden;
}

.clicker-progress {
  flex-shrink: 0;
}
.clicker-progress-bar {
  width: 100%;
  height: 10px;
  background: rgba(229, 122, 160, 0.18);
  border-radius: 999px;
  overflow: hidden;
}
#clicker-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pink) 0%, var(--pink-deep) 100%);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.clicker-progress-label {
  text-align: center;
  font-size: 11px;
  color: #7a4a5e;
  margin-top: 4px;
  font-weight: 600;
}

.clicker-heart-zone {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 140px;
}
.clicker-heart {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  width: min(180px, 42vw);
  height: min(180px, 42vw);
  filter: drop-shadow(0 8px 16px rgba(229, 122, 160, 0.45));
  transition: transform 0.08s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: heartIdle 2.5s ease-in-out infinite;
}
.clicker-heart svg {
  width: 100%;
  height: 100%;
  display: block;
}
.clicker-heart:active {
  transform: scale(0.92);
}
.clicker-heart.clicked {
  animation: heartClick 0.18s ease;
}
@keyframes heartIdle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes heartClick {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.clicker-floats {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.float {
  position: absolute;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  text-shadow:
    -2px -2px 0 var(--pink-deep),
     2px -2px 0 var(--pink-deep),
    -2px  2px 0 var(--pink-deep),
     2px  2px 0 var(--pink-deep),
     0 4px 6px rgba(229, 122, 160, 0.5);
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: floatRise 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
@keyframes floatRise {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20%  { opacity: 1; transform: translate(calc(-50% + var(--dx)), calc(-50% - 10px)) scale(1.15); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% - 80px)) scale(1); }
}

.clicker-shop {
  flex-shrink: 0;
  background: rgba(255, 248, 251, 0.85);
  backdrop-filter: blur(6px);
  border-radius: 18px 18px 0 0;
  padding: 10px 8px 8px;
  margin: 0 -14px -14px;
  border-top: 2px solid var(--pink);
  max-height: 42vh;
  display: flex;
  flex-direction: column;
}
.clicker-shop-title {
  font-size: 14px;
  color: var(--pink-deep);
  text-align: center;
  margin-bottom: 6px;
  font-weight: 700;
}
.clicker-upgrades {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 6px 4px;
  -webkit-overflow-scrolling: touch;
}

.upgrade-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  border: 2px solid var(--pink);
  border-radius: 14px;
  padding: 8px 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
  width: 100%;
}
.upgrade-row:active:not(.locked) {
  transform: scale(0.98);
}
.upgrade-row.locked {
  opacity: 0.55;
  background: #f5e8ee;
  border-color: #e8c8d6;
  cursor: not-allowed;
}
.upgrade-row.bought {
  animation: bought 0.5s ease;
}
.upgrade-row.shake {
  animation: shake 0.3s ease;
}
@keyframes bought {
  0%   { background: #fff; }
  30%  { background: #ffe0eb; transform: scale(1.02); }
  100% { background: #fff; transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}

.upgrade-icon {
  font-size: 24px;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}
.upgrade-info {
  flex: 1;
  min-width: 0;
}
.upgrade-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.upgrade-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--pink-deep);
}
.upgrade-level {
  font-size: 10px;
  color: #a06880;
  font-weight: 600;
  background: #ffe3ee;
  padding: 1px 6px;
  border-radius: 999px;
}
.upgrade-bottom {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.upgrade-desc {
  font-size: 11px;
  color: #7a4a5e;
}
.upgrade-cost {
  font-size: 12px;
  font-weight: 700;
  color: var(--pink-deep);
  white-space: nowrap;
}

/* ============= Mensaje emergente en juego ============= */
.message-popup {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: var(--cream);
  padding: 20px 28px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  font-size: 18px;
  font-weight: 600;
  color: var(--pink-deep);
  text-align: center;
  max-width: 80vw;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}
.message-popup.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.message-popup.hidden {
  display: none;
}

/* ============= End screen ============= */
.end-message {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  margin: 16px 0;
  white-space: pre-line;
}
.final-score {
  font-size: 14px;
  color: #7a4a5e;
  margin-bottom: 20px;
}
.final-score span {
  color: var(--pink-deep);
  font-weight: 700;
  font-size: 18px;
}
#end-title {
  font-size: 24px;
  color: var(--pink-deep);
  margin-bottom: 8px;
}
.end-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============= Carta final estilo papel manuscrito ============= */
.paper-stack {
  position: relative;
  width: min(380px, 92vw);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 18px;
}

.paper {
  position: relative;
  width: 100%;
  background: #fdf6e3;
  background-image:
    /* manchitas de papel envejecido */
    radial-gradient(ellipse at 18% 20%, rgba(180, 120, 60, 0.07) 0%, transparent 35%),
    radial-gradient(ellipse at 85% 75%, rgba(180, 120, 60, 0.06) 0%, transparent 35%),
    radial-gradient(ellipse at 60% 40%, rgba(200, 140, 80, 0.04) 0%, transparent 50%),
    /* gradiente base */
    linear-gradient(180deg, #fdf8e8 0%, #fbf2d8 100%);
  padding: 32px 28px 24px;
  border-radius: 4px;
  box-shadow:
    0 1px 0 rgba(0,0,0,0.04),
    0 12px 24px rgba(120, 80, 40, 0.18),
    0 22px 44px rgba(120, 80, 40, 0.14);
  transform: rotate(-0.8deg);
  /* esquina doblada con clip-path opcional */
}
/* esquina inferior derecha sutilmente doblada */
.paper::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, transparent 50%, rgba(180, 130, 60, 0.18) 50%, rgba(220, 180, 110, 0.4) 60%, #fdf6e3 62%);
  border-bottom-right-radius: 4px;
}

/* Cintas washi decorativas */
.washi-tape {
  position: absolute;
  top: 0;
  width: 70px;
  height: 22px;
  background: rgba(248, 187, 208, 0.78);
  background-image: repeating-linear-gradient(
    45deg,
    transparent 0 6px,
    rgba(255, 255, 255, 0.35) 6px 8px
  );
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
  z-index: 3;
}
.washi-left {
  left: 12%;
  transform: rotate(-12deg);
}
.washi-right {
  right: 12%;
  transform: rotate(10deg);
  background: rgba(229, 122, 160, 0.7);
}

.paper-title {
  font-family: "Caveat", cursive;
  font-size: 34px;
  color: #6b2c4a;
  text-align: center;
  margin: 4px 0 14px;
  font-weight: 700;
  line-height: 1;
}

.paper-message {
  font-family: "Caveat", cursive;
  font-size: 22px;
  line-height: 1.45;
  color: #3a2230;
  white-space: pre-line;
  text-align: left;
  margin-bottom: 14px;
  letter-spacing: 0.2px;
}

.paper-signature {
  font-family: "Caveat", cursive;
  font-size: 26px;
  color: #b73a6a;
  font-weight: 700;
  text-align: right;
  margin-bottom: 18px;
  transform: rotate(-2deg);
  transform-origin: right center;
}

/* Polaroid */
.polaroid {
  background: #fff;
  padding: 10px 10px 38px;
  box-shadow:
    0 4px 8px rgba(0,0,0,0.15),
    0 10px 20px rgba(0,0,0,0.12);
  width: 75%;
  margin: 8px auto 4px;
  transform: rotate(2.5deg);
  position: relative;
}
.polaroid img {
  width: 100%;
  height: auto;
  display: block;
  background: #f0e8e0;
}
.polaroid figcaption {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "Caveat", cursive;
  font-size: 18px;
  color: #5a3346;
}

.final-restart-btn {
  margin-top: 20px;
  width: 220px;
  font-family: inherit;
}

/* En pantallas pequeñas la carta puede ser alta: alineamos arriba para que se pueda scrollear */
#final-screen {
  justify-content: flex-start;
  padding-top: 24px;
  padding-bottom: 24px;
}

/* ============= Fondo de corazoncitos ============= */
.hearts-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(248, 187, 208, 0.45) 0%, transparent 8%),
    radial-gradient(circle at 80% 30%, rgba(229, 122, 160, 0.3) 0%, transparent 6%),
    radial-gradient(circle at 30% 70%, rgba(248, 187, 208, 0.4) 0%, transparent 7%),
    radial-gradient(circle at 90% 85%, rgba(229, 122, 160, 0.3) 0%, transparent 6%),
    radial-gradient(circle at 50% 50%, rgba(255, 211, 226, 0.4) 0%, transparent 10%);
  z-index: 1;
}

/* ============= Animaciones ============= */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@media (max-height: 600px) {
  .card { padding: 22px 24px; }
  .title { font-size: 22px; }
  .gift-icon { font-size: 32px; }
}
