:root {
  --blue: #1e6ff2;
  --blue-dark: #1450b8;
  --yellow: #ffd23f;
  --pink: #ff3fa4;
  --ink: #221a33;
  --card: #fffdf8;
  --muted: #6c6479;
  --font: "Fredoka", ui-rounded, system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: var(--font); color: var(--ink); user-select: none; -webkit-user-select: none;
  background: radial-gradient(circle at 50% 30%, #4d9bff, var(--blue) 45%, #0d3d9c);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- Pantallas ---------- */
.screen { position: fixed; inset: 0; z-index: 5; overflow-y: auto; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.home { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.logo { width: min(64vw, 280px); margin-top: 8px; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, .35)); }
.total { margin: 0; color: #fff; font-size: 18px; font-weight: 600; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.total b { color: var(--yellow); font-size: 22px; }

.btn {
  border: 0; border-radius: 16px; padding: 12px 22px; font-weight: 700; font-size: 18px;
  background: linear-gradient(180deg, #ffe066, #ffbf1f); color: #6b3a00;
  box-shadow: 0 4px 0 #c98a00, 0 8px 18px rgba(0, 0, 0, .2); transition: transform .08s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c98a00; }
.btn.big { font-size: 24px; padding: 14px 40px; }
.btn.ghost { background: #efeaf5; color: var(--ink); box-shadow: 0 4px 0 #cfc6dc; }

.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; width: min(100%, 420px); }
.lvl {
  aspect-ratio: 1; border: 0; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff; line-height: 1;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .25);
}
.lvl.inma { background: linear-gradient(160deg, #ff9a3c, #e8551f); }
.lvl.mati { background: linear-gradient(160deg, #ff6fbf, #d11f86); }
.lvl .ico { font-size: 16px; margin-bottom: 2px; }
.lvl .st { font-size: 10px; letter-spacing: 1px; color: #ffe066; margin-top: 3px; }
.lvl.locked { background: rgba(255, 255, 255, .25); color: rgba(255, 255, 255, .7); box-shadow: none; }
.home-foot { display: flex; gap: 18px; margin-top: 4px; }
.link { background: none; border: 0; color: rgba(255, 255, 255, .85); text-decoration: underline; font-size: 14px; }

.card-screen { display: grid; place-items: center; background: rgba(10, 20, 60, .55); backdrop-filter: blur(4px); }
.card {
  width: min(100%, 420px); background: var(--card); border-radius: 26px; padding: 18px 18px 20px; text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35); animation: pop .35s cubic-bezier(.2, 1.5, .4, 1);
}
.card.small { width: min(100%, 300px); }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }
.card h1 { margin: 4px 0 6px; font-size: 28px; }
.intro-img, .res-img { width: 100%; max-height: 42vh; object-fit: contain; border-radius: 16px; }
.who { margin: 6px 0 0; font-weight: 600; color: var(--pink); text-transform: uppercase; letter-spacing: 1px; font-size: 13px; }
.quote { margin: 0 0 10px; font-size: 18px; font-weight: 600; font-style: italic; }
.tips { list-style: none; padding: 0; margin: 0 0 14px; text-align: left; }
.tips li { background: #f1edf7; border-radius: 12px; padding: 8px 12px; margin-bottom: 6px; font-size: 15px; }
.row { display: flex; gap: 10px; justify-content: center; }
.row.col { flex-direction: column; }
.phrase { font-size: 22px; font-weight: 700; margin: 12px 0 6px; line-height: 1.15; }
.stars { font-size: 38px; letter-spacing: 4px; color: #e2dcea; min-height: 44px; }
.stars .on { color: #ffc21a; text-shadow: 0 2px 0 #c98a00; display: inline-block; animation: star .45s cubic-bezier(.2, 1.8, .4, 1) both; }
@keyframes star { from { transform: scale(0) rotate(-90deg); } }
.pts { font-size: 40px; font-weight: 700; color: var(--blue); font-variant-numeric: tabular-nums; }
.info { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.record {
  display: inline-block; margin: 0 0 12px; padding: 8px 16px; border-radius: 99px; font-weight: 700;
  background: linear-gradient(135deg, #fff1b8, #ffc93c); color: #6b3a00; animation: pop .6s cubic-bezier(.2, 1.8, .4, 1) both;
}

/* ---------- Marcador ---------- */
.hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 4; display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .45), rgba(0, 0, 0, 0));
}
.round { width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .9); font-size: 14px; font-weight: 700; flex: 0 0 auto; }
.face { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 3px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .3); flex: 0 0 auto; transition: transform .15s; }
.face.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: rotate(-12deg) scale(1.1); } 40%, 80% { transform: rotate(12deg) scale(1.1); } }
.hud-mid { flex: 1; min-width: 0; }
.hud-row { display: flex; justify-content: space-between; align-items: center; color: #fff; font-weight: 700; }
.lives { font-size: 22px; letter-spacing: 2px; }
.score { font-size: 24px; font-variant-numeric: tabular-nums; text-shadow: 0 2px 0 rgba(0, 0, 0, .35); }
.bar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .35); overflow: hidden; margin-top: 4px; }
.bar > div { height: 100%; width: 0; background: var(--yellow); border-radius: inherit; transition: width .2s; }
.combo {
  position: fixed; right: 14px; top: calc(max(10px, env(safe-area-inset-top)) + 62px); z-index: 4;
  background: var(--pink); color: #fff; font-weight: 700; font-size: 20px; padding: 4px 12px; border-radius: 99px;
  box-shadow: 0 3px 0 #a3126a; animation: pop .3s cubic-bezier(.2, 1.8, .4, 1);
}

/* Reacción grande al perder una vida (no bloquea los toques) */
.react {
  position: fixed; left: 50%; top: 30%; z-index: 4; pointer-events: none; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(86vw, 340px);
}
.react img {
  width: min(46vw, 190px); height: min(46vw, 190px); border-radius: 50%; object-fit: cover;
  border: 5px solid #fff; box-shadow: 0 0 0 5px #e63946, 0 12px 30px rgba(0, 0, 0, .4);
}
.react p {
  margin: 0; padding: 10px 18px; border-radius: 18px; background: rgba(34, 26, 51, .9); color: #fff;
  font-weight: 700; font-size: 22px; text-align: center; line-height: 1.15;
}
.react.show { animation: reactIn 1.25s cubic-bezier(.2, 1.6, .4, 1) both; }
.react.show img { animation: shake .5s .15s; }
@keyframes reactIn {
  0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(.9); opacity: 0; }
}

.res-wrap { position: relative; }
.res-face {
  position: absolute; left: -6px; bottom: -14px; width: 92px; height: 92px; border-radius: 50%; object-fit: cover;
  border: 4px solid #fff; box-shadow: 0 0 0 4px #e63946, 0 6px 16px rgba(0, 0, 0, .35); transform: rotate(-8deg);
  animation: pop .5s .3s cubic-bezier(.2, 1.8, .4, 1) both;
}
