:root {
  --fg: #e9f0ff; --dim: #9fb0cc; --accent: #8fb8ff; --coral: #ff7a5c;
  --glass: rgba(10, 18, 36, 0.55); --line: rgba(160, 190, 255, 0.18);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #03070f; color: var(--fg); overflow: hidden;
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#gl { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
video#cam { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.hidden { display: none !important; }

/* Portada */
.screen { position: fixed; inset: 0; display: grid; place-items: center; z-index: 20;
  background: radial-gradient(120% 80% at 50% 35%, #0d2146 0%, #050b18 55%, #02050b 100%); }
.splash-inner { text-align: center; padding: 32px 28px; max-width: 420px; animation: rise .9s ease both; }
.logo { width: 92px; height: 92px; filter: drop-shadow(0 0 24px rgba(120, 170, 255, .45)); animation: breathe 4s ease-in-out infinite; }
h1 { font-weight: 300; letter-spacing: .32em; text-transform: uppercase; font-size: 30px; margin: 18px 0 6px; padding-left: .32em; }
.tag { color: var(--dim); margin: 0 0 34px; font-size: 15px; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
.primary { display: block; width: 100%; padding: 16px; border-radius: 999px; font-size: 16px; letter-spacing: .06em;
  background: linear-gradient(135deg, #5d8eff, #8fb8ff 55%, #ffb199); color: #061024; font-weight: 600;
  box-shadow: 0 10px 34px rgba(93, 142, 255, .35); transition: transform .15s; }
.primary:active { transform: scale(.98); }
.ghost { display: block; width: 100%; margin-top: 12px; padding: 13px; border-radius: 999px; background: transparent;
  border: 1px solid var(--line); color: var(--dim); }
.status { min-height: 1.4em; color: var(--accent); margin: 18px 0 0; font-size: 14px; }
.privacy { color: #6f7f9a; font-size: 12.5px; margin-top: 26px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 50% { transform: scale(1.05); filter: drop-shadow(0 0 34px rgba(255, 140, 110, .4)); } }

/* Barra superior */
#top { position: fixed; left: 0; right: 0; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px; background: linear-gradient(#02050bcc, #02050b00); }
.brand { font-weight: 300; letter-spacing: .28em; text-transform: uppercase; font-size: 12px; color: var(--dim); }
#exp-name { flex: 1; font-size: 15px; letter-spacing: .04em; }
.right { display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #2a3550; transition: background .2s, box-shadow .2s; }
.dot.on { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
#hand-l.on { background: var(--coral); box-shadow: 0 0 10px var(--coral); }
.icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--glass);
  border: 1px solid var(--line); color: var(--fg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.icon svg { width: 20px; height: 20px; }

/* Pista central */
#hint { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); z-index: 9; padding: 10px 18px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); color: var(--fg); font-size: 14px;
  width: max-content; max-width: calc(100vw - 32px); text-align: center; border-radius: 18px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: opacity .6s; }
#hint.fade { opacity: 0; }

/* HUD inferior */
#hud { position: fixed; left: 16px; right: 16px; bottom: calc(78px + var(--safe-b)); z-index: 9; text-align: center; pointer-events: none; }
#hud-line { color: var(--dim); font-size: 13px; margin-bottom: 8px; text-shadow: 0 1px 8px #000; }
#bars { display: flex; justify-content: center; gap: 8px; }
.bar { width: 44px; text-align: center; font-size: 10px; color: #7f8fab; }
.bar i { display: block; height: 4px; border-radius: 2px; background: rgba(120, 150, 200, .18); margin-top: 4px; overflow: hidden; }
.bar i b { display: block; height: 100%; background: var(--accent); border-radius: 2px; transform-origin: left center;
  transform: scaleX(0); transition: transform .08s linear; will-change: transform; }
/* Fundido entre experiencias */
#fade { position: fixed; inset: 0; z-index: 5; background: #03070f; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
#fade.on { opacity: 1; transition-duration: .18s; }
.bar i.in b { background: var(--coral); }

/* Selector de experiencias */
/* 9 experiencias: fila que se desliza con el dedo, la activa se centra sola */
#exps { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; gap: 10px;
  padding: 12px 16px calc(14px + var(--safe-b)); background: linear-gradient(#02050b00, #02050bcc);
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(90deg, transparent, #000 24px, #000 calc(100% - 24px), transparent); }
#exps::-webkit-scrollbar { display: none; }
#exps::before, #exps::after { content: ''; flex: 1 0 0; }
#exps button { flex: 0 0 auto; scroll-snap-align: center; white-space: nowrap; padding: 10px 18px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); color: var(--dim);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 14px; }
#exps button.on { color: #061024; background: linear-gradient(135deg, #8fb8ff, #dbe9ff); border-color: transparent; font-weight: 600; }

/* Vista de cámara */
#pip { position: fixed; right: 14px; top: calc(62px + var(--safe-t)); z-index: 9; width: 120px; height: 90px; border-radius: 12px;
  border: 1px solid var(--line); background: #000a; }

/* Ajustes */
#sheet { position: fixed; inset: 0; z-index: 30; background: rgba(2, 5, 11, .45); display: flex; align-items: flex-end; }
.sheet-inner { width: 100%; max-width: 520px; margin: 0 auto; padding: 18px 20px calc(22px + var(--safe-b));
  background: rgba(10, 16, 30, .92); border-top: 1px solid var(--line); border-radius: 22px 22px 0 0;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); animation: up .25s ease both; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
h2 { font-weight: 400; font-size: 18px; margin: 4px 0 10px; }
.row { display: block; padding: 12px 0; border-bottom: 1px solid rgba(160, 190, 255, .08); color: var(--fg); font-size: 14px; }
.row output { float: right; color: var(--accent); }
.row input[type=range] { width: 100%; margin-top: 10px; accent-color: #8fb8ff; }
.row.check { display: flex; gap: 10px; align-items: center; }
.row.check input { width: 20px; height: 20px; accent-color: #8fb8ff; }
.seg { display: flex; gap: 6px; margin-top: 10px; }
.seg button { flex: 1; padding: 9px 0; border-radius: 10px; background: rgba(120, 150, 200, .1); color: var(--dim); font-size: 13px; }
.seg button.on { background: #8fb8ff; color: #061024; font-weight: 600; }
.tip { color: #74839e; font-size: 12.5px; margin: 14px 0 0; }

/* Pestañas del panel de ajustes */
.tabs { display: flex; gap: 4px; padding: 4px; margin: 2px 0 6px; border-radius: 12px; background: rgba(120, 150, 200, .08); }
.tabs button { flex: 1; padding: 9px 0; border-radius: 9px; background: transparent; color: var(--dim); font-size: 14px; }
.tabs button.on { background: rgba(143, 184, 255, .18); color: var(--fg); font-weight: 600; }
.pane { min-height: 236px; }
.pane .row:last-of-type { border-bottom: 0; }
.row.song { display: flex; align-items: center; gap: 12px; }
.pill { flex: 0 0 auto; padding: 9px 16px; border-radius: 999px; background: rgba(143, 184, 255, .16);
  border: 1px solid var(--line); color: var(--fg); font-size: 13px; }
.sub { flex: 1; min-width: 0; color: var(--dim); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg button { padding-left: 4px; padding-right: 4px; }

/* nota bajo una opción de ajustes */
.note { margin: -4px 0 8px 28px; font-size: 12px; line-height: 1.35; opacity: 0.65; }

/* Cuenta y BioSense Pro */
.sheet-inner { max-height: 88vh; overflow-y: auto; overscroll-behavior: contain; }
.form { display: grid; gap: 10px; margin-top: 12px; }
.form input { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid rgba(160, 190, 255, .16);
  background: rgba(10, 18, 34, .7); color: var(--fg); font: inherit; font-size: 15px; outline: none; }
.form input:focus { border-color: rgba(143, 184, 255, .55); }
.primary.small { padding: 12px; font-size: 15px; }
.primary:disabled { opacity: .55; }
.link { background: none; color: #8fb8ff; font-size: 13px; padding: 8px 0; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(143, 184, 255, .35); }
#btn-account { margin-top: 14px; }
.links { display: flex; justify-content: space-between; }
.msg { min-height: 1.2em; font-size: 13px; color: var(--accent); margin: 6px 0; }
.msg.err { color: #ff9b85; }
.why { margin: 6px 0 4px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 122, 92, .1); border: 1px solid rgba(255, 122, 92, .25); font-size: 13.5px; line-height: 1.4; }
.acc-who { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.acc-who span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { flex: 0 0 auto; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: rgba(120, 150, 200, .14); color: var(--dim); }
.badge.pro { background: linear-gradient(135deg, #8fb8ff, #dbe9ff); color: #061024; font-weight: 600; }
.plans { display: grid; gap: 8px; margin-top: 4px; }
.plan { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: rgba(120, 150, 200, .08); border: 1px solid rgba(160, 190, 255, .1); }
.plan.star { border-color: rgba(143, 184, 255, .45); background: rgba(143, 184, 255, .1); }
.plan div { flex: 1; min-width: 0; }
.plan b { display: block; font-weight: 600; font-size: 14px; }
.plan small { color: var(--dim); font-size: 12px; }
.plan .pill { font-size: 13px; }
/* Estilos en dos filas; sonido original / electrónica */
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 0 30%; padding-top: 8px; padding-bottom: 8px; font-size: 12.5px; }
/* Grabar 15 s y compartir */
#btn-rec.on { box-shadow: 0 0 0 2px rgba(255, 122, 92, .6); }
#btn-rec.on .rec-dot { animation: recblink 1s steps(2) infinite; }
@keyframes recblink { 50% { opacity: .25; } }
#rec-done { position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%); z-index: 12; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 16px; border-radius: 999px; background: rgba(8, 14, 28, .88); border: 1px solid rgba(160, 190, 255, .18); font-size: 13.5px; white-space: nowrap;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
#rec-done .link { padding: 4px 6px; text-decoration: none; }
/* Modo Evento */
.field { display: block; width: 100%; margin-top: 10px; padding: 11px 13px; border-radius: 12px; border: 1px solid rgba(160, 190, 255, .16);
  background: rgba(10, 18, 34, .7); color: var(--fg); font: inherit; font-size: 14px; outline: none; }
.check-inline { display: flex; gap: 10px; align-items: center; margin: 10px 0; font-size: 13.5px; color: var(--dim); }
.check-inline input { width: 18px; height: 18px; accent-color: #8fb8ff; }
body.evento #top, body.evento #exps, body.evento #hud, body.evento #hint, body.evento #pip, body.evento #rec-done { display: none !important; }
#ev-mark { position: fixed; right: 22px; bottom: calc(18px + var(--safe-b)); z-index: 9; text-align: right; pointer-events: none;
  color: rgba(215, 228, 255, .5); font-size: 12px; letter-spacing: .22em; text-transform: uppercase; text-shadow: 0 1px 10px #000; }
#ev-mark b { display: block; font-weight: 300; font-size: 22px; letter-spacing: .12em; color: rgba(230, 238, 255, .62); margin-bottom: 4px; text-transform: none; }