:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: #05070a; }
body {
  min-height: 100svh;
  overflow: hidden;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

/* Author display rules otherwise override the browser's [hidden] behavior. */
[hidden] { display: none !important; }

button, a { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #05070a;
  touch-action: none;
}

.camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #05070a;
  transform: translateZ(0);
}

.veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: .72;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 20%, rgba(68,89,116,.20), transparent 32%),
    radial-gradient(circle at 80% 10%, rgba(255,255,255,.06), transparent 28%),
    linear-gradient(180deg, rgba(7,10,14,.65), rgba(0,0,0,.38));
  transition: opacity .25s ease;
}

.scratch {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  touch-action: none;
  transition: opacity .45s ease;
}

.glass-noise {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: .10;
  background-image:
    repeating-linear-gradient(96deg, rgba(255,255,255,.025) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(12deg, rgba(255,255,255,.016) 0 1px, transparent 1px 7px);
  mix-blend-mode: screen;
}

.hud {
  position: absolute;
  z-index: 8;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 13px) 16px 10px;
  pointer-events: none;
}

.hud > * { pointer-events: auto; }
.home {
  justify-self: start;
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  background: rgba(5,7,10,.35);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}

.meter {
  min-width: 92px;
  padding: 7px 12px 8px;
  text-align: center;
  border-radius: 999px;
  background: rgba(5,7,10,.44);
  border: 1px solid rgba(255,255,255,.12);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.meter-label { display: block; color: rgba(255,255,255,.48); font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.meter strong { display: block; margin-top: 1px; font-size: 15px; letter-spacing: -.02em; }
.reset {
  justify-self: end;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 999px;
  color: rgba(255,255,255,.74);
  background: rgba(5,7,10,.36);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  font-size: 10px;
  font-weight: 850;
}

.boot {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: flex-end;
  padding: 28px 24px calc(var(--safe-bottom) + 44px);
  background:
    radial-gradient(circle at 50% 13%, rgba(89,111,140,.18), transparent 32%),
    linear-gradient(180deg, rgba(6,9,13,.32), #07090d 72%);
}
.app.is-live .boot { display: none; }
.boot-copy { width: 100%; max-width: 520px; margin: 0 auto; }
.eyebrow {
  margin: 0 0 12px;
  color: rgba(255,255,255,.42);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .28em;
}
h1 {
  margin: 0;
  font-size: clamp(58px, 18vw, 106px);
  line-height: .88;
  letter-spacing: -.075em;
}
.lead {
  margin: 24px 0 28px;
  color: rgba(255,255,255,.68);
  font-size: 14px;
  line-height: 1.8;
  font-weight: 650;
}
.start {
  width: 100%;
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 19px 0 21px;
  border: 0;
  border-radius: 19px;
  background: #fff;
  color: #090b0f;
  font-weight: 900;
  box-shadow: 0 14px 42px rgba(0,0,0,.28);
}
.start b { font-size: 22px; }
.start:disabled { opacity: .6; }
.privacy { margin: 13px 2px 0; color: rgba(255,255,255,.35); font-size: 9px; line-height: 1.65; }

.rub-hint {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 75px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  border-radius: 999px;
  background: rgba(4,5,8,.28);
  border: 1px solid rgba(255,255,255,.14);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: rgba(255,255,255,.78);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .03em;
  pointer-events: none;
  animation: breathe 1.25s ease-in-out infinite alternate;
  transition: opacity .28s ease, transform .28s ease;
}
.rub-hint.fade { opacity: 0; transform: translateX(-50%) translateY(8px); }
.finger {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,.7);
  border-radius: 50%;
  color: transparent;
  box-shadow: 17px 0 0 -3px rgba(255,255,255,.22), -17px 0 0 -3px rgba(255,255,255,.22);
}
@keyframes breathe { to { transform: translateX(-50%) scale(1.035); } }

.done {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: grid;
  place-items: end center;
  padding-bottom: calc(var(--safe-bottom) + 78px);
  pointer-events: none;
  animation: doneIn .7s ease both;
}
.done p {
  margin: 0;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.17);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
}
@keyframes doneIn { from { opacity: 0; transform: translateY(8px); } }

.error-panel {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 22px 20px calc(var(--safe-bottom) + 22px);
  background: rgba(3,4,6,.82);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.error-card { width: min(100%, 480px); padding: 22px; border-radius: 24px; background: #151920; border: 1px solid rgba(255,255,255,.09); }
.error-card h2 { margin: 0 0 10px; font-size: 25px; letter-spacing: -.04em; }
.error-card p:not(.eyebrow) { margin: 0; color: rgba(255,255,255,.61); font-size: 12px; line-height: 1.75; }
.retry { margin-top: 18px; width: 100%; min-height: 50px; border: 0; border-radius: 15px; background: #fff; color: #090b0f; font-weight: 900; }

.app.is-done .scratch { opacity: 0; pointer-events: none; }
.app.is-done .veil { opacity: 0 !important; }
.app.is-done .glass-noise { opacity: .03; }
.app.is-done .meter { opacity: .78; }

@media (min-width: 720px) {
  .boot { align-items: center; }
  .boot-copy { width: min(88vw, 520px); }
  .hud { max-width: 720px; margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
