:root {
  --noite: #06223f;
  --fundo: #041a31;
  --bloco: rgba(255, 255, 255, 0.07);
  --bloco-toque: rgba(255, 255, 255, 0.16);
  --borda: rgba(255, 255, 255, 0.08);
  --texto: #f2f0eb;
  --texto-2: rgba(242, 240, 235, 0.6);
  --laranja: #ff5a1f;
  --ceu: #3db0ff;
  --verde: #34d399;
  --vermelho: #f87171;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
html, body { background: var(--fundo); color: var(--texto); }
body {
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-left));
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; touch-action: manipulation; }

/* login */
body.entrar { display: grid; place-items: center; }
.caixa { width: min(340px, 100%); display: grid; gap: 12px; text-align: center; }
.caixa img { justify-self: center; border-radius: 14px; }
.caixa h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.sub { color: var(--texto-2); font-size: 14px; margin-bottom: 8px; }
.caixa input {
  background: var(--bloco); border: 1px solid var(--borda); border-radius: 12px;
  padding: 14px 16px; color: var(--texto); font-size: 17px; outline: none;
}
.caixa input:focus { border-color: var(--ceu); }
.caixa button {
  background: var(--laranja); border: 0; border-radius: 12px; padding: 14px;
  font-size: 17px; font-weight: 600; color: #fff; cursor: pointer;
}
.erro { color: var(--vermelho); font-size: 14px; }

/* topo */
.topo { display: flex; align-items: center; gap: 12px; padding: 12px 0 8px; }
.marca { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 17px; }
.marca img { border-radius: 6px; }
.status { display: flex; gap: 6px; flex: 1; justify-content: flex-end; flex-wrap: wrap; }
.pilula {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--texto-2);
  background: var(--bloco); border-radius: 99px; padding: 4px 10px;
}
.pilula::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--vermelho); }
.pilula.on::before { background: var(--verde); }
.icone-btn {
  background: var(--bloco); border: 0; border-radius: 10px; width: 34px; height: 34px;
  font-size: 16px; cursor: pointer;
}

/* deck */
.vazio { color: var(--texto-2); text-align: center; padding: 40px 0; }
.agente { margin-top: 10px; }
.agente.off { opacity: 0.4; }
.agente.off .bloco { pointer-events: none; }
.grupo-titulo {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--texto-2); margin: 14px 2px 8px;
}
.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.bloco {
  position: relative; aspect-ratio: 1; border: 1px solid var(--borda); border-radius: 18px;
  background: var(--bloco); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; padding: 8px; cursor: pointer; overflow: hidden;
  transition: transform 120ms ease-out, background-color 160ms ease-out;
}
.bloco:active { transform: scale(0.95); background: var(--bloco-toque); }
.bloco .emoji { font-size: 30px; line-height: 1; }
.bloco .rotulo { font-size: 12.5px; font-weight: 550; text-align: center; line-height: 1.2; }
.bloco.rodando::after {
  content: ""; position: absolute; inset: 6px auto auto 6px; width: 12px; height: 12px;
  border: 2px solid var(--ceu); border-right-color: transparent; border-radius: 50%;
  animation: gira 700ms linear infinite;
}
.bloco.confirmar { background: var(--laranja); border-color: var(--laranja); }
.bloco.confirmar .rotulo::after { content: " · toca de novo"; }
.bloco.ok { box-shadow: inset 0 0 0 2px var(--verde); }
.bloco.falhou { box-shadow: inset 0 0 0 2px var(--vermelho); }
@keyframes gira { to { transform: rotate(360deg); } }

/* aviso */
.aviso {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  background: #0d2b4d; border: 1px solid var(--borda); border-radius: 14px; padding: 12px 14px;
  font-size: 14px; white-space: pre-wrap; max-height: 50dvh; overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.aviso.falhou { border-color: var(--vermelho); }
.aviso b { font-family: -apple-system, system-ui, sans-serif; display: block; margin-bottom: 4px; }

@media (prefers-reduced-motion: reduce) {
  .bloco { transition: none; }
  .bloco.rodando::after { animation-duration: 2s; }
}
