:root {
  --bg: #070b1a;
  --text: #eef2ff;
  --muted: #9aa4c7;
  --a: #22d3ee;
  --b: #f472b6;
  --accent: #7c3aed;
  --stroke: rgba(255, 255, 255, 0.12);
  --card: rgba(255, 255, 255, 0.06);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #fb7185;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100%;
  overflow-x: hidden;
  position: relative;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 15% 0%, rgba(34, 211, 238, 0.18), transparent 60%),
    radial-gradient(900px 700px at 85% 100%, rgba(244, 114, 182, 0.18), transparent 60%),
    radial-gradient(700px 500px at 50% 50%, rgba(124, 58, 237, 0.12), transparent 70%);
}

/* ---------- Telas ---------- */
.screen {
  display: none;
  min-height: 100vh;
  padding: 24px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
  z-index: 1;
}
.screen.active { display: flex; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  padding: 34px 30px;
  width: 100%;
  max-width: 430px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  animation: rise 0.35s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.logo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--a), #a78bfa, var(--b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle { color: var(--muted); margin: 12px 0 22px; line-height: 1.5; }
.how { color: var(--muted); font-size: 0.8rem; margin-top: 18px; }
.muted { color: var(--muted); }
.small { font-size: 0.78rem; }
.field-label {
  display: block;
  text-align: left;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

/* ---------- Inputs ---------- */
input[type="text"] {
  width: 100%;
  padding: 15px 18px;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus {
  border-color: var(--a);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.15);
}
.code-input {
  text-transform: uppercase;
  letter-spacing: 4px;
  text-align: center;
  font-weight: 700;
}

/* ---------- Botoes ---------- */
.btn {
  border: none;
  border-radius: 14px;
  padding: 15px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, filter 0.2s, opacity 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: default; }

.btn-primary {
  color: #041018;
  background: linear-gradient(90deg, var(--a), #a78bfa);
  box-shadow: 0 12px 30px rgba(34, 211, 238, 0.25);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--stroke);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }

.btn-link {
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 10px;
  text-decoration: underline;
}
.btn-link:hover { color: var(--text); }

.btn-mini {
  padding: 8px 14px;
  font-size: 0.8rem;
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--stroke);
}

.lobby-card { display: flex; flex-direction: column; }
.lobby-card #input-name { margin-bottom: 12px; }
.lobby-card #btn-create { margin-bottom: 4px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  margin: 18px 0;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--stroke);
}

.join-row { display: flex; gap: 10px; }
.join-row .btn { flex: none; }

/* ---------- Fila ---------- */
.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 22px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--a);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.waiting-card h2 { font-size: 1.25rem; margin-bottom: 8px; }
.waiting-card .btn { margin-top: 22px; }

/* ---------- Sala ---------- */
.status-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(251, 191, 36, 0.15);
  color: var(--warn);
  border: 1px solid rgba(251, 191, 36, 0.35);
  margin-bottom: 20px;
}
.status-badge.small { padding: 4px 12px; font-size: 0.75rem; }
.status-badge.ok { background: rgba(52, 211, 153, 0.15); color: var(--ok); border-color: rgba(52, 211, 153, 0.35); }

.code-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.code-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.code-row { display: flex; align-items: center; gap: 12px; }
.code {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 8px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(90deg, var(--a), var(--b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.role-badge {
  font-weight: 700;
  margin-bottom: 18px;
  font-size: 0.95rem;
}

.roster { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
}
.slot.filled { border-color: rgba(34, 211, 238, 0.4); }
.slot-role { font-size: 0.78rem; color: var(--muted); font-weight: 700; }
.slot-name { font-weight: 700; }

.spectators {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 12px;
  min-height: 18px;
}

.scoreline {
  font-weight: 700;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- HUD ---------- */
.hud {
  width: 100%;
  max-width: 900px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.plate {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--card);
  font-weight: 700;
  max-width: 38%;
  overflow: hidden;
}
.plate .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.plate-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 38%;
}
.plate-col .plate { max-width: 100%; }
.plate-col .status-badge { margin: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.plate-a .dot { background: var(--a); box-shadow: 0 0 12px var(--a); }
.plate-b .dot { background: var(--b); box-shadow: 0 0 12px var(--b); }

.hud-center {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 1.3rem;
}
.hud-center .taps:first-child { color: var(--a); }
.hud-center .taps:last-child { color: var(--b); }
.taps-sep { color: var(--muted); }

.topbar {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.subbar {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}
.subbar .score { font-weight: 700; font-size: 0.85rem; color: var(--muted); }

/* ---------- Arena / barra ---------- */
.arena {
  width: 100%;
  max-width: 900px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.track {
  position: relative;
  height: 84px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--stroke);
  overflow: hidden;
  box-shadow: inset 0 6px 24px rgba(0, 0, 0, 0.55);
}

.side { position: absolute; top: 0; bottom: 0; width: 50%; }
.side-me { left: 0; background: linear-gradient(90deg, rgba(34, 211, 238, 0.22), transparent); }
.side-op { right: 0; background: linear-gradient(270deg, rgba(244, 114, 182, 0.22), transparent); }

.center-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.65) 0 8px, transparent 8px 16px);
}

/* O "ponto" da barra que se move */
.knot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #fff, #c7d2fe 45%, #6366f1);
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 26px rgba(148, 163, 255, 0.9), 0 8px 20px rgba(0, 0, 0, 0.5);
  transition: left 0.06s linear, box-shadow 0.2s;
  will-change: left;
}
.knot::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.35);
}
.knot.danger-me { box-shadow: 0 0 34px rgba(244, 114, 182, 1), 0 8px 20px rgba(0, 0, 0, 0.5); }
.knot.danger-op { box-shadow: 0 0 34px rgba(34, 211, 238, 1), 0 8px 20px rgba(0, 0, 0, 0.5); }

.labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--muted);
}
.labels #label-me { color: var(--a); font-weight: 700; }
.labels #label-op { color: var(--b); font-weight: 700; }
.center-label { opacity: 0.7; }

/* ---------- Botao PUXA ---------- */
.tug-btn {
  margin-top: 28px;
  width: 100%;
  max-width: 900px;
  padding: 26px;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #041018;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  background: linear-gradient(90deg, var(--a), #a78bfa, var(--b));
  box-shadow: 0 16px 40px rgba(124, 58, 237, 0.35);
  transition: transform 0.08s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.tug-btn:active,
.tug-btn.press { transform: scale(0.98); }
.tug-btn.hidden { display: none; }

.hint { margin-top: 16px; color: var(--muted); font-size: 0.85rem; text-align: center; }
kbd {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--stroke);
  border-radius: 6px;
  padding: 1px 7px;
  font-family: inherit;
  font-size: 0.8rem;
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 18, 0.72);
  backdrop-filter: blur(6px);
  z-index: 20;
}
.overlay.show { display: flex; }

.countdown {
  font-size: 9rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(90deg, var(--a), var(--b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 30px rgba(124, 58, 237, 0.6));
}
.countdown.go { font-size: 6rem; }
.countdown.pop { animation: pop 0.45s ease; }
@keyframes pop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

.result-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  padding: 36px 32px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(14px);
  animation: rise 0.3s ease both;
}
.result-card h2 { font-size: 1.7rem; margin-bottom: 10px; }
.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 26px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 20px);
  background: rgba(20, 26, 50, 0.95);
  border: 1px solid var(--stroke);
  color: var(--text);
  padding: 13px 22px;
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 50;
  font-size: 0.9rem;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(251, 113, 133, 0.6); }

/* ---------- Responsivo ---------- */
@media (max-width: 640px) {
  .logo { font-size: 1.6rem; }
  .countdown { font-size: 6rem; }
  .track { height: 68px; }
  .knot { width: 52px; height: 52px; }
  .tug-btn { font-size: 1.05rem; padding: 22px; letter-spacing: 0; }
  .plate { max-width: 42%; padding: 8px 12px; font-size: 0.85rem; }
  .hud-center { font-size: 1.1rem; }
  .code { font-size: 1.6rem; letter-spacing: 6px; }
}
