/* ============================================================
   COMPONENTES — a biblioteca do app
   ============================================================ */

/* ============ APP BAR ============ */
.appbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--s-3);
  height: var(--appbar-h);
  padding-inline: var(--s-3) var(--gutter);
  background: var(--bg-canvas);
  position: relative; z-index: var(--z-appbar);
}
.appbar__title {
  font-family: var(--ff-display); font-weight: var(--fw-bold);
  font-size: var(--fs-h2); color: var(--text-hi);
}
.appbar--center .appbar__title { flex: 1; text-align: center; }
.appbar--center .appbar__spacer { width: 40px; }
.appbar--float { position: absolute; top: 0; left: 0; right: 0; background: transparent; }

.iconbtn {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--r-full);
  color: var(--text-hi); flex: 0 0 auto;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line-soft);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.iconbtn:active { background: var(--bg-surface-3); border-color: var(--line-strong); }
.iconbtn svg { width: 22px; height: 22px; stroke-width: 2; }

/* ============ BOTÕES ============ */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s-2);
  width: 100%; min-height: 54px;
  padding: 0 var(--s-5);
  border-radius: var(--r-md);
  font-family: var(--ff-display);
  font-size: var(--fs-h3); font-weight: var(--fw-bold);
  letter-spacing: .04em; text-transform: uppercase;
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.btn:active { transform: scale(.975); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .42; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }

/* Primário — o botão dourado da referência */
.btn--primary {
  background: var(--grad-gold-cta);
  color: var(--text-on-gold);
  box-shadow: var(--glow-cta);
}
.btn--primary::after {
  content: ""; position: absolute; inset: 0;
  background: var(--grad-sheen);
  transform: translateX(-120%);
  animation: sheen 4.5s var(--ease) infinite;
  pointer-events: none;
}

.btn--ghost {
  background: transparent;
  color: var(--text-hi);
  border: 1.5px solid var(--line-strong);
}
.btn--ghost:active { background: var(--bg-surface); }

.btn--soft {
  background: var(--bg-surface-2);
  color: var(--text-hi);
  border: 1px solid var(--line-soft);
}

.btn--danger { background: var(--danger-bg); color: var(--danger); border: 1.5px solid var(--danger-border); }
.btn--sm { min-height: 40px; font-size: var(--fs-sm); border-radius: var(--r-sm); padding: 0 var(--s-4); }
.btn--auto { width: auto; }
.btn--link {
  background: none; min-height: 40px; color: var(--gold-300);
  text-transform: none; letter-spacing: 0; font-weight: var(--fw-semi);
}

/* Barra de ação fixada no rodapé da tela */
.actionbar {
  flex: 0 0 auto;
  padding: var(--s-3) var(--gutter) calc(var(--s-4) + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--bg-canvas) 28%);
  display: flex; flex-direction: column; gap: var(--s-2);
}

/* ============ TAB BAR ============
   A barra é o PADRÃO: fica em toda tela onde o jogador ainda está
   navegando. Some só onde ela atrapalharia — onboarding, a arena (que
   tem o próprio rodapé de ação), o resultado e o offline. Sem isso,
   entrar em "Chances" ou "Saque" deixava o app sem saída visível. */
.tabbar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: var(--z-nav);
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: linear-gradient(180deg, rgba(10,7,3,.94), var(--bg-nav));
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
html[data-route="splash"] .tabbar,
html[data-route="age"] .tabbar,
html[data-route="auth"] .tabbar,
html[data-route="signup"] .tabbar,
html[data-route="otp"] .tabbar,
html[data-route="recover"] .tabbar,
html[data-route="game"] .tabbar,
html[data-route="result"] .tabbar,
html[data-route="offline"] .tabbar { display: none; }

.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-mid);
  font-size: var(--fs-micro); font-weight: var(--fw-semi);
  transition: color var(--dur-base) var(--ease);
}
/* o ícone ganha corpo: 24px e traço mais grosso lêem de longe */
.tab svg {
  width: 24px; height: 24px;
  stroke-width: 1.9;
  transition: transform var(--dur-base) var(--ease-back);
}
.tab:active svg { transform: scale(.88); }

/* pílula atrás do ícone ativo: marca a posição sem depender só da cor */
.tab::before {
  content: ""; position: absolute; top: 6px;
  width: 44px; height: 30px; border-radius: var(--r-full);
  background: var(--gold-500); opacity: 0;
  transform: scale(.7);
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease-back);
}
.tab.is-active { color: var(--gold-200); }
.tab.is-active::before { opacity: .14; transform: scale(1); }
.tab.is-active svg { color: var(--gold-300); filter: drop-shadow(0 0 7px rgba(237,185,72,.55)); }
.tab > svg, .tab > span { position: relative; z-index: 1; }

/* ============ CARDS ============ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--sh-card);
}
.card--gold { border-color: var(--line-strong); box-shadow: var(--sh-card), var(--glow-sm); }
.card--flat { box-shadow: none; background: var(--bg-surface-2); }
.card--press { transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.card--press:active { transform: scale(.985); }

/* Banner hero (PRÊMIOS REAIS ATÉ R$ 50.000) */
.banner {
  position: relative; overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--line-strong);
  padding: var(--s-4) var(--s-5);
  text-align: center;
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(237,185,72,.22), transparent 62%),
    linear-gradient(180deg, #1B1408, #0E0A04);
  box-shadow: var(--glow-sm);
}
.banner::before {
  content: ""; position: absolute; inset: -40% -10%;
  background: conic-gradient(from 0deg, transparent 0 78%, rgba(237,185,72,.16) 88%, transparent 100%);
  animation: sweep 9s linear infinite;
  pointer-events: none;
}
/* display:block nos filhos — dentro de um <button> eles são spans e
   fluiriam inline, grudando o "R$ 50.000" no fim da linha do kicker */
.banner > * { position: relative; display: block; }
.banner__kicker {
  display: inline-flex !important; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  letter-spacing: var(--ls-caps); text-transform: uppercase; color: var(--gold-200);
}
.banner__kicker svg { width: 15px; height: 15px; }
.banner__value {
  font-family: var(--ff-display); font-weight: var(--fw-black);
  font-size: 27px; line-height: 1.1; letter-spacing: -.01em; margin-top: 2px;
}

/* ============ PÍLULA DE SALDO ============ */
.wallet-pill {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 36px; padding: 0 4px 0 var(--s-3);
  border-radius: var(--r-full);
  background: var(--bg-surface-2);
  border: 1px solid var(--line-strong);
  font-weight: var(--fw-bold); font-size: var(--fs-sm);
  color: var(--text-hi);
}
.wallet-pill__coin { width: 18px; height: 18px; flex: 0 0 auto; }
.wallet-pill__add {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: var(--r-full);
  background: var(--grad-gold-cta); color: var(--text-on-gold);
}
.wallet-pill__add svg { width: 15px; height: 15px; }

/* ============ BADGES / CHIPS ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: var(--fs-micro); font-weight: var(--fw-bold);
  letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid transparent; white-space: nowrap;
}
.badge--gold   { background: var(--grad-gold-cta); color: var(--text-on-gold); }
.badge--ok     { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.badge--danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge--warn   { background: var(--warn-bg); color: var(--warn); }
.badge--info   { background: var(--info-bg); color: var(--info); }
.badge--mute   { background: var(--bg-surface-3); color: var(--text-mid); }

.chiprow { display: flex; gap: var(--s-2); overflow-x: auto; scrollbar-width: none; padding-block: 2px; }
.chiprow::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  height: 34px; padding: 0 var(--s-4);
  border-radius: var(--r-full);
  background: var(--bg-surface-2);
  border: 1px solid var(--line-soft);
  color: var(--text-mid);
  font-size: var(--fs-sm); font-weight: var(--fw-semi);
  transition: all var(--dur-fast) var(--ease);
}
.chip.is-active {
  background: var(--grad-gold-cta); color: var(--text-on-gold);
  border-color: transparent; box-shadow: var(--glow-sm);
}

/* ============ LISTAS ============ */
.list { display: flex; flex-direction: column; gap: var(--s-2); }

.listrow {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; text-align: left;
  padding: var(--s-3) var(--s-4);
  background: var(--bg-surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  transition: background var(--dur-fast) var(--ease);
}
.listrow:active { background: var(--bg-surface-2); }
.listrow__icon {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: var(--r-sm);
  background: rgba(237,185,72,.1);
  border: 1px solid var(--line);
  color: var(--gold-200);
}
.listrow__icon svg { width: 21px; height: 21px; stroke-width: 1.9; }
.listrow__chev { color: var(--text-low); flex: 0 0 auto; }
.listrow__chev svg { width: 18px; height: 18px; }

/* Linha de menu do perfil */
.menurow {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; text-align: left; padding: var(--s-4) 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
}
.menurow:last-child { border-bottom: 0; }
.menurow > svg:first-child {
  width: 22px; height: 22px; color: var(--gold-200); flex: 0 0 auto; stroke-width: 1.9;
}
.menurow__chev { margin-left: auto; color: var(--text-low); width: 18px; height: 18px; flex: 0 0 auto; }

/* ============ CAMPOS ============ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-mid);
}
.field__box {
  display: flex; align-items: center; gap: var(--s-2);
  min-height: 52px; padding: 0 var(--s-4);
  background: var(--bg-surface);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease);
}
.field__box:focus-within { border-color: var(--gold-500); box-shadow: var(--glow-sm); }
.field__box > svg { width: 19px; height: 19px; color: var(--text-low); flex: 0 0 auto; }
.field input, .field select, .field textarea {
  flex: 1; min-width: 0; background: none; color: var(--text-hi);
  font-size: var(--fs-body); padding: var(--s-3) 0;
}
.field input::placeholder { color: var(--text-low); }
.field__hint { font-size: var(--fs-xs); color: var(--text-low); }
.field__error { font-size: var(--fs-xs); color: var(--danger); }
.field.has-error .field__box { border-color: var(--danger); }

.switch {
  position: relative; flex: 0 0 auto;
  width: 46px; height: 27px; border-radius: var(--r-full);
  background: var(--bg-surface-3); border: 1px solid var(--line-soft);
  transition: background var(--dur-base) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: var(--r-full);
  background: var(--text-mid);
  transition: transform var(--dur-base) var(--ease-back), background var(--dur-base) var(--ease);
}
.switch[aria-checked="true"] { background: var(--gold-600); border-color: transparent; }
.switch[aria-checked="true"]::after { transform: translateX(19px); background: #fff; }

/* ============ SHEET / MODAL ============ */
.scrim {
  position: absolute; inset: 0; z-index: var(--z-sheet);
  background: var(--bg-scrim);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: var(--z-sheet);
  max-height: 86%;
  display: flex; flex-direction: column;
  background: var(--bg-sheet);
  border-top: 1px solid var(--line-strong);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--sh-sheet);
  transform: translateY(101%);
  transition: transform var(--dur-slow) var(--ease-out);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.is-open { transform: translateY(0); }
.sheet__grab {
  width: 38px; height: 4px; border-radius: var(--r-full);
  background: var(--text-low); opacity: .5;
  margin: var(--s-3) auto var(--s-2);
  flex: 0 0 auto;
}
.sheet__head { padding: var(--s-2) var(--gutter) var(--s-3); flex: 0 0 auto; }
.sheet__body { overflow-y: auto; padding: 0 var(--gutter) var(--s-5); scrollbar-width: none; }
.sheet__body::-webkit-scrollbar { display: none; }

/* ============ TOAST ============ */
.toaster {
  position: absolute; top: 58px; left: var(--gutter); right: var(--gutter);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--s-2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--bg-surface-2);
  border: 1px solid var(--line-strong);
  box-shadow: var(--sh-raised);
  font-size: var(--fs-sm); color: var(--text-hi);
  animation: toast-in var(--dur-base) var(--ease-back);
}
.toast svg { width: 19px; height: 19px; flex: 0 0 auto; }
.toast--ok svg { color: var(--ok); }
.toast--err { border-color: var(--danger-border); }
.toast--err svg { color: var(--danger); }
.toast.is-out { animation: toast-out var(--dur-base) var(--ease-in) forwards; }

/* ============ ESTADO VAZIO ============ */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--s-3); padding: var(--s-9) var(--s-6);
}
.empty__art { width: 92px; height: 92px; opacity: .5; color: var(--gold-700); }

/* ============ SKELETON ============ */
.skel {
  background: linear-gradient(90deg, var(--bg-surface) 25%, var(--bg-surface-3) 50%, var(--bg-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--r-sm);
}

/* ============ PROGRESSO ============ */
.meter { height: 7px; border-radius: var(--r-full); background: var(--bg-surface-3); overflow: hidden; }
.meter__fill { height: 100%; border-radius: inherit; background: var(--grad-gold-cta); transition: width var(--dur-slow) var(--ease); }
.meter--danger .meter__fill { background: linear-gradient(90deg, var(--warn), var(--danger)); }

/* ============ CALLOUT ============ */
.callout {
  display: flex; gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  border: 1px solid var(--line);
  font-size: var(--fs-sm); line-height: 1.45;
}
.callout > svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--gold-300); margin-top: 1px; }
.callout--warn { background: var(--warn-bg); border-color: rgba(242,179,61,.28); }
.callout--warn > svg { color: var(--warn); }
.callout--danger { background: var(--danger-bg); border-color: var(--danger-border); }
.callout--danger > svg { color: var(--danger); }
.callout--info { background: var(--info-bg); border-color: rgba(91,184,245,.28); }
.callout--info > svg { color: var(--info); }

/* ============ TABELA (odds) ============ */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left; padding: var(--s-2) var(--s-3);
  font-size: var(--fs-micro); letter-spacing: var(--ls-caps);
  text-transform: uppercase; color: var(--text-mid); font-weight: var(--fw-bold);
  border-bottom: 1px solid var(--line);
}
.table td { padding: var(--s-3); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table td:last-child, .table th:last-child { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.table__wrap { overflow-x: auto; }

/* ============ SEGMENTED ============ */
.segmented {
  display: flex; gap: 3px; padding: 3px;
  background: var(--bg-surface-2); border-radius: var(--r-full);
  border: 1px solid var(--line-soft);
}
.segmented button {
  flex: 1; height: 36px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: var(--fw-semi); color: var(--text-mid);
  transition: all var(--dur-fast) var(--ease);
}
.segmented button.is-active { background: var(--bg-surface-3); color: var(--gold-200); }

/* ============ STEPS (como funciona) ============ */
.step { display: flex; gap: var(--s-4); align-items: center; }
.step__n {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 26px; height: 26px; border-radius: var(--r-full);
  border: 1.5px solid var(--gold-500); color: var(--gold-300);
  font-family: var(--ff-display); font-weight: var(--fw-bold); font-size: var(--fs-sm);
}
.step__art {
  display: grid; place-items: center; flex: 0 0 auto;
  width: 54px; height: 54px; border-radius: var(--r-full);
  background: radial-gradient(circle at 50% 35%, rgba(237,185,72,.18), transparent 70%);
  border: 1px solid var(--line);
}
.step__art svg { width: 28px; height: 28px; color: var(--gold-300); }

/* ============ SELO DE CONFIANÇA (splash) ============ */
.trust { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); }
.trust__item { display: flex; flex-direction: column; align-items: center; gap: 7px; text-align: center; }
.trust__ring {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: var(--r-full);
  border: 1px solid var(--line-strong);
  background: rgba(237,185,72,.05);
}
.trust__ring svg { width: 20px; height: 20px; color: var(--gold-300); }
.trust__label { font-size: var(--fs-micro); line-height: 1.25; color: var(--text-mid); font-weight: var(--fw-semi); }

/* ============================================================
   CONVITE DE INSTALAÇÃO
   Aparece na tela de entrada, e só para quem ainda não instalou.
   Linha única em telas estreitas: a tela de login é curta e qualquer
   bloco alto empurra o botão de entrar para fora da dobra — que é
   justamente o botão que a pessoa veio apertar.
   ============================================================ */
.instalar-convite {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-5);
  margin: var(--s-5) 0 0;
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-surface-2);
  /* Um fio dourado à esquerda liga o bloco à marca sem pintar o
     fundo inteiro e competir com o formulário. */
  box-shadow: inset 3px 0 0 0 var(--gold-500), var(--sh-card);
}

.instalar-icone {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--r-full);
  color: var(--gold-300);
  background: var(--gold-900);
  border: 1px solid var(--gold-700);
}

.instalar-texto { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.instalar-texto strong {
  font: var(--fw-bold) var(--fs-sm)/1.2 var(--ff-body);
  color: var(--text-hi);
}
.instalar-texto span {
  font: var(--fw-reg) var(--fs-xs)/1.35 var(--ff-body);
  color: var(--text-mid);
}

/* O × não rouba foco na navegação por teclado: a ação principal é
   instalar, e dispensar fica por último na ordem natural do DOM. */
.instalar-fechar {
  position: absolute;
  top: 4px; right: 4px;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-full);
  background: transparent;
  color: var(--text-low);
  font-size: 18px; line-height: 1;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.instalar-fechar:hover { color: var(--text); background: var(--bg-surface-3); }

/* No iOS não há botão, então o texto é a instrução inteira e ganha
   o espaço que o botão ocupava. */
.instalar-ios .instalar-texto span { color: var(--text); }

@media (max-width: 380px) {
  /* Em tela bem estreita o botão desce: três colunas a 360px fazem
     o texto quebrar em quatro linhas e o bloco fica mais alto do que
     se empilhar de propósito. */
  .instalar-convite { flex-wrap: wrap; }
  .instalar-convite .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .instalar-fechar { transition: none; }
}

/* O botão do convite é compacto: a altura padrão do .btn--primary é
   de alvo de toque principal (48px) e aqui ele é ação secundária
   numa linha de 38px. */
.instalar-btn {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 var(--s-5);
  font-size: var(--fs-xs);
  width: auto;
}
