/* CapiLandia — estilos */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fff6e9;
  --card: #ffffff;
  --ink: #4a3a2a;
  --orange: #f5923e;
  --orange-dark: #e07a26;
  --blue: #4fa3f7;
  --green: #6fcf5f;
  --pink: #f470a8;
  --purple: #b678f2;
  --yellow: #ffd93d;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.12);
  --radius: 26px;
}

html, body {
  height: 100%;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%; /* iOS: no inflar letras en apaisado */
}

body {
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Segoe Print', 'Comic Neue', cursive, sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 217, 61, 0.25) 0 120px, transparent 120px),
    radial-gradient(circle at 88% 30%, rgba(79, 163, 247, 0.18) 0 100px, transparent 100px),
    radial-gradient(circle at 20% 85%, rgba(244, 112, 168, 0.15) 0 110px, transparent 110px),
    var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  max-width: 860px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: -webkit-fill-available; /* Safari iOS: altura real sin la barra */
  min-height: 100dvh;
  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);
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.hidden { display: none !important; }

/* ── Barra superior ── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 10px;
}

#topbar button {
  font-size: 1.6rem;
  background: var(--card);
  border: none;
  border-radius: 18px;
  width: 56px;
  height: 52px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

#topbar button:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,0.12); }

#orange-count {
  font-size: 1.5rem;
  font-weight: bold;
  background: var(--card);
  border-radius: 18px;
  padding: 8px 20px;
  box-shadow: var(--shadow);
}

#screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 16px 20px;
}

/* ── Botones genéricos ── */
button { font-family: inherit; color: inherit; }

.btn-big {
  font-size: 1.4rem;
  font-weight: bold;
  padding: 16px 26px;
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.btn-big:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,0.12); }

.btn-primary { background: var(--orange); color: #fff; }

.btn-small {
  font-size: 1.05rem;
  font-weight: bold;
  padding: 12px 18px;
  border: none;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.btn-small:active { transform: translateY(2px); }

/* ── Capi ── */
.capy { display: inline-block; animation: floaty 3.2s ease-in-out infinite; cursor: pointer; }

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.capy .capy-lids rect { transform-origin: center; animation: blink 4.6s infinite; }

@keyframes blink {
  0%, 94%, 100% { transform: scaleY(0); }
  96%, 98% { transform: scaleY(1); }
}

.capy .mouth-talk { display: none; }

.capy.talking .mouth-talk { display: block; animation: chew 0.35s infinite alternate; transform-origin: 120px 156px; }
.capy.talking .mouth-smile { display: none; }

@keyframes chew {
  from { transform: scaleY(0.35); }
  to { transform: scaleY(1.05); }
}

.capy.mood-happy { animation: bounce 0.55s ease-in-out 2; }

@keyframes bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-18px) scale(1.04); }
  70% { transform: translateY(0) scale(0.98); }
}

/* ── Pantalla de perfil ── */
.profile-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}

.logo {
  font-size: clamp(2.6rem, 9vw, 4rem);
  color: var(--orange);
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
  letter-spacing: 1px;
}

.logo span { color: var(--blue); }

.profile-q { font-size: 1.5rem; font-weight: bold; }

.profile-cards { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; }

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 34px;
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
  min-width: 170px;
}

.profile-card:active { transform: translateY(4px) scale(0.98); }

.profile-card.junior { background: linear-gradient(160deg, #bfe0ff, #8ec7ff); }
.profile-card.blanca { background: linear-gradient(160deg, #ffd3e6, #ffadd0); }

.profile-avatar { font-size: 3.4rem; }

.profile-name { font-size: 1.6rem; font-weight: bold; letter-spacing: 2px; }

/* ── Inicio ── */
.home-wrap { flex: 1; display: flex; flex-direction: column; gap: 16px; }

.home-hello { font-size: 1.7rem; text-align: center; }

.game-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* si hay número impar de juegos, el último ocupa todo el ancho */
.game-cards .game-card:last-child:nth-child(odd) { grid-column: 1 / -1; }

.game-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 1.35rem;
  font-weight: bold;
  padding: 22px 10px;
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: #fff;
  text-shadow: 1px 2px 0 rgba(0, 0, 0, 0.18);
  cursor: pointer;
  letter-spacing: 1px;
}

.game-card:active { transform: translateY(4px) scale(0.98); }

.game-emoji { font-size: 2.6rem; text-shadow: none; }

.c-blue { background: linear-gradient(160deg, #6db5ff, #3d8fe0); }
.c-green { background: linear-gradient(160deg, #85dd75, #55b845); }
.c-pink { background: linear-gradient(160deg, #ff8fbc, #ef5c99); }
.c-purple { background: linear-gradient(160deg, #c893fa, #a05fe6); }
.c-orange { background: linear-gradient(160deg, #ffab5e, #ef8322); }

.talk-card { flex-direction: row; justify-content: center; gap: 14px; padding: 18px; }

.home-bottom {
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.home-capy { text-align: center; }

.home-side { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; }

/* ── Juegos ── */
.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.game-title { font-size: 1.3rem; font-weight: bold; }

.progress-dots { display: flex; gap: 6px; }

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.12);
}

.dot.ok { background: var(--green); }
.dot.fail { background: #f2a09e; }

.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}

.game-capy { text-align: center; min-height: 100px; }
.game-capy .capy { animation-duration: 4s; }

.prompt { font-size: 1.5rem; }
.prompt b { color: var(--orange-dark); font-size: 1.9rem; }

.prompt-word { font-size: 1.9rem; font-weight: bold; letter-spacing: 3px; }

.btn-hear {
  font-size: 1.25rem;
  background: var(--card);
  border: none;
  border-radius: 14px;
  padding: 6px 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  vertical-align: middle;
  margin-left: 8px;
}

.btn-hear-lone { margin: 0; }

.big-emoji { font-size: 5rem; line-height: 1; }

.options { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

.opt {
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s;
}

.opt:active { transform: scale(0.95); }

.opt.right { background: var(--green); color: #fff; animation: pop 0.4s; }
.opt.wrong { background: #f2a09e; opacity: 0.6; animation: shake 0.4s; }

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.opt-letter {
  font-size: 3rem;
  font-weight: bold;
  width: 96px;
  height: 96px;
}

.opt-number {
  font-size: 2.6rem;
  font-weight: bold;
  width: 88px;
  height: 88px;
}

.opt-emoji { font-size: 3.4rem; width: 104px; height: 104px; }

.opt-scene { font-size: 2.6rem; padding: 14px 20px; letter-spacing: 6px; }

.opt-word { font-size: 1.7rem; font-weight: bold; padding: 16px 26px; letter-spacing: 2px; }

.opt-orange { font-size: 2.8rem; width: 88px; height: 88px; }

.opt-orange.flying { animation: fly 0.5s forwards; }

@keyframes fly {
  to { transform: translateY(90px) scale(0.3); opacity: 0; }
}

.options-grid { max-width: 460px; }

.count-items {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  font-size: 2.8rem;
  max-width: 500px;
}

.sub-items span { position: relative; }

.sub-items .crossed { opacity: 0.45; }

.sub-items .crossed::after {
  content: '✖';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d33;
  font-size: 2rem;
}

.sub-expr { font-size: 2.6rem; font-weight: bold; letter-spacing: 4px; }

.give-count { font-size: 2.4rem; font-weight: bold; color: var(--orange-dark); }

.read-word {
  font-size: 3rem;
  font-weight: bold;
  letter-spacing: 8px;
  background: var(--card);
  padding: 12px 30px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.read-phrase {
  font-size: 1.9rem;
  font-weight: bold;
  letter-spacing: 2px;
  background: var(--card);
  padding: 14px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 560px;
  line-height: 1.5;
}

/* trazado de letras */
.trace-wrap {
  position: relative;
  width: min(300px, 78vw);
  aspect-ratio: 1;
}

#trace-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  touch-action: none;
  z-index: 2;
}

.trace-ghost {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 190px;
  font-weight: bold;
  color: rgba(0, 0, 0, 0.1);
  z-index: 3;
  pointer-events: none;
}

/* fin de ronda */
.round-end {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
}

.stars { font-size: 3.6rem; animation: pop 0.6s; }

.round-score { font-size: 1.4rem; }

.round-oranges { font-size: 1.6rem; font-weight: bold; color: var(--orange-dark); }

.round-buttons { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

/* ── Chat con Capi ── */
.chat-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.chat-capy { margin-top: 4px; }

.bubble {
  position: relative;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 16px 22px;
  font-size: 1.3rem;
  max-width: 560px;
  min-height: 60px;
  line-height: 1.45;
}

.bubble::before {
  content: '';
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-bottom-color: var(--card);
}

.bubble.thinking { color: #9a8a76; font-style: italic; }

.chat-you { font-size: 1.05rem; color: #8a7a66; min-height: 1.3em; }

.chips { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.chip {
  font-size: 1.05rem;
  font-weight: bold;
  background: var(--card);
  border: none;
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.chip:active { transform: translateY(2px); }

.chat-controls {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding-bottom: 8px;
}

.mic-btn {
  font-size: 3rem;
  width: 110px;
  height: 110px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(160deg, #ffab5e, #ef8322);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.mic-btn:active { transform: scale(0.95); }

.mic-btn.listening {
  background: linear-gradient(160deg, #ff7a7a, #e54848);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 72, 0.5), var(--shadow); }
  50% { box-shadow: 0 0 0 22px rgba(229, 72, 72, 0), var(--shadow); }
}

.type-form { display: flex; gap: 8px; width: min(480px, 92%); }

.type-form input {
  flex: 1;
  font-family: inherit;
  font-size: 1.05rem;
  padding: 12px 16px;
  border: none;
  border-radius: 18px;
  background: var(--card);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.08);
  color: var(--ink);
  user-select: text;
  -webkit-user-select: text;
}

.type-form input:focus { outline: 3px solid var(--orange); }

.send-btn {
  font-size: 1.3rem;
  border: none;
  border-radius: 18px;
  width: 56px;
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* ── Tienda ── */
.shop-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.shop-title { font-size: 1.7rem; }

.shop-hint { color: #8a7a66; }

.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: min(560px, 100%);
  margin-top: 6px;
}

.shop-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px;
  border: 3px solid transparent;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.shop-item:active { transform: translateY(2px); }

.shop-item.locked { opacity: 0.55; }

.shop-item.equipped { border-color: var(--green); }

.shop-emoji { font-size: 2.2rem; }

.shop-name { font-weight: bold; font-size: 1rem; }

.shop-price { font-size: 0.95rem; color: #8a7a66; }

.shop-item.equipped .shop-price { color: var(--green); font-weight: bold; }

/* ── Botón repetir (chat) ── */
.bubble-row {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(640px, 94%);
}

.btn-replay {
  flex: none;
  font-size: 1.5rem;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.btn-replay:active { transform: scale(0.93); }

/* ── A colorear ── */
.coloring-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 560px;
}

.swatch {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.15);
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 1.2rem;
}

.swatch.selected {
  border-color: var(--ink);
  transform: scale(1.18);
}

.swatch-eraser { background: #fff; }

.coloring-frame {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
}

.coloring-svg {
  display: block;
  width: min(88vw, 44vh, 430px);
  height: auto;
  touch-action: manipulation;
}

.coloring-svg .paint {
  fill: #ffffff;
  cursor: pointer;
}

.coloring-svg * {
  stroke: #444;
  stroke-width: 4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.coloring-mini .coloring-frame { padding: 6px; }
.coloring-mini .coloring-svg { width: min(50vw, 24vh, 220px); }
.coloring-mini .btn-big { display: none; }
.coloring-mini .prompt, .coloring-mini .palette { display: none; }

/* ── Instalación como app ── */
.install-btn {
  font-size: 1rem;
  font-weight: bold;
  padding: 12px 20px;
  border: none;
  border-radius: 18px;
  background: var(--card);
  color: #8a7a66;
  box-shadow: var(--shadow);
  cursor: pointer;
  margin-top: 6px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 40, 20, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  padding: 24px 26px;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal h3 { font-size: 1.3rem; }

.modal ol {
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 1.05rem;
  line-height: 1.4;
}

.sum-plus {
  font-size: 2.4rem;
  font-weight: bold;
  color: var(--orange-dark);
  align-self: center;
}

/* ── Responsive: ancho (móvil) ── */
@media (max-width: 560px) {
  .opt-letter { width: 80px; height: 80px; font-size: 2.5rem; }
  .opt-emoji { width: 88px; height: 88px; font-size: 2.9rem; }
  .opt-number { width: 76px; height: 76px; font-size: 2.2rem; }
  .home-bottom { flex-direction: column; align-items: center; gap: 4px; }
  .home-side { flex-direction: row; padding-bottom: 0; }
  .shop-grid { grid-template-columns: repeat(3, 1fr); }
  .read-word { font-size: 2.3rem; letter-spacing: 5px; }
  .read-phrase { font-size: 1.5rem; }
  .game-card { font-size: 1.1rem; padding: 16px 8px; }
  .game-emoji { font-size: 2.1rem; }
  .count-items { font-size: 2.2rem; }
}

/* ── Responsive: altura (tablets y móviles apaisados) ──
   Todo debe caber sin scroll: encogemos a Capi y los elementos grandes. */
@media (max-height: 860px) {
  .home-capy .capy-svg { width: 150px; height: 150px; }
  .home-wrap { gap: 12px; }
  .profile-wrap { gap: 14px; }
}

@media (max-height: 740px) {
  .home-capy .capy-svg { width: 118px; height: 118px; }
  .chat-capy .capy-svg { width: 130px; height: 130px; }
  .game-capy .capy-svg { width: 80px; height: 80px; }
  .game-capy { min-height: 0; }
  .game-card { padding: 12px 8px; font-size: 1.05rem; }
  .game-emoji { font-size: 1.8rem; }
  .home-hello { font-size: 1.4rem; }
  .talk-card { padding: 12px; }
  .big-emoji { font-size: 3.8rem; }
  .logo { font-size: 2.4rem; }
  .profile-capy .capy-svg { width: 130px; height: 130px; }
  .game-area { gap: 12px; }
  .mic-btn { width: 88px; height: 88px; font-size: 2.4rem; }
  .coloring-svg { width: min(88vw, 40vh, 380px); }
}

@media (max-height: 600px) {
  .home-capy .capy-svg { width: 92px; height: 92px; }
  .chat-capy .capy-svg { width: 92px; height: 92px; }
  .game-capy { display: none; }
  .prompt { font-size: 1.2rem; }
  .prompt b { font-size: 1.5rem; }
  .opt-letter, .opt-emoji { width: 70px; height: 70px; font-size: 2.1rem; }
  .opt-number { width: 64px; height: 64px; font-size: 1.9rem; }
  .stars { font-size: 2.6rem; }
  .profile-capy { display: none; }
}

/* ══ Expansión: muchos juegos, niveles y el mundo de Capi ══ */

/* inicio con muchos juegos: cabecera compacta con Capi pequeño */
.home-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.home-capy-mini .capy-svg { width: 84px !important; height: 84px !important; }
.home-capy-mini .capy { animation-duration: 4s; }

.game-cards-many {
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.game-cards-many .game-card {
  padding: 12px 6px;
  gap: 3px;
  font-size: 0.92rem;
  border-radius: 20px;
}

.game-cards-many .game-emoji { font-size: 1.7rem; }

.game-card-title { line-height: 1.15; }

.card-level {
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  padding: 2px 8px;
  text-shadow: none;
}

.world-card { flex-direction: row; justify-content: center; gap: 12px; padding: 14px; }

.level-badge {
  font-size: 0.95rem;
  font-weight: bold;
  background: var(--yellow);
  border-radius: 12px;
  padding: 4px 10px;
  white-space: nowrap;
}

.level-up {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--orange-dark);
  background: var(--yellow);
  border-radius: 18px;
  padding: 10px 22px;
  animation: pop 0.7s;
}

/* memoria (parejas) */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(480px, 94vw);
}

.memory-grid.pairs-3 { grid-template-columns: repeat(3, 1fr); width: min(340px, 90vw); }
.memory-grid.pairs-4 { grid-template-columns: repeat(4, 1fr); width: min(420px, 94vw); }
.memory-grid.pairs-10 { grid-template-columns: repeat(5, 1fr); }

.mem-card {
  aspect-ratio: 1;
  border: none;
  background: none;
  cursor: pointer;
  perspective: 500px;
  padding: 0;
}

.mem-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.35s;
  transform-style: preserve-3d;
}

.mem-card.flipped .mem-inner { transform: rotateY(180deg); }

.mem-back, .mem-front {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border-radius: 16px;
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.mem-back { background: linear-gradient(160deg, #ffab5e, #ef8322); }
.mem-front { background: var(--card); transform: rotateY(180deg); }

.mem-card.matched .mem-inner { animation: pop 0.5s; }
.mem-card.matched .mem-front { background: #d9f2d0; }

/* series */
.pattern-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  font-size: 2.6rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 18px;
  max-width: 94vw;
}

/* ordena la palabra */
.spell-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.spell-slot {
  width: 44px;
  height: 54px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.07);
  border: 3px dashed rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: bold;
}

.spell-slot.filled {
  background: var(--card);
  border-style: solid;
  border-color: var(--green);
  animation: pop 0.3s;
}

.spell-bank { max-width: 560px; }

.opt-spell { width: 62px; height: 62px; font-size: 2rem; }

.opt-spell.used { opacity: 0.25; }

/* formas, reloj */
.options-shapes .opt-shape { padding: 8px; }
.options-odd { max-width: 480px; }
.clock-wrap { background: var(--card); border-radius: 50%; box-shadow: var(--shadow); padding: 8px; }
.options-clocks .opt-clockface { padding: 6px; border-radius: 24px; }
.opt-clock { font-size: 1.25rem; }
.opp-word { font-size: 2.2rem; letter-spacing: 4px; }
.opp-emoji { font-size: 1.3rem; }

/* el mundo de Capi */
.world-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.world-scene {
  width: 100%;
  max-width: 720px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}

.world-svg { display: block; width: 100%; height: auto; }

.world-friend { animation: floaty 3.4s ease-in-out infinite; }

.food-fly {
  position: absolute;
  left: 46%;
  top: 60%;
  font-size: 3rem;
  animation: foodfly 1.1s forwards;
  pointer-events: none;
}

@keyframes foodfly {
  0% { transform: translate(-120px, 90px) scale(1.2); opacity: 1; }
  70% { transform: translate(0, 0) scale(0.9); opacity: 1; }
  100% { transform: translate(6px, -6px) scale(0.4); opacity: 0; }
}

.world-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.wtab {
  font-size: 0.98rem;
  font-weight: bold;
  padding: 10px 14px;
  border: none;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0.75;
}

.wtab.on {
  background: var(--orange);
  color: #fff;
  opacity: 1;
}

.world-panel { width: 100%; max-width: 640px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-bottom: 14px; }

.world-hint { color: #8a7a66; text-align: center; font-size: 1.02rem; }

.goals { display: flex; flex-direction: column; gap: 10px; width: min(480px, 100%); }

.goal {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
}

.goal-emoji { font-size: 2rem; }

.goal-body { flex: 1; display: flex; flex-direction: column; gap: 5px; }

.goal-name { font-weight: bold; font-size: 1rem; }

.goal-bar {
  height: 14px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.goal-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #ffd93d, #f5923e);
  transition: width 0.6s;
}

/* móvil: 2 columnas de juegos */
@media (max-width: 560px) {
  .game-cards-many { grid-template-columns: repeat(2, 1fr); }
  .memory-grid.pairs-10 { grid-template-columns: repeat(4, 1fr); }
  .opt-spell { width: 52px; height: 52px; font-size: 1.7rem; }
  .spell-slot { width: 36px; height: 46px; font-size: 1.5rem; }
  .pattern-row { font-size: 2rem; }
}

/* ══ Cuentos, pincel y código familiar ══ */

/* mi cuento */
.story-text {
  font-size: 1.5rem;
  line-height: 1.6;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 22px;
  max-width: 600px;
  text-align: center;
}

.story-gap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 46px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.07);
  border: 3px dashed rgba(0, 0, 0, 0.2);
  margin: 0 4px;
  vertical-align: middle;
  font-size: 1.7rem;
}

.story-gap.filled {
  background: #d9f2d0;
  border-style: solid;
  border-color: var(--green);
  animation: pop 0.4s;
}

/* herramientas de colorear */
.tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.tool {
  font-size: 1rem;
  font-weight: bold;
  padding: 10px 16px;
  border: none;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0.7;
}

.tool.on { background: var(--blue); color: #fff; opacity: 1; }

.brush-sizes { display: inline-flex; gap: 6px; }

.bsize {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}

.bsize.on { outline: 3px solid var(--blue); opacity: 1; }

.dot-s, .dot-m, .dot-l { border-radius: 50%; background: var(--ink); display: block; }
.dot-s { width: 6px; height: 6px; }
.dot-m { width: 13px; height: 13px; }
.dot-l { width: 22px; height: 22px; }

.coloring-frame { position: relative; }

.coloring-canvas {
  position: absolute;
  top: 10px;
  left: 10px;
  pointer-events: none; /* solo recibe toques con el pincel activo */
  touch-action: none;
  border-radius: 16px;
}

.coloring-mini .tools { display: none; }
.coloring-mini .coloring-canvas { width: 100% !important; height: auto !important; top: 6px; left: 6px; }

/* código familiar (pantalla de perfil) */
.family-code {
  font-size: 0.92rem;
  color: #8a7a66;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-code {
  font-size: 0.85rem;
  border: none;
  border-radius: 12px;
  padding: 6px 12px;
  background: var(--card);
  color: #8a7a66;
  box-shadow: var(--shadow);
  cursor: pointer;
}
