:root {
  --bg: #fff6e8;
  --bg2: #ffe9f1;
  --ink: #2d1f5e;
  --soft: #7a6c9e;
  --card: #ffffff;
  --accent: #7b5cff;
  --hs: min(24vh, 14vw, 140px);
  font-family: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: radial-gradient(circle at 15% 10%, var(--bg2), transparent 45%),
              radial-gradient(circle at 90% 90%, #e5f4ff, transparent 40%), var(--bg);
  user-select: none;
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
#app { height: 100dvh; }
section { height: 100%; display: flex; flex-direction: column; }

svg text { font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 800; fill: #22183f;
  paint-order: stroke; stroke: rgba(255,255,255,.6); stroke-width: 3px; }

/* ---------- comunes ---------- */
.icon-btn { background: var(--card); width: 46px; height: 46px; border-radius: 50%; font-size: 22px;
  box-shadow: 0 3px 0 rgba(45,31,94,.15); flex: none; }
.pill-btn { background: var(--card); padding: 6px 16px; border-radius: 999px; font-size: 18px; font-weight: 700;
  box-shadow: 0 3px 0 rgba(45,31,94,.15); flex: none; }
.pill-btn:active, .icon-btn:active, .big-btn:active, .card:active { transform: translateY(2px); box-shadow: none; }
.big-btn { background: var(--accent); color: #fff; padding: 12px 26px; border-radius: 22px; font-size: 22px; font-weight: 800;
  box-shadow: 0 5px 0 #5638d6; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
.screen-title { flex: 1; font-size: 20px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mic { position: relative; width: 46px; height: 46px; display: grid; place-items: center; font-size: 20px; flex: none; }
.mic-dot { position: absolute; inset: 8px; border-radius: 50%; background: #d9d2ea; transition: transform .08s; z-index: -1; }
.mic-dot.hot { background: #9be38b; }

/* ---------- teclado ---------- */
.kb { --kbh: clamp(90px, 27vh, 190px); position: relative; display: flex; height: var(--kbh); margin: 0 10px max(10px, env(safe-area-inset-bottom));
  background: #1b1630; border-radius: 12px 12px 14px 14px; padding: 6px 6px 8px; gap: 4px; flex: none; }
.wk { flex: 1; background: linear-gradient(#fffdf6, #f3ecdc); border-radius: 0 0 8px 8px; display: flex; align-items: flex-end;
  justify-content: center; padding-bottom: calc(var(--kbh) * .05); position: relative; transition: background .2s; }
.wk .sticker { width: min(72%, calc(var(--kbh) * .42)); }
.wk .sticker svg { display: block; width: 100%; }
.bk { position: absolute; top: 6px; width: 8%; height: 55%; transform: translateX(-50%); background: linear-gradient(#3a3450, #0d0a18);
  border-radius: 0 0 5px 5px; pointer-events: none; margin-left: 3px; }
.wk.target { background: linear-gradient(#fff7c2, #ffe680); box-shadow: 0 0 0 4px #ffd31c inset; animation: glow 1s ease-in-out infinite; }
.wk.ok { animation: okflash .5s; }
.wk.bad { animation: badflash .5s; }
@keyframes glow { 50% { box-shadow: 0 0 0 7px #ffd31c inset; } }
@keyframes okflash { 0% { background: #b8f5a8; } }
@keyframes badflash { 0%, 60% { background: #ffc2c2; } }

/* ---------- inicio ---------- */
.home { overflow-y: auto; padding: 0 16px 24px; }
.home header { display: flex; align-items: center; justify-content: space-between; padding-top: max(10px, env(safe-area-inset-top)); }
.home h1 { margin: 6px 0 0; font-size: clamp(28px, 6vw, 44px); line-height: 1; }
.title-hearts { display: flex; gap: 6px; margin: 10px 0 16px; }
.title-hearts span { width: clamp(36px, 9vw, 60px); animation: float 3s ease-in-out infinite; }
.title-hearts span:nth-child(2n) { animation-delay: -1.5s; }
@keyframes float { 50% { transform: translateY(-5px); } }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.card { background: var(--card); border-radius: 22px; padding: 14px 12px 12px; display: flex; flex-direction: column; align-items: center;
  gap: 2px; box-shadow: 0 5px 0 rgba(45,31,94,.12); text-align: center; }
.card .emoji { font-size: 46px; line-height: 1.1; }
.card .title { font-size: 19px; font-weight: 800; line-height: 1.1; min-height: 2.2em; display: grid; place-items: center; }
.card .sub { color: var(--soft); font-size: 15px; line-height: 1.1; }
.group-title { margin: 26px 0 12px; font-size: 26px; }
.card .level { font-size: 11px; letter-spacing: 2px; opacity: .7; }
.card.free { background: linear-gradient(135deg, #8f74ff, #5f43e8); color: #fff; box-shadow: 0 5px 0 #4529c4; }
.card.free .sub { color: #e4dcff; }
.stars span { color: #ddd5ea; font-size: 22px; }
.stars span.on { color: #ffc21c; }

/* ---------- tocar ---------- */
.dots { display: flex; justify-content: center; gap: 8px; height: 14px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: #e0d8ee; }
.dots i.now { background: var(--accent); transform: scale(1.25); }
.dots i.done { background: #ffc21c; }
.track { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; min-height: 0; }
.strip { display: flex; gap: calc(var(--hs) * .22); align-items: center; transition: transform .45s cubic-bezier(.3,1.3,.5,1); padding: 0 50vw; }
.strip .h { width: var(--hs); flex: none; transition: transform .3s, opacity .3s, filter .3s; }
.strip .h svg { display: block; width: 100%; filter: drop-shadow(0 6px 0 rgba(45,31,94,.12)); }
.strip .h.current { transform: scale(1.35); animation: bounce .9s ease-in-out infinite; }
.strip .h.sing { transform: scale(1.35); }
.strip .h.done { opacity: .35; transform: scale(.75); }
.strip .h.shake { animation: shake .45s; }
@keyframes bounce { 0%, 100% { transform: scale(1.35) translateY(0); } 50% { transform: scale(1.35) translateY(-10%); } }
@keyframes shake { 0%, 100% { transform: scale(1.35); } 20% { transform: scale(1.35) translateX(-14%) rotate(-8deg); }
  40% { transform: scale(1.35) translateX(12%) rotate(7deg); } 60% { transform: scale(1.35) translateX(-8%); } 80% { transform: scale(1.35) translateX(5%); } }

.banner { position: absolute; top: 6px; left: 50%; transform: translate(-50%, -150%); background: var(--card); padding: 4px 22px;
  border-radius: 999px; font-size: clamp(20px, 4.5vh, 30px); font-weight: 800; box-shadow: 0 4px 0 rgba(45,31,94,.12);
  transition: transform .35s cubic-bezier(.3,1.4,.5,1); z-index: 2; white-space: nowrap; }
.banner.show { transform: translate(-50%, 0); }
.banner.turn { background: #fff2b3; }
.banner.win { background: #d6f7c9; }

.oops { position: absolute; right: 16px; bottom: 6px; display: flex; align-items: center; gap: 4px; opacity: 0; font-size: 28px; }
.oops .oops-heart { width: calc(var(--hs) * .55); }
.oops .oops-heart svg { display: block; width: 100%; }
.oops.show { animation: oops 1.4s; }
@keyframes oops { 0% { opacity: 0; transform: scale(.6); } 15%, 70% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti span { position: absolute; top: -60px; animation: fall linear forwards; }
.confetti svg { display: block; width: 100%; }
@keyframes fall { to { transform: translateY(115vh) rotate(var(--rot)); } }

/* ---------- resultado ---------- */
.results { align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 16px; }
.res-emoji { font-size: clamp(50px, 14vh, 90px); line-height: 1; }
.results h2 { margin: 0; font-size: clamp(32px, 8vh, 56px); }
.big-stars span { font-size: clamp(50px, 15vh, 96px); color: #ddd5ea; display: inline-block; }
.big-stars span.on { color: #ffc21c; animation: starpop .6s backwards; }
.big-stars span:nth-child(2) { animation-delay: .25s; }
.big-stars span:nth-child(3) { animation-delay: .5s; }
@keyframes starpop { 0% { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.3); } }
.res-btns { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 8px; }

/* ---------- juego libre ---------- */
.free-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.big-heart { width: min(34vh, 45vw, 220px); }
.big-heart svg { display: block; width: 100%; filter: drop-shadow(0 0 24px var(--glow, transparent)); }
.big-heart.empty { opacity: .35; animation: float 2.5s ease-in-out infinite; }
.big-heart.pop, .live-heart.pop, .strip .h.pop { animation: pop .35s; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } }
.free-hint { margin: 0; font-size: clamp(20px, 5vh, 34px); font-weight: 800; }
.history { display: flex; justify-content: center; gap: 4px; height: calc(var(--hs) * .45); margin-bottom: 8px; padding: 0 12px; overflow: hidden; }
.history .mini { width: calc(var(--hs) * .45); flex: none; animation: pop .3s; }
.history .mini svg { display: block; width: 100%; }

/* ---------- ajustes ---------- */
.settings { overflow-y: auto; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; padding: 0 14px 14px; }
.panel { background: var(--card); border-radius: 20px; padding: 14px 18px; box-shadow: 0 4px 0 rgba(45,31,94,.1); }
.panel h3 { margin: 0 0 6px; font-size: 20px; }
.live-heart { width: 110px; margin: 0 auto; }
.live-heart svg { display: block; width: 100%; }
.readout { text-align: center; font-size: 17px; color: var(--soft); }
.meter { position: relative; height: 16px; background: #eee8f6; border-radius: 99px; margin: 10px 0; overflow: hidden; }
.meter .fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #9be38b, #ffd31c, #f2333f); width: 0; transition: width .06s; }
.meter .thr { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--ink); }
.hint { color: var(--soft); font-size: 15px; line-height: 1.3; margin: 6px 0; }
.sens { width: 100%; accent-color: var(--accent); }
.toggle { display: flex; gap: 10px; align-items: center; font-size: 16px; margin: 10px 0; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.settings .kb { display: none; }

.overlay { position: fixed; inset: 0; background: rgba(45,31,94,.45); display: grid; place-items: center; z-index: 60; padding: 16px; }
.dialog { background: var(--card); border-radius: 26px; padding: 22px; max-width: 440px; text-align: center; }
.dialog h2 { margin: 4px 0; }
.dialog p { color: var(--soft); }
.big-emoji { font-size: 54px; }

/* móvil en vertical */
@media (orientation: portrait) {
  :root { --hs: min(25vw, 13vh); }
  .kb { --kbh: clamp(130px, 30vh, 260px); }
}
/* móvil apaisado bajito */
@media (max-height: 430px) {
  .topbar { padding-top: 4px; padding-bottom: 2px; }
  .icon-btn, .mic { width: 40px; height: 40px; }
  .dots { height: 10px; }
  .dots i { width: 10px; height: 10px; }
}
