/* ============================================================
   Corrente — Tema escuro "Tinta & Carvão" + tokens compartilhados.
   Carregado em TODAS as páginas, DEPOIS do CSS principal.

   - :root                  → valores-padrão de tokens (modo claro)
   - :root[data-theme=dark] → paleta escura (sobrescreve os tokens)

   O modo claro continua exatamente como era. O escuro só troca fundos,
   texto e alguns acentos; as cores das PEÇAS (vermelho/azul) seguem iguais.
   ============================================================ */

/* ---------- tokens (padrão CLARO) ----------
   Ficam aqui para existirem em todas as páginas (o styles.css, por ex.,
   não definia --line). O styles.css/home.css continuam donos das cores antigas. */
:root {
  --line:          rgba(59, 51, 37, 0.14);
  --cell-hi:       #fff6e0;                 /* realce do grupo (respiros) */
  --card-edge:     rgba(255, 255, 255, 0.35); /* fio claro na borda dos cards */
  --stripe:        rgba(255, 255, 255, 0.28); /* zebra do ranking */
  --topbar-bg:     rgba(240, 232, 210, 0.82); /* fundo da barra superior */
  --modal-overlay: rgba(40, 33, 20, 0.45);    /* fundo atrás dos modais */
  --elo-red:       #7d2820;                 /* linha de elo (vermelho) */
  --elo-blue:      #1d3f5c;                 /* linha de elo (azul) */
  --ink-red:       #9a3327;                 /* TEXTO de acento vermelho */
  --ink-blue:      #244e70;                 /* TEXTO de acento azul */
  --ok:            #3c7a47;                 /* verde de sucesso */
  --avatar-ink:    #f7efda;                 /* letra dos avatares (creme nos 2 temas,
                                               como as peças, que também não mudam) */
}

/* ---------- barra de rolagem da PÁGINA (estilo tinta, claro e escuro) ----------
   Vale em todas as telas. As listas com barra própria (ex.: .rooms) têm regra
   mais específica e continuam com o estilo delas. */
html { scrollbar-width:thin; scrollbar-color:color-mix(in srgb, var(--ink) 26%, transparent) transparent; }
::-webkit-scrollbar { width:12px; height:12px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb {
  background:color-mix(in srgb, var(--ink) 22%, transparent);
  border-radius:10px; border:3px solid transparent; background-clip:padding-box; }
::-webkit-scrollbar-thumb:hover { background:color-mix(in srgb, var(--ink) 40%, transparent); }

/* ---------- TEMA ESCURO ---------- */
:root[data-theme="dark"] {
  --paper:        #15110b;   /* fundo da página (bem escuro) */
  --paper-2:      #1c160e;
  --paper-board:  #2a2317;   /* tabuleiro / casas / painéis (mais claro, p/ destacar) */
  --paper-edge:   #221b11;   /* molduras / cards (emoldura o tabuleiro) */
  --grid:         rgba(236, 227, 207, 0.16);
  --ink:          #ece3cf;   /* texto principal (claro) */
  --ink-soft:     #ab9f82;   /* texto secundário */
  --shadow:       rgba(0, 0, 0, 0.5);

  /* tons "soft" um pouco mais visíveis sobre o escuro */
  --vermelho-soft: rgba(208, 89, 74, 0.20);
  --azul-soft:     rgba(91, 147, 200, 0.20);

  /* tokens compartilhados, versão escura */
  --line:          rgba(236, 227, 207, 0.12);
  --cell-hi:       #3a3120;
  --card-edge:     rgba(255, 255, 255, 0.05);
  --stripe:        rgba(255, 255, 255, 0.04);
  --topbar-bg:     rgba(22, 18, 13, 0.85);
  --modal-overlay: rgba(0, 0, 0, 0.62);
  --elo-red:       #d2675a;
  --elo-blue:      #6fa8d8;
  --ink-red:       #e2796b;
  --ink-blue:      #80b2dd;
  --ok:            #5fae6e;
}

/* textura de papel: no escuro, troca o brilho branco por um leve veludo */
:root[data-theme="dark"] body::before {
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.03), transparent 45%),
    radial-gradient(circle at 80% 85%, rgba(0, 0, 0, 0.28), transparent 55%);
}

/* grade do tabuleiro no escuro (linhas claras) */
:root[data-theme="dark"] .board,
:root[data-theme="dark"] .replay-board {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%209%209'%20preserveAspectRatio='none'%3E%3Cpath%20d='M1%200V9M2%200V9M3%200V9M4%200V9M5%200V9M6%200V9M7%200V9M8%200V9M0%201H9M0%202H9M0%203H9M0%204H9M0%205H9M0%206H9M0%207H9M0%208H9'%20stroke='%23ece3cf'%20stroke-opacity='.16'%20stroke-width='.025'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] .live-board {
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%209%209'%20preserveAspectRatio='none'%3E%3Cpath%20d='M1%200V9M2%200V9M3%200V9M4%200V9M5%200V9M6%200V9M7%200V9M8%200V9M0%201H9M0%202H9M0%203H9M0%204H9M0%205H9M0%206H9M0%207H9M0%208H9'%20stroke='%23ece3cf'%20stroke-opacity='.16'%20stroke-width='.04'/%3E%3C/svg%3E");
}

/* ---------- botão de alternar tema (claro/escuro) ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 999px; flex: none;
  border: none; cursor: pointer; color: var(--ink);
  background: var(--paper-board); box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover { box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.4); }
.theme-toggle svg { display: block; }

/* agrupa o botão de tema com o de conta/voltar, à direita da barra */
.topbar-actions { display: inline-flex; align-items: center; gap: 10px; }

/* ---------- chip de saldo da carteira (topo) ---------- */
.wallet-chip {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none; cursor: pointer;
  background: var(--paper-board); box-shadow: inset 0 0 0 1px var(--line);
  border-radius: 999px; padding: 6px 13px 6px 11px;
  color: var(--ink); font: inherit; font-weight: 700; font-size: 13px;
  transition: box-shadow 0.15s ease, transform 0.08s ease;
}
.wallet-chip:hover { box-shadow: inset 0 0 0 1px rgba(127,127,127,0.4); }
.wallet-chip:active { transform: translateY(1px); }
.wallet-chip .ico-svg { width: 16px; height: 16px; color: var(--vermelho); }
.wallet-chip .wc-bal { font-variant-numeric: tabular-nums; }
/* no celular o topo fica enxuto: carteira (com saldo) + perfil. O botão de
   TEMA sai do header e vai para as Configurações no balão de perfil. */
@media (max-width: 600px) {
  .wallet-chip { padding: 6px 11px 6px 9px; font-size: 12.5px; }
  .topbar-actions .theme-toggle { display: none; }
}

/* ---------- ícones SVG (substituem emojis) ---------- */
.ico-svg { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; flex: none; }
[data-icon] { display: inline-flex; align-items: center; }
/* ícones um pouco maiores nos botões redondos de controle (replay/jogo) */
.rp-btn .ico-svg, #rp-play .ico-svg { width: 1.25em; height: 1.25em; vertical-align: -0.2em; }

/* ---------- divisões (tiers) ---------- */
.tier-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px; padding: 4px 11px 4px 9px; border-radius: 999px;
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; border: none;
  color: var(--tier-color, var(--ink)); background: var(--paper-board);
  box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow 0.15s ease;
}
.tier-badge::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--tier-color, #888); flex: none; }
.tier-badge:hover { box-shadow: inset 0 0 0 1px var(--tier-color, var(--ink-soft)); }

.division-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.division-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  background: var(--paper-board); box-shadow: inset 0 0 0 1px var(--line);
}
.division-row.cur { box-shadow: inset 0 0 0 2px var(--tier-color, var(--ink)); }
.division-row .d-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--tier-color, #888); flex: none; }
.division-row .d-name { flex: 1; font-weight: 700; font-size: 14px; }
.division-row .d-range { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.division-progress .dp-track { height: 9px; border-radius: 999px; background: var(--paper-board); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.division-progress .dp-fill { height: 100%; border-radius: 999px; background: var(--tier-color, var(--ink)); transition: width 0.4s ease; }
.division-progress .dp-text { font-size: 12.5px; color: var(--ink-soft); margin: 8px 0 14px; line-height: 1.5; }

/* ganho/perda de elo no fim da ranqueada */
.elo-delta { font-size: 14px; font-weight: 600; margin: 2px 0 4px; line-height: 1.45; }

/* ---------- partida fantasma da home: mais visível sobre o escuro,
   com a grade em traço CLARO (a escura sumia no fundo) ---------- */
:root[data-theme="dark"] {
  --ghost-op: 0.08;
  --ghost-line: rgba(236, 227, 207, 0.32);
}

/* ---------- transição suave entre as páginas ----------
   Navegadores com suporte (Chrome/Edge) fazem um crossfade ao navegar;
   os demais ignoram esta regra sem nenhum efeito colateral. */
@view-transition { navigation: auto; }

/* ============================================================
   POP-UP DE VITÓRIA (modal de resultado) — FONTE ÚNICA.
   Antes estava DUPLICADO em styles.css (jogo.html) e online.css
   (online.html). Como o theme.css é carregado em TODAS as páginas,
   agora vive aqui só uma vez. A base do avatar (.avatar, tamanhos)
   continua em cada CSS de página porque o tamanho varia.
   A tela "VS" cheia (.vsx) é só do online → segue no online.css.
   ============================================================ */
.result-modal { position: fixed; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--modal-overlay); animation: vsFade .35s ease;
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px); }
.result-card { background: var(--paper-edge); border-radius: 22px; padding: 28px 26px 22px; width: min(94vw, 400px);
  text-align: center; box-shadow: 0 30px 70px -12px rgba(0, 0, 0, .5), inset 0 0 0 1px var(--line);
  animation: vsPop .45s cubic-bezier(.34, 1.4, .6, 1); display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden; }
.result-card::before { content: ""; position: absolute; inset: 9px; border: 1.5px solid var(--line); border-radius: 12px;
  pointer-events: none; opacity: .7; }
/* moldura "a pincel": o traço se DESENHA na cor do vencedor (SVG no HTML) */
.result-card .ink-frame { position: absolute; inset: 9px; width: calc(100% - 18px); height: calc(100% - 18px);
  pointer-events: none; overflow: visible; }
.result-card .ink-frame rect { fill: none; stroke: var(--win-c, var(--ink)); stroke-width: 2;
  vector-effect: non-scaling-stroke; stroke-linecap: round; opacity: .55;
  stroke-dasharray: 100; stroke-dashoffset: 100; animation: inkDraw 1.4s ease-out .4s forwards; }
@keyframes inkDraw { to { stroke-dashoffset: 0; } }
/* respingos de tinta na cor do vencedor, nos cantos do cartão */
.result-card::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(circle at 7% 11%,  var(--win-c, var(--ink)) 0 7px,   transparent 8px),
    radial-gradient(circle at 12% 5%,  var(--win-c, var(--ink)) 0 3px,   transparent 4px),
    radial-gradient(circle at 17% 13%, var(--win-c, var(--ink)) 0 2px,   transparent 3px),
    radial-gradient(circle at 93% 8%,  var(--win-c, var(--ink)) 0 5px,   transparent 6px),
    radial-gradient(circle at 87% 14%, var(--win-c, var(--ink)) 0 2.5px, transparent 3.5px),
    radial-gradient(circle at 5% 90%,  var(--win-c, var(--ink)) 0 4px,   transparent 5px),
    radial-gradient(circle at 95% 89%, var(--win-c, var(--ink)) 0 6px,   transparent 7px),
    radial-gradient(circle at 90% 95%, var(--win-c, var(--ink)) 0 2.5px, transparent 3.5px);
  opacity: 0; animation: splatterIn .7s ease .6s forwards; }
@keyframes splatterIn { from { opacity: 0; transform: scale(.92); } to { opacity: .2; transform: scale(1); } }
@keyframes titleStamp { from { opacity: 0; transform: scale(1.6) rotate(2deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
/* entrada em 2 atos: o título CARIMBA, depois jogadores e botões sobem */
.result-title { font-family: 'Fraunces', Georgia, serif; font-size: 33px; font-weight: 700; letter-spacing: .3px; position: relative;
  animation: titleStamp .5s cubic-bezier(.3, 1.5, .5, 1) .15s both; }
.vs-row { display: flex; align-items: flex-start; justify-content: center; gap: 18px; margin: 18px 0 6px; position: relative;
  animation: riseIn .45s ease .35s both; }
.vs-row .vs-player { position: relative; flex: 1; max-width: 132px; padding-top: 8px;
  display: flex; flex-direction: column; align-items: center; gap: 5px; }
.vs-row .vs-word { flex: none; align-self: center; font-family: 'Fraunces', Georgia, serif; font-weight: 700; font-size: 20px;
  color: var(--ink-soft); letter-spacing: 1px; opacity: .85; }
.vs-row .vs-name { font-weight: 700; font-size: 15px; margin-top: 6px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crown { position: absolute; top: -26px; left: 50%; transform: translateX(-50%); color: #f0b429;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); animation: crownPop .6s cubic-bezier(.2, 1.6, .4, 1) .95s both; }
.crown .ico-svg { width: 37px; height: 37px; }
.vs-player .crown { display: none; }            /* específico p/ vencer o [data-icon] do theme.css */
.vs-player.winner .crown { display: block; }
.result-card .vs-player .avatar { transition: transform .28s ease, box-shadow .28s ease, filter .28s ease; }
.result-card .vs-player.winner .avatar { transform: scale(1.1);
  box-shadow: inset -2px -3px 5px rgba(0, 0, 0, .22), 0 0 0 3px var(--paper-edge), 0 0 0 5px var(--win-c, var(--ink)); }
.result-card .vs-player.winner .vs-name { color: var(--win-c, var(--ink)); }
/* perdedor: MANTÉM a cor da bolinha; ganha um X de tinta riscando por cima */
.vs-player .loser-x { display: none; position: absolute; top: 5px; left: 0; right: 0; height: 62px;
  align-items: center; justify-content: center; line-height: 1; overflow: visible;
  font-family: 'Permanent Marker', system-ui, cursive; font-weight: 400; font-size: 112px;
  color: var(--lose-c, var(--ink)); pointer-events: none; user-select: none; }
/* delta de elo embaixo do nome (online ranqueada): ganho VERDE, perda VERMELHO */
.vs-delta { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; min-height: 16px; letter-spacing: .3px; line-height: 1.2; }
.vs-delta.up { color: var(--ok, #3f9e5c); }
.vs-delta.down { color: var(--vermelho); }
.vs-delta.flat { color: var(--ink-soft); }
.vs-player:not(.winner) .loser-x { display: flex; animation: xStamp .4s cubic-bezier(.3, 1.5, .5, 1) .75s both; }
@keyframes xStamp { from { opacity: 0; transform: scale(1.7) rotate(-11deg); } to { opacity: 1; transform: scale(1) rotate(-5deg); } }
.result-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; position: relative;
  animation: riseIn .45s ease .55s both; }
.result-actions .btn { width: 100%; }
/* a coroa CAI de cima e assenta na cabeça do vencedor */
@keyframes crownPop { from { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(.55) rotate(-14deg); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1) rotate(0); } }
@keyframes vsFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes vsPop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
/* barra de progresso da divisão dentro do pop-up (reusa .division-progress) */
.result-card .division-progress { margin-top: 6px; }
.result-card .division-progress .dp-text { margin: 6px 0 0; }
