html, body { margin: 0; height: 100%; background: #0b0814; color: #e8dcff; font-family: monospace; }
#wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100%; padding: 12px; box-sizing: border-box; gap: 10px; }
canvas {
  width: min(100%, calc((100vh - 100px) * 16 / 9)); aspect-ratio: 16 / 9;
  image-rendering: pixelated; image-rendering: crisp-edges;
  background: #000; border: 2px solid #3b2a5c; border-radius: 6px; box-shadow: 0 0 30px #5b3b9a55; outline: none;
}
.help { font-size: 12px; opacity: .8; text-align: center; line-height: 1.9; max-width: 980px; }
kbd { background: #2a1f44; border: 1px solid #4d3a7a; border-radius: 3px; padding: 0 5px; color: #fff; }
.back { width: min(100%, 960px); color: #c48bff; text-decoration: none; font-size: 13px; }
.back:hover { color: #ffe066; }
/* Modo embutido no site (iframe) */
.embed body { background: #06050f; }
.embed #wrap { padding: 0; gap: 0; }
.embed .back, .embed .help { display: none; }
.embed canvas { width: min(100%, calc(100vh * 16 / 9)); border: 0; border-radius: 0; box-shadow: none; }

/* ============================================================
   VERSÃO MOBILE (ativada automaticamente em telas de toque)
   ============================================================ */
html.touch, html.touch body { height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
html.touch #wrap { padding: 0; gap: 0; min-height: 100%; height: 100%; }
html.touch .back, html.touch .help { display: none; }
html.touch canvas { width: min(100vw, calc(100vh * 16 / 9)); width: min(100vw, calc(100dvh * 16 / 9));
  border: 0; border-radius: 0; box-shadow: none; }

#touch { position: fixed; inset: 0; z-index: 10; pointer-events: none; font-family: "Press Start 2P", monospace; }
#touch.hide { display: none; }
#touch button { pointer-events: auto; touch-action: none; font: inherit; color: #fff; cursor: pointer;
  -webkit-appearance: none; appearance: none; padding: 0; margin: 0; }

/* barra de cima (lado direito, onde o HUD do PC ficaria) */
.tc-top { position: absolute; top: max(6px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right));
  display: flex; gap: 5px; align-items: center; }
.tb { height: 38px; min-width: 40px; padding: 0 7px !important; border-radius: 10px; border: 2px solid rgba(155,120,255,.55);
  background: rgba(14,9,32,.72); display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 9px !important; }
.tb b { font-size: 14px; font-weight: normal; line-height: 1; }
.tb span { font-size: 9px; color: #ffe066; }
.tb.sm { min-width: 30px; font-size: 10px !important; }
.tb.spell { min-width: 112px; max-width: 150px; justify-content: flex-start; }
.tb.spell i { flex: none; width: 14px; height: 14px; border-radius: 50%; background: #c48bff; box-shadow: 0 0 6px currentColor; }
.tb.spell span { color: #fff; font-size: 7px; line-height: 1.3; text-align: left; white-space: normal; }
.tb.on, .ab.on { background: rgba(255,224,102,.35); border-color: #ffe066; transform: scale(.94); }

/* direcional */
.tc-pad { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom));
  width: 150px; height: 150px; border-radius: 50%; pointer-events: auto; touch-action: none;
  background: radial-gradient(circle, rgba(30,20,60,.35) 0 40%, rgba(14,9,32,.55) 41%); border: 2px solid rgba(155,120,255,.45); }
.tc-pad .ar { position: absolute; color: rgba(255,255,255,.55); font-size: 16px; line-height: 1; }
.tc-pad .l { left: 12px; top: 50%; transform: translateY(-50%); } .tc-pad .r { right: 12px; top: 50%; transform: translateY(-50%); }
.tc-pad .u { top: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; } .tc-pad .d { bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; }
.tc-pad.L .l, .tc-pad.R .r, .tc-pad.U .u, .tc-pad.D .d { color: #ffe066; text-shadow: 0 0 8px #ffe066; }
.tc-pad .knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(220,200,255,.6), rgba(100,70,190,.55)); border: 2px solid rgba(255,255,255,.35);
  transition: transform .06s; pointer-events: none; }

/* botões de ação (polegar direito) */
.tc-act { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); width: 240px; height: 190px; }
.ab { position: absolute; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); background: rgba(14,9,32,.6);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.ab b { font-size: 22px; font-weight: normal; line-height: 1; }
.ab small { font-size: 6px; opacity: .85; }
.ab.magic { --sc: #c48bff; --ch: 0; width: 86px; height: 86px; right: 4px; bottom: 76px; border-color: var(--sc);
  background: conic-gradient(var(--sc) calc(var(--ch) * 360deg), rgba(14,9,32,.62) 0); }
.ab.magic b { color: #fff; text-shadow: 0 0 10px var(--sc); }
.ab.magic.full { animation: tcpulse .25s infinite alternate; }
@keyframes tcpulse { to { box-shadow: 0 0 24px #fff; } }
.ab.jump { width: 82px; height: 82px; right: 96px; bottom: 6px; border-color: #7dffb0; }
.ab.shield { width: 66px; height: 66px; right: 110px; bottom: 102px; border-color: #8fe3ff; }
.ab.dash { width: 52px; height: 52px; right: 14px; bottom: 6px; border-color: #ffe066; }
.ab.dash b { font-size: 18px; }

/* telas menores (celulares pequenos) */
@media (max-height: 360px) {
  .tc-pad { width: 128px; height: 128px; } .tc-pad .knob { width: 48px; height: 48px; margin: -24px 0 0 -24px; }
  .tc-act { transform: scale(.86); transform-origin: right bottom; }
  .tb { height: 32px; } .tb.spell { min-width: 96px; }
}

/* celular em pé: pede para girar */
#rotate { display: none; }
@media (orientation: portrait) {
  html.touch #rotate { display: flex; position: fixed; inset: 0; z-index: 50; align-items: center; justify-content: center;
    background: #0b0814; color: #ffe066; text-align: center; font: 14px/1.8 "Press Start 2P", monospace; }
  #rotate b { display: block; font-size: 56px; font-weight: normal; animation: tcrot 1.6s ease-in-out infinite; }
  @keyframes tcrot { 50% { transform: rotate(90deg); } }
}
