:root {
  --rosa: #F28DB8;
  --rosa-claro: #FFE6F0;
  --rosa-forte: #E0558F;
  --lilas: #9B6BE0;
  --lilas-claro: #EFE4FF;
  --creme: #FFF8F2;
  --texto: #4A2A47;
  --sombra: 0 6px 0 rgba(122, 59, 99, .18);
  font-family: "Fredoka", "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; margin: 0; }

body {
  background:
    radial-gradient(circle at 15% 10%, #FFE0EE 0 12%, transparent 13%),
    radial-gradient(circle at 85% 20%, #EBDDFF 0 9%, transparent 10%),
    radial-gradient(circle at 80% 85%, #FFE0EE 0 14%, transparent 15%),
    linear-gradient(180deg, #FFF1F7 0%, #F6ECFF 100%);
  color: var(--texto);
  overflow: hidden;
  user-select: none;
}

.app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 16px 16px;
  gap: 8px;
}

/* ---------- topo ---------- */
.topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 56px; }
.botao-redondo {
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: #fff; box-shadow: var(--sombra); font-size: 28px; cursor: pointer;
}
.botao-redondo:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(122,59,99,.18); }
.titulo { font-size: 26px; font-weight: 700; color: var(--rosa-forte); letter-spacing: .5px; }
.estrelas { font-size: 22px; background: #fff; border-radius: 30px; padding: 6px 14px; box-shadow: var(--sombra); }

/* ---------- palco ---------- */
.palco {
  display: grid;
  grid-template-columns: minmax(180px, 38%) 1fr;
  align-items: center;
  gap: 12px;
  min-height: 0;
}
@media (max-aspect-ratio: 1/1) { .palco { grid-template-columns: 1fr; grid-template-rows: 42% 1fr; } }

.raposa-area { position: relative; height: 100%; display: flex; align-items: center; justify-content: center; min-height: 0; }
.raposa-area .rz { height: 100%; max-height: 420px; width: auto; max-width: 100%; filter: drop-shadow(0 10px 10px rgba(122,59,99,.15)); cursor: pointer; }

.cena { position: absolute; top: 4px; right: 4px; font-size: 44px; animation: flutua 3s ease-in-out infinite; }

.conversa { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding: 4px; }

.balao {
  background: #fff; border-radius: 28px; padding: 18px 22px;
  font-size: 26px; line-height: 1.35; box-shadow: var(--sombra);
  position: relative; min-height: 80px;
}
.balao::before {
  content: ""; position: absolute; left: -14px; top: 30px;
  border: 14px solid transparent; border-right-color: #fff; border-left: 0;
}
@media (max-aspect-ratio: 1/1) { .balao::before { left: 40%; top: -14px; border: 14px solid transparent; border-bottom-color: #fff; border-top: 0; } }
.balao .p { transition: background .1s, color .1s; border-radius: 8px; padding: 0 2px; }
.balao .p.lendo { background: var(--lilas-claro); color: var(--lilas); }

.pensando span { display: inline-block; width: 14px; height: 14px; margin: 0 4px; border-radius: 50%; background: var(--rosa); animation: pula 1s infinite; }
.pensando span:nth-child(2) { animation-delay: .15s; }
.pensando span:nth-child(3) { animation-delay: .3s; }

.palavra {
  align-self: center; display: flex; gap: 6px; padding: 10px 18px; border-radius: 22px;
  background: var(--lilas-claro); border: 3px dashed var(--lilas); cursor: pointer; font-size: 40px; font-weight: 700;
}
.palavra[hidden] { display: none; }
.palavra .sil:nth-child(odd) { color: var(--rosa-forte); }
.palavra .sil:nth-child(even) { color: var(--lilas); }
.palavra .ouvir { font-size: 30px; align-self: center; }

.opcoes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.opcao {
  border: none; border-radius: 24px; background: #fff; box-shadow: var(--sombra);
  padding: 12px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-family: inherit; color: var(--texto); font-size: 20px; font-weight: 600;
  animation: aparece .35s ease-out both;
}
.opcao .emoji { font-size: 50px; line-height: 1.1; }
.opcao:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(122,59,99,.18); }
.opcao:nth-child(1) { background: #FFF0F6; } .opcao:nth-child(2) { background: #F3EBFF; }
.opcao:nth-child(3) { background: #FFF6E5; } .opcao:nth-child(4) { background: #E9F8F1; }

/* ---------- base ---------- */
.base { display: flex; align-items: center; justify-content: center; gap: 14px; }
.modos { display: flex; gap: 10px; }
.modo {
  width: 78px; height: 78px; border-radius: 24px; border: none; cursor: pointer;
  font-size: 38px; box-shadow: var(--sombra); background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: inherit; color: var(--texto);
}
.modo small { font-size: 12px; font-weight: 600; margin-top: -2px; }
.modo:active { transform: translateY(3px); }
.modo[data-modo="conversar"] { background: #FFE9F2; }
.modo[data-modo="historia"] { background: #EFE4FF; }
.modo[data-modo="brincar"] { background: #FFF3D9; }
.modo[data-modo="orar"] { background: #E3F4FF; }

.microfone {
  width: 112px; height: 112px; border-radius: 50%; border: 6px solid #fff; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, #FF9CC6, var(--rosa-forte));
  box-shadow: 0 8px 0 #B83E73, 0 12px 20px rgba(184,62,115,.3);
  font-size: 54px; color: #fff; flex: none;
}
.microfone:active { transform: translateY(4px); box-shadow: 0 4px 0 #B83E73; }
.microfone.ouvindo { animation: pulsa 1s ease-in-out infinite; background: radial-gradient(circle at 35% 30%, #C9A6FF, var(--lilas)); box-shadow: 0 8px 0 #6E3FB3; }
.microfone:disabled { filter: grayscale(.6) opacity(.6); }

.teclado { display: none; gap: 8px; width: 100%; }
.teclado.aberto { display: flex; }
.teclado input { flex: 1; font-size: 22px; padding: 12px 16px; border-radius: 20px; border: 3px solid var(--rosa); font-family: inherit; }
.teclado button { font-size: 22px; padding: 0 18px; border-radius: 20px; border: none; background: var(--rosa-forte); color: #fff; font-family: inherit; }

/* ---------- tela de descanso ---------- */
.descanso {
  position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #3B2D6B, #6B4E9E); color: #fff; text-align: center; padding: 24px; gap: 12px; z-index: 10;
}
.descanso.ativo { display: flex; }
.descanso .rz { height: 45vh; }
.descanso h1 { font-size: 34px; margin: 0; }
.descanso p { font-size: 22px; margin: 0; opacity: .9; }

/* ---------- animações da Raporoza ---------- */
.rz-corpo { animation: respira 3.2s ease-in-out infinite; transform-origin: 150px 320px; }
.rz-rabo { animation: abana 2.4s ease-in-out infinite; transform-origin: 205px 260px; }
.rz-olho { animation: pisca 4.5s infinite; }
.rz-boca-aberta, .rz-olhos-felizes, .rz-olhos-sono { display: none; }
.rz-cabeca { transition: transform .4s; transform-origin: 150px 200px; }
.rz-orelha-e { transform-origin: 95px 90px; } .rz-orelha-d { transform-origin: 205px 90px; }

.estado-falando .rz-boca-fechada { animation: boca-f .32s steps(1) infinite; }
.estado-falando .rz-boca-aberta { display: inline; animation: boca-a .32s steps(1) infinite; }
.estado-ouvindo .rz-cabeca { transform: rotate(-6deg); }
.estado-ouvindo .rz-orelha-e, .estado-ouvindo .rz-orelha-d { animation: orelha .6s ease-in-out infinite alternate; }
.estado-pensando .rz-cabeca { transform: rotate(7deg); }

.humor-feliz .rz-olhos-normais, .humor-risada .rz-olhos-normais, .humor-carinho .rz-olhos-normais { display: none; }
.humor-feliz .rz-olhos-felizes, .humor-risada .rz-olhos-felizes, .humor-carinho .rz-olhos-felizes { display: inline; }
.humor-sono .rz-olhos-normais { display: none; }
.humor-sono .rz-olhos-sono { display: inline; }
.humor-surpresa .rz-olho { transform: scale(1.18); animation: none; }
.humor-carinho .rz-bochecha, .humor-risada .rz-bochecha { opacity: .75; }
.humor-animada .rz-corpo { animation: pulinho .7s ease-in-out 2; }
.humor-risada .rz-corpo { animation: risada .25s ease-in-out 6; }

@keyframes respira { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-4px) scale(1.01, .99); } }
@keyframes abana { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-9deg); } }
@keyframes pisca { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes boca-f { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes boca-a { 0% { opacity: 0; } 50% { opacity: 1; } }
@keyframes orelha { from { transform: rotate(-4deg); } to { transform: rotate(5deg); } }
@keyframes pulinho { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-22px); } }
@keyframes risada { 0%,100% { transform: rotate(0); } 50% { transform: rotate(3deg); } }
@keyframes pula { 0%,100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-8px); opacity: 1; } }
@keyframes pulsa { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes flutua { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
@keyframes aparece { from { opacity: 0; transform: translateY(14px) scale(.9); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) { * { animation-duration: .01s !important; animation-iteration-count: 1 !important; } }

@media (max-width: 600px) {
  .balao { font-size: 22px; }
  .modo { width: 62px; height: 62px; font-size: 30px; }
  .microfone { width: 92px; height: 92px; font-size: 44px; }
}
