: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; }
}
/* abertura = 3 bolinhas pulando, iguais ao #loading (Johnes 10/11) */
.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; }

/* ---------- Caca-figura (fase extra, em teste: ?caca) — Johnes 10/11 ---------- */
.caca-top { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 0 0 6px; }
.caca-top .word-btn { margin: 0; }
/* contagem: numero grande dentro de um anel que esvazia (--p de 1 a 0) */
.cd-ring {
  --sz: clamp(64px, 11vmin, 92px);
  width: var(--sz); height: var(--sz); border-radius: 50%; flex: none;
  background: conic-gradient(var(--green) calc(var(--p) * 360deg), #e2e8f0 0);
  display: grid; place-items: center; box-shadow: var(--shadow);
  transition: background .3s;
}
.cd-ring.low { background: conic-gradient(var(--red) calc(var(--p) * 360deg), #e2e8f0 0); }
.cd-num {
  width: 76%; height: 76%; border-radius: 50%; background: var(--paper);
  display: grid; place-items: center; font-size: calc(var(--sz) * .5); font-weight: 900; color: var(--ink);
}
.cd-ring.low .cd-num { color: var(--red); }
.cd-num.beat { animation: cd-beat .35s ease-out; }
@keyframes cd-beat { 0% { transform: scale(1.3); } 100% { transform: scale(1); } }
/* figuras "espalhadas": cada uma um pouco torta */
.caca-card { transform: rotate(var(--rot, 0deg)); }
.caca-card.right { animation: caca-yes .6s ease-out; }
@keyframes caca-yes { 0% { transform: rotate(var(--rot)) scale(1); } 40% { transform: rotate(0) scale(1.18); } 100% { transform: rotate(0) scale(1.05); } }
/* entrada (uma a uma) e carta nova depois do acerto */
.caca-card.deal-in { animation: caca-in .42s cubic-bezier(.3,.7,.3,1.3) both; }
@keyframes caca-in { from { opacity: 0; transform: translateY(-50px) scale(.3) rotate(-25deg); } to { opacity: 1; transform: rotate(var(--rot)); } }
.caca-card.wrong { animation: shake .5s; }
.caca-card.wrong::after { display: none; }
@media (max-height: 500px) and (orientation: landscape) {
  .caca-top { margin: 0 0 2px; }
  .cd-ring { --sz: 56px; }
}
/* tempo esgotado: as outras saem devagar; a certa vai ao meio, grande, piscando (Johnes 10/11) */
.caca-card.leave { opacity: 0; transform: scale(.3) rotate(var(--rot)); pointer-events: none; transition: opacity .35s ease, transform .35s ease; }
.caca-card { transition: opacity .5s ease, transform .5s ease; }
.caca-card.spot { position: relative; z-index: 20; border-color: var(--green); animation: spot-pulse 1s ease-in-out .8s infinite; }
@keyframes spot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(60,199,106,.75), var(--shadow); }
  50% { box-shadow: 0 0 0 14px rgba(60,199,106,0), var(--shadow); filter: brightness(1.08); }
}
.caca-card.fly { opacity: 0; pointer-events: none; z-index: 10; }

/* 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); }

/* engrenagem: tempo do caca-figura (3 a 12 s) */
.secs-row { display: flex; align-items: center; gap: 12px; justify-content: center; font-size: 30px; margin-top: 6px; }
.secs-range { -webkit-appearance: none; appearance: none; width: min(60vw, 260px); height: 14px; border-radius: 999px; background: linear-gradient(90deg, var(--red), var(--yellow), var(--green)); outline: none; }
.secs-range::-webkit-slider-thumb { -webkit-appearance: none; width: 40px; height: 40px; border-radius: 50%; background: #fff; border: 5px solid var(--blue); box-shadow: var(--shadow); cursor: pointer; }
.secs-range::-moz-range-thumb { width: 32px; height: 32px; border-radius: 50%; background: #fff; border: 5px solid var(--blue); cursor: pointer; }
.secs-out { display: block; margin-top: 6px; font-size: 22px; }

/* Caca-figuras como jogo proprio: uma fase so, entao a barra de baixo nao mostra "Fase 1" */
.hud-phase { display: none; }
#hud { justify-content: center; gap: 24px; }
