:root {
  --roxo: #2b2235;
  --roxo-2: #3d2f4d;
  --creme: #fff6e8;
  --amarelo: #ffc93c;
  --laranja: #ff8a3d;
  --rosa: #ff5f8f;
  --verde: #3bceac;
  --texto: #2b2235;
  --sombra: 0 10px 30px rgba(20, 10, 30, .45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--roxo);
  font-family: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  color: var(--texto);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

#palco { touch-action: none; }

#palco canvas { display: block; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 .35em;
  margin: 0 .1em;
  border-radius: 6px;
  background: var(--creme);
  color: var(--texto);
  border-bottom: 3px solid #cbb89c;
  font-family: inherit;
  font-weight: 700;
  font-size: .85em;
  text-align: center;
  line-height: 1.5;
}

.oculto { display: none !important; }

.botao {
  font: inherit;
  font-weight: 700;
  font-size: 1.35rem;
  padding: .6em 1.8em;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--amarelo), var(--laranja));
  color: var(--texto);
  box-shadow: 0 6px 0 #c4591f, var(--sombra);
  cursor: pointer;
  transition: transform .1s;
}
.botao:hover { transform: translateY(-2px); }
.botao:active { transform: translateY(3px); box-shadow: 0 2px 0 #c4591f; }
.botao.pequeno { font-size: 1rem; padding: .5em 1.4em; }

/* ---------------- HUD ---------------- */
#hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  gap: 10px;
  align-items: flex-start;
  pointer-events: none;
  z-index: 5;
}
.caixa-contador, #btn-painel, .ajuda {
  background: rgba(255, 246, 232, .95);
  border-radius: 14px;
  box-shadow: var(--sombra);
  padding: 8px 14px;
}
#contador { font-size: 1.1rem; }
#contador b { color: #c4304f; }
.barra { height: 8px; margin-top: 6px; border-radius: 99px; background: #ead9c2; overflow: hidden; }
#barra-progresso { height: 100%; width: 0; background: linear-gradient(90deg, var(--rosa), var(--amarelo)); transition: width .5s; }
#btn-painel {
  pointer-events: auto;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  border: 0;
  cursor: pointer;
  color: var(--texto);
}
#btn-painel:hover { background: #fff; }
.ajuda { margin-left: auto; font-size: .9rem; opacity: .9; }

/* ---------------- prompt "E Investigar" ---------------- */
#prompt {
  position: fixed;
  transform: translate(-50%, -130%) scale(.8);
  opacity: 0;
  pointer-events: none;
  padding: 6px 12px;
  border-radius: 12px;
  background: var(--roxo-2);
  color: var(--creme);
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--sombra);
  transition: opacity .15s, transform .15s;
  z-index: 4;
}
#prompt::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-bottom: 0;
  border-top-color: var(--roxo-2);
}
#prompt.visivel { opacity: 1; transform: translate(-50%, -130%) scale(1); animation: flutua 1.2s ease-in-out infinite; }
#prompt .nome { opacity: .7; font-weight: 400; margin-left: 4px; }
#prompt.revirado { background: #6c6377; }
#prompt.revirado::after { border-top-color: #6c6377; }
@keyframes flutua { 50% { margin-top: -4px; } }

/* ---------------- toast e banner ---------------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  width: max-content;
  max-width: min(640px, calc(100vw - 32px));
  padding: 14px 20px;
  border-radius: 16px;
  background: rgba(255, 246, 232, .97);
  box-shadow: var(--sombra);
  font-size: 1.1rem;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 6;
}
#toast.visivel { opacity: 1; transform: translate(-50%, 0); }
#toast b { color: #c4304f; }

#banner-comodo {
  position: fixed;
  top: 90px;
  left: 50%;
  transform: translate(-50%, -10px);
  padding: 8px 24px;
  border-radius: 999px;
  background: rgba(43, 34, 53, .85);
  color: var(--creme);
  font-size: 1.4rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
  z-index: 4;
}
#banner-comodo.visivel { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- telas ---------------- */
.tela {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 10;
}
.tela.escura { background: rgba(25, 15, 35, .7); backdrop-filter: blur(3px); }

#tela-inicio, #conclusao {
  background:
    radial-gradient(circle at 50% 110%, #ffcf5c 0 18%, transparent 19%),
    linear-gradient(180deg, #5b3a8c 0%, #d9487a 55%, #ff9a4d 100%);
}

.cartao-inicio {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  text-align: center;
  padding: 24px 28px 28px;
  border-radius: 28px;
  background: rgba(255, 246, 232, .96);
  box-shadow: var(--sombra);
}
.cartao-inicio h1 { margin: 4px 0; font-size: clamp(2rem, 6vw, 3rem); line-height: 1.05; color: #7a2b4f; }
.sub { margin: 0 0 12px; font-size: 1.05rem; opacity: .8; }
.historia { font-size: 1.1rem; }
.boi-capa { width: 180px; height: 200px; object-fit: contain; animation: quica 1.4s ease-in-out infinite; filter: drop-shadow(0 8px 6px rgba(0,0,0,.25)); }
@keyframes quica { 50% { transform: translateY(-10px) rotate(-2deg); } }
.controles { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; margin-top: 20px; font-size: .95rem; opacity: .85; }

/* ---------------- modal de evidência ---------------- */
.cartao-evidencia {
  width: min(720px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  text-align: center;
  padding: 18px 22px 22px;
  border-radius: 24px;
  background: var(--creme);
  box-shadow: var(--sombra);
  animation: surge .35s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes surge { from { transform: scale(.6) rotate(-4deg); opacity: 0; } }
.selo {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 999px;
  background: var(--roxo-2);
  color: var(--amarelo);
  font-weight: 700;
  letter-spacing: .05em;
  margin-bottom: 12px;
}
#modal.nova .selo { background: #c4304f; color: #fff; animation: pisca .6s ease-in-out 3; }
@keyframes pisca { 50% { transform: scale(1.12); } }
.moldura {
  background: #fff;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  transform: rotate(-1deg);
}
.moldura img, .moldura video { display: block; max-width: 100%; max-height: 55vh; margin: 0 auto; object-fit: contain; }
.cartao-evidencia h2 { margin: 16px 0 4px; color: #7a2b4f; }
.cartao-evidencia p { margin: 0 0 8px; font-size: 1.1rem; }
.contador-modal { font-weight: 600; margin-bottom: 14px; opacity: .75; }

/* ---------------- painel ---------------- */
.cartao-painel {
  width: min(860px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 20px 24px;
  border-radius: 24px;
  background:
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(122, 43, 79, .06) 27px 28px),
    #f7ead1;
  box-shadow: var(--sombra);
}
.topo-painel { display: flex; align-items: center; justify-content: space-between; }
.topo-painel h2 { margin: 0; color: #7a2b4f; }
.fechar { font: inherit; font-size: 1.4rem; border: 0; background: none; cursor: pointer; }
.contador-painel { font-weight: 600; margin: 6px 0 14px; }
#grade-evidencias { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.slot {
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 8px 10px;
  border: 0;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.18);
  cursor: pointer;
  transition: transform .15s;
}
.slot:nth-child(odd) { transform: rotate(-1.5deg); }
.slot:nth-child(even) { transform: rotate(1.5deg); }
.slot.achada:hover { transform: rotate(0) scale(1.05); }
.slot img, .slot video { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 3px; }
.slot span { font-size: .9rem; font-weight: 600; }
.slot:disabled { cursor: default; background: #ebe0cc; }
.interrogacao {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  border-radius: 3px;
  background: repeating-linear-gradient(45deg, #d8c9ad 0 10px, #cdbc9d 10px 20px);
  font-size: 2.6rem;
  font-weight: 700;
  color: #9a8766;
}
.dica { font-size: .9rem; opacity: .65; margin: 14px 0 0; }

/* ---------------- cena final ---------------- */
#cena-final {
  background: linear-gradient(180deg, #4b2a7a 0%, #c83e7a 45%, #ff9a4d 75%, #3d8f6a 75.2%, #2f7a54 100%);
  overflow: hidden;
  cursor: pointer;
  place-items: stretch;
  padding: 0;
}
.sol {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 240px;
  height: 240px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, #ffe27a, #ffb347 70%);
  opacity: .9;
}
.palco-final {
  position: absolute;
  inset: 0 0 180px 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: min(14vw, 180px);
  padding-bottom: 4vh;
}
.ator { position: relative; transition: transform .3s, filter .3s; }
.boi-ator img { width: min(34vw, 300px); display: block; filter: drop-shadow(0 12px 8px rgba(0,0,0,.35)); }
.ela-ator .ela { font-size: min(22vw, 200px); line-height: 1; filter: drop-shadow(0 12px 8px rgba(0,0,0,.35)); }
.ela-ator .laco { position: absolute; top: 2%; left: 14%; font-size: min(7vw, 60px); }
.ela-ator .coracao { position: absolute; top: -30%; left: 50%; font-size: min(9vw, 80px); opacity: 0; transform: translateX(-50%); }
#cena-final[data-falando="boi"] .boi-ator { transform: translateY(-8px) scale(1.03); }
#cena-final[data-falando="ela"] .ela-ator { transform: translateY(-8px) scale(1.03); }
#cena-final[data-falando="boi"] .ela-ator,
#cena-final[data-falando="ela"] .boi-ator { filter: brightness(.8); }

.oculos {
  position: absolute;
  left: 48%;
  top: -40%;
  font-size: min(7vw, 64px);
  opacity: 0;
  transform: rotate(-10deg);
}
#cena-final.oculos-on .oculos { animation: cai-oculos .8s cubic-bezier(.3, 1.4, .5, 1) forwards; }
@keyframes cai-oculos { to { top: 37%; opacity: 1; transform: rotate(0); } }

#cena-final.saindo .boi-ator { animation: vai-embora 2.6s ease-in forwards; filter: none; }
@keyframes vai-embora {
  0% { transform: scaleX(1); }
  15% { transform: scaleX(-1); }
  100% { transform: scaleX(-1) translateX(120vw); }
}
#cena-final.saindo .coracao { animation: parte .8s .3s forwards; }
@keyframes parte { to { opacity: 1; top: -45%; } }
#cena-final.saindo .ela-ator { filter: none; animation: chora .4s ease-in-out infinite; }
@keyframes chora { 50% { transform: translateX(-4px); } }

.dialogo {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px));
  min-height: 130px;
  padding: 16px 22px 30px;
  border-radius: 20px;
  background: rgba(255, 246, 232, .97);
  box-shadow: var(--sombra);
  border: 4px solid var(--amarelo);
}
.dialogo.ela { border-color: var(--rosa); }
.dialogo .quem {
  position: absolute;
  top: -18px;
  left: 20px;
  padding: 2px 14px;
  border-radius: 999px;
  background: var(--amarelo);
  font-weight: 700;
}
.dialogo.ela .quem { background: var(--rosa); color: #fff; }
.dialogo .fala { font-size: 1.35rem; line-height: 1.35; }
.dialogo .dica { position: absolute; right: 16px; bottom: 8px; margin: 0; font-size: .85rem; }

/* ---------------- conclusão ---------------- */
.trofeu { font-size: 4rem; animation: quica 1.2s ease-in-out infinite; }
#conclusao .texto { font-size: 1.25rem; }
.tira { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0 22px; }
.tira img, .tira video { width: 90px; height: 70px; object-fit: cover; border-radius: 6px; border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.2); }

@media (max-width: 700px) {
  .ajuda { display: none; }
  #contador { font-size: .95rem; }
  .dialogo .fala { font-size: 1.1rem; }
  .palco-final { inset: 0 0 170px 0; }
}


/* ---------------- controles de toque ---------------- */
.so-toque { display: none !important; }
body.toque .so-toque { display: inline !important; }
body.toque .so-teclado,
body.toque #hud kbd,
body.toque #prompt kbd,
body.toque .ajuda { display: none !important; }

#toque { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#zona-joystick { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }

#joystick {
  position: fixed;
  left: calc(max(20px, env(safe-area-inset-left)) + 60px);
  top: calc(100% - max(20px, env(safe-area-inset-bottom)) - 60px);
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 246, 232, .10) 0 55%, rgba(255, 246, 232, .22) 56% 100%);
  border: 3px solid rgba(255, 246, 232, .45);
  opacity: .55;
  pointer-events: none;
  transition: opacity .2s;
}
#joystick.ativo { opacity: 1; }
#joystick .pino {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--creme) 55%, #e6d3b5);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .35);
}

#btn-acao {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 92px;
  height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  border: 0;
  border-radius: 50%;
  font: inherit;
  font-weight: 700;
  color: var(--texto);
  background: rgba(255, 246, 232, .35);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .25);
  pointer-events: auto;
  touch-action: none;
  opacity: .5;
  transform: scale(.85);
  transition: opacity .15s, transform .15s, background .15s;
}
#btn-acao .icone { font-size: 2rem; line-height: 1; }
#btn-acao .texto { font-size: .72rem; }
#btn-acao.pronto {
  opacity: 1;
  transform: scale(1);
  background: linear-gradient(180deg, var(--amarelo), var(--laranja));
  box-shadow: 0 6px 0 #c4591f, var(--sombra);
  animation: chama 1s ease-in-out infinite;
}
#btn-acao:active { transform: scale(.92) translateY(3px); }
@keyframes chama { 50% { transform: scale(1.07); } }

body.toque #btn-painel { padding: 10px 14px; font-size: 1.05rem; }
body.toque .fechar { padding: 4px 10px; font-size: 1.8rem; }
body.toque .botao:hover { transform: none; }

@media (max-width: 480px) {
  #hud { gap: 8px; }
  .caixa-contador { flex: 1; padding: 6px 12px; }
  #contador { font-size: .9rem; }
  #banner-comodo { top: 80px; font-size: 1.1rem; }
  .cartao-inicio { padding: 16px 18px 20px; border-radius: 22px; }
  .boi-capa { width: 130px; height: 150px; }
  .historia { font-size: 1rem; }
  .cartao-painel { padding: 14px; }
  .topo-painel h2 { font-size: 1.2rem; }
  #grade-evidencias { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cartao-evidencia { padding: 14px; }
  .moldura img, .moldura video { max-height: 50vh; max-height: 50dvh; }
  #toast { font-size: 1rem; bottom: calc(max(24px, env(safe-area-inset-bottom)) + 110px); }
  .dialogo { padding: 14px 16px 30px; min-height: 110px; }
  .dialogo .fala { font-size: 1.05rem; }
}
/* celular deitado: pouca altura */
@media (max-height: 480px) {
  .boi-capa { width: 90px; height: 100px; }
  .cartao-inicio h1 { font-size: 1.8rem; }
  .historia { margin: 6px 0; }
  .controles { margin-top: 10px; }
  #banner-comodo { top: 64px; }
  .palco-final { inset: 0 0 140px 0; }
  .boi-ator img { width: min(22vw, 200px); }
  .ela-ator .ela { font-size: min(16vw, 130px); }
  .dialogo { min-height: 96px; bottom: 10px; }
  body.toque #toast { max-width: calc(100vw - 320px); font-size: .95rem; }
}
