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

:root {
  --p:     #5b4fff;
  --p-glow: rgba(91,79,255,.4);
  --bg:    #0a0a1a;
  --bg2:   #10102a;
  --surf:  rgba(255,255,255,.06);
  --bord:  rgba(255,255,255,.10);
  --txt:   #f0f0ff;
  --dim:   rgba(240,240,255,.55);
  --gold:  #ffb830;
  --red:   #ff4757;
  --r:     16px;
  --rs:    10px;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Screen system ───────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
  z-index: 1;
}
.screen.active { opacity: 1; pointer-events: all; z-index: 10; }
.hidden { display: none !important; }

/* ── Splash ──────────────────────────────────────────────── */
#splash {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(91,79,255,.35) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg) 0%, #0d0d28 100%);
  overflow-y: auto;
  align-items: flex-start;
  padding: 0 0 40px;
}

.splash-inner {
  display: flex; flex-direction: column;
  align-items: center; gap: 22px;
  width: 100%; max-width: 420px;
  padding: 60px 28px 0;
  margin: 0 auto;
  text-align: center;
}

.logo-wrap {
  width: 96px; height: 96px;
  background: linear-gradient(135deg, #5b4fff 0%, #a855f7 100%);
  border-radius: 26px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 50px var(--p-glow);
  margin-bottom: 4px;
}
.logo-wrap svg { width: 56px; height: 56px; }

h1 {
  font-size: 2.4rem; font-weight: 800; letter-spacing: -.5px;
  background: linear-gradient(135deg, #fff 20%, #b0a8ff 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sub { font-size: 1rem; color: var(--dim); line-height: 1.6; }

.btn-cta {
  width: 100%; max-width: 300px;
  background: linear-gradient(135deg, #5b4fff 0%, #a855f7 100%);
  color: #fff; border: none;
  padding: 17px 36px; border-radius: 50px;
  font-size: 1.1rem; font-weight: 700;
  cursor: pointer; letter-spacing: .3px;
  box-shadow: 0 6px 28px var(--p-glow);
  transition: transform .15s, box-shadow .15s;
}
.btn-cta:active { transform: scale(.97); box-shadow: 0 2px 12px var(--p-glow); }

/* How-it-works pills */
.steps {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; text-align: left;
}
.step {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surf); border: 1px solid var(--bord);
  border-radius: var(--rs); padding: 12px 14px;
}
.step-num {
  width: 26px; height: 26px; min-width: 26px;
  background: var(--p); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; margin-top: 1px;
}
.step-txt strong { display: block; font-size: .92rem; margin-bottom: 2px; }
.step-txt small   { color: var(--dim); font-size: .8rem; }

/* Install banner (Android) */
.install-banner {
  width: 100%;
  background: rgba(91,79,255,.14);
  border: 1px solid rgba(91,79,255,.3);
  border-radius: var(--r); padding: 16px;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.install-banner p { font-size: .88rem; color: var(--dim); }
.btn-install {
  background: var(--p); color: #fff; border: none;
  padding: 11px 28px; border-radius: 50px;
  font-size: .92rem; font-weight: 700; cursor: pointer;
  transition: opacity .15s;
}
.btn-install:active { opacity: .85; }

/* iOS instructions */
.ios-tip {
  width: 100%;
  background: rgba(255,184,48,.1);
  border: 1px solid rgba(255,184,48,.25);
  border-radius: var(--r); padding: 14px 16px;
}
.ios-tip p { font-size: .85rem; color: var(--txt); line-height: 1.7; text-align: center; }
.ios-tip .kbd {
  display: inline-block;
  background: rgba(255,184,48,.2); border-radius: 4px;
  padding: 1px 7px; font-size: .9em; font-weight: 600;
}

.share-url {
  width: 100%;
  background: var(--surf); border: 1px solid var(--bord);
  border-radius: var(--r); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.share-url p { font-size: .82rem; color: var(--dim); }
.url-row { display: flex; gap: 8px; align-items: center; }
.url-row span {
  flex: 1; font-size: .82rem; color: var(--txt);
  background: rgba(255,255,255,.05); border: 1px solid var(--bord);
  border-radius: 8px; padding: 8px 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-copy {
  background: var(--surf); border: 1px solid var(--bord);
  color: var(--txt); padding: 8px 14px; border-radius: 8px;
  font-size: .82rem; cursor: pointer; white-space: nowrap;
  transition: background .15s;
}
.btn-copy:active { background: rgba(255,255,255,.15); }

/* Stars */
.stars { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.star {
  position: absolute; width: 2px; height: 2px;
  background: #fff; border-radius: 50%;
  animation: twinkle var(--d,3s) var(--delay,0s) infinite;
}
@keyframes twinkle { 0%,100%{opacity:.15} 50%{opacity:.7} }

/* ── Permissions ─────────────────────────────────────────── */
#permissions { background: var(--bg); }

.perm-card {
  background: var(--bg2); border: 1px solid var(--bord);
  border-radius: 24px; padding: 32px 22px;
  max-width: 380px; width: calc(100% - 40px);
  display: flex; flex-direction: column; gap: 22px;
}
.perm-card h2 { font-size: 1.45rem; font-weight: 700; }
.perm-card .desc { color: var(--dim); font-size: .92rem; line-height: 1.6; }

.perm-list { display: flex; flex-direction: column; gap: 10px; }
.perm-item {
  display: flex; align-items: center; gap: 14px;
  background: var(--surf); border: 1px solid var(--bord);
  border-radius: var(--rs); padding: 13px 15px;
}
.pi-icon { font-size: 1.5rem; min-width: 36px; text-align: center; }
.pi-text strong { display: block; font-size: .93rem; }
.pi-text small  { color: var(--dim); font-size: .78rem; }

.tip-box {
  background: rgba(255,184,48,.08); border: 1px solid rgba(255,184,48,.2);
  border-radius: var(--rs); padding: 12px 14px;
  font-size: .82rem; color: var(--dim); line-height: 1.6;
}
.tip-box strong { color: var(--gold); }

/* ── Loading ─────────────────────────────────────────────── */
#loading { background: var(--bg); flex-direction: column; gap: 20px; }

.spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--bord); border-top-color: var(--p);
  border-radius: 50%; animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { color: var(--dim); font-size: .95rem; }

/* ── Projector ───────────────────────────────────────────── */
#projector { background: #000; }

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

/* Tap hint */
#tapHint {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.6); backdrop-filter: blur(10px);
  border: 1px solid var(--bord); color: var(--dim);
  font-size: .78rem; padding: 7px 16px; border-radius: 20px;
  pointer-events: none; z-index: 200;
  opacity: 1; transition: opacity .5s;
}
#tapHint.fade { opacity: 0; }

/* Controls */
#controls {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 0 16px 16px;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  display: flex; flex-direction: column; gap: 10px;
  z-index: 100;
  transition: opacity .3s, transform .3s;
}
#controls.ctrl-hidden {
  opacity: 0; pointer-events: none; transform: translateY(16px);
}

.ctrl-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

.slider-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
}
.sl-label { font-size: .72rem; color: var(--dim); min-width: 56px; text-align: right; }

input[type="range"] {
  -webkit-appearance: none; flex: 1; height: 4px;
  background: rgba(255,255,255,.18); border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  background: var(--p); border-radius: 50%;
  box-shadow: 0 0 8px var(--p-glow); cursor: pointer;
}

select {
  background: rgba(255,255,255,.1); border: 1px solid var(--bord);
  color: var(--txt); padding: 7px 10px; border-radius: var(--rs);
  font-size: .82rem; outline: none;
}

.cbtn {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.1); border: 1px solid var(--bord);
  color: var(--txt); padding: 9px 13px; border-radius: var(--rs);
  font-size: .8rem; cursor: pointer; white-space: nowrap;
  transition: background .15s;
}
.cbtn:active { background: rgba(255,255,255,.2); }
.cbtn.on  { background: rgba(91,79,255,.3); border-color: rgba(91,79,255,.5); }
.cbtn.red { background: rgba(255,71,87,.2); border-color: rgba(255,71,87,.3); color: #ff7480; }

/* ── Error ───────────────────────────────────────────────── */
#error { background: var(--bg); }

.err-card {
  background: var(--bg2); border: 1px solid rgba(255,71,87,.25);
  border-radius: 24px; padding: 32px 24px;
  max-width: 360px; width: calc(100% - 40px);
  display: flex; flex-direction: column; align-items: center;
  gap: 14px; text-align: center;
}
.err-icon { font-size: 3rem; }
.err-card h3 { font-size: 1.2rem; color: #ff7480; }
.err-card p  { color: var(--dim); font-size: .9rem; line-height: 1.6; }
.btn-back {
  background: var(--surf); border: 1px solid var(--bord);
  color: var(--txt); padding: 11px 28px; border-radius: 50px;
  font-size: .92rem; font-weight: 600; cursor: pointer;
}
.btn-back:active { background: rgba(255,255,255,.12); }
