/* ===== Base / Canvas ===== */
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  overflow: hidden; background: #0b1320; color: #e5e7eb;
  font-family: system-ui, Segoe UI, Roboto, Arial, sans-serif;
}

/* Tamanho visual do canvas é ajustado pelo JS.
   Mantemos apenas o posicionamento/camada. */
#game {
  position: fixed; inset: 0;
  display: block;
  image-rendering: pixelated;
  background: #000;
}

/* ===== Menu ===== */
.menuWrap { position: fixed; inset: 0; display: grid; place-items: center; }
.menuWrap.hidden { display: none; }

.menuCard {
  display: grid; grid-template-columns: 1fr 1fr; gap: 28px;
  padding: 26px; border-radius: 18px; background: #0f172acc;
  border: 1px solid #ffffff18; box-shadow: 0 10px 30px rgba(0,0,0,.45);
  max-width: 860px; margin: 0 16px;
}
.menuCard .title { font-weight: 800; font-size: 26px; margin-bottom: 8px; }
.wizRow { display: flex; gap: 18px; }
.wiz {
  background: #111a; border: 2px solid transparent; border-radius: 12px;
  padding: 8px 12px; cursor: pointer; color: #e5e7eb;
}
.wiz:hover, .wiz.selected { border-color: #ffd166; }
.wiz .name { font-weight: 700; margin-top: 6px; }
.help h3 { margin: 10px 0 6px; }

/* ===== Bottom bar & buttons ===== */
:root{
  --barH: 72px;   /* altura da barra no mobile */
  --radius: 16px;
}

.bottomBar{
  position: fixed; left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  display: flex; gap: 12px; justify-content: center;
  pointer-events: none;
}
.bottomBar .btn{
  pointer-events: auto;
  min-width: 112px; height: 48px; padding: 10px 16px;
  border-radius: var(--radius); font-weight: 800;
  background: rgba(255,209,102,.88); color: #111; border: none;
  box-shadow: 0 4px 0 rgba(201,169,79,.55);
}
.bottomBar .btn:active { transform: translateY(1px); }

/* ===== Joystick ===== */
#stick{
  position: fixed; left: 16px;
  bottom: calc(var(--barH) + env(safe-area-inset-bottom, 0px) + 16px);
  width: 128px; height: 128px; border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.15);
  display: none;             /* só mostra em touch */
  touch-action: none; backdrop-filter: blur(3px);
}
#knob{
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 999px; background: rgba(255,255,255,.18);
  border: 2px solid rgba(255,255,255,.25);
}
@media (pointer:coarse){ #stick { display: block; } }

/* Esconde joystick e barra quando menu estiver visível */
#menu:not(.hidden) ~ #stick,
#menu:not(.hidden) ~ .bottomBar { display: none !important; }

/* ===== Mobile portrait: layout do cartão ===== */
@media (max-width: 420px), (pointer:coarse) and (max-width: 540px){
  .menuWrap{ display: flex; align-items: center; justify-content: center; padding: 12px; }
  .menuCard{
    width: 100%; max-width: 360px;
    grid-template-columns: 1fr; gap: 14px; padding: 16px 18px;
  }
  .menuCard .title, .menuCard h3{
    margin: 0; font-size: 20px; line-height: 1.2; text-align: center; font-weight: 800;
  }
  .wizRow{
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px;
  }
  .wiz{
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 10px 8px; border-radius: 12px; background: #0b1222;
  }
  .wiz img{ width: 64px; height: 64px; image-rendering: pixelated; }
  .wiz .name{ font-size: 12px; font-weight: 700; }
  .help{ padding-top: 4px; }
  .help ul{ margin: 0; padding-left: 18px; line-height: 1.45; font-size: 13px; }
  .menuCard{ padding-bottom: calc(16px + var(--barH)); }
}

/* ===== Avisos de orientação ===== */
/* Toast discreto no rodapé — não bloqueia clicks */
.orientation-hint{
  position: fixed; left: 50%;
  bottom: env(safe-area-inset-bottom, 12px);
  transform: translateX(-50%);
  max-width: 92vw; padding: 10px 14px; border-radius: 10px;
  background: rgba(0,0,0,0.7); color: #fff;
  font: 500 14px/1.25 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
  z-index: 9999; white-space: nowrap;
}
.orientation-hint.show{ opacity: 1; }
@media (min-width: 1025px){ .orientation-hint { display: none; } }

/* Overlay em retrato — leve e sem bloquear toques */
#rotateHint{
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.35); color: #fff;
  font: 700 18px/1.4 system-ui, Segoe UI, Roboto;
  text-align: center; padding: 24px; z-index: 2000;
  pointer-events: none;        /* não intercepta cliques */
  backdrop-filter: blur(2px);
}
@media (orientation: portrait) and (max-width: 900px){
  #rotateHint{ display: flex; }
}

/* Utilitário */
.hidden { display: none !important; }
/* ===== Mensagem discreta no menu ===== */
.note-landscape {
  margin-top: 10px;
  font-size: 13px;
  text-align: center;
  color: #ffd166;
  opacity: 0.85;
}
/* ===========================
   MOBILE LANDSCAPE: botões em diagonal
   =========================== */
@media (orientation: landscape) and (pointer:coarse) {
  /* Não muda o desktop, só touch devices em landscape */
  .bottomBar {
    pointer-events: none;   /* deixa o container “transparente” ao toque */
  }

  /* Solta os botões do fluxo e posiciona cada um */
  #btnAttack, #btnSwitch {
    position: fixed;
    z-index: 40;
    pointer-events: auto;   /* volta a aceitar toques */
  }

  /* Attack no canto inferior-direito */
  #btnAttack {
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(env(safe-area-inset-bottom) + 90px);
  }

  /* Switch um pouco mais à esquerda e mais abaixo (diagonal) */
  #btnSwitch {
    right: calc(max(16px, env(safe-area-inset-right)) + 140px); /* afastamento horizontal */
    bottom: calc(env(safe-area-inset-bottom) + 30px);           /* afastamento vertical */
  }

  /* Opcional: deixa os botões um pouco maiores em landscape mobile */
  #btnAttack, #btnSwitch {
    min-width: 132px;
    height: 52px;
    font-size: 16px;
  }
}

/* Pequeno ajuste: em telas MUITO baixas, traz um tiquinho pra cima */
@media (orientation: landscape) and (pointer:coarse) and (max-height: 360px) {
  #btnAttack { bottom: calc(env(safe-area-inset-bottom) + 76px); }
  #btnSwitch { bottom: calc(env(safe-area-inset-bottom) + 20px); }
}
 /* 🔹 Joystick um pouco menor em mobile landscape */
  #stick{
    width: 110px;
    height: 110px;
  }
  #knob{
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
  }

  /* 🔹 Botões um pouco mais compactos */
  #btnAttack, #btnSwitch {
    min-width: 110px;
    height: 46px;
    font-size: 15px;
  }
