/* Multiply! v2 — sistema visual coherente.
   Se abandonan los PNG estirados (Barra, FondoVent*, etc.) y se reconstruyen
   con CSS: cream + borde naranja + sombras. Se conservan los personajes,
   iconos y medallas originales. */
@font-face {
  font-family: "Robgraves";
  src: url("assets/Robgraves-lKYV.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "Bignoodle";
  src: url("assets/BignoodletitlingOblique-BxY5.ttf") format("truetype");
  font-display: swap;
}
:root {
  --blue: #2f6bff;
  --blue-dark: #193fae;
  --blue-light: #5b8cff;
  --cream: #ffedbb;
  --cream-2: #ffe1a0;
  --cream-deep: #ffd47e;
  --border: #f0a400;
  --border-dark: #c67e00;
  --ink: #4a2f0b;
  --ink-soft: #7a5a22;
  --green: #2ecc5a;
  --green-dark: #189a3d;
  --red: #f0445e;
  --red-dark: #b81a38;
  --gold: #ffc93a;
  --card-shadow: 0 6px 0 rgba(74, 47, 11, 0.18), 0 12px 28px rgba(0,0,0,0.18);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: #7d5a33 url("assets/FondoApp.png") repeat;
  background-size: 320px auto;
  font-family: "Robgraves", "Trebuchet MS", Verdana, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
  text-align: center;
}
/* oscurece apenas la madera para que el cream destaque */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(60, 38, 12, 0.28);
  pointer-events: none;
  z-index: 0;
}
#app {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
  overflow-x: hidden;
  background: transparent;
  isolation: isolate;
}
#app img { user-select: none; -webkit-user-drag: none; }

/* ---------- pantallas ---------- */
#app .screen { display: none; flex: 1; flex-direction: column; align-items: center; padding: 12px 16px 16px; width: 100%; gap: 12px; }
#app .screen.active { display: flex; animation: scrIn 0.25s ease; }
@keyframes scrIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* transiciones por pantalla, como el original */
#app #scr-niveles.active { animation: slideL 0.28s ease; }
@keyframes slideL { from { opacity: 0; transform: translateX(48px); } to { opacity: 1; transform: none; } }
#app #scr-quiz.active, #app #scr-learn.active { animation: quizZoom 0.28s ease; }
@keyframes quizZoom { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }

/* ---------- Splash ---------- */
#scr-splash.active {
  background: linear-gradient(180deg, #ffe45e 0%, #ffc93a 30%, #f5a623 55%, #e8820c 80%, #ffe45e 100%);
  background-size: 100% 220%;
  animation: splashShift 5s ease-in-out infinite alternate;
  justify-content: center;
  padding: 24px 16px;
  margin: 0;
  border-radius: 0;
  transition: opacity 0.35s ease;
}
@keyframes splashShift { from { background-position: 50% 0%; } to { background-position: 50% 100%; } }
#scr-splash.leaving { opacity: 0; }
#app .splash-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; justify-content: center; width: 100%; }
#app .splash-logo { width: 132px; filter: drop-shadow(0 3px 0 rgba(0,0,0,0.12)); }
#scr-splash h1 { color: #f7f7f7; font-family: "Bignoodle", "Robgraves", sans-serif; font-size: 68px; letter-spacing: 2px; margin: 0; text-shadow: 0 2px 0 rgba(0,0,0,0.18); font-weight: normal; }
#app .splash-count { min-height: 112px; display: flex; align-items: center; justify-content: center; }
#app .splash-count img { width: 96px; filter: drop-shadow(0 4px 0 rgba(0,0,0,0.18)); }
/* números con zoom+giro como el original (extensión Animación) */
#app .splash-count img.pop { animation: numPop 0.9s cubic-bezier(0.2, 1.4, 0.35, 1); }
@keyframes numPop {
  0% { transform: scale(0.2) rotate(-14deg); opacity: 0; }
  55% { transform: scale(1.12) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
#app .splash-ver { color: #fff; font-size: 14px; line-height: 1.6; margin-top: 28px; text-shadow: 0 1px 2px rgba(0,0,0,0.25); }

/* ---------- barras superiores / inferiores ---------- */
#app .topbar, #app .footerbar {
  width: 100%;
  background: linear-gradient(180deg, #fff3cf 0%, var(--cream) 55%, var(--cream-deep) 100%);
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  box-shadow: 0 3px 0 var(--border-dark), 0 6px 14px rgba(0,0,0,0.18);
}
#app .topbar.center { justify-content: center; }
#app .tb-title { flex: 1; font-size: 19px; line-height: 1.1; color: var(--ink); font-weight: bold; display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
#app .tb-title b { font-size: 19px; }
#app .tb-title small, #app .timer-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 24px; padding: 0 8px;
  background: #4a2f0b; color: #fff; border-radius: 999px;
  font-size: 14px; font-weight: bold;
}
#app .timer-badge:empty { display: none; }
#app .score { display: flex; align-items: center; gap: 5px; font-size: 19px; font-weight: bold; color: var(--ink); min-width: 58px; }
#app .score img { width: 26px; height: 26px; }
#app .score.bad { justify-content: flex-end; }
#app .coins-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(240, 164, 0, 0.16);
  border: 2px solid rgba(240, 164, 0, 0.55);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  font-size: 18px; font-weight: bold; color: var(--ink);
  white-space: nowrap;
}
#app .coins-pill img { width: 28px; height: 28px; }
/* racha del reto diario en el menú (solo visible con racha activa) */
#app .streak-pill {
  display: inline-flex; align-items: center; gap: 6px; align-self: center;
  margin-top: 10px; padding: 5px 14px;
  font-size: 15px; font-weight: bold; color: #fff; white-space: nowrap;
  background: linear-gradient(180deg, #ff9a3c, #ef671c);
  border: 2px solid rgba(74,47,11,0.4); border-radius: 999px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.25); text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
#app .streak-pill[hidden] { display: none; }
#app .footerbar { margin-top: auto; }
#app .flex-sp { flex: 1; }

/* ---------- botones ---------- */
#app button { font-family: inherit; }
#app button.btn, #app .btn {
  background: linear-gradient(180deg, var(--blue-light) 0%, var(--blue) 60%, #2657d8 100%);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 0.3px;
  width: 100%;
  max-width: 300px;
  min-height: 54px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--blue-dark), 0 8px 16px rgba(0,0,0,0.22);
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  transition: transform 0.06s ease, filter 0.15s ease;
}
#app button.btn:hover { filter: brightness(1.06); }
#app button.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blue-dark); }
#app button.btn:disabled, #app .btn:disabled { opacity: 0.55; filter: grayscale(0.4); cursor: default; }
#app button.btn.ghost {
  background: linear-gradient(180deg, #fff8e2, #ffe3a1);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--border-dark);
  text-shadow: none;
  border: 2px solid var(--border);
}
#app .row2 { display: flex; gap: 10px; justify-content: center; width: 100%; max-width: 300px; }
#app .row2 .btn { width: 50%; padding: 12px 6px; font-size: 16px; min-height: 50px; }
#app button.opt-btn { max-width: 260px; font-size: 22px; }

/* estados acierto / error */
#app button.btn.good, #app .btn.good {
  background: linear-gradient(180deg, #4be073, var(--green) 60%, #1fad4a 100%);
  box-shadow: 0 4px 0 var(--green-dark);
}
#app button.btn.bad, #app .btn.bad {
  background: linear-gradient(180deg, #ff6d86, var(--red) 60%, #d92a49 100%);
  box-shadow: 0 4px 0 var(--red-dark);
  animation: shake 0.3s ease;
}
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- icon buttons ---------- */
#app button.icon-btn {
  background: linear-gradient(180deg, #fff6d8, var(--cream-2));
  border: 2.5px solid var(--border);
  border-radius: 13px;
  width: 52px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--border-dark);
  padding: 0;
  flex: none;
}
#app button.icon-btn img { width: 26px; height: 26px; object-fit: contain; display: block; }
#app button.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--border-dark); }
#app button.icon-btn.small { width: 44px; height: 40px; border-radius: 11px; }
#app button.icon-btn.small img { width: 20px; height: 20px; }
/* botón "?" de ayuda contextual */
#app button.icon-btn.help-q { font-size: 21px; font-weight: bold; color: var(--ink); }
/* botón-imagen (como las Image clicables del original) */
#app button.img-btn { background: none; border: none; padding: 0; cursor: pointer; flex: none; line-height: 0; filter: drop-shadow(0 3px 0 rgba(140, 90, 10, 0.45)); }
#app button.img-btn:active { transform: translateY(2px); filter: none; }
#app button.img-btn img { width: 44px; height: 44px; border-radius: 12px; display: block; }
/* hidden siempre gana (también sobre los estilos del motor) */
#app [hidden] { display: none !important; }

/* ---------- menú ---------- */
#app .top-actions, #app .bottom-actions { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#app .top-actions { margin-top: 2px; }
#app .menu-coins { font-size: 20px; color: #fff; background: rgba(0,0,0,0.28); border-color: rgba(255,255,255,0.35); text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
#app .menu-coins img { width: 32px; height: 32px; }
#menu-title-img { width: 92%; max-width: 360px; margin: 4px 0 0; filter: drop-shadow(0 5px 0 rgba(0,0,0,0.22)); }
#menu-larry { width: 148px; margin: 4px 0 8px; animation: bob 2.6s ease-in-out infinite; transform-origin: 50% 20%; filter: drop-shadow(0 8px 10px rgba(0,0,0,0.3)); }
@keyframes bob { 0%,100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(3deg) translateY(-4px); } }
#app .menu-btns { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; }
#app .bottom-actions { margin-top: auto; padding-top: 14px; }

/* ---------- paneles ---------- */
#app .panel {
  width: 100%;
  /* Ondas originales (FondoVentConfig) replicadas con código: mosaico SVG en el
     propio fondo con attachment local para que cubra TODO el contenido con
     scroll (el ::before absoluto solo medía la parte visible y se cortaba). */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='18' viewBox='0 0 48 18'%3E%3Cpath d='M0 9 Q12 3 24 9 T48 9' fill='none' stroke='%23E0A02E' stroke-width='1.6' opacity='0.35'/%3E%3C/svg%3E"), linear-gradient(180deg, #fff2cb 0%, var(--cream) 100%);
  background-size: 48px 18px, auto;
  background-repeat: repeat, no-repeat;
  background-attachment: local;
  border: 4px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--card-shadow);
  padding: 10px 10px 12px;
  overflow: visible;
  position: relative;
}
#app .card { position: relative; }
#app .card::before {
  content: ""; position: absolute; inset: 0; border-radius: 18px; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='18' viewBox='0 0 48 18'%3E%3Cpath d='M0 9 Q12 3 24 9 T48 9' fill='none' stroke='%23E0A02E' stroke-width='1.6' opacity='0.35'/%3E%3C/svg%3E");
  background-size: 48px 18px; background-repeat: repeat;
}
#app .card > * { position: relative; z-index: 1; }
#app .levels-panel { padding: 6px 6px 8px; flex: 1; display: flex; flex-direction: column; min-height: 0; }
#app .levels-list { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; border-radius: 14px; scrollbar-width: none; -ms-overflow-style: none; }
#app .levels-list::-webkit-scrollbar, #app .ans-list::-webkit-scrollbar, #app .card::-webkit-scrollbar, #app .shop-list::-webkit-scrollbar, #app .help-imgs::-webkit-scrollbar { width: 0; height: 0; display: none; }
#app .levels-list::-webkit-scrollbar-button, #app .ans-list::-webkit-scrollbar-button, #app .card::-webkit-scrollbar-button { display: none; width: 0; height: 0; }
#app button.level-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: transparent; border: none; border-bottom: 1px solid rgba(74,47,11,0.12);
  color: var(--ink); font-size: 20px; font-weight: bold;
  padding: 15px 14px; cursor: pointer; text-align: left;
  border-radius: 0;
}
#app button.level-row:last-child { border-bottom: none; }
#app button.level-row img { width: 30px; height: 30px; }
#app button.level-row.locked { opacity: 0.38; }
#app button.level-row:not(.locked):hover { background: rgba(240,164,0,0.14); }
#app button.level-row:not(.locked):active { background: rgba(240,164,0,0.24); }
#app .hint { font-size: 13px; color: rgba(255,255,255,0.9); text-shadow: 0 1px 3px rgba(0,0,0,0.5); min-height: 16px; margin: 0; }

/* ---------- pizarrón ---------- */
#app .board {
  width: 100%; position: relative; margin-top: 2px; overflow: visible;
  /* marco de madera clara como el original, con veta */
  background:
    repeating-linear-gradient(93deg, rgba(120,75,30,0.10) 0 3px, rgba(255,235,200,0.08) 3px 9px, rgba(0,0,0,0) 9px 17px),
    linear-gradient(160deg, #d8ab6a 0%, #c49a5e 45%, #a3763d 80%, #8a6238 100%);
  border-radius: 14px;
  padding: 16px 16px 30px;
  box-shadow: inset 0 2px 0 rgba(255,240,210,0.6), inset 0 -3px 0 rgba(60,35,10,0.35), 0 6px 0 rgba(74,47,11,0.35), 0 10px 22px rgba(0,0,0,0.3);
}
#app .board .screw {
  position: absolute; width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f0d49a, #a3763d 55%, #5a4128 100%);
  box-shadow: inset 0 -1px 2px rgba(0,0,0,0.5), 0 1px 1px rgba(255,255,255,0.3);
  z-index: 3;
}
#app .board .screw::after {
  content: ""; position: absolute; left: 2px; right: 2px; top: 5.5px; height: 2px;
  background: #3d2a12; border-radius: 1px; transform: rotate(38deg);
}
#app .board .screw.tl { top: 5px; left: 6px; }
#app .board .screw.tr { top: 5px; right: 6px; }
#app .board .screw.bl { bottom: 5px; left: 6px; }
#app .board .screw.br { bottom: 5px; right: 6px; }
#app .board-black {
  background: linear-gradient(180deg, #232429 0%, #17181c 100%);
  border-radius: 6px;
  min-height: 168px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  padding: 22px 14px;
  box-shadow: inset 0 0 0 3px rgba(0,0,0,0.55), inset 0 0 46px rgba(0,0,0,0.75);
  overflow: hidden;
}
#app .board-black::before {
  /* polvo de tiza */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.09;
}
#app .board-black::after {
  /* borrones de borrador */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(55% 22% at 30% 62%, rgba(255,255,255,0.07), transparent 70%),
    radial-gradient(38% 18% at 72% 30%, rgba(255,255,255,0.06), transparent 70%),
    linear-gradient(104deg, transparent 58%, rgba(255,255,255,0.045) 74%, transparent 90%);
}
#app .board .q { position: relative; z-index: 1; color: #fffdf4; font-family: "Robgraves", "Trebuchet MS", sans-serif; font-size: 42px; letter-spacing: 2px; text-shadow: 0 0 2px rgba(255,253,244,0.9), 0 2px 1px rgba(0,0,0,0.4); white-space: nowrap; line-height: 1.15; }
/* repisa inferior: la tiza y el borrador APOYADOS en el marco, con sombra */
#app .board .ledge {
  position: absolute; left: 0; right: 0; bottom: 7px;
  display: flex; align-items: flex-end; justify-content: center; gap: 12px;
  pointer-events: none;
}
#app .board .chalk-stick {
  width: 56px; height: 11px; border-radius: 6px; transform: rotate(-2.5deg);
  background: linear-gradient(180deg, #ffffff 0%, #ececec 55%, #c9c9c9 100%);
  box-shadow: 0 3px 2px rgba(0,0,0,0.45), inset 0 -2px 2px rgba(0,0,0,0.12);
}
#app .board .felt-eraser {
  width: 36px; height: 15px; border-radius: 3px; transform: rotate(1.5deg);
  background: linear-gradient(180deg, #33333a 0 46%, #7d828c 46% 100%);
  box-shadow: 0 3px 2px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
}
#app .mini-larry { position: absolute; right: -6px; bottom: -20px; width: 62px; filter: drop-shadow(0 4px 4px rgba(0,0,0,0.35)); z-index: 4; }
/* monedas flotantes (+6/−2) sobre el pizarrón */
#app .gain-float {
  position: absolute; left: 0; right: 0; top: 30%; z-index: 6; pointer-events: none;
  text-align: center; font-size: 36px; font-weight: bold; color: #ffd94d;
  text-shadow: 0 2px 0 rgba(0,0,0,0.55), 0 0 14px rgba(255, 217, 77, 0.6);
}
#app .gain-float.bad { color: #ff8ba0; text-shadow: 0 2px 0 rgba(0,0,0,0.55); }
#app .gain-float.show { animation: gainUp 1s ease forwards; }
@keyframes gainUp {
  0% { opacity: 0; transform: translateY(12px) scale(0.7); }
  20% { opacity: 1; transform: translateY(0) scale(1.1); }
  100% { opacity: 0; transform: translateY(-48px) scale(1.15); }
}
/* pulso en la píldora de monedas al cambiar */
#app .coins-pill.pulse { animation: coinPulse 0.45s ease; }
@keyframes coinPulse { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
#app .quiz-mid { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 26px; min-height: 120px; }
#app .answer-box {
  width: 100%; max-width: 300px;
  background: linear-gradient(180deg, #fff3cf, var(--cream-2));
  border: 3px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 4px 0 var(--border-dark);
}
#app .answer-box input, #app input#reto-input {
  width: 100%; font-family: inherit; font-size: 22px; text-align: center;
  background: rgba(255,255,255,0.65); border: 2px solid rgba(74,47,11,0.15);
  border-radius: 10px; outline: none; padding: 10px 8px; color: var(--ink);
}
#app .answer-box input::placeholder { color: #a08c5a; font-style: italic; }
#app .answer-box input:focus { border-color: var(--blue); background: #fff; }

/* ---------- overlays ---------- */
#app .overlay {
  position: absolute; inset: 0; z-index: 30;
  background: rgba(43, 28, 8, 0.66);
  backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; padding: 16px;
  overflow: hidden;
}
#app .overlay.open { display: flex; animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#app .card {
  width: 100%; max-width: 360px; max-height: 88%; max-height: 88dvh;
  /* marco naranja biselado como los fondos originales: el título vive en el marco */
  background: linear-gradient(180deg, #ffc65e 0%, #f5a623 32%, #e8930c 72%, #cf7f00 100%);
  border: 3px solid #a86400;
  border-radius: 24px;
  padding: 48px 12px 12px;
  position: relative;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.55), inset 0 -4px 0 rgba(120,60,0,0.28), 0 12px 30px rgba(0,0,0,0.4);
  display: flex; flex-direction: column;
  animation: pop 0.22s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes pop { from { transform: scale(0.92) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
#app .card::before {
  /* vetas sutiles del marco, repetidas: jamás se estiran */
  background-image: repeating-linear-gradient(90deg, rgba(255,255,255,0.07) 0 6px, rgba(120,60,0,0.06) 6px 12px);
  border-radius: 20px;
}
#app .card > .panel {
  border: 2px solid rgba(168,100,0,0.65);
  border-radius: 15px;
  box-shadow: inset 0 2px 10px rgba(120,60,0,0.22);
  padding: 14px 14px 14px;
  display: flex; flex-direction: column; gap: 10px;
  max-height: calc(88dvh - 150px);
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
}
#app .card > .panel::-webkit-scrollbar { display: none; width: 0; }
/* título SOBRE el marco, fuera del fondo con ondas (como el original) */
#app .card > .frame-title {
  position: absolute; top: 11px; left: 50px; right: 50px; z-index: 3;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: #4a2f0b; font-size: 21px; font-weight: bold; text-align: center;
  text-shadow: 0 1px 0 rgba(255,255,255,0.55);
}
#app .card > .frame-title h2 { margin: 0; font-size: 21px; color: inherit; }
#app .card > .frame-title.shop-head { justify-content: space-between; left: 18px; right: 58px; }
#app .card > .frame-title .coins-pill { font-size: 16px; }
#app .card > .frame-title .coins-pill img { width: 24px; height: 24px; }
#app .card h2 { margin: 2px 0 6px; font-size: 24px; color: var(--ink); }
#app button.x {
  position: absolute; top: -13px; right: -9px; background: #ff4d4d; border: 2px solid #fff;
  border-radius: 10px; width: 34px; height: 34px; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 rgba(0,0,0,0.3);
  z-index: 4;
}
#app button.x img { width: 18px; height: 18px; }
#app .card .btn { max-width: none; }
#app .comment {
  background: linear-gradient(180deg, #ffdf9a, #ffca63);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 12px; font-size: 19px; font-weight: bold; color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
#app .result-boxes { display: flex; gap: 12px; justify-content: center; margin: 2px 0 6px; }
#app .rbox {
  width: 124px; min-height: 104px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #fff; border-radius: 16px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.2);
  padding: 10px;
}
#app .rbox b { font-size: 40px; line-height: 1; text-shadow: 0 2px 0 rgba(0,0,0,0.2); }
#app .rbox span { font-size: 15px; font-weight: bold; }
#app .rbox.green { background: linear-gradient(180deg, #43d86a, #1fad4a); }
#app .rbox.red { background: linear-gradient(180deg, #ff6078, #d92a49); }

/* respuestas */
#app .ans-list { display: flex; flex-direction: column; background: #fffdf4; border: 2px solid rgba(74,47,11,0.14); border-radius: 14px; padding: 6px 8px; max-height: 46vh; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; -ms-overflow-style: none; }
#app .ans-row { display: flex; align-items: center; gap: 12px; padding: 11px 10px; font-size: 20px; font-weight: bold; border-bottom: 1px solid rgba(0,0,0,0.07); color: var(--ink); }
#app .ans-row:last-child { border-bottom: none; }
#app .ans-row img { width: 28px; height: 28px; flex: none; }
#app .ans-row.ok { color: #189a3d; }
#app .ans-row.no { color: #d92a49; }
#app .ans-row { flex-wrap: wrap; }
#app .ans-row .trick {
  flex-basis: 100%; margin: -2px 0 2px 40px; font-size: 14px; font-weight: normal;
  color: var(--ink-soft); text-align: left; line-height: 1.45;
}
/* misiones: texto flexible + píldora de recompensa fija (sin choques ni cortes) */
#app #misiones-list .ans-row { font-size: 17px; gap: 10px; align-items: center; }
#app #misiones-list .ans-row > img { width: 26px; height: 26px; }
#app #misiones-list .ans-row .nm { flex: 1 1 140px; min-width: 0; text-align: left; line-height: 1.4; overflow-wrap: anywhere; }
#app #misiones-list .ans-row .mprice {
  flex: none; margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  font-weight: bold; font-size: 15px; color: var(--ink);
  background: rgba(240,164,0,0.18); border: 2px solid rgba(240,164,0,0.5);
  border-radius: 999px; padding: 3px 10px 3px 4px; white-space: nowrap;
}
#app #misiones-list .ans-row .mprice img { width: 22px; height: 22px; }

/* ---------- tienda ---------- */
#app .shop-list { display: flex; flex-direction: column; background: rgba(255,255,255,0.4); border-radius: 14px; overflow-y: auto; overflow-x: hidden; max-height: 46vh; scrollbar-width: none; -ms-overflow-style: none; }
#app button.shop-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 10px;
  border: none; border-bottom: 1px solid rgba(74,47,11,0.12);
  width: 100%; background: transparent; cursor: pointer; text-align: left;
  color: var(--ink);
}
#app button.shop-row:last-child { border-bottom: none; }
#app button.shop-row img.avatar { width: 58px; height: 58px; border-radius: 50%; object-fit: contain; padding: 3px; background: #fffdf4; border: 2px solid var(--border); flex: none; }
#app button.shop-row img.avatar.incognito { object-fit: contain; background: #2b2b33; padding: 4px; }
#app button.shop-row .nm { flex: 1; font-size: 18px; font-weight: bold; color: var(--ink); line-height: 1.2; }
#app button.shop-row .sub { display: block; font-size: 13px; font-weight: normal; color: var(--ink-soft); }
#app button.shop-row img.lock { width: 26px; flex: none; opacity: 0.85; }
#app button.shop-row.equipped { background: rgba(47, 107, 255, 0.12); }
#app button.shop-row .price { display: inline-flex; align-items: center; gap: 4px; font-weight: bold; color: var(--ink); background: rgba(240,164,0,0.18); border: 2px solid rgba(240,164,0,0.5); border-radius: 999px; padding: 3px 9px 3px 3px; font-size: 15px; white-space: nowrap; }
#app button.shop-row .price img { width: 22px; height: 22px; }
#app button.shop-row .equipped { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--green); color: #fff; font-weight: bold; font-size: 17px; box-shadow: 0 2px 0 var(--green-dark); flex: none; }
#app button.shop-row .sub-eq { color: #189a3d; font-weight: bold; }

/* ---------- config ---------- */
#app .cfg-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 4px; font-size: 17px; font-weight: bold; min-height: 42px; color: var(--ink); }
#app .cfg-row button.link {
  background: none; border: none; color: inherit; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 0;
  font-size: inherit; font-weight: inherit;
}
#app .cfg-row .flag { width: 36px; height: 25px; object-fit: cover; border-radius: 4px; border: 1px solid rgba(0,0,0,0.2); }
#app .cfg-row .chev { width: 14px; opacity: 0.7; }
#app .cfg-row .cfg-icon { width: 26px; }
#app input.switch {
  position: relative; width: 54px; height: 30px; appearance: none; -webkit-appearance: none;
  background: #c9bfa8; border-radius: 999px; cursor: pointer; outline: none;
  transition: background 0.15s; border: 2px solid rgba(74,47,11,0.2); margin: 0; flex: none;
}
#app input.switch:checked { background: var(--green); border-color: var(--green-dark); }
#app input.switch::after {
  content: ""; position: absolute; top: 1px; left: 2px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.35); transition: left 0.15s;
}
#app input.switch:checked::after { left: 26px; }

/* ---------- aprender (flashcards) ---------- */
#app .learn-panel { align-items: center; }
#app .learn-count { flex: none; font-size: 16px; }
#app button.flashcard {
  width: 100%; min-height: 220px; cursor: pointer;
  background: linear-gradient(180deg, #232429 0%, #17181c 100%);
  border: 3px solid var(--border); border-radius: 16px;
  color: #fffdf4; font-family: "Robgraves", sans-serif;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 20px 12px;
  box-shadow: inset 0 0 0 3px rgba(0,0,0,0.55), inset 0 0 46px rgba(0,0,0,0.75);
}
#app button.flashcard .fc-front { font-size: 44px; letter-spacing: 2px; text-shadow: 0 0 2px rgba(255,253,244,0.9); }
#app button.flashcard .fc-back { font-size: 64px; color: #ffd94d; text-shadow: 0 0 8px rgba(255,217,77,0.5); animation: badgeZoom 0.35s ease; }
#app button.flashcard .fc-trick { font-size: 15px; color: #ffe9b0; font-family: inherit; line-height: 1.5; max-width: 260px; }
#app .tabla-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
#app .tabla-grid button {
  font-family: inherit; font-size: 22px; font-weight: bold; color: var(--ink);
  background: linear-gradient(180deg, #fff8e2, #ffe3a1);
  border: 2px solid var(--border); border-radius: 12px;
  min-height: 52px; cursor: pointer; box-shadow: 0 3px 0 var(--border-dark);
}
#app .tabla-grid button:active { transform: translateY(2px); box-shadow: none; }
#app .progress-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 4px; }
#app .progress-arrow { width: 196px; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3)); }
#app .progress-track {
  width: 92%; height: 30px; position: relative;
  background: #efe9dc; border: 3px solid #fff; border-radius: 999px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.18), inset 0 2px 5px rgba(0,0,0,0.15);
  overflow: hidden;
}
#app .progress-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, #5b8cff, #2f6bff);
  border-radius: 999px 0 0 999px;
  transition: width 0.6s ease;
}
#app .progress-track span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: bold; color: var(--ink);
}
#app .fin-panel { align-items: center; display: flex; flex-direction: column; }
#app .fin-stage { position: relative; width: 200px; height: 190px; display: flex; align-items: center; justify-content: center; }
#app .fin-stage .rays { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; animation: spin 26s linear infinite; opacity: 0.95; }
@keyframes spin { to { transform: rotate(360deg); } }
#app .fin-hero { position: relative; width: 132px; filter: drop-shadow(0 6px 8px rgba(0,0,0,0.25)); }
/* Larry celebra al aprobar y se consuela al reprobar */
#app .fin-hero.celebrate { animation: celebrate 1.6s ease-in-out infinite; }
@keyframes celebrate {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-12px) rotate(4deg); }
}
#app .fin-hero.console { animation: consoleSway 3s ease-in-out infinite; }
@keyframes consoleSway { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
/* insignia del diálogo premio con zoom de entrada (Phase ZoomIn del original) */
#app .prem-badge { position: relative; width: 118px; filter: drop-shadow(0 6px 8px rgba(0,0,0,0.25)); }
#app .prem-badge.zoom { animation: badgeZoom 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes badgeZoom { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
/* lluvia de papelitos del diploma final */
#app .confetti-box { position: absolute; inset: 0; border-radius: 24px; overflow: hidden; pointer-events: none; z-index: 5; }
#app .confetti-box i { position: absolute; top: -16px; width: 8px; height: 13px; border-radius: 2px; animation: confFall linear infinite; }
@keyframes confFall { to { transform: translateY(460px) rotate(540deg); } }
/* feedback de respuesta escrita (reto): igual que el verde/rojo de opciones */
#app .answer-box.good { border-color: var(--green-dark); box-shadow: 0 4px 0 var(--green-dark), 0 0 0 3px rgba(46,204,90,0.35); }
#app .answer-box.bad { border-color: var(--red-dark); box-shadow: 0 4px 0 var(--red-dark), 0 0 0 3px rgba(240,68,94,0.35); animation: shake 0.3s ease; }
#app .answer-box input:disabled { opacity: 0.75; }
#fin-badge { width: 58px; margin: 2px 0; }
#fin-badge[hidden] { display: none; }
#app .fin-coins { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 20px; font-weight: bold; color: var(--ink); margin: 4px 0 10px; }
#app .fin-coins img { width: 30px; }
#app .cafecito-btn { background: none; border: none; cursor: pointer; margin-top: 10px; padding: 0; }
#app .cafecito-btn img { width: 196px; border-radius: 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.25); }

/* ---------- ayuda / lang / user ---------- */
#app .help-imgs { display: flex; flex-direction: column; gap: 10px; max-height: 52vh; overflow-y: auto; overflow-x: hidden; }
#app .help-imgs img { width: 100%; border-radius: 12px; border: 2px solid rgba(74,47,11,0.15); }
#app .lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#app .lang-grid button {
  display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: bold; color: var(--ink);
  padding: 10px; border-radius: 12px; border: 2px solid var(--border); background: #fff8e6; cursor: pointer;
}
#app .lang-grid button.sel { border-color: var(--blue); background: #e3ebff; box-shadow: 0 0 0 2px rgba(47,107,255,0.25); }
#app .lang-grid img { width: 32px; border-radius: 3px; }
#app input.user-input, #app .user-input {
  width: 100%; font-family: inherit; font-size: 19px; text-align: center; padding: 12px;
  border-radius: 12px; border: 2px solid var(--border); background: #fffdf4; color: var(--ink); outline: none;
}
#app textarea.user-input.share-text { text-align: left; font-size: 15px; line-height: 1.5; resize: none; }
#app .about-top { display: flex; justify-content: center; margin-bottom: 2px; }
#app .about-top img { width: 84px; }
#app .about-text { font-size: 15px; line-height: 1.55; color: var(--ink); margin: 6px 0; }

/* ---------- tienda: temas ---------- */
#app .shop-section { font-weight: bold; color: var(--ink-soft); padding: 10px 10px 2px; font-size: 15px; text-align: left; }
#app button.shop-row .theme-swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--border); flex: none; box-shadow: inset 0 -3px 5px rgba(0,0,0,0.25); }
/* tiza de colores (pizarrón y flashcards) */
#app.chalk-amarilla .board .q { color: #ffe45e; }
#app.chalk-rosa .board .q { color: #ff9ec6; }
#app.chalk-celeste .board .q { color: #9ed8ff; }
#app.chalk-amarilla button.flashcard .fc-front { color: #ffe45e; }
#app.chalk-rosa button.flashcard .fc-front { color: #ff9ec6; }
#app.chalk-celeste button.flashcard .fc-front { color: #9ed8ff; }
/* marcos de colores */
#app.frame-azul .board {
  background:
    repeating-linear-gradient(93deg, rgba(30,60,120,0.12) 0 3px, rgba(220,235,255,0.08) 3px 9px, rgba(0,0,0,0) 9px 17px),
    linear-gradient(160deg, #7fa8d8 0%, #5b8cc4 45%, #3a6ea5 80%, #2c5685 100%);
}
#app.frame-verde .board {
  background:
    repeating-linear-gradient(93deg, rgba(20,70,30,0.12) 0 3px, rgba(225,245,220,0.08) 3px 9px, rgba(0,0,0,0) 9px 17px),
    linear-gradient(160deg, #93c47d 0%, #6aa84f 45%, #4a7c3a 80%, #3a6230 100%);
}

/* ---------- toast ---------- */
#app #toast {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(16px);
  background: rgba(30, 20, 5, 0.92); color: #fff; padding: 10px 16px; border-radius: 12px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 99;
  max-width: 90%; text-align: center; border: 1px solid rgba(255,255,255,0.2);
}
#app #toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#app .hidden { display: none !important; }

@media (min-width: 520px) {
  #app { box-shadow: 0 0 50px rgba(0,0,0,0.45); }
}
@media (max-height: 640px) {
  #menu-larry { width: 118px; }
  #menu-title-img { max-width: 300px; }
  #app button.btn, #app .btn { min-height: 48px; padding: 12px 14px; }
  #app .board-black { min-height: 150px; }
  #app .board .q { font-size: 38px; }
}

#app .duel-inputs { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
#app .duel-inputs .user-input { width: 100%; box-sizing: border-box; }

#app .mode-name { display: block; }
#app .mode-sub { display: block; font-size: 13px; font-weight: normal; opacity: 0.85; margin-top: 2px; }

#app .help-card { position: relative; overflow: hidden; background: #ffdc9c; border: 7px solid #dd9500; border-radius: 26px; padding: 22px 26px 30px; }
#app .help-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#app .help-bg span { position: absolute; font-family: Georgia, "Times New Roman", serif; font-weight: bold; font-style: italic; color: #f2c16e; line-height: 1; }
#app .help-title { position: relative; font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: bold; font-size: 32px; color: #111; text-align: center; margin: 0 0 10px; }
#app .help-body { position: relative; font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: 20px; line-height: 1.38; color: #111; text-align: center; }
#app .help-imgs .help-card { flex: none; }
#app .help-stage { flex: 1 1 auto; min-height: 0; overflow: hidden; }
#app .help-stage .help-card { box-sizing: border-box; height: 100%; overflow: hidden; }
#app .help-stage .help-card::-webkit-scrollbar { width: 0; height: 0; display: none; }
#app .help-nav { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 4px; }
#app .help-arrow { width: 44px; height: 44px; border-radius: 50%; border: none; background: #dd9500; color: #fff; font-size: 28px; font-weight: bold; line-height: 1; box-shadow: 0 4px 0 #a86e00; }
#app .help-arrow:active { transform: translateY(3px); box-shadow: none; }
#app .help-dots { display: flex; gap: 8px; }
#app .help-dots i { width: 12px; height: 12px; border-radius: 50%; background: rgba(74,47,11,0.25); }
#app .help-dots i.on { background: #dd9500; }
#app #ov-help .card > .panel { max-height: calc(88dvh - 110px); }
#app #ov-help .help-imgs { max-height: none; flex: none; height: calc(88dvh - 160px); min-height: 200px; }
#app button.icon-btn svg { width: 26px; height: 26px; display: block; }
#app button.icon-btn.small svg { width: 20px; height: 20px; }
#app .qmark { font-size: 24px; font-weight: bold; color: var(--ink); line-height: 1; }
#app button.x svg { width: 18px; height: 18px; display: block; }
#app .cfg-row svg.chev { width: 16px; height: 16px; opacity: 0.8; }
#app .cfg-row svg.cfg-icon { width: 24px; height: 24px; }
#app .mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
#app .mode-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; background: linear-gradient(180deg, #fff6d8, #ffedb8); border: 3px solid var(--border); border-radius: 16px; padding: 16px 8px 14px; cursor: pointer; box-shadow: 0 4px 0 var(--border-dark); color: var(--ink); }
#app .mode-tile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--border-dark); }
#app .tile-ic { width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(180deg, #f5a623, #dd9500); display: flex; align-items: center; justify-content: center; box-shadow: inset 0 2px 0 rgba(255,255,255,0.4); }
#app .tile-ic svg { width: 28px; height: 28px; display: block; }
#app .tile-tx { display: flex; flex-direction: column; align-items: center; }
#app .tile-tx .mode-name { font-size: 17px; font-weight: bold; }
#app .tile-tx .mode-sub { font-size: 13px; opacity: 0.75; margin-top: 2px; font-weight: normal; }
#app .duel-name { display: none; font-size: 12px; font-weight: bold; }
#app .quiz-top.duel .duel-name { display: block; }
#app .quiz-top.duel .score { flex-direction: column; gap: 0; align-items: center; background: linear-gradient(180deg, #fff6d8, #ffedb8); border: 2px solid var(--border); border-radius: 12px; padding: 3px 10px; }
#app .quiz-top.duel .score img { display: none; }
#app .mprice { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 15px; color: var(--ink); background: linear-gradient(180deg, #fff8e2, #ffe3a1); border: 2px solid var(--border); border-radius: 999px; padding: 2px 10px; }
#app .mprice img { width: 20px; height: 20px; }
#app .help-nav { flex: none; }
#app .learn-board { width: 100%; cursor: pointer; }
#app .learn-board .q.ans { font-size: 60px; color: #ffd94d; }
#app .learn-trick { min-height: 24px; margin-top: 10px; font-size: 15px; color: #ffe9b0; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }
#app .learn-btns { display: flex; gap: 10px; justify-content: center; width: 100%; margin-top: 14px; }
#app .learn-btns .btn { flex: 1 1 0; max-width: 180px; }
