/* ── Self-hosted fonts (no external request, works offline) ─────────────── */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('./fonts/fredoka-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('./fonts/fredoka-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('./fonts/nunito-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('./fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  /* Palette - Candy Neon */
  --pink:          #FF61A6;   --pink-dark:    #FF147A;
  --orange:        #FF9B6A;   --orange-dark:  #FF5C12;
  --yellow:        #FFEB5C;   --yellow-dark:  #FFD600;
  --green:         #5EF3C5;   --green-dark:   #0ED295;
  --teal:          #5CE4FF;   --teal-dark:    #00BBE0;
  --blue:          #7F9BFF;   --blue-dark:    #3A64FF;
  --purple:        #C78BFF;   --purple-dark:  #9632FF;
  --red:           #FF6B6B;   --red-dark:     #FF1F1F;
  --lime:          #C4FF61;   --lime-dark:    #94EB00;

  /* Semantic */
  --primary:       var(--pink);
  --primary-dark:  var(--pink-dark);
  --secondary:     var(--teal);
  --secondary-dark: var(--teal-dark);

  /* Surface - Liquid Glassmorphism */
  --bg:            #FFF0F8;
  --surface:       rgba(255, 255, 255, 0.4);
  --text:          #2A004D;
  --text-muted:    #8D66A5;
  --border:        rgba(255, 255, 255, 0.8);
  --border-dark:   rgba(255, 105, 180, 0.3);

  /* Legacy compat */
  --glass-bg:      var(--surface);
  --glass-border:  var(--border);
  --shadow-sm:     0 8px 32px rgba(255, 105, 180, 0.1);
  --shadow-md:     0 12px 40px rgba(255, 105, 180, 0.15);
  --shadow-lg:     0 16px 50px rgba(255, 105, 180, 0.2);

  /* Radius - Bubble */
  --r-sm:   16px;
  --r-md:   24px;
  --r-lg:   36px;
  --r-xl:   48px;
  --r-pill: 9999px;

  /* Fonts */
  --font-head: 'Fredoka', sans-serif;
  --font-body: 'Nunito', sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, #FFD1FF, #B5E8FF, #FFF1B8);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: var(--text);
}
/* Pause all decorative animations when a game is fullscreen */
body.game-open {
  animation-play-state: paused;
}
body.game-open .bg-float,
body.game-open .bg-pulse,
body.game-open .bg-spin {
  animation-play-state: paused;
}
/* Respect OS accessibility setting */
@media (prefers-reduced-motion: reduce) {
  body,
  .bg-float, .bg-pulse, .bg-spin,
  .activity-icon, .floating, .section-card-icon {
    animation: none !important;
    transition: none !important;
  }
}
@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
/* ── Decorative background shapes ───────────────────────────────────────── */
.bg-shapes {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}
.bg-shape {
  position: absolute;
  transform-origin: center;
}
@keyframes bgFloat {
  0%,100% { transform: translateY(0) rotate(var(--r, 0deg)); }
  50%      { transform: translateY(-18px) rotate(var(--r, 0deg)); }
}
@keyframes bgPulse {
  0%,100% { transform: scale(1) rotate(var(--r, 0deg)); opacity: 1; }
  50%      { transform: scale(0.68) rotate(var(--r, 0deg)); opacity: 0.25; }
}
@keyframes bgSpin {
  from { transform: rotate(calc(var(--r, 0deg))); }
  to   { transform: rotate(calc(var(--r, 0deg) + 360deg)); }
}
.bg-float { animation: bgFloat ease-in-out infinite; }
.bg-pulse { animation: bgPulse ease-in-out infinite; }
.bg-spin  { animation: bgSpin  linear     infinite; }

h1,h2,h3,h4,h5,h6 { font-family: var(--font-head); font-weight: 600; }

.hidden { display: none !important; }

/* ── Offline indicator ───────────────────────────────────────────────────── */
.offline-bar {
  background: #FF9B6A;
  color: #fff;
  text-align: center;
  font-family: var(--font-head);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  letter-spacing: 0.02em;
}

/* ── App shell ───────────────────────────────────────────────────────────── */
.app-container {
  display: flex;
  flex-direction: column;
  width:  100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  padding: 0.75rem 1rem;
  padding-top:    max(0.75rem, env(safe-area-inset-top));
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  padding-left:   max(1rem,    env(safe-area-inset-left));
  padding-right:  max(1rem,    env(safe-area-inset-right));
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  margin-bottom: 0.75rem;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--r-xl);
}

.header h1 {
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.header-actions { display: flex; align-items: center; gap: 0.5rem; }

.btn-back-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  border: 3px solid var(--border);
  box-shadow: 0 4px 0 var(--border-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.btn-back-circle:hover  { transform: translateY(-2px); box-shadow: 0 6px 0 var(--border-dark); }
.btn-back-circle:active { transform: translateY(3px);  box-shadow: 0 1px 0 var(--border-dark); }

.btn-admin-lock {
  padding: 0.55rem;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--border) !important;
  box-shadow: 0 3px 0 var(--border-dark) !important;
  color: var(--text-muted);
  transition: transform 0.1s, box-shadow 0.1s, color 0.15s;
}
.btn-admin-lock:hover { color: var(--purple); }
.btn-admin-lock:active { transform: translateY(3px) !important; box-shadow: 0 0 0 var(--border-dark) !important; }

/* ── Main content ────────────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  min-height: 0;
  position: relative;
  /* border-radius removed: combined with overflow:hidden it was clipping game
     content, button shadows, and scroll indicators at all edges/corners */
  overflow: hidden;
}

/* ── Dashboard (scrollable) ──────────────────────────────────────────────── */
#view-dashboard {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0 1rem;
}

.dash-section { margin-bottom: 1.5rem; }

.dash-section-label {
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-size: clamp(1.2rem, 3.5vw, 1.6rem);
  font-weight: 600;
  margin-bottom: 1rem;
  padding-left: 0.25rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.dash-section-label::before {
  content: '';
  display: block;
  width: 6px;
  height: 1.2em;
  background: linear-gradient(to bottom, var(--orange), var(--pink));
  border-radius: var(--r-pill);
}

/* ── Activities grid ─────────────────────────────────────────────────────── */
.activities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  grid-template-columns: repeat(auto-fill, minmax(clamp(130px, 20vw, 180px), 1fr));
  gap: 1rem;
}

.activity-card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--r-lg);
  padding: 1.5rem 0.8rem 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
  text-align: center;
  min-height: 145px;
  transition:
    transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.15s ease;
}
.activity-card:hover {
  transform: translateY(-8px) rotate(-2deg);
  box-shadow: 7px 10px 0 var(--border-dark);
}
.activity-card:nth-child(even):hover {
  transform: translateY(-8px) rotate(2deg);
}
.activity-card:active {
  transform: scale(0.93);
  box-shadow: 2px 2px 0 var(--border-dark);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.activity-icon-wrap {
  width: 56px;
  width: clamp(56px, 10vw, 72px);
  height: 56px;
  height: clamp(56px, 10vw, 72px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: float 3.5s ease-in-out infinite;
  flex-shrink: 0;
}

/* Legacy (emoji icon) */
.activity-icon { font-size: 2rem; font-size: clamp(2rem, 5.5vw, 3rem); animation: float 3.5s ease-in-out infinite; }

.activity-title {
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.3px;
}
.activity-desc { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-body); }

/* ── Activity card variants (with image thumbnail) ───────────────────────── */
.activity-card--muted {
  opacity: 0.55;
  pointer-events: none;
}

.activity-card--img {
  padding: 0 0 1rem;
  overflow: hidden;
}
.activity-card--img .activity-title {
  padding: 0 0.7rem;
  margin-top: 0.4rem;
}
.activity-card--img .activity-desc {
  padding: 0 0.7rem;
}

.activity-card-thumb {
  width: 100%;
  height: 80px;
  object-fit: cover;
  display: block;
  border-radius: calc(var(--r-lg) - 3px) calc(var(--r-lg) - 3px) 0 0;
}
.activity-card-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  height: 80px;
}

/* Portrait cards (cuentos) — taller thumbnail */
.activity-card--portrait .activity-card-thumb,
.activity-card--portrait .activity-card-thumb--placeholder {
  height: 110px;
  aspect-ratio: unset;
}

/* ── Full views ──────────────────────────────────────────────────────────── */
#view-detail {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 max(1.2rem, env(safe-area-inset-bottom));
  transition: background-color 0.45s ease;
}

#view-game-active {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 1rem;
}

/* ── Carousel ────────────────────────────────────────────────────────────── */
.carousel-viewport {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  position: relative;
  touch-action: none;
  overscroll-behavior: contain;
}

.carousel-track {
  display: flex;
  align-items: stretch;
  gap: 10px;
  will-change: transform;
}

.carousel-card {
  flex: 0 0 var(--card-w, 300px);
  display: flex;
  flex-direction: column;
  transform: scale(0.88);
  opacity: 0.55;
  filter: blur(1px);
  transition:
    transform 0.40s cubic-bezier(0.25, 0.8, 0.25, 1),
    opacity   0.40s,
    filter    0.40s;
  pointer-events: none;
}
.carousel-card.active {
  transform: scale(1);
  opacity: 1;
  filter: none;
  pointer-events: auto;
}

/* ── Scrubber de posición ──────────────────────────────────────────────────── */
.carousel-scrubber {
  width: 100%;
  padding: 0.45rem 1.5rem 0.35rem;
  box-sizing: border-box;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.scrubber-track {
  position: relative;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: 3px;
  cursor: pointer;
}
.scrubber-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--clr-primary, #FF3D78);
  border-radius: 3px;
  width: 0%;
  pointer-events: none;
  transition: width 0.32s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.scrubber-thumb {
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  background: white;
  border: 3px solid var(--clr-primary, #FF3D78);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  transform: translateY(-50%) translateX(-50%);
  left: 0%;
  pointer-events: none;
  transition: left 0.32s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.carousel-scrubber.scrubbing .scrubber-thumb,
.carousel-scrubber.scrubbing .scrubber-fill {
  transition: none;
}

/* Flashcard inner card */
.fc-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.8rem 1.2rem 1.4rem;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 4px solid var(--border);
  box-shadow: 6px 6px 0 var(--border-dark);
  min-height: min(55vh, 460px);
  gap: 0.6rem;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.flashcard-image {
  max-width: 100%;
  max-height: 40vh;
  object-fit: contain;
  border-radius: var(--r-md);
  animation: bounceIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.flashcard-icon {
  font-size: 5rem;
  font-size: clamp(5rem, 15vw, 9rem);
}
.flashcard-icon-wrap {
  width: 100px;
  width: clamp(100px, 22vw, 160px);
  height: 100px;
  height: clamp(100px, 22vw, 160px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bounceIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  flex-shrink: 0;
}

.image-dots {
  display: flex;
  gap: 7px;
  justify-content: center;
  min-height: 14px;
}
.img-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border-dark);
  transition: background 0.25s, transform 0.25s;
}
.img-dot-active {
  background: var(--primary);
  transform: scale(1.4);
}

/* ── Image stack (multi-image hint) ─────────────────────────────────────── */
.img-stack {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-stack-ghost {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 3px solid var(--border-dark);
  box-shadow: var(--shadow-sm);
}
.img-stack-ghost.g1 {
  transform: rotate(4deg) translate(6px, 6px);
  opacity: 0.7;
  animation: ghost-hint-1 4s ease-in-out 1.8s infinite;
}
.img-stack-ghost.g2 {
  transform: rotate(-3deg) translate(-5px, 7px);
  opacity: 0.45;
  animation: ghost-hint-2 4s ease-in-out 1.8s infinite;
}
@keyframes ghost-hint-1 {
  0%, 55%, 100% { transform: rotate(4deg) translate(6px, 6px); }
  75%           { transform: rotate(9deg) translate(13px, 13px); }
}
@keyframes ghost-hint-2 {
  0%, 55%, 100% { transform: rotate(-3deg) translate(-5px, 7px); }
  75%           { transform: rotate(-7deg) translate(-11px, 13px); }
}

.flashcard-word {
  font-family: var(--font-body);
  font-size: 2.8rem;
  font-size: clamp(2.8rem, 10vw, 5.5rem);
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--text);
  text-align: center;
  word-break: break-word;
  transition: transform 0.2s, color 0.2s;
  line-height: 1.1;
}
.pop { transform: scale(1.12) !important; color: var(--primary) !important; }

/* ── Number cards ─────────────────────────────────────────────────────────── */
.num-shape-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 280px;
  margin-bottom: 0.3rem;
}

.num-shape {
  animation: bounceIn 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--i, 0) * 0.045s);
  flex-shrink: 0;
}

/* Circle */
.num-shape-circle .num-shape {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4361EE, #7B9EFF);
  box-shadow: 0 3px 8px rgba(67,97,238,0.35);
}
/* Square */
.num-shape-square .num-shape {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  background: linear-gradient(135deg, #FF6B6B, #FF3D78);
  box-shadow: 0 3px 8px rgba(255,61,120,0.35);
}
/* Triangle via clip-path */
.num-shape-triangle .num-shape {
  width: 30px;
  height: 26px;
  background: linear-gradient(135deg, #06D6A0, #0ED295);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  box-shadow: none;
}
/* Diamond */
.num-shape-diamond .num-shape {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #C78BFF, #9632FF);
  transform: rotate(45deg);
  border-radius: 4px;
  box-shadow: 0 3px 8px rgba(150,50,255,0.35);
  animation: bounceIn 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--i, 0) * 0.045s);
}
/* Star via clip-path */
.num-shape-star .num-shape {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #FFD600, #FF9B6A);
  clip-path: polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%);
  box-shadow: none;
}
.num-digit {
  font-family: var(--font-head);
  font-size: 5.5rem;
  font-size: clamp(5.5rem, 22vw, 10rem);
  font-weight: 800;
  line-height: 1;
  color: #4361EE;
  -webkit-text-stroke: 3px rgba(255, 255, 255, 0.55);
  paint-order: stroke fill;
  animation: bounceIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  letter-spacing: -3px;
}
.num-emoji-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.45rem;
  max-width: 270px;
}
.num-emoji {
  font-size: 1.7rem;
  font-size: clamp(1.7rem, 6vw, 2.5rem);
  line-height: 1;
  display: inline-block;
  animation: bounceIn 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(var(--i, 0) * 0.05s);
}

/* ── Controls ────────────────────────────────────────────────────────────── */
.controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  width: 100%;
  max-width: 560px;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  border: 2px solid rgba(255,255,255,0.8);
  padding: 0.9rem 1.75rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-head);
  border-radius: var(--r-pill);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  user-select: none;
  white-space: nowrap;
  letter-spacing: 0.3px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  transform: translateY(0);
  background: var(--surface);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
  box-shadow: 0 8px 16px rgba(255,105,180,0.15);
}
.btn:hover  { transform: translateY(-4px) scale(1.05); box-shadow: 0 12px 24px rgba(255,105,180,0.25); }
.btn:active { transform: translateY(2px) scale(0.95);  box-shadow: 0 4px 8px rgba(255,105,180,0.1); }

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 6px 0 var(--primary-dark);
}
.btn-primary:hover  { box-shadow: 0 9px 0 var(--primary-dark); }
.btn-primary:active { box-shadow: 0 1px 0 var(--primary-dark); }

.btn-secondary {
  background: var(--secondary);
  color: white;
  box-shadow: 0 6px 0 var(--secondary-dark);
}
.btn-secondary:hover  { box-shadow: 0 9px 0 var(--secondary-dark); }
.btn-secondary:active { box-shadow: 0 1px 0 var(--secondary-dark); }

.btn-icon {
  padding: 1rem;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--border);
  box-shadow: 0 5px 0 var(--border-dark);
  color: var(--text-muted);
}
.btn-icon:hover  { color: var(--primary); box-shadow: 0 8px 0 var(--border-dark); }
.btn-icon:active { box-shadow: 0 1px 0 var(--border-dark); }

.btn-large {
  padding: 1.1rem 2.4rem;
  font-size: 1.2rem;
}

.btn-sound {
  padding: 1rem 1.25rem;
  border-radius: var(--r-pill);
  background: var(--secondary);
  color: white;
  box-shadow: 0 6px 0 var(--secondary-dark);
  flex-shrink: 0;
}
.btn-sound:hover  { box-shadow: 0 9px 0 var(--secondary-dark); }
.btn-sound:active { box-shadow: 0 1px 0 var(--secondary-dark); }

.btn-sound-card {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 5;
  padding: 0.55rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 0 var(--secondary-dark);
}
.btn-sound-card:hover  { box-shadow: 0 6px 0 var(--secondary-dark) !important; }
.btn-sound-card:active { box-shadow: 0 1px 0 var(--secondary-dark) !important; }
.btn-sound.sound-playing { animation: pulse 0.7s ease-in-out infinite; }
.btn-sound.btn-sound-muted {
  background: rgba(180,180,190,0.35) !important;
  color: rgba(120,120,130,0.7) !important;
  box-shadow: 0 6px 0 rgba(120,120,130,0.25) !important;
  cursor: default;
  pointer-events: none;
  opacity: 0.6;
}

.btn-back-game {
  align-self: flex-start;
  background: var(--surface);
  border: 3px solid var(--border);
  box-shadow: 0 4px 0 var(--border-dark);
  color: var(--text);
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}
.btn-back-game:hover  { box-shadow: 0 6px 0 var(--border-dark); }
.btn-back-game:active { box-shadow: 0 1px 0 var(--border-dark); }

.mt-2 { margin-top: 1rem; }

/* ── Card (generic) ──────────────────────────────────────────────────────── */
.glass {
  background: var(--surface);
  border: 3px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--r-md);
}
.glass-card {
  background: var(--surface);
  border: 4px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--r-xl);
}

/* ── View transitions (iOS-style slide) ─────────────────────────────────── */
@keyframes slideFromRight {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes slideFromLeft {
  from { transform: translateX(-28%); opacity: 0.5; }
  to   { transform: translateX(0);    opacity: 1; }
}
.view-enter-right { animation: slideFromRight 0.3s  cubic-bezier(0.4, 0, 0.2, 1) both; }
.view-enter-left  { animation: slideFromLeft  0.26s  cubic-bezier(0.4, 0, 0.2, 1) both; }

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes bounceIn {
  0%   { opacity: 0; transform: scale(0.5); }
  60%  { transform: scale(1.08); }
  80%  { transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes float {
  0%,100% { transform: translateY(0) rotate(0); }
  50%     { transform: translateY(-10px) rotate(4deg); }
}
@keyframes wiggle {
  0%,100% { transform: rotate(0); }
  20%     { transform: rotate(-8deg) scale(1.05); }
  40%     { transform: rotate(8deg) scale(1.05); }
  60%     { transform: rotate(-5deg); }
  80%     { transform: rotate(5deg); }
}
@keyframes slideUp  { from { opacity:0; transform:translateY(28px); } to { opacity:1; transform:translateY(0); } }
@keyframes popIn    { from { opacity:0; transform:scale(0.75); }       to { opacity:1; transform:scale(1); } }
@keyframes shake    { 0%,100% { transform:translateX(0); } 25% { transform:translateX(-7px); } 75% { transform:translateX(7px); } }
@keyframes pulse    { 0%,100% { transform:scale(1); } 50% { transform:scale(1.07); } }
@keyframes pop      { 0%,100% { transform:scale(1); } 50% { transform:scale(1.2); } }
/* confettiFall keyframe removed — confetti now uses Canvas (see launchConfetti in app.js) */

.floating    { animation: float  3.5s ease-in-out infinite; }
.wiggling    { animation: wiggle 0.6s ease-in-out; }

/* ═══════════════════════════════════════════════════════════════════════════
   GAME VIEWS
═══════════════════════════════════════════════════════════════════════════ */
.game-view {
  width: 100%;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0.5rem 1.5rem;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  flex: 1;
  min-height: 0;
}

.game-hint {
  width: 100%;
  text-align: center;
  font-size: 0.85rem;
  font-size: clamp(0.85rem, 2.5vw, 1.05rem);
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  flex-shrink: 0;
}

.game-title-block { display: flex; flex-direction: column; gap: 0.1rem; }
.game-title {
  font-family: var(--font-head);
  font-size: 1.3rem;
  font-size: clamp(1.3rem, 4.5vw, 1.9rem);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.game-subtitle { font-size: 0.75rem; font-size: clamp(0.75rem, 2vw, 0.95rem); color: var(--text-muted); }
.game-status {
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-size: clamp(1.2rem, 4vw, 1.6rem);
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  min-height: 2rem;
  margin-top: 0.5rem;
}

/* ── MEMOTEST ────────────────────────────────────────────────────────────── */
#game-memo {
  overflow: hidden;
  padding-bottom: 0;
  justify-content: space-between;
}

.memo-grid {
  display: grid;
  gap: 8px;
  flex-shrink: 0;
}

.memo-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.3rem;
  padding-bottom: 0.6rem;
}

.memo-card { min-height: 60px; aspect-ratio: 1/1; perspective: 900px; cursor: pointer; }

.memo-card-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.42s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: var(--r-md);
}
.memo-card.flipped .memo-card-inner,
.memo-card.matched .memo-card-inner { transform: rotateY(180deg); }

.memo-card-back,
.memo-card-front {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  border-radius: var(--r-md);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--border);
  box-shadow: 3px 3px 0 var(--border-dark);
}
.memo-card-back {
  background: linear-gradient(135deg, var(--purple), var(--pink));
  color: white;
  font-size: 1.6rem;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
}
.memo-card-front {
  transform: rotateY(180deg);
  background: var(--surface);
  padding: 0.4rem;
}
.memo-card-front img { max-width:100%; max-height:100%; object-fit:contain; border-radius: var(--r-sm); }
.memo-front-word span { font-family: var(--font-head); font-size: var(--memo-font-size, 1.4rem); font-weight: 700; text-align:center; word-break:break-word; line-height: 1.1; }
.memo-card.matched .memo-card-front { background: #D4EDDA; border-color:#28A745; box-shadow: 3px 3px 0 #28A745; }
.memo-front-combo { flex-direction: column; gap: 0.2rem; }
.memo-front-combo img { max-width: 100%; max-height: 55%; object-fit: contain; border-radius: var(--r-sm); }
.memo-front-combo span { font-family: var(--font-head); font-size: var(--memo-font-size, 0.85rem); font-weight: 700; text-align: center; word-break: break-word; line-height: 1.1; }

/* ── DRAG & DROP ─────────────────────────────────────────────────────────── */
#game-drag {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}

.drag-arena {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: 100%;
  flex: 1;
  min-height: 0;
}
.drag-col { display: flex; flex-direction: column; gap: 0.9rem; }
.drag-item {
  background: var(--surface);
  border: 3px solid var(--border);
  box-shadow: 4px 4px 0 var(--border-dark);
  border-radius: var(--r-md);
  padding: 0.7rem;
  cursor: grab;
  touch-action: none;
  display: flex; align-items: center; justify-content: center;
  flex: 1;
  min-height: 90px;
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.1s;
}
.drag-item:active { transform: scale(1.06) rotate(2deg); cursor: grabbing; box-shadow: 6px 6px 0 var(--border-dark); }
.drag-item img { max-height: 100%; max-width: 100%; object-fit: contain; }
.drag-item.dragging  { opacity: 0.3; }
.drag-item.drag-done { opacity: 0.25; pointer-events: none; }

.drop-target {
  background: var(--bg);
  border: 3px dashed var(--border-dark);
  border-radius: var(--r-md);
  padding: 1rem 0.8rem;
  flex: 1;
  min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
}
.drop-target span { font-family: var(--font-head); font-size: 1.5rem; font-size: clamp(1.5rem, 5vw, 2.2rem); font-weight: 700; text-align: center; }
.drag-new-round-btn { margin-top: 0.75rem; flex-shrink: 0; }
.drop-target.drag-over    { border-color: var(--teal); background: rgba(0,180,216,0.1); transform: scale(1.04); border-style: solid; }
.drop-target.drag-matched { background: #D4EDDA; border-color: #28A745; border-style: solid; }
.drop-target.drag-wrong   { background: rgba(255,61,120,0.1); border-color: var(--pink); animation: shake 0.42s; }

/* ── PIZARRA ─────────────────────────────────────────────────────────────── */
.game-view-canvas { gap: 0.5rem; }
.canvas-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  border-radius: var(--r-xl);
  overflow: hidden;
  background: white;
  border: 4px solid var(--border);
  box-shadow: 6px 6px 0 var(--border-dark);
  touch-action: none;
  display: flex;
  flex-direction: column;
}
.canvas-word-bg {
  position: absolute; top: 0; right: 0; bottom: 110px; left: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Nunito', 'Arial Rounded MT Bold', Arial, sans-serif;
  font-size: 10rem;
  font-weight: 900;
  color: rgba(0,0,0,0.10);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}
#drawing-canvas { position: absolute; top: 0; right: 0; bottom: 0; left: 0; touch-action: none; cursor: crosshair; }

/* Controles dentro de la tarjeta — barra inferior sobre el canvas */
.canvas-controls-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 1rem 0.75rem;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 2px solid rgba(0,0,0,0.06);
  z-index: 2;
}

.canvas-btns { display: flex; gap: 0.8rem; flex-wrap: wrap; justify-content: center; }
.color-picker-row { display: flex; gap: 0.75rem; align-items: center; }
.color-dot {
  width: 36px;
  width: clamp(32px, 7vw, 44px);
  height: 36px;
  height: clamp(32px, 7vw, 44px);
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  flex-shrink: 0;
  box-shadow: 0 4px 0 rgba(0,0,0,0.25);
}
.color-dot.active, .color-dot:hover {
  transform: scale(1.3) translateY(-3px);
  border-color: #222;
  box-shadow: 0 6px 0 rgba(0,0,0,0.25);
}

/* ── VOZ ─────────────────────────────────────────────────────────────────── */
.game-view-voice { justify-content: flex-start; gap: 1rem; }
.voice-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 1.5rem; width: 100%; max-width: 420px; gap: 0.8rem;
  flex: 1; min-height: 0;
}
.voice-image { flex: 1; min-height: 0; max-height: clamp(120px, 38vh, 340px); max-width: 100%; object-fit: contain; border-radius: var(--r-md); }
.voice-word {
  font-family: var(--font-head);
  font-size: 2rem;
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 700;
  letter-spacing: 2px;
}
.btn-mic {
  font-family: var(--font-head);
  font-size: 1.3rem;
  font-size: clamp(1.3rem, 4.5vw, 1.8rem);
  font-weight: 600;
  padding: 1.1rem 2rem;
  padding: 1.1rem clamp(2rem, 8vw, 4rem);
  border-radius: var(--r-pill);
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 7px 0 var(--primary-dark);
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.btn-mic:hover  { transform: translateY(-3px); box-shadow: 0 10px 0 var(--primary-dark); }
.btn-mic:active { transform: translateY(5px);  box-shadow: 0 2px 0 var(--primary-dark); }
.btn-mic:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-mic.mic-listening { background: var(--orange); box-shadow: 0 7px 0 var(--orange-dark); animation: pulse 0.85s infinite; }

.voice-feedback { font-family: var(--font-head); font-size: 1.1rem; font-size: clamp(1.1rem, 3.5vw, 1.5rem); font-weight: 600; text-align:center; }
.voice-success  { color: var(--green); }
.voice-fail     { color: var(--primary); }
.voice-heard    { font-size: 0.95rem; color: var(--text-muted); text-align: center; font-family: var(--font-body); }

/* ── Admin Modal ─────────────────────────────────────────────────────────── */
.admin-modal-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(26,0,48,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9998;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.admin-modal {
  width: min(92vw, 380px);
  padding: 2rem;
  display: flex; flex-direction: column; align-items: center; gap: 1.1rem;
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: var(--surface);
  border: 4px solid var(--border);
  box-shadow: 8px 8px 0 var(--border-dark);
  border-radius: var(--r-xl);
}
.admin-modal-title { font-family: var(--font-head); font-size: 1.6rem; text-align: center; }
.admin-math-q      { font-family: var(--font-head); font-size: 1.5rem; font-weight:600; text-align:center; }
.admin-math-input  {
  width: 100%; text-align: center;
  font-family: var(--font-head);
  font-size: 2.4rem; font-weight: 700;
  padding: 0.8rem;
  border: 4px solid var(--border);
  border-radius: var(--r-lg);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  background: var(--bg);
  color: var(--text);
}
.admin-math-input:focus { border-color: var(--secondary); box-shadow: 0 4px 0 var(--secondary-dark); }
.admin-math-error  { color: var(--red); font-weight: 800; font-family: var(--font-head); animation: shake 0.4s; }
.admin-modal-btns  { display:flex; gap:0.8rem; width:100%; }
.admin-modal-btns .btn { flex:1; justify-content:center; }

/* ── Confetti ────────────────────────────────────────────────────────────── */
.confetti-container { position: fixed; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; z-index: 9999; overflow: hidden; }

/* ═══════════════════════════════════════════════════════════════════════════
   HOME SCREEN — 3 secciones
═══════════════════════════════════════════════════════════════════════════ */
#view-home {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0 1rem;
  display: flex;
  flex-direction: column;
}

.home-greeting {
  text-align: center;
  padding: 0.75rem 1rem 1.4rem;
  flex-shrink: 0;
}
.home-greeting-name {
  font-family: var(--font-head);
  font-size: 1.7rem;
  font-size: clamp(1.7rem, 5.5vw, 3rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--orange), var(--pink), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.home-greeting-sub {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.sections-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  flex: 1;
  min-height: 0;
}
@media (max-width: 520px) {
  .sections-grid { grid-template-columns: 1fr; flex: none; }
}

.section-card {
  border-radius: var(--r-xl);
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  cursor: pointer;
  min-height: 190px;
  user-select: none;
  text-align: center;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease;
}
.section-card:hover  { transform: translateY(-8px); }
.section-card:active { transform: translateY(6px); }

.section-card-icon  { display: flex; align-items: center; justify-content: center; animation: float 3.5s ease-in-out infinite; }
.section-card-title {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-size: clamp(1.1rem, 3.2vw, 1.55rem);
  font-weight: 600;
  line-height: 1.2;
  color: white;
  text-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.sec-aprender {
  background: var(--orange);
  box-shadow: 0 8px 0 var(--orange-dark), 0 12px 24px rgba(204,68,0,0.25);
}
.sec-aprender:hover  { box-shadow: 0 12px 0 var(--orange-dark), 0 16px 28px rgba(204,68,0,0.3); }
.sec-aprender:active { box-shadow: 0 3px 0 var(--orange-dark); }

.sec-buscar {
  background: var(--teal);
  box-shadow: 0 8px 0 var(--teal-dark), 0 12px 24px rgba(0,119,160,0.25);
}
.sec-buscar:hover  { box-shadow: 0 12px 0 var(--teal-dark), 0 16px 28px rgba(0,119,160,0.3); }
.sec-buscar:active { box-shadow: 0 3px 0 var(--teal-dark); }

.sec-cuentos {
  background: var(--purple);
  box-shadow: 0 8px 0 var(--purple-dark), 0 12px 24px rgba(106,13,173,0.25);
}
.sec-cuentos:hover  { box-shadow: 0 12px 0 var(--purple-dark), 0 16px 28px rgba(106,13,173,0.3); }
.sec-cuentos:active { box-shadow: 0 3px 0 var(--purple-dark); }

/* ═══════════════════════════════════════════════════════════════════════════
   BUSCAR A CLARISA
═══════════════════════════════════════════════════════════════════════════ */
#view-buscar {
  flex-direction: column;
  padding: 0;
  align-items: stretch;
  overflow: hidden;
}

.buscar-empty {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1rem; text-align: center; padding: 2rem;
}
.buscar-empty-icon { font-size: 5rem; }
.buscar-empty-text {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.6;
}

.buscar-viewer {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column;
}
.buscar-wrap {
  flex: 1; min-height: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #111;
  cursor: grab;
  touch-action: none;
}
.buscar-wrap:active { cursor: grabbing; }
.buscar-img {
  max-width: 100%; max-height: 100%;
  object-fit: contain; display: block;
  transform-origin: center center;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.buscar-footer {
  flex-shrink: 0;
  padding: 0.7rem 1.5rem;
  display: flex; flex-direction: column; gap: 0.4rem;
  background: var(--surface);
  border-top: 3px solid var(--border);
  box-shadow: 0 -3px 0 var(--border-dark);
}
.buscar-footer-main { display: flex; justify-content: space-between; align-items: center; }
.buscar-title   { font-family: var(--font-head); font-weight: 600; font-size: 0.95rem; font-size: clamp(0.95rem, 2.5vw, 1.2rem); }
.buscar-counter { font-size: 0.88rem; color: var(--text-muted); font-family: var(--font-body); }
.buscar-targets-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.buscar-targets-row:empty { display: none; }
.bt-chip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.8rem; font-family: var(--font-head); font-weight: 700;
  background: var(--bg); border: 2px solid var(--border); color: var(--text-muted);
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}
.bt-chip.bt-found { background: #4ECDC4; border-color: #3ab7af; color: #fff; }

/* Sparkle on target found */
.buscar-sparkle {
  position: fixed; transform: translate(-50%, -50%);
  background: #4ECDC4; color: #fff;
  font-family: var(--font-head); font-weight: 900; font-size: 1.1rem;
  padding: 0.35rem 0.8rem; border-radius: 999px;
  pointer-events: none; z-index: 9999;
  animation: buscarSparkle 0.9s ease forwards;
}
@keyframes buscarSparkle {
  0%   { opacity:1; transform: translate(-50%,-50%) scale(0.5); }
  40%  { opacity:1; transform: translate(-50%,-160%) scale(1.15); }
  100% { opacity:0; transform: translate(-50%,-260%) scale(0.9); }
}

/* Win toast */
.buscar-win-toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,0.82); color: #fff;
  font-family: var(--font-head); font-weight: 900; font-size: 1.4rem; font-size: clamp(1.4rem, 5vw, 2rem);
  padding: 1rem 2rem; border-radius: 20px;
  pointer-events: none; z-index: 9999;
  animation: buscarWinToast 2.2s ease forwards;
}
@keyframes buscarWinToast {
  0%   { opacity:0; transform: translate(-50%,-50%) scale(0.85); }
  15%  { opacity:1; transform: translate(-50%,-50%) scale(1); }
  75%  { opacity:1; transform: translate(-50%,-50%) scale(1); }
  100% { opacity:0; transform: translate(-50%,-50%) scale(1); }
}

/* ── Target editor (admin) ── */
.targets-img-wrap {
  position: relative; cursor: crosshair;
  border-radius: 12px; overflow: hidden;
  margin-bottom: 0.8rem; border: 2px solid var(--border);
}
.targets-preview-img { width: 100%; height: auto; display: block; pointer-events: none; }
#targets-pins { position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; }
.t-pin {
  position: absolute; width: 30px; height: 30px; border-radius: 50%;
  transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 0.8rem; color: #fff;
  cursor: pointer; pointer-events: auto;
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  font-family: var(--font-head);
  transition: transform 0.15s;
}
.t-pin:hover { transform: translate(-50%,-50%) scale(1.25); }
.targets-list { list-style: none; padding: 0; margin: 0 0 0.4rem; display: flex; flex-direction: column; gap: 0.5rem; }
.targets-list-item { display: flex; align-items: center; gap: 0.6rem; }
.targets-list-item .form-input { flex: 1; padding: 0.5rem 0.75rem; font-size: 0.95rem; }
.t-pin-mini {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 0.75rem; color: #fff; font-family: var(--font-head);
}
.targets-empty-msg { font-size: 0.82rem; color: var(--muted); text-align: center; padding: 0.4rem 0; margin: 0; }

/* ═══════════════════════════════════════════════════════════════════════════
   CUENTOS — lista
═══════════════════════════════════════════════════════════════════════════ */
.cuentos-grid {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 25vw, 210px), 1fr));
  gap: 1.2rem;
  align-content: start;
}
.cuento-card {
  background: var(--surface);
  border: 3px solid var(--border);
  box-shadow: 5px 5px 0 var(--border-dark);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.15s;
}
.cuento-card:hover  { transform: translateY(-7px) rotate(-1deg); box-shadow: 8px 10px 0 var(--border-dark); }
.cuento-card:active { transform: translateY(3px); box-shadow: 2px 2px 0 var(--border-dark); }
.cuento-cover {
  width: 100%; min-height: 120px; aspect-ratio: 3/4; object-fit: cover; display: block;
}
.cuento-cover-placeholder {
  width: 100%; min-height: 160px; aspect-ratio: 3/4;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 2.5rem;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
}
.cuento-info { padding: 0.75rem 1rem; }
.cuento-title-text {
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.cuento-pages-count { font-size: 0.8rem; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════════
   CUENTO READER
═══════════════════════════════════════════════════════════════════════════ */
#view-cuento-reader { flex-direction: column; padding: 0; }

.reader-viewport {
  flex: 1; min-height: 0;
  overflow-x: scroll; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  display: flex;
  touch-action: pan-x;
}
.reader-viewport::-webkit-scrollbar { display: none; }
.reader-track { display: flex; height: 100%; }
.reader-page {
  flex-shrink: 0; height: 100%;
  scroll-snap-align: start;
  display: flex; flex-direction: column; overflow: hidden;
  background: #000;
}
.reader-page-img   { flex: 1; min-height: 0; width: 100%; object-fit: contain; display: block; }
.reader-page-placeholder {
  flex: 1;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 5rem;
}
.reader-page-text {
  flex-shrink: 0;
  padding: 0.9rem 1.5rem;
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-size: clamp(1.1rem, 3vw, 1.7rem);
  font-weight: 500;
  text-align: center;
  background: var(--surface);
  border-top: 3px solid var(--border);
  color: var(--text);
  line-height: 1.5;
}
.reader-footer {
  flex-shrink: 0;
  padding: 0.55rem 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border-top: 3px solid var(--border);
  box-shadow: 0 -3px 0 var(--border-dark);
}
.reader-page-counter {
  font-family: var(--font-head);
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 4ch;
  text-align: center;
}
.reader-dots { display: flex; gap: 8px; align-items: center; min-height: 22px; }
.reader-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--border-dark); cursor: pointer;
  transition: background 0.25s, transform 0.25s;
  border: 2px solid transparent;
}
.reader-dot.active {
  background: var(--primary);
  transform: scale(1.5);
  border-color: var(--primary-dark);
  box-shadow: 0 3px 0 var(--primary-dark);
}

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE — iPad portrait & landscape
═══════════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  .app-container { padding: 1rem 1.5rem; }
  .activities-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1.2rem; }
  .activity-card { min-height: 165px; padding: 2rem 1rem 1.5rem; }
  .drag-item, .drop-target { min-height: 150px; }
}

@media (min-width: 1024px) {
  .activities-grid { grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 1.4rem; }
  .activity-card { min-height: 185px; }
  .drag-arena { gap: 1.5rem; }
  .game-view-voice { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: flex-start; }
  .game-view-voice .game-header { width: 100%; }
  .voice-card { max-width: 360px; flex: 0 1 auto; }
}

@media (max-width: 480px) {
  /* ── General ─────────────────────────────────────────────── */
  .app-container {
    padding: 0.5rem 0.6rem;
    padding-top:    max(0.5rem, env(safe-area-inset-top));
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    padding-left:   max(0.6rem, env(safe-area-inset-left));
    padding-right:  max(0.6rem, env(safe-area-inset-right));
  }
  .header { padding: 0.6rem 0.9rem; margin-bottom: 0.5rem; border-radius: var(--r-lg); }

  /* ── Dashboard ───────────────────────────────────────────── */
  .activities-grid { gap: 0.7rem; }
  .activity-card { padding: 1.1rem 0.6rem 0.9rem; min-height: 130px; }
  .activity-icon-wrap { width: 54px; width: clamp(54px, 15vw, 76px); height: 54px; height: clamp(54px, 15vw, 76px); border-radius: var(--r-md); }
  .activity-title { font-size: 0.8rem; font-size: clamp(0.8rem, 4vw, 1rem); }
  .activity-desc  { font-size: 0.65rem; }
  .dash-section-label { font-size: 1rem; }

  /* ── Flashcard controls ──────────────────────────────────── */
  .controls { gap: 0.5rem; padding: 0 0.3rem; }
  .btn-large { padding: 0.8rem 1.2rem; font-size: 1rem; }
  .btn-icon  { padding: 0.8rem; }
  .btn-sound:not(.btn-sound-card) { padding: 0.8rem 0.9rem; font-size: 0.9rem; }

  /* ── Games ───────────────────────────────────────────────── */
  .game-view  { padding: 0 0.3rem 1rem; }
  .game-hint  { font-size: 0.78rem; margin-bottom: 0.5rem; }
  .game-status { font-size: 1rem; }

  /* Drag */
  .drag-arena { gap: 0.6rem; }
  .drag-col   { gap: 0.6rem; }
  .drag-item, .drop-target { min-height: 70px; }

  /* Voz */
  .voice-card  { padding: 1rem; }
  .voice-image { max-height: clamp(80px, 18vh, 140px); }
  .btn-mic     { font-size: 1.1rem; padding: 0.9rem 1.4rem; }

  /* Pizarra */
  .color-picker-row { gap: 0.45rem; }
  .canvas-btns { gap: 0.45rem; }
  .canvas-controls-overlay { padding: 0.45rem 0.7rem 0.6rem; gap: 0.4rem; }

  /* ── Letras ──────────────────────────────────────────────── */
  .letras-card       { padding: 1rem 0.75rem; gap: 0.9rem; }
  .letras-combos-row { gap: 0.4rem; }
  .letra-combo-btn   { padding: 0.4rem 0.5rem; min-width: 46px; }
  .combo-text        { font-size: 1.3rem; }
  .letras-sound-btn  { padding: 0.55rem 0.7rem !important; min-width: 58px; }
  .letras-controls   { gap: 1.5rem; }

  /* ── Buscar ──────────────────────────────────────────────── */
  .buscar-footer { padding: 0.5rem 0.7rem 0.6rem; }
  .bt-chip       { padding: 0.15rem 0.45rem; font-size: 0.72rem; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   3D PRESS — override global, aplica en absolutamente todos los botones
   (esto gana sobre cualquier regla previa de box-shadow gaussiano)
═══════════════════════════════════════════════════════════════════════════ */
.btn {
  box-shadow: 0 5px 0 var(--border-dark) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
.btn:hover  { transform: translateY(-3px) !important; box-shadow: 0 8px 0 var(--border-dark) !important; }
.btn:active { transform: translateY(4px)  !important; box-shadow: 0 1px 0 var(--border-dark) !important; }

.btn-primary  { box-shadow: 0 6px 0 var(--primary-dark)   !important; }
.btn-primary:hover  { box-shadow: 0 9px  0 var(--primary-dark)   !important; }
.btn-primary:active { box-shadow: 0 1px  0 var(--primary-dark)   !important; }

.btn-secondary  { box-shadow: 0 6px 0 var(--secondary-dark) !important; }
.btn-secondary:hover  { box-shadow: 0 9px  0 var(--secondary-dark) !important; }
.btn-secondary:active { box-shadow: 0 1px  0 var(--secondary-dark) !important; }

.btn-icon  { box-shadow: 0 5px 0 var(--border-dark) !important; }
.btn-icon:hover  { box-shadow: 0 8px 0 var(--border-dark) !important; }
.btn-icon:active { box-shadow: 0 1px 0 var(--border-dark) !important; }

.btn-sound  { box-shadow: 0 6px 0 var(--secondary-dark) !important; }
.btn-sound:hover  { box-shadow: 0 9px 0 var(--secondary-dark) !important; }
.btn-sound:active { box-shadow: 0 1px 0 var(--secondary-dark) !important; }

.btn-back-circle  { box-shadow: 0 4px 0 var(--border-dark) !important; }
.btn-back-circle:hover  { box-shadow: 0 6px 0 var(--border-dark) !important; }
.btn-back-circle:active { transform: translateY(3px) !important; box-shadow: 0 1px 0 var(--border-dark) !important; }

.btn-mic  { box-shadow: 0 7px 0 var(--primary-dark) !important; }
.btn-mic:hover  { box-shadow: 0 10px 0 var(--primary-dark) !important; }
.btn-mic:active { box-shadow: 0 2px  0 var(--primary-dark) !important; }

.btn-admin-lock  { box-shadow: 0 3px 0 var(--border-dark) !important; }
.btn-admin-lock:active { transform: translateY(3px) !important; box-shadow: 0 0 0 transparent !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   LETRAS
═══════════════════════════════════════════════════════════════════════════ */
#view-letras {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.75rem max(1rem, env(safe-area-inset-bottom));
  gap: 0.75rem;
}

.letras-card-area {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.letras-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.5rem 1.2rem;
  width: min(96%, 580px);
  min-height: min(60vh, 400px);
  gap: 1.2rem;
}

@keyframes letraIn {
  0%   { opacity: 0; transform: scale(0.5) rotate(-8deg); }
  60%  { transform: scale(1.08) rotate(2deg); }
  80%  { transform: scale(0.96) rotate(-1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.letras-letters {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  gap: clamp(1rem, 5vw, 2.5rem);
  width: 100%;
}

/* Bloque letra mayúscula+minúscula */
.letra-block {
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 3vw, 1.5rem);
}

.letra-upper {
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  font-size: 7rem;
  font-size: clamp(6rem, 20vw, 13rem);
  font-weight: 700;
  color: #3A64FF;
  line-height: 1;
  display: block;
  animation: letraIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  -webkit-text-stroke: 3px rgba(255, 255, 255, 0.8);
  paint-order: stroke fill;
}

.letra-lower {
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  font-size: 5.5rem;
  font-size: clamp(4.5rem, 16vw, 10rem);
  font-weight: 700;
  color: var(--pink);
  line-height: 1;
  display: block;
  animation: letraIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.07s both;
  -webkit-text-stroke: 3px rgba(255, 255, 255, 0.8);
  paint-order: stroke fill;
}

/* Columna de botones de sonido dentro de la tarjeta */
.letras-sound-col {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex-shrink: 0;
}

.letras-sound-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.7rem 0.9rem !important;
  min-width: 68px;
}

.letras-sound-label {
  font-size: 0.75rem;
  font-family: var(--font-head);
  font-weight: 700;
  letter-spacing: 0.3px;
}

/* Sílabas dentro de la tarjeta */
.letras-combos-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
  flex-shrink: 0;
  width: 100%;
}

.letra-combo-btn {
  font-family: var(--font-head);
  font-weight: 700;
  padding: 0.55rem 0.7rem;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 3px solid var(--border);
  box-shadow: 0 4px 0 var(--border-dark);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.1s;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  user-select: none;
  min-width: 54px;
}
.letra-combo-btn:hover  { transform: translateY(-3px); box-shadow: 0 7px 0 var(--border-dark); }
.letra-combo-btn:active { transform: translateY(3px);  box-shadow: 0 1px 0 var(--border-dark); }
.letra-combo-btn.playing {
  background: var(--secondary);
  color: white;
  box-shadow: 0 4px 0 var(--secondary-dark) !important;
}

/* Texto de sílaba con letra resaltada */
.combo-text {
  font-size: 1.6rem;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  line-height: 1;
  letter-spacing: 1px;
}
.combo-letra { color: #3A64FF; -webkit-text-stroke: 1.5px rgba(255,255,255,0.7); paint-order: stroke fill; }
.combo-vocal { color: var(--pink); -webkit-text-stroke: 1.5px rgba(255,255,255,0.7); paint-order: stroke fill; }

.combo-icon {
  color: var(--text-muted);
  display: flex;
  align-items: center;
}
.letra-combo-btn.playing .combo-icon { color: white; }

.letras-controls {
  flex-shrink: 0;
  gap: 2rem;
}

/* ── Legibilidad en glassmorphism — borde blanco en textos ───────────────── */

/* Palabra principal de la flashcard — crítica para aprender a leer */
.flashcard-word {
  -webkit-text-stroke: 2.5px rgba(255,255,255,0.7);
  paint-order: stroke fill;
}

/* Títulos de cards sobre fondo translúcido */
.activity-title,
.cuento-title-text,
.cuento-dash-title,
.voice-word,
.game-title {
  -webkit-text-stroke: 1.5px rgba(255,255,255,0.6);
  paint-order: stroke fill;
}

/* Section labels del dashboard */
.dash-section-label {
  text-shadow:
    0 0 8px rgba(255,255,255,0.9),
    0 1px 4px rgba(255,255,255,0.7);
}

/* Texto de botones (no necesita stroke, el bg sólido ya da contraste) */
.btn-primary, .btn-secondary, .btn-mic, .btn-sound {
  -webkit-text-stroke: 0 !important;
}

/* ══════════════════════════════════════════════════════════════════════════
   TELÉFONO
══════════════════════════════════════════════════════════════════════════ */
.game-view-phone {
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  max-width: 900px;
  width: 100%;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem max(1rem, env(safe-area-inset-bottom));
  overflow: hidden;
}

/* ── Agenda ────────────────────────────────────────────────────────────── */
.phone-agenda {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  overflow: hidden;
}

.phone-agenda-header {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-bottom: 0.45rem;
  border-bottom: 2px solid var(--border-dark);
  margin-bottom: 0.45rem;
  flex-shrink: 0;
}

.phone-agenda-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.phone-contact {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  gap: 0.55rem;
  flex-shrink: 0;
}
.phone-contact:active {
  background: rgba(255, 105, 180, 0.25);
  transform: scale(0.97);
}

.phone-contact-img {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  object-fit: contain;
  background: rgba(255,255,255,0.4);
  flex-shrink: 0;
}

.phone-contact-name {
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phone-contact-num {
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--blue);
  flex-shrink: 0;
  letter-spacing: 0.05em;
}

/* ── Phone device ──────────────────────────────────────────────────────── */
.phone-device {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ── Screen ────────────────────────────────────────────────────────────── */
.phone-screen-area {
  flex: 0 0 auto;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
  position: relative;
  overflow: hidden;
}

.phone-dial-display {
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  font-size: 2rem;
  font-size: clamp(1.6rem, 6vw, 2.8rem);
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text);
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.phone-dial-display.phone-dial-error {
  color: var(--primary);
  animation: shake 0.4s;
}

.phone-callee-wrap {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  gap: 0.2rem;
}

.phone-callee-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: var(--r-sm);
}

.phone-callee-name {
  font-family: var(--font-head);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.phone-calling-status {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
  text-align: center;
  animation: phonePulse 0.9s ease-in-out infinite;
}

@keyframes phonePulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Keyboard body ─────────────────────────────────────────────────────── */
.phone-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.6rem;
  gap: 0.4rem;
  border-radius: var(--r-lg);
}

/* ── Numpad ────────────────────────────────────────────────────────────── */
.phone-numpad {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 0.4rem;
}

.phone-key-empty { background: transparent; }

/* ── QWERTY ────────────────────────────────────────────────────────────── */
.phone-qwerty {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.2rem 0;
}

.phone-qwerty-row {
  display: flex;
  justify-content: center;
  gap: 0.22rem;
  height: 54px;
  flex-shrink: 0;
}

/* ── Keys (shared base — phone & typing) ───────────────────────────────── */
.phone-key,
.typing-key {
  font-family: var(--font-head);
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone-key {
  font-size: 1.4rem;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  transition: background 0.15s, color 0.15s, transform 0.08s, box-shadow 0.08s;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  line-height: 1;
  width: 100%;
  height: 100%;
}

.phone-digit-key {
  font-size: 1.8rem;
  font-size: clamp(1.6rem, 3.8vh, 2.4rem);
}

.phone-key:active {
  transform: translateY(3px) scale(0.94);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.phone-qwerty-key {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 100%;
  font-size: 0.9rem;
}

/* ── Controls row (3 botones) ─────────────────────────────────────────── */
.phone-kb-controls {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  height: 68px;
  margin-top: 0.45rem;
}

.phone-key-call {
  flex: 1;
  background: #22C55E;
  color: white;
  box-shadow: 0 4px 0 #16A34A;
  font-size: 1.3rem;
  border-radius: var(--r-md);
}
.phone-key-call:active {
  box-shadow: 0 1px 0 #16A34A;
}

.phone-key-call.phone-key-call-ready {
  animation: phoneCallReadyPulse 0.75s ease-in-out infinite;
}
@keyframes phoneCallReadyPulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 4px 0 #16A34A, 0 0 16px rgba(34,197,94,0.5); }
  50%       { transform: scale(1.1); box-shadow: 0 4px 0 #16A34A, 0 0 32px rgba(34,197,94,0.9); }
}

.phone-key-del {
  flex: 1;
  height: 100%;
  font-size: 1.2rem;
  background: #EF4444;
  color: white;
  box-shadow: 0 4px 0 #B91C1C;
  border-radius: var(--r-md);
}
.phone-key-del:active {
  box-shadow: 0 1px 0 #B91C1C;
}

.phone-key-toggle {
  flex: 1;
  height: 100%;
  font-size: 1.15rem;
  font-family: var(--font-head);
  font-weight: 700;
  background: rgba(127, 155, 255, 0.28);
  color: var(--blue);
  box-shadow: 0 4px 0 rgba(58,100,255,0.22);
  border-radius: var(--r-md);
}
.phone-key-toggle:active {
  box-shadow: 0 1px 0 rgba(58,100,255,0.22);
}

/* ── iPhone / pantalla pequeña ────────────────────────────────────────── */
@media (max-width: 600px) {
  .game-view-phone {
    flex-direction: column;
    align-items: stretch;
    padding: 0.3rem 0.35rem max(0.6rem, env(safe-area-inset-bottom));
    gap: 0.4rem;
    overflow: hidden;
  }

  /* Agenda: arriba, más alta, con scroll vertical */
  .phone-agenda {
    flex: 0 0 auto;
    max-height: 30vh;
    padding: 0.4rem 0.5rem;
  }

  .phone-agenda-header {
    font-size: 0.85rem;
    padding-bottom: 0.3rem;
    margin-bottom: 0.3rem;
  }

  .phone-agenda-list {
    flex-direction: row;
    flex-wrap: wrap;
    overflow-x: hidden;
    overflow-y: auto;
    gap: 0.3rem;
  }

  .phone-contact {
    flex-direction: row;
    align-items: center;
    flex: 0 0 calc(50% - 0.15rem);
    min-width: 0;
    padding: 0.35rem 0.45rem;
    gap: 0.35rem;
  }

  .phone-contact-img { width: 32px; height: 32px; }
  .phone-contact-name { font-size: 0.78rem; }
  .phone-contact-num  { font-size: 0.8rem; }

  /* Dispositivo llena el resto */
  .phone-device {
    flex: 1;
    min-height: 0;
    width: 100%;
  }

  .phone-screen-area { min-height: 100px; flex: 0 0 auto; }
  .phone-callee-img  { width: 60px; height: 60px; }
  .phone-callee-name { font-size: 1.3rem; }

  .phone-body {
    flex: 1;
    min-height: 0;
    padding: 0.4rem;
    gap: 0.3rem;
  }

  .phone-numpad { gap: 0.3rem; }
  .phone-qwerty-row { height: 46px; }
  .phone-kb-controls { height: 58px; margin-top: 0.35rem; }
}

/* ══════════════════════════════════════════════════════════════════════════
   TECLADO
══════════════════════════════════════════════════════════════════════════ */
.game-view-typing {
  flex-direction: column;
  align-items: stretch;
  max-width: 900px;
  padding: 0.4rem 0.4rem max(0.5rem, env(safe-area-inset-bottom));
  gap: 0.4rem;
  overflow: hidden;
}

.typing-top {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  flex: 0 0 auto;
  flex-shrink: 0;
  min-height: 150px;
  height: 26vh;
}

.typing-img-card {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  overflow: hidden;
}

.typing-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-md);
}

.typing-word-card {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.5rem;
  overflow: hidden;
}

.typing-letters {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-end;
  gap: 0.15rem;
  font-size: 2.5rem;
}

.typing-letter {
  font-family: var(--font-head);
  font-weight: 700;
  color: rgba(42, 0, 77, 0.18);
  line-height: 1;
  padding-bottom: 0.06em;
  border-bottom: 0.06em solid rgba(42, 0, 77, 0.12);
  transition: color 0.15s;
  text-transform: uppercase;
  -webkit-user-select: none;
  user-select: none;
}

.typing-letter-active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  animation: typingBlink 0.85s ease-in-out infinite;
}

.typing-letter-done {
  color: var(--green-dark) !important;
  border-bottom-color: var(--green-dark) !important;
  animation: typingPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.typing-letter-wrong {
  animation: shake 0.35s;
}

@keyframes typingBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

@keyframes typingPop {
  0%   { transform: scale(1) translateY(0); }
  50%  { transform: scale(1.5) translateY(-6px); }
  100% { transform: scale(1) translateY(0); }
}

/* ── Teclado QWERTY ──────────────────────────────────────────────────── */
.typing-keyboard {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.4rem 0.25rem 0.3rem;
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.45);
  border: 3px solid var(--border);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.typing-kb-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: stretch;
  gap: 0.22rem;
  flex: 1;
  min-height: 0;
}

.typing-key {
  flex: 1;
  min-width: 0;
  max-width: 80px;
  font-size: 1.35rem;
  font-size: clamp(0.85rem, 3.8vw, 1.45rem);
  color: var(--text);
  background: white;
  border-radius: var(--r-md);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
  touch-action: manipulation;
  transition: background 0.12s, color 0.12s;
}

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

.typing-key-del {
  flex: 1.4;
  max-width: 90px;
  background: rgba(255, 97, 166, 0.12);
  color: var(--primary);
}

.typing-key-del:active {
  box-shadow: 0 1px 0 rgba(255, 20, 122, 0.2);
}

@media (max-width: 480px) {
  .typing-top { min-height: 120px; height: 22vh; }
  .typing-key { font-size: 0.88rem; border-radius: var(--r-sm); }
}

/* ── iOS 12 flex-gap fallbacks ──────────────────────────────────────────── */
/* .no-flex-gap is set on <html> by JS detection in index.html              */
/* Linear flex: adjacent sibling margin. Wrapping flex: negative margin trick */

/* Header */
.no-flex-gap .header-left > * + *        { margin-left:  0.65rem; }
.no-flex-gap .header-actions > * + *     { margin-left:  0.5rem;  }
.no-flex-gap .dash-section-label > * + * { margin-left:  0.5rem;  }

/* Cards (column) */
.no-flex-gap .activity-card > * + *  { margin-top: 0.55rem; }
.no-flex-gap .fc-card > * + *        { margin-top: 0.6rem;  }
.no-flex-gap .section-card > * + *   { margin-top: 1.1rem;  }

/* Carousel (row) */
.no-flex-gap .carousel-track > * + * { margin-left: 16px; }

/* Controls & buttons */
.no-flex-gap .controls > * + *       { margin-left: 1rem;    }
.no-flex-gap .btn > * + *            { margin-left: 0.45rem; }

/* Image dots (row) */
.no-flex-gap .image-dots > * + *     { margin-left: 7px; }

/* num-emoji-grid wraps (gap: 0.25rem 0.45rem) */
.no-flex-gap .num-emoji-grid         { margin: -0.125rem -0.225rem; }
.no-flex-gap .num-emoji-grid > *     { margin:  0.125rem  0.225rem; }

/* Game titles */
.no-flex-gap .game-title > * + *       { margin-left: 0.4rem;  }
.no-flex-gap .game-title-block > * + * { margin-top:  0.1rem;  }

/* Memotest footer (column) */
.no-flex-gap .memo-footer > * + *    { margin-top: 0.4rem; }

/* Voice game (column) */
.no-flex-gap .voice-card > * + *     { margin-top:  0.8rem; }
.no-flex-gap .btn-mic > * + *        { margin-left: 0.5rem; }

/* Drag & drop (column) */
.no-flex-gap .drag-col > * + *       { margin-top: 0.9rem; }

/* Phone game */
.no-flex-gap .phone-agenda-header > * + * { margin-left: 0.4rem;  }
.no-flex-gap .phone-agenda-list > * + *   { margin-top:  0.4rem;  }
.no-flex-gap .phone-contact > * + *       { margin-left: 0.55rem; }
.no-flex-gap .phone-device > * + *        { margin-top:  0.5rem;  }
.no-flex-gap .phone-callee-wrap > * + *   { margin-top:  0.2rem;  }
.no-flex-gap .phone-body > * + *          { margin-top:  0.4rem;  }
.no-flex-gap .phone-qwerty > * + *        { margin-top:  0.3rem;  }
.no-flex-gap .phone-qwerty-row > * + *    { margin-left: 0.22rem; }
.no-flex-gap .phone-kb-controls > * + *   { margin-left: 0.4rem;  }
.no-flex-gap .game-view-phone > * + *     { margin-left: 0.75rem; }

/* Typing game */
.no-flex-gap .game-view-typing > * + * { margin-top:  0.4rem;  }
.no-flex-gap .typing-top > * + *       { margin-left: 0.5rem;  }
.no-flex-gap .typing-keyboard > * + *  { margin-top:  0.28rem; }
.no-flex-gap .typing-kb-row > * + *    { margin-left: 0.22rem; }
.no-flex-gap .typing-letters > * + *   { margin-left: 0.15rem; }

/* Canvas / drawing */
.no-flex-gap .canvas-controls > * + *  { margin-top: 0.75rem; }
/* canvas-btns wraps (gap: 0.8rem) */
.no-flex-gap .canvas-btns              { margin: -0.4rem; }
.no-flex-gap .canvas-btns > *          { margin:  0.4rem; }
.no-flex-gap .color-picker-row > * + * { margin-left: 0.9rem; }

/* Cuento reader */
.no-flex-gap .reader-footer > * + *    { margin-left: 1rem; }
.no-flex-gap .reader-dots > * + *      { margin-left: 8px;  }

/* Buscar */
.no-flex-gap .bt-chip > * + *          { margin-left: 0.25rem; }
/* buscar-targets-row wraps (gap: 0.4rem) */
.no-flex-gap .buscar-targets-row       { margin: -0.2rem; }
.no-flex-gap .buscar-targets-row > *   { margin:  0.2rem; }
.no-flex-gap .buscar-footer > * + *    { margin-top: 0.4rem; }
.no-flex-gap .buscar-empty > * + *     { margin-top: 1rem;  }

/* Letras */
/* letras-combos-row wraps (gap: 0.6rem) */
.no-flex-gap .letras-combos-row        { margin: -0.3rem; }
.no-flex-gap .letras-combos-row > *    { margin:  0.3rem; }
.no-flex-gap .letra-combo-btn > * + *  { margin-top: 0.2rem; }
.no-flex-gap .letras-letters > * + *   { margin-left: 1rem; }
.no-flex-gap .letra-block > * + *      { margin-left: 0.5rem; }
.no-flex-gap .letras-sound-col > * + * { margin-top: 0.6rem; }
.no-flex-gap .letras-card > * + *      { margin-top: 1.2rem; }
/* view-letras column sections */

/* ── PWA Install ──────────────────────────────────────────────────────────── */
.pwa-hidden { display: none !important; }

.pwa-banner {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 1rem);
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.88);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-radius: 1rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  z-index: 9999;
  white-space: nowrap;
  font-family: var(--font-body);
}
.pwa-banner img { border-radius: 10px; }
.pwa-banner span { -webkit-flex: 1; flex: 1; font-size: 0.9rem; color: #333; }
.pwa-banner button { background: var(--clr-primary); color: #fff; border: none; border-radius: 0.5rem; padding: 0.4rem 0.9rem; font-size: 0.85rem; cursor: pointer; font-family: var(--font-body); }
#pwa-banner-close { background: transparent !important; color: #999; font-size: 1rem; padding: 0.2rem 0.5rem; }

.pwa-modal {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,0.5);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: flex-end;
  align-items: flex-end;
  -webkit-justify-content: center;
  justify-content: center;
  z-index: 9999;
  padding-bottom: env(safe-area-inset-bottom);
}
.pwa-modal-box {
  background: #fff;
  border-radius: 1.5rem 1.5rem 0 0;
  padding: 2rem 1.5rem;
  text-align: center;
  width: 100%;
  max-width: 480px;
}
.pwa-modal-box img { border-radius: 14px; margin-bottom: 1rem; }
.pwa-modal-box h3 { font-family: var(--font-heading); font-size: 1.2rem; margin: 0 0 0.75rem; color: #222; }
.pwa-modal-box p { font-family: var(--font-body); font-size: 1rem; color: #555; margin-bottom: 1.5rem; line-height: 1.5; }
.pwa-share-icon { display: inline-block; font-size: 1.1rem; vertical-align: middle; }
.pwa-modal-box button { background: var(--clr-primary); color: #fff; border: none; border-radius: 0.75rem; padding: 0.75rem 2rem; font-size: 1rem; cursor: pointer; font-family: var(--font-body); }
.no-flex-gap #view-letras > * + *      { margin-top: 0.75rem; }
