/* ---------- Tokens ---------- */
:root {
  --vermelho: #9b1c23;      /* copas, ouros, "Isso é" */
  --tinta: #111;            /* espadas, paus, borda */
  --papel: #fff;
  --bom: #1e6b3c;
  --ruim: #9b1c23;

  --bg: #efe9df;
  --fg: #1d1b18;
  --muted: #5e584f;
  --linha: #d6cec1;
  --painel: #fff;
  --acento: #9b1c23;
  --chip-bg: #fff;
  --chip-on-bg: #1d1b18;
  --chip-on-fg: #fff;
  --veu: rgba(18, 14, 10, .86);
  --sombra: 0 1px 2px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.08);
  --mesa-luz: #fbf6ec;      /* centro iluminado da mesa */
  --mesa-meio: #ece2d1;
  --mesa-borda: #d3c3a9;    /* vinheta nas bordas */
  --chao: rgba(80, 52, 24, .30);

  --fonte: "Carlito", "Calibri", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a18; --fg: #eeeae3; --muted: #aaa397; --linha: #3a3732;
    --painel: #262421; --acento: #e3737a;
    --chip-bg: #262421; --chip-on-bg: #eeeae3; --chip-on-fg: #1b1a18;
    --veu: rgba(0, 0, 0, .82);
    --sombra: 0 1px 2px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.35);
    --mesa-luz: #34302a; --mesa-meio: #24211d; --mesa-borda: #141311; --chao: rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1a18; --fg: #eeeae3; --muted: #aaa397; --linha: #3a3732;
  --painel: #262421; --acento: #e3737a;
  --chip-bg: #262421; --chip-on-bg: #eeeae3; --chip-on-fg: #1b1a18;
  --veu: rgba(0, 0, 0, .82);
  --sombra: 0 1px 2px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.35);
  --mesa-luz: #34302a; --mesa-meio: #24211d; --mesa-borda: #141311; --chao: rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--fonte);
  font-size: 1rem;
  line-height: 1.5;
}
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--painel); color: var(--fg); padding: 8px 12px; border-radius: 8px; }
.skip:focus { top: 8px; }
a { color: var(--acento); }
:focus-visible { outline: 3px solid var(--acento); outline-offset: 3px; }
main:focus { outline: none; }
.muted { color: var(--muted); }

/* ---------- Botões ---------- */
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  min-height: 44px; padding: 10px 18px; border-radius: 999px;
  border: 2px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; transition: transform .15s ease, background-color .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--fg); }
.btn-ghost:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.btn-primario { background: var(--fg); color: var(--bg); }
.btn-pequeno { min-height: 40px; padding: 6px 14px; font-size: .92rem; gap: 6px; }
.btn-pequeno svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- Cabeçalho (compacto, para o leque ter espaço) ---------- */
.top { position: relative; z-index: 5; padding: 12px 0 0; }
.title { margin: 0; font-size: clamp(1.45rem, 5.6vw, 2.3rem); line-height: 1.1; letter-spacing: -.01em; }
.isso { color: var(--acento); }
.lead {
  margin: 2px 0 10px; color: var(--muted); font-size: .92rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toolbar { display: flex; align-items: center; gap: 8px; }
.progress { display: grid; gap: 4px; flex: 1 1 auto; min-width: 0; max-width: 360px; margin-right: auto; font-size: .92rem; }
.progress .bar { display: block; height: 5px; border-radius: 3px; background: var(--linha); overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--acento); transition: width .3s ease; }
#btn-filtros { max-width: 46vw; }
#btn-filtros span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-filtros.ativo { background: var(--fg); color: var(--bg); }

/* Painel de filtros: flutua sobre a mesa, sem empurrar o leque */
.painel-filtros {
  position: absolute; left: 16px; right: 16px; top: calc(100% + 6px);
  max-width: 1148px; margin: 0 auto;
  background: var(--painel); border: 1px solid var(--linha); border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 12px;
}
.painel-filtros[hidden] { display: none; }
.filtros { display: flex; flex-wrap: wrap; gap: 8px; max-height: 50vh; overflow-y: auto; }
.chip {
  flex: 0 0 auto; font: inherit; font-size: .9rem; cursor: pointer;
  min-height: 36px; padding: 6px 14px; border-radius: 999px;
  background: var(--chip-bg); color: var(--fg); border: 1px solid var(--linha);
}
.chip[aria-pressed="true"] { background: var(--chip-on-bg); color: var(--chip-on-fg); border-color: var(--chip-on-bg); }
.chip .n { opacity: .65; margin-left: 4px; }

/* ---------- Mesa: leque na mão ---------- */
.tela {
  min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column;
  /* mesa iluminada de cima: centro claro atrás do leque, bordas escurecidas */
  background:
    radial-gradient(ellipse 90% 70% at 50% 62%, var(--mesa-luz) 0%, var(--mesa-meio) 55%, var(--mesa-borda) 100%);
}
.mesa { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 460px; }
.leque { position: relative; flex: 1 1 auto; min-height: 420px; }
.leque-palco {
  position: absolute; inset: 0; overflow: hidden;
  touch-action: pan-y; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.cartas { position: absolute; inset: 0; z-index: 1; perspective: 1100px; perspective-origin: 50% 70%; }
/* sombra de contato difusa sob o leque e a mão */
.chao {
  position: absolute; left: 50%; bottom: calc(var(--base, 90px) * 0.2);
  width: calc(var(--cw, 200px) * 4.2); height: calc(var(--ch, 280px) * 0.9);
  margin-left: calc(var(--cw, 200px) * -2.1);
  background: radial-gradient(ellipse 50% 50% at 50% 60%, var(--chao), transparent 70%);
  pointer-events: none;
}

.braco {
  position: absolute; left: 50%; bottom: var(--base);
  width: var(--cw); height: var(--ch); margin-left: calc(var(--cw) / -2);
  transform-origin: 50% calc(100% + var(--raio));
  transform-style: preserve-3d;
  will-change: transform;
}
.mini {
  all: unset; box-sizing: border-box; display: block; position: relative;
  width: 100%; height: 100%; cursor: pointer;
  border-radius: 8%/5.7%;
  transform-origin: 50% 100%;
  will-change: transform;
}
.arrastando .mini { cursor: grabbing; }
.mini:focus-visible { outline: 3px solid var(--acento); outline-offset: 5px; }
.mini .palco-mini { container-type: inline-size; position: absolute; inset: 0; }
.mini .face { box-shadow: 0 1px 1px rgba(60,40,20,.10), 0 6px 18px rgba(60,40,20,.14); }
.sombra-oferta {
  position: absolute; inset: 0; border-radius: inherit; opacity: 0; pointer-events: none;
  box-shadow: 0 30px 50px rgba(50,30,10,.30), 0 10px 18px rgba(50,30,10,.16);
}
.mini.vista .face::after {
  content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.4); border-radius: inherit;
}
.mini.voando { visibility: hidden; }

/* A mão: imagem de fundo (palma e dedos) atrás e polegar na frente das cartas.
   As duas imagens têm o mesmo enquadramento e giram juntas pelo pulso. */
.mao {
  position: absolute; left: 50%; bottom: 0;
  width: calc(var(--cw) * 1.9); height: auto; margin-left: calc(var(--cw) * -0.95);
  transform-origin: 50% 100%;
  pointer-events: none; will-change: transform;
}
.mao-fundo { z-index: 0; }
.mao-polegar { z-index: 2; }
.mao:not([src]) { visibility: hidden; }

/* Controles sob o leque: setas só com mouse; no toque, o arrasto basta */
.controles { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 6px 16px 14px; }
.seta {
  flex: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--linha); background: var(--painel); color: var(--fg);
  display: grid; place-items: center; box-shadow: var(--sombra);
}
.seta[disabled] { opacity: .35; cursor: default; }
.seta svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.dica { margin: 0; text-align: center; color: var(--muted); font-size: .88rem; }
.dica-toque { display: none; }
.posicao { flex: none; font-variant-numeric: tabular-nums; font-weight: 700; font-size: .88rem; color: var(--fg);
  padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--fg) 8%, transparent); }
.posicao[hidden] { display: none; }
@media (pointer: coarse) {
  .seta { display: none; }
  .dica-toque { display: inline; }
  .dica-mouse { display: none; }
}
.vazio { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 16px; text-align: center; }

.carimbo {
  position: absolute; z-index: 2; left: 50%; top: 82%;
  transform: translate(-50%, -50%) rotate(-12deg);
  padding: 2cqw 5cqw; border: 1.2cqw solid currentColor; border-radius: 3cqw;
  background: rgba(255,255,255,.92);
  font-family: var(--fonte); font-weight: 800; text-align: center; line-height: 1.1;
  white-space: nowrap;
}
.carimbo b { display: block; font-size: 11cqw; letter-spacing: .06em; }
.carimbo small { display: block; font-size: 5.4cqw; font-weight: 700; color: var(--tinta); }
.carimbo.bom { color: var(--bom); }
.carimbo.ruim { color: var(--ruim); }


/* ---------- Carta ---------- */
.face {
  position: absolute; inset: 0;
  background: var(--papel); color: var(--tinta);
  border: 1.3cqw solid var(--tinta); border-radius: 8cqw;
  font-family: var(--fonte);
  overflow: hidden;
}
.copas, .ouros { --naipe: var(--vermelho); }
.espadas, .paus { --naipe: var(--tinta); }

.canto {
  position: absolute; top: 4cqw; left: 5cqw; width: 14cqw;
  display: flex; flex-direction: column; align-items: center;
  color: var(--naipe); line-height: 1;
}
.canto .rank { font-size: 13cqw; letter-spacing: -.04em; }
.canto svg { width: 10.5cqw; height: 10.5cqw; margin-top: 1.2cqw; fill: currentColor; }
.canto.inv { top: auto; left: auto; bottom: 4cqw; right: 5cqw; transform: rotate(180deg); }

.frente .corpo {
  position: absolute; inset: 22cqw 9cqw 9cqw;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.pergunta { margin: 0; font-size: 7.4cqw; line-height: 1.3; }
.pergunta .isso { color: var(--vermelho); }
.frase { margin: auto 0; font-size: 7.6cqw; line-height: 1.3; text-wrap: balance; }
.frase.m { font-size: 6.9cqw; }
.frase.l { font-size: 6.2cqw; }
.tag { margin: 0; font-size: 5.4cqw; padding: 0 6cqw; }

.verso .corpo {
  position: absolute; inset: 20cqw 8cqw;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4cqw;
}
.verso .politico { margin: 0; color: var(--vermelho); font-weight: 800; font-size: 11cqw; line-height: 1.15; letter-spacing: .01em; }
.verso .resposta { margin: 0; font-size: 5.6cqw; color: #444; }
.verso .resposta b { text-transform: uppercase; }
.verso .resposta b.bom { color: var(--bom); }
.verso .resposta b.ruim { color: var(--ruim); }
.verso .frase-curta { margin: 0; font-size: 5cqw; color: #555; line-height: 1.3; }

/* ---------- Camadas (modais) ---------- */
html.travado { overflow: hidden; }
.camada { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; }
.camada[hidden] { display: none; }
.fundo { position: absolute; inset: 0; background: var(--veu); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; transition: opacity .3s ease; }
.camada.aberta .fundo { opacity: 1; }
.dialogo { position: relative; }

.fechar {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 3;
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center;
}
.fechar:hover { background: rgba(255,255,255,.26); }
.fechar svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; fill: none; }

.dialogo-carta {
  --w: min(88vw, 380px, calc((100dvh - 200px) * 5 / 7));
  display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%;
}
.palco {
  width: var(--w); aspect-ratio: 5 / 7;
  container-type: inline-size; perspective: 1600px;
}
.virador {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .75s cubic-bezier(.3, .7, .2, 1);
}
.virador.virada { transform: rotateY(180deg); }
.virador .face {
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
}
.virador .verso { transform: rotateY(180deg); }

.acoes {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
  width: var(--w, 100%); max-width: 100%;
  position: relative; z-index: 1;
  opacity: 0; transition: opacity .25s ease .1s;
}
.camada.aberta .acoes { opacity: 1; }
.acoes .btn { flex: 1 1 140px; min-height: 52px; font-size: 1.1rem; }
.btn-bom { background: var(--bom); color: #fff; }
.btn-ruim { background: var(--ruim); color: #fff; }
.btn-claro { background: #fff; color: #111; }
.btn-contorno-claro { background: rgba(0,0,0,.35); color: #fff; border-color: rgba(255,255,255,.75); }
.acoes .btn[disabled] { opacity: .5; }
.acoes .dica { flex-basis: 100%; margin: 0; text-align: center; color: #ddd; font-size: .9rem; }

/* ---------- Resumo ---------- */
.painel {
  width: min(100%, 480px); max-height: calc(100dvh - 32px); overflow: auto;
  background: var(--painel); color: var(--fg);
  border-radius: 16px; padding: 24px 20px 20px; box-shadow: 0 20px 50px rgba(0,0,0,.4);
  opacity: 0; transform: translateY(12px); transition: opacity .25s ease, transform .25s ease;
}
.camada.aberta .painel { opacity: 1; transform: none; }
.painel .fechar { position: absolute; top: 10px; right: 10px; background: transparent; color: var(--fg); }
.painel .fechar:hover { background: color-mix(in srgb, var(--fg) 10%, transparent); }
.painel h2 { margin: 0 44px 4px 0; font-size: 1.5rem; }
.politico-resumo { margin: 20px 0 0; }
.politico-resumo h3 { margin: 0 0 6px; font-size: 1.05rem; letter-spacing: .02em; }
.empilhada { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--linha); }
.empilhada span { display: block; height: 100%; }
.empilhada .b { background: var(--bom); }
.empilhada .r { background: var(--ruim); }
.legenda { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; padding: 0; list-style: none; font-size: .95rem; }
.legenda li::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.legenda .b::before { background: var(--bom); }
.legenda .r::before { background: var(--ruim); }
.legenda .n::before { background: var(--linha); }
.painel-acoes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.painel-acoes .btn { flex: 1 1 140px; }

/* ---------- Rodapé ---------- */
.rodape { border-top: 1px solid var(--linha); padding: 20px 0 calc(28px + env(safe-area-inset-bottom)); font-size: .95rem; }
.rodape p { margin: 0 0 6px; }
.rodape a { font-weight: 700; }
.rodape .creditos { margin-top: 14px; }

/* ---------- Movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
