/* ============================================================
   SeparaLAB — Estilos
   Laboratorio interactivo de separación de mezclas
   ============================================================ */

:root {
  --bg1: #170f3a;
  --bg2: #261a58;
  --bg3: #0d1b4e;
  --ink: #ffffff;
  --ink-dim: rgba(255,255,255,.78);
  --accent: #22d3ee;
  --accent2: #67e8f9;
  --lime: #a3e635;
  --pink: #f472b6;
  --amber: #fbbf24;
  --orange: #fb923c;
  --red: #fb7185;
  --purple: #a78bfa;
  --glass: rgba(255,255,255,.09);
  --glass-line: rgba(255,255,255,.22);
  --shadow: 0 18px 45px rgba(0,0,0,.45);
  --radius: 22px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: 'Baloo 2', 'Nunito', 'Comic Sans MS', 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(103,232,249,.14), transparent 60%),
    radial-gradient(1000px 600px at 110% 110%, rgba(167,139,250,.18), transparent 60%),
    radial-gradient(900px 500px at 50% 120%, rgba(34,211,238,.10), transparent 55%),
    linear-gradient(160deg, var(--bg1), var(--bg2) 55%, var(--bg3));
  overflow: hidden;
}

/* ---------- Fondo animado de burbujas ---------- */
#bg-fx {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 20% 30%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 60% 70%, rgba(255,255,255,.4), transparent),
    radial-gradient(2px 2px at 80% 20%, rgba(255,255,255,.35), transparent),
    radial-gradient(1.5px 1.5px at 40% 85%, rgba(255,255,255,.4), transparent);
  background-size: 300px 300px;
  animation: bgDrift 40s linear infinite;
}
@keyframes bgDrift {
  from { background-position: 0 0, 0 0, 0 0, 0 0; }
  to   { background-position: 300px 300px, -300px 150px, 200px -200px, -150px 100px; }
}

/* ---------- Pantallas ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  overflow-y: auto;
  opacity: 0; visibility: hidden; transform: scale(.96);
  transition: opacity .45s ease, transform .45s ease, visibility .45s;
}
.screen.active { opacity: 1; visibility: visible; transform: scale(1); }

/* ---------- Botones ---------- */
.btn {
  font-family: inherit;
  border: none; cursor: pointer;
  font-weight: 800; font-size: 1.15rem;
  padding: 14px 30px; border-radius: 999px;
  letter-spacing: .5px; color: #fff;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
  position: relative;
}
.btn:active { transform: scale(.94); }
.btn:hover { filter: brightness(1.08); }

.btn-play {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  font-size: 1.5rem; padding: 18px 46px;
  text-shadow: 0 2px 0 rgba(0,0,0,.2);
  box-shadow: 0 10px 26px rgba(34,211,238,.45), inset 0 2px 0 rgba(255,255,255,.35);
  animation: pulse 2.2s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}
.btn-ghost {
  background: var(--glass);
  border: 2px solid var(--glass-line);
  backdrop-filter: blur(6px);
}
.btn-sm { font-size: 1rem; padding: 10px 22px; }

.btn-icon {
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--glass); border: 2px solid var(--glass-line);
  color: #fff; font-size: 1.25rem; cursor: pointer;
  transition: transform .15s ease, background .15s ease;
  backdrop-filter: blur(4px);
}
.btn-icon:hover { background: rgba(255,255,255,.2); transform: scale(1.08); }
.btn-icon:active { transform: scale(.92); }

/* ---------- MENÚ PRINCIPAL ---------- */
#screen-menu { flex-direction: column; gap: 10px; text-align: center; }
.menu-inner {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
  max-width: 720px;
  animation: popIn .7s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.85) translateY(30px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.lab-sign {
  display: inline-block;
  padding: 6px 22px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(251,191,36,.18), rgba(251,113,133,.18));
  border: 2px solid rgba(251,191,36,.45);
  color: var(--amber); font-weight: 800; font-size: .8rem;
  letter-spacing: 3px; text-transform: uppercase;
  box-shadow: 0 0 24px rgba(251,191,36,.25);
}

.game-title { line-height: 1; margin: 4px 0 0; }
.t-title {
  font-size: clamp(3.2rem, 10vw, 5.4rem); font-weight: 800;
  background: linear-gradient(120deg, var(--accent2), var(--lime) 40%, var(--amber) 75%, var(--pink));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,.25)) drop-shadow(0 0 26px rgba(103,232,249,.4));
  display: block;
}
.t-accent { background: linear-gradient(120deg, var(--pink), var(--orange)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.t-sub { display: block; margin-top: 8px; font-size: clamp(1.05rem, 3vw, 1.4rem); color: var(--ink-dim); font-weight: 600; }
.t-sub em { color: var(--accent2); font-style: normal; font-weight: 800; }

.mascot {
  background: var(--glass); border: 2px solid var(--glass-line);
  border-radius: var(--radius); padding: 16px 26px;
  max-width: 480px; backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.mascot-face { font-size: 2.4rem; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.mascot-name { font-weight: 800; font-size: 1.15rem; color: var(--accent2); }
.mascot-text { color: var(--ink-dim); font-size: 1rem; }

.diff-selector { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.ds-label { font-weight: 700; color: var(--ink-dim); }
.ds-options { display: flex; background: var(--glass); border-radius: 999px; border: 2px solid var(--glass-line); padding: 4px; }
.ds-btn {
  font-family: inherit; border: none; cursor: pointer;
  padding: 10px 22px; border-radius: 999px;
  background: transparent; color: var(--ink-dim); font-weight: 800; font-size: 1rem;
  transition: all .2s ease;
}
.ds-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff; box-shadow: 0 4px 14px rgba(34,211,238,.45);
}

.menu-buttons { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.credits { color: rgba(255,255,255,.55); font-size: .85rem; }

.menu-floats { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.float-emoji {
  position: absolute; font-size: 2rem; opacity: .55;
  animation: floaty 7s ease-in-out infinite;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,.3));
}
.e1 { left: 8%; top: 18%; animation-delay: 0s; }
.e2 { left: 85%; top: 22%; animation-delay: 1.2s; font-size: 2.6rem; }
.e3 { left: 14%; top: 72%; animation-delay: 2s; font-size: 2.4rem; }
.e4 { left: 88%; top: 68%; animation-delay: .6s; }
.e5 { left: 50%; top: 8%; animation-delay: 1.8s; font-size: 1.6rem; }
.e6 { left: 30%; top: 84%; animation-delay: 2.6s; font-size: 1.8rem; }
.e7 { left: 70%; top: 86%; animation-delay: .4s; }
.e8 { left: 60%; top: 12%; animation-delay: 3s; }
@keyframes floaty {
  0%,100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-26px) rotate(6deg); }
}

/* ---------- ¿Cómo jugar? ---------- */
.howto-inner { max-width: 760px; display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }
.h-title {
  font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 800;
  text-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.howto-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; width: 100%; }
.howto-card {
  background: var(--glass); border: 2px solid var(--glass-line);
  border-radius: var(--radius); padding: 18px 12px; backdrop-filter: blur(6px);
  position: relative; transition: transform .2s ease;
}
.howto-card:hover { transform: translateY(-6px) rotate(-1deg); }
.hc-num {
  position: absolute; top: -12px; left: 12px;
  background: linear-gradient(135deg, var(--amber), var(--orange));
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; box-shadow: 0 4px 10px rgba(0,0,0,.3);
}
.hc-emoji { font-size: 2.4rem; }
.howto-card p { color: var(--ink-dim); font-size: .95rem; }
.howto-tip {
  background: rgba(163,230,53,.12); border: 2px dashed rgba(163,230,53,.5);
  border-radius: var(--radius); padding: 14px 20px; color: var(--ink-dim); max-width: 560px;
}

/* ---------- Mapa de niveles ---------- */
.levels-inner { max-width: 920px; width: 100%; display: flex; flex-direction: column; gap: 22px; }
.levels-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.progress-pill {
  display: flex; gap: 14px; align-items: center;
  background: var(--glass); border: 2px solid var(--glass-line);
  border-radius: 999px; padding: 8px 18px; font-weight: 800;
}
.progress-pill span { color: var(--amber); }
.progress-pill span:last-child { color: var(--ink-dim); }

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
}
.level-card {
  position: relative;
  background: linear-gradient(160deg, rgba(255,255,255,.12), rgba(255,255,255,.04));
  border: 2px solid var(--glass-line);
  border-radius: var(--radius);
  padding: 18px 14px 14px;
  cursor: pointer;
  text-align: center;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
  backdrop-filter: blur(6px);
  overflow: hidden;
}
.level-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,.15) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform .6s ease;
}
.level-card:hover::before { transform: translateX(120%); }
.level-card:not(.locked):hover {
  transform: translateY(-8px) scale(1.03);
  border-color: var(--accent);
  box-shadow: 0 16px 34px rgba(34,211,238,.28);
}
.level-card.locked { opacity: .45; cursor: not-allowed; filter: saturate(.3); }
.level-card.completed { border-color: rgba(163,230,53,.55); }
.level-card.bonus { border-color: rgba(251,113,133,.55); }

.lc-num {
  position: absolute; top: 10px; left: 12px;
  font-size: .78rem; font-weight: 800; color: var(--ink-dim);
  background: rgba(0,0,0,.25); padding: 2px 10px; border-radius: 999px;
}
.lc-bonus {
  position: absolute; top: 10px; right: 12px;
  font-size: .7rem; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  padding: 2px 10px; border-radius: 999px;
  transform: rotate(6deg);
}
.lc-icon { font-size: 3rem; display: block; margin: 8px auto 4px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.35)); }
.lc-name { font-weight: 800; font-size: 1.1rem; }
.lc-mix { color: var(--ink-dim); font-size: .82rem; min-height: 2.4em; }
.lc-stars { font-size: .85rem; letter-spacing: 2px; color: rgba(255,255,255,.25); margin-top: 6px; }
.lc-stars .lit { color: var(--amber); text-shadow: 0 0 10px rgba(251,191,36,.6); }
.lc-lock-ico { font-size: 1.6rem; display: block; margin-top: 4px; }

/* ---------- QUIZ ---------- */
.quiz-inner { max-width: 860px; width: 100%; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.quiz-top { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.badge {
  background: linear-gradient(135deg, var(--purple), var(--accent));
  padding: 6px 16px; border-radius: 999px; font-weight: 800; font-size: .9rem;
  box-shadow: 0 4px 12px rgba(34,211,238,.35);
}
.badge-hint { background: linear-gradient(135deg, var(--amber), var(--orange)); }
.quiz-q { text-align: center; }
.quiz-question { font-size: clamp(1.15rem, 3.4vw, 1.5rem); font-weight: 700; color: var(--ink-dim); }
.quiz-question b { color: var(--amber); }

.mix-box {
  width: 260px; height: 170px; margin: 12px auto 0;
  border-radius: 18px; position: relative; overflow: hidden;
  background:
    radial-gradient(3px 3px at 30% 40%, rgba(255,255,255,.35), transparent),
    radial-gradient(2px 2px at 70% 60%, rgba(255,255,255,.3), transparent),
    linear-gradient(160deg, rgba(255,255,255,.14), rgba(255,255,255,.03));
  border: 2px solid var(--glass-line);
  box-shadow: inset 0 0 40px rgba(0,0,0,.3), 0 14px 30px rgba(0,0,0,.35);
}
.mix-emoji { font-size: 4rem; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; animation: bob 3.4s ease-in-out infinite; }

.quiz-ask { margin-top: 10px; font-size: clamp(1.1rem, 3vw, 1.35rem); font-weight: 800; }

.quiz-options {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; width: 100%;
}
.opt-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: linear-gradient(160deg, rgba(255,255,255,.12), rgba(255,255,255,.04));
  border: 3px solid var(--glass-line);
  border-radius: 18px; padding: 16px 10px;
  cursor: pointer; text-align: center;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s;
}
.opt-card:hover { transform: translateY(-5px) scale(1.03); border-color: var(--accent); box-shadow: 0 12px 26px rgba(34,211,238,.25); }
.opt-card svg { width: 64px; height: 64px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); }
.opt-name { font-weight: 800; font-size: 1rem; }
.opt-sub { font-size: .75rem; color: var(--ink-dim); }
.opt-card.correct {
  border-color: var(--lime); background: rgba(163,230,53,.18);
  animation: correctPop .5s ease;
}
.opt-card.wrong {
  border-color: var(--red); background: rgba(251,113,133,.16);
  animation: shake .45s ease;
}
.opt-card.faded { opacity: .4; pointer-events: none; filter: grayscale(.6); }
@keyframes correctPop { 0% { transform: scale(1); } 40% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-1deg); }
  40% { transform: translateX(10px) rotate(1deg); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(7px); }
}

.quiz-actions { display: flex; gap: 12px; }

.quiz-explain {
  background: rgba(163,230,53,.1); border: 2px dashed rgba(163,230,53,.5);
  border-radius: var(--radius); padding: 18px 24px; text-align: center;
  max-width: 620px; animation: popIn .4s ease both;
}
.qe-star { font-size: 2.2rem; animation: bob 1.5s ease-in-out infinite; }
#qe-text { color: var(--ink); margin: 8px 0 14px; font-size: 1.02rem; }

/* ---------- MINI-JUEGO ---------- */
.game-inner {
  width: 100%; max-width: 980px;
  display: flex; flex-direction: column; gap: 12px;
}
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.game-title-badge {
  font-weight: 800; font-size: 1.1rem;
  background: var(--glass); border: 2px solid var(--glass-line);
  padding: 6px 20px; border-radius: 999px;
}
.canvas-wrap {
  position: relative;
  background: linear-gradient(180deg, #223a6e 0%, #123 45%, #0e2a3a 100%);
  border-radius: var(--radius);
  border: 3px solid var(--glass-line);
  box-shadow: var(--shadow), inset 0 0 80px rgba(0,0,0,.35);
  overflow: hidden;
}
#gameCanvas {
  display: block; width: 100%; height: auto;
  aspect-ratio: 900 / 520;
  touch-action: none;
  cursor: pointer;
}
.canvas-hint {
  position: absolute; left: 50%; bottom: 12px;
  transform: translateX(-50%);
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  padding: 6px 18px; border-radius: 999px;
  font-size: .9rem; font-weight: 700;
  pointer-events: none;
  animation: hintFade 2.2s ease-in-out infinite;
}
@keyframes hintFade { 0%,100% { opacity: .7; } 50% { opacity: 1; } }

.game-bottom { display: flex; align-items: center; gap: 14px; color: var(--ink-dim); font-weight: 700; }
.progress-track {
  flex: 1; height: 16px; border-radius: 999px;
  background: rgba(255,255,255,.12); border: 2px solid var(--glass-line);
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--lime));
  border-radius: 999px;
  transition: width .4s ease;
  box-shadow: 0 0 14px rgba(163,230,53,.6);
}

/* ---------- RESULTADO ---------- */
.result-inner { max-width: 720px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.stars-row { display: flex; gap: 14px; }
.star {
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  opacity: .18; transform: scale(.6);
  transition: all .5s cubic-bezier(.2,1.5,.4,1);
}
.star.lit { opacity: 1; transform: scale(1); filter: drop-shadow(0 0 18px rgba(251,191,36,.8)); animation: starPop .6s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes starPop { from { transform: scale(0) rotate(-180deg); } to { transform: scale(1) rotate(0); } }

.result-card {
  background: var(--glass); border: 2px solid var(--glass-line);
  border-radius: var(--radius); padding: 22px 26px;
  backdrop-filter: blur(8px); box-shadow: var(--shadow);
}
.rc-method { font-size: 3.2rem; }
.rc-method svg { width: 110px; height: 110px; }
.result-card h3 { font-size: 1.6rem; color: var(--accent2); }
.result-card p { color: var(--ink-dim); margin-top: 6px; }
.fact-card {
  margin-top: 16px; background: rgba(251,191,36,.1);
  border: 2px dashed rgba(251,191,36,.5); border-radius: 16px;
  padding: 12px 16px; text-align: left;
}
.fact-card b { color: var(--amber); }
.fact-card p { color: var(--ink-dim); }

.result-buttons { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

/* ---------- TOSTADA ---------- */
.toast {
  position: fixed; left: 50%; top: 22px; transform: translateX(-50%);
  background: rgba(20,10,40,.92); border: 2px solid var(--accent);
  color: #fff; font-weight: 800; padding: 12px 24px; border-radius: 999px;
  z-index: 100; box-shadow: var(--shadow);
  transition: all .35s cubic-bezier(.2,1.4,.4,1);
  text-align: center; max-width: 90vw;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(-30px); pointer-events: none; }

/* ---------- CONFETI ---------- */
#confetti-host { position: fixed; inset: 0; z-index: 200; pointer-events: none; overflow: hidden; }
.confetti {
  position: absolute; top: -20px; border-radius: 3px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot)); }
}

/* ---------- Varios ---------- */
.hidden { display: none !important; }
.h-v { opacity: 0; visibility: hidden; }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.05); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 999px; }

@media (max-width: 640px) {
  .btn-play { font-size: 1.25rem; padding: 14px 32px; }
  .level-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .screen { padding: 16px; }
}
