:root {
  --sky-top: #5bb8f5;
  --sky-bottom: #c9ecff;
  --ink: #213047;
  --ink-soft: #4d6079;
  --paper: #ffffff;
  --yellow: #ffd23f;
  --green: #3cc76a;
  --green-dark: #23a04f;
  --red: #ff5a5f;
  --blue: #2f8fd8;
  --c1: #ff8a3d;
  --c2: #9b6cff;
  --c3: #ff5fa2;
  --c4: #2fbfa8;
  --c5: #3d9bff;
  --c6: #ffb626;
  --c7: #7bc943;
  --shadow: 0 6px 0 rgba(33, 48, 71, .18), 0 10px 24px rgba(33, 48, 71, .16);
  --radius: 22px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --top-h: 64px;
  --hud-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  color: var(--ink);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

img { -webkit-user-drag: none; user-select: none; pointer-events: none; }

/* Zera o estilo padrao de botao do navegador. O Safari do iPhone/iPad da aos botoes um espaco
   interno lateral grande: nos botoes redondos de 52 px o icone ficava fora do centro (iPad Pro,
   Johnes 08/11). Cada botao do jogo define o proprio padding. */
button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* nuvens decorativas */
#app::before, #app::after {
  content: "";
  position: absolute;
  z-index: -1;
  background: #fff;
  border-radius: 999px;
  opacity: .7;
  filter: blur(1px);
}
#app::before { width: 180px; height: 56px; top: 12%; left: -40px; box-shadow: 60px -24px 0 8px #fff; animation: drift 40s linear infinite; }
#app::after { width: 140px; height: 44px; top: 30%; right: -30px; box-shadow: -50px -18px 0 6px #fff; animation: drift 55s linear infinite reverse; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(40vw); } }

/* ---------- barra de cima ---------- */
#topbar {
  height: var(--top-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}
#topbar .spacer { flex: 1; }

.round-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-size: 26px;
  display: grid;
  place-items: center;
  transition: transform .1s;
}
.round-btn:active { transform: translateY(3px) scale(.96); }
.round-btn[hidden] { display: none; }

/* icone de tela cheia (4 cantos) */
.fs-icon { width: 28px; height: 28px; fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.gear-icon { width: 32px; height: 32px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; }
/* casinha desenhada (o emoji 🏠 fica fora do centro na fonte de emoji do Windows) */
/* casinha (Johnes 10/11: a de contorno com pintura parcial ficou feia) */
.home-icon { width: 32px; height: 32px; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.home-icon .roof { fill: var(--red); }
.home-icon .chimney { fill: #b8573f; }
/* seta "voltar para a Home dos jogos" (so no menu, fora do app instalado) — Johnes, 10/11 */
.back-icon { width: 30px; height: 30px; fill: none; stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.home-icon .wall { fill: var(--yellow); }
.home-icon .door { fill: var(--c1); }
.fs-icon .fs-exit { display: none; }
#btn-fs.is-fs .fs-enter { display: none; }
#btn-fs.is-fs .fs-exit { display: inline; }
#btn-fs.is-fs { background: var(--yellow); }

/* ---------- telas ---------- */
#screen {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 16px 8px;
}

.screen-in { animation: pop-in .35s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }

h1, h2 { margin: 0; text-align: center; }
.big-title {
  font-size: clamp(34px, 8vmin, 64px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 0 var(--blue), 0 8px 14px rgba(0,0,0,.18);
  letter-spacing: .5px;
}
.subtitle { font-size: clamp(18px, 3.6vmin, 26px); font-weight: 800; color: var(--ink); text-align: center; margin: 6px 0 12px; }

.big-btn {
  min-height: 76px;
  padding: 0 34px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: clamp(24px, 5vmin, 34px);
  font-weight: 900;
  box-shadow: 0 7px 0 var(--green-dark), 0 12px 24px rgba(0,0,0,.18);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: transform .1s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--green-dark); }
.big-btn.secondary { background: var(--blue); box-shadow: 0 7px 0 #1d6fae, 0 12px 24px rgba(0,0,0,.18); }

.center-col {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }

/* ---------- menu ---------- */
.menu { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; min-height: 0; }
.lang-list { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.lang-opt { background: #eef3f9; border: 4px solid transparent; border-radius: 999px; padding: 10px 16px; font-weight: 800; font-size: 18px; }
.lang-opt.on { border-color: var(--green); background: #e9fbef; }
/* bandeirinha 4:3 (assets/img/flags_mini, bandeira inteira sem margem) — Johnes, 10/11 */
.lang-opt { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.lang-flag { width: 28px; height: 21px; border-radius: 3px; flex: none; display: block; object-fit: cover; box-shadow: 0 0 0 1px rgba(0, 0, 0, .15); }
.cat-grid {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1100px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  padding: 8px 4px 16px;
  align-content: start;
}
.cat-card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 5px solid var(--cc, var(--c1));
  transition: transform .1s;
  position: relative;
}
.cat-card:active { transform: scale(.96); }
.cat-card .cat-pic { width: 100%; aspect-ratio: 1; display: grid; place-items: center; font-size: 64px; border-radius: 14px; overflow: hidden; }
.cat-card .cat-pic img { width: 100%; height: 100%; object-fit: contain; }
.cat-card .cat-name { font-size: 20px; font-weight: 900; }
.cat-card .cat-sub { font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.cat-card.locked { filter: grayscale(1); opacity: .55; cursor: default; }
.cat-card.locked:active { transform: none; }
.cat-card .soon { position: absolute; top: 8px; right: 8px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px; }
.menu-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; padding: 4px 0 2px; font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.small-btn { background: var(--paper); border-radius: 999px; padding: 10px 18px; font-weight: 900; box-shadow: var(--shadow); font-size: 16px; }

/* ---------- HUD ---------- */
#hud {
  height: var(--hud-h);
  flex: 0 0 auto;
  margin: 0 12px 10px;
  background: rgba(255,255,255,.9);
  border-radius: 999px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 18px;
  font-weight: 900;
  font-size: 20px;
}
#hud[hidden] { display: none; }
.hud-phase { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.pips { display: flex; gap: 4px; }
.pips i { width: 12px; height: 12px; border-radius: 50%; background: #d5dde8; display: block; }
.pips i.on { background: var(--blue); }
.pips i.done { background: var(--green); }
.dots { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: #d5dde8; display: block; transition: background .2s, transform .2s; }
.dots i.done { background: var(--yellow); box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.dots i.now { background: var(--blue); transform: scale(1.25); }
.hud-stars { white-space: nowrap; }
@media (max-width: 420px) {
  #hud { font-size: 17px; padding: 0 12px; }
  .dots i { width: 11px; height: 11px; }
  .pips { display: none; }
}

/* ---------- cards de imagem ---------- */
.pic-card {
  width: var(--size, 160px);
  height: var(--size, 160px);
  background: var(--paper);
  border-radius: var(--radius);
  border: 5px solid var(--cc, var(--c1));
  box-shadow: var(--shadow);
  padding: 4px;
  display: grid;
  place-items: center;
  position: relative;
  transition: transform .12s, border-color .2s, opacity .3s;
}
.pic-card img { width: 100%; height: 100%; object-fit: contain; border-radius: 14px; }
button.pic-card:active { transform: scale(.95); }
.pic-card.right { border-color: var(--green); animation: bounce .5s; }
.pic-card.right::after, .word-opt.right::after { content: "✓"; position: absolute; top: -14px; right: -14px; width: 40px; height: 40px; border-radius: 50%; background: var(--green); color: #fff; font-size: 26px; font-weight: 900; display: grid; place-items: center; box-shadow: var(--shadow); }
.pic-card.wrong, .word-opt.wrong, .slot.wrong { border-color: var(--red); animation: shake .5s; }
.pic-card.wrong::after, .word-opt.wrong::after { content: "✗"; position: absolute; top: -14px; right: -14px; width: 40px; height: 40px; border-radius: 50%; background: var(--red); color: #fff; font-size: 26px; font-weight: 900; display: grid; place-items: center; box-shadow: var(--shadow); }
.pic-card.reveal, .word-opt.reveal, .slot.reveal { border-color: var(--green); box-shadow: 0 0 0 6px rgba(60,199,106,.45), var(--shadow); }
@keyframes bounce { 0%,100% { transform: scale(1); } 40% { transform: scale(1.12); } 70% { transform: scale(.97); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-10px); } 40%,80% { transform: translateX(10px); } }

.grid-box { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; }
.pic-grid { display: grid; gap: var(--gap, 14px); justify-content: center; align-content: center; }

/* ---------- fase 1 ---------- */
.word-btn {
  margin: 4px 0 14px;
  min-height: 72px;
  padding: 6px 30px 6px 18px;
  background: var(--paper);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: clamp(30px, 7vmin, 52px);
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  border: 5px solid var(--yellow);
  transition: transform .1s;
}
.word-btn .spk { width: 52px; height: 52px; border-radius: 50%; background: var(--yellow); display: grid; place-items: center; font-size: 28px; }
.word-btn:active { transform: scale(.96); }
.word-btn.speaking .spk { animation: pulse .6s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.15); } }

/* ---------- fase 2 ---------- */
/* figuras em cima, nomes embaixo, as duas fileiras juntas no centro da tela */
.p2 { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--gap, 14px) * 2.2); }
.p2 .row { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap, 14px); max-width: var(--rowmax, 100%); }
.drag-card { touch-action: none; cursor: grab; }
/* lugar de uma figura/nome (vazio fica invisivel, mas guarda o espaco) */
.p2 .cell { width: var(--size, 160px); height: var(--size, 160px); }
.p2 .cell-slot { height: calc(var(--size, 160px) * 1.28); }
.p2 .enter { animation: pop-in .35s ease-out; }
.drag-card.dragging { opacity: .25; }
/* Copia que segue o dedo. SEM transicao/animacao herdada do card: com a transicao de .12s do
   .pic-card ela tremia e ficava para tras do dedo no iPad (ate 120 movimentos/s; Johnes 08/11).
   A volta para a bandeja define a propria transicao direto no elemento (style). */
.ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; transform-origin: center; box-shadow: 0 18px 40px rgba(0,0,0,.3); transition: none; animation: none; will-change: transform; }
.slot {
  width: var(--size, 160px);
  height: calc(var(--size, 160px) * 1.28);
  border-radius: var(--radius);
  border: 5px dashed var(--ink-soft);
  background: rgba(255,255,255,.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px;
  position: relative;
  transition: background .15s, border-color .15s, transform .15s, opacity .3s;
}
.slot .slot-hole { width: 100%; flex: 1; border-radius: 14px; display: grid; place-items: center; min-height: 0; }
.slot .slot-hole img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; }
/* Nome no espaco da fase 2: ate 2 linhas equilibradas ("amusement / park"); palavra unica longa
   diminui a fonte via fitSlotWord() em phases.js (Johnes, 10/11: texto estourava o card). */
.slot .slot-word { width: 100%; font-size: clamp(20px, calc(var(--size, 160px) * .17), 34px); font-weight: 900; padding: 2px 4px 0; white-space: normal; text-align: center; line-height: 1.05; text-wrap: balance; overflow-wrap: normal; overflow: hidden; }
.slot.hover { background: #fff7cf; border-color: var(--yellow); transform: scale(1.05); }
.slot.filled { border-style: solid; border-color: var(--green); background: #fff; animation: bounce .5s; }
.fade-out { opacity: 0 !important; transform: scale(.8) !important; }

/* ---------- fase 3 ---------- */
.p3 { flex: 1; min-height: 0; width: 100%; max-width: 1000px; display: flex; align-items: center; justify-content: center; gap: clamp(14px, 4vw, 48px); }
.p3 .p3-pic { flex: 1 1 50%; display: grid; place-items: center; min-width: 0; height: 100%; }
.p3 .p3-pic .pic-card { width: min(100%, 52vh); height: auto; aspect-ratio: 1; }
.p3 .p3-words { flex: 1 1 50%; display: flex; flex-direction: column; gap: clamp(8px, 1.8vh, 16px); justify-content: center; min-width: 0; }
.word-opt {
  position: relative;
  min-height: clamp(72px, 9vh, 84px); /* >= 72 px: alvo de toque para crianca (AGENTS.md) */
  border-radius: 20px;
  background: var(--paper);
  border: 5px solid var(--cc, var(--c2));
  box-shadow: var(--shadow);
  font-size: clamp(22px, 5vmin, 40px);
  font-weight: 900;
  padding: 4px 12px;
  transition: transform .1s;
}
.word-opt:active { transform: scale(.97); }
.word-opt.right { border-color: var(--green); background: #e9fbef; animation: bounce .5s; }

/* ---------- vitória / derrota ---------- */
.emoji-big { font-size: clamp(80px, 20vmin, 150px); line-height: 1; }
.wiggle { animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.learned {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, 720px);
}
.learned button { background: var(--paper); border-radius: 16px; box-shadow: var(--shadow); padding: 4px 4px 6px; display: flex; flex-direction: column; align-items: center; font-weight: 900; font-size: clamp(13px, 2.6vmin, 18px); border: 4px solid var(--cc, var(--c1)); }
.learned img { width: 100%; aspect-ratio: 1; object-fit: contain; }
/* (antes: 4 colunas no celular em pe = 3 linhas; com 5 colunas sao 2 linhas e a tela final cabe) */

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 80; background: rgba(20, 30, 50, .55); display: grid; place-items: center; padding: 16px; }
#modal[hidden] { display: none; }
.modal-box { background: var(--paper); border-radius: 26px; max-width: 420px; padding: 24px; text-align: center; box-shadow: var(--shadow); font-size: 19px; font-weight: 700; line-height: 1.4; }
.modal-box h2 { margin-bottom: 8px; font-size: 26px; }
.modal-box .big-btn { margin-top: 16px; min-height: 60px; font-size: 24px; }

/* ---------- abertura (1a carga): cards pulando + barra, sem texto (Johnes, 09/11) ---------- */
#splash {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px;
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  transition: opacity .45s ease;
}
#splash.out { opacity: 0; pointer-events: none; }
.splash-cards { display: flex; gap: clamp(12px, 3vmin, 22px); }
.splash-cards span {
  width: clamp(76px, 18vmin, 120px); height: clamp(76px, 18vmin, 120px);
  display: grid; place-items: center; font-size: clamp(42px, 10vmin, 68px);
  background: var(--paper); border-radius: 22px; border: 5px solid var(--c1); box-shadow: var(--shadow);
  animation: splash-hop 1.2s ease-in-out infinite;
}
.splash-cards span:nth-child(2) { border-color: var(--c2); animation-delay: .2s; }
.splash-cards span:nth-child(3) { border-color: var(--c3); animation-delay: .4s; }
@keyframes splash-hop {
  0%, 55%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-28px) rotate(-6deg); }
  40% { transform: translateY(0) rotate(3deg); }
}
.splash-bar {
  width: min(70vw, 320px); height: 18px; border-radius: 999px;
  background: rgba(255, 255, 255, .6); box-shadow: inset 0 2px 4px rgba(0, 0, 0, .12); overflow: hidden;
}
.splash-bar b {
  display: block; height: 100%; width: 8%; border-radius: 999px;
  background: linear-gradient(90deg, var(--yellow), var(--c1));
  transition: width .3s ease;
}

/* ---------- carregando (3 bolinhas pulando, sem texto) ---------- */
#loading { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; gap: 18px; pointer-events: none; }
#loading[hidden] { display: none; }
#loading i { width: 30px; height: 30px; border-radius: 50%; background: var(--c1); box-shadow: var(--shadow); animation: hop .9s ease-in-out infinite; }
#loading i:nth-child(2) { background: var(--c2); animation-delay: .15s; }
#loading i:nth-child(3) { background: var(--c3); animation-delay: .3s; }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-26px); } }

/* ---------- pontuacao (Johnes, 06/11) ---------- */
/* opcao ja tentada e errada: fica marcada com ✗, apagada e sem toque */
.pic-card.used, .word-opt.used { opacity: .4; pointer-events: none; filter: grayscale(.6); }
/* dica depois de 2 erros: a resposta certa pulsa em verde */
.pic-card.hint, .word-opt.hint, .slot.hint { border-color: var(--green); animation: hint-pulse 1s ease-in-out infinite; }
@keyframes hint-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(60,199,106,.6), var(--shadow); transform: scale(1); }
  50% { box-shadow: 0 0 0 12px rgba(60,199,106,0), var(--shadow); transform: scale(1.05); }
}
.pic-card.hint.right, .word-opt.hint.right, .slot.hint.filled { animation: bounce .5s; }
/* "+3 ⭐" que sobe do acerto */
.star-pop { position: fixed; z-index: 70; pointer-events: none; transform: translate(-50%, -50%); font-family: var(--font); font-size: clamp(28px, 6vmin, 46px); font-weight: 900; color: #fff; text-shadow: 0 3px 0 rgba(33,48,71,.35), 0 0 12px rgba(255,180,0,.9); white-space: nowrap; animation: star-rise 1.2s ease-out forwards; }
@keyframes star-rise {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -220%) scale(1); }
}
.hud-stars.bump { animation: bounce .45s; }
/* nota final: 3 estrelas grandes, apagadas as que nao ganhou */
.grade { display: flex; gap: 10px; font-size: clamp(54px, 13vmin, 96px); line-height: 1; margin: 4px 0; }
.grade span { animation: grade-in .5s ease-out both; }
.grade .off { filter: grayscale(1); opacity: .3; }
@keyframes grade-in { from { opacity: 0; transform: scale(.2) rotate(-40deg); } to { transform: none; } }
.record { font-size: clamp(18px, 3.4vmin, 24px); font-weight: 900; color: var(--ink); margin: 0 0 4px; text-align: center; }
.record.new { color: #b26b00; animation: wiggle 1s ease-in-out 3; }
.subtitle.small { font-size: clamp(15px, 2.8vmin, 20px); margin: 2px 0 6px; }
/* tela final: mais coisa na tela (nota, recorde), entao tudo mais junto, e rola se ainda faltar */
.center-col.win { gap: 8px; justify-content: safe center; overflow-y: auto; min-height: 0; padding-bottom: 8px; }
.win .big-title { font-size: clamp(30px, 6.5vmin, 56px); }
.win .grade { font-size: clamp(44px, 10vmin, 80px); }
.win .subtitle, .win .record { margin: 0; }
.win .learned { width: min(100%, 720px, 68vh); }
.win .btn-row { margin-top: 6px; }
.score-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 22px; }
.win-head, .win-words { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
/* celular em pe: botoes um pouco menores (2 linhas de botao cabem com as palavras) */
@media (max-width: 520px) and (orientation: portrait) {
  .win .big-btn { min-height: 64px; font-size: 24px; padding: 0 24px; }
  .win .btn-row { gap: 10px; }
}

/* ---------- telas baixas: celular deitado (Johnes 08/11, teste WebKit) ----------
   Barras mais finas, Fase 3 com as palavras em grade e tela final em 2 colunas. */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --top-h: 52px; --hud-h: 44px; }
  #topbar { padding: 4px 10px; }
  .round-btn { width: 44px; height: 44px; font-size: 22px; }
  .fs-icon { width: 24px; height: 24px; }
  .gear-icon { width: 27px; height: 27px; }
  .home-icon { width: 26px; height: 26px; }
  #hud { margin-bottom: 6px; font-size: 16px; }
  #screen { padding: 2px 12px 4px; }
  .word-btn { margin: 0 0 6px; }

  .p3 .p3-pic { flex: 0 0 auto; }
  .p3 .p3-pic .pic-card { width: min(40vw, calc(100dvh - var(--top-h) - var(--hud-h) - 40px)); }
  .p3 .p3-words { flex: 1 1 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; align-content: center; }
  .word-opt { min-height: 72px; font-size: clamp(20px, 7vh, 30px); }

  .center-col.win { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); grid-template-areas: "head words" "btns words"; align-items: center; justify-items: center; gap: 8px 20px; }
  .win .win-head { grid-area: head; }
  .win .win-words { grid-area: words; }
  .win .btn-row { grid-area: btns; flex-direction: column; align-items: stretch; gap: 8px; margin: 0; }
  .win .big-btn { min-height: 60px; font-size: 22px; padding: 0 22px; justify-content: center; }
  .win .big-title { font-size: clamp(26px, 9vh, 40px); }
  .win .grade { font-size: clamp(36px, 13vh, 56px); }
  .win .learned { width: min(100%, 520px); gap: 8px; }
  .learned button { font-size: 13px; }
}
.record.new { display: inline-block; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* =====================================================================
   Jogo da Memoria (Johnes, 10/11) — o resto deste arquivo e copia do Vocabulario
   ===================================================================== */
/* opcoes do menu: pares (6/8/10) e jogadores (1/2/3) */
.opt-bar { display: flex; flex-wrap: wrap; gap: 10px 26px; justify-content: center; margin: 6px 0 2px; }
.opt-group { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.55); border-radius: 999px; padding: 6px 8px 6px 16px; }
.opt-label { font-weight: 900; font-size: 17px; color: var(--ink); }
.opt-btns { display: flex; gap: 8px; }
.opt-btn {
  min-width: 72px; min-height: 60px; padding: 0 14px; border-radius: 999px; background: var(--paper);
  box-shadow: var(--shadow); font-size: 26px; font-weight: 900; border: 4px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform .1s;
}
.opt-btn:active { transform: translateY(3px) scale(.96); }
.opt-btn.on { border-color: var(--green); background: #e9fbef; }
.mini-cards { position: relative; width: 22px; height: 26px; display: inline-block; }
.mini-cards i { position: absolute; width: 16px; height: 22px; border-radius: 4px; background: var(--c2); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.mini-cards i:first-child { left: 0; top: 4px; transform: rotate(-10deg); }
.mini-cards i:last-child { left: 6px; top: 0; transform: rotate(8deg); background: var(--c1); }
.avatars { font-size: 26px; letter-spacing: -2px; line-height: 1; }
@media (max-width: 520px) {
  .opt-bar { gap: 8px; }
  .opt-group { padding: 4px 6px 4px 12px; gap: 6px; }
  .opt-label { font-size: 15px; }
  .opt-btn { min-width: 60px; min-height: 54px; padding: 0 10px; font-size: 22px; }
  .avatars { font-size: 22px; }
}

/* tabuleiro */
.board { flex: 1; min-height: 0; width: 100%; display: flex; padding: 10px; border-radius: 26px; transition: box-shadow .3s; }
.board.multi { box-shadow: inset 0 0 0 6px var(--pc); background: color-mix(in srgb, var(--pc) 10%, transparent); }
.mem-grid { perspective: 900px; }
.mcard { width: var(--size, 140px); height: var(--size, 140px); background: none; position: relative; border-radius: var(--radius); }
.mc-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .38s ease; }
.mcard.up .mc-inner { transform: rotateY(180deg); }
.mc-face {
  position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center;
}
/* verso: desenho do tema apagado (sem cor), sobre a cor do tema */
/* verso sempre roxo: cor que nenhum jogador usa (laranja/azul/verde) */
.mc-back { background: var(--c2); border: 5px solid #fff; }
.mc-back::before { content: ""; position: absolute; inset: 7%; border-radius: calc(var(--radius) - 8px); background: rgba(255,255,255,.88); }
.mc-back img { position: relative; width: 74%; height: 74%; object-fit: contain; filter: grayscale(1) contrast(.8); opacity: .45; }
.mc-back span { position: relative; font-size: calc(var(--size, 140px) * .4); filter: grayscale(1); opacity: .45; }
.mc-front { background: var(--paper); border: 5px solid #d9cdf7; transform: rotateY(180deg); padding: 4px 4px 2px; }
.mc-front img { width: 100%; flex: 1; min-height: 0; object-fit: contain; }
.mc-word { font-size: clamp(12px, calc(var(--size, 140px) * .13), 26px); font-weight: 900; line-height: 1.05; text-align: center; padding: 0 2px 2px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard:not(.up):active .mc-inner { transform: scale(.95); }
.mcard.done .mc-front { border-color: var(--green); box-shadow: 0 0 0 5px rgba(60,199,106,.45), var(--shadow); }
.mcard.done { animation: bounce .5s; cursor: default; }
.mcard.miss .mc-front { border-color: var(--red); animation: shake .5s; }

/* barra de baixo: sozinho = pares achados; varios = placar com a vez em destaque */
#hud.solo { justify-content: center; gap: 22px; }
#hud.multi { justify-content: center; gap: clamp(14px, 4vw, 40px); padding: 0 10px; }
.pcell { display: flex; align-items: center; gap: 8px; opacity: .55; transition: transform .2s, opacity .2s; }
.pcell.now { opacity: 1; transform: scale(1.06); }
.pchip { display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px; border-radius: 999px; border: 4px solid transparent; white-space: nowrap; font-size: 18px; }
.pscore { position: relative; display: flex; align-items: center; gap: 4px; padding: 2px 14px; border-radius: 16px; background: #fff; border: 3px solid var(--pc); box-shadow: var(--shadow); font-size: clamp(26px, 4.4vmin, 34px); font-weight: 900; line-height: 1.1; }
.pscore .st { font-size: .75em; }
.pchip .pav { font-size: 26px; line-height: 1; }
.pcell.now .pchip { border-color: var(--pc); background: color-mix(in srgb, var(--pc) 16%, #fff); }
@media (max-width: 520px) { .pchip .pname { display: none; } .pchip { font-size: 17px; } }

/* troca de vez */
.turn-banner {
  /* centralizado SEM transform: a animacao pop-in mexe no transform e o aviso nascia fora do centro */
  position: fixed; inset: 0; margin: auto; width: fit-content; height: fit-content; z-index: 70;
  background: var(--paper); border: 6px solid var(--pc); border-radius: 32px; box-shadow: var(--shadow);
  padding: 18px 30px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  animation: pop-in .18s ease-out; pointer-events: none; transition: opacity .3s;
}
.turn-banner.out { opacity: 0; transition: opacity .18s; }
.turn-banner .tb-av { font-size: clamp(64px, 16vmin, 110px); line-height: 1; animation: wiggle 1s ease-in-out infinite; }
.turn-banner .tb-name { font-size: clamp(20px, 4.4vmin, 30px); font-weight: 900; }

/* placar final com 2-3 jogadores */
.podium { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 6px 0; }
.pod { position: relative; background: var(--paper); border: 5px solid var(--pc); border-radius: 22px; box-shadow: var(--shadow); padding: 10px 16px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 110px; animation: grade-in .5s ease-out both; }
.pod .pav { font-size: 44px; line-height: 1; }
.pod .pname { font-weight: 800; font-size: 16px; }
.pod b { font-size: 24px; }
.pod.win { transform: scale(1.1); background: #fff7cf; }
.pod { margin-top: 14px; }
.pod .crown { position: absolute; top: -34px; font-size: 34px; }
.learned { grid-template-columns: repeat(var(--lcols, 5), minmax(0, 1fr)); }
.win .learned { width: min(100%, calc(var(--lcols, 5) * 144px), calc(var(--lcols, 5) * 13.6vh)); }
/* ultima linha incompleta fica centralizada (grid deixaria a carta sobrando na esquerda) */
.mem-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--gap, 14px);
  width: calc(var(--cols, 4) * var(--size, 140px) + (var(--cols, 4) - 1) * var(--gap, 14px)); }
/* Safari/iPad (teste WebKit 10/11): o backface-visibility nao esconde o lado de tras quando a face
   tem imagem; as cartas apareciam todas abertas e espelhadas. Por isso cada face tambem some/aparece
   no MEIO do giro (metade dos .38 s), o que funciona em qualquer navegador. */
.mc-back { transform: rotateY(0deg); visibility: visible; transition: visibility 0s .19s; }
.mc-front { visibility: hidden; transition: visibility 0s .19s; }
.mcard.up .mc-back { visibility: hidden; }
.mcard.up .mc-front { visibility: visible; }
/* cartas distribuidas no comeco da partida */
.mcard.deal { animation: deal .4s ease-out both; }
@keyframes deal { from { opacity: 0; transform: translateY(-40px) scale(.6) rotate(-8deg); } to { opacity: 1; transform: none; } }
/* abertura = 3 bolinhas pulando, iguais ao #loading */
.splash-dots { display: flex; gap: 18px; }
.splash-dots i { width: 30px; height: 30px; border-radius: 50%; background: var(--c1); box-shadow: var(--shadow); animation: hop .9s ease-in-out infinite; }
.splash-dots i:nth-child(2) { background: var(--c2); animation-delay: .15s; }
.splash-dots i:nth-child(3) { background: var(--c3); animation-delay: .3s; }

/* card "Surpresa": sorteia o tema (Johnes 10/11) */
.random-card .dice { font-size: clamp(56px, 9vmin, 80px); background: linear-gradient(160deg, #fff3b0, #ffd23f); }
.random-card.rolling .dice span { display: inline-block; animation: dice-roll .5s linear infinite; }
@keyframes dice-roll { to { transform: rotate(360deg); } }
.cat-card.picking { transform: scale(1.07); box-shadow: 0 0 0 6px var(--yellow), var(--shadow); z-index: 2; }
.cat-card.picked { animation: bounce .5s; box-shadow: 0 0 0 8px var(--green), var(--shadow); }
/* aviso de quem joga: tabuleiro some e volta rapido (Johnes 10/11) */
.mem-grid .mcard { transition: opacity .14s ease, transform .14s ease; }
.board.hide-cards .mcard { opacity: 0; transform: scale(.85); pointer-events: none; }
/* vez do jogador fixa no alto (Johnes 10/11), no lugar do aviso grande no meio */
#topbar .spacer { display: flex; justify-content: center; min-width: 0; }
.turn-pill {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  background: color-mix(in srgb, var(--pc) 18%, #fff); border: 4px solid var(--pc); border-radius: 999px;
  padding: 2px 16px 2px 6px; box-shadow: var(--shadow); font-weight: 900; font-size: clamp(16px, 2.6vmin, 22px);
  white-space: nowrap; overflow: hidden;
}
.turn-pill .tp-av { font-size: clamp(30px, 5vmin, 40px); line-height: 1.1; }
.turn-pill .tp-name { overflow: hidden; text-overflow: ellipsis; }
.turn-pill.change { animation: turn-pop .45s cubic-bezier(.3,.7,.3,1.4); }
.turn-pill.change .tp-av { animation: wiggle .8s ease-in-out 1; }
@keyframes turn-pop { 0% { transform: scale(.6); opacity: .3; } 100% { transform: scale(1); opacity: 1; } }
@media (max-width: 420px) { .turn-pill { padding-right: 12px; } }
.turn-pill .tp-short { display: none; }
@media (max-width: 480px) { .turn-pill .tp-name { display: none; } .turn-pill .tp-short { display: inline; } }

/* ---- Festa do acerto (Johnes 11/11) ---- */
.fly-star { position: fixed; z-index: 80; pointer-events: none; font-size: clamp(30px, 7vmin, 52px); filter: drop-shadow(0 0 10px rgba(255,200,0,.95)); }
.spark { position: fixed; z-index: 75; pointer-events: none; font-size: clamp(18px, 4vmin, 30px); transform: translate(-50%,-50%); animation: spark-out .9s ease-out forwards; }
@keyframes spark-out {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.3); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.3) rotate(180deg); }
}
.mascot { position: fixed; bottom: 0; z-index: 74; pointer-events: none; display: flex; flex-direction: column; align-items: center; line-height: 1; animation: mascot-up 1.7s cubic-bezier(.3,1.4,.5,1) forwards; }
.mascot.l { left: calc(8px + env(safe-area-inset-left)); }
.mascot.r { right: calc(8px + env(safe-area-inset-right)); }
.m-body { font-size: clamp(54px, 15vmin, 120px); transform-origin: 50% 100%; animation: mascot-dance .5s ease-in-out 3 .25s; }
.m-cheer { font-size: clamp(26px, 7vmin, 52px); animation: bounce .5s ease-in-out 3; }
@keyframes mascot-up {
  0% { transform: translateY(110%); }
  25%, 75% { transform: translateY(0); }
  100% { transform: translateY(120%); }
}
@keyframes mascot-dance { 0%, 100% { transform: rotate(-12deg) scale(1); } 50% { transform: rotate(12deg) scale(1.12); } }

/* placar: pulo, brilho e "+1" subindo */
.hud-stars.gain, .pscore.gain b { display: inline-block; animation: score-pop .7s cubic-bezier(.3,1.6,.5,1); }
.pscore.gain { animation: chip-glow .9s ease-out; }
.hud-stars.gain { position: relative; }

@keyframes score-pop { 0% { transform: scale(1); } 30% { transform: scale(1.7) rotate(-6deg); color: #ffb300; text-shadow: 0 0 14px rgba(255,190,0,.9); } 100% { transform: scale(1); } }
@keyframes chip-glow { 0% { box-shadow: 0 0 0 0 var(--pc, #ffb300); } 40% { box-shadow: 0 0 0 10px transparent, 0 0 26px 6px var(--pc, #ffb300); } 100% { box-shadow: 0 0 0 0 transparent; } }
.plus1 { position: absolute; right: -4px; top: -6px; font-family: var(--font); font-weight: 900; font-size: 1.1em; color: #fff; background: #ff8a3d; border-radius: 999px; padding: 0 .45em; box-shadow: 0 2px 0 rgba(33,48,71,.3); pointer-events: none; animation: plus-rise 1.1s ease-out forwards; }
@keyframes plus-rise {
  0% { opacity: 0; transform: translateY(6px) scale(.4); }
  20% { opacity: 1; transform: translateY(-8px) scale(1.2); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-34px) scale(1); }
}
.dots i.fresh { animation: bounce .6s; }
@media (prefers-reduced-motion: reduce) { .mascot, .spark { animation-duration: .01s; } }
