/* ── Pixel Font ── */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --pink:    #ff6b9d;
  --rose:    #c84b7a;
  --blush:   #ffb3c6;
  --cream:   #fff0f3;
  --red:     #e63946;
  --white:   #ffffff;
  --dark:    #4a2040;
}

body {
  font-family: 'Press Start 2P', monospace;
  background: var(--cream);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

/* ── Page System ── */
.page {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
  z-index: 0;
}

.page.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}

.page.fade-out {
  opacity: 0;
  pointer-events: none;
}

.page-content {
  text-align: center;
  padding: 2rem;
  animation: fadeUp 0.8s ease both;
  animation-delay: 0.3s;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Typography ── */
.pixel-title {
  font-size: clamp(1.2rem, 4vw, 2rem);
  color: var(--rose);
  margin-bottom: 1rem;
  text-shadow: 2px 2px 0 var(--blush);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.pixel-subtitle {
  font-size: clamp(0.6rem, 2vw, 0.85rem);
  color: var(--pink);
  margin-bottom: 2.5rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Page 1 : Input ── */
.input-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 1.5rem;
}

.pixel-input {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.65rem, 2vw, 0.9rem);
  padding: 14px 20px;
  border: 4px solid var(--pink);
  border-radius: 0;
  background: var(--white);
  color: var(--dark);
  outline: none;
  text-align: center;
  width: clamp(240px, 50vw, 360px);
  box-shadow:
    4px 4px 0 var(--blush),
    inset 0 0 0 2px var(--cream);
  image-rendering: pixelated;
  transition: border-color 0.2s, box-shadow 0.2s;
  caret-color: transparent;
}

.pixel-input:focus {
  border-color: var(--red);
  box-shadow:
    4px 4px 0 var(--pink),
    inset 0 0 0 2px var(--cream);
}

.pixel-input::placeholder {
  color: var(--blush);
}

.pixel-input:focus::placeholder {
  color: transparent;
}

/* Custom pixel caret */
.pixel-caret {
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background: var(--pink);
  position: absolute;
  pointer-events: none;
  animation: caretBlink 0.8s step-start infinite;
}

@keyframes caretBlink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

/* ── Buttons ── */
.pixel-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(0.6rem, 1.8vw, 0.8rem);
  padding: 12px 32px;
  border: 4px solid var(--rose);
  background: var(--pink);
  color: var(--white);
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--rose);
  transition: transform 0.1s, box-shadow 0.1s;
  image-rendering: pixelated;
  display: inline-block;
}

.pixel-btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--rose);
}

.pixel-btn:active {
  transform: translate(4px, 4px);
  box-shadow: none;
}

/* ── Error Message ── */
.error-msg {
  font-size: clamp(0.5rem, 1.5vw, 0.7rem);
  color: var(--red);
  margin-top: 1.2rem;
  min-height: 1.5em;
  transition: opacity 0.3s;
}

.error-msg.shake-text {
  animation: shakeX 0.4s ease;
}

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-8px); }
  75%      { transform: translateX(8px); }
}

/* ── Page 1 : Background Hearts ── */
.floating-hearts-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: -1;
}

.bg-heart {
  position: absolute;
  color: var(--blush);
  opacity: 0.3;
  font-size: 1.4rem;
  animation: floatUp linear infinite;
}

@keyframes floatUp {
  0%   { transform: translateY(100vh) rotate(0deg); opacity: 0.3; }
  100% { transform: translateY(-10vh) rotate(40deg); opacity: 0; }
}

/* ── Page 2 : Letter ── */
.letter {
  position: relative;
  width: clamp(400px, 50vw, 500px);
  margin: 2rem auto 0;
  cursor: pointer;
}

.letter-img {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
  transition: transform 0.2s ease;
}

.letter:hover .letter-img {
  transform: scale(1.05);
}

/* Pokemon-ball shake: shake briefly, then pause */
.shake {
  animation: pokeBallShake 2.5s ease-in-out infinite;
}

@keyframes pokeBallShake {
  0%   { transform: rotate(0deg); }
  4%   { transform: rotate(-6deg); }
  8%   { transform: rotate(6deg); }
  12%  { transform: rotate(-4deg); }
  16%  { transform: rotate(4deg); }
  20%  { transform: rotate(0deg); }
  100% { transform: rotate(0deg); }
}

/* ── Page 3 : Yes / No ── */
.page3-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.buttons-area {
  margin-top: 2.5rem;
}

.yes-btn,
.no-btn {
  position: fixed;
  font-size: clamp(0.7rem, 2vw, 1rem);
  padding: 16px 40px;
  z-index: 100;
}

.yes-btn {
  background: var(--red);
  border-color: var(--rose);
}

.yes-btn:hover {
  background: var(--pink);
}

.no-btn {
  background: var(--blush);
  border-color: var(--pink);
  color: var(--rose);
}

/* ── Page 4 : Final ── */
#page4 {
  background: var(--cream);
}

.final-title {
  font-size: clamp(1.6rem, 5vw, 3rem);
  color: var(--red);
  text-shadow: 3px 3px 0 var(--blush);
  z-index: 10;
  position: relative;
}

#heartsCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

/* ── Responsive tweaks ── */
@media (max-width: 480px) {
  .buttons-area {
    gap: 1rem;
  }
}
