/* Estilo do HUD em DOM (botoes, menu, aviso). O jogo em si e o canvas. */
@font-face { font-family: 'Fredoka'; src: url('fontes/fredoka-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('fontes/fredoka-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --tinta: #1f1a2e;
  --vidro: rgba(31, 26, 46, 0.26);
  --vidro-forte: rgba(31, 26, 46, 0.5);
  --creme: #fff8ec;
  --mel: #ffc93c;
  --rosa: #ff7aa8;
  --menta: #6fd6b4;
  --sombra: rgba(31, 26, 46, 0.28);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #8fd3c4; color: #fff;
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif; font-weight: 700;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  touch-action: none; overscroll-behavior: none;
}
#cena { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#cena.alvo { cursor: pointer; }

.hud { position: fixed; z-index: 2; display: flex; gap: 8px; pointer-events: none; }
.hud > * { pointer-events: auto; }
#topo { top: 0; right: 0; padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(env(safe-area-inset-right, 0px) + 10px) 0 0; }

.btn {
  position: relative; width: 48px; height: 48px; border-radius: 15px; border: 0; padding: 0; cursor: pointer;
  background: var(--vidro); color: #fff; display: grid; place-items: center;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}
.btn:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2); }
.btn svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.22)); }
.btn .selo {
  position: absolute; right: -4px; bottom: -4px; width: 19px; height: 19px; border-radius: 6px; background: var(--mel);
  display: grid; place-items: center; box-shadow: 0 2px 0 var(--sombra);
}
.btn .selo::after { content: ''; border-left: 7px solid var(--tinta); border-top: 4.5px solid transparent; border-bottom: 4.5px solid transparent; margin-left: 2px; }
.btn.pulsar { animation: pulsar 0.9s ease-in-out infinite; }
@keyframes pulsar { 50% { transform: scale(1.12); } }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
body.sem-anuncio .anuncio { display: none !important; }
@media (orientation: landscape) and (max-height: 520px) {
  .btn { width: 42px; height: 42px; border-radius: 13px; }
  .btn svg { width: 23px; height: 23px; }
  #topo { gap: 6px; padding-top: calc(env(safe-area-inset-top, 0px) + 6px); }
}

/* menu: fases e chapeus */
#menu { position: fixed; inset: 0; z-index: 4; display: grid; place-items: center; background: rgba(31, 26, 46, 0.55); padding: 16px; }
#menu[hidden], #aviso[hidden], #anuncio[hidden] { display: none; }
.cartao {
  width: min(440px, 100%); max-height: min(640px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 12px;
  background: var(--creme); color: var(--tinta); border-radius: 26px; padding: 16px; box-shadow: 0 10px 0 var(--sombra);
  border: 4px solid var(--tinta);
}
.cartao header { display: flex; align-items: center; gap: 8px; }
.abas { display: flex; gap: 6px; flex: 1; }
.aba { font: inherit; font-size: 17px; border: 3px solid var(--tinta); border-radius: 14px; padding: 6px 14px; background: #fff; color: var(--tinta); cursor: pointer; }
.aba[aria-selected="true"] { background: var(--mel); }
.fechar { width: 42px; height: 42px; border-radius: 13px; border: 3px solid var(--tinta); background: #fff; color: var(--tinta); font: inherit; font-size: 20px; cursor: pointer; }
.corpo { overflow-y: auto; min-height: 0; }
.mundos { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: 18px; }
.mundos button { width: 40px; height: 40px; border-radius: 12px; border: 3px solid var(--tinta); background: #fff; font: inherit; font-size: 18px; cursor: pointer; color: var(--tinta); }
.mundos button:disabled { opacity: 0.35; cursor: default; }
.grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fase {
  aspect-ratio: 1; border-radius: 18px; border: 3px solid var(--tinta); background: #fff; color: var(--tinta); font: inherit; font-size: 26px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; box-shadow: 0 4px 0 var(--sombra);
}
.fase small { font-size: 13px; letter-spacing: 1px; color: #e3a400; }
.fase.atual { background: var(--mel); }
.fase:disabled { background: #ece4d6; color: #b9ad9b; box-shadow: none; cursor: default; }
.chapeus { grid-template-columns: repeat(4, 1fr); }
.chapeu { aspect-ratio: 1; border-radius: 16px; border: 3px solid var(--tinta); background: #fff; padding: 0; cursor: pointer; overflow: hidden; }
.chapeu canvas { width: 100%; height: 100%; display: block; }
.chapeu[aria-pressed="true"] { background: var(--menta); }
.chapeu:disabled { background: #ece4d6; cursor: default; }
.chapeu:disabled canvas { opacity: 0.35; filter: grayscale(1); }
.cartao footer { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.acao {
  font: inherit; font-size: 16px; border: 3px solid var(--tinta); border-radius: 14px; padding: 9px 14px; cursor: pointer;
  background: var(--mel); color: var(--tinta); display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 4px 0 var(--sombra);
}
.acao.clara { background: #fff; }
.acao:disabled { opacity: 0.45; cursor: default; }

/* aviso de chapeu novo */
#aviso {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 10px; background: var(--creme); color: var(--tinta); border: 4px solid var(--tinta);
  border-radius: 20px; padding: 8px 16px 8px 8px; font-size: 18px; box-shadow: 0 6px 0 var(--sombra); animation: subir 0.35s ease-out;
}
#aviso canvas { width: 56px; height: 56px; }
@keyframes subir { from { transform: translate(-50%, 40px); opacity: 0; } }

/* rewarded simulado (so local, sem SDK) */
#anuncio { position: fixed; inset: 0; z-index: 6; display: grid; place-items: center; background: rgba(10, 8, 24, 0.85); }
#anuncio .cartao { text-align: center; align-items: center; }
#anuncio b { font-size: 64px; line-height: 1; }

@media (prefers-reduced-motion: reduce) { .btn.pulsar, #aviso { animation: none; } }
