:root {
  --verde: #4caf50; --verde-esc: #2e7d32; --azul: #3f8fe0; --creme: #fff8e8; --txt: #3b2f22;
  --sombra: 0 6px 0 rgba(0,0,0,.18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #5bb0e8; font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--txt); }
body { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#tela { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button, #hud #barra { pointer-events: auto; }
#mira { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%,-50%); }
#mira::before, #mira::after { content: ""; position: absolute; background: rgba(255,255,255,.9); box-shadow: 0 0 2px rgba(0,0,0,.6); }
#mira::before { left: 10px; top: 0; width: 2px; height: 22px; }
#mira::after { top: 10px; left: 0; height: 2px; width: 22px; }
body.toque #mira { display: none; }

#topo { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; align-items: center; gap: 10px; }
#status { color: #fff; font-weight: 800; text-shadow: 0 1px 3px rgba(0,0,0,.5); font-size: 14px; flex: 1; }
#emotes { display: flex; gap: 6px; }
#emotes button { width: 44px; height: 44px; border-radius: 14px; border: 0; background: rgba(255,255,255,.75); font-size: 22px; box-shadow: var(--sombra); }
#emotes button:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.18); }

.redondo { width: 56px; height: 56px; border-radius: 50%; border: 0; background: rgba(255,255,255,.72); font-size: 24px; font-weight: 900; color: #333; box-shadow: var(--sombra); }
.redondo.grande { width: 84px; height: 84px; font-size: 34px; }
.redondo.ativo, .redondo:active { background: rgba(255,255,255,.95); transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.18); }
#bt-voar.ligado { background: #ffe066; }

#botoes-toque { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: 100px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
body:not(.toque) #botoes-toque, body:not(.toque) #dica-toque { display: none; }
#dica-toque { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); color: #fff; font-size: 13px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.6); white-space: nowrap; transition: opacity 1s; }

#joy { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(255,255,255,.18); border: 3px solid rgba(255,255,255,.5); display: none; }
#joy-pino { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.8); transform: translate(-50%,-50%); }

#barra { position: absolute; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 4px; padding: 5px; background: rgba(0,0,0,.35); border-radius: 14px; }
#barra .slot { width: 52px; height: 52px; border-radius: 10px; border: 3px solid transparent; background: rgba(255,255,255,.15); display: grid; place-items: center; padding: 0; }
#barra .slot.sel { border-color: #fff; background: rgba(255,255,255,.35); }
#barra .slot canvas { width: 38px; height: 38px; image-rendering: pixelated; }
#barra .slot.mais { font-size: 26px; color: #fff; font-weight: 900; }
@media (max-width: 640px) { #barra .slot { width: 40px; height: 40px; } #barra .slot canvas { width: 30px; height: 30px; } #barra .slot:nth-child(n+8):not(.mais) { display: none; } }

#aviso { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); color: #fff; font-weight: 900; font-size: 20px; text-shadow: 0 2px 4px rgba(0,0,0,.6); opacity: 0; transition: opacity .3s; text-align: center; }
#aviso.mostra { opacity: 1; }
#fps { position: fixed; left: 8px; bottom: 8px; color: #fff; font: 12px monospace; text-shadow: 0 1px 2px #000; pointer-events: none; }

/* ---------- janelas / menus ---------- */
.janela { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(20,40,60,.45); padding: 16px; overflow-y: auto; touch-action: pan-y; }
.janela.fundo { background: linear-gradient(#7cc8f5, #bfe6ff 55%, #8fd16a 55.2%, #6fb34f); }
.caixa { width: min(420px, 100%); background: var(--creme); border-radius: 24px; padding: 22px; box-shadow: 0 10px 0 rgba(0,0,0,.15), 0 20px 40px rgba(0,0,0,.2); display: flex; flex-direction: column; gap: 10px; user-select: text; }
.caixa h2 { margin: 0; font-size: 24px; }
.sub { margin: 0 0 6px; opacity: .75; }
.logo { font-size: 46px; font-weight: 900; text-align: center; color: #fff; letter-spacing: 1px;
  text-shadow: 0 4px 0 #2e7d32, 0 6px 0 #1b5e20, 0 10px 16px rgba(0,0,0,.25); -webkit-text-stroke: 2px #2e7d32; }
.logo.pequeno { font-size: 34px; }
.bt { border: 0; border-radius: 14px; padding: 13px 16px; font: inherit; font-weight: 800; font-size: 17px; background: #fff; color: var(--txt); box-shadow: 0 5px 0 #d8cdb8; cursor: pointer; }
.bt:active { transform: translateY(3px); box-shadow: 0 2px 0 #d8cdb8; }
.bt.verde { background: var(--verde); color: #fff; box-shadow: 0 5px 0 var(--verde-esc); }
.bt.grande { font-size: 20px; padding: 16px; }
.bt.fraco { background: transparent; box-shadow: none; opacity: .7; }
.linha-bts { display: flex; gap: 8px; } .linha-bts .bt { flex: 1; }
.campo { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: 15px; }
.campo.linha { flex-direction: row; align-items: center; gap: 8px; }
.campo input:not([type=checkbox]):not([type=range]) { font: inherit; font-size: 18px; padding: 12px; border-radius: 12px; border: 2px solid #e2d6bf; background: #fff; }
.campo input[type=checkbox] { width: 22px; height: 22px; }
.erro { color: #c62828; font-weight: 700; margin: 0; min-height: 1em; }
.cores { display: flex; gap: 8px; flex-wrap: wrap; }
.cores button { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #ccc; }
.cores button.sel { box-shadow: 0 0 0 3px #333; }

#lista-mundos { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.mundo { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 12px; box-shadow: 0 4px 0 #e2d6bf; border: 0; font: inherit; text-align: left; cursor: pointer; }
.mundo b { display: block; font-size: 17px; } .mundo small { opacity: .65; }
.mundo .ic { font-size: 28px; }
.vazio { opacity: .7; text-align: center; padding: 10px; }

#grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; max-height: 55vh; overflow-y: auto; padding: 4px; }
#grade button { aspect-ratio: 1; border-radius: 12px; border: 0; background: #fff; box-shadow: 0 3px 0 #e2d6bf; display: grid; place-items: center; padding: 4px; }
#grade canvas { width: 42px; height: 42px; image-rendering: pixelated; }

.girando { width: 46px; height: 46px; margin: 10px auto; border: 6px solid #cfe9c0; border-top-color: var(--verde); border-radius: 50%; animation: gira 1s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
