* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%; overflow: hidden;
  font-family: 'Fredoka', 'Comic Sans MS', system-ui, sans-serif;
  color: #3b2a5a;
  background: #ffb3d1;
  touch-action: none; user-select: none; -webkit-user-select: none;
  overscroll-behavior: none;
}
#app {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ff9ec7 0%, #ffd66b 50%, #8fd3ff 100%);
}
canvas#game { display: block; }
.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; border: none; }

/* ---------- Botones ---------- */
.btn {
  display: inline-block;
  font-size: 22px; font-weight: 700; color: #fff;
  padding: 12px 26px; border-radius: 999px;
  background: linear-gradient(180deg, #ff6fb5, #ff3d8b);
  box-shadow: 0 6px 0 #c2185b, 0 10px 20px rgba(0,0,0,.18);
  transition: transform .1s, box-shadow .1s;
  text-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.btn:hover { transform: translateY(-2px) scale(1.03); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c2185b; }
.btn.big { font-size: 30px; padding: 14px 40px; background: linear-gradient(180deg, #5ee07a, #22b14c); box-shadow: 0 7px 0 #138a35, 0 12px 24px rgba(0,0,0,.2); animation: pulse 1.6s ease-in-out infinite; }
.btn.big:active { box-shadow: 0 2px 0 #138a35; }
.btn.alt { background: linear-gradient(180deg, #5ab8ff, #2f7ff0); box-shadow: 0 6px 0 #1b56b3, 0 10px 20px rgba(0,0,0,.18); }
.btn.ghost { background: #fff; color: #7a4bbf; box-shadow: 0 5px 0 #d6c4f5; text-shadow: none; }
.btn.small { font-size: 18px; padding: 9px 20px; }
.btn:disabled { filter: grayscale(.8); opacity: .6; cursor: default; animation: none; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }

/* ---------- Pantallas ---------- */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  background: rgba(255, 220, 240, .35);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.card {
  position: relative;
  background: #fff; border-radius: 30px;
  padding: 22px 26px; max-width: 520px; width: 100%;
  margin: auto;
  box-shadow: 0 10px 0 rgba(122, 75, 191, .25), 0 20px 40px rgba(0,0,0,.2);
  text-align: center;
  border: 5px solid #ffe066;
}
.card.wide { max-width: 860px; }
.card h2 { font-size: 30px; color: #7a4bbf; margin-bottom: 12px; }
.col { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-top: 14px; }
.col .btn { min-width: 260px; }
.row { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 14px; }

/* Título */
.title-wrap { text-align: center; margin: auto; }
.logo { font-size: clamp(44px, 9vw, 92px); font-weight: 700; line-height: 1; letter-spacing: 1px; }
.logo span { display: inline-block; -webkit-text-stroke: 3px #fff; paint-order: stroke fill; text-shadow: 0 6px 0 rgba(0,0,0,.15); animation: bob 2s ease-in-out infinite; }
.logo .j { color: #ff5a2e; }
.logo .amp { color: #9b5de5; animation-delay: .3s; }
.logo .t { color: #ff3d8b; animation-delay: .6s; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
.subtitle { font-size: clamp(22px, 4vw, 34px); font-weight: 600; color: #fff; text-shadow: 0 3px 0 #7a4bbf; margin: 6px 0 4px; }
.kids-preview { display: flex; justify-content: center; gap: 10px; height: 200px; }
.kids-preview canvas { width: 130px; height: 200px; }
.story { font-size: 18px; background: rgba(255,255,255,.85); border-radius: 20px; padding: 10px 18px; margin: 4px auto 16px; max-width: 560px; line-height: 1.35; }
.title-wrap .btn-mute { margin-left: 10px; vertical-align: middle; }

/* Niveles */
#level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 10px 0 16px; }
.lvl {
  position: relative; border-radius: 22px; padding: 12px 6px 10px; min-height: 120px;
  background: linear-gradient(180deg, #fff6c9, #ffe28a); color: #6b3e00;
  box-shadow: 0 6px 0 #e0b23a; font-size: 15px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  transition: transform .12s;
}
.lvl .num { position: absolute; top: 6px; left: 10px; font-size: 14px; opacity: .7; }
.lvl .em { font-size: 40px; line-height: 1; }
.lvl .st { font-size: 14px; letter-spacing: 1px; min-height: 18px; }
.lvl:not(.locked):hover { transform: translateY(-3px) rotate(-1deg); }
.lvl.locked { background: linear-gradient(180deg, #ecebf3, #d6d3e6); color: #8a86a3; box-shadow: 0 6px 0 #bbb6d1; cursor: default; }
.lvl.locked .em { filter: grayscale(1); opacity: .5; }
.lvl .soon { font-size: 12px; background: #9b5de5; color: #fff; border-radius: 999px; padding: 1px 8px; }

/* Nota de mamá */
.card.note { max-width: 720px; background: #fffbe6; border-color: #ffb3d1; transform: rotate(-.5deg); }
.note-pin { position: absolute; top: -14px; left: 50%; width: 28px; height: 28px; margin-left: -14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff8a8a, #e02424); box-shadow: 0 3px 4px rgba(0,0,0,.3); }
.mom-note { font-size: 18px; line-height: 1.4; margin-bottom: 10px; }
.find-title { font-weight: 700; color: #ff3d8b; font-size: 18px; margin-bottom: 6px; }
#brief-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 12px; }
.find-item { background: #fff; border: 3px dashed #ffb3d1; border-radius: 16px; padding: 4px 10px; display: flex; flex-direction: column; align-items: center; min-width: 74px; font-size: 14px; font-weight: 600; }
.find-item .e { font-size: 30px; line-height: 1.1; }
.find-item small { font-size: 11px; font-weight: 500; opacity: .75; max-width: 110px; }
.cat-ico { width: 1.6em; height: 1.6em; vertical-align: middle; }
.find-item .cat-ico { width: 54px; height: 54px; }
.hud-item .cat-ico { width: 34px; height: 34px; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.ctrl { border-radius: 18px; padding: 8px 12px; font-size: 15px; }
.ctrl-j { background: #ffe4d9; border: 3px solid #ff7a45; }
.ctrl-t { background: #ffe1f0; border: 3px solid #ff5fa2; }
.ctrl .who { font-weight: 700; font-size: 19px; }
.ctrl-j .who { color: #e8541f; }
.ctrl-t .who { color: #e0307d; }
.ctrl .power { margin-top: 4px; }
kbd { display: inline-block; min-width: 26px; text-align: center; padding: 1px 6px; border-radius: 7px; background: #fff; border: 2px solid #3b2a5a; border-bottom-width: 4px; font-family: inherit; font-weight: 700; font-size: 14px; }
body.touch .keys { display: none; }

/* Fin */
.end-emoji { font-size: 72px; line-height: 1; animation: bob 1.8s ease-in-out infinite; }
.stars { font-size: 46px; letter-spacing: 6px; min-height: 10px; }
.stars .off { filter: grayscale(1); opacity: .3; }
#end-text { font-size: 19px; margin: 6px 0; line-height: 1.35; }

/* Novedades del nivel */
.news { background: #e8f7ff; border: 3px solid #5ab8ff; border-radius: 16px; padding: 6px 12px; margin: 0 auto 12px; font-size: 16px; font-weight: 600; color: #1b56b3; max-width: 600px; }

/* Preguntas */
.card.quiz { max-width: 560px; border-color: #5ab8ff; }
.quiz-who { display: inline-block; font-size: 20px; color: #fff; border-radius: 999px; padding: 4px 18px; margin-bottom: 8px; }
.quiz-who.qt { background: #ff5fa2; }
.quiz-who.qj { background: #ff7a45; }
.quiz-q { font-size: 28px; font-weight: 700; color: #5b3a8a; }
.quiz-big { font-size: 46px; font-weight: 700; margin: 6px 0; color: #3b2a5a; letter-spacing: 2px; line-height: 1.2; }
.quiz-opts { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 12px 0 6px; }
.btn.qopt { min-width: 120px; font-size: 30px; padding: 12px 22px; background: linear-gradient(180deg, #ffe066, #ffc300); color: #5b3a00; box-shadow: 0 6px 0 #d49b00; text-shadow: none; position: relative; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn.qopt.emo { font-size: 42px; padding: 8px 22px; }
.btn.qopt small { position: absolute; top: 4px; left: 10px; font-size: 12px; opacity: .55; }
.btn.qopt .sw { width: 26px; height: 26px; border-radius: 50%; border: 3px solid rgba(0,0,0,.2); display: inline-block; }
.btn.qopt.wrong { background: #ddd; color: #999; box-shadow: 0 6px 0 #bbb; animation: shake .4s; }
.btn.qopt.right { background: linear-gradient(180deg, #5ee07a, #22b14c); color: #fff; box-shadow: 0 6px 0 #138a35; animation: pop .5s; }
.quiz-msg { font-size: 22px; font-weight: 700; color: #e0307d; min-height: 30px; }
.quiz-help { font-size: 16px; color: #7a4bbf; }

/* ---------- HUD ---------- */
#hud { position: absolute; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); pointer-events: none; }
#hud-items { display: flex; gap: 4px; background: rgba(255,255,255,.88); border-radius: 18px; padding: 4px 8px; box-shadow: 0 4px 0 rgba(122,75,191,.25); flex-wrap: wrap; max-width: 40%; }
.hud-item { position: relative; font-size: 26px; line-height: 1.2; filter: grayscale(1); opacity: .35; transition: all .3s; }
.hud-item.got { filter: none; opacity: 1; animation: pop .5s; }
.hud-item.got::after { content: '✔'; position: absolute; right: -4px; bottom: -2px; font-size: 13px; color: #fff; background: #22b14c; border-radius: 50%; width: 16px; height: 16px; line-height: 16px; text-align: center; font-weight: 700; }
@keyframes pop { 0% { transform: scale(.4); } 60% { transform: scale(1.5); } 100% { transform: scale(1); } }
#hud-timer { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.88); border-radius: 18px; padding: 4px 12px; box-shadow: 0 4px 0 rgba(122,75,191,.25); font-weight: 700; font-size: 22px; }
#hud-timer .mom { font-size: 26px; }
#hud-timer .bar { width: 120px; height: 14px; background: #eee; border-radius: 999px; overflow: hidden; border: 2px solid #7a4bbf; }
#timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #5ee07a, #ffd23f); transition: width .25s linear; }
#hud-timer.hurry { animation: shake .4s infinite; color: #e02424; }
#hud-timer.hurry #timer-fill { background: #ff4d4d; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
#hud-btns { display: flex; gap: 6px; pointer-events: auto; }
#hud-btns button { font-size: 22px; width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.9); box-shadow: 0 4px 0 rgba(122,75,191,.3); }

/* ---------- Táctil ---------- */
#touch { position: absolute; inset: 0; z-index: 11; pointer-events: none; }
.pad { position: absolute; bottom: max(10px, env(safe-area-inset-bottom)); pointer-events: auto; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pad-j { left: max(12px, env(safe-area-inset-left)); }
.pad-t { right: max(12px, env(safe-area-inset-right)); }
.pad-name { font-size: 14px; font-weight: 700; color: #fff; padding: 1px 12px; border-radius: 999px; }
.pad-j .pad-name { background: #ff7a45; }
.pad-t .pad-name { background: #ff5fa2; }
.pad-row { display: flex; gap: 8px; }
.pad button {
  width: 62px; height: 62px; border-radius: 50%;
  font-size: 26px; font-weight: 700; color: #3b2a5a;
  background: rgba(255,255,255,.55); border: 4px solid rgba(255,255,255,.9);
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
  touch-action: none;
}
.pad-j button { border-color: #ff7a45; }
.pad-t button { border-color: #ff5fa2; }
.pad button.jump { width: 70px; height: 70px; margin-top: -8px; }
.pad-j button.jump { background: rgba(255,122,69,.7); color: #fff; }
.pad-t button.jump { background: rgba(255,95,162,.7); color: #fff; }
.pad button.on { transform: scale(.92); background: rgba(255,255,255,.95); }
.pad button.jump.on { filter: brightness(1.15); }

#rotate { display: none; position: fixed; inset: 0; z-index: 100; background: linear-gradient(135deg, #ff9ec7, #8fd3ff); color: #fff; font-size: 26px; font-weight: 700; text-align: center; flex-direction: column; align-items: center; justify-content: center; text-shadow: 0 3px 0 #7a4bbf; }
#rotate div { font-size: 80px; animation: bob 1.5s infinite; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }

/* Pantallas bajitas (celular acostado) */
@media (max-height: 520px) {
  .card { padding: 14px 18px; border-radius: 24px; }
  .card h2 { font-size: 22px; margin-bottom: 6px; }
  .logo { font-size: 48px; }
  .subtitle { font-size: 20px; }
  .kids-preview { height: 120px; }
  .kids-preview canvas { width: 78px; height: 120px; }
  .story { font-size: 14px; padding: 6px 12px; margin-bottom: 10px; }
  .btn { font-size: 18px; padding: 8px 18px; }
  .btn.big { font-size: 22px; padding: 10px 28px; }
  .col { gap: 10px; margin-top: 8px; }
  .col .btn { min-width: 220px; }
  .mom-note { font-size: 14px; margin-bottom: 6px; }
  .find-item { min-width: 60px; font-size: 12px; padding: 2px 6px; }
  .find-item .e { font-size: 22px; }
  .find-item .cat-ico { width: 40px; height: 40px; }
  .hud-item .cat-ico { width: 26px; height: 26px; }
  .ctrl { font-size: 13px; padding: 5px 10px; }
  .ctrl .who { font-size: 16px; }
  .lvl { min-height: 84px; font-size: 12px; padding: 8px 4px; }
  .lvl .em { font-size: 28px; }
  #level-grid { gap: 8px; margin: 6px 0 10px; }
  .end-emoji { font-size: 48px; }
  .news { font-size: 13px; margin-bottom: 6px; padding: 4px 10px; }
  .controls { display: none; }
  .mom-note { font-size: 13px; line-height: 1.3; }
  .find-item small { display: none; }
  .find-item .cat-ico { width: 34px; height: 34px; }
  .quiz-q { font-size: 20px; }
  .quiz-big { font-size: 32px; margin: 2px 0; }
  .btn.qopt { font-size: 22px; min-width: 90px; padding: 8px 16px; }
  .btn.qopt.emo { font-size: 30px; }
  .quiz-msg { font-size: 16px; min-height: 22px; }
  .stars { font-size: 34px; }
  #end-text { font-size: 15px; }
  .hud-item { font-size: 20px; }
  #hud-timer { font-size: 17px; padding: 3px 10px; }
  #hud-timer .mom { font-size: 20px; }
  #hud-timer .bar { width: 70px; }
  #hud-btns button { width: 38px; height: 38px; font-size: 18px; }
  .pad button { width: 54px; height: 54px; font-size: 22px; }
  .pad button.jump { width: 60px; height: 60px; }
}
@media (max-width: 700px) {
  #level-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .controls { grid-template-columns: 1fr 1fr; }
}
