:root {
  --bg: #0e0e0f;
  --cartao: #161618;
  --borda: #2a2a2d;
  --texto: #ececec;
  --texto-2: #a3a3a8;
  --acento: #c0392b;
  --botao: #000;
  --botao-hover: #1c1c1e;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}

#kf {
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  background: #000;
  touch-action: none;
}
#kf[hidden] { display: none; }

#tela {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
#tela[hidden] { display: none; }

.cartao {
  width: 100%;
  max-width: 400px;
  background: var(--cartao);
  border: 1px solid var(--borda);
  border-radius: 14px;
  padding: 32px 24px 24px;
  display: flex;
  flex-direction: column;
}

h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 800;
}
h1::after {
  content: "";
  display: block;
  width: 40px;
  height: 3px;
  margin-top: 10px;
  background: var(--acento);
  border-radius: 2px;
}

.sub { margin: 12px 0 24px; color: var(--texto-2); font-size: 0.95rem; }

label { font-size: 0.85rem; color: var(--texto-2); margin: 0 0 6px; }

input {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--texto);
  background: var(--bg);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
input:focus { outline: none; border-color: #55555a; }

button {
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: var(--botao);
  border: 1px solid #3a3a3e;
  border-radius: 10px;
  padding: 16px;
  margin-top: 6px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--botao-hover); }
button:disabled { opacity: 0.6; cursor: default; }

#progresso { margin-top: 20px; }
#progresso[hidden] { display: none; }
.barra {
  height: 6px;
  background: var(--borda);
  border-radius: 3px;
  overflow: hidden;
}
#barra-fill {
  height: 100%;
  width: 0%;
  background: var(--acento);
  transition: width 0.15s linear;
}
#progresso-texto {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--texto-2);
  font-variant-numeric: tabular-nums;
}

#status { margin: 14px 0 0; font-size: 0.85rem; color: var(--texto-2); min-height: 1.2em; }
#status.erro { color: #e2786d; }

/* O jogo desenha em metade da largura e da altura (um quarto dos pixels)
   e o navegador amplia 2x: o Bevy desenha no tamanho do canvas. */
#palco {
  position: fixed;
  left: 0;
  top: 0;
  width: 50vw;
  height: 50vh;
  transform: scale(2);
  transform-origin: 0 0;
  /* Só o canvas recebe cliques; antes do jogo a tela de entrada fica livre. */
  pointer-events: none;
}
#palco #kf { pointer-events: auto; }

/* Partida online */
#online {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--borda);
  display: flex;
  flex-direction: column;
}
#online h2 { font-size: 1.05rem; margin: 0 0 4px; color: var(--texto); }
#online .sub { margin: 0 0 16px; }
#online-criar { display: flex; flex-direction: column; }
#online-criar[hidden], #online button[hidden] { display: none; }
select {
  font: inherit;
  color: var(--texto);
  background: var(--bg);
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
  width: 100%;
  cursor: pointer;
}
select:focus { outline: none; border-color: #55555a; }
.linha { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.linha > div { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 420px) { .linha { grid-template-columns: 1fr; gap: 0; } }
button.secundario { background: transparent; border-color: #55555a; }
button.secundario:hover:not(:disabled) { background: var(--botao-hover); }
button.link {
  background: none;
  border: none;
  color: var(--texto-2);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px;
  text-decoration: underline;
}
button.link:hover:not(:disabled) { background: none; color: var(--texto); }
