/* Resenha — a tela é um jogo (spec 01 §4.7): céu, chão de blocos, painéis
   cinza de inventário, botões de pedra e fonte pixelada. Texturas e ícones
   são nossos; fontes livres (OFL). */

@font-face { font-family: "Pixelify"; src: url("/fontes/pixelify.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "PressStart"; src: url("/fontes/press-start.woff2") format("woff2"); font-display: swap; }

:root {
  --pixel: "Pixelify", ui-monospace, monospace;
  --titulo: "PressStart", "Pixelify", monospace;
  --bloco: 48px;

  --ceu-alto: #6f9cf5;
  --ceu-baixo: #b9d4ff;
  --estrelas: none;

  --painel: #c6c6c6;
  --painel-claro: #ffffff;
  --painel-escuro: #555555;
  --painel-tinta: #3f3f3f;
  --contorno: #000000;

  --campo: #000000;
  --campo-tinta: #e0e0e0;
  --campo-borda: #a0a0a0;

  --texto-sobre-ceu: #ffffff;
  --sombra-texto: #3f3f3f;
  --amarelo: #ffff55;
  --verde-fala: #7cfc00;
  --vermelho: #ff5555;
  --foco: #ffff55;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ceu-alto: #070b1f;
    --ceu-baixo: #1d2a52;
    --estrelas: url("/img/estrelas.svg");
  }
}
:root[data-theme="dark"] {
  --ceu-alto: #070b1f;
  --ceu-baixo: #1d2a52;
  --estrelas: url("/img/estrelas.svg");
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ceu-baixo);
  color: var(--texto-sobre-ceu);
  font-family: var(--pixel);
  font-size: 18px;
  line-height: 1.3;
  overflow-x: hidden;
  /* A ligadura «fi» da Pixelify sai com o glifo errado («Altros»). */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0;
  display: flex;
  flex-direction: column;
}

.ceu {
  position: fixed; inset: 0; z-index: -2;
  background: var(--estrelas) repeat 0 0 / 256px 256px, linear-gradient(var(--ceu-alto), var(--ceu-baixo));
  image-rendering: pixelated;
}

.chao {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: -1;
  height: calc(var(--bloco) * 2);
  background:
    url("/img/grama.svg") repeat-x 0 0 / var(--bloco) var(--bloco),
    url("/img/terra.svg") repeat 0 var(--bloco) / var(--bloco) var(--bloco);
  image-rendering: pixelated;
  border-top: 3px solid #2d5a16;
}

main {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 16px calc(var(--bloco) * 2 + 110px);
}

[hidden] { display: none !important; }

/* ── O título ─────────────────────────────────────────────────────────── */
.titulo { text-align: center; position: relative; margin: 8px 0 28px; }
.logo {
  margin: 0;
  font-family: var(--titulo);
  font-weight: 400;
  font-size: clamp(30px, 8vw, 64px);
  letter-spacing: 2px;
  color: #d9d9d9;
  text-shadow: 3px 3px 0 #555, 6px 6px 0 #262626;
  -webkit-text-stroke: 1px #262626;
}
.frase {
  position: absolute; right: max(4%, 8px); bottom: -18px; margin: 0;
  color: var(--amarelo);
  text-shadow: 2px 2px 0 #3f3f00;
  font-size: clamp(14px, 3vw, 20px);
  transform: rotate(-14deg);
  animation: pulsar .5s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes pulsar { from { transform: rotate(-14deg) scale(1); } to { transform: rotate(-14deg) scale(1.08); } }

/* ── Painel de inventário ─────────────────────────────────────────────── */
.painel {
  background: var(--painel);
  color: var(--painel-tinta);
  border: 4px solid;
  border-color: var(--painel-claro) var(--painel-escuro) var(--painel-escuro) var(--painel-claro);
  outline: 3px solid var(--contorno);
  padding: 20px;
  max-width: 460px;
  margin: 0 auto;
}
.painel h2 { margin: 0 0 16px; font-size: 22px; font-weight: 700; }
.painel p { margin: 0 0 12px; }

dialog.painel { padding: 20px; width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; }
dialog::backdrop { background: rgba(16, 16, 16, .6); }

.campo { display: grid; gap: 6px; margin-bottom: 14px; font-weight: 700; }
.campo input, .campo select, .botao, .slot {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0;
}
.campo input, .campo select {
  font: inherit; font-weight: 400;
  width: 100%;
  padding: 8px 10px;
  background: var(--campo);
  color: var(--campo-tinta);
  border: 2px solid var(--campo-borda);
  border-radius: 0;
  -webkit-appearance: none; appearance: none;
}
.campo select { background-image: linear-gradient(45deg, transparent 50%, var(--campo-tinta) 50%), linear-gradient(135deg, var(--campo-tinta) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 32px; }

.caixa { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; cursor: pointer; }
.caixa small { display: block; font-size: 14px; opacity: .8; }
.caixa input {
  -webkit-appearance: none; appearance: none;
  flex: none; width: 24px; height: 24px; margin: 0;
  background: var(--campo); border: 2px solid var(--campo-borda);
  display: grid; place-content: center; cursor: pointer;
}
.caixa input::after { content: ""; width: 12px; height: 12px; background: transparent; }
.caixa input:checked::after { background: var(--verde-fala); box-shadow: inset -3px -3px 0 #3a7d24; }

.dica { font-size: 15px; }
.aviso { color: #a00000; font-weight: 700; min-height: 1em; margin-top: 12px; }

/* ── O boneco ─────────────────────────────────────────────────────────── */
.boneco { border: 2px solid var(--painel-escuro); margin: 0 0 14px; padding: 10px 12px 4px; }
.boneco legend { font-weight: 700; padding: 0 6px; }
.boneco-topo { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.boneco-topo .rosto { width: 80px; height: 80px; flex: none; }
.boneco-acoes { display: grid; gap: 6px; flex: 1; }
.boneco-acoes .botao { margin: 0; padding: 6px 10px; font-size: 16px; }
.paleta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 10px; }
.paleta-nome { width: 62px; flex: none; font-weight: 700; }
.amostra {
  width: 24px; height: 24px; padding: 0; cursor: pointer;
  border: 2px solid #000; outline: 2px solid transparent; outline-offset: 0;
}
.amostra[aria-checked="true"] { outline: 3px solid #ffffff; box-shadow: 0 0 0 5px #000; }
.traços { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.boneco-porta { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.boneco-porta .botao { margin: 0; font-size: 16px; padding: 8px 10px; }
.rosto.pequeno { width: 56px; height: 56px; flex: none; }
.pessoa.eu .rosto { cursor: pointer; }

/* ── Botão de pedra ───────────────────────────────────────────────────── */
.botao {
  font: inherit; font-weight: 700;
  display: block; width: 100%;
  padding: 10px 14px; margin-top: 8px;
  color: #ffffff;
  text-shadow: 2px 2px 0 var(--sombra-texto);
  background: url("/img/pedra.svg") 0 0 / var(--bloco) var(--bloco);
  image-rendering: pixelated;
  border: 3px solid;
  border-color: #b5b5b5 #3d3d3d #3d3d3d #b5b5b5;
  outline: 2px solid var(--contorno);
  cursor: pointer;
}
.botao.grande { font-size: 22px; padding: 14px; }
.botao:hover { color: var(--amarelo); border-color: #d6d6ff #4a4a8a #4a4a8a #d6d6ff; }
.botao:active { border-color: #3d3d3d #b5b5b5 #b5b5b5 #3d3d3d; }
.botao:disabled { color: #a0a0a0; cursor: wait; filter: grayscale(1) brightness(.8); }

:focus-visible { outline: 3px solid var(--foco) !important; outline-offset: 2px; }

/* ── A sala ───────────────────────────────────────────────────────────── */
.conexao {
  text-align: center; margin: 0 0 16px;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .55);
}

.pessoas {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 210px));
  justify-content: center;
}

.pessoa {
  position: relative;
  display: grid; justify-items: center; align-content: start; gap: 10px;
  padding: 44px 14px 14px;
  background:
    url("/img/grama.svg") repeat-x 0 0 / 32px 32px,
    url("/img/terra.svg") repeat 0 32px / 32px 32px;
  image-rendering: pixelated;
  outline: 3px solid var(--contorno);
  transition: box-shadow .12s;
}
.pessoa.falando { box-shadow: 0 0 0 4px var(--verde-fala), 0 0 28px 6px rgba(124, 252, 0, .55); }

.placa {
  position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 8px);
  padding: 2px 10px;
  background: rgba(0, 0, 0, .6);
  color: #ffffff;
  font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pessoa.eu .placa { color: var(--amarelo); }

.rosto { width: 96px; height: 96px; outline: 3px solid var(--contorno); background: #000; }
.rosto svg { display: block; width: 100%; height: 100%; }

.estado-par {
  font-size: 14px; color: #ffffff; text-shadow: 1px 1px 0 #000;
  background: rgba(0, 0, 0, .45); padding: 1px 8px;
}
.selo-mudo { position: absolute; top: 18px; right: 8px; width: 32px; height: 32px; }
.selo-mudo svg { width: 100%; height: 100%; }

.volume { width: 100%; display: grid; gap: 2px; font-size: 14px; color: #fff; text-shadow: 1px 1px 0 #000; }
.volume input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 16px; margin: 0;
  background: #000; border: 2px solid #8b8b8b;
}
.volume input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 22px; background: #c6c6c6; border: 2px solid; border-color: #fff #555 #555 #fff; }
.volume input[type="range"]::-moz-range-thumb { width: 12px; height: 22px; background: #c6c6c6; border: 2px solid #555; border-radius: 0; }

/* ── A barra de atalhos ───────────────────────────────────────────────── */
.barra {
  position: fixed; left: 50%; bottom: calc(var(--bloco) * 2 - 22px); transform: translateX(-50%);
  display: flex; gap: 0;
  background: rgba(0, 0, 0, .55);
  outline: 3px solid var(--contorno);
  padding: 3px;
  padding-bottom: calc(3px + env(safe-area-inset-bottom));
  z-index: 5;
}
.slot {
  position: relative;
  width: 72px; height: 72px;
  display: grid; place-items: center; align-content: center; gap: 2px;
  background: rgba(139, 139, 139, .35);
  border: 3px solid #8b8b8b;
  color: #ffffff;
  font: inherit; font-size: 13px;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
}
.slot + .slot { border-left-width: 0; }
.slot::before {
  content: attr(data-tecla);
  position: absolute; top: 2px; left: 4px;
  font-family: var(--titulo); font-size: 8px; color: #e0e0e0;
}
.slot-icone { width: 36px; height: 36px; display: block; }
.slot-icone svg { width: 100%; height: 100%; display: block; }
.slot:hover { background: rgba(200, 200, 200, .4); }
.slot[aria-pressed="true"] { border-color: #ffffff; box-shadow: inset 0 0 0 2px #000; }
#slot-mudo[aria-pressed="true"] .slot-nome { color: var(--vermelho); }

/* ── A tela de depuração (qualidade) ──────────────────────────────────── */
.f3 {
  position: fixed; top: 8px; left: 8px; z-index: 6;
  max-width: min(560px, calc(100vw - 16px));
  max-height: calc(100dvh - 220px); overflow: auto;
  font-size: 15px; color: #ffffff;
  display: grid; gap: 10px; justify-items: start;
}
.f3 .grupo { display: grid; gap: 2px; justify-items: start; }
.f3 span { background: rgba(80, 80, 80, .75); padding: 0 4px; white-space: pre-wrap; word-break: break-all; }
.f3 .ruim { color: var(--vermelho); }
.f3 .bom { color: var(--verde-fala); }

/* ── O chat, como o do jogo (§4.9) ────────────────────────────────────── */
.chat {
  position: fixed; left: 8px; bottom: calc(var(--bloco) * 2 + 70px); z-index: 4;
  width: min(620px, calc(100vw - 16px));
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none;
}
.avisos {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 2px; justify-items: start; align-content: end;
  max-height: 40dvh; overflow-y: auto; overscroll-behavior: contain;
  font-size: 19px;
}
.avisos li {
  display: none;
  max-width: 100%;
  background: rgba(0, 0, 0, .5); padding: 2px 8px;
  color: #ffffff; text-shadow: 2px 2px 0 #3f3f3f;
  overflow-wrap: anywhere;
}
.avisos li.sistema { color: var(--amarelo); text-shadow: 2px 2px 0 #3f3f00; }
.avisos li .quem { color: #aaffaa; }
.avisos li.minha .quem { color: var(--amarelo); }
.avisos li.recente { display: block; animation: sumir 10s forwards; }
@keyframes sumir { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

body.chat-aberto .chat { pointer-events: auto; }
body.chat-aberto .avisos { background: rgba(0, 0, 0, .35); padding: 6px; }
body.chat-aberto .avisos li { display: block; animation: none; opacity: 1; }

.chat-form { display: flex; gap: 6px; }
.chat-form input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 20px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, .75); color: #ffffff;
  border: 2px solid #a0a0a0; border-radius: 0;
  font-variant-ligatures: none; font-feature-settings: "liga" 0, "clig" 0;
}
.chat-form .botao { width: auto; margin: 0; padding: 8px 14px; }

.selo-novas {
  position: absolute; top: -10px; right: -8px;
  min-width: 24px; padding: 2px 5px;
  background: var(--vermelho); color: #ffffff; outline: 2px solid #000;
  font-family: var(--titulo); font-size: 10px; line-height: 16px; text-align: center;
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .slot { width: 58px; height: 64px; font-size: 11px; }
  .slot-icone { width: 30px; height: 30px; }
  .pessoas { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 12px; }
  .rosto { width: 72px; height: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .frase { animation: none; }
  .avisos li { animation-duration: 0s; animation-delay: 7s; }
}
