/* ==========================================================================
   Tela do jogo da memória — layout completo (desktop e celular).
   Todas as regras ficam sob body.is-game para vencer as regras gerais do site.
   ========================================================================== */

body.is-game { --gap: 12px; --pad: 14px; }

/* ---------- Estrutura da página ---------- */
body.is-game .game {
  box-sizing: border-box; width: 100%; max-width: 1200px; margin: 0 auto;
  padding: 14px 16px 22px;
  display: flex; flex-direction: column; gap: var(--gap);
  position: relative;
}
body.is-game .game > * { min-width: 0; }

/* ---------- Cabeçalho: perfil e indicadores ---------- */
body.is-game .hud { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; }
body.is-game .hud-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 22px; box-sizing: border-box; min-width: 0; }
body.is-game .hud-card--player { background: #fff; border: 1px solid var(--line); box-shadow: 0 1px 0 var(--line), 0 14px 28px -22px oklch(20% 0.05 152 / .5); }
body.is-game .hud-card--guest { background: linear-gradient(135deg, var(--green-900), var(--green-700)); color: #fff; border: 0; padding: 12px 16px; }
body.is-game .hud-card--guest b { display: block; font-size: 15px; }
body.is-game .hud-card--guest span { display: none; }
body.is-game .hud-card__cta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
body.is-game .hud-card__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
body.is-game .hud-card__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
body.is-game .hud-card__top b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.is-game .hud-card__meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; flex-wrap: wrap; }
body.is-game .hud-avatar { width: 42px; height: 42px; font-size: 18px; flex-shrink: 0; }
body.is-game .hud-xp { height: 7px; margin: 0; }
body.is-game .hud-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
body.is-game .hud-tile { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; box-shadow: 0 1px 0 var(--line); min-width: 0; }
body.is-game .hud-tile b { font-size: 20px; line-height: 1.1; font-variant-numeric: tabular-nums; }
body.is-game .hud-tile span { margin-top: 3px; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
body.is-game .hud-tile--points { background: var(--green-900); border-color: var(--green-900); }
body.is-game .hud-tile--points b { color: var(--yellow-300); }
body.is-game .hud-tile--points span { color: #bcd4c3; }
body.is-game .hud-tile--combo.is-hot { background: var(--yellow-300); border-color: var(--yellow-400); }

/* ---------- Título da fase e ferramentas ---------- */
body.is-game .game__phase { display: flex; flex-direction: column; gap: 10px; margin: 0; }
body.is-game .game__phase > div:first-child { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; min-width: 0; }
body.is-game .game__phase .eyebrow { margin: 0; }
body.is-game .game__title { margin: 0; font-size: clamp(20px, 2.6vw, 28px); line-height: 1.15; white-space: normal; }
body.is-game .game__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
body.is-game .powers { display: flex; flex-wrap: wrap; gap: 8px; }
body.is-game .power { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 5px 8px 5px 10px; border-radius: var(--pill); border: 1px solid var(--line); background: #fff; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; white-space: nowrap; box-sizing: border-box; }
body.is-game .power span { font-size: 15px; line-height: 1; }
body.is-game .power b { font-weight: 800; }
body.is-game .power em { font-style: normal; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--pill); background: var(--green-100); color: var(--green-700); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
body.is-game .power:disabled { opacity: .55; cursor: not-allowed; }
body.is-game .power:disabled em { background: var(--soft); color: var(--ink-3); }
body.is-game .chip { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 6px 12px; border-radius: var(--pill); border: 1px solid var(--line); background: #fff; font: inherit; font-size: 13px; font-weight: 800; color: var(--ink-2); cursor: pointer; white-space: nowrap; box-sizing: border-box; }
body.is-game .chip[aria-pressed='false'] { color: var(--ink-3); text-decoration: line-through; }

/* ---------- Progresso ---------- */
body.is-game .game__progress { width: 100%; height: 6px; margin: 0; border-radius: 6px; background: var(--green-100); overflow: hidden; }
body.is-game .game__progress > div { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--green-600), var(--yellow-400)); transition: width .6s var(--ease-out); }

/* ---------- Área principal: mesa + painel ---------- */
body.is-game .game__stage { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
body.is-game .game__table { position: relative; width: 100%; min-width: 0; display: flex; align-items: center; justify-content: center; container-type: inline-size; }

body.is-game .game__board {
  --size: min(180px, calc((100cqw - 2 * var(--pad) - (var(--cols) - 1) * var(--gap)) / var(--cols)));
  position: relative; isolation: isolate; box-sizing: border-box;
  width: 100%; padding: var(--pad); border-radius: 28px;
  display: grid; grid-template-columns: repeat(var(--cols), var(--size));
  justify-content: center; align-content: center; gap: var(--gap);
  background: radial-gradient(ellipse 85% 75% at 50% 25%, oklch(45% 0.1 152), oklch(30% 0.08 152) 62%, oklch(22% 0.06 152));
  box-shadow: 0 0 0 5px oklch(76% 0.1 88), 0 0 0 8px oklch(38% 0.07 85), 0 26px 50px -24px oklch(14% 0.05 152 / .8), inset 0 2px 0 oklch(100% 0 0 / .12);
}
body.is-game .game__board::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; opacity: .14; mix-blend-mode: overlay; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E"); }
body.is-game .game__board::after { content: ''; position: absolute; inset: 8px; z-index: -1; border-radius: 22px; pointer-events: none; border: 1.5px dashed oklch(89% 0.08 95 / .3); }

/* Cartas */
body.is-game .mcard { position: relative; width: 100%; aspect-ratio: 3 / 4; height: auto; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 14px; perspective: 900px; box-sizing: border-box; animation: none; }
body.is-game .mcard:disabled { cursor: default; }
body.is-game .mcard__inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.3, .7, .25, 1), opacity .35s; }
body.is-game .mcard.is-open .mcard__inner { transform: rotateY(180deg); }
body.is-game .mcard.is-matched .mcard__inner { opacity: .6; }
body.is-game .mcard__face { position: absolute; inset: 0; border-radius: 14px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; box-sizing: border-box; }
body.is-game .mcard__back {
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 50% 50%, oklch(89% 0.08 95 / .2) 0 18%, transparent 19%),
    repeating-linear-gradient(45deg, oklch(100% 0 0 / .06) 0 2px, transparent 2px 12px),
    repeating-linear-gradient(-45deg, oklch(100% 0 0 / .05) 0 2px, transparent 2px 12px),
    linear-gradient(150deg, oklch(44% 0.1 152), oklch(26% 0.07 152));
  border: 2px solid oklch(89% 0.08 95 / .85);
  box-shadow: 0 10px 20px -10px oklch(10% 0.04 152 / .9);
}
body.is-game .mcard__back::after { content: ''; position: absolute; inset: 7px; border-radius: 10px; border: 1.5px solid oklch(89% 0.08 95 / .45); }
body.is-game .mcard__mark { width: 46%; aspect-ratio: 1; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: radial-gradient(circle, oklch(31% 0.07 152), oklch(22% 0.06 152)); border: 2px solid oklch(89% 0.08 95 / .7); color: var(--yellow-300); font-weight: 800; font-size: calc(var(--size) * .2); line-height: 1; }
body.is-game .mcard__front {
  transform: rotateY(180deg); display: flex; flex-direction: column; gap: 6px; padding: 6px;
  background: linear-gradient(180deg, oklch(99% 0.01 95), oklch(96% 0.025 95));
  border: 2px solid oklch(89% 0.08 95);
  box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px oklch(88% 0.04 150), 0 12px 22px -14px oklch(15% 0.04 152 / .8);
}
body.is-game .mcard__front .media { flex: 1 1 auto; min-height: 0; width: 100%; height: auto; border-radius: 9px; object-fit: cover; }
body.is-game .mcard__front .mcard__label {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 2.4em; margin: 0 -6px -6px; padding: 6px 6px; border-radius: 0 0 11px 11px;
  background: var(--green-900); color: var(--yellow-300);
  font-size: 11px; font-weight: 800; line-height: 1.2; text-transform: uppercase; letter-spacing: .02em;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
body.is-game .mcard.is-matched .mcard__front { box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px var(--yellow-400), 0 0 0 3px var(--yellow-400), 0 0 22px 4px oklch(89% 0.08 95 / .55); }
body.is-game .mcard.is-wrong .mcard__inner { animation: shake .4s .2s; }

/* ---------- Painel do item ---------- */
body.is-game .info-panel { position: relative; display: flex; flex-direction: column; min-height: 0; background: #fff; border: 1px solid var(--line); border-radius: 26px; overflow: hidden; box-shadow: 0 1px 0 var(--line), 0 20px 40px -28px oklch(20% 0.05 152 / .4); }
body.is-game .info-panel[hidden] { display: none; }
body.is-game .info-panel__empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 28px; text-align: center; color: var(--ink-2); }
body.is-game .info-panel__empty b { font-size: 17px; color: var(--ink); }
body.is-game .info-panel__empty span { font-size: 14px; line-height: 1.5; max-width: 240px; }
body.is-game .info-panel__icon { width: 64px; height: 64px; border-radius: 50%; background: var(--green-100); display: flex; align-items: center; justify-content: center; font-size: 28px; }
body.is-game .info-panel.is-empty .info-panel__content { display: none; }
body.is-game .info-panel:not(.is-empty) .info-panel__empty { display: none; }
body.is-game .info-panel__content { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body.is-game .info-panel__media { position: relative; flex: 1 1 auto; min-height: 220px; aspect-ratio: 3 / 4; max-height: 460px; background: var(--green-50); overflow: hidden; }
body.is-game .info-panel__media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
body.is-game .info-panel__media .media--empty { position: absolute; inset: 0; }
body.is-game .info-panel__body { flex: 0 0 auto; padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; }
body.is-game .info-panel__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
body.is-game .info-panel__count { font-size: 11px; font-weight: 800; color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; }
body.is-game .info-panel__title { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
body.is-game .info-panel__desc { margin: 0; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
body.is-game .info-panel__desc[hidden] { display: none; }
body.is-game .info-panel__video { width: 100%; border-radius: 14px; background: #000; aspect-ratio: 16 / 9; }
body.is-game .info-panel__video[hidden] { display: none; }

/* ---------- Rodapé de status ---------- */
body.is-game .game__status { min-height: 20px; margin: 0; font-size: 13px; font-weight: 800; color: var(--green-700); text-align: center; position: static; }
body.is-game .game__status:empty { display: none; }
body.is-game .game__status.is-error { color: oklch(50% 0.17 27); }

/* ==========================================================================
   Desktop (≥ 960px): cabeçalho no topo, mesa à esquerda e painel à direita.
   A página ocupa a altura da janela, sem rolagem.
   ========================================================================== */
@media (min-width: 960px) {
  body.is-game .game {
    height: calc(100svh - 84px - 6px); min-height: 640px;
    display: grid; grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "hud hud" "phase phase" "progress progress" "table panel" "status status";
    column-gap: 22px; row-gap: 12px; padding: 16px 24px 14px;
  }
  body.is-game .hud { grid-area: hud; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 12px; }
  body.is-game .hud-card--player { height: 100%; }
  body.is-game .game__phase { grid-area: phase; flex-direction: row; justify-content: space-between; align-items: center; gap: 16px; }
  body.is-game .game__tools { flex-wrap: nowrap; flex-shrink: 0; }
  body.is-game .game__progress { grid-area: progress; }
  body.is-game .game__stage { display: contents; }
  body.is-game .game__table { grid-area: table; height: 100%; min-height: 0; container-type: size; }
  body.is-game .game__board {
    width: 100%; height: 100%;
    --size: min(190px, calc((100cqw - 2 * var(--pad) - (var(--cols) - 1) * var(--gap)) / var(--cols)), calc((100cqh - 2 * var(--pad) - (var(--rows) - 1) * var(--gap)) / var(--rows) * 0.75));
    justify-content: space-evenly; align-content: space-evenly;
    --pad: clamp(14px, 1.8vw, 24px); --gap: clamp(10px, 1.4vw, 16px);
  }
  body.is-game .info-panel { grid-area: panel; height: 100%; min-height: 0; }
  body.is-game .info-panel__media { flex: 1 1 auto; max-height: none; aspect-ratio: auto; }
  body.is-game .game__status { grid-area: status; text-align: left; }
  body.is-game .power b { display: inline; }
}
@media (min-width: 960px) and (max-width: 1240px) {
  body.is-game .power b { display: none; }
}

/* ==========================================================================
   Celular / tablet (< 960px): tudo em uma coluna, na ordem de leitura.
   ========================================================================== */
@media (max-width: 959px) {
  body.is-game .game { padding: 12px 14px 22px; gap: 14px; }
  body.is-game .hud-stats { gap: 8px; }
  body.is-game .hud-tile { padding: 8px 4px; border-radius: 16px; }
  body.is-game .hud-tile b { font-size: 18px; }
  body.is-game .game__phase { gap: 12px; }
  body.is-game .game__tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  body.is-game .powers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; grid-column: 1 / -1; }
  body.is-game .power { justify-content: center; min-width: 0; padding: 6px 8px; }
  body.is-game .power b { display: none; }
  body.is-game .game__tools .chip { justify-content: center; }
  body.is-game .game__stage { gap: 16px; }
  body.is-game .game__table { container-type: inline-size; }
  body.is-game .game__board {
    --pad: 12px; --gap: 10px;
    --size: min(200px, calc((100cqw - 2 * var(--pad) - (var(--cols) - 1) * var(--gap)) / var(--cols)));
  }
  body.is-game .info-panel { min-height: 0; }
  body.is-game .info-panel__media { aspect-ratio: 4 / 3; max-height: 340px; min-height: 0; }
}

/* Regras antigas de painel fixo não se aplicam aqui (o painel fica no fluxo da grade). */
body.is-game .info-panel { top: auto; left: auto; right: auto; bottom: auto; position: relative; }

/* Celular: ferramentas e painel ocupam a largura toda, alinhados às margens da tela. */
@media (max-width: 959px) {
  body.is-game .game__tools { width: 100%; }
  body.is-game .game__stage > * { width: 100%; box-sizing: border-box; }
  body.is-game .info-panel { width: 100%; max-width: none; }
}

/* ---------- Verso: logo do site ---------- */
body.is-game .mcard__mark { width: 50%; aspect-ratio: 1; padding: 0; overflow: hidden; background: #fff; border: 2px solid oklch(89% 0.08 95); box-shadow: 0 4px 12px -4px oklch(10% 0.04 152 / .8); }
body.is-game .mcard__mark img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Carta acertada x carta fechada ----------
   Fechada: verso escuro, sem nada na frente.
   Acertada: frente clara, moldura verde-dourada, selo ✓ e título em verde. */
body.is-game .mcard.is-matched .mcard__inner { opacity: 1; }
body.is-game .mcard.is-matched .mcard__back { filter: saturate(.5) brightness(.8); }
body.is-game .mcard.is-matched .mcard__front {
  background: linear-gradient(180deg, oklch(98% 0.03 150), oklch(93% 0.06 150));
  border: 3px solid var(--green-500);
  box-shadow: inset 0 0 0 3px #fff, 0 0 0 3px oklch(84% 0.1 92), 0 0 22px 2px oklch(84% 0.1 92 / .55);
}
body.is-game .mcard.is-matched .mcard__front .mcard__label { background: var(--green-600); color: #fff; }
body.is-game .mcard.is-matched .mcard__front::after {
  content: '✓'; position: absolute; top: 7px; right: 7px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--green-600); color: #fff; font-size: 15px; font-weight: 900; line-height: 1;
  border: 2px solid #fff; box-shadow: 0 4px 10px -3px oklch(20% 0.05 152 / .6);
}
body.is-game .mcard.is-matched { cursor: default; }
body.is-game .mcard.is-matched:hover .mcard__front { transform: rotateY(180deg); }

/* ==========================================================================
   Alinhamento do cabeçalho da fase (desktop): rótulo acima do título,
   ferramentas à direita, todos centralizados verticalmente no mesmo bloco.
   ========================================================================== */
@media (min-width: 960px) {
  body.is-game .game__phase { align-items: center; }
  body.is-game .game__phase > div:first-child { flex-direction: column; align-items: flex-start; gap: 4px; }
  body.is-game .game__phase .eyebrow { font-size: 11px; line-height: 1; }
  body.is-game .game__title { line-height: 1.1; }
}

/* Sem foto, o nome do item já aparece na faixa de baixo: não repetir na área da imagem (evita cortes e sobreposição com o selo). */
body.is-game .mcard__front .media--empty > span { display: none; }
body.is-game .mcard__front .media--empty { background: repeating-linear-gradient(135deg, oklch(94% 0.012 145) 0 10px, oklch(91% 0.014 145) 10px 20px); }

/* Respiro entre a barra de progresso e a mesa (desktop e celular). */
body.is-game .game__progress { margin-bottom: 12px; }

/* ==========================================================================
   Estilo indígena amazônico: grafismo geométrico, cores da terra e esteira trançada.
   Motivos genéricos (zigue-zague, losangos, pontos), sem símbolos sagrados de um povo.
   ========================================================================== */
body.is-game {
  --ind-urucum: oklch(52% 0.17 35);      /* urucum */
  --ind-jenipapo: oklch(24% 0.04 50);    /* jenipapo */
  --ind-ochre: oklch(74% 0.11 78);       /* argila/ocre */
  --ind-cream: oklch(96% 0.025 85);      /* fibra clara */
  --ind-leaf: oklch(56% 0.12 150);       /* folha de bananeira */
}

/* Moldura da mesa: faixa de grafismo em jenipapo, com filete de urucum */
body.is-game .game__table {
  box-sizing: border-box; padding: 12px; border-radius: 30px;
  background-color: var(--ind-jenipapo);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath d='M0 10 L10 0 L20 10 L30 0 L40 10 M0 30 L10 20 L20 30 L30 20 L40 30' stroke='%23d9a441' stroke-width='2.5' fill='none'/%3E%3Cpath d='M0 40 L10 30 M20 40 L30 30' stroke='%23b8432b' stroke-width='2' fill='none'/%3E%3Ccircle cx='20' cy='20' r='2.2' fill='%23f3e6c8'/%3E%3C/svg%3E");
  box-shadow: 0 0 0 3px var(--ind-urucum), 0 0 0 5px var(--ind-ochre), 0 28px 50px -26px oklch(14% 0.05 50 / .85);
}

/* Tabuleiro: esteira de palha trançada, cor de fibra */
body.is-game .game__board {
  background-color: var(--ind-cream);
  background-image:
    repeating-linear-gradient(0deg, oklch(70% 0.09 78 / .32) 0 3px, transparent 3px 9px),
    repeating-linear-gradient(90deg, oklch(70% 0.09 78 / .32) 0 3px, transparent 3px 9px),
    linear-gradient(160deg, oklch(89% 0.06 85), oklch(80% 0.08 80));
  box-shadow: inset 0 0 0 2px oklch(60% 0.09 70 / .5), inset 0 0 40px oklch(60% 0.09 70 / .25);
}
body.is-game .game__board::before { display: none; }
body.is-game .game__board::after {
  inset: 10px; border-radius: 20px; border: 2px dashed var(--ind-urucum); opacity: .45;
}

/* Cartas: só a borda recebe a textura amazônica (faixa de zigue-zague em urucum sobre fibra clara).
   Miolo, verso e estados de acerto seguem o padrão original. */
body.is-game .mcard__face {
  border: 6px solid transparent;
  border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Crect width='24' height='24' fill='%23f3e6c8'/%3E%3Cpath d='M0 16 L6 8 L12 16 L18 8 L24 16' stroke='%23b8432b' stroke-width='2.5' fill='none'/%3E%3Cpath d='M0 4 L4 0 M12 4 L16 0 M20 4 L24 0' stroke='%23d9a441' stroke-width='1.5' fill='none'/%3E%3Ccircle cx='6' cy='21' r='1.4' fill='%23183d2b'/%3E%3Ccircle cx='18' cy='21' r='1.4' fill='%23183d2b'/%3E%3C/svg%3E") 8 round;
}
