/* Problemas del Polo Norte */
:root {
  --tinta: #3a2142;
  --oro: #ffd84a;
  --oro2: #e2a514;
  --crema: #fff8e8;
  --noche: #1b2a7a;
  --hielo: #dff4ff;
  --rojo: #e2453a;
  --verde: #2fbf4f;
  --lila: #a77bff;
  --alto: 100vh;
}
@supports (height: 100dvh) { :root { --alto: 100dvh; } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a1440; }
body { font-family: "Baloo 2", system-ui, sans-serif; color: var(--tinta); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font-family: inherit; color: inherit; cursor: pointer; }
input { font-family: inherit; }
[hidden] { display: none !important; }
#fondo { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
#app { position: relative; z-index: 1; height: var(--alto); max-width: 600px; margin: 0 auto; }
.pant { position: absolute; inset: 0; display: flex; flex-direction: column; padding: calc(8px + env(safe-area-inset-top, 0px)) 10px calc(8px + env(safe-area-inset-bottom, 0px)); animation: entra 0.35s ease-out; }
@keyframes entra { from { opacity: 0; transform: translateY(12px); } }

/* ---------- botones */
.btn { border: 0; border-radius: 999px; min-height: 52px; padding: 6px 22px; font: 800 20px/1.1 "Baloo 2", sans-serif; box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.5); transition: transform 0.08s; position: relative; }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3); }
.btn:disabled { filter: grayscale(0.7) brightness(0.9); opacity: 0.6; cursor: default; }
.btn.oro { background: linear-gradient(180deg, #fff1a6, var(--oro) 45%, var(--oro2)); color: #5a3400; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); }
.btn.crema { background: linear-gradient(180deg, #fff, #f3e6c8); }
.btn.lila { background: linear-gradient(180deg, #e2d4ff, var(--lila)); color: #2a1660; }
.btn.verde { background: linear-gradient(180deg, #8ef07c, var(--verde)); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.btn.rojo { background: linear-gradient(180deg, #ff8f84, var(--rojo)); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.btn.azul { background: linear-gradient(180deg, #9cc8ff, #3a7ae0); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.btn.grande { min-height: 64px; font-size: 26px; }
.btn.peq { min-height: 44px; font-size: 17px; padding: 4px 14px; }
.redondo { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%; border: 3px solid var(--tinta); background: var(--crema); font-size: 20px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); padding: 0; }
.chip { flex: 0 0 auto; background: var(--crema); border: 3px solid var(--tinta); border-radius: 999px; padding: 2px 12px; font-weight: 800; font-size: 17px; white-space: nowrap; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
.chip.dinero { background: linear-gradient(180deg, #fff6c4, #ffd84a); }

/* ---------- barra superior */
.barra { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.barra h1 { flex: 1; margin: 0; font: 400 clamp(18px, 5vw, 24px)/1.05 "Lilita One", sans-serif; color: #fff; text-shadow: 0 2px 0 var(--tinta), 0 0 8px rgba(0, 0, 0, 0.4); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- portada */
#pMenu { justify-content: space-between; align-items: center; }
.ajustes { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; z-index: 2; }
.menu-logo { width: min(92%, 440px); margin-top: 18px; }
.menu-logo canvas { width: 100%; height: auto; display: block; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.35)); }
.menu-pj { flex: 1; min-height: 0; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 0; position: relative; }
.menu-pj .spr { filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.35)); }
.menu-botones { width: min(100%, 380px); display: flex; flex-direction: column; gap: 12px; padding-bottom: 6px; }
.menu-botones .fila { display: flex; gap: 10px; }
.menu-botones .fila .btn.lila { flex: 1; }
.cursos { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; color: #fff; font-weight: 800; text-shadow: 0 2px 0 var(--tinta); }
.cursos button { min-width: 46px; height: 40px; border-radius: 12px; border: 3px solid var(--tinta); background: rgba(255, 248, 232, 0.85); font-weight: 800; font-size: 17px; color: var(--tinta); text-shadow: none; }
.cursos button.sel { background: var(--oro); transform: scale(1.1); box-shadow: 0 0 0 3px #fff; }

/* ---------- sprites */
.spr { display: block; pointer-events: none; }

/* ---------- pie con el paje */
.pie { position: relative; display: flex; align-items: flex-end; gap: 8px; min-height: 92px; padding-top: 6px; }
.pie.solo { min-height: 0; justify-content: space-between; }
.pie.solo .btn { flex: 1; }
.pj-zona { flex: 0 0 auto; width: 78px; height: 104px; margin-bottom: -6px; }
.bocadillo { position: relative; flex: 1; align-self: center; background: #fff; border: 3px solid var(--tinta); border-radius: 18px; padding: 6px 34px 6px 10px; font-weight: 700; font-size: clamp(14px, 3.9vw, 17px); line-height: 1.2; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); min-height: 46px; display: flex; align-items: center; }
.bocadillo::before { content: ""; position: absolute; left: -12px; bottom: 14px; border: 8px solid transparent; border-right: 12px solid var(--tinta); border-left: 0; }
.bocadillo::after { content: ""; position: absolute; left: -7px; bottom: 16px; border: 6px solid transparent; border-right: 9px solid #fff; border-left: 0; }
.bocadillo .voz { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; background: none; font-size: 18px; padding: 0; }
.bocadillo:empty { visibility: hidden; }
.btn.pagar { margin: 8px auto 0; min-height: 48px; width: min(100%, 320px); }
.btn.pagar:not(:disabled) { animation: late 1.4s infinite; }

/* ---------- caja / ventanas */
.velo { position: fixed; inset: 0; z-index: 20; background: rgba(15, 10, 40, 0.6); display: flex; align-items: center; justify-content: center; padding: 12px; animation: aparece 0.2s; }
@keyframes aparece { from { opacity: 0; } }
.ventana { width: min(100%, 460px); max-height: calc(var(--alto) - 24px); overflow-y: auto; background: linear-gradient(180deg, #fffdf6, #f6ead0); border: 4px solid var(--tinta); border-radius: 26px; padding: 14px 14px 16px; box-shadow: 0 10px 0 rgba(0, 0, 0, 0.35); animation: pop 0.3s cubic-bezier(0.2, 1.5, 0.4, 1); text-align: center; }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } }
.ventana h2 { margin: 0 0 4px; font: 400 24px/1.1 "Lilita One", sans-serif; }
.ventana p { margin: 4px 0 8px; font-weight: 700; font-size: 17px; line-height: 1.25; }
.ventana .fila { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.ventana .fila .btn { flex: 1; min-width: 120px; }
.ventana label { display: block; text-align: left; font-weight: 800; margin: 8px 0 2px; }
.ventana input[type="text"] { width: 100%; border: 3px solid var(--tinta); border-radius: 14px; padding: 8px 12px; font-size: 18px; font-weight: 700; }
.ventana .nota { font-size: 13px; color: #6b5a74; font-weight: 700; }
.ventana .opcs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.ventana .opcs button { border: 3px solid var(--tinta); background: #fff; border-radius: 14px; font-weight: 800; font-size: 17px; padding: 6px 12px; }
.ventana .opcs button.sel { background: var(--oro); }
@keyframes tiembla { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 300px; margin: 0 auto; }
.teclado button { min-height: 54px; border-radius: 16px; border: 3px solid var(--tinta); background: #fff; font: 400 26px "Lilita One", sans-serif; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25); }
.teclado button:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.teclado .ok { background: linear-gradient(180deg, #8ef07c, var(--verde)); color: #fff; }
.teclado .borra { background: #ffe0dc; }
.explica { background: #eaf7ff; border: 3px solid #3a7ae0; border-radius: 16px; padding: 8px 10px; font-weight: 700; font-size: 16px; line-height: 1.25; margin: 6px 0; text-align: left; }
.explica.bien { background: #e6fbe6; border-color: var(--verde); }
.explica b { color: #c21a2c; }

/* ---------- avisos */
.toast { position: fixed; left: 50%; top: 18%; z-index: 30; transform: translate(-50%, -20px); opacity: 0; pointer-events: none; background: #fff; border: 4px solid var(--tinta); border-radius: 20px; padding: 8px 18px; font: 400 22px/1.2 "Lilita One", sans-serif; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3); transition: opacity 0.25s, transform 0.25s; text-align: center; max-width: 90%; }
.toast.ver { opacity: 1; transform: translate(-50%, 0); }
.toast.bien { background: #e6fbe6; }
.toast.mal { background: #ffe6e2; }
.chispas { position: fixed; inset: 0; pointer-events: none; z-index: 25; }
.vuela { position: fixed; z-index: 26; pointer-events: none; transition: transform 0.55s cubic-bezier(0.5, -0.3, 0.6, 1), opacity 0.55s; }


/* ---------- portada */
.menu-pj { flex: 1; min-height: 0; width: 100%; display: flex; align-items: flex-end; justify-content: center; position: relative; }
.menu-pj .spr { filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.35)); pointer-events: auto; cursor: pointer; }
.menu-pie { color: #fff; font-weight: 700; font-size: 13px; text-align: center; text-shadow: 0 1px 2px #000; margin: 0; }

/* ---------- mapa de talleres */
.mapa { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 20px; }
.taller { position: relative; display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border-radius: 24px; border: 4px solid var(--tinta); padding: 10px 12px; min-height: 108px; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3); background: linear-gradient(160deg, rgba(255, 255, 255, 0.97), rgba(223, 244, 255, 0.97)); font-family: inherit; color: var(--tinta); }
.taller .num { position: absolute; left: -6px; top: -10px; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--tinta); color: #fff; font: 400 20px/28px "Lilita One", sans-serif; text-align: center; }
.taller canvas { flex: 0 0 auto; }
.taller h2 { margin: 0; font: 400 20px/1.1 "Lilita One", sans-serif; }
.taller p { margin: 2px 0 4px; font-size: 14px; font-weight: 700; color: #4a5a7a; line-height: 1.2; }
.taller .est { font-size: 20px; letter-spacing: 1px; }
.taller.sig { animation: late 1.4s infinite; }
.taller:disabled { filter: grayscale(0.8); opacity: 0.75; cursor: default; }
@keyframes late { 50% { transform: scale(1.03); } }
.trineo-meta { text-align: center; color: #fff; font-weight: 800; text-shadow: 0 2px 0 var(--tinta); font-size: 15px; }

/* ---------- problema */
.progreso { display: flex; justify-content: center; gap: 6px; margin: 0 0 6px; }
.progreso span { width: 38px; height: 38px; border-radius: 12px; border: 3px dashed rgba(255, 255, 255, 0.7); background: rgba(10, 20, 64, 0.35); display: flex; align-items: center; justify-content: center; }
.progreso span.hecho { border: 3px solid var(--tinta); background: rgba(255, 255, 255, 0.9); animation: pum 0.4s; }
.progreso span.fallo { border-style: solid; border-color: var(--tinta); background: rgba(255, 220, 215, 0.9); }
.progreso span.ahora { border-color: var(--oro); box-shadow: 0 0 0 3px rgba(255, 216, 74, 0.5); }
.progreso canvas { width: 28px; height: 28px; }
@keyframes pum { 40% { transform: scale(1.25); } }
.tarjeta { flex: 0 1 auto; min-height: 0; overflow-y: auto; background: linear-gradient(180deg, #fffdf6, #fff4dc); border: 4px solid var(--tinta); border-radius: 22px; padding: 10px 12px; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3); position: relative; }
.tarjeta::before { content: ""; position: absolute; left: 16px; right: 16px; top: -9px; height: 14px; border-radius: 10px; background: repeating-linear-gradient(90deg, #fff 0 14px, #e2453a 14px 28px); border: 3px solid var(--tinta); }
.enun { display: flex; gap: 10px; align-items: flex-start; }
.enun .ico { flex: 0 0 auto; width: 54px; }
.enun p { margin: 0; font-weight: 700; font-size: clamp(17px, 4.7vw, 21px); line-height: 1.3; }
.enun p b { color: #c21a2c; }
.dibujo { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 8px; margin-top: 6px; }
.dibujo:empty { display: none; }
.dibujo .grupo { display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; max-width: 150px; background: rgba(58, 108, 208, 0.08); border-radius: 12px; padding: 4px; }
.dibujo .grupo canvas { width: 26px; height: 26px; }
.dibujo .grupo canvas.tachado { opacity: 0.25; }
.dibujo .op { font: 400 26px "Lilita One", sans-serif; }
.ayuda { margin-top: 8px; }
.respuesta { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 0 8px; color: #fff; font-weight: 800; font-size: 18px; text-shadow: 0 2px 0 var(--tinta); }
.respuesta .caja { min-width: 130px; min-height: 54px; display: inline-flex; align-items: center; justify-content: center; background: #fff; color: var(--tinta); border: 4px solid var(--tinta); border-radius: 16px; font: 400 32px/1 "Lilita One", sans-serif; padding: 0 12px; text-shadow: none; box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.1); }
.respuesta .caja:empty::after { content: "?"; color: #b8c4d8; }
.respuesta .caja.mal { animation: tiembla 0.4s; background: #ffe6e2; }
.respuesta .caja.bien { background: #e6fbe6; }
.respuesta .ud { max-width: 40%; line-height: 1.1; }
.teclado { grid-template-columns: repeat(4, 1fr); max-width: 380px; width: 100%; gap: 7px; }
.teclado button { min-height: 50px; }
.teclado .ok { grid-column: span 2; font-size: 22px; }
.teclado .pista { background: #fff6c4; font-size: 18px; }
.teclado .sig { grid-column: span 4; background: linear-gradient(180deg, #8ef07c, var(--verde)); color: #fff; font-size: 24px; }
.pie { margin-top: 8px; }
.respuesta { margin-top: auto; }
.respuesta .ud:not(:empty), .respuesta .pre:not(:empty) { background: rgba(20, 30, 70, 0.72); border-radius: 12px; padding: 2px 10px; }
.menu-pj { padding-bottom: 10px; }
.cursos > span { background: rgba(20, 30, 70, 0.6); border-radius: 10px; padding: 0 6px; }
#mCursos { gap: 5px; flex-wrap: nowrap; }
#mCursos button { min-width: 0; flex: 1 1 0; max-width: 46px; padding: 0; }

/* ---------- escena final */
.escena { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.escena .bocadillo { position: absolute; top: 6px; left: 8px; right: 8px; text-align: center; justify-content: center; padding-right: 34px; font-size: 18px; }
.escena .bocadillo::before { left: 50%; bottom: -14px; border: 10px solid transparent; border-top: 14px solid var(--tinta); border-bottom: 0; }
.escena .bocadillo::after { left: calc(50% + 3px); bottom: -9px; border: 7px solid transparent; border-top: 10px solid #fff; border-bottom: 0; }
.escena .estrellas { display: flex; gap: 6px; justify-content: center; margin: 70px 0 6px; }
.escena .estrellas canvas { animation: pum 0.5s both; }
.escena .pjs { display: flex; align-items: flex-end; justify-content: center; gap: 6px; }
.escena .vuelo { position: absolute; left: -40%; top: 30%; animation: vuela 3.5s ease-in forwards; }
@keyframes vuela { to { transform: translate(180vw, -40vh) rotate(-8deg); } }
.acciones { display: flex; flex-direction: column; gap: 10px; padding: 8px 0 4px; width: min(100%, 380px); margin: 0 auto; }

/* ---------- ficha */
.ficha-opc { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin-bottom: 8px; }
.ficha-opc .cursos { width: 100%; }
.ficha-opc label { color: #fff; font-weight: 800; text-shadow: 0 2px 0 var(--tinta); display: flex; align-items: center; gap: 6px; }
.ficha-vista { flex: 1; overflow-y: auto; background: #fff; border: 4px solid var(--tinta); border-radius: 18px; padding: 10px; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3); }
.hoja-ficha { font-family: "Baloo 2", system-ui, sans-serif; color: #1d2540; }
.hoja-ficha header { display: flex; align-items: center; gap: 10px; border-bottom: 3px solid #3a6cd0; padding-bottom: 6px; margin-bottom: 8px; }
.hoja-ficha header img { width: 120px; }
.hoja-ficha h2 { margin: 0; font: 400 22px/1.1 "Lilita One", sans-serif; color: #1d2540; }
.hoja-ficha .datos { display: flex; gap: 16px; font-weight: 700; margin: 4px 0 8px; font-size: 14px; }
.hoja-ficha .datos span { flex: 1; border-bottom: 2px dotted #8d9bb8; }
.hoja-ficha .prob { display: flex; gap: 8px; border: 2px solid #b8c4d8; border-radius: 12px; padding: 8px; margin-bottom: 8px; break-inside: avoid; }
.hoja-ficha .prob img { width: 40px; height: 40px; flex: 0 0 auto; }
.hoja-ficha .prob .n { font: 400 20px "Lilita One", sans-serif; color: #3a6cd0; flex: 0 0 auto; }
.hoja-ficha .prob p { margin: 0 0 4px; font-weight: 600; font-size: 15px; line-height: 1.3; }
.hoja-ficha .hueco { height: 64px; border: 1.5px dashed #c9d3e6; border-radius: 8px; margin: 4px 0; font-size: 11px; color: #8d9bb8; padding: 2px 6px; }
.hoja-ficha .sol-linea { font-weight: 700; font-size: 14px; }
.hoja-ficha .soluciones { margin-top: 12px; border-top: 3px dashed #3a6cd0; padding-top: 8px; }
.hoja-ficha .soluciones h3 { margin: 0 0 4px; font: 400 18px "Lilita One", sans-serif; }
.hoja-ficha .soluciones ol { margin: 0; padding-left: 22px; font-size: 13px; font-weight: 600; }
.hoja-ficha .pie-ficha { text-align: center; font-size: 11px; color: #6b7a99; margin-top: 6px; }

/* ---------- pantallas grandes y bajas */
@media (min-width: 700px) and (min-height: 760px) {
  .pj-zona { width: 96px; height: 116px; }
  .tarjeta { padding: 14px 16px; }
}
@media (max-height: 700px) {
  .pie { min-height: 64px; }
  .pj-zona { width: 56px; height: 68px; }
  .teclado button { min-height: 44px; }
  .menu-logo { margin-top: 4px; width: min(80%, 360px); }
  .btn.grande { min-height: 56px; font-size: 22px; }
  .btn { min-height: 46px; }
  .progreso span { width: 32px; height: 32px; }
  .respuesta { margin: 6px 0; }
  .respuesta .caja { min-height: 46px; font-size: 28px; }
}

/* ---------- impresión: solo la ficha */
#imprimir { display: none; }
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  html, body { height: auto; overflow: visible; background: #fff; }
  body > *:not(#imprimir) { display: none !important; }
  #imprimir { display: block !important; }
  #imprimir .hoja-ficha .hueco { height: 30mm; }
  #imprimir .salto { break-before: page; }
}
