/* FLÁVIO — estilos.
   Identidade verde-amarela de cartaz: faixa verde, títulos em Anton, sombra amarela nos cartões.
   Todas as cores ficam nos tokens de :root; app.js lê daqui as cores do tabuleiro. */

@font-face {
  font-family: 'Anton';
  src: url('fonts/anton-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Cores da bandeira */
  --verde: #009c3b;
  --verde-escuro: #00702b;
  --amarelo: #ffdf00;
  --amarelo-claro: #fff7c2;
  --azul: #002776;
  --branco: #ffffff;

  /* Superfícies e texto */
  --paper: #f5f8f3;
  --card: #ffffff;
  --ink: #0d1f45;
  --muted: #4f5b70;
  --line: #d3dae2;

  /* Estados das letras (tabuleiro, teclado, legenda) */
  --correct: #00873c;
  --present: #ffd400;
  --absent: #33467a;
  --on-correct: #ffffff;
  --on-present: #0d1f45;
  --on-absent: #ffffff;
  --tile-empty: #ffffff;
  --tile-filled: #eef6ef;
  --tile-border: #cfd8d2;
  --tile-border-filled: #6f8f7a;
  --tile-active: #00873c;
  --tile-text: #0d1f45;
  --key: #e3e8ee;
  --key-edge: #c3ccd7;

  --display: 'Anton', Impact, 'Arial Narrow', sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --gutter: 40px;
  color-scheme: light;
}

/* Base */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button, a, canvas { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 3px; }
.masthead :focus-visible, .site-footer :focus-visible { outline-color: var(--amarelo); }
canvas:focus { outline: none; }
@media (hover: hover) {
  button:hover:not(:disabled) { filter: brightness(.94); }
}
[hidden] { display: none !important; }
svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; scroll-behavior: auto !important; }
}

/* Cabeçalho verde e faixa amarela */
.masthead { background: var(--verde); color: var(--branco); }
.masthead-inner, .faixa-inner, .footer-inner, .page {
  max-width: 1120px;
  margin: 0 auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}
.masthead-inner { display: flex; align-items: center; gap: 22px; min-height: 92px; }
.brand {
  display: inline-flex;
  align-items: flex-end;
  font-family: var(--display);
  font-size: 60px;
  line-height: 1;
  letter-spacing: .5px;
  color: var(--amarelo);
  text-decoration: none;
  text-shadow: 3px 3px 0 var(--azul);
}
/* Globo azul com faixa branca, no lugar do ponto final. */
.brand-dot {
  width: .26em;
  height: .26em;
  margin: 0 0 .1em .08em;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--azul) 0 42%, var(--branco) 42% 56%, var(--azul) 56%);
  box-shadow: 3px 3px 0 var(--verde-escuro);
}
.masthead-caption {
  font-size: 10px;
  line-height: 1.6;
  font-weight: 800;
  letter-spacing: 1.8px;
  border-left: 2px solid rgba(255, 255, 255, .45);
  padding-left: 20px;
}
nav { display: flex; gap: 24px; margin-left: auto; }
.nav-button {
  display: flex; align-items: center; gap: 7px;
  border: 0; padding: 6px 0; background: none;
  color: var(--branco); font-size: 13px; font-weight: 700;
}
.faixa { background: var(--amarelo); border-bottom: 5px solid var(--azul); }
.faixa-inner {
  display: flex; justify-content: space-between; gap: 8px;
  padding-top: 8px; padding-bottom: 8px;
  font-size: 10px; font-weight: 800; letter-spacing: 1.6px; color: var(--azul);
}

/* Tipografia comum */
.eyebrow { font-size: 11px; letter-spacing: 1.6px; font-weight: 800; margin: 0; color: var(--verde-escuro); }
.text-button { padding: 0; border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 600; }
.text-button span { margin-left: 4px; }
.fine-print { font-size: 11px !important; color: var(--muted) !important; }
h1, h2 { font-family: var(--display); font-weight: 400; text-transform: uppercase; letter-spacing: .3px; }

/* Cartões: borda fina e sombra amarela deslocada, como cartaz colado. */
.card {
  background: var(--card);
  border: 2px solid var(--azul);
  box-shadow: 7px 7px 0 var(--amarelo);
  padding: 0 28px 26px;
}
.paper-top {
  display: flex; justify-content: space-between;
  margin: 0 -28px 18px;
  padding: 10px 28px;
  background: var(--azul);
  color: var(--amarelo);
  font-size: 10px; font-weight: 800; letter-spacing: 1.6px;
}

/* Botões */
.primary-button, .secondary-button {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 18px;
  border-radius: 6px;
  font-size: 14px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
}
.primary-button { background: var(--correct); color: var(--branco); border: 0; border-bottom: 4px solid var(--verde-escuro); }
.secondary-button { background: var(--branco); color: var(--azul); border: 2px solid var(--azul); }

/* Página inicial */
.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .84fr);
  grid-template-areas: "copy guide" "cta guide";
  grid-template-rows: auto 1fr;
  column-gap: 80px;
  padding: 52px 0 60px;
  align-items: start;
}
.intro-copy { grid-area: copy; }
.intro-guide { grid-area: guide; }
/* No celular, o botão vem depois das instruções de como ler as pistas. */
.intro-cta { grid-area: cta; margin-top: 28px; }
.intro-copy h1 { font-size: 76px; line-height: 1.1; margin: 18px 0 24px; color: var(--azul); }
/* Marca-texto amarelo só na faixa das letras, sem invadir a linha de cima. */
.destaque {
  background: linear-gradient(transparent 22%, var(--amarelo) 22%, var(--amarelo) 94%, transparent 94%);
  padding: 0 .1em;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
}
.intro-lead { font-size: 16px; line-height: 1.7; color: var(--ink); max-width: 420px; }
.intro-start { max-width: 360px; padding: 18px 20px; font-size: 16px; }
.intro-footnote { font-size: 12px; color: var(--muted); margin: 14px 0 0; }
.intro-guide { margin-top: 8px; }
.intro-guide h2 { font-size: 36px; line-height: 1.05; margin: 8px 0 22px; color: var(--azul); }
.intro-example-label { font-size: 10px; font-weight: 800; letter-spacing: 1.4px; color: var(--muted); margin: 0; }
.intro-example { margin: 12px 0 26px; gap: 6px; }
.intro-example b { flex: 1; width: auto; max-width: 52px; height: 52px; font-size: 24px; }
.intro-colors { list-style: none; padding: 0; display: grid; gap: 18px; margin: 0 0 24px; }
.intro-colors li { display: flex; gap: 12px; align-items: flex-start; }
.intro-colors .swatch { width: 22px; height: 22px; margin-top: 1px; }
.intro-colors strong { font-size: 14px; }
.intro-colors p { font-size: 13px; line-height: 1.6; color: var(--muted); margin: 4px 0 0; }
.intro-tip { background: var(--amarelo-claro); border-left: 6px solid var(--amarelo); padding: 14px 16px; }
.intro-tip > strong { font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--azul); }
.intro-tip p { font-size: 13px; line-height: 1.65; color: var(--ink); margin: 8px 0 0; }

/* Jogo */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, .86fr);
  gap: 74px;
  padding: 36px 0 48px;
}
.play-panel { max-width: 490px; width: 100%; margin: 0 auto; }
.round-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.round-label {
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--azul);
  color: var(--amarelo);
  font-size: 11px; font-weight: 800; letter-spacing: 1.4px;
}
#game-title { font-size: 44px; line-height: 1; margin: 18px 0 8px; color: var(--azul); }
.round-hint { display: flex; align-items: baseline; gap: 8px; margin: 0; font-size: 16px; line-height: 1.35; }
.hint-label {
  flex-shrink: 0;
  padding: 3px 8px;
  border-radius: 3px;
  background: var(--amarelo); color: var(--azul);
  font-size: 10px; font-weight: 800; letter-spacing: 1.3px;
}
#hint-text { font-weight: 700; color: var(--ink); }
.round-hint.no-hint .hint-label { display: none; }
.round-hint.no-hint #hint-text { font-weight: 400; color: var(--muted); font-size: 14px; }
/* --board-ratio (largura/altura) vem do app.js: 1 com seis letras, maior na exceção de oito. */
.board-wrap { width: min(100%, calc(360px * var(--board-ratio, 1))); margin: 20px auto 0; }
canvas { display: block; width: 100%; aspect-ratio: var(--board-ratio, 1); }
.game-message {
  min-height: 26px;
  margin: 10px auto 12px;
  padding: 4px 12px;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  font-size: 13px; line-height: 18px; text-align: center;
  color: var(--muted);
}
.game-message.error { background: var(--amarelo); color: var(--azul); font-weight: 800; }
.game-message.success { color: var(--correct); font-weight: 800; }

.keyboard {
  display: flex; flex-direction: column; gap: 6px; width: 100%;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.key-row { display: flex; justify-content: center; gap: 5px; }
.key {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  flex: 1; min-width: 0; max-width: 46px; height: 48px;
  padding: 0;
  background: var(--key);
  border: 0; border-bottom: 3px solid var(--key-edge);
  border-radius: 5px;
  color: var(--ink);
  font-size: 15px; font-weight: 800;
}
.key.wide { max-width: 72px; flex: 1.6; font-size: 11px; letter-spacing: .4px; }
.key.wide.enter { background: var(--correct); color: var(--branco); border-bottom-color: var(--verde-escuro); }
.key:disabled { opacity: .65; }
.key-symbol { position: absolute; right: 3px; bottom: 1px; font-size: 8px; line-height: 9px; }
.correct, .key.correct { background: var(--correct); color: var(--on-correct); border-bottom-color: var(--verde-escuro); }
.present, .key.present { background: var(--present); color: var(--on-present); border-bottom-color: #c9a600; }
.absent, .key.absent { background: var(--absent); color: var(--on-absent); border-bottom-color: #1f2d55; }
.legend { display: flex; justify-content: center; gap: 16px; font-size: 11px; color: var(--muted); margin-top: 16px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.swatch {
  width: 16px; height: 16px;
  display: inline-flex; justify-content: center; align-items: center; flex-shrink: 0;
  border-radius: 3px;
  font-size: 10px; font-style: normal;
}

/* História */
.story-panel { padding-top: 4px; min-width: 0; }
.paper-illustration { height: 180px; display: flex; align-items: center; justify-content: center; }
.paper-sheet {
  position: relative;
  width: 136px; height: 141px;
  padding: 22px 19px;
  background: #f1f4ee;
  border: 2px solid var(--azul);
  transform: rotate(-6deg);
}
.paper-lines b { display: block; height: 4px; background: #b9c5d6; margin-bottom: 10px; width: 90%; }
.paper-lines b:first-child { height: 10px; width: 60%; margin-bottom: 18px; background: var(--verde); }
.paper-lines b:last-child { width: 66%; }
.seal {
  position: absolute; right: -18px; bottom: 0;
  width: 70px; height: 70px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--amarelo); color: var(--azul);
  border: 3px solid var(--azul);
  transform: rotate(8deg);
  font: 32px/1 var(--display);
}
.seal span { font: 800 7px var(--sans); letter-spacing: 1.3px; margin-top: 2px; }
.story-locked h2 { font-size: 40px; line-height: 1; margin: 12px 0 16px; color: var(--azul); }
.story-locked > p:not(.eyebrow) { font-size: 15px; line-height: 1.7; color: var(--muted); max-width: 320px; }
.locked-note {
  display: flex; align-items: center; gap: 10px;
  margin-top: 24px; padding-top: 18px;
  border-top: 2px dashed var(--line);
  color: var(--azul); font-size: 13px; font-weight: 700;
}
.locked-note svg { width: 17px; height: 17px; }
.answer-label { font-size: 11px; font-weight: 800; letter-spacing: 1.4px; color: var(--verde-escuro); margin: 4px 0 8px; }
.answer-word {
  font: 58px/1.2 var(--display);
  letter-spacing: 2px;
  color: var(--correct);
  text-shadow: 3px 3px 0 var(--amarelo);
  margin-bottom: 14px;
}
.story-meta {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin: 0;
  font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  color: var(--azul);
}
.story-open h2 { font-size: 30px; line-height: 1.08; margin: 10px 0 14px; color: var(--azul); text-transform: none; }
.story-summary { font-size: 15px; line-height: 1.65; color: var(--ink); }
.story-context { font-size: 14px; line-height: 1.65; color: var(--muted); }
.connection { margin-top: 16px; padding: 14px 16px; background: var(--amarelo-claro); border-left: 6px solid var(--amarelo); }
.connection > span { font-size: 10px; font-weight: 800; letter-spacing: 1.3px; color: var(--azul); }
.connection p { font-size: 14px; line-height: 1.6; margin: 6px 0 0; }
.video-box { margin-top: 18px; }
.video-box h3, .source-box h3 { font-size: 13px; font-weight: 800; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .6px; }
.video-box ul { padding: 0; margin: 0; list-style: none; display: grid; gap: 8px; }
.video-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px 10px 10px;
  border-radius: 6px;
  background: var(--azul); color: var(--branco);
  text-decoration: none;
}
.video-play {
  flex-shrink: 0;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--amarelo); color: var(--azul);
  font-size: 13px; padding-left: 2px;
}
.video-text { display: flex; flex-direction: column; gap: 2px; font-size: 14px; font-weight: 700; line-height: 1.3; }
.video-text small { font-size: 11px; font-weight: 600; color: var(--amarelo); }
@media (hover: hover) { .video-link:hover { filter: brightness(1.15); } }
.source-box { margin-top: 18px; }
.source-box h3 span { float: right; }
.source-box ul { padding: 0; margin: 0; list-style: none; }
.source-box li + li { margin-top: 10px; }
.source-box a { font-size: 13px; line-height: 1.5; text-decoration-thickness: 1px; text-underline-offset: 3px; color: var(--azul); }
.source-kind { display: block; margin-top: 2px; font-size: 10px; color: var(--muted); }
.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }

/* Rodapé azul */
.site-footer { background: var(--azul); color: #dfe6f5; border-top: 5px solid var(--amarelo); }
.footer-inner {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding-top: 18px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  font-size: 12px;
}
.site-footer p { margin: 0; line-height: 1.5; }
.site-footer .text-button { color: var(--amarelo); flex-shrink: 0; }
.site-footer .fine-print { color: var(--amarelo) !important; margin-bottom: 8px; }

/* Diálogos */
dialog {
  width: min(460px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: 22px 28px 26px;
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--azul);
  border-top: 8px solid var(--verde);
  border-radius: 6px;
  box-shadow: 8px 8px 0 var(--amarelo);
}
dialog::backdrop { background: rgba(0, 39, 118, .55); backdrop-filter: blur(2px); }
.dialog-top { display: flex; justify-content: space-between; align-items: center; }
.close-button { padding: 0 4px; border: 0; background: transparent; font-size: 28px; line-height: 1; color: var(--muted); }
dialog h2 { font-size: 36px; line-height: 1.02; margin: 14px 0 16px; color: var(--azul); }
dialog p { font-size: 14px; line-height: 1.65; color: var(--muted); }
.help-example { display: flex; gap: 5px; margin: 18px 0; }
.help-example b {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 44px;
  border: 2px solid var(--tile-border); border-radius: 4px;
  font-size: 20px; font-weight: 800;
}
.help-example b.correct, .help-example b.present, .help-example b.absent { border-color: transparent; }
.help-example b span { position: absolute; bottom: 1px; right: 3px; font-size: 8px; }
.help-list { list-style: none; padding: 0; display: grid; gap: 12px; font-size: 14px; }
.help-list li { display: flex; align-items: center; gap: 10px; }
/* Como jogar: janela compacta, aberta sozinha na primeira visita (estilo Termo). */
dialog.help-dialog { width: min(380px, calc(100% - 32px)); padding: 16px 20px 20px; }
.help-dialog h2 { margin: 0; font-size: 30px; }
.help-dialog p { margin: 10px 0; line-height: 1.5; }
.help-dialog .help-example { justify-content: center; margin: 12px 0; }
.help-dialog .help-example b { width: 38px; height: 40px; font-size: 18px; }
.help-dialog .help-list { gap: 8px; margin: 0 0 4px; }
.help-dialog .help-note { font-size: 13px; }
.help-dialog .primary-button { width: 100%; margin-top: 6px; }
.round-list { display: grid; gap: 9px; margin-top: 20px; }
.round-choice {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 13px 14px;
  text-align: left;
  background: var(--card); color: var(--ink);
  border: 2px solid var(--line); border-radius: 6px;
}
.round-choice.active { border-color: var(--correct); background: #eaf6ee; }
.round-index { font: 26px var(--display); color: var(--correct); min-width: 30px; }
.round-info { flex: 1; }
.round-info strong { display: block; font-size: 14px; }
.round-info small { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); }
.round-status { font-size: 16px; color: var(--azul); }
.stats-summary { display: flex; justify-content: space-around; gap: 10px; margin: 22px 0 28px; }
.stat { text-align: center; }
.stat strong { display: block; font: 44px/1.1 var(--display); color: var(--azul); }
.stat span { font-size: 12px; color: var(--muted); }
.stats-distribution { display: grid; gap: 7px; margin: 16px 0; }
.distribution-row { display: flex; gap: 9px; align-items: center; font-size: 12px; font-weight: 700; }
.distribution-row > span { min-width: 10px; }
.distribution-bar { min-width: 24px; padding: 4px 8px; border-radius: 3px; background: var(--correct); color: var(--branco); text-align: right; }
.distribution-bar.zero { background: var(--key); color: var(--muted); }
#share-text {
  display: block; width: 100%; resize: vertical;
  margin-bottom: 14px; padding: 14px;
  background: var(--paper); color: var(--ink);
  border: 2px solid var(--line); border-radius: 6px;
  font: 15px/1.5 ui-monospace, Menlo, monospace;
}
/* Compartilhar: prévia da imagem, botões e texto opcional */
dialog { overflow-y: auto; }
.share-preview { display: flex; justify-content: center; align-items: center; min-height: 120px; margin: 4px 0 16px; }
#share-image {
  display: block;
  width: auto; max-width: 100%;
  height: auto; max-height: min(46vh, 420px);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(13, 31, 69, .22);
}
.share-actions { display: grid; gap: 10px; }
.share-actions .secondary-button { text-decoration: none; }
.share-mode { display: block; margin: 14px auto 0; color: var(--azul); text-decoration: underline; text-underline-offset: 3px; }
.share-text-box { margin-top: 16px; border-top: 2px dashed var(--line); padding-top: 12px; }
.share-text-box summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--azul); }
.share-text-box #share-text { margin-top: 12px; }
#final-share-button { margin-top: 8px; }
.board-wrap.shake { animation: shake .25s ease-in-out; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* Telas largas */
@media (min-width: 1200px) {
  :root { --gutter: 48px; }
  main { gap: 86px; }
}

/* Tablets e janelas estreitas */
@media (max-width: 850px) {
  :root { --gutter: 24px; }
  main { gap: 36px; grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); }
  .masthead-caption { display: none; }
  .card { padding: 0 20px 22px; }
  .paper-top { margin: 0 -20px 16px; padding: 10px 20px; }
  .story-locked h2 { font-size: 32px; }
  .board-wrap { max-width: calc(340px * var(--board-ratio, 1)); }
  .legend { gap: 10px; font-size: 10px; }
  .intro-panel { column-gap: 36px; }
  .intro-copy h1 { font-size: 58px; }
  .intro-guide h2 { font-size: 30px; }
  .intro-example { gap: 4px; }
  .intro-example b { height: 44px; font-size: 21px; }
}

/* Celular: tabuleiro e teclado inteiros na tela, sem rolar.
   A altura do tabuleiro desconta o cabeçalho, a mensagem e o teclado (~318px). */
@media (max-width: 650px) {
  :root { --gutter: 14px; --masthead-h: 63px; }
  .masthead-inner { min-height: 54px; gap: 10px; }
  .brand { font-size: 36px; text-shadow: 2px 2px 0 var(--azul); }
  .brand-dot { box-shadow: 2px 2px 0 var(--verde-escuro); }
  nav { gap: 16px; }
  .nav-button { font-size: 12px; gap: 5px; }
  .nav-button svg { width: 18px; height: 18px; }
  .faixa { border-bottom-width: 3px; }
  .faixa-inner { display: none; }
  .faixa { height: 9px; }

  /* Tela do jogo em altura cheia: o teclado fica colado embaixo e a sobra de altura
     vira respiro acima e abaixo do tabuleiro (em telas baixas, o tabuleiro encolhe). */
  main { display: block; padding: 0 0 28px; }
  .play-panel {
    max-width: 440px;
    display: flex; flex-direction: column;
    min-height: calc(100vh - var(--masthead-h));
    min-height: calc(100svh - var(--masthead-h));
    padding-top: 10px;
  }
  #game-title {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .round-label { font-size: 10px; padding: 4px 10px; }
  .round-hint { margin: 8px 0 8px; font-size: 15px; }
  .board-wrap {
    width: min(100%, calc(350px * var(--board-ratio, 1)), max(calc(200px * var(--board-ratio, 1)), calc((100vh - 346px) * var(--board-ratio, 1))));
    width: min(100%, calc(350px * var(--board-ratio, 1)), max(calc(200px * var(--board-ratio, 1)), calc((100svh - 346px) * var(--board-ratio, 1))));
    margin: auto;
  }
  .game-message { min-height: 24px; margin: 6px auto 8px; font-size: 12px; padding: 3px 10px; }
  .keyboard { gap: 6px; }
  .key-row { gap: 4px; }
  .key { height: 50px; max-width: none; font-size: 15px; }
  .key.wide { max-width: none; font-size: 10px; }
  .legend { gap: 12px; font-size: 10px; margin: 12px 0 6px; }

  .story-panel { max-width: 440px; margin: 0 auto; padding-top: 26px; }
  .story-locked .paper-illustration { display: none; }
  .story-locked h2 { font-size: 30px; margin: 8px 0; }
  .story-locked h2 br { display: none; }
  .story-locked > p:not(.eyebrow) { max-width: none; font-size: 14px; }
  .locked-note { margin-top: 14px; padding-top: 14px; }
  .answer-word { font-size: 48px; }
  .story-open h2 { font-size: 27px; }

  .footer-inner { display: block; font-size: 11px; }
  .site-footer .text-button { margin-top: 10px; }
  dialog { padding: 18px 20px 22px; }
  dialog h2 { font-size: 32px; }

  .intro-panel { display: flex; flex-direction: column; gap: 30px; padding: 26px 0 36px; max-width: 440px; margin: 0 auto; }
  .intro-copy h1 { font-size: 52px; margin-top: 14px; }
  .intro-copy h1 br:nth-of-type(2) { display: none; }
  .intro-lead { font-size: 15px; }
  .intro-start { max-width: none; }

  /* Celular: cada passo cabe na tela. Página inicial enxuta, em altura cheia, com o botão
     fixo no pé; a sobra de altura fica como respiro antes do botão. */
  .intro-panel {
    align-items: stretch;
    gap: 16px; padding: 16px 0 0;
    min-height: calc(100vh - var(--masthead-h));
    min-height: calc(100svh - var(--masthead-h));
  }
  .intro-cta { margin-top: auto; }
  .intro-copy h1 { font-size: 40px; margin: 8px 0 10px; }
  .intro-copy h1 br { display: none; }
  .intro-lead { font-size: 14px; line-height: 1.55; margin: 0; }
  .intro-guide h2, .intro-example-label, .intro-colors p, .intro-tip p + p { display: none; }
  .intro-guide .paper-top { margin-bottom: 12px; }
  .intro-example { margin: 2px 0 14px; }
  .intro-example b { height: 42px; font-size: 20px; }
  .intro-colors { gap: 10px; margin-bottom: 14px; }
  .intro-tip { padding: 10px 12px; }
  .intro-tip p { margin-top: 4px; font-size: 13px; }
  .intro-cta {
    position: sticky; bottom: 0; z-index: 5;
    margin: 0 calc(-1 * var(--gutter));
    padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
    background: var(--paper);
    box-shadow: 0 -6px 16px rgba(13, 31, 69, .08);
  }
  .intro-footnote { margin-top: 6px; text-align: center; }

  /* Depois de acertar: compartilhar e próxima rodada sempre à vista, numa barra fixa. */
  .result-actions {
    position: sticky; bottom: 0; z-index: 5;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
    margin: 18px -20px -22px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: var(--card);
    border-top: 2px solid var(--azul);
  }
  .result-actions .primary-button, .result-actions .secondary-button { padding: 12px 12px; font-size: 13px; }
  .wide-only { display: none; }
  .intro-guide { width: 100%; margin: 0; }
  .intro-guide h2 { font-size: 30px; }
  .intro-example b { height: 46px; }
}

/* Celulares baixos (iPhone SE de 1ª geração, Android pequeno com barras abertas) */
@media (max-width: 650px) and (max-height: 600px) {
  :root { --masthead-h: 55px; }
  .masthead-inner { min-height: 46px; }
  .brand { font-size: 30px; }
  .play-panel { padding-top: 8px; }
  .round-hint { margin: 6px 0 6px; font-size: 14px; }
  .board-wrap {
    width: min(100%, calc(350px * var(--board-ratio, 1)), max(calc(150px * var(--board-ratio, 1)), calc((100vh - 304px) * var(--board-ratio, 1))));
    width: min(100%, calc(350px * var(--board-ratio, 1)), max(calc(150px * var(--board-ratio, 1)), calc((100svh - 304px) * var(--board-ratio, 1))));
    margin: auto;
  }
  .game-message { margin: 4px auto 6px; }
  .key { height: 44px; }
}

/* Telas muito estreitas (320–360 px) */
@media (max-width: 360px) {
  :root { --gutter: 10px; }
  .brand { font-size: 32px; }
  .nav-button span { display: none; }
  nav { gap: 20px; }
  .key-row { gap: 3px; }
  .key { font-size: 14px; }
  .legend { gap: 8px; font-size: 9px; }
  .round-hint { font-size: 13px; gap: 6px; }
  .intro-copy h1 { font-size: 44px; }
}
