/* Página de jogos: usa os mesmos tokens de ../src/styles.css (cores, fontes, raio, curva de movimento).
   Aqui ficam o layout da página e as peças comuns a todos os jogos (.jg-*). Cada jogo traz o seu próprio CSS. */
.jogos { position: relative; z-index: 1; max-width: 1100px; margin-inline: auto; display: flex; flex-direction: column; gap: 16px; }

.jogos .brand { color: inherit; text-decoration: none; }
.top-links { display: flex; flex-wrap: wrap; gap: 8px; }
a.btn { text-decoration: none; color: inherit; }

/* Uma cor para cada jogo, usada só no ícone e na barra de progresso. Botões, seleção e textos usam o
   destaque único do site: a tela fica calma e o tabuleiro é o que chama a atenção. */
[data-game="sudoku"] { --g: #2f7de1; }
[data-game="kakuro"] { --g: #e8702a; }
[data-game="hitori"] { --g: #7c4ddb; }
[data-game="hashi"] { --g: #0d9da0; }
[data-game="strimko"] { --g: #d63f9c; }
[data-game="arukone"] { --g: #e5484d; }
[data-game="picapix"] { --g: #2f9e58; }
[data-game="tangram"] { --g: #e39a12; }
[data-game="cruzadas"] { --g: #4a5fe8; }
[data-game="logica"] { --g: #6b9a12; }
[data-game="zip"] { --g: #e0603a; }
[data-game="queens"] { --g: #9a55d6; }
[data-game="tango"] { --g: #e2a40f; }
[data-game="patches"] { --g: #1f9c86; }
[data-game="norinori"] { --g: #3f6fd8; }
[data-game="akari"] { --g: #d99a1c; }
[data-game="shikaku"] { --g: #c7567f; }
[data-game="kenken"] { --g: #d9622b; }
[data-game="futoshiki"] { --g: #2e9c6a; }
[data-game="slitherlink"] { --g: #5b6ee0; }
[data-game="tents"] { --g: #3f9a3a; }
[data-game="masyu"] { --g: #b0526e; }
[data-game="nurikabe"] { --g: #2a8fb5; }
[data-game="killer"] { --g: #c0392b; }
[data-game="creek"] { --g: #2f8f9d; }
[data-game="ripple"] { --g: #3d8bd9; }
[data-game="kurodoko"] { --g: #55607a; }
[data-game="inshi"] { --g: #c9741a; }
[data-game="shakashaka"] { --g: #d1557a; }
[data-game="busca"] { --g: #2f86c9; }
[data-game="pares"] { --g: #c2578f; }
[data-game="digitos"] { --g: #4f7fd9; }
[data-game="regra"] { --g: #7a62d6; }
[data-game="nomes"] { --g: #c7742f; }
[data-game="nback"] { --g: #5b6fd6; }
[data-game="sustentada"] { --g: #2e9a8f; }
[data-game="rastreio"] { --g: #d06a3a; }
[data-game="tentai"] { --g: #6c63d9; }
[data-game="yosenabe"] { --g: #d0782a; }
[data-game="sukoro"] { --g: #3aa37c; }
[data-game="dominosa"] { --g: #8a6a3d; }
[data-game="sujiko"] { --g: #d4553f; }
[data-game="meandering"] { --g: #4a9a8a; }
[data-game="symapix"] { --g: #d0508a; }
[data-game="nawabari"] { --g: #a8643c; }
[data-game="chocona"] { --g: #8a5a3a; }
[data-game="lits"] { --g: #5a8f3c; }
[data-game="heyawake"] { --g: #5f7fb8; }
[data-game="fillomino"] { --g: #6a7fd6; }
[data-game="stroop"] { --g: #3f7fd0; }
[data-game="campo"] { --g: #4a8fd4; }
[data-game="mudou"] { --g: #c26a3c; }
[data-game="flanker"] { --g: #d0623f; }
[data-game="lista"] { --g: #4c9a52; }
[data-game="corsi"] { --g: #5a7bd8; }
[data-game="inverso"] { --g: #7a6bd9; }
[data-game="calculo"] { --g: #2f7de1; }
[data-game="onde"] { --g: #9a6fd0; }
[data-game="alterna"] { --g: #3d9a5a; }
[data-game="hanoi"] { --g: #b5743a; }
[data-game="cripto"] { --g: #8b5fc7; }
[data-game="cacapalavras"] { --g: #2f9a7a; }
[data-game="aseasyas"] { --g: #b5653d; }
[data-game="yinyang"] { --g: #4b5563; }
[data-game="nondango"] { --g: #b8743a; }
[data-game="mochikoro"] { --g: #6b7a8f; }
[data-game="tapa"] { --g: #7b5ad6; }
[data-game="yajilin"] { --g: #3b8f6e; }
[data-game="naovai"] { --g: #c94f4f; }
[data-game="contaguarda"] { --g: #4a86c9; }
[data-game="relampago"] { --g: #d9a01e; }
[data-game="trilhas"] { --g: #4f9a6a; }
[data-game="estimativa"] { --g: #8a6ad0; }
[data-game="kakurasu"] { --g: #c98a2a; }
[data-game="gokigen"] { --g: #5c8fd6; }
[data-game="pipelink"] { --g: #3a9aa8; }
[data-game="kurotto"] { --g: #6a6f8a; }
[data-game="abaco"] { --g: #c9831a; }
[data-game] {
  --g-frame: color-mix(in srgb, var(--g) 62%, black);
  --g-felt: var(--g);
  --g-glyph: #ffffff;
}

/* Lista de jogos */
#hub { display: flex; flex-direction: column; gap: 14px; padding-inline: 6px; }
/* Abas: cada seção aparece só na aba dela */
#hub[data-tab="jogos"] > [data-in]:not([data-in="jogos"]),
#hub[data-tab="ranking"] > [data-in]:not([data-in="ranking"]),
#hub[data-tab="voce"] > [data-in]:not([data-in="voce"]) { display: none; }

/* Casca de aplicativo: cabeçalho fixo no topo, abas embaixo no celular, conteúdo rolando no meio */
.jogos { min-height: calc(100dvh - 48px); }
.jogos > .top { position: sticky; top: calc(8px + env(safe-area-inset-top, 0px)); z-index: 6; }
.appnav {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; align-self: center; width: min(100%, 420px);
  padding: 4px; border-radius: 999px; background: var(--shell); border: 1px solid var(--line);
}
.appnav button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 6px 10px;
  border: 0; border-radius: 999px; background: none; cursor: pointer; font: 600 .95rem var(--display); color: var(--muted);
  transition: background .25s var(--ease), color .25s var(--ease);
}
.appnav button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 1px 0 var(--hi), 0 1px 2px var(--lift); }
.appnav button[aria-pressed="true"] .ico { color: var(--accent); }
body.in-game .appnav { display: none; }
/* Barra de progresso fina, na cor do jogo ou da família (cartões da página inicial: hub.css) */
.card-bar { height: 6px; border-radius: 999px; background: color-mix(in srgb, var(--g) 18%, var(--bg)); overflow: hidden; }
.card-bar i { display: block; height: 100%; border-radius: inherit; background: var(--g); transform-origin: left; transition: transform .8s var(--ease); }

/* Ícone de jogo: o desenho de cada um sobre a moldura e o feltro do ábaco */
.g-ico { display: inline-flex; width: 44px; height: 44px; flex: none; color: var(--bead-on); filter: drop-shadow(0 6px 8px var(--lift)); }
.g-ico svg { width: 100%; height: 100%; }
.g-ico { color: var(--g-glyph, var(--bead-on)); }
.g-ico use { fill: none; stroke: var(--g-glyph, var(--bead-on)); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Professor: rosto e balão de fala */
.prof {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 12px; align-items: start; padding: 12px 16px;
  border: 1px solid var(--accent); border-radius: 20px; background: var(--surface);
  box-shadow: inset 0 1px 0 var(--hi), 0 18px 32px -22px var(--lift);
}
.prof.talk { animation: prof-in .45s var(--ease); }
.prof.talk .prof-face { animation: prof-nod .7s var(--ease); }
.prof-face { width: 76px; height: 76px; filter: drop-shadow(0 8px 10px var(--lift)); }
/* Retrato do mentor: o SVG ocupa a caixa inteira, seja qual for o mascote */
.mentor { display: block; }
.mentor > svg { display: block; width: 100%; height: 100%; }
.prof-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.prof-passo { font: 600 .82rem var(--display); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Dispensar é escolha de fundo, não a ação do momento: um link discreto no fim da fila de botões */
.prof-off { min-height: 38px; margin-left: auto; padding: 4px 6px; border: 0; background: none; cursor: pointer; font: 500 .84rem var(--display); color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
/* Depois de dispensado, o botão que o chama pisca algumas vezes: "é por aqui" */
#g-prof.aponta { animation: prof-aponta 1s var(--ease) 5; }
@keyframes prof-aponta { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent); transform: translateY(-3px); } }
.prof-eyes { transform-origin: 32px 31.5px; animation: prof-blink 4.5s infinite; }
.prof-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.prof-body strong { font: 700 .95rem var(--display); color: var(--accent); }
.prof-body p { margin: 0; font-size: 1.05rem; text-wrap: pretty; }
.prof-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.prof-actions .btn { min-height: 38px; font-size: .9rem; }
@keyframes prof-in { from { transform: translateY(10px) scale(.98); opacity: .3; } }
@keyframes prof-nod { 30% { transform: rotate(-7deg); } 65% { transform: rotate(5deg); } }
@keyframes prof-blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }

/* Destaque padrão do "onde olhar"; cada jogo pode refinar em .game-<id> .jg-spot */
.jg-spot { outline: 3px solid var(--accent); outline-offset: -3px; animation: jg-spot 1s ease-in-out 5; }
@keyframes jg-spot { 50% { outline-color: color-mix(in srgb, var(--accent) 25%, transparent); } }

/* Tela de jogo (a coluna, o palco e a barra de ações estão em tela.css) */
/* Faixas de dificuldade: quatro botões em linha, com a atual em destaque */
.bands { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.bands button { justify-content: center; min-height: 36px; padding: 4px 6px; border-radius: 999px; font-size: .9rem; }
.bands button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.play-head { display: flex; align-items: center; gap: 10px; }
/* O nome do jogo aparece inteiro: se não couber numa linha, quebra em duas (nunca corta) */
.play-head h2 { overflow-wrap: break-word; text-wrap: balance; }
.play-head .back { width: 44px; height: 44px; }
#g-levels { flex: none; min-height: 44px; }
.jogos .btn, .appnav button, .tabs button { white-space: nowrap; }
/* O balão do Professor reserva sempre o mesmo espaço para o texto: os botões não pulam de lugar a cada passo */
.prof-body p { min-height: 4.4em; }
.lv-step { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lv-step .tgl { margin-left: auto; }
.play-head h2 { font-size: 1.35rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.level-nav { display: flex; gap: 6px; }
.level-nav .btn { padding-inline: 12px; }
#g-level { font-variant-numeric: tabular-nums; }
.board {
  display: flex; flex-direction: column; align-items: center; gap: 12px; min-height: 240px;
  padding: 16px; margin: 6px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface);
  box-shadow: inset 0 1px 0 var(--hi), 0 0 0 5px var(--shell), 0 0 0 6px var(--line), 0 34px 48px -34px var(--lift);
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.lv-step .btn { min-width: 46px; justify-content: center; }
.win {
  position: relative; z-index: 36; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 8px 14px;
  padding: 12px 16px; border-radius: 20px; border: 2px solid var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 22px 36px -24px var(--lift);
}
.win.party { animation: win-pop .7s var(--ease); }
.win.party .win-owl { animation: owl-jump .55s ease-in-out 4; }
.win-owl { width: 64px; height: 64px; filter: drop-shadow(0 8px 10px var(--lift)); }
.win-body { display: flex; flex-direction: column; min-width: 0; }
.win-title { font: 800 1.5rem/1.1 var(--display); letter-spacing: -.03em; color: var(--accent); }
.win strong { font: 500 .98rem var(--display); }
/* Os botões do aviso acompanham o tamanho do texto do aviso (estavam menores que a frase acima deles) */
#win .btn { min-height: 48px; padding-inline: 22px; font-size: 1.06rem; font-weight: 700; }
#win .btn .ico { width: 20px; height: 20px; }
@keyframes win-pop { 0% { transform: scale(.7) rotate(-2deg); opacity: 0; } 60% { transform: scale(1.04) rotate(1deg); } }
@keyframes owl-jump { 50% { transform: translateY(-12px) rotate(-8deg); } }
.fogos { position: fixed; inset: 0; z-index: 34; width: 100%; height: 100%; pointer-events: none; }

.lv-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; font: 600 1rem var(--display); font-variant-numeric: tabular-nums; }
.lv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
.lv { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); cursor: pointer; font: 500 .9rem var(--display); font-variant-numeric: tabular-nums; }
.lv.done { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.lv.cur { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Peças comuns aos jogos */
/* Grade quadrada: defina --n (casas por lado) no elemento. Cabe em tela de celular e não passa de 560px. */
.jg-grid {
  display: grid; grid-template-columns: repeat(var(--n, 9), minmax(0, 1fr));
  width: min(100%, 560px); aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; background: var(--line); gap: 1px;
}
.jg-cell {
  display: grid; place-items: center; min-width: 0; padding: 0; border: 0; background: var(--surface); color: var(--ink); cursor: pointer;
  font: 600 clamp(.8rem, 4.2cqw, 1.6rem) var(--display); font-variant-numeric: tabular-nums; -webkit-tap-highlight-color: transparent;
}
.jg-grid { container-type: inline-size; }
.jg-cell.is-given { font-weight: 800; background: var(--shell); }
.jg-cell.is-peer { background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.jg-cell.is-sel { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.jg-cell.is-bad { color: var(--bad); }
.jg-cell.is-hint { animation: jg-pop .6s var(--ease); background: color-mix(in srgb, var(--good) 22%, var(--surface)); }
@keyframes jg-pop { from { transform: scale(.7); opacity: .4; } }

/* Teclado numérico para toque */
.jg-pad { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; width: min(100%, 560px); }
.jg-key {
  flex: 1 0 44px; max-width: 64px; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer;
  font: 700 1.2rem var(--display); box-shadow: inset 0 1px 0 var(--hi), 0 1px 2px var(--lift);
  transition: transform .15s var(--ease), background .2s;
}
.jg-key-wide { flex-basis: 96px; max-width: 140px; font-size: .95rem; font-weight: 600; }
.jg-key:active { transform: scale(.95); }
.jg-key[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Comemoração da vitória: contas caindo */
.confetti { position: fixed; inset: 0; z-index: 35; pointer-events: none; overflow: hidden; }
.confetti i {
  position: absolute; top: -24px; width: 22px; height: 13px; clip-path: var(--bicone);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bead-on) 60%, white), var(--bead-on) 48%, color-mix(in srgb, var(--bead-on) 60%, black));
  animation: jg-fall 1.8s cubic-bezier(.3, .1, .6, 1) forwards;
}
.confetti i.alt { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 60%, white), var(--accent) 48%, color-mix(in srgb, var(--accent) 60%, black)); }
@keyframes jg-fall { to { transform: translateY(110vh) rotate(var(--turn, 360deg)); opacity: .2; } }

@media (max-width: 640px) {
  /* Abas como barra de aplicativo, fixa embaixo, com ícone em cima e nome embaixo */
  .appnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; width: auto; border-radius: 0; border-width: 1px 0 0;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px)); background: var(--surface);
    box-shadow: 0 -16px 28px -20px var(--shade);
  }
  .appnav button { flex-direction: column; gap: 2px; min-height: 48px; border-radius: 14px; font-size: .72rem; }
  .appnav button .ico { width: 22px; height: 22px; }
  .appnav button[aria-pressed="true"] { background: var(--accent-soft); box-shadow: none; }
  #hub { padding-bottom: 84px; }
  /* Celular: tudo um pouco menor, para sobrar tela para o tabuleiro */
  .jogos { gap: 10px; font-size: .94rem; }
  .jogos .btn { min-height: 36px; padding: 6px 12px; font-size: .86rem; }
  /* Marca e botão de música com 44 px de toque, sem engordar a barra */
  .jogos .top { padding: 3px 6px 3px 12px; }
  .jogos .brand { min-height: 44px; }
  .jogos .music-btn { width: 44px; height: 44px; }
  .prof-body p { min-height: 5.6em; }
  /* O botão de níveis vira só o ícone: a faixa e o nível ficam escritos sob o nome do jogo */
  #g-levels { width: 44px; padding: 0; justify-content: center; }
  #g-levels span { display: none; }
  #g-levels .ico { width: 20px; height: 20px; }
  .jogos .bands button { min-height: 32px; font-size: .82rem; }
  .bands { gap: 4px; }
  .win { grid-template-columns: 48px minmax(0, 1fr); padding: 10px 12px; }
  .win .btn { grid-column: 1 / -1; justify-content: center; }
  .win-owl { width: 48px; height: 48px; }
  .win-title { font-size: 1.25rem; }
  .play-head { gap: 6px; }
  .play-head h2 { font-size: 1.05rem; }
  .prof-face { width: 46px; height: 46px; }
  .prof-body p { font-size: .9rem; line-height: 1.4; }
  .prof-body strong { font-size: .82rem; }
  .prof-actions { gap: 4px; margin-top: 2px; }
  .prof-actions .btn, .prof-off { min-height: 46px; }
  .prof-actions .btn { padding: 4px 12px; font-size: .84rem; }
  .prof-actions .btn.primary { padding-left: 4px; }
  .prof-actions .btn.primary .ico { padding: 3px; }
  .board { padding: 8px; border-radius: 16px; gap: 8px; }
  .jg-key { min-height: 40px; font-size: 1.05rem; }
}
@media (prefers-reduced-motion: reduce) {
  .jg-key, .card-bar i { transition: none; }
  .win, .win.party, .win.party .win-owl, .sky i, .jg-cell.is-hint, .prof.talk, .prof.talk .prof-face, .prof-eyes, .jg-spot, #g-prof.aponta { animation: none; }
}

/* O estoque de ícones (símbolos usados por <use>) não entra no cálculo de estilo: são centenas de nós que nunca aparecem */
.sprite { display: none; }

/* Aviso passageiro no pé da tela (Jogos.ui.aviso): texto de mais de uma linha, então cantos menores que a pílula do ábaco */
.toast { max-width: 34rem; border-radius: 16px; font-size: .92rem; line-height: 1.4; text-align: center; text-wrap: pretty; }
#g-retry { margin: 24px auto; min-height: 48px; }

/* Faixa que pede uma ação (Jogos.ui.faixa): fica por cima de tudo, no alto, em qualquer aba e durante o jogo */
.faixa { position: fixed; z-index: 38; top: calc(8px + env(safe-area-inset-top, 0px)); left: 8px; right: 8px; max-width: 560px; margin-inline: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; padding: 10px 12px 10px 16px; border: 1px solid var(--accent); border-radius: 18px; background: var(--surface); box-shadow: 0 22px 36px -18px var(--shade); }
.faixa p { margin: 0; flex: 1 1 180px; font-size: .94rem; line-height: 1.35; text-wrap: pretty; }
.faixa .btn { min-height: 44px; }
/* Depois da aula assistida a ação principal é jogar o nível; seguir adiante fica como segunda opção */
.win #win-again:not([hidden]) ~ #win-next { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: inset 0 1px 0 var(--hi), 0 1px 2px var(--lift); }
.win #win-again:not([hidden]) ~ #win-next .ico { background: var(--shell); }
