:root {
  --tinta: #25304d;                
  --tinta-suave: rgba(37, 48, 77, .38);
  --lh: 33.05px;                 
  --fonte-mao: 'Caveat', 'Segoe Print', 'Bradley Hand', 'Comic Sans MS', cursive;
  --fonte-titulo: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --vidro: rgba(14, 40, 92, .62);
  --vidro-borda: rgba(255, 255, 255, .55);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: #0b1a33;
  color: #fff;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

#app { position: fixed; inset: 0; overflow: hidden; }

#stage {
  position: absolute; left: 0; top: 0;
  width: 1920px; height: 1080px;
  transform-origin: 0 0;
  opacity: 0;
  transition: opacity .9s ease;
  will-change: transform;
}
#app:not([data-state="carregando"]) #stage { opacity: 1; }

#fundo, #stage video {
  position: absolute; left: 0; top: 0;
  width: 1920px; height: 1080px;
  display: block;
  object-fit: fill;              
  user-select: none; -webkit-user-drag: none;
}
#fundo   { z-index: 0; }
#vIntro  { z-index: 1; transition: opacity 1.1s ease; }
#rig     { z-index: 2; }
#vSaida  { z-index: 3; opacity: 0; pointer-events: none; }

#rig {
  position: absolute; left: 0; top: 0; width: 1920px; height: 1080px;
  transform-origin: 974px 553px;  
  opacity: 0; pointer-events: none;
  transition: opacity .16s linear, transform .9s cubic-bezier(.33, 1, .4, 1);
}
#rig.is-on { opacity: 1; }
#rig.is-live { pointer-events: auto; }
#rig.no-anim { transition: opacity .16s linear; }
#papel { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; display: block;
         user-select: none; -webkit-user-drag: none; pointer-events: none; }

.writing {
  position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; margin: 0;
  transform-origin: 974px 553px;
  transform: rotate(4.15deg);
  pointer-events: none;
}
.writing fieldset { position: absolute; inset: 0; margin: 0; padding: 0; border: 0; min-width: 0; }
.writing textarea, .writing input, .writing .assinatura { pointer-events: auto; }

#mensagem {
  position: absolute; left: 705px; top: 91px;
  width: 565px; height: calc(var(--lh) * 25);
  margin: 0; padding: 0; border: 0; border-radius: 0;
  background: transparent; box-shadow: none; resize: none; outline: none;
  overflow: hidden;
  color: var(--tinta); caret-color: #2f6bbd;
  font: 600 28px/var(--lh) var(--fonte-mao);
  letter-spacing: .1px;
  white-space: pre-wrap; overflow-wrap: anywhere;
  -webkit-appearance: none; appearance: none;
}

.assinatura {
  position: absolute; left: 790px; top: calc(91px + var(--lh) * 26); width: 480px; height: var(--lh);
  display: flex; align-items: baseline; gap: 10px;
  font: 600 28px/var(--lh) var(--fonte-mao); color: var(--tinta);
}
.assinatura label { flex: none; opacity: .8; }
#nome {
  flex: 1; min-width: 0; height: var(--lh); margin: 0; padding: 0; border: 0; border-radius: 0;
  background: transparent; box-shadow: none; outline: none;
  color: var(--tinta); caret-color: #2f6bbd;
  font: inherit; -webkit-appearance: none; appearance: none;
}
#mensagem::placeholder, #nome::placeholder { color: var(--tinta-suave); opacity: 1; }
#mensagem:focus-visible, #nome:focus-visible {
  outline: 1.5px dotted rgba(47, 107, 189, .4); outline-offset: 6px; border-radius: 3px;
}
#mensagem:disabled, #nome:disabled { color: var(--tinta); -webkit-text-fill-color: var(--tinta); opacity: 1; }

.hp { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }

#acoes {
  position: fixed; left: var(--bx, 50%); top: var(--by, calc(100% - 44px));
  transform: translate(-50%, -50%);
  z-index: 10; display: flex; flex-direction: column; align-items: center;
  opacity: 0; pointer-events: none; transition: opacity .6s ease;
}
#app[data-state="escrevendo"] #acoes,
#app[data-state="enviando"] #acoes { opacity: 1; pointer-events: auto; }

.vidro, #enviar, #comecar {
  background: var(--vidro);
  border: 1px solid var(--vidro-borda);
  -webkit-backdrop-filter: blur(10px) saturate(1.3); backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: 0 8px 28px rgba(14, 40, 92, .38), inset 0 1px 0 rgba(255, 255, 255, .45);
}

#enviar, #comecar {
  display: inline-flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 24px 0 16px; border-radius: 999px;
  color: #fff; cursor: pointer;
  font: 600 25px/1 var(--fonte-mao);
  text-shadow: 0 1px 6px rgba(8, 24, 60, .6);
  transition: transform .2s ease, background .2s ease, opacity .3s ease;
  -webkit-tap-highlight-color: transparent;
}
#comecar { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 20; padding-left: 24px; }
#enviar:hover:not(:disabled) { transform: translateY(-1px); background: rgba(24, 62, 130, .72); }
#enviar:active:not(:disabled) { transform: translateY(1px); }
#enviar:focus-visible, #comecar:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
#enviar:disabled { opacity: .55; cursor: default; }
.ico-flor { width: 26px; height: 26px; color: #9fd0ff; flex: none; transition: transform .6s ease; }
#enviar[data-state="sending"] .ico-flor { animation: gira 1.1s linear infinite; }
#enviar[data-state="error"] { animation: treme .45s ease; background: rgba(120, 30, 50, .62); }
#enviar[data-state="success"] { background: rgba(20, 100, 90, .62); }
.rot { display: none; }
#enviar[data-state="idle"] .rot-idle,
#enviar[data-state="sending"] .rot-sending,
#enviar[data-state="success"] .rot-success,
#enviar[data-state="error"] .rot-error { display: inline; }

#aviso {
  position: absolute; top: calc(100% + 12px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: min(300px, 86vw); margin: 0;
  padding: 9px 14px; border-radius: 14px; text-align: center;
  font-size: 14px; line-height: 1.35; color: #fff;
  background: rgba(11, 26, 51, .78); border: 1px solid rgba(255, 255, 255, .25);
}
#aviso:empty { display: none; }
#acoes.acima #aviso { top: auto; bottom: calc(100% + 12px); }

#dica-giro {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 30; margin: 0;
  max-width: 90vw; padding: 7px 14px; border-radius: 999px; font-size: 13px; text-align: center;
  background: rgba(11, 26, 51, .78); border: 1px solid rgba(255, 255, 255, .25);
}

#final {
  position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px;
  pointer-events: none; opacity: 0; transition: opacity 1.8s ease .3s;
  background: radial-gradient(ellipse at center, rgba(8, 30, 70, .5) 0%, rgba(8, 30, 70, 0) 62%);
}
#final.is-on { opacity: 1; }
#final h1 {
  margin: 0 0 .35em; font: italic 500 clamp(36px, 7vw, 84px)/1.1 var(--fonte-titulo);
  text-shadow: 0 2px 30px rgba(8, 36, 90, .85), 0 0 3px rgba(0, 30, 80, .55);
}
#final p { margin: 0; font: italic 500 clamp(20px, 3vw, 30px)/1.3 var(--fonte-titulo);
  text-shadow: 0 2px 20px rgba(8, 36, 90, .85), 0 0 3px rgba(0, 30, 80, .55); }

@keyframes gira { to { transform: rotate(360deg); } }
@keyframes treme { 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

@media (prefers-reduced-motion: reduce) {
  #stage, #acoes, #final, #vIntro, #enviar { transition-duration: .01s !important; transition-delay: 0s !important; }
  #rig { transition: opacity .01s linear !important; }
  .ico-flor { animation: none !important; }
  #enviar[data-state="error"] { animation: none; }
}

/* ---------- Música de fundo (botão de som) ---------- */
#som {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 25;
  width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border-radius: 50%;
  color: #fff; cursor: pointer;
  background: var(--vidro); border: 1px solid var(--vidro-borda);
  -webkit-backdrop-filter: blur(10px) saturate(1.3); backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: 0 6px 20px rgba(14, 40, 92, .35), inset 0 1px 0 rgba(255, 255, 255, .45);
  transition: transform .2s ease, background .2s ease; -webkit-tap-highlight-color: transparent;
}
#som svg { width: 22px; height: 22px; }
#som:hover { transform: translateY(-1px); background: rgba(24, 62, 130, .72); }
#som:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
#som .corte { display: none; }
#som[aria-pressed="true"] .onda { display: none; }
#som[aria-pressed="true"] .corte { display: inline; }
#som[aria-pressed="true"] { opacity: .8; }
