:root {
  --bg: #0f1226;
  --card: #1b1f3b;
  --card-hi: #262b54;
  --accent: #ffd23f;
  --accent-2: #4cc9f0;
  --ok: #2ecc71;
  --miss: #5a6080;
  --text: #f5f6fa;
  --muted: #a7adcb;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* Garante que o atributo `hidden` sempre vença regras de display
   (ex.: .auth-form{display:flex}), senão elementos ocultos aparecem. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 40px;
}

.topbar {
  text-align: center;
  padding: 18px 16px 8px;
  background: linear-gradient(135deg, #7209b7, #3a0ca3);
}
.topbar h1 { margin: 0; font-size: 1.25rem; }
.subtitle { margin: 4px 0 0; color: #e0d7ff; font-size: .85rem; }

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.tab {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--muted);
  font-size: .95rem;
  font-weight: 600;
}
.tab.active { background: var(--accent); color: #1a1a1a; }

main { padding: 0 16px; max-width: 720px; margin: 0 auto; }

.view { display: none; }
.view.active { display: block; }

/* Grupos */
.group-block { margin-bottom: 22px; }
.group-title {
  font-size: 1rem;
  color: var(--accent);
  border-bottom: 2px solid var(--card-hi);
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.team-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.team-card:active { background: var(--card-hi); }
.team-info { display: flex; align-items: center; gap: 10px; }
.team-code {
  background: var(--accent-2);
  color: #06283d;
  font-weight: 800;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: .8rem;
  min-width: 46px;
  text-align: center;
}
.team-name { font-weight: 600; }
.progress-pill {
  font-size: .8rem;
  color: var(--muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 20px;
}
.progress-pill.complete { color: var(--ok); }

/* Detalhe do time */
.back-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  font-size: 1rem;
  padding: 8px 0;
  margin-bottom: 8px;
}
#team-header h2 { margin: 4px 0; }
#team-header .meta { color: var(--muted); font-size: .9rem; }
.hint { color: var(--muted); font-size: .85rem; line-height: 1.4; }

.stickers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.sticker {
  aspect-ratio: 1;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border: 2px solid transparent;
  background: var(--miss);
  color: #cfd3ec;
  user-select: none;
}
.sticker .num { font-size: 1.2rem; }
.sticker .lbl { font-size: .6rem; opacity: .8; }
.sticker.owned {
  background: var(--ok);
  color: #07351c;
}

/* Scan */
.camera-btn {
  display: block;
  text-align: center;
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
  padding: 16px;
  border-radius: var(--radius);
  margin: 14px 0;
}
.scan-preview { width: 100%; border-radius: var(--radius); margin: 12px 0; }
.scan-status { color: var(--muted); font-size: .9rem; min-height: 20px; }

.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.result-item .left { display: flex; align-items: center; gap: 10px; }
.badge {
  background: var(--accent-2);
  color: #06283d;
  font-weight: 800;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: .75rem;
}
.apply-btn {
  display: block;
  width: 100%;
  background: var(--ok);
  color: #06351c;
  border: none;
  font-weight: 700;
  padding: 14px;
  border-radius: var(--radius);
  margin-top: 12px;
}
.empty { color: var(--muted); text-align: center; padding: 20px; }

/* ---- sessão / topo ---- */
.session {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: .85rem;
  color: var(--muted);
  background: #15182f;
}
.session .sp { flex: 1; }
.link {
  background: none;
  border: none;
  color: var(--accent-2);
  cursor: pointer;
  font-size: .85rem;
  text-decoration: none;
}

/* ---- home ---- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 14px;
}
.cta {
  display: inline-block;
  margin-top: 12px;
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 700;
  border: none;
  padding: 12px 16px;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
}
.owner-banner {
  padding: 10px 0;
  color: var(--muted);
  font-size: .9rem;
}
.guide {
  background: var(--card);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

/* ---- modal de auth ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 360px;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
}
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.auth-tab.active { background: var(--accent); color: #1a1a1a; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--card-hi);
  background: var(--bg);
  color: var(--text);
  font-size: .95rem;
}
.auth-form button {
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent-2);
  color: #06283d;
  font-weight: 700;
  cursor: pointer;
}
.auth-error { color: #ff6b6b; font-size: .85rem; min-height: 18px; margin-top: 10px; }

/* ---- busca dinâmica de seleções ---- */
.team-search {
  width: 100%;
  padding: 12px 14px;
  margin: 4px 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--card-hi);
  background: var(--card);
  color: var(--text);
  font-size: .95rem;
}
.team-search::placeholder { color: var(--muted); }
.team-search:focus {
  outline: none;
  border-color: var(--accent-2);
}

/* ---- aviso de spam no modal de confirmação ---- */
.spam-warning {
  font-size: .82rem;
  color: var(--accent);
  background: rgba(255, 210, 63, .1);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0;
}

/* ---- ações em massa na tela do time ---- */
.team-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0 4px;
}
.bulk-btn {
  flex: 1;
  padding: 11px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
  background: var(--ok);
  color: #06351c;
}
.bulk-btn.active { background: #1f7a44; color: #d6ffe6; }
.bulk-btn.ghost {
  background: var(--card-hi);
  color: var(--muted);
}
