/* ============================================================
   SILABINHAS — estilos
   Tema azul pastel, layout fixo e previsível (amigável ao TEA)
   ============================================================ */

:root {
  --bg:        #d7ebfb;  /* fundo da página, azul pastel bem claro */
  --card:      #93c2e7;  /* cartão azul do jogo */
  --card-top:  #6ba3d6;  /* barra da palavra */
  --card-foot: #5b93c9;  /* barra de pontos */
  --white:     #ffffff;
  --ink:       #23415c;  /* texto escuro azulado */
  --ink-soft:  #3a5f80;

  --good:      #6cbf72;  /* verde acerto */
  --good-bg:   #e2f3e1;
  --good-card: #7ec983;
  --bad:       #e0796f;  /* vermelho erro */
  --bad-bg:    #f7dcd8;
  --bad-card:  #d8695f;

  --tile:      #eaf4fc;  /* fundo do quadro de imagem */
  --radius:    24px;
  --radius-sm: 16px;
  --shadow:    0 6px 18px rgba(35, 65, 92, .18);

  --tap: 0.15s;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Verdana, Arial, sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body { -webkit-user-select: none; user-select: none; }

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

/* ---------- troca de telas ---------- */
.screen { display: none; width: 100%; max-width: 460px; margin-inline: auto; }
.screen.is-active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- botões genéricos ---------- */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  padding: 14px 22px;
  font-size: 18px;
  transition: transform var(--tap) ease, filter var(--tap) ease;
}
.btn:active { transform: scale(.96); }
.btn-big { font-size: 22px; padding: 18px 26px; width: 100%; }
.btn-primary { background: var(--card-top); color: #fff; }
.btn-light   { background: #fff; color: var(--ink); }
.btn-ghost   { background: rgba(255,255,255,.35); color: var(--ink); }
.btn-danger  { background: var(--bad-card); color: #fff; width: 100%; }

/* ============================================================
   TELA INICIAL
   ============================================================ */
.home-card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 22px 30px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.home-title {
  color: #fff;
  font-size: 30px;
  letter-spacing: 2px;
  margin: 4px 0 0;
  text-shadow: 0 2px 0 rgba(35,65,92,.25);
}
.home-logo {
  width: min(64vw, 220px);
  height: auto;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.mode-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gear {
  position: absolute;
  top: 14px; right: 14px;
  width: 46px; height: 46px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,.30);
  font-size: 22px; line-height: 1;
  cursor: pointer;
}
.gear:active { transform: rotate(30deg); }

/* ============================================================
   TELA DO JOGO
   ============================================================ */
.game-card {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 6px solid transparent;
  transition: border-color .2s ease, background .2s ease;
}
.game-card.correct { border-color: var(--good); background: var(--good-card); }
.game-card.wrong   { border-color: var(--bad);  background: var(--bad-card); }

.word-bar {
  position: relative;
  padding: 22px 16px 14px;
  text-align: center;
}
.word {
  color: #fff;
  font-size: clamp(44px, 13vw, 68px);
  letter-spacing: 3px;
  margin: 0;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(35,65,92,.22);
  overflow-wrap: anywhere;
}
.word-long {
  font-size: clamp(26px, 8vw, 40px);
  line-height: 1.08;
}
.word-xlong {
  font-size: clamp(20px, 6vw, 30px);
  line-height: 1.12;
  letter-spacing: 1px;
}

/* pílula flutuante +1 / -1 */
.feedback-pill {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(.6);
  padding: 6px 18px;
  border-radius: 30px;
  font-size: 34px;
  font-weight: 800;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.feedback-pill.show { animation: pop 1.6s ease forwards; }
.feedback-pill.good { background: var(--good); }
.feedback-pill.bad  { background: var(--bad); }
@keyframes pop {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  75%  { opacity: 1; transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

/* grade de opções de imagem */
.options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 8px 14px 16px;
}
.options.opt-3 { grid-template-columns: repeat(3, 1fr); }

.opt {
  background: var(--tile);
  border: 4px solid #fff;
  border-radius: var(--radius-sm);
  padding: 8px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--tap) ease, border-color var(--tap) ease, box-shadow var(--tap) ease;
}
.opt img {
  width: 100%; height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}
.opt:active { transform: scale(.95); }
.opt.pick-good { border-color: var(--good); box-shadow: 0 0 0 4px var(--good-bg); }
.opt.pick-bad  { border-color: var(--bad);  box-shadow: 0 0 0 4px var(--bad-bg); }
.opt.dim { opacity: .45; }
.options.locked .opt { cursor: default; }

.score-bar {
  background: var(--card-foot);
  color: #fff;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}
.game-card.correct .score-bar { background: var(--good); }
.game-card.wrong   .score-bar { background: var(--bad); }
.score-value { font-size: 24px; }

.corner-home {
  display: block;
  margin: 16px auto 0;
  width: 52px; height: 52px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,.5);
  font-size: 24px; cursor: pointer;
}

/* ============================================================
   FIM DE JOGO
   ============================================================ */
.over-card {
  background: var(--bad-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 22px 28px;
  text-align: center;
  color: #fff;
  display: flex; flex-direction: column; gap: 14px;
}
.over-top { margin: 0; font-size: 18px; opacity: .9; letter-spacing: 1px; }
.over-title { margin: 6px 0; font-size: 40px; letter-spacing: 2px; text-shadow: 0 3px 0 rgba(0,0,0,.15); }
.over-record { margin: 0; font-size: 22px; font-weight: 800; }

/* ============================================================
   RECORDES
   ============================================================ */
.scores-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 22px 28px;
  text-align: center;
  color: #fff;
  display: flex; flex-direction: column; gap: 16px;
}
.scores-title { margin: 0; font-size: 30px; letter-spacing: 2px; }
.scores-list {
  list-style: none;
  counter-reset: rank;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.scores-list li {
  counter-increment: rank;
  background: rgba(255,255,255,.22);
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 22px; font-weight: 700;
  display: flex; align-items: center; gap: 14px;
}
.scores-list li::before {
  content: counter(rank);
  width: 34px; height: 34px;
  flex: 0 0 auto;
  background: #fff; color: var(--ink);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 18px;
}
.scores-list li.top::before { background: #ffd35b; }
.scores-empty { font-size: 20px; line-height: 1.5; }

/* ============================================================
   MODAIS (bloqueio parental + configurações)
   ============================================================ */
.modal {
  position: fixed; inset: 0;
  background: rgba(35,65,92,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
  animation: fade .2s ease;
}
.modal[hidden] { display: none; }
.modal-box {
  background: #fff; color: var(--ink);
  border-radius: var(--radius);
  padding: 24px 22px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.modal-box-wide { max-width: 420px; }
.modal-title { margin: 0; font-size: 24px; text-align: center; }
.modal-sub { margin: 0; text-align: center; color: var(--ink-soft); }
.gate-question { text-align: center; font-size: 34px; font-weight: 800; margin: 4px 0; }
.gate-input {
  font-size: 26px; text-align: center;
  padding: 12px; border: 3px solid var(--card);
  border-radius: 14px; width: 100%;
  font-family: inherit;
}
.gate-input:focus { outline: none; border-color: var(--card-top); }
.gate-error { color: var(--bad); text-align: center; margin: 0; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions .btn { flex: 1; }

/* linhas de configuração */
.set-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid #e6eef5;
}
.set-row:last-of-type { border-bottom: none; }
.set-col { flex-direction: column; align-items: stretch; }
.set-label { font-size: 18px; font-weight: 700; }

/* interruptor liga/desliga */
.toggle {
  width: 62px; height: 34px;
  border: none; border-radius: 20px;
  background: #c9d6e2; cursor: pointer;
  position: relative; transition: background var(--tap) ease;
  flex: 0 0 auto;
}
.toggle[aria-checked="true"] { background: var(--good); }
.toggle-dot {
  position: absolute; top: 3px; left: 3px;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; transition: transform var(--tap) ease;
}
.toggle[aria-checked="true"] .toggle-dot { transform: translateX(28px); }

/* seletor segmentado */
.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1;
  border: 3px solid var(--card);
  background: #fff; color: var(--ink);
  border-radius: 14px; padding: 12px 6px;
  font-family: inherit; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: background var(--tap) ease, color var(--tap) ease;
}
.seg-btn.on { background: var(--card-top); color: #fff; border-color: var(--card-top); }

/* confete */
.confetti {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 40;
  display: none;
}
.confetti.run { display: block; }

/* respeitar preferência de menos animação (sensibilidade sensorial) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .confetti { display: none !important; }
}

/* telas baixas: reduzir espaçamentos */
@media (max-height: 620px) {
  .word { font-size: clamp(38px, 11vw, 54px); }
  .home-logo { width: min(48vw, 170px); }
}
