/* ===================================================================
   Variáveis — baseadas no style-guide.html validado
=================================================================== */
:root {
  --bg-app:        #0E0F13;
  --bg-surface:    #16181D;
  --border:        #1F2128;
  --green:         #22C55E;
  --green-bg:      #173B27;
  --green-text:    #4ADE80;
  --amber:         #FBBF24;
  --amber-bg:      #3A2A0E;
  --red:           #E24B4A;
  --red-bg:        #3A1414;
  --chip-bg:       #1F222B;
  --chip-text:     #C9CDD6;
  --text-primary:  #F4F5F7;
  --text-secondary:#8B90A0;
  --text-tertiary: #6B7280;
  --gold:          #FBBF24;
  --silver:        #C9CDD6;
  --bronze:        #D88C4E;

  --nav-h:         60px;
  --radius-card:   18px;
  --radius-btn:    12px;
}

/* ===================================================================
   Reset e base
=================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; color: inherit; }
input, textarea { font: inherit; color: inherit; background: none; border: none; outline: none; }

/* ===================================================================
   Layout principal
=================================================================== */
#app {
  min-height: 100svh;
  padding-bottom: calc(var(--nav-h) + 8px);
}

.page-wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* ===================================================================
   Nav inferior
=================================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: color .15s;
}
.nav-item svg { stroke: currentColor; }
.nav-item.active { color: var(--green); }

/* ===================================================================
   Tela de loading
=================================================================== */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100svh;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================================================
   Auth
=================================================================== */
.auth-wrap {
  max-width: 400px;
  margin: 0 auto;
  padding: 48px 20px 32px;
}

.auth-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 28px;
  line-height: 1.2;
}

.auth-title .accent { color: var(--green); }

.auth-form { display: flex; flex-direction: column; gap: 14px; }

/* ===================================================================
   Campos de formulário
=================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.field-hint { font-weight: 400; text-transform: none; letter-spacing: 0; }

.field input,
.field select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color .15s;
}
.field input:focus,
.field select:focus { border-color: var(--green); }

.field input::placeholder { color: var(--text-tertiary); }

.form-error {
  font-size: 12px;
  color: var(--red);
  padding: 6px 10px;
  background: var(--red-bg);
  border-radius: 8px;
}

/* ===================================================================
   Botões
=================================================================== */
.btn-primary {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-btn);
  background: var(--green);
  color: #06210F;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled,
.btn-primary.btn-disabled { opacity: .4; cursor: not-allowed; }

.btn-ghost {
  display: block;
  width: 100%;
  padding: 11px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: border-color .15s;
}
.btn-ghost:hover { border-color: var(--text-secondary); }

.btn-sm {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  width: auto;
}

.wpp-btn { margin-top: 6px; }

/* ===================================================================
   Pills de filtro
=================================================================== */
.filter-pills,
.group-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.pill.active   { background: var(--green); color: #06210F; }
.pill.inactive { background: var(--chip-bg); color: var(--text-secondary); }

.group-pill {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--chip-bg);
  color: var(--chip-text);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background .15s;
}
.group-pill.active { background: var(--green-bg); color: var(--green-text); }

/* ===================================================================
   Badges
=================================================================== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge.total   { background: var(--green-bg); color: var(--green-text); }
.badge.parcial { background: var(--amber-bg); color: var(--amber); }

/* ===================================================================
   Chips
=================================================================== */
.chip {
  display: inline-flex;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 10px;
  flex-wrap: wrap;
}
.chip-row { margin-bottom: 6px; }

/* ===================================================================
   Cards
=================================================================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px;
}

.match-card { margin-bottom: 12px; }

.match-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.match-name {
  font-size: 14px;
  font-weight: 600;
}

/* ===================================================================
   Álbum — grid de tiles
=================================================================== */
.album-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.album-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 8px;
  border: 1px solid;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s;
  user-select: none;
}
.tile:active { transform: scale(.94); }

.tile.falta    { border-color: var(--red);    background: var(--red-bg);    color: #F09595; }
.tile.tenho    { border-color: var(--border); background: var(--bg-surface); color: var(--text-secondary); }
.tile.repetida { border-color: var(--green);  background: var(--green-bg);  color: var(--green-text); }

.tile.mini { width: 28px; height: 28px; padding: 0; font-size: 10px; }

.tile-num { font-size: 13px; }
.tile-qty { font-size: 10px; opacity: .7; }

/* ===================================================================
   Modal de figurinha
=================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 20px 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-num   { font-size: 32px; font-weight: 800; text-align: center; }
.modal-label { font-size: 13px; color: var(--text-secondary); text-align: center; }

.status-pills {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.status-btn {
  flex: 1;
  padding: 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  background: var(--chip-bg);
  color: var(--text-secondary);
  border: 2px solid transparent;
}
.status-btn.active-falta    { background: var(--red-bg);    color: #F09595;             border-color: var(--red); }
.status-btn.active-tenho    { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border); }
.status-btn.active-repetida { background: var(--green-bg); color: var(--green-text);    border-color: var(--green); }

/* Stepper de quantidade */
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}
.step-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--chip-bg);
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
#step-val { font-size: 20px; font-weight: 700; min-width: 32px; text-align: center; }

/* Checkbox row */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--green); }

/* ===================================================================
   Ranking
=================================================================== */
.rank-list { display: flex; flex-direction: column; }

.rank-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}
.rank-row:last-child { border-bottom: none; }

.rank-num {
  width: 24px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--chip-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.rank-info { flex: 1; min-width: 0; }
.rank-name   { font-size: 13px; font-weight: 600; }
.rank-region { font-size: 11px; color: var(--text-secondary); }

.rank-stats { text-align: right; flex-shrink: 0; }
.rank-trocas { font-size: 14px; font-weight: 700; color: var(--green-text); }
.stars { font-size: 11px; color: var(--amber); }

/* ===================================================================
   Utilitários
=================================================================== */
.empty-msg {
  color: var(--text-secondary);
  text-align: center;
  padding: 40px 16px;
  line-height: 1.7;
}

.error-msg {
  color: var(--red);
  background: var(--red-bg);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

[hidden] { display: none !important; }
