:root {
  --bg: #14121c;
  --panel: #1f1b2e;
  --panel-2: #2a2540;
  --text: #ece9f5;
  --muted: #9a94b3;
  --accent: #7c5cff;
  --accent-2: #a58bff;
  --danger: #e5484d;
  --ok: #30a46c;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-2);
}

header .brand { font-weight: 700; letter-spacing: 0.05em; color: var(--text); }
header .brand span { color: var(--accent-2); }

nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
nav .who { color: var(--muted); font-size: 0.9rem; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; }

input, select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--panel-2);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }

button {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: 0;
  background: var(--accent);
  color: white;
  font-size: 0.95rem;
  cursor: pointer;
}
button:hover { background: var(--accent-2); }
button:disabled { opacity: 0.5; cursor: default; }
button.ghost { background: transparent; border: 1px solid var(--panel-2); color: var(--text); }
button.ghost:hover { background: var(--panel-2); }
button.danger { background: var(--danger); }
button.small { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

.field { margin-bottom: 0.9rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 180px; }

.msg { padding: 0.6rem 0.8rem; border-radius: 8px; margin: 0.75rem 0; font-size: 0.9rem; }
.msg.error { background: rgba(229, 72, 77, 0.15); color: #ff9592; }
.msg.ok { background: rgba(48, 164, 108, 0.15); color: #4cc38a; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: 100%; max-width: 360px; }
.login h1 { text-align: center; }
.login button { width: 100%; margin-top: 0.5rem; }

/* Lista de jogos */
.toolbar { display: flex; gap: 0.75rem; margin-bottom: 1rem; align-items: center; }
.toolbar input { max-width: 360px; }
.toolbar .count { color: var(--muted); font-size: 0.9rem; }

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.9rem; }
.game {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.6rem;
  background: var(--panel);
  border: 1px solid var(--panel-2);
  border-radius: var(--radius);
  padding: 1rem;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.game:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.game .title { font-weight: 600; line-height: 1.3; }
.game .meta { color: var(--muted); font-size: 0.8rem; }
.empty { color: var(--muted); text-align: center; padding: 3rem 1rem; }
.empty code { background: var(--panel-2); padding: 0.1rem 0.4rem; border-radius: 4px; }

/* Tabela de usuários */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--panel-2); }
th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
td .actions { display: flex; gap: 0.4rem; justify-content: flex-end; flex-wrap: wrap; }
.badge { font-size: 0.75rem; padding: 0.15rem 0.5rem; border-radius: 999px; background: var(--panel-2); }
.badge.admin { background: rgba(124, 92, 255, 0.25); color: var(--accent-2); }

/* Tela do jogo */
.play-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.25rem; align-items: start; }
@media (max-width: 1000px) { .play-layout { grid-template-columns: 1fr; } }

.screen-area { display: flex; justify-content: center; }
#game-wrap { width: 100%; aspect-ratio: 4 / 3; background: #000; border-radius: var(--radius); overflow: hidden; }
#game-wrap.fixed { width: auto; aspect-ratio: auto; }
#game { width: 100%; height: 100%; }
#game-wrap.sharp canvas { image-rendering: pixelated; }

.side h2 { margin-top: 0.25rem; }
.side .field { margin-bottom: 0.75rem; }
.side button { width: 100%; margin-bottom: 0.5rem; }
.keys { width: 100%; font-size: 0.85rem; }
.keys td { padding: 0.3rem 0.25rem; }
.keys kbd { background: var(--panel-2); border-radius: 4px; padding: 0.1rem 0.4rem; font-family: inherit; }
.pads { font-size: 0.85rem; color: var(--muted); margin: 0.25rem 0 0.75rem; }
.pads .on { color: #4cc38a; }
