:root {
  --bg: #0a0a0a;
  --bg-2: #121212;
  --bg-3: #1a1a1a;
  --line: #262626;
  --red: #e8000d;
  --red-dark: #a3000a;
  --text: #f2f2f2;
  --muted: #8a8a8a;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
}

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }

/* ===================== LOBBY ===================== */
.lobby {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.lobby-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% -10%, rgba(232, 0, 13, 0.18), transparent 70%),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(255, 255, 255, 0.025) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, rgba(255, 255, 255, 0.025) 31px 32px),
    var(--bg);
}

.lobby-card {
  position: relative;
  width: min(720px, 100%);
  background: rgba(18, 18, 18, 0.92);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  padding: 28px 32px 20px;
  max-height: 96vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 26px;
  height: 26px;
  background: var(--red);
  display: inline-block;
  box-shadow: 4px 4px 0 rgba(232, 0, 13, 0.25);
}
.brand-mark.sm { width: 14px; height: 14px; box-shadow: none; }

.brand h1 {
  font-family: var(--font-display);
  font-size: 44px;
  letter-spacing: 2px;
  line-height: 1;
}
.brand h1 em { font-style: normal; color: var(--red); }

.brand-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--muted);
  margin: 6px 0 22px 38px;
}

.lobby-body { display: flex; gap: 28px; }

.preview-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.preview-frame {
  width: 160px;
  height: 200px;
  background:
    repeating-linear-gradient(0deg, #20160f 0 31px, #281b12 31px 32px),
    #20160f;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  image-rendering: pixelated;
}
#preview { image-rendering: pixelated; }

.form-col { flex: 1; min-width: 0; }

.field-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  margin: 14px 0 6px;
  display: block;
}
.form-col .field-label:first-child { margin-top: 0; }

#name {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}
#name:focus { border-color: var(--red); }

.swatch-row { display: flex; flex-wrap: wrap; gap: 6px; }

.swatch {
  width: 26px;
  height: 26px;
  border: 2px solid transparent;
  cursor: pointer;
  outline: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 0.1s;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: #fff; outline-color: var(--red); }

.style-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
}
.style-btn.active { border-color: var(--red); color: var(--text); background: rgba(232, 0, 13, 0.1); }

.btn-primary {
  width: 100%;
  margin-top: 22px;
  padding: 14px;
  background: var(--red);
  border: none;
  color: #fff;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 3px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: #ff1622; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 7px 14px;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.lobby-error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

.lobby-footer {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

/* ===================== JOGO ===================== */
.game { position: fixed; inset: 0; }

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: #0a0a0a;
}

.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  pointer-events: none;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 10, 10, 0.78);
  border: 1px solid var(--line);
  padding: 7px 12px;
  backdrop-filter: blur(4px);
}

.hud-title {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 2px;
}

.zone-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--red);
  border-left: 1px solid var(--line);
  padding-left: 10px;
  margin-left: 4px;
}

.hud-right { display: flex; gap: 8px; align-items: center; pointer-events: auto; }

.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(10, 10, 10, 0.78);
  border: 1px solid var(--line);
  padding: 7px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.online-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2ecc71;
  box-shadow: 0 0 6px #2ecc71;
}

.hud-btn {
  background: rgba(10, 10, 10, 0.78);
  border: 1px solid var(--line);
  color: var(--text);
  width: 33px;
  height: 33px;
  cursor: pointer;
  font-size: 14px;
}
.hud-btn:hover { border-color: var(--red); }

.zone-toast {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  padding: 9px 18px;
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: 2px;
  animation: toast-in 0.25s ease;
  pointer-events: none;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.players-panel {
  position: absolute;
  top: 56px;
  right: 14px;
  width: 220px;
  max-height: 50vh;
  overflow-y: auto;
  background: rgba(10, 10, 10, 0.88);
  border: 1px solid var(--line);
  border-top: 2px solid var(--red);
  padding: 12px;
  backdrop-filter: blur(4px);
}
.players-panel h3 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 8px;
}
.players-panel ul { list-style: none; }
.players-panel li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.players-panel li .pcolor {
  width: 11px;
  height: 11px;
  outline: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}
.players-panel li .pzone {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--muted);
}

.minimap {
  position: absolute;
  bottom: 14px;
  right: 14px;
  border: 1px solid var(--line);
  background: #000;
  opacity: 0.92;
  image-rendering: pixelated;
}

/* Chat */
.chat {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: min(360px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-log {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px;
  scrollbar-width: thin;
  mask-image: linear-gradient(to bottom, transparent, #000 14%);
}

.chat-msg {
  font-size: 13px;
  line-height: 1.35;
  background: rgba(10, 10, 10, 0.72);
  padding: 4px 9px;
  border-left: 2px solid var(--line);
  word-wrap: break-word;
  animation: msg-in 0.18s ease;
}
.chat-msg.me { border-left-color: var(--red); }
.chat-msg.system { border-left-color: #555; color: var(--muted); font-style: italic; font-size: 12px; }
.chat-msg .author { color: var(--red); font-weight: 700; margin-right: 5px; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-input-row { display: flex; gap: 6px; }

#chatInput {
  flex: 1;
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
}
#chatInput:focus { border-color: var(--red); }

.chat-send {
  background: var(--red);
  border: none;
  color: #fff;
  width: 38px;
  cursor: pointer;
  font-size: 14px;
}

/* Emotes */
.emote-bar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}
.emote-btn {
  width: 40px;
  height: 40px;
  font-size: 19px;
  background: rgba(10, 10, 10, 0.78);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}
.emote-btn:hover { transform: translateY(-3px); border-color: var(--red); }

/* Joystick touch */
.joystick {
  position: absolute;
  bottom: 90px;
  left: 26px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  touch-action: none;
}
.joy-knob {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(232, 0, 13, 0.55);
  border: 1px solid var(--red);
  left: 32px;
  top: 32px;
}

.overlay-msg {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 40;
}
.overlay-msg h2 { font-family: var(--font-display); font-size: 34px; letter-spacing: 3px; color: var(--red); }
.overlay-msg p { color: var(--muted); margin-top: 8px; }

/* Mobile */
@media (max-width: 640px) {
  .lobby-body { flex-direction: column; align-items: center; }
  .brand h1 { font-size: 34px; }
  .chat { width: calc(100vw - 28px); }
  .chat-log { max-height: 110px; }
  .minimap { display: none; }
  .emote-bar { bottom: 70px; right: 14px; left: auto; transform: none; flex-direction: column; }
}

/* Voz */
.hud-btn.voice { font-size: 15px; }
.hud-btn.voice.on {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 12px rgba(232, 0, 13, 0.5);
}

/* Compartilhamento de tela */
.hud-btn.screen.on,
.hud-btn.lock.on {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 12px rgba(232, 0, 13, 0.5);
}

.screens {
  position: absolute;
  top: 56px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}
.screen-tile {
  position: relative;
  width: 220px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  background: #000;
  cursor: pointer;
}
.screen-tile video {
  display: block;
  width: 100%;
  background: #000;
}
.screen-tile .screen-label {
  position: absolute;
  left: 0;
  bottom: 0;
  background: rgba(10, 10, 10, 0.8);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 7px;
}

.screen-full {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.screen-full-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
}
.screen-full-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1px;
  color: #fff;
}
.screen-full video {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
}

/* Configuracoes */
.settings-panel {
  position: absolute;
  top: 56px;
  right: 14px;
  width: 240px;
  background: rgba(10, 10, 10, 0.88);
  border: 1px solid var(--line);
  border-top: 2px solid var(--red);
  padding: 12px;
  backdrop-filter: blur(4px);
  z-index: 6;
}
.settings-panel h3 {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 10px;
}
.setting-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
}
.setting-row.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.setting-row input[type='range'] { width: 100%; accent-color: var(--red); }
.setting-row input[type='checkbox'] { accent-color: var(--red); }

/* Login Google */
.google-row { margin-bottom: 14px; }
.google-status {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
}
.google-status.ok { color: #4caf50; }

/* Microfone desligado: barra vermelha desenhada via CSS */
.hud-btn.voice { position: relative; }
.hud-btn.voice:not(.on)::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 15%;
  width: 2px;
  height: 70%;
  background: var(--red);
  transform: rotate(45deg);
  pointer-events: none;
}
.hud-btn.voice:not(.on) { opacity: 0.85; }

/* Botao de trancar sala (aparece dentro de salas trancaveis) */
.lock-pill {
  position: absolute;
  top: 112px; /* abaixo do toast de zona */
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  color: var(--text);
  padding: 9px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 7;
}
.lock-pill:hover { border-color: var(--red); }
.lock-pill.on {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

/* Lobby travado ate logar com Google */
.form-col.locked > *:not(.google-row) {
  opacity: 0.35;
  pointer-events: none;
}

.logout-link {
  margin-top: 6px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.logout-link:hover { color: var(--text); }

/* Preview da propria tela compartilhada */
.screen-tile.self { border-left-color: #4caf50; }

/* Botoes do HUD com texto (tela, camera, em reuniao) */
.hud-text-btn {
  background: rgba(10, 10, 10, 0.78);
  border: 1px solid var(--line);
  color: var(--text);
  height: 33px;
  padding: 0 12px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.hud-text-btn:hover { border-color: var(--red); }
.hud-text-btn.on {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
  box-shadow: 0 0 12px rgba(232, 0, 13, 0.5);
}

/* Bolhas de webcam sobre os personagens */
.cams {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
}
.cam-bubble {
  position: absolute;
  left: 0;
  top: 0;
  width: 104px;
  height: 78px;
  border: 2px solid var(--red);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.cam-bubble.self { border-color: #4caf50; }
.cam-bubble video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 900px) {
  .hud-right { flex-wrap: wrap; justify-content: flex-end; row-gap: 4px; }
  .hud-text-btn { font-size: 9px; padding: 0 7px; }
}
