:root {
  color: #f7faf8;
  background: #050706;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* { box-sizing: border-box; }

html, body, #app, #scene { width: 100%; height: 100%; }

html, body { margin: 0; overflow: hidden; background: #050706; }

button, input { font: inherit; }

#app { position: relative; isolation: isolate; min-height: 100dvh; }

#scene canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 46%, transparent 20%, rgba(0, 0, 0, .22) 64%, rgba(0, 0, 0, .72) 100%);
  z-index: 2;
}

.status {
  position: absolute;
  top: max(14vh, env(safe-area-inset-top));
  left: 50%;
  z-index: 4;
  width: min(88vw, 460px);
  text-align: center;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity .24s ease, transform .24s ease;
}

.status strong { display: block; font-size: clamp(18px, 3.8vw, 28px); font-weight: 720; }
.status span { display: block; margin-top: 7px; color: rgba(235, 241, 238, .58); font-size: 12px; }
.status.hidden { opacity: 0; transform: translate(-50%, -8px); }
.status[data-mode="tear"] { top: 39vh; }
.status[data-mode="reveal"] { top: auto; bottom: max(7vh, calc(env(safe-area-inset-bottom) + 48px)); }
.status[data-mode="complete"] { top: auto; bottom: max(7vh, calc(env(safe-area-inset-bottom) + 48px)); }

.progress {
  display: none;
  position: absolute;
  left: 50%;
  bottom: max(13vh, calc(env(safe-area-inset-bottom) + 64px));
  z-index: 4;
  width: min(62vw, 280px);
  height: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, .12);
  opacity: 0;
  transform: translateX(-50%);
  transition: opacity .2s ease;
}

.progress.visible { opacity: 1; }
.progress i { display: block; width: 100%; height: 100%; background: #54f6bf; transform: scaleX(0); transform-origin: left; }

.reset {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: 18px;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: rgba(255, 255, 255, .82);
  background: rgba(9, 13, 11, .72);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 6px;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.reset:hover { color: #fff; border-color: rgba(255, 255, 255, .42); }

.utility-links {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 18px;
  z-index: 6;
  display: flex;
  gap: 8px;
}

.utility-links a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 11px 0 8px;
  color: rgba(255, 255, 255, .78);
  background: rgba(9, 13, 11, .72);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 6px;
  text-decoration: none;
  backdrop-filter: blur(12px);
}

.utility-links a:hover { color: #fff; border-color: rgba(255, 255, 255, .42); }
.utility-links span { display: grid; place-items: center; width: 24px; height: 24px; font-size: 16px; font-weight: 800; }
.utility-links b { font-size: 11px; font-weight: 650; }

.settings {
  position: absolute;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  gap: 14px;
  padding: 10px 12px;
  color: rgba(255, 255, 255, .72);
  background: rgba(9, 13, 11, .72);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 6px;
  backdrop-filter: blur(12px);
}

.settings label { display: flex; gap: 7px; align-items: center; font-size: 11px; cursor: pointer; }
.settings input { width: 14px; height: 14px; margin: 0; accent-color: #54f6bf; }

.theme-picker {
  position: absolute;
  left: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  gap: 9px;
  padding: 9px;
  background: rgba(9, 13, 11, .72);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 6px;
  backdrop-filter: blur(12px);
}

.theme-swatch {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .28);
}

.theme-swatch.blue { background: #3788ff; }
.theme-swatch.orange { background: #ff6d24; }
.theme-swatch.gold { background: #ffd462; }
.theme-swatch.red { background: #ff334e; }
.theme-swatch.active { outline: 2px solid #fff; outline-offset: 2px; }

.loading {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-content: center;
  gap: 14px;
  color: rgba(255, 255, 255, .64);
  background: #050706;
  text-align: center;
  transition: opacity .45s ease, visibility .45s ease;
}

.loading.hide { opacity: 0; visibility: hidden; }
.loading span { width: 30px; height: 30px; margin: auto; border: 2px solid rgba(255, 255, 255, .16); border-top-color: #54f6bf; border-radius: 50%; animation: spin .8s linear infinite; }
.loading b { font-size: 11px; font-weight: 600; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .settings { right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .theme-picker { left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); }
  .reset { top: max(12px, env(safe-area-inset-top)); right: 12px; }
  .utility-links { top: max(12px, env(safe-area-inset-top)); left: 12px; gap: 6px; }
  .utility-links a { min-height: 40px; padding: 0 8px 0 6px; }
  .utility-links span { width: 20px; }
  .utility-links b { font-size: 10px; }
  .status { top: max(14vh, calc(env(safe-area-inset-top) + 56px)); }
  .status[data-mode="tear"] { top: 39vh; }
  .status[data-mode="reveal"] { top: auto; bottom: max(7vh, calc(env(safe-area-inset-bottom) + 48px)); }
  .status[data-mode="complete"] { top: auto; bottom: max(7vh, calc(env(safe-area-inset-bottom) + 48px)); }
}

@media (prefers-reduced-motion: reduce) {
  .status, .progress, .loading { transition: none; }
}
