/* Brain Rush — quadro de ardósia e giz */
@font-face { font-family: 'Inter'; src: url('../fonts/inter-regular.woff') format('woff'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/inter-semibold.woff') format('woff'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/inter-extrabold.woff') format('woff'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Inter Display'; src: url('../fonts/inter-blackitalic.woff') format('woff'); font-weight: 900; font-style: italic; font-display: swap; }

:root {
  --slate: #1D2D29;
  --slate-deep: #16231F;
  --slate-2: #23362F;
  --slate-3: #2B423B;
  --slate-4: #3A5650;
  --chalk: #F2EFE4;
  --chalk-2: #C9CFC6;
  --chalk-3: #8FA09A;
  --line: rgba(242, 239, 228, .16);
  --line-2: rgba(242, 239, 228, .28);
  --yellow: #FFD45C;
  --yellow-ink: #1D2D29;
  --orange: #FFB067;
  --blue: #8ED1FC;
  --lilac: #C9B6FF;
  --pink: #FF9BB0;
  --green: #A6E59A;
  --red: #FF7B7B;
  --c: var(--yellow);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Inter Display', 'Inter', system-ui, sans-serif;
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tab-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
.board, .ttt, .keyboard, .keypad, .answers { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--slate);
  background-image: url('../img/chalk-noise.png'), radial-gradient(120% 70% at 50% -10%, #284039 0%, var(--slate) 55%, var(--slate-deep) 100%);
  background-attachment: fixed;
  color: var(--chalk);
  font: 400 16px/1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--chalk); text-underline-offset: 3px; text-decoration-color: var(--line-2); }
a:hover { text-decoration-color: var(--chalk); }
img, svg { display: block; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Estrutura ---------- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: linear-gradient(var(--slate) 70%, rgba(29, 45, 41, 0));
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--chalk); margin-right: auto; }
.logo svg { width: 34px; height: 34px; }
.logo-word { font: italic 900 22px/1 var(--display); letter-spacing: -.02em; }
.logo-word b { color: var(--yellow); font-weight: 900; }
.nav-desktop { display: none; gap: 4px; margin-right: 8px; }
main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 4px 16px calc(var(--tab-h) + var(--safe-b) + 28px); overflow-x: clip; }
main.wide { max-width: 1120px; }
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(22, 35, 31, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--chalk-3); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tab svg { width: 26px; height: 26px; }
.tab[aria-current="page"] { color: var(--chalk); }
.tab[aria-current="page"] svg { color: var(--yellow); }
.navlink { padding: 8px 14px; border-radius: 999px; color: var(--chalk-2); text-decoration: none; font-weight: 600; font-size: 15px; }
.navlink[aria-current="page"] { color: var(--slate); background: var(--chalk); }
@media (min-width: 900px) {
  .tabbar { display: none; }
  .nav-desktop { display: flex; }
  main { padding-bottom: 48px; }
  .topbar { padding-left: 28px; padding-right: 28px; }
}

/* ---------- Tipografia ---------- */
.display { font: italic 900 40px/1 var(--display); letter-spacing: -.025em; }
.h1 { font: italic 900 30px/1.05 var(--display); letter-spacing: -.02em; }
.h2 { font: 800 21px/1.2 var(--font); letter-spacing: -.01em; }
.h3 { font: 800 17px/1.3 var(--font); }
.lead { font-size: 17px; color: var(--chalk-2); }
.muted { color: var(--chalk-3); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.big-num { font: italic 900 28px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* ---------- Utilitários ---------- */
.stack { display: flex; flex-direction: column; gap: var(--gap, 12px); }
.row { display: flex; align-items: center; gap: var(--gap, 10px); }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.center { text-align: center; }
.mt { margin-top: 16px; } .mt-lg { margin-top: 28px; } .mb { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ---------- Botões ---------- */
.btn {
  --bg: var(--slate-3); --fg: var(--chalk); --lip: #12201c;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border: 0; border-radius: 14px;
  background: var(--bg); color: var(--fg);
  font-weight: 800; font-size: 16px; text-decoration: none; cursor: pointer;
  box-shadow: 0 4px 0 var(--lip);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--lip); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 0 4px 0 var(--lip); }
.btn svg { width: 20px; height: 20px; }
.btn-primary { --bg: var(--yellow); --fg: var(--yellow-ink); --lip: #B8901F; }
.btn-color { --bg: var(--c); --fg: var(--yellow-ink); --lip: color-mix(in srgb, var(--c) 55%, #000); }
.btn-ghost { --bg: transparent; box-shadow: inset 0 0 0 2px var(--line-2); }
.btn-ghost:active { transform: translateY(1px); box-shadow: inset 0 0 0 2px var(--line-2); }
.btn-danger { --bg: #5A2A2A; --fg: #FFD9D9; --lip: #2E1414; }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  border: 0; background: transparent; color: var(--chalk-2); cursor: pointer;
}
.icon-btn:hover { background: rgba(242, 239, 228, .06); color: var(--chalk); }
.icon-btn svg { width: 24px; height: 24px; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--chalk-2); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-2); cursor: pointer; font-weight: 600; }
.avatar {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  border: 2px solid var(--chalk-2); color: var(--chalk); font: italic 900 17px/1 var(--display); text-decoration: none;
}
.avatar.lg { width: 72px; height: 72px; font-size: 32px; border-width: 3px; }

/* ---------- Painéis, chips, segmentos ---------- */
.panel { background: rgba(43, 66, 59, .55); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.panel.tight { padding: 14px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 6px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line-2);
  background: transparent; color: var(--chalk-2); font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--chalk); color: var(--slate); border-color: var(--chalk); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--slate-deep); border-radius: 14px; }
.seg button { min-height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--chalk-3); font-weight: 700; font-size: 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--slate-3); color: var(--chalk); box-shadow: 0 2px 0 #12201c; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: rgba(242, 239, 228, .08); color: var(--chalk-2); }
.badge.ranked { background: rgba(255, 212, 92, .14); color: var(--yellow); }
.badge svg { width: 14px; height: 14px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--chalk-3); font-size: 13px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- Formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 700; font-size: 14px; color: var(--chalk-2); }
.input {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 12px;
  background: var(--slate-deep); border: 1.5px solid var(--line-2); color: var(--chalk); font-size: 16px;
}
textarea.input { padding: 12px 14px; min-height: 160px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--yellow); }
.input[aria-invalid="true"] { border-color: var(--red); }
.field-error { color: var(--red); font-size: 13px; font-weight: 600; }
.hint { color: var(--chalk-3); font-size: 13px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 52px; }
.pw-wrap .icon-btn { position: absolute; right: 4px; top: 4px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-size: 15px; color: var(--chalk-2); }
.check input { appearance: none; flex: none; width: 24px; height: 24px; margin: 0; border-radius: 7px; border: 2px solid var(--chalk-3); display: grid; place-items: center; cursor: pointer; }
.check input:checked { background: var(--yellow); border-color: var(--yellow); }
.check input:checked::after { content: ''; width: 6px; height: 11px; border: solid var(--yellow-ink); border-width: 0 3px 3px 0; transform: translateY(-1px) rotate(45deg); }
.switch { appearance: none; position: relative; width: 50px; height: 30px; border-radius: 999px; background: var(--slate-4); cursor: pointer; flex: none; margin: 0; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--chalk); transition: transform .15s; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.alert { padding: 12px 14px; border-radius: 12px; background: rgba(255, 123, 123, .12); color: #FFC9C9; font-weight: 600; font-size: 14px; }
.alert.ok { background: rgba(166, 229, 154, .12); color: var(--green); }
.alert.info { background: rgba(142, 209, 252, .1); color: var(--blue); }
.gbtn { min-height: 44px; display: flex; justify-content: center; color-scheme: light; }
/* O botão do Google vem num iframe claro: sem isto, o modo escuro da página pinta-lhe um fundo branco. */
.gbtn iframe { color-scheme: light; background: transparent !important; }

/* ---------- Página inicial ---------- */
.hello { padding: 10px 2px 18px; }
.hello .h1 { font-size: 34px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  min-height: 172px; padding: 16px; border-radius: var(--r-lg);
  background: linear-gradient(160deg, rgba(43, 66, 59, .9), rgba(29, 45, 41, .9));
  border: 1.5px solid color-mix(in srgb, var(--c) 35%, transparent);
  color: var(--chalk); text-decoration: none; overflow: hidden;
  transition: transform .12s ease, border-color .2s;
}
.tile:hover { border-color: var(--c); }
.tile:active { transform: scale(.98); }
.tile-art { width: 88px; height: 70px; color: var(--c); }
.tile-name { font: italic 900 22px/1.05 var(--display); letter-spacing: -.02em; }
.tile-desc { color: var(--chalk-2); font-size: 13.5px; line-height: 1.35; margin-top: 4px; }
.tile-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tile.wide { grid-column: 1 / -1; flex-direction: row; align-items: center; min-height: 128px; }
.tile.wide .tile-art { width: 96px; height: 84px; order: 2; flex: none; }
.tile.wide > div { flex: 1; }
.resume {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 14px; border-radius: var(--r);
  background: var(--yellow); color: var(--yellow-ink); text-decoration: none; font-weight: 800;
}
.resume svg { width: 26px; height: 26px; flex: none; }
.footer-links { display: flex; justify-content: center; gap: 20px; margin-top: 28px; font-size: 13px; }
.footer-links a { color: var(--chalk-3); }
@media (min-width: 1000px) {
  .home { max-width: 1040px; margin: 0 auto; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tile.wide { grid-column: span 2; }
}

/* Desenho a giz */
.chalk-draw path, .chalk-draw line, .chalk-draw circle, .chalk-draw polyline, .chalk-draw rect, .chalk-draw ellipse {
  stroke-dasharray: 1; stroke-dashoffset: 0;
}
.first-load .chalk-draw path, .first-load .chalk-draw line, .first-load .chalk-draw circle, .first-load .chalk-draw polyline, .first-load .chalk-draw rect, .first-load .chalk-draw ellipse {
  animation: draw .9s ease-out both; animation-delay: var(--d, 0s);
}
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

/* ---------- Cabeçalho dos jogos ---------- */
.game-head { display: flex; align-items: center; gap: 6px; margin: 0 -6px 14px; }
.game-head .title { font: italic 900 24px/1 var(--display); letter-spacing: -.02em; color: var(--c); }
.game-head .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.setup-title { margin: 6px 0 14px; }
.option-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  min-height: 92px; padding: 14px; border-radius: var(--r); cursor: pointer;
  background: rgba(43, 66, 59, .6); border: 1.5px solid var(--line); color: var(--chalk);
}
.option strong { font-size: 17px; }
.option span { font-size: 13px; color: var(--chalk-3); }
.option[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--slate-2)); }
.option .level-dots { display: flex; gap: 4px; margin-top: auto; }
.level-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--slate-4); }
.level-dots i.on { background: var(--c); }
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: rgba(22, 35, 31, .7); border-radius: 14px; padding: 8px 10px; text-align: center; }
.stat b { display: block; font: italic 900 22px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--chalk-3); font-weight: 600; }
.timebar { height: 8px; border-radius: 999px; background: var(--slate-deep); overflow: hidden; }
.timebar i { display: block; height: 100%; width: 100%; background: var(--c); transform-origin: left; border-radius: inherit; }
.progress-dots { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.progress-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--slate-4); }
.progress-dots i.ok { background: var(--green); }
.progress-dots i.bad { background: var(--red); }
.progress-dots i.now { background: var(--chalk); }

/* Resultado / resumo */
.summary { text-align: center; padding: 8px 0; }
.summary .score { font: italic 900 64px/1 var(--display); color: var(--c); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.mistakes { text-align: left; }
.mistake { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mistake:last-child { border-bottom: 0; }
.mistake img { width: 54px; height: 36px; object-fit: cover; border-radius: 4px; background: var(--slate-deep); }

/* ---------- Matemática ---------- */
.math-q { text-align: center; padding: 18px 0 8px; }
.math-expr { font: italic 900 52px/1.1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.math-ans { margin: 14px auto 0; min-height: 66px; max-width: 280px; display: grid; place-items: center; border-radius: 16px; border: 2px dashed var(--line-2); font: italic 900 42px/1 var(--display); font-variant-numeric: tabular-nums; color: var(--yellow); }
.math-ans.ok { border-color: var(--green); color: var(--green); border-style: solid; }
.math-ans.bad { border-color: var(--red); color: var(--red); border-style: solid; animation: shake .35s; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 360px; margin: 18px auto 0; }
.key {
  min-height: 60px; border: 0; border-radius: 14px; background: var(--slate-3); color: var(--chalk);
  font: 800 24px/1 var(--font); cursor: pointer; box-shadow: 0 4px 0 #12201c; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 #12201c; }
.key.ok { background: var(--yellow); color: var(--yellow-ink); box-shadow: 0 4px 0 #B8901F; }
.key.fn { background: var(--slate-2); font-size: 18px; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Bandeiras ---------- */
.flag-card { display: grid; place-items: center; aspect-ratio: 3 / 2; max-width: 420px; margin: 8px auto 16px; border-radius: 16px; background: var(--slate-deep); overflow: hidden; border: 1.5px solid var(--line); }
.flag-card img { width: 100%; height: 100%; object-fit: contain; }
.flag-emoji { font-size: clamp(90px, 36vw, 200px); line-height: 1; }
.mistake .flag-emoji { font-size: 34px; }
.flag-missing { padding: 20px; text-align: center; color: var(--chalk-3); }
.answers { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .answers { grid-template-columns: 1fr 1fr; } }
.answer {
  min-height: 58px; padding: 10px 16px; border-radius: 14px; border: 0; cursor: pointer; text-align: left;
  background: var(--slate-3); color: var(--chalk); font-weight: 700; font-size: 17px; box-shadow: 0 4px 0 #12201c;
}
.answer:active { transform: translateY(3px); box-shadow: 0 1px 0 #12201c; }
.answer.ok { background: var(--green); color: #12301B; box-shadow: 0 4px 0 #5E9B54; }
.answer.bad { background: var(--red); color: #3A0E0E; box-shadow: 0 4px 0 #A54848; animation: shake .35s; }
.answer:disabled { cursor: default; }

/* ---------- Forca ---------- */
.gallows { width: min(230px, 56vw, 30dvh); margin: 0 auto; color: var(--chalk); }
.gallows .part { stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset .5s ease-out; }
.gallows .part.on { stroke-dashoffset: 0; }
.gallows .face { opacity: 0; transition: opacity .3s .3s; }
.gallows .face.on { opacity: 1; }
.word { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 18px; margin: 16px 0 10px; }
.word-part { display: flex; gap: 6px; }
.slot { width: 28px; height: 40px; display: grid; place-items: end center; border-bottom: 3px solid var(--chalk-2); font: italic 900 27px/1 var(--display); padding-bottom: 3px; }
.slot.sym { border-bottom-color: transparent; }
.slot.reveal { color: var(--red); }
.slot.pop { animation: pop .3s ease-out; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
.wrong-letters { min-height: 24px; text-align: center; color: var(--red); font-weight: 800; letter-spacing: .3em; }
.keyboard { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.kb-row { display: flex; justify-content: center; gap: 5px; }
.kb {
  flex: 1; max-width: 46px; min-height: 52px; border: 0; border-radius: 10px; background: var(--slate-3); color: var(--chalk);
  font: 800 18px/1 var(--font); cursor: pointer; box-shadow: 0 3px 0 #12201c; touch-action: manipulation; padding: 0;
}
.kb:active { transform: translateY(2px); box-shadow: 0 1px 0 #12201c; }
.kb.hit { background: var(--green); color: #12301B; box-shadow: 0 3px 0 #5E9B54; }
.kb.miss { background: transparent; color: var(--chalk-3); box-shadow: inset 0 0 0 1.5px var(--line); text-decoration: line-through; }
.kb:disabled { cursor: default; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

/* ---------- Jogo do galo ---------- */
.ttt { position: relative; width: min(360px, 86vw); aspect-ratio: 1; margin: 6px auto 0; }
.ttt svg.grid { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--chalk); pointer-events: none; }
.ttt .cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
.ttt .cell { position: relative; min-width: 0; min-height: 0; border: 0; background: transparent; padding: 0; cursor: pointer; touch-action: manipulation; }
.ttt .cell:disabled { cursor: default; }
.ttt .cell svg { position: absolute; inset: 14%; width: 72%; height: 72%; overflow: visible; pointer-events: none; }
.ttt .mark-x { color: var(--blue); }
.ttt .mark-o { color: var(--yellow); }
.ttt .mark path, .ttt .mark circle, .ttt svg.winline line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .35s ease-out forwards; }
.ttt .mark path:nth-child(2) { animation-delay: .15s; }
.ttt svg.winline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; color: var(--chalk); }
.scoreline { display: flex; justify-content: center; gap: 22px; margin: 4px 0 2px; }
.scoreline div { text-align: center; }
.scoreline b { display: block; font: italic 900 30px/1 var(--display); font-variant-numeric: tabular-nums; }
.scoreline span { font-size: 12px; color: var(--chalk-3); font-weight: 700; }
.status-line { text-align: center; min-height: 26px; font-weight: 700; color: var(--chalk-2); margin: 12px 0; }

/* ---------- Tabuleiros (xadrez e damas) ---------- */
.bg-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.bg-layout > * { min-width: 0; }
@media (min-width: 960px) {
  .bg-layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .bg-side { position: sticky; top: 80px; }
}
.board-wrap { width: 100%; max-width: min(640px, calc(100dvh - 250px)); min-width: 280px; margin: 0 auto; }
.board {
  --light: #E8E2CF; --dark: #6F8F83;
  position: relative; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); aspect-ratio: 1;
  border-radius: 10px; overflow: hidden; touch-action: manipulation; touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: 0 0 0 3px var(--slate-deep), 0 0 0 5px var(--line-2);
}
.board.checkers { --light: #E8E2CF; --dark: #7A6A58; }
.sq { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; }
.sq.light { background: var(--light); }
.sq.dark { background: var(--dark); }
.sq.last::before { content: ''; position: absolute; inset: 0; background: rgba(255, 212, 92, .42); }
.sq.sel::before { content: ''; position: absolute; inset: 0; background: rgba(255, 212, 92, .65); }
.sq.check::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255, 70, 70, .95) 0%, rgba(255, 70, 70, .5) 45%, transparent 75%); }
.sq.must::after { content: ''; position: absolute; inset: 6%; border-radius: 50%; box-shadow: 0 0 0 3px var(--yellow); pointer-events: none; }
.sq .dot { position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(29, 45, 41, .38); pointer-events: none; z-index: 2; }
.sq .ring { position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(29, 45, 41, .38); pointer-events: none; z-index: 2; }
.sq .coord { position: absolute; font-size: 10px; font-weight: 800; pointer-events: none; z-index: 1; }
.sq .coord.file { right: 3px; bottom: 1px; }
.sq .coord.rank { left: 3px; top: 1px; }
.sq.light .coord { color: var(--dark); }
.sq.dark .coord { color: var(--light); }
.piece { position: relative; z-index: 3; width: 100%; height: 100%; pointer-events: none; }
.piece.anim { transition: transform .18s ease-out; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; transform: translate(-50%, -50%); filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .3)); }
.ck { position: relative; z-index: 3; width: 80%; height: 80%; border-radius: 50%; pointer-events: none; }
.ck.w { background: radial-gradient(circle at 40% 35%, #FFFDF4, #E2DAC4 70%); box-shadow: inset 0 -4px 0 #BDB39A, 0 3px 4px rgba(0, 0, 0, .35); border: 2px solid #A99F86; }
.ck.b { background: radial-gradient(circle at 40% 35%, #4A4744, #1F1D1B 70%); box-shadow: inset 0 -4px 0 #0E0D0C, 0 3px 4px rgba(0, 0, 0, .4); border: 2px solid #0E0D0C; }
.ck::after { content: ''; position: absolute; inset: 22%; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .14); }
.ck.b::after { border-color: rgba(255, 255, 255, .12); }
.ck svg { position: absolute; inset: 22%; width: 56%; height: 56%; z-index: 1; }
.ck.w svg { color: #B8860B; }
.ck.b svg { color: var(--yellow); }
.ck.fade { animation: fadeout .35s forwards; }
@keyframes fadeout { to { opacity: 0; transform: scale(.6); } }
.player-bar { display: flex; align-items: center; gap: 10px; padding: 8px 4px; min-height: 52px; }
.player-bar .who { flex: 1; min-width: 0; }
.player-bar .name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-bar .meta { font-size: 13px; color: var(--chalk-3); display: flex; gap: 8px; align-items: center; min-height: 20px; }
.captured { display: flex; align-items: center; min-height: 18px; }
.captured svg { width: 18px; height: 18px; margin-right: -6px; }
.clock { min-width: 86px; padding: 8px 12px; border-radius: 12px; background: var(--slate-deep); text-align: center; font: 800 22px/1 var(--font); font-variant-numeric: tabular-nums; color: var(--chalk-3); }
.clock.on { background: var(--chalk); color: var(--slate); }
.clock.low.on { background: var(--red); color: #3A0E0E; }
.turn-dot { width: 10px; height: 10px; border-radius: 50%; background: transparent; flex: none; }
.turn-dot.on { background: var(--green); box-shadow: 0 0 0 4px rgba(166, 229, 154, .2); }
.moves-strip { display: flex; gap: 4px; max-width: 100%; overflow-x: auto; padding: 8px 2px; scrollbar-width: none; font-size: 14px; font-variant-numeric: tabular-nums; }
.moves-strip::-webkit-scrollbar { display: none; }
.moves-strip span { flex: none; padding: 4px 8px; border-radius: 8px; color: var(--chalk-2); }
.moves-strip span.n { color: var(--chalk-3); padding-right: 0; }
.moves-strip span.cur { background: var(--slate-3); color: var(--chalk); }
.bg-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
@media (max-width: 599px) {
  .bg-actions { flex-wrap: nowrap; }
  .bg-actions .btn-ghost { padding: 0 12px; }
  .bg-actions .btn-ghost .lbl { display: none; }
  .bg-layout .status-line { margin: 6px 0; }
  .player-bar { min-height: 44px; padding: 4px 2px; }
}
.banner { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--slate-3); margin: 8px 0; font-weight: 700; }
.banner.warn { background: rgba(255, 176, 103, .16); color: var(--orange); }
.banner .grow { min-width: 0; }
.banner > svg { width: 22px; height: 22px; flex: none; }
.promo-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.promo-pick button { aspect-ratio: 1; border-radius: 14px; border: 0; background: var(--chalk); cursor: pointer; padding: 6px; }
.emotes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.emote-bubble { position: absolute; z-index: 20; left: 50%; transform: translateX(-50%); padding: 8px 14px; border-radius: 14px; background: var(--chalk); color: var(--slate); font-weight: 800; animation: bubble 2.6s ease forwards; white-space: nowrap; }
@keyframes bubble { 0% { opacity: 0; transform: translate(-50%, 6px); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
.searching { text-align: center; padding: 20px 0; }
.searching .pulse { width: 74px; height: 74px; margin: 0 auto 14px; border-radius: 50%; border: 3px dashed var(--c); animation: spin 3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.room-code { font: italic 900 46px/1 var(--display); letter-spacing: .12em; color: var(--c); text-align: center; margin: 10px 0; }
.rules { font-size: 14.5px; color: var(--chalk-2); }
.rules li { margin: 4px 0; }

/* ---------- Ranking ---------- */
.lb { display: flex; flex-direction: column; }
.lb-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 6px; border-bottom: 1px solid var(--line); }
.lb-row.me { background: rgba(255, 212, 92, .1); border-radius: 12px; border-bottom-color: transparent; }
.lb-pos { font: italic 900 20px/1 var(--display); color: var(--chalk-3); text-align: center; font-variant-numeric: tabular-nums; }
.lb-row:nth-child(1) .lb-pos { color: var(--yellow); }
.lb-row:nth-child(2) .lb-pos { color: var(--chalk); }
.lb-row:nth-child(3) .lb-pos { color: var(--orange); }
.lb-name { font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-sub { font-size: 12.5px; color: var(--chalk-3); font-weight: 600; }
.lb-score { font: italic 900 20px/1 var(--display); text-align: right; font-variant-numeric: tabular-nums; }
.lb-me { position: sticky; bottom: calc(var(--tab-h) + var(--safe-b) + 8px); margin-top: 10px; background: var(--slate-2); border: 1px solid var(--line-2); border-radius: 14px; }
.empty { text-align: center; padding: 34px 12px; color: var(--chalk-2); }
.empty svg { width: 90px; height: 70px; margin: 0 auto 12px; color: var(--chalk-3); }

/* ---------- Perfil ---------- */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.elo-card { padding: 14px 12px; border-radius: 16px; background: rgba(22, 35, 31, .7); min-width: 0; }
.elo-card b { display: block; font: italic 900 clamp(24px, 7.4vw, 30px)/1.05 var(--display); font-variant-numeric: tabular-nums; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.pill-res { min-width: 26px; height: 26px; padding: 0 6px; display: grid; place-items: center; border-radius: 8px; font-weight: 900; font-size: 13px; }
.pill-res.win { background: rgba(166, 229, 154, .2); color: var(--green); }
.pill-res.loss { background: rgba(255, 123, 123, .18); color: var(--red); }
.pill-res.draw { background: rgba(242, 239, 228, .1); color: var(--chalk-2); }

/* ---------- Legal ---------- */
.legal h2 { font-size: 18px; margin: 22px 0 8px; }
.legal p, .legal li { color: var(--chalk-2); }
.legal p { margin: 8px 0; }
.legal ul { padding-left: 20px; }

/* ---------- Toast e modal ---------- */
.toasts { position: fixed; z-index: 200; left: 50%; top: calc(var(--safe-t) + 12px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 14px; background: var(--chalk); color: var(--slate); font-weight: 700; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); animation: toast-in .25s ease-out; pointer-events: auto; }
.toast.error { background: var(--red); color: #2B0A0A; }
.toast.ok { background: var(--green); color: #12301B; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
.modal-back { position: fixed; inset: 0; z-index: 150; display: grid; place-items: end center; background: rgba(10, 18, 16, .65); backdrop-filter: blur(2px); animation: fade .2s; }
@media (min-width: 640px) { .modal-back { place-items: center; } }
.modal {
  width: min(100%, 460px); max-height: 92dvh; overflow: auto; padding: 22px 20px calc(20px + var(--safe-b));
  background: var(--slate-2); border: 1px solid var(--line-2); border-radius: 24px 24px 0 0; animation: rise .25s ease-out;
}
@media (min-width: 640px) { .modal { border-radius: 24px; padding-bottom: 22px; } }
.modal h2 { font: italic 900 26px/1.1 var(--display); letter-spacing: -.02em; margin-bottom: 8px; }
.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(30px); opacity: 0; } }
.result-title { font: italic 900 38px/1 var(--display); letter-spacing: -.02em; }
.delta-up { color: var(--green); } .delta-down { color: var(--red); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--yellow); animation: spin .8s linear infinite; margin: 30px auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
.narrow { max-width: 640px; margin-inline: auto; }
.auth { max-width: 440px; margin: 0 auto; }
.auth .h1 { margin: 8px 0 6px; }
