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

/* ══ Cuidados de Capi, hucha y juegos nuevos ══ */

/* barras de necesidades (tipo Sims) */
.care-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  width: min(520px, 100%);
}

.care-bar { display: flex; align-items: center; gap: 8px; }

.care-emoji { font-size: 1.4rem; }

.care-track {
  flex: 1;
  height: 16px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.09);
  overflow: hidden;
}

.care-fill {
  height: 100%;
  border-radius: 9px;
  background: linear-gradient(90deg, #6fcf5f, #2fa86b);
  transition: width 0.5s;
}

.care-fill.low { background: linear-gradient(90deg, #f2a09e, #e5484d); }

.care-pct { font-size: 0.85rem; font-weight: bold; min-width: 26px; text-align: right; }

.care-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* hucha */
.btn-save {
  flex: none;
  font-size: 0.9rem;
  font-weight: bold;
  border: none;
  border-radius: 12px;
  padding: 8px 10px;
  background: var(--yellow);
  box-shadow: var(--shadow);
  cursor: pointer;
}

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

.shop-grid-goals { grid-template-columns: repeat(2, 1fr); }

.shop-goal {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  cursor: default;
}

.shop-goal .shop-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}

/* las tablas: grupos visuales */
.times-groups {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.times-row {
  display: flex;
  gap: 6px;
  font-size: 1.9rem;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 14px;
  padding: 4px 12px;
}

/* penaltis */
.goal-wrap { width: min(420px, 92vw); }
.goal-svg { display: block; width: 100%; height: auto; }

/* escucha bien */
.listen-progress { display: flex; gap: 8px; font-size: 1.6rem; }
.listen-dot { opacity: 0.25; }
.listen-dot.got { opacity: 1; animation: pop 0.4s; }

/* números grandes */
.opt-bignum { width: auto; min-width: 88px; padding: 0 14px; }

/* ══ Escena viva del mundo + juego estrella ══ */
.world-svg .cloud { animation: cloud-drift 75s linear infinite; }
.world-svg .cloud-b { animation-duration: 110s; animation-delay: -45s; }

@keyframes cloud-drift {
  from { transform: translateX(-200px); }
  to { transform: translateX(880px); }
}

.world-svg .wave { animation: wave-shift 5s linear infinite; }
.world-svg .wave-b { animation-duration: 7.5s; animation-direction: reverse; }

@keyframes wave-shift {
  from { transform: translateX(0); }
  to { transform: translateX(80px); }
}

.world-svg .smoke-p { animation: smoke-rise 4.2s ease-out infinite; }

@keyframes smoke-rise {
  0% { transform: translateY(0); opacity: 0.55; }
  100% { transform: translateY(-52px); opacity: 0; }
}

.world-svg .butterfly { animation: butterfly-fly 16s ease-in-out infinite alternate; }
.world-svg .butterfly-b { animation-duration: 11s; animation-delay: -5s; }

@keyframes butterfly-fly {
  0% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(90px, -42px) rotate(14deg); }
  50% { transform: translate(185px, 8px) rotate(-10deg); }
  75% { transform: translate(85px, 55px) rotate(10deg); }
  100% { transform: translate(-25px, 15px) rotate(-8deg); }
}

.world-svg .firefly { animation: firefly-blink 2.6s ease-in-out infinite; }

@keyframes firefly-blink {
  0%, 100% { opacity: 0.08; }
  50% { opacity: 1; }
}

/* ══ Entrada con clave (cuentas de Junior y Blanca) ══ */
.pin-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.pin-title { font-size: 1.35rem; text-align: center; min-height: 1.6em; }

.pin-dots { display: flex; gap: 16px; }

.pin-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  border: 3px solid rgba(0, 0, 0, 0.16);
}

.pin-dot.on { background: var(--orange); border-color: var(--orange-dark); transform: scale(1.15); }

.pin-dots.shake { animation: shake 0.45s; }

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.pin-key {
  width: 78px;
  height: 78px;
  font-size: 2rem;
  font-weight: bold;
  border: none;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
}

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

.pin-back { font-size: 1.6rem; }

.pin-cancel { font-size: 1.3rem; background: #ffe3ec; }

@media (max-height: 700px) {
  .pin-key { width: 66px; height: 66px; font-size: 1.7rem; }
  .pin-capy .capy-svg { width: 90px; height: 90px; }
}

/* tarjeta del juego estrella del día (doble naranja) */
.star-card { position: relative; outline: 4px solid var(--yellow); }

.star-flag {
  position: absolute;
  top: -10px;
  right: -6px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: bold;
  padding: 4px 10px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-shadow: none;
  animation: pop 0.6s;
  transform: rotate(6deg);
}

/* ══ El mundo en 3D ══ */
.world-canvas { display: block; width: 100%; }

/* ══ Inicio 2.0: cielo animado, cartel del mundo y tarjetas vivas ══ */
.home-wrap { position: relative; }

.home-float {
  position: absolute;
  font-size: 1.25rem;
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
  animation: float-deco 7s ease-in-out infinite;
}

.home-float.f1 { top: 200px; left: 1%; }
.home-float.f2 { top: 350px; right: 2%; animation-delay: 1.7s; font-size: 1rem; }
.home-float.f3 { bottom: 190px; left: 3%; animation-delay: 3s; font-size: 1rem; }
.home-float.f4 { bottom: 60px; right: 5%; animation-delay: 4.2s; }

@keyframes float-deco {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-14px) rotate(10deg); }
}

.home-sky {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px 8px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, #8fd0f4, #c9ecfb 60%, #eafaff);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.home-sun {
  position: absolute;
  top: -24px;
  left: -24px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe066 0 52%, rgba(255, 224, 102, 0.35) 62%, transparent 72%);
  animation: sun-glow 5s ease-in-out infinite;
}

@keyframes sun-glow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14); }
}

.home-cloud {
  position: absolute;
  height: 14px;
  width: 48px;
  border-radius: 10px;
  background: #fff;
  opacity: 0.9;
}

.home-cloud::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 9px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
}

.home-cloud::after {
  content: '';
  position: absolute;
  top: -5px;
  left: 26px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
}

.hc1 { top: 12px; animation: hc-drift 36s linear infinite; }
.hc2 { bottom: 8px; transform: scale(0.65); opacity: 0.6; animation: hc-drift 52s linear infinite; animation-delay: -26s; }

@keyframes hc-drift {
  from { right: -70px; }
  to { right: 105%; }
}

.home-hello-box { position: relative; text-align: center; }

.home-greet {
  font-size: 0.95rem;
  color: #35607a;
  font-weight: bold;
}

.home-sky .home-capy-mini { position: relative; }

/* cartel grande del mundo, con el humor real de Capi */
.world-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius);
  background: linear-gradient(120deg, #58b7f0, #6fcf5f 85%);
  color: #fff;
  text-shadow: 1px 2px 0 rgba(0, 0, 0, 0.18);
  box-shadow: 0 5px 0 rgba(47, 111, 60, 0.3), var(--shadow);
  cursor: pointer;
  overflow: hidden;
  font-family: inherit;
}

.world-banner::after {
  content: '';
  position: absolute;
  top: -40%;
  left: -30%;
  width: 38px;
  height: 180%;
  background: rgba(255, 255, 255, 0.35);
  transform: rotate(20deg);
  animation: banner-shine 5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes banner-shine {
  0%, 55%, 100% { left: -30%; }
  30% { left: 112%; }
}

.world-banner:active { transform: translateY(3px) scale(0.99); }

.world-banner.needs-care {
  background: linear-gradient(120deg, #f5923e, #e5484d);
  box-shadow: 0 5px 0 rgba(150, 40, 40, 0.35), var(--shadow);
}

.wb-emoji {
  font-size: 2.3rem;
  animation: wb-bob 3s ease-in-out infinite;
}

@keyframes wb-bob {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(8deg) translateY(-3px); }
}

.wb-txt {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
}

.wb-title {
  font-size: 1.25rem;
  font-weight: bold;
  letter-spacing: 1px;
}

.wb-sub {
  font-size: 0.85rem;
  font-weight: bold;
  opacity: 0.95;
  text-shadow: none;
}

.wb-go { font-size: 1.25rem; opacity: 0.9; }

.wb-alert {
  font-size: 1.5rem;
  animation: alert-pulse 1s ease-in-out infinite;
}

@keyframes alert-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

/* separador de sección con cintas */
.home-section {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 2px 0 -4px;
  font-weight: bold;
  font-size: 1rem;
  color: #8a744f;
  letter-spacing: 2px;
}

.home-section::before,
.home-section::after {
  content: '';
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, #e8c99a);
}

.home-section::after { background: linear-gradient(90deg, #e8c99a, transparent); }

/* tarjetas 2.0: entran en cascada, emoji en burbuja y brillo */
.game-cards-many .game-card {
  position: relative;
  animation: card-in 0.45s backwards;
  animation-delay: var(--d, 0s);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.16), var(--shadow);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(0.9); }
  to { opacity: 1; transform: none; }
}

.game-cards-many .game-card::after {
  content: '';
  position: absolute;
  top: 5px;
  right: 7px;
  width: 30%;
  height: 22%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transform: rotate(-16deg);
  pointer-events: none;
}

.card-bubble {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  font-size: 1.7rem;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
  text-shadow: none;
  transition: transform 0.15s;
}

.game-card:active .card-bubble { transform: scale(1.15) rotate(-8deg); }

/* pantallas bajas: que siga cabiendo todo */
@media (max-height: 800px) {
  .card-bubble { width: 42px; height: 42px; font-size: 1.4rem; }
  .home-sky { padding: 8px 12px 5px; }
  .wb-title { font-size: 1.1rem; }
  .wb-emoji { font-size: 1.9rem; }
}

@media (max-height: 640px) {
  .card-bubble { width: 36px; height: 36px; font-size: 1.2rem; }
  .home-greet { display: none; }
  .wb-sub { display: none; }
}

/* ══ Juegos: modos curriculares nuevos ══ */
.level-up.level-down { background: #ffe3c2; color: #7a4a1e; }

.level-near {
  font-size: 1.1rem;
  font-weight: bold;
  color: #b35a00;
  background: #fff2d9;
  border-radius: 14px;
  padding: 8px 16px;
  animation: pop 0.6s;
}

.prompt-small { font-size: 1rem; color: #7a6a52; font-weight: bold; }

.number-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 8px 0;
  flex-wrap: wrap;
}

.nl-tick {
  min-width: 52px;
  padding: 8px 6px;
  background: #fff;
  border: 3px solid var(--orange);
  border-radius: 12px;
  font-weight: bold;
  font-size: 1.2rem;
  text-align: center;
}

.nl-seg { width: 22px; height: 4px; background: var(--orange); border-radius: 2px; }

.money-row span {
  background: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: bold;
  box-shadow: var(--shadow);
}

.options-compare { display: flex; gap: 14px; justify-content: center; }

.opt-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 200px;
  padding: 14px;
  font-size: 1.5rem;
  background: #fff;
  border: 4px solid #e8d9c2;
  border-radius: var(--radius);
  cursor: pointer;
}

.options-row-line { display: flex; align-items: center; justify-content: center; gap: 10px; }

.line-flag { font-size: 2rem; }

.options-sizes { align-items: center; }

.pos-stage {
  position: relative;
  width: 260px;
  height: 240px;
  margin: 0 auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.pos-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.4rem;
}

.pos-item {
  position: absolute;
  font-size: 2rem;
  background: #fdf3e3;
  border: 3px solid #e8d9c2;
  border-radius: 16px;
  padding: 6px 10px;
  cursor: pointer;
}

.pos-item.pos-top { top: 8px; left: 50%; transform: translateX(-50%); }
.pos-item.pos-bottom { bottom: 8px; left: 50%; transform: translateX(-50%); }
.pos-item.pos-left { left: 8px; top: 50%; transform: translateY(-50%); }
.pos-item.pos-right { right: 8px; top: 50%; transform: translateY(-50%); }

.mem-word { font-size: 0.85rem; font-weight: bold; line-height: 1.05; word-break: break-word; }

.mini-text { font-size: 1.15rem; line-height: 1.5; }

.spell-slots-words .spell-slot { min-width: 54px; font-size: 0.95rem; }

.opt-spell-word { font-size: 1rem; padding: 10px 12px; }

.opt-syll { font-size: 1.3rem; min-width: 74px; }

.btn-alert { outline: 3px solid var(--red, #e5484d); animation: alert-pulse 1s infinite; }

/* dictado y pronunciación */
.btn-dictate { margin: 4px auto 10px; display: block; }

.pron-word { font-size: 2rem; letter-spacing: 3px; }

.pron-controls { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

.btn-mic-big { font-size: 1.3rem; padding: 16px 26px; }

.btn-mic-big.recording {
  background: linear-gradient(160deg, #ff8f8f, #e5484d);
  animation: alert-pulse 1.1s infinite;
}

.pron-status { min-height: 24px; font-weight: bold; color: #7a6a52; }

/* el profe de ayuda */
.btn-help {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 16px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  background: linear-gradient(160deg, #ffd93d, #f5b91e);
  color: #5a4415;
  box-shadow: 0 4px 0 rgba(150, 110, 10, 0.35);
  cursor: pointer;
  animation: pop 0.5s;
}

.btn-help.hidden { display: none; }
.btn-help:active { transform: translateY(3px); box-shadow: none; }

.game-area { position: relative; }

.hint-glow { outline: 5px solid var(--yellow) !important; animation: alert-pulse 0.9s 3; }

/* ══ La Puerta Mágica (encajar formas + cerrojos) ══ */
.lk-board, .lk-tray, .lk-keys {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0;
}

.lk-hole {
  background: #e8dcc8;
  border: 4px dashed #b9a888;
  border-radius: 16px;
  padding: 8px;
  cursor: pointer;
}

.lk-hole.lk-filled { border-style: solid; border-color: #6fcf5f; background: #f2fbe8; }

.lk-piece {
  background: #fff;
  border: 4px solid #e8d9c2;
  border-radius: 16px;
  padding: 8px;
  cursor: pointer;
}

.lk-piece.lk-sel { border-color: var(--orange, #f5923e); transform: scale(1.12); box-shadow: var(--shadow); }
.lk-piece.lk-done { opacity: 0.25; pointer-events: none; }

.lk-shake { animation: shake 0.4s; }

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

.lk-door { position: relative; width: 230px; height: 250px; margin: 6px auto; perspective: 700px; }

.lk-behind {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 5rem;
  background: linear-gradient(#fdf2c9, #ffe08a);
  border-radius: 14px;
  border: 5px solid #b9862f;
}

.lk-door-leaf {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(160deg, #b07a44, #8a5a36);
  border: 5px solid #6f4426;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transform-origin: left center;
  transition: transform 0.9s ease-in;
}

.lk-door-leaf.lk-swing { transform: rotateY(-108deg); }

.lk-knob { position: absolute; right: 14px; top: 48%; width: 18px; height: 18px; border-radius: 50%; background: #ffd93d; }

.lk-lock {
  width: 56px;
  height: 40px;
  border-radius: 10px;
  background: #5d4328;
  border: 3px solid #3f2c18;
  display: grid;
  place-items: center;
  color: #ffd93d;
  font-size: 1.3rem;
  font-weight: bold;
}

.lk-lock.lk-now { outline: 4px solid var(--yellow); animation: alert-pulse 1.2s infinite; }
.lk-lock.lk-open { background: #4e8c3a; border-color: #35682a; }

.lk-panel { min-height: 130px; }

.lk-hint { font-weight: bold; color: #7a6a52; }

.lk-bolt {
  position: relative;
  width: 220px;
  height: 58px;
  border-radius: 14px;
  border: 4px solid #8a5a36;
  background: #e8dcc8;
  font-size: 1.8rem;
  cursor: pointer;
  overflow: hidden;
}

.lk-bolt-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #6fcf5f; transition: width 0.25s; }

.lk-keyhole { display: inline-block; background: #e8dcc8; border-radius: 14px; padding: 8px 16px; }

.lk-key {
  background: #fff8e0;
  border: 4px solid #d9a520;
  border-radius: 14px;
  padding: 6px 10px;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.lk-key.lk-rot svg { transform: rotate(90deg); }

.lk-seq { display: flex; gap: 10px; justify-content: center; font-size: 1.7rem; margin: 6px 0; }

.lk-dot { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(0,0,0,0.2); }

.lk-colorbtn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 4px solid rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.lk-colorbtn.lk-done { outline: 4px solid #6fcf5f; transform: scale(0.9); }

.lk-numbtn {
  width: 66px;
  height: 66px;
  border-radius: 16px;
  border: none;
  background: #fff;
  box-shadow: var(--shadow);
  font-family: inherit;
  font-size: 1.7rem;
  font-weight: bold;
  cursor: pointer;
}

/* ══ El Arcade de Capi ══ */
.arcade-wrap { position: absolute; inset: 0; z-index: 20; }

.arcade-exit { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: 12px; z-index: 5; }

.arcade-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  font-family: inherit;
}

.arcade-stage.ag-sky { background: linear-gradient(#7ec8ef, #c9ecfb 60%, #a8d878 92%, #89c556); }
.arcade-stage.ag-water { background: linear-gradient(#bfe6fb, #4fa3f7 70%, #2f6fa8); }
.arcade-stage.ag-field { background: linear-gradient(#7ec8ef 55%, #a8d878 56%, #89c556); }
.arcade-stage.ag-track { background: linear-gradient(#f6d992, #e8b866); }

.ag-time, .ag-score, .ag-lives {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  padding: 8px 14px;
  font-weight: bold;
  font-size: 1.15rem;
  z-index: 4;
  pointer-events: none;
}

.ag-time { right: 12px; }
.ag-score { left: 50%; transform: translateX(-50%); }
.ag-lives { right: 12px; top: calc(60px + env(safe-area-inset-top, 0px)); }

.ag-capy {
  position: absolute;
  bottom: 26px;
  font-size: 4.2rem;
  transform: translateX(-50%);
  filter: drop-shadow(0 6px 4px rgba(0, 0, 0, 0.25));
  pointer-events: none;
  transition: left 0.06s linear;
}

.ag-runner { left: 70px; transform: none; transition: none; }

.ag-ouch { filter: drop-shadow(0 0 12px #e5484d); animation: alert-pulse 0.4s 2; }

.ag-drop { position: absolute; font-size: 2.6rem; pointer-events: none; }

.ag-log { position: absolute; bottom: 22px; font-size: 3.2rem; pointer-events: none; }

.ag-bubble {
  position: absolute;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.95), rgba(255,255,255,0.25));
  border: 2px solid rgba(255, 255, 255, 0.8);
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  cursor: pointer;
}

.ag-popped { transform: scale(1.5); opacity: 0; transition: all 0.18s; }

.ag-lane {
  position: absolute;
  left: 0; right: 0;
  height: 96px;
  background: rgba(255, 255, 255, 0.25);
  border-top: 4px dashed rgba(255, 255, 255, 0.7);
  border-bottom: 4px dashed rgba(255, 255, 255, 0.7);
}

.ag-lane:nth-of-type(2) { top: 32%; }
.ag-lane:nth-of-type(3) { top: 58%; }

.ag-racer { position: absolute; left: 14px; top: 12px; font-size: 3.6rem; transition: left 0.1s linear; }
.ag-rival { filter: grayscale(0.5) brightness(1.15); }
.ag-flag { position: absolute; right: 60px; top: 14px; font-size: 3rem; }

.ag-banner {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--yellow);
  color: var(--ink, #4a3a2a);
  font-size: 1.6rem;
  font-weight: bold;
  padding: 14px 26px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: pop 0.5s;
  z-index: 5;
}

/* ══ EL MUNDO TAMAGOTCHI (pantalla completa) ══ */
body.tama-mode #topbar { display: none; }
body.tama-mode #screen { padding: 0; max-width: none; }

.world-loading {
  display: grid;
  place-items: center;
  min-height: 60vh;
  font-size: 1.4rem;
  font-weight: bold;
  color: #7a6a52;
}

.tama-wrap {
  position: fixed;
  inset: 0;
  background: #14244a;
  z-index: 50;
  overflow: hidden;
}

.tama-stage, .tama-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.tama-top {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.tama-exit, .tama-oranges {
  pointer-events: auto;
  border: none;
  border-radius: 16px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink, #4a3a2a);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.tama-bars {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top, 0px));
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
}

.tbar { display: flex; align-items: center; gap: 6px; font-size: 0.95rem; }

.tbar-track {
  width: 74px;
  height: 9px;
  background: #eadfce;
  border-radius: 5px;
  overflow: hidden;
}

.tbar-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, #6fcf5f, #4caf50); transition: width 0.4s; }
.tbar-fill.low { background: linear-gradient(90deg, #ff9c5b, #e5484d); }

.tama-msg {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top, 0px));
  right: 12px;
  max-width: min(46vw, 340px);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  font-size: 1rem;
  font-weight: bold;
  color: var(--ink, #4a3a2a);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.tama-msg.on { opacity: 1; transform: none; }

.tama-actions {
  position: absolute;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 96vw;
}

.tact {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 62px;
  border: none;
  border-radius: 16px;
  padding: 8px 8px 6px;
  font-family: inherit;
  font-size: 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.tact small { font-size: 0.62rem; font-weight: bold; color: #7a6a52; letter-spacing: 0.5px; }

.tact:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }
.tact:disabled { opacity: 0.45; }

.tact-alert { outline: 4px solid #e5484d; animation: alert-pulse 1s infinite; }

.tama-panel {
  position: absolute;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: min(94vw, 620px);
  max-height: min(62vh, 500px);
  overflow-y: auto;
  background: var(--paper, #fdf6ea);
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  z-index: 5;
}

.tama-panel.hidden { display: none; }

.tpanel-close {
  position: sticky;
  top: 0;
  float: right;
  border: none;
  border-radius: 12px;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  background: #eadfce;
  cursor: pointer;
  z-index: 2;
}

.tshop-tabs { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }

.sick-tag { color: #e5484d; }

@media (max-width: 560px) {
  .tama-bars { transform: scale(0.9); transform-origin: top left; }
  .tact { min-width: 54px; font-size: 1.3rem; padding: 7px 6px 5px; }
  .tama-msg { max-width: 58vw; font-size: 0.9rem; }
}

/* ══ Aviso: progreso sin conectar a la nube (falta la clave) ══ */
.cloud-warn {
  display: block;
  width: 100%;
  border: 3px solid #e5484d;
  background: #fff2f0;
  color: #a02c30;
  border-radius: 16px;
  padding: 10px 14px;
  margin: 4px 0 10px;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  animation: alert-pulse 1.6s infinite;
}

/* ══ Las galletas de Capi (sumas y restas manipulativas) ══ */
.ck-stage { margin: 6px 0 2px; }

.ck-plate, .ck-tray {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
  min-height: 86px;
  padding: 22px 12px 12px;
  border-radius: 22px;
  margin: 10px auto 0;
  max-width: 420px;
}

.ck-plate { background: #fff; border: 5px solid #e8d9c2; box-shadow: var(--shadow); }

.ck-tray { background: #fdf2c9; border: 5px dashed #d9a520; }

.ck-label {
  position: absolute;
  top: -12px;
  left: 14px;
  background: var(--yellow, #ffd93d);
  border-radius: 10px;
  padding: 2px 10px;
  font-size: 0.78rem;
  font-weight: bold;
  letter-spacing: 0.4px;
}

.ck-cookie {
  border: none;
  background: none;
  font-size: 2.1rem;
  line-height: 1;
  padding: 4px;
  cursor: default;
  touch-action: none;
  user-select: none;
  font-family: inherit;
}

.ck-cookie.ck-live { cursor: grab; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.25)); animation: ck-wiggle 2.2s infinite; }

.ck-cookie.ck-drag { cursor: grabbing; z-index: 30; position: relative; animation: none; }

@keyframes ck-wiggle {
  0%, 88%, 100% { rotate: 0deg; }
  92% { rotate: -8deg; }
  96% { rotate: 8deg; }
}

.ck-ghost {
  position: fixed;
  z-index: 999;
  font-size: 2.1rem;
  line-height: 1;
  pointer-events: none;
}

.ck-count {
  text-align: center;
  font-weight: bold;
  font-size: 1.05rem;
  margin: 8px 0 0;
  color: #7a5b2f;
}

/* ══ La clase de multiplicar + premio triple de las tablas ══ */
.flag-triple { background: linear-gradient(135deg, #ff9736, #f5563e); color: #fff; }

.times-lesson { text-align: center; }

.times-lesson .lesson-expr { font-size: 1.35rem; font-weight: bold; margin: 8px 0; }

.times-lesson .lesson-triple {
  display: inline-block;
  background: linear-gradient(135deg, #ff9736, #f5563e);
  color: #fff;
  font-weight: bold;
  border-radius: 14px;
  padding: 6px 14px;
  margin: 6px 0 12px;
}

.times-lesson .btn-big { display: block; margin: 10px auto 0; }

.lesson-pop { opacity: 0; animation: lesson-in 0.5s forwards; animation-delay: var(--d, 0s); }

@keyframes lesson-in {
  0% { opacity: 0; transform: scale(0.6); }
  70% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 1; transform: scale(1); }
}
