/* Rivalwords — telas do jogo. Mesmo sistema da página inicial (DESIGN.md, referência PlayStation):
   faixas preto, branco e azul #0070d1, botões em pílula, cartões com raio de 8 px, campos com 4 px,
   Sora nos títulos e Figtree no texto. A partida fica sempre no fundo preto. */
:root {
  color-scheme: light dark;
  --font-display: "Sora", system-ui, sans-serif;
  --font-text: "Figtree", system-ui, sans-serif;
  --font-mono: "Martian Mono", ui-monospace, Menlo, Consolas, monospace;

  --accent: #0070d1;
  --accent-pressed: #0064b7;
  --accent-active: #004d8d;
  --on-accent: #ffffff;
  --commerce: #d53b00;
  --commerce-pressed: #aa2f00;
  --gold: #ffce21;

  --r-sm: 4px;
  --r-md: 8px;
  --r-full: 9999px;

  --bg: #ffffff;
  --surface: #f5f7fa;
  --field: #ffffff;
  --track: #e6e9ee;
  --text: #000000;
  --muted: #6b6b6b;
  --border: #e1e4e8;
  --field-border: #b8bcc2;
  --link: #0064b7;
  --pos: #1a7f53;
  --neg: #c81b3a;
  --disabled-bg: #f3f3f3;
  --disabled-text: #a3a3a3;

  --correct: #1e8456;
  --present: #e0b43a;
  --on-present: #000000;
  --absent: #6b6b6b;
  --tile-empty: #ffffff;
  --tile-line: #d3d6da;
  --tile-filled: #6b6b6b;
  --key: #e3e6ea;
  --key-absent: #c4c8cd;
  --key-absent-text: #4a4a4a;
  --warn-bg: #fff4d6;
  --warn-text: #5c4700;
}

/* Fundo preto: o tema escuro do aparelho e, sempre, a tela da partida. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #181818;
    --field: #121314;
    --track: #121314;
    --text: #ffffff;
    --muted: #a0a0a0;
    --border: rgba(229, 229, 229, .2);
    --field-border: rgba(229, 229, 229, .35);
    --link: #53b1ff;
    --pos: #3ccf8e;
    --neg: #ff6b81;
    --disabled-bg: #1f2024;
    --disabled-text: #6b6b6b;
    --absent: #3a3c42;
    --tile-empty: #000000;
    --tile-line: #3a3c42;
    --tile-filled: #8a8a8a;
    --key: #2b2d33;
    --key-absent: #161719;
    --key-absent-text: #8a8a8a;
    --warn-bg: #3a3218;
    --warn-text: #f1d78a;
  }
}
body[data-view="game"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #181818;
  --field: #121314;
  --track: #121314;
  --text: #ffffff;
  --muted: #a0a0a0;
  --border: rgba(229, 229, 229, .2);
  --field-border: rgba(229, 229, 229, .35);
  --link: #53b1ff;
  --pos: #3ccf8e;
  --neg: #ff6b81;
  --disabled-bg: #1f2024;
  --disabled-text: #6b6b6b;
  --absent: #3a3c42;
  --tile-empty: #000000;
  --tile-line: #3a3c42;
  --tile-filled: #8a8a8a;
  --key: #2b2d33;
  --key-absent: #161719;
  --key-absent-text: #8a8a8a;
  --warn-bg: #3a3218;
  --warn-text: #f1d78a;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 400 16px/1.5 var(--font-text);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

h1, h2 { font-family: var(--font-display); letter-spacing: -0.02em; }
h1 { font-size: clamp(32px, 4.2vw, 48px); font-weight: 300; line-height: 1.1; margin: 0; }
h2 { font-size: 22px; font-weight: 400; line-height: 1.25; margin: 0 0 16px; }
.muted { color: var(--muted); }
small.muted { display: block; margin-top: 12px; font-size: 14px; line-height: 1.45; }
a { color: var(--link); }

/* ---------- Botões ---------- */
button, input { font: inherit; color: inherit; }
button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  padding: 10px 22px;
  border: 1.5px solid var(--text);
  border-radius: var(--r-full);
  background: transparent;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .02em;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
button:hover:not(:disabled) { background: var(--track); }
button:active:not(:disabled) { transform: scale(.98); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { background: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--disabled-text); cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); min-height: 48px; font-size: 16px; }
button.primary:hover:not(:disabled) { background: var(--accent-pressed); border-color: var(--accent-pressed); }
button.primary:active:not(:disabled) { background: var(--accent-active); border-color: var(--accent-active); }
button.primary:disabled { background: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--disabled-text); }
button.link {
  min-height: 0; border: none; background: none; padding: 6px 8px;
  color: var(--link); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
button.link:hover:not(:disabled) { background: none; color: var(--text); }

/* ---------- Campos ---------- */
input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid var(--field-border);
  border-radius: var(--r-sm);
  background: var(--field);
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
label { display: block; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
label input { margin-top: 6px; font-weight: 400; font-size: 16px; }

/* ---------- Barra do topo: faixa preta ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 8px 24px;
  background: #000000;
  color: #ffffff;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: inherit; text-decoration: none;
  font: 600 18px/1 var(--font-display); letter-spacing: -0.02em;
}
.brand .mark {
  width: 22px; height: 22px; flex: none; background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.5 21.5V12a9.5 9.5 0 0 1 19 0v9.5h-6V12a3.5 3.5 0 0 0-7 0v9.5z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M2.5 21.5V12a9.5 9.5 0 0 1 19 0v9.5h-6V12a3.5 3.5 0 0 0-7 0v9.5z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.pill {
  font: 600 11px/1 var(--font-text);
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--r-full);
  padding: 5px 10px;
}
.account { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; font-size: 15px; }
.acc-name { display: inline-block; vertical-align: bottom; font-weight: 700; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-stat { font-variant-numeric: tabular-nums; }
.acc-stat small { color: #cccccc; font-size: 13px; }
.topbar button.link { color: #ffffff; }
.topbar button.link:hover { color: #cccccc; }

main { max-width: 1240px; margin: 0 auto; padding: 32px 24px 48px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Cartões ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 24px;
  margin-bottom: 24px;
}
.warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-radius: var(--r-sm);
  padding: 12px 16px;
  font-size: 14px;
  margin: 20px 0 0;
}

/* ---------- Login: faixa azul e formulário ---------- */
.auth {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  max-width: 920px;
  margin: 24px auto 0;
}
.auth .card { margin: 0; }
.auth-band {
  display: flex; flex-direction: column; justify-content: center; gap: 20px;
  padding: 48px 40px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--on-accent);
}
.auth-band p { margin: 0; font-size: 18px; max-width: 32ch; }
.demo-row { --tile: 52px; grid-template-columns: repeat(5, var(--tile)); margin-top: 8px; }
.demo-row .tile { border: none; }
.demo-row .tile.absent { background: #00325e; }
.auth-card .tabs { margin-top: 0; }
.auth-card button.primary { width: 100%; margin-top: 4px; }

/* ---------- Lobby ---------- */

/* Abas: pílulas num trilho, como os filtros do DESIGN.md. */
.tabs {
  display: flex; gap: 4px; padding: 4px; margin: 0 0 16px;
  background: var(--track);
  border-radius: var(--r-full);
}
.tab {
  flex: 1;
  min-height: 36px;
  padding: 6px 14px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 14px;
}
.tab:hover:not(:disabled) { background: none; color: var(--text); }
.tab.active, .tab.active:hover:not(:disabled) { background: var(--field); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.field { margin-bottom: 20px; }
.label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.label b { color: var(--text); }
.seg { display: flex; gap: 4px; padding: 4px; background: var(--track); border-radius: var(--r-full); }
.seg button { flex: 1; min-height: 40px; padding: 6px 10px; border: none; font-size: 14px; color: var(--text); }
.seg button:hover:not(:disabled) { background: var(--field); }
.seg button.active, .seg button.active:hover:not(:disabled) { background: var(--accent); color: var(--on-accent); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.actions button { flex: 1; }
.inline { display: flex; gap: 12px; }
.inline input { flex: 1; min-width: 0; }
.inline button { flex: none; }
.invite { box-shadow: inset 0 0 0 2px var(--accent); }
.invite p { margin: 0; }
.invite .actions { margin-top: 16px; }

table.rank { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.rank th, .rank td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--border); }
.rank th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.rank td:first-child { color: var(--muted); width: 2.5rem; }
.rank td:nth-child(2), .offer p, #r-detail, .g-status, .invite p { overflow-wrap: anywhere; }
.rank tr.me td { font-weight: 700; background: rgba(0, 112, 209, .1); }
.rank .prize {
  display: inline-block; margin-left: 6px; padding: 2px 8px;
  background: var(--gold); color: #000000;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; vertical-align: 1px;
}
#rank-note { font-size: 14px; margin: 0 0 8px; }

/* ---------- Esperando adversário ---------- */
.wait-card { max-width: 480px; margin: 48px auto 24px; padding: 40px 32px; text-align: center; }
.wait-card h2 { font-size: 28px; font-weight: 300; }
.wait-card .inline { margin: 16px 0 24px; }
.code { font: 500 34px/1.2 var(--font-mono); letter-spacing: .2em; margin: 12px 0; }
.spinner {
  width: 40px; height: 40px; margin: 0 auto 20px;
  border: 3px solid var(--track); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Partida ---------- */
.game-head { text-align: center; margin-bottom: 16px; }
.g-round { font: 400 22px/1.25 var(--font-display); letter-spacing: -0.02em; }
#g-meta { font-size: 14px; }
/* Peças do tabuleiro: celular primeiro. O tamanho acompanha a largura e a altura da tela, para o
   tabuleiro, o do adversário (miniatura ao lado) e o teclado caberem juntos sem rolar. */
#view-game {
  --tile: clamp(30px, min(calc((100vw - 150px) / 5), calc((100vh - 410px) / 6)), 52px);
  --mini: clamp(10px, calc(var(--tile) * .3), 22px);
}
@supports (height: 100dvh) {
  #view-game { --tile: clamp(30px, min(calc((100vw - 150px) / 5), calc((100dvh - 410px) / 6)), 52px); }
}
@media (min-width: 700px) { #view-game { --mini: 22px; } }
.boards { display: flex; justify-content: center; align-items: flex-start; gap: clamp(12px, 4vw, 40px); }
.board-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.board-label { font-size: 14px; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.board-wrap.opp { max-width: max(calc(var(--mini) * 5 + 8px), 96px); }
.board-label b { color: var(--text); }
.board-label .pts { white-space: nowrap; }
.board { display: grid; grid-template-rows: repeat(6, 1fr); gap: 5px; }
.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.tile {
  width: var(--tile); height: var(--tile);
  display: flex; align-items: center; justify-content: center;
  font: 600 calc(var(--tile) * .5)/1 var(--font-display);
  text-transform: uppercase;
  border: 2px solid var(--tile-line);
  background: var(--tile-empty);
  border-radius: var(--r-sm);
}
.tile.filled { border-color: var(--tile-filled); }
.tile.correct, .tile.present, .tile.absent { color: #ffffff; border-color: transparent; }
.tile.correct { background: var(--correct); }
.tile.present { background: var(--present); color: var(--on-present); }
.tile.absent { background: var(--absent); }
.board.small .tile { width: var(--mini); height: var(--mini); border-width: 1px; border-radius: 2px; }
.board.small { gap: 2px; }
.board.small .row { gap: 2px; }
.row.shake { animation: shake .35s; }
@keyframes shake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.g-status { text-align: center; min-height: 1.5rem; margin: 16px 0 8px; font-weight: 500; }
.g-status .alert { color: var(--present); }
.history { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; }
.history span { border: 1px solid var(--border); border-radius: var(--r-full); padding: 4px 12px; color: var(--muted); }
.history b { color: var(--text); }

.keyboard { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.krow { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1; min-width: 0; height: clamp(44px, 6.5vh, 56px); min-height: 0; padding: 0;
  border: none; border-radius: var(--r-sm);
  background: var(--key);
  font-size: 15px; font-weight: 700; letter-spacing: 0; text-transform: uppercase;
}
.key:hover:not(:disabled) { background: var(--key); filter: brightness(1.15); }
.key:active:not(:disabled) { transform: scale(.95); }
.key.wide { flex: 1.6; font-size: 12px; letter-spacing: .04em; }
.key.correct, .key.correct:hover:not(:disabled) { background: var(--correct); color: #ffffff; }
.key.present, .key.present:hover:not(:disabled) { background: var(--present); color: var(--on-present); }
.key.absent, .key.absent:hover:not(:disabled) { background: var(--key-absent); color: var(--key-absent-text); }

/* ---------- Resultado ---------- */
.result {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 20;
}
.result-card { max-width: 460px; width: 100%; margin: 0; padding: 32px; text-align: center; box-shadow: 0 0 0 1px var(--border); }
.result-card h2 { font-size: 35px; font-weight: 300; margin-bottom: 8px; }
.result-card button.primary { width: 100%; }
.r-stats { display: flex; justify-content: center; gap: 32px; margin: 24px 0; }
.r-stats div { display: flex; flex-direction: column; gap: 2px; }
.r-stats b { font: 400 28px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.r-stats small { color: var(--muted); font-size: 13px; }
#r-rounds table { width: 100%; font-size: 14px; border-collapse: collapse; margin-bottom: 24px; font-variant-numeric: tabular-nums; }
#r-rounds td, #r-rounds th { padding: 8px 4px; border-bottom: 1px solid var(--border); }
#r-rounds th { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ---------- Anúncio de 10 s ---------- */
.ad {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .75);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 30;
}
.ad-box {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 24px;
  max-width: 400px; width: 100%;
  text-align: center;
}
.ad-box > p { margin: 0 0 20px; }
.ad-tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.ad-brand { font: 300 40px/1.1 var(--font-display); letter-spacing: -0.03em; margin: 16px 0 4px; }
.ad-line { color: var(--muted); }
.ad-link { display: inline-block; margin: 16px 0 24px; color: var(--link); font-weight: 700; }
.ad-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.ad-full { max-width: 440px; }
.ad-hero {
  margin: 16px 0 8px; padding: 40px 16px;
  border-radius: var(--r-sm);
  background: var(--accent); color: var(--on-accent);
}
.ad-hero .ad-brand { margin: 0; }
.ad-hero .ad-line { color: inherit; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 12px 20px; border-radius: var(--r-md);
  font-size: 15px; font-weight: 600; z-index: 40; max-width: 90vw;
}
.toast:empty { padding: 0; }

/* Aposta e contagens que mudam a cada segundo */
.stake-box, #ad-count, #wait-time, .g-status { font-variant-numeric: tabular-nums; }

/* Apostas abertas: o aceite gasta créditos, então usa o laranja de compra do DESIGN.md. */
.offers { box-shadow: inset 0 0 0 2px var(--commerce); }
.offer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.offer:first-child { border-top: none; padding-top: 0; }
.offer p { margin: 0; }
.offer button { white-space: nowrap; }
.offer button.primary { background: var(--commerce); border-color: var(--commerce); }
.offer button.primary:hover:not(:disabled) { background: var(--commerce-pressed); border-color: var(--commerce-pressed); }
.wait-offers { max-width: 480px; margin: 0 auto; text-align: left; }

/* Anúncio fixo: quando visível, a página vira uma coluna — o conteúdo rola acima e o anúncio
   ocupa a própria faixa no rodapé, sem cobrir nada. Em telas largas vira um cartão no canto,
   fora da coluna de conteúdo (que tem no máximo 1040 px). */
body.has-banner { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
body.has-banner .page { flex: 1; min-height: 0; overflow-y: auto; }
.ad-banner {
  flex-shrink: 0;
  min-height: 52px;
  padding: 6px 16px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.ad-banner a { color: var(--text); text-decoration: none; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; justify-content: center; }
.ad-banner a b { font-family: var(--font-display); font-weight: 600; }
.ad-banner a span { color: var(--muted); }
.ad-banner a u { color: var(--link); text-decoration: none; font-weight: 700; }
.ad-banner .ad-tag { font-size: 10px; }
@media (min-width: 1560px) {
  body.has-banner { display: block; height: auto; }
  body.has-banner .page { overflow: visible; }
  .ad-banner {
    position: fixed; right: 16px; bottom: 16px; z-index: 10;
    width: 220px; flex-direction: column; gap: 6px; padding: 16px;
    border: 1px solid var(--border); border-radius: var(--r-md);
  }
  .ad-banner a { flex-direction: column; align-items: center; gap: 2px; }
}

/* ---------- Idioma no topo ---------- */
.top-right { display: flex; align-items: center; gap: 20px; min-width: 0; }
.lang-pick { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: #cccccc; font-size: 14px; font-weight: 600; }
.lang-pick svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.lang-pick select {
  appearance: none; -webkit-appearance: none;
  min-height: 36px; padding: 6px 28px 6px 12px;
  border: 1px solid rgba(229, 229, 229, .35); border-radius: var(--r-full);
  background: #121314 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23cccccc' stroke-width='1.5'/%3E%3C/svg%3E") right 10px center / 12px no-repeat;
  color: #ffffff; font: 700 14px/1 var(--font-text); letter-spacing: .04em; cursor: pointer;
}
.lang-pick select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.lang-pick option { background: #121314; color: #ffffff; }

/* ---------- Login: quem já tem sessão ---------- */
.auth-continue { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-continue p { margin: 0 0 12px; }
.auth-continue p.muted { margin: 16px 0 0; font-size: 14px; }
.auth-continue button.primary { width: 100%; }

/* ---------- Lobby: conta | nova partida | ranking ---------- */
.lobby {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) minmax(0, 380px);
  grid-template-areas: "account match rank";
  gap: 24px;
  align-items: start;
}
.lobby .card { margin: 0; }
.lobby-account { grid-area: account; display: flex; flex-direction: column; gap: 16px; }
.lobby-match { grid-area: match; }
.lobby-rank { grid-area: rank; }

.profile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; min-width: 0; }
.profile-head > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.avatar {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent); color: var(--on-accent);
  font: 600 18px/1 var(--font-display);
}
.p-name { font: 600 18px/1.2 var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crown-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--text); }
.crown-tag .crown { width: 14px; height: 14px; }
.p-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.p-stats div { display: flex; flex-direction: column-reverse; gap: 2px; }
.p-stats dt { font-size: 12px; color: var(--muted); }
.p-stats dd { margin: 0; font: 400 22px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }

/* Conta demo: discreta, sem cartão. */
.demo-box { padding: 0 4px; }
.demo-box h3 { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row span { font-size: 15px; font-weight: 600; }
.switch-row small.muted { display: block; margin: 2px 0 0; font-size: 13px; }
.demo-box > small.muted { margin-top: 10px; font-size: 13px; }
.demo-box button.link { margin-top: 6px; padding: 6px 0; font-size: 14px; }
.switch {
  position: relative; flex: none; width: 48px; min-height: 0; height: 28px; padding: 0;
  border: none; border-radius: var(--r-full); background: var(--field-border);
}
.switch span {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #ffffff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s;
}
.switch[aria-checked="true"], .switch[aria-checked="true"]:hover:not(:disabled) { background: var(--accent); }
.switch[aria-checked="true"] span { transform: translateX(20px); }
.switch:hover:not(:disabled) { background: var(--muted); }
.switch:active:not(:disabled) { transform: none; }

/* Stromgate: uma linha discreta, para todos (assinantes também). */
.sponsor { padding: 0 4px; font-size: 13px; color: var(--muted); text-decoration: none; line-height: 1.4; }
.sponsor b { color: var(--text); font-family: var(--font-display); font-weight: 600; }
.sponsor:hover b { text-decoration: underline; text-underline-offset: 3px; }

/* Nova partida */
.match-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.match-head h2 { margin: 0; }
.lang-chip { font-size: 13px; font-weight: 600; color: var(--muted); }
.stake-box {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; align-items: center; gap: 6px;
  padding: 6px; border-radius: var(--r-md); background: var(--track);
}
.stake-box .step { min-height: 40px; padding: 6px 12px; border: none; background: var(--field); font-size: 14px; }
.stake-box .step:hover:not(:disabled) { background: var(--surface); }
.stake-box .step:disabled { background: transparent; }
.stake-value {
  display: block; text-align: center; color: var(--accent);
  font: 400 28px/1.15 var(--font-display); letter-spacing: -0.02em; white-space: nowrap;
}
.stake-box.is-zero .stake-value { color: var(--text); font-size: 22px; }
.stake-note { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.lobby-match .actions { margin-top: 4px; }
.join { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.join-label { margin-bottom: 8px; }

/* Ranking compacto */
.rank-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rank-head h2 { margin: 0; }
.seg-sm { padding: 3px; }
.seg-sm button { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.lobby-rank .tabs { margin-bottom: 12px; }
.lobby-rank .tab { padding: 6px 8px; font-size: 13px; }
.champion {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px; padding: 12px 14px;
  border-radius: var(--r-md); background: #000000; color: #ffffff;
}
.champion .crown { width: 28px; height: 28px; flex: none; }
.champion div { display: flex; flex-direction: column; min-width: 0; }
.champion small { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); }
.champion b { font: 600 18px/1.25 var(--font-display); overflow-wrap: anywhere; }
.champion .muted { color: #cccccc; font-size: 13px; }
.champion.is-current small { color: #cccccc; }
.crown { fill: var(--gold); stroke: var(--gold); stroke-width: 1.5; stroke-linejoin: round; vertical-align: -2px; }
.rank .crown { width: 16px; height: 16px; margin-right: 4px; }
.rank.compact .x { display: none; }
.rank tr.gap td { padding: 6px 8px; text-align: center; color: var(--muted); border-bottom-style: dashed; }
.rank tr.gap td.muted { text-align: left; font-size: 13px; }
.rank .you { margin-left: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.rank-toggle { display: block; margin: 12px auto 4px; }
.rank-note { margin: 8px 0 0; font-size: 13px; }

/* Teclado do aparelho: campo invisível que recebe o que é digitado */
.type-sink {
  position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; padding: 0; min-height: 0;
  border: 0; opacity: 0; font-size: 16px; pointer-events: none;
}
.game-head { position: relative; }
.device-kb {
  position: absolute; right: 0; top: 0; width: 40px; min-height: 40px; height: 40px; padding: 0;
  display: grid; place-items: center; border: 1px solid var(--border); color: var(--text);
}
.device-kb svg { width: 22px; height: 22px; }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  .lobby { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "match rank" "account rank"; }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; max-width: 520px; }
  .auth-band { padding: 32px; }
}
@media (max-width: 760px) {
  .lobby { grid-template-columns: minmax(0, 1fr); grid-template-areas: "match" "rank" "account"; gap: 16px; }
}

/* ---------- Celular ---------- */
.result-card { max-height: calc(100vh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.result, .ad { overscroll-behavior: contain; }
.keyboard, .key { user-select: none; -webkit-user-select: none; }
.ad-banner { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }

@media (max-width: 600px) {
  .topbar { min-height: 48px; padding: 6px 16px; gap: 8px; flex-wrap: nowrap; }
  .brand { font-size: 16px; white-space: nowrap; gap: 6px; }
  .brand .mark { width: 18px; height: 18px; }
  .top-right { gap: 12px; }
  .lang-pick select { min-height: 32px; padding: 4px 24px 4px 10px; background-position: right 8px center; }
  .stake-box .step { padding: 6px 8px; }
  .stake-value { font-size: 24px; }
  .stake-box.is-zero .stake-value { font-size: 18px; }
  .profile-head { margin-bottom: 12px; }
  .account { gap: 12px; font-size: 13px; flex-wrap: nowrap; white-space: nowrap; }
  .acc-stat small { font-size: 12px; }
  main { padding: 12px 16px 16px; }
  .card { padding: 16px; margin-bottom: 12px; }
  h2 { font-size: 19px; margin-bottom: 12px; }
  .auth { margin-top: 4px; gap: 12px; }
  .auth-band { padding: 24px 20px; gap: 12px; }
  .auth-band h1 { font-size: 28px; }
  .auth-band p { font-size: 16px; }
  .demo-row { --tile: 34px; margin-top: 4px; }
  .field { margin-bottom: 16px; }
  .seg button { padding: 6px 4px; }
  .actions button { padding: 10px 12px; }
  .offer { flex-direction: column; align-items: stretch; gap: 8px; }
  #sub-status, #rank-note { font-size: 14px; }
  .rank { font-size: 14px; }
  .rank th, .rank td { padding: 10px 6px; }
  .wait-card { margin-top: 16px; padding: 28px 20px; }
  .game-head { margin-bottom: 8px; }
  .g-round { font-size: 18px; }
  #g-meta { font-size: 13px; }
  .board-label { font-size: 12px; }
  .g-status { margin: 8px 0 6px; font-size: 15px; }
  /* Placar das rodadas numa linha só, rolando de lado. */
  .history { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; margin-bottom: 8px; padding-bottom: 2px; }
  .history span { white-space: nowrap; flex-shrink: 0; }
  .keyboard { gap: 5px; }
  .krow { gap: 4px; }
  .result-card { padding: 24px 20px; }
  .result-card h2 { font-size: 28px; }
  .r-stats { gap: 20px; margin: 16px 0; }
  .r-stats b { font-size: 22px; }
  #r-rounds table { font-size: 13px; }
  .ad-banner { min-height: 44px; font-size: 13px; gap: 8px; }
  .ad-banner a { gap: 6px; }
  .ad-box { padding: 20px; }
}
@media (max-width: 480px) {
  .brand .pill { display: none; }
}
@media (max-width: 420px) {
  .account { gap: 10px; }
  .lang-pick svg { display: none; }
  .account .streak, .acc-name { display: none; }
  .ad-tagline { display: none; }
  /* Coluna "Partidas" sai em telas bem estreitas. */
  .rank th:nth-child(4), .rank td:nth-child(4) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .row.shake { animation: none; }
  .spinner { animation-duration: 3s; }
}
