/* Mago da Torre: uma tela só, com a ilha inteira à vista (docs/mago-da-torre-mvp.md, seção 5).
   Materiais do GUIA-DO-SITE.md: pedra, madeira, pergaminho, latão e azul arcano. */
.mg {
  --ease-out: cubic-bezier(.215, .61, .355, 1);
  max-width: 1560px; margin: 0 auto; padding: 0 16px;
}
main:has(.mg) { padding: 14px 0 28px; }
.mg-carregando { text-align: center; color: var(--muted); padding: 80px 0; }

/* ---------- recursos: faixa dentro da janela do jogo, em caixas de largura fixa ---------- */
.mg-recursos {
  position: absolute; z-index: 1; top: 6px; left: 6px; right: 6px; margin: 0; padding: 0; list-style: none;
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px;
  pointer-events: none; /* não atrapalha os cliques nem o cursor do mapa */
}
.mg-rec {
  display: flex; align-items: center; gap: 5px; min-width: 0; padding: 3px 7px 3px 5px; border-radius: 3px;
  white-space: nowrap; overflow: hidden; line-height: 1.15; font-size: .85rem;
  color: var(--parch-ink); background: var(--parch) var(--tex-parch);
  box-shadow: inset 0 0 10px rgba(120, 70, 20, .45), 0 0 0 1px rgba(60, 30, 5, .8), 0 3px 8px rgba(0, 0, 0, .45);
}
.mg-rec .val { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; } /* número à direita: a caixa não mexe */
.mg-rec b { font-family: var(--font-ui); font-weight: 700; font-variant-numeric: tabular-nums; }
.mg-rec small { color: var(--parch-muted); font: .75rem var(--font-ui); font-variant-numeric: tabular-nums; }
.mg-rec.cheio b { color: #7a1d12; }
.mg-quadro { container-type: inline-size; }
@container (max-width: 760px) {  /* janela estreita: os nomes somem da vista (o leitor de tela continua lendo) */
  .mg-rec .nome { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
@container (max-width: 480px) {
  .mg-recursos { gap: 3px; top: 4px; left: 4px; right: 4px; }
  .mg-rec { font-size: .75rem; padding: 2px 4px 2px 3px; gap: 3px; }
  .mg-rec small { display: none; }
}
.mg-ico { width: 16px; height: 16px; flex-shrink: 0; image-rendering: pixelated; background-repeat: no-repeat; }

/* ---------- grade: ilha + painel ---------- */
.mg-grade { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 14px; align-items: start; }
@media (max-width: 900px) { .mg-grade { grid-template-columns: minmax(0, 1fr); } }

.mg-quadro {
  position: relative; margin: 0 auto; line-height: 0; border-radius: 3px; overflow: hidden; touch-action: manipulation;
  background: #41a6f6; box-shadow: 0 0 0 2px var(--brass-dark), 0 0 0 3px #000, 0 14px 30px rgba(0, 0, 0, .6);
}
.mg-quadro canvas { display: block; width: 100%; height: 100%; cursor: pointer; }
.mg-quadro.com-zoom canvas { cursor: grab; touch-action: none; }
/* cursor próprio desenhado no canvas: a seta do sistema some sobre o mapa */
.mg-quadro.cursor-proprio canvas, .mg-quadro.cursor-proprio .mg-alvo { cursor: none; }
.mg-quadro[data-cursor="info"] canvas { cursor: help; }
.mg-quadro.arrastando canvas { cursor: grabbing; }
.mg-quadro.cursor-proprio.arrastando canvas { cursor: none; } /* o cursor desenhado (mão fechada) já aparece: a do sistema some */

/* palco: recursos + mapa; é ele que vai para a tela cheia */
.mg-palco:fullscreen { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px; background: #0a0c0f var(--tex-rock); }

/* botões de zoom no canto do mapa */
.mg-zoom { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 4px; line-height: 1; z-index: 1; }
.mg-zoom button {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0; cursor: pointer; border-radius: 3px;
  color: var(--brass-light); background: rgba(36, 21, 10, .88); border: 1px solid var(--brass-dark); box-shadow: 0 0 0 1px #000;
}
.mg-zoom button:hover:not(:disabled) { border-color: var(--brass); color: #fff; }
.mg-zoom button:disabled { opacity: .45; cursor: default; }
.mg-zoom button:focus-visible { outline: 2px solid var(--arcane-2); outline-offset: 2px; }
.mg-zoom svg { width: 16px; height: 16px; fill: currentColor; }
.mg-quadro canvas:focus-visible { outline: 3px solid var(--arcane-2); outline-offset: -3px; }

/* botões invisíveis por cima do mapa (teclado e leitor de tela) */
.mg-alvo {
  position: absolute; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: 4px;
}
.mg-alvo:focus-visible { outline: 3px solid var(--arcane-2); outline-offset: 2px; box-shadow: 0 0 18px rgba(0, 168, 232, .6); }

/* números que sobem do clique */
.mg-flutua {
  position: absolute; pointer-events: none; line-height: 1; white-space: nowrap; transform: translate(-50%, -50%);
  font: 700 .95rem var(--font-ui); color: #fff3b0; text-shadow: 0 1px 0 #1a1c2c, 1px 0 0 #1a1c2c, -1px 0 0 #1a1c2c, 0 -1px 0 #1a1c2c;
  animation: mg-sobe .9s var(--ease-out) forwards;
}
.mg-flutua.madeira { color: #e8c39e; } .mg-flutua.pedra { color: #dfe8ef; } .mg-flutua.mana { color: #7fd6f7; }
@keyframes mg-sobe { from { opacity: 1; translate: 0 0; } to { opacity: 0; translate: 0 -28px; } }

/* balão de detalhes no mapa */
.mg-balao {
  position: absolute; z-index: 2; max-width: 230px; padding: 8px 10px; line-height: 1.35; font-size: .9rem; border-radius: 3px;
  color: var(--parch-ink); background: var(--parch) var(--tex-parch); transform: translate(-50%, calc(-100% - 10px));
  box-shadow: inset 0 0 14px rgba(120, 70, 20, .45), 0 0 0 1px rgba(60, 30, 5, .8), 0 8px 16px rgba(0, 0, 0, .5);
  animation: mg-aparece .18s var(--ease-out);
}
.mg-balao strong { font-family: var(--font-head); display: block; }
@keyframes mg-aparece { from { opacity: 0; scale: .96; } }

/* modo de escolher lugar */
.mg-escolha {
  position: absolute; left: 50%; bottom: 48px; translate: -50% 0; z-index: 2; line-height: 1.3; padding: 6px 12px; font-size: .9rem;
  border-radius: 3px; color: var(--arcane-2); background: rgba(10, 12, 15, .88); border: 1px solid var(--arcane-mid); text-align: center;
}

/* ---------- painel lateral ---------- */
.mg-painel {
  padding: 12px 14px; border-radius: 4px; margin-bottom: 12px;
  background: linear-gradient(180deg, rgba(29, 34, 40, .94), rgba(10, 12, 15, .96)), var(--tex-grain);
  border: 1px solid var(--brass-dark); box-shadow: 0 0 0 1px #000, 0 10px 24px rgba(0, 0, 0, .55);
}
.mg-painel h2 { margin: 0 0 8px; font-size: 1.02rem; color: var(--brass-light); }
.mg-painel h2::after { display: none; }
.mg-painel p { margin: 0 0 6px; font-size: .95rem; }
.mg-cmds { display: grid; gap: 6px; }
.mg-cmd {
  display: grid; grid-template-columns: 1fr; gap: 2px; width: 100%; padding: 7px 10px; text-align: left;
  font: inherit; color: var(--text); cursor: pointer; border-radius: 3px; border: 1px solid var(--brass-dark);
  background: linear-gradient(180deg, #3a2716, var(--wood-dark)); transition: border-color .2s, box-shadow .2s, transform .1s;
}
.mg-cmd:hover:not(:disabled) { border-color: var(--brass); box-shadow: 0 0 14px rgba(0, 168, 232, .35); }
.mg-cmd:active:not(:disabled) { transform: translateY(1px); }
.mg-cmd:disabled { cursor: not-allowed; opacity: .55; }
.mg-cmd strong { font-family: var(--font-head); font-size: .92rem; color: var(--brass-light); }
.mg-cmd small { grid-column: 1 / -1; color: var(--muted); font-size: .82rem; line-height: 1.25; }
.mg-cmd .custo { font-size: .82rem; color: var(--arcane-2); white-space: nowrap; }
.mg-coleta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 6px; }
.mg-coleta .mg-cmd { grid-template-columns: 1fr; text-align: center; padding: 6px 4px; }

.mg-alerta { border-color: #8a2a1c; box-shadow: 0 0 0 1px #000, 0 0 18px rgba(255, 60, 30, .25); }
.mg-alerta h2 { color: #ff9b8a; }
.mg-barra { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; margin: 4px 0 8px; }
.mg-barra i { display: block; height: 100%; background: var(--arcane); transform-origin: left; }

.mg-diario { list-style: none; margin: 0; padding: 0; font-size: .9rem; line-height: 1.35; }
.mg-diario li { padding: 4px 0; border-top: 1px solid rgba(255, 255, 255, .06); }
.mg-diario li:first-child { border-top: 0; }
.mg-diario time { color: var(--muted); font-size: .8rem; margin-right: 4px; }
.mg-diario .ruim { color: #ffb3a6; } .mg-diario .bom { color: #c8f0a0; }

.mg-dialogo {
  max-width: 420px; width: calc(100% - 32px); padding: 18px 20px; border-radius: 4px; color: var(--parch-ink);
  background: var(--parch) var(--tex-parch); border: 0; box-shadow: inset 0 0 24px rgba(120, 70, 20, .5), 0 0 0 2px var(--brass-dark), 0 20px 50px rgba(0, 0, 0, .7);
}
.mg-dialogo::backdrop { background: rgba(0, 0, 0, .6); }
.mg-dialogo h2 { margin: 0 0 10px; color: var(--parch-ink); font-size: 1.2rem; }
.mg-dialogo h2::after { display: none; }
.mg-dialogo ul { margin: 0 0 14px; padding-left: 18px; }

@media (prefers-reduced-motion: reduce) {
  .mg-flutua { animation: mg-some .9s linear forwards; }
  .mg-balao { animation: none; }
  @keyframes mg-some { to { opacity: 0; } }
}
