* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #14151a;
  font-family: 'Pixelify Sans', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

body { min-height: 100vh; padding: 20px; }

/* ---------- APP WINDOW ---------- */
#app {
  width: min(92vw, 380px);
  height: min(84vh, 660px);
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 40px 90px -30px rgba(0,0,0,0.75);
  opacity: 0;
  transform: scale(0.85) translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease, background 0.4s ease;
  background: #fff;
}
#app.show { opacity: 1; transform: scale(1) translateY(0); }
#app.minimized { transform: scale(0.85) translateY(0) scaleY(0.05); opacity: 0.4; }

.chrome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  position: relative;
  z-index: 20;
}
.chrome button {
  width: 30px; height: 30px;
  border: 2px solid rgba(0,0,0,0.55);
  border-radius: 6px;
  background: var(--btn, #7fb2c9);
  color: rgba(0,0,0,0.7);
  font-family: 'Pixelify Sans', sans-serif;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}
.chrome .right { display: flex; gap: 7px; }
.chrome button:active { transform: translateY(1px); }

.toast {
  position: absolute;
  top: 52px; left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: #2a241c;
  color: #fff;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 30;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.pages {
  position: relative;
  width: 100%;
  height: calc(100% - 50px);
}

.page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 26px 30px;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.page.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.page h2 {
  font-size: 1.5rem;
  line-height: 1.35;
  margin: 10px 0 18px;
  color: #2a241c;
  font-weight: 600;
  flex: none;
}

.critter-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 26px;
  position: relative;
  width: 100%;
  flex: none;
  margin-bottom: 10px;
  min-height: 92px;
}

.critter-slot { position: relative; display: flex; flex-direction: column; align-items: center; }
.critter-slot canvas { image-rendering: pixelated; }
.critter-label {
  font-size: 0.95rem;
  color: #2a241c;
  margin-bottom: 6px;
}

/* heart accessory */
.heart {
  width: 20px; height: 18px;
  position: absolute;
  right: -14px; bottom: 30px;
  clip-path: polygon(50% 15%, 61% 3%, 78% 3%, 92% 17%, 92% 34%, 50% 78%, 8% 34%, 8% 17%, 22% 3%, 39% 3%);
  background: #e8577a;
}

/* flower accessory */
.flower { position: absolute; right: -18px; bottom: 26px; width: 40px; height: 40px; }
.flower .petal {
  position: absolute; width: 15px; height: 15px; border-radius: 50%;
  background: #f2c14e;
}
.flower .petal:nth-child(1){ top:0; left:12px; }
.flower .petal:nth-child(2){ top:12px; left:24px; }
.flower .petal:nth-child(3){ top:24px; left:12px; }
.flower .petal:nth-child(4){ top:12px; left:0; }
.flower .center { position:absolute; top:12px; left:12px; width:16px; height:16px; border-radius:50%; background:#e2703a; }

/* firework burst */
.burst { position: absolute; width: 46px; height: 46px; }
.burst span {
  position: absolute; top: 50%; left: 50%;
  width: 3px; height: 16px;
  background: var(--c, #e2703a);
  transform-origin: center bottom;
}
.burst.left { left: -6px; top: 30%; }
.burst.right { right: -6px; top: 30%; }

.subtext {
  margin-top: 10px;
  font-size: 1.02rem;
  color: #2a241c;
  line-height: 1.6;
  min-height: 1.6em;
  flex: none;
}
.subtext.typed { white-space: pre-line; text-align: left; }

.signature {
  margin-top: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #2a241c;
  opacity: 0;
  transition: opacity 0.6s ease;
  flex: none;
}
.signature.show { opacity: 1; }

.dots { display: flex; gap: 6px; margin: 16px 0 4px; flex: none; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: rgba(42,36,28,0.25); }
.dots span.on { background: #2a241c; }

.nav-btn {
  margin-top: 14px;
  margin-bottom: 6px;
  background: var(--btn, #7fb2c9);
  border: 2px solid rgba(0,0,0,0.55);
  color: #2a241c;
  font-family: 'Pixelify Sans', sans-serif;
  font-size: 1.02rem;
  padding: 10px 26px;
  border-radius: 22px;
  cursor: pointer;
  flex: none;
  position: relative;
  z-index: 5;
}
.nav-btn:hover { filter: brightness(1.05); }
.nav-btn:active { transform: translateY(1px); }

/* =====================================================
   COUNTER PAGE — decorated & animated
   ===================================================== */

.counter-page {
  background:
    radial-gradient(circle at 15% 12%, rgba(255,255,255,0.55), transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(255,255,255,0.35), transparent 45%),
    linear-gradient(160deg, #cfe0f7, #9fc2ee 45%, #7fa8dd 100%);
  background-size: 200% 200%;
  animation: bgDrift 12s ease-in-out infinite;
}

@keyframes bgDrift {
  0%   { background-position: 0% 0%, 100% 100%, 0% 0%; }
  50%  { background-position: 20% 30%, 70% 70%, 100% 60%; }
  100% { background-position: 0% 0%, 100% 100%, 0% 0%; }
}

.particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.particle {
  position: absolute;
  bottom: -10%;
  font-size: var(--size, 18px);
  opacity: 0;
  animation: floatUp var(--dur, 9s) linear infinite;
  animation-delay: var(--delay, 0s);
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.5));
}

@keyframes floatUp {
  0%   { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  8%   { opacity: 0.9; }
  50%  { transform: translateY(-160px) translateX(var(--drift, 10px)) rotate(90deg); }
  92%  { opacity: 0.7; }
  100% { transform: translateY(-320px) translateX(calc(var(--drift, 10px) * -1)) rotate(180deg); opacity: 0; }
}

.twinkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.twinkle {
  position: absolute;
  width: 4px; height: 4px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px 1px rgba(255,255,255,0.9);
  animation: twinkle var(--tdur, 2.4s) ease-in-out infinite;
  animation-delay: var(--tdelay, 0s);
}
@keyframes twinkle {
  0%, 100% { opacity: 0.15; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1.2); }
}

.counter-page .page-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.counter-page h2 {
  color: #1f3a5f;
  text-shadow: 0 2px 0 rgba(255,255,255,0.5);
  animation: titleFloat 3.4s ease-in-out infinite;
}
@keyframes titleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.badge-heart {
  width: 52px; height: 46px;
  margin: 4px auto 6px;
  position: relative;
  animation: heartbeat 1.6s ease-in-out infinite;
}
.badge-heart::before,
.badge-heart::after {
  content: "";
  position: absolute;
  top: 0; left: 26px;
  width: 26px; height: 40px;
  border-radius: 26px 26px 0 0;
  background: #4f7fc4;
  transform: rotate(-45deg);
  transform-origin: 0 100%;
  box-shadow: 0 0 14px 2px rgba(79,127,196,0.55);
}
.badge-heart::after {
  left: 0;
  transform: rotate(45deg);
  transform-origin: 100% 100%;
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.12); }
  30% { transform: scale(0.98); }
  45% { transform: scale(1.08); }
  60% { transform: scale(1); }
}

.counter {
  display: flex;
  gap: 10px;
  margin: 14px 0 8px;
  flex-wrap: wrap;
  justify-content: center;
  flex: none;
}
.counter .unit {
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(2px);
  border: 2px solid rgba(31,58,95,0.35);
  border-radius: 12px;
  padding: 12px 13px;
  min-width: 64px;
  box-shadow: 0 8px 18px -10px rgba(31,58,95,0.5);
  transition: transform 0.18s ease;
}
.counter .unit.pop { animation: unitPop 0.35s ease; }
@keyframes unitPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.counter .num {
  font-size: 1.7rem;
  font-weight: 700;
  color: #1f3a5f;
  line-height: 1;
  text-shadow: 0 0 10px rgba(127,168,221,0.6);
}
.counter .label {
  font-size: 0.72rem;
  color: #3a5378;
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.counter-sub {
  font-size: 0.95rem;
  color: #294a72;
  margin-top: 2px;
  flex: none;
}

.sparkle-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  font-size: 1.1rem;
  flex: none;
}
.sparkle-row span {
  display: inline-block;
  animation: sparkleWiggle 1.8s ease-in-out infinite;
}
.sparkle-row span:nth-child(2) { animation-delay: 0.2s; }
.sparkle-row span:nth-child(3) { animation-delay: 0.4s; }
.sparkle-row span:nth-child(4) { animation-delay: 0.6s; }
.sparkle-row span:nth-child(5) { animation-delay: 0.8s; }
@keyframes sparkleWiggle {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.7; }
  50% { transform: translateY(-5px) rotate(12deg); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .counter-page,
  .particle,
  .twinkle,
  .counter-page h2,
  .badge-heart,
  .sparkle-row span {
    animation: none !important;
  }
}

@media (max-width: 420px) {
  #app { width: 94vw; height: 88vh; }
  .page h2 { font-size: 1.28rem; }
}
