/* ===== PERSONALIZAÇÃO: cores principais ===== */
:root {
  --rosa-pastel: #ffd6e7;
  --rosa-claro: #fff0f6;
  --rosa-chiclete: #ff6fa8;
  --rosa-forte: #d9457f;
  --creme: #fff8ec;
  --lilas: #e6d9ff;
  --morango: #e8344f;
  --texto: #5a2a40;
  --branco: #fff;

  --fonte-pixel: "Pixelify Sans", "Press Start 2P", "Courier New", ui-monospace, monospace;
  --fonte-texto: "Nunito", "Quicksand", "Segoe UI", system-ui, -apple-system, sans-serif;
  --fonte-manuscrita: "Caveat", "Segoe Script", "Comic Sans MS", cursive;
}

/* Fontes locais opcionais (veja assets/fonts/README.md) */
@font-face { font-family: "Pixelify Sans"; src: local("Pixelify Sans"), url("../assets/fonts/PixelifySans.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Nunito"; src: local("Nunito"), url("../assets/fonts/Nunito.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Caveat"; src: local("Caveat"), url("../assets/fonts/Caveat.woff2") format("woff2"); font-display: swap; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: hidden; }
body {
  font-family: var(--fonte-texto);
  color: var(--texto);
  background: linear-gradient(160deg, var(--rosa-claro) 0%, var(--rosa-pastel) 55%, var(--lilas) 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
body::before { /* bolinhas cremes de fundo */
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background-image: radial-gradient(var(--creme) 12%, transparent 13%);
  background-size: 34px 34px; opacity: .45;
}

/* ===== Telas ===== */
.screen {
  position: fixed; inset: 0;
  height: 100vh; height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  overflow-y: auto; overflow-x: hidden;
  opacity: 0; visibility: hidden; transition: opacity .6s ease, visibility .6s;
}
.screen[hidden] { display: none; }
.screen.active { opacity: 1; visibility: visible; }

.card-start, .stage { position: relative; z-index: 2; width: 100%; max-width: 30rem; margin: auto; text-align: center; }
.card-start {
  background: rgba(255,255,255,.7); border: 3px dashed var(--rosa-chiclete);
  border-radius: 2rem; padding: 2rem 1.25rem 2.2rem;
  box-shadow: 0 .6rem 1.6rem rgba(217,69,127,.2);
}
.label { font-family: var(--fonte-pixel); font-size: .85rem; color: var(--rosa-forte); margin: 0 0 .8rem; letter-spacing: .05em; }
h1 {
  font-family: var(--fonte-pixel); font-weight: 700; margin: 0 0 1.8rem;
  font-size: clamp(1.9rem, 8.5vw, 3rem); line-height: 1.2; color: var(--rosa-forte);
  text-shadow: 3px 3px 0 var(--branco), 5px 5px 0 var(--rosa-pastel);
}
h2 { font-family: var(--fonte-pixel); color: var(--rosa-forte); font-size: clamp(1.2rem, 5vw, 1.7rem); margin: 0 0 1rem; outline: none; text-shadow: 2px 2px 0 var(--branco); }

/* ===== Botões ===== */
.btn {
  font-family: var(--fonte-pixel); font-weight: 700; font-size: 1.05rem;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 3.4rem; min-width: 11rem; padding: .7rem 1.4rem;
  color: var(--branco); background: linear-gradient(180deg, #ff8fbd, var(--rosa-chiclete));
  border: 3px solid var(--branco); border-radius: 2rem; cursor: pointer;
  box-shadow: 0 .35rem 0 var(--rosa-forte), 0 .8rem 1.2rem rgba(217,69,127,.35);
  transition: transform .15s ease, box-shadow .15s ease;
  touch-action: manipulation;
}
.btn-alt { background: linear-gradient(180deg, #c9b0ff, #a98bf0); box-shadow: 0 .35rem 0 #7d5fcf, 0 .8rem 1.2rem rgba(125,95,207,.3); }
.btn-big { font-size: 1.4rem; min-height: 4.2rem; min-width: 14rem; animation: pulse 2.4s ease-in-out infinite; }
.btn:hover { transform: translateY(-3px) scale(1.04); }
.btn:active { transform: translateY(.3rem) scale(.98); box-shadow: 0 .05rem 0 var(--rosa-forte), 0 .3rem .6rem rgba(217,69,127,.3); }
.btn-alt:active { box-shadow: 0 .05rem 0 #7d5fcf; }
:focus-visible { outline: 4px solid var(--morango); outline-offset: 3px; }

/* ===== Tela 2 ===== */
.stage { display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.cat-frame {
  width: min(78vw, 22rem, 46dvh); aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.75); border: 4px solid var(--branco); border-radius: 2.2rem;
  box-shadow: 0 0 0 4px var(--rosa-chiclete), 0 1rem 2rem rgba(217,69,127,.25); overflow: hidden; margin-bottom: 1.4rem;
}
.cat-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cat-fallback { text-align: center; padding: 1rem; font-size: .9rem; }
.cat-fallback span { display: block; font-size: 4rem; }
.cat-fallback code { background: var(--rosa-pastel); padding: .1rem .3rem; border-radius: .3rem; font-size: .8rem; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; width: 100%; }
.actions .btn { flex: 1 1 11rem; max-width: 16rem; }
.aviso { min-height: 1.6rem; margin: .8rem 0 0; font-weight: 800; font-size: .95rem; color: var(--rosa-forte); background: rgba(255,255,255,.7); border-radius: 1rem; padding: .1rem .8rem; }
.aviso:empty { background: none; }
.eq { display: none; gap: 2px; align-items: flex-end; height: 1rem; }
.eq i { width: 4px; height: 100%; background: currentColor; border-radius: 2px; transform-origin: bottom; }
.tocando .eq { display: inline-flex; }
.tocando .eq i { animation: eq .8s ease-in-out infinite; }
.tocando .eq i:nth-child(2) { animation-delay: .2s; } .tocando .eq i:nth-child(3) { animation-delay: .4s; }

/* ===== Decoração ===== */
.deco-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.deco { position: absolute; font-size: var(--s); width: var(--s); height: var(--s); line-height: 1; animation-delay: var(--d, 0s); filter: drop-shadow(0 2px 2px rgba(217,69,127,.25)); }
svg.deco { overflow: visible; }
.sway { animation: sway 4s ease-in-out infinite; }
.twinkle { animation: twinkle 2.6s ease-in-out infinite; }
.bob { animation: bob 3.6s ease-in-out infinite; }
.floaters { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.floaters span { position: absolute; bottom: -3rem; opacity: 0; animation: rise linear infinite; }
.burst { position: fixed; z-index: 60; pointer-events: none; font-size: 1.4rem; animation: burst .9s ease-out forwards; }

/* ===== Modal ===== */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: rgba(120,40,80,.35); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .35s ease;
}
.overlay[hidden] { display: none; }
.overlay.open { opacity: 1; }
.letter {
  position: relative; width: 100%; max-width: 34rem; max-height: 88vh; max-height: 88dvh;
  display: flex; flex-direction: column; padding: 2.2rem 1.2rem 1.2rem;
  background: linear-gradient(180deg, #fff, var(--rosa-claro)); border: 4px solid var(--rosa-chiclete); border-radius: 1.8rem;
  box-shadow: 0 1rem 2.5rem rgba(90,42,64,.35); outline: none;
  transform: translateY(1.5rem) scale(.92); transition: transform .35s cubic-bezier(.2,.9,.3,1.2);
}
.overlay.open .letter { transform: none; }
.letter h2 { font-family: var(--fonte-manuscrita); font-size: clamp(1.6rem, 7vw, 2.1rem); text-align: center; text-shadow: none; margin: 0 1.6rem .8rem; }
.letter-body {
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: .2rem .5rem .5rem; font-size: 1.12rem; line-height: 1.75; color: var(--texto);
}
.letter-body p { margin: 0 0 1rem; }
.letter-body .assin { font-family: var(--fonte-manuscrita); font-size: 1.45rem; line-height: 1.4; color: var(--rosa-forte); margin-bottom: .4rem; }
.close {
  position: absolute; top: .6rem; right: .6rem; width: 2.75rem; height: 2.75rem; border-radius: 50%;
  border: 3px solid var(--rosa-chiclete); background: var(--branco); color: var(--rosa-forte);
  font-size: 1.1rem; font-weight: 800; cursor: pointer; z-index: 3; transition: transform .15s;
}
.close:hover { transform: rotate(90deg) scale(1.1); }
.corner { position: absolute; font-size: 2rem; pointer-events: none; z-index: 2; }
.c1 { top: -.9rem; left: -.7rem; transform: rotate(-20deg); }
.c2 { top: -.9rem; right: 2.6rem; font-size: 1.5rem; }
.c3 { bottom: -.9rem; left: 1rem; font-size: 1.6rem; }
.c4 { bottom: -.9rem; right: -.7rem; transform: rotate(20deg); }
body.modal-open { overflow: hidden; }

/* ===== Animações ===== */
@keyframes rise { 0% { transform: translateY(0) rotate(0); opacity: 0; } 10% { opacity: .75; } 90% { opacity: .5; } 100% { transform: translateY(-110vh) rotate(25deg); opacity: 0; } }
@keyframes sway { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes twinkle { 0%,100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-.6rem); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes eq { 0%,100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) scale(.4); opacity: 0; } }

/* ===== Responsivo ===== */
@media (max-height: 560px) and (orientation: landscape) {
  .stage { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .cat-frame { width: min(40vw, 70dvh); margin-bottom: .6rem; }
  h2 { width: 100%; }
}
@media (min-width: 768px) { .letter-body { font-size: 1.2rem; } .btn-big { font-size: 1.6rem; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  .floaters, .burst { display: none; }
}
