/* Jogo da Memória e Memória Curta: tabuleiros, cartas, placar e animação de virar. */
body[data-app-view="treino"] .trainer:has(.short-memory-workspace) { display:flex; flex-direction:column; align-items:center; gap:12px; }

.trainer:has(.short-memory-workspace) > .prompt-zone { width:100%; padding:10px; min-height:0; }

body[data-app-view="treino"] .trainer > .short-memory-workspace { display:flex; flex:1; min-height:0; width:100%; flex-direction:column; align-items:center; justify-content:center; gap:12px; }

.short-memory-board { display:grid; grid-template-columns:repeat(var(--memory-columns),minmax(0,1fr)); gap:clamp(12px,3vw,32px); width:min(80%,660px); align-items:center; justify-items:center; }

.short-memory-square { width:100%; max-width:150px; aspect-ratio:1; border:3px solid #94a3b8; border-radius:16px; background:#cbd5e1; touch-action:manipulation; cursor:pointer; padding:0; opacity:1; }

.short-memory-square:disabled { opacity:1; cursor:default; }

.short-memory-square.is-lit { background:var(--memory-color); border-color:var(--memory-color); box-shadow:0 0 0 6px color-mix(in srgb,var(--memory-color) 25%,transparent),0 0 26px color-mix(in srgb,var(--memory-color) 60%,transparent); }

.short-memory-square.is-wrong { border-color:#dc2626; background:#fee2e2; }

.short-memory-square:focus-visible { outline:4px solid #334155; outline-offset:4px; }

.short-memory-board.is-scattered { display:block; position:relative; height:clamp(260px,49dvh,520px); }

.short-memory-board.is-scattered .short-memory-square { position:absolute; left:var(--memory-x); top:var(--memory-y); }

.short-memory-status { min-height:24px; margin:0; font-weight:700; color:#475569; }

.trainer:has(.short-memory-workspace) > .feedback { min-height:24px; margin:0; }

body.training-fullscreen .trainer:has(.short-memory-workspace) { height:100dvh; padding:56px 16px 16px; }

.module-grid .memory-cover { display:flex; align-items:center; justify-content:center; gap:12px; background:#fff; padding:24px; }

.memory-cover i { width:25%; aspect-ratio:1; border-radius:10px; background:#2563eb; }

.memory-cover i:nth-child(2) { background:#ef4444; box-shadow:0 0 18px #fca5a5; }

.memory-cover i:nth-child(3) { background:#22c55e; }

/* Fases avançadas: peças maiores e tabuleiro ocupando a área disponível. */
.short-memory-board.is-scattered {
  width: min(100%, 1040px);
  height: clamp(280px, 55dvh, 650px);
}

.short-memory-board.is-scattered .short-memory-square {
  width: 24%;
  max-width: none;
  height: 27%;
  max-height: none;
  aspect-ratio: auto;
}

.short-memory-board.is-scattered .short-memory-square:not([data-shape]),
.short-memory-board.is-scattered .short-memory-square[data-shape="quadrado"] {
  width: min(24%, 14.85dvh);
  height: auto;
  aspect-ratio: 1;
}

.short-memory-square[data-shape="círculo"] { border-radius:50%; width:min(24%,14.85dvh); height:auto; aspect-ratio:1; }

.short-memory-square[data-shape="oval"] { border-radius:50%; }

.short-memory-square[data-shape="triângulo"] { clip-path:polygon(50% 0,100% 100%,0 100%); border-radius:0; }

.short-memory-square[data-shape="losango"] { clip-path:polygon(50% 0,100% 50%,50% 100%,0 50%); border-radius:0; }

.short-memory-square[data-shape="trapézio"] { clip-path:polygon(22% 0,78% 0,100% 100%,0 100%); border-radius:0; }

.short-memory-square[data-shape="hexágono"] { clip-path:polygon(25% 0,75% 0,100% 50%,75% 100%,25% 100%,0 50%); border-radius:0; }

@media(max-height:600px) {
 .short-memory-board.is-scattered { height:48dvh; min-height:180px; }
}

.short-memory-board.is-scattered .short-memory-square[data-shape="círculo"] {
  width: min(24%, 14.85dvh);
  height: auto;
  aspect-ratio: 1;
}

body[data-app-view="treino"] .trainer:has(.memory-game-workspace) { display:flex; flex-direction:column; align-items:center; gap:8px; overflow:auto; }

.trainer:has(.memory-game-workspace) > .prompt-zone { min-height:0; padding:8px; width:100%; }

body[data-app-view="treino"] .trainer > .memory-game-workspace { width:100%; flex:1; min-height:0; flex-direction:column; gap:10px; }

.memory-scoreboard { display:flex; }

.memory-player { flex:1; border-radius:14px; padding:12px; text-align:center; font-weight:800; opacity:.45; border:3px solid transparent; }

.memory-player.player-0 { background:#dbeafe; color:#1d4ed8; }

.memory-player.player-1 { background:#fee2e2; color:#b91c1c; }

.memory-player.is-active { opacity:1; border-color:currentColor; box-shadow:0 0 14px currentColor; }

.memory-turn { margin:0; font-weight:700; min-height:24px; }

.memory-game-board { display:grid; gap:clamp(4px,1vw,10px); flex-shrink:0; }

.memory-game-card { min-width:0; min-height:0; display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:minmax(0,1fr); place-items:center; border-radius:10px; font-size:clamp(18px,3vw,32px); cursor:pointer; touch-action:manipulation; }

.memory-game-card img { width:100%; height:100%; min-width:0; min-height:0; object-fit:contain; }

.memory-game-card.is-matched { border-color:#22c55e; opacity:1; }

.memory-game-card.is-neutral { background:#fef9c3; border-color:#fde68a; color:#ca8a04; opacity:1; }

.memory-game-card:disabled { opacity:1; }

.memory-game-card:focus-visible { outline:3px solid #2563eb; outline-offset:1px; }

body.training-fullscreen .trainer:has(.memory-game-workspace) { min-height:100dvh; height:auto; padding:55px 14px 14px; }

body[data-active-module="memoryGame"] .session-panel #soundToggle,
body[data-active-module="memoryGame"] .session-panel .panel-heading { display:none; }

/* Jogo da memória: tabuleiro escuro e distribuição para tablets na horizontal. */
body[data-app-view="treino"] .trainer:has(.memory-game-workspace) {
  background:#111827;
  color:#f8fafc;
  border-color:#334155;
}

body[data-app-view="treino"] .trainer:has(.memory-game-workspace) > .prompt-zone {
  background:#1e293b;
  border-color:#334155;
  color:#f8fafc;
}

.trainer:has(.memory-game-workspace) #promptText,
.memory-game-workspace .memory-turn { color:#f8fafc; }

.memory-game-workspace > .ghost-button { color:#f8fafc; background:#334155; border-color:#64748b; }

.memory-game-board {
  --memory-columns:var(--memory-grid);
  grid-template-columns:repeat(var(--memory-columns),minmax(0,1fr));
}

.memory-game-card { color:#e2e8f0; border-color:#64748b; }

.memory-game-card.is-open { color:#334155; }

@media (orientation:landscape) {
  body[data-app-view="treino"] .trainer > .memory-game-workspace { gap:8px; }

  

  .memory-player { padding:8px 12px; }

  .memory-game-board {
    gap:clamp(4px,.7vw,8px);
  }

  

  

  

  

  

  
}

/* Placar maior e grades completas, sem casas neutras ou linhas incompletas. */
.memory-scoreboard { width:100%; max-width:1100px; gap:16px; }

.memory-scoreboard .memory-player {
  min-height:76px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px 20px;
  font-size:clamp(20px,2.3vw,32px);
  line-height:1.2;
  box-sizing:border-box;
}

.memory-game-board .is-neutral { display:none; }

.memory-game-board[data-size="4"] { --memory-columns:4; --memory-rows:4; }

.memory-game-board[data-size="5"] { --memory-columns:4; --memory-rows:6; }

.memory-game-board[data-size="6"] { --memory-columns:6; --memory-rows:6; }

.memory-game-board[data-size="7"] { --memory-columns:6; --memory-rows:8; }

.memory-game-board[data-size="8"] { --memory-columns:8; --memory-rows:8; }

body[data-app-view="treino"] .trainer > .memory-game-workspace {
  display:grid;
  grid-template-columns:minmax(0,1fr);
  grid-template-rows:auto auto minmax(0,1fr) auto;
  align-items:stretch;
  justify-items:center;
}

.memory-game-board {
  width:100%;
  height:100%;
  min-height:240px;
  grid-template-rows:repeat(var(--memory-rows),minmax(0,1fr));
}

.memory-game-card { aspect-ratio:auto; width:100%; height:100%; }

.memory-turn { text-align:center; }

body.training-fullscreen .trainer:has(.memory-game-workspace) { height:100dvh; min-height:100dvh; }

@media(orientation:landscape) {
 .memory-game-board[data-size="4"] { --memory-columns:4; --memory-rows:4; }

 .memory-game-board[data-size="5"] { --memory-columns:6; --memory-rows:4; }

 .memory-game-board[data-size="6"] { --memory-columns:9; --memory-rows:4; }

 .memory-game-board[data-size="7"] { --memory-columns:8; --memory-rows:6; }

 .memory-game-board[data-size="8"] { --memory-columns:8; --memory-rows:8; }

 .memory-game-board { width:100%; }
}

/* Virada de carta: mantém as duas faces montadas durante a animação. */
.memory-game-card {
  perspective:900px;
  overflow:visible;
  padding:0;
  background:transparent;
  border:0;
}

.memory-card-inner {
  display:block;
  position:relative;
  width:100%;
  height:100%;
  min-height:0;
  transform-style:preserve-3d;
  transition:transform 380ms ease-in-out;
}

.memory-game-card.is-open .memory-card-inner { transform:rotateY(180deg); }

.memory-card-face {
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  grid-template-columns:minmax(0,1fr);
  grid-template-rows:minmax(0,1fr);
  padding:5px;
  box-sizing:border-box;
  border:2px solid #64748b;
  border-radius:10px;
  overflow:hidden;
  backface-visibility:hidden;
  -webkit-backface-visibility:hidden;
}

.memory-card-back { background:#334155; color:#e2e8f0; }

.memory-card-front { transform:rotateY(180deg); background:#fff; }

.memory-game-card.is-open,
.memory-game-card.is-matched { background:transparent; border:0; }

.memory-game-card.is-matched .memory-card-front { background:#ecfdf5; border-color:#22c55e; }
