*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background-color: #f7f9fc;
  color: #2c3e50;
  margin: 0;
  padding: 0;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

header {
  background-color: #3f51b5;
  color: white;
  padding: 15px;
  text-align: center;
  border-bottom: 4px solid #283593;
}
header h1 { margin: 0; font-size: 22px; font-weight: bold; }
header p { margin: 5px 0 0 0; font-size: 13px; opacity: 0.9; }
header .tema-dia { font-size: 12px; margin-top: 6px; font-style: italic; opacity: 0.95; }

.nav-tabs {
  display: table;
  width: 100%;
  background: #fff;
  border-bottom: 2px solid #e0e0e0;
}
.tab-link {
  display: table-cell;
  text-align: center;
  padding: 14px 5px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  color: #757575;
  border-bottom: 3px solid transparent;
  min-height: 44px;
}
.tab-link.active {
  color: #3f51b5;
  border-bottom: 3px solid #3f51b5;
  background-color: #f5f5f5;
}

.periodo-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.periodo-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  background: #eee;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  font-size: 13px;
  cursor: pointer;
  min-height: 44px;
}
.periodo-tab.active { background: #673ab7; color: white; }

.container {
  max-width: 750px;
  margin: 15px auto;
  padding: 0 10px 30px;
}

.card {
  background: white;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  padding: 15px;
  margin-bottom: 15px;
}
h2 {
  color: #283593;
  font-size: 16px;
  margin-top: 0;
  border-left: 4px solid #3f51b5;
  padding-left: 8px;
}

.progress-bar-wrap {
  background: #e0e0e0;
  border-radius: 10px;
  height: 10px;
  margin: 8px 0;
  overflow: hidden;
}
.progress-bar {
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  height: 100%;
  border-radius: 10px;
  transition: width 0.4s;
}
.progress-label { font-size: 12px; color: #666; }

.grid-words { display: block; text-align: center; }
.word-btn {
  display: inline-block;
  background-color: #f1f3f5;
  border: 1px solid #ced4da;
  border-radius: 20px;
  padding: 12px 18px;
  margin: 4px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
  min-height: 44px;
}
.word-btn.clicked { background-color: #4caf50; color: white; border-color: #388e3c; }

.badge-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 5px 0;
}
.badge {
  width: 72px;
  text-align: center;
  opacity: 0.25;
  transition: opacity 0.5s;
}
.badge.unlocked { opacity: 1; }
.badge-icon { font-size: 28px; display: block; }
.badge-text { font-size: 10px; font-weight: bold; margin-top: 4px; }

.day-panel { display: none; }
.day-panel.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.session-block {
  background: #fafafa;
  border-radius: 6px;
  padding: 10px;
  margin-top: 10px;
  border-left: 3px solid #673ab7;
}
.session-title {
  font-weight: bold;
  color: #673ab7;
  font-size: 14px;
  margin-bottom: 8px;
}

.quiz-item {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  position: relative;
}
.quiz-item.completo { border-color: #4caf50; background: #f9fff9; }
.quiz-item.completo::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 10px;
  color: #4caf50;
  font-weight: bold;
  font-size: 18px;
}
.quiz-item p { margin: 0 0 8px 0; font-size: 13px; font-weight: 500; }
.quiz-item .instrucao { font-size: 12px; color: #666; margin-bottom: 8px; }
.time-lbl {
  font-size: 11px;
  color: #e91e63;
  font-weight: bold;
  background: #fce4ec;
  padding: 2px 5px;
  border-radius: 3px;
}

.option-btn {
  display: block;
  width: 100%;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 6px;
  padding: 12px 10px;
  margin: 5px 0;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  min-height: 44px;
}
.option-btn:active { background: #f1f3f5; }
.option-btn.correct { background-color: #d4edda; border-color: #c3e6cb; color: #155724; pointer-events: none; }
.option-btn.wrong { background-color: #f8d7da; border-color: #f5c6cb; }

.assoc-container { margin-bottom: 12px; }
.assoc-zonas { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.assoc-zona {
  background: #e3f2fd;
  border: 2px dashed #90caf9;
  padding: 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  min-height: 48px;
  cursor: pointer;
  transition: 0.2s;
}
.assoc-zona.highlight { border-color: #3f51b5; background: #bbdefb; }
.assoc-zona.filled { background: #d4edda; border: 2px solid #c3e6cb; color: #155724; cursor: default; }
.assoc-opcoes { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.assoc-opcao {
  background: #fff;
  border: 2px solid #3f51b5;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  min-height: 44px;
  user-select: none;
}
.assoc-opcao.selected { background: #3f51b5; color: white; }
.assoc-opcao.used { display: none; }
.assoc-hint { font-size: 12px; color: #666; text-align: center; margin-bottom: 8px; }

.canvas-container {
  border: 2px solid #bdbdbd;
  border-radius: 5px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 10px;
  touch-action: none;
  height: 250px;
  position: relative;
}
.canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}
.tools { text-align: center; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.color-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid #ccc;
  cursor: pointer; min-width: 36px;
}
.color-btn.active { border-color: #333; transform: scale(1.1); }
.clear-btn, .action-btn {
  background: #f44336;
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  min-height: 44px;
  font-size: 13px;
}
.action-btn { background: #4caf50; }
.action-btn.secondary { background: #3f51b5; }

.seq-list { list-style: none; padding: 0; margin: 0; }
.seq-item {
  background: #fff;
  border: 2px solid #3f51b5;
  padding: 12px;
  margin: 6px 0;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.seq-num {
  background: #3f51b5;
  color: white;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 14px;
  flex-shrink: 0;
}
.seq-item.ordered { border-color: #4caf50; background: #f1f8e9; }

.img-options { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.img-option {
  border: 3px solid #ccc;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  width: 140px;
  min-height: 44px;
}
.img-option img { width: 100%; height: 90px; object-fit: contain; }
.img-option span { font-size: 11px; display: block; margin-top: 4px; }
.img-option.correct { border-color: #4caf50; }
.img-option.wrong { border-color: #f44336; opacity: 0.6; }

.maze-container { touch-action: none; margin-bottom: 10px; }
.maze-container canvas { width: 100%; border-radius: 6px; border: 2px solid #bdbdbd; touch-action: none; }

.pedrinho-wrap { position: relative; touch-action: none; }
.pedrinho-wrap canvas { width: 100%; border-radius: 6px; border: 2px solid #333; background: #87ceeb; touch-action: none; }
.pedrinho-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}
.pedrinho-btn {
  width: 56px; height: 56px;
  font-size: 24px;
  border: none;
  border-radius: 10px;
  background: #3f51b5;
  color: white;
  cursor: pointer;
}
.pedrinho-hud { text-align: center; font-size: 13px; margin-bottom: 8px; font-weight: bold; }

.palavras-only {
  background: #fff8e1;
  border: 1px dashed #ffc107;
  border-radius: 6px;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  color: #795548;
}

.modo-teste-bar {
  background: #fff3e0;
  padding: 8px 12px;
  text-align: center;
  font-size: 12px;
  border-bottom: 1px solid #ffe0b2;
}
.modo-teste-bar button {
  background: #ff9800;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
}

.app-footer {
  text-align: center;
  font-size: 11px;
  color: #999;
  padding: 16px 20px 24px;
  line-height: 1.6;
}
.app-footer a { color: #999; }
.app-footer button {
  margin-top: 12px;
  background: #3f51b5;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: bold;
  cursor: pointer;
  min-height: 44px;
}

.nota-wrap { margin-top: 10px; }
.nota-btn {
  background: #f1f3f5;
  border: 1px solid #ced4da;
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: bold;
  color: #555;
  cursor: pointer;
  position: relative;
  min-height: 32px;
}
.nota-btn.tem-nota {
  background: #fff3e0;
  border-color: #ffcc80;
  color: #e65100;
}
.nota-box {
  display: none;
  margin-top: 8px;
}
.nota-box.aberta { display: block; }
.nota-textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  padding: 10px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.nota-hint {
  font-size: 11px;
  color: #999;
  margin-top: 4px;
}

.feedback-msg {
  padding: 10px;
  border-radius: 6px;
  margin-top: 8px;
  font-size: 13px;
  text-align: center;
}
.feedback-msg.ok { background: #d4edda; color: #155724; }
.feedback-msg.err { background: #f8d7da; color: #721c24; }

.sub-desafio { border-top: 2px dashed #e0e0e0; padding-top: 12px; margin-top: 12px; }
.sub-desafio:first-child { border-top: none; padding-top: 0; margin-top: 0; }

.memoria-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.memoria-card {
  aspect-ratio: 3/4;
  border: 2px solid #3f51b5;
  border-radius: 8px;
  padding: 4px;
  background: #e8eaf6;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  touch-action: manipulation;
}
.memoria-card.flipped,
.memoria-card.matched {
  background: #fff;
  border-color: #4caf50;
}
.memoria-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}
.memoria-back {
  font-size: 28px;
  font-weight: bold;
  color: #3f51b5;
}
.memoria-label {
  font-size: 9px;
  color: #666;
  margin-top: 2px;
  display: none;
}
.memoria-card.flipped .memoria-label { display: block; }

@media (max-width: 500px) {
  .memoria-grid { grid-template-columns: repeat(3, 1fr); }
}

.sopa-grid {
  display: grid;
  gap: 2px;
  background: #cfd8dc;
  border: 2px solid #3f51b5;
  border-radius: 6px;
  padding: 3px;
  margin-bottom: 12px;
  touch-action: none;
  user-select: none;
}
.sopa-cell {
  aspect-ratio: 1;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: clamp(10px, 3vw, 16px);
  border-radius: 3px;
  color: #2c3e50;
}
.sopa-cell.selecting { background: #bbdefb; color: #0d47a1; }
.sopa-cell.found { background: #a5d6a7; color: #1b5e20; }
.sopa-cell.wrong { background: #ffcdd2; color: #b71c1c; }

.sopa-palavras { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.sopa-palavra {
  background: #f1f3f5;
  border: 1px solid #ced4da;
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: bold;
  color: #555;
}
.sopa-palavra.found {
  background: #d4edda;
  border-color: #c3e6cb;
  color: #155724;
  text-decoration: line-through;
}

.estante-progresso { font-size: 12px; color: #666; text-align: center; margin-bottom: 8px; font-weight: bold; }
.estante-banco {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}
.estante-chip {
  background: #fff;
  border: 2px solid #3f51b5;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  min-height: 44px;
}
.estante-chip.used { display: none; }
.estante-lista { list-style: none; padding: 0; margin: 0; }
.estante-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  font-size: 13px;
  border-bottom: 1px dashed #e0e0e0;
  min-height: 36px;
}
.estante-slot .num {
  background: #ccc;
  color: white;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 12px;
  flex-shrink: 0;
}
.estante-slot .livro { color: #aaa; }
.estante-slot.proximo .num { background: #ff9800; }
.estante-slot.filled .num { background: #4caf50; }
.estante-slot.filled .livro { color: #1b5e20; font-weight: bold; }
