:root {
  --pink: #ff6ef1;
  --purple: #b862ff;
  --violet: #7d4dff;
  --blue: #46c5ff;
  --gold: #ffd86d;
  --fg: rgba(255,255,255,.96);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #020004;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button { font: inherit; -webkit-tap-highlight-color: transparent; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: manipulation;
  background: radial-gradient(circle at center, #130019 0%, #020004 70%);
}
#camera, #threeCanvas, #fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#camera {
  object-fit: cover;
  transform: scaleX(-1);
  opacity: .98;
}
#camera.back { transform: none; }
#threeCanvas { pointer-events: none; z-index: 2; }
#fx { pointer-events: none; z-index: 3; mix-blend-mode: screen; }

.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 420px);
  padding: 24px 20px 22px;
  color: white;
  z-index: 5;
  border-radius: 28px;
  text-align: center;
  background: linear-gradient(150deg, rgba(25, 0, 34, .80), rgba(4, 0, 12, .58));
  border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 24px 90px rgba(0,0,0,.45), inset 0 0 34px rgba(255,255,255,.05);
  backdrop-filter: blur(18px);
}
.panel h1 {
  margin: 0 0 10px;
  font-size: 28px;
  text-shadow: 0 0 20px rgba(255, 105, 244, .42);
}
.panel p {
  margin: 0 0 18px;
  line-height: 1.55;
  color: rgba(255,255,255,.86);
}
.scan-box {
  position: relative;
  width: min(70vw, 260px);
  aspect-ratio: 9 / 16;
  margin: 0 auto 16px;
  border-radius: 24px;
  background: rgba(255,255,255,.03);
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0,0,0,.22), 0 0 28px rgba(184, 98, 255, .12);
}
.scan-box img {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
  object-fit: contain;
  opacity: .28;
  filter: saturate(1.08) brightness(1.06) drop-shadow(0 0 20px rgba(184, 98, 255, .25));
}
.scan-corner {
  position: absolute;
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255,255,255,.94);
  filter: drop-shadow(0 0 12px rgba(209, 130, 255, .7));
}
.c1 { top: 12px; left: 12px; border-right: 0; border-bottom: 0; border-radius: 16px 0 0 0; }
.c2 { top: 12px; right: 12px; border-left: 0; border-bottom: 0; border-radius: 0 16px 0 0; }
.c3 { bottom: 12px; left: 12px; border-right: 0; border-top: 0; border-radius: 0 0 0 16px; }
.c4 { bottom: 12px; right: 12px; border-left: 0; border-top: 0; border-radius: 0 0 16px 0; }
.scan-line {
  position: absolute;
  left: 8%;
  width: 84%;
  height: 2px;
  top: 10%;
  background: linear-gradient(90deg, transparent, #fff, #ff9ef6, #66c8ff, transparent);
  box-shadow: 0 0 14px rgba(255,255,255,.92), 0 0 28px rgba(184, 98, 255, .82);
  animation: scanning 2.4s ease-in-out infinite;
}
.btn-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.primary, .ghost, #topBar button {
  border: 0;
  color: white;
  border-radius: 999px;
  cursor: pointer;
}
.primary {
  padding: 13px 20px;
  font-weight: 750;
  background: linear-gradient(135deg, var(--pink), var(--violet) 52%, var(--blue));
  box-shadow: 0 0 24px rgba(184, 98, 255, .46);
}
.ghost {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(10px);
}
.tips {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255,255,255,.72);
}

#topBar {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  display: none;
  gap: 10px;
  z-index: 6;
}
#topBar button {
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: rgba(18, 0, 28, .60);
  border: 1px solid rgba(255,255,255,.15);
  backdrop-filter: blur(12px);
  box-shadow: 0 0 18px rgba(208, 114, 255, .15);
}
#statusPill, #hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  color: white;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(7, 0, 14, .58);
  backdrop-filter: blur(14px);
}
#statusPill {
  top: calc(14px + env(safe-area-inset-top));
  padding: 10px 14px;
  font-size: 14px;
  box-shadow: 0 0 22px rgba(200, 90, 255, .18);
}
#hint {
  bottom: calc(18px + env(safe-area-inset-bottom));
  max-width: 88vw;
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: 0 0 24px rgba(204, 90, 255, .20);
  display: none;
}
.started #topBar,
.started #hint { display: flex; }
.detected #intro,
.started.detected #intro {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity .35s ease;
}
#intro.hidden {
  display: none !important;
}

@keyframes scanning {
  0% { top: 10%; opacity: .65; }
  50% { opacity: 1; }
  100% { top: 86%; opacity: .65; }
}

@media (max-width: 420px) {
  .panel { padding: 20px 16px 18px; }
  .panel h1 { font-size: 24px; }
  .scan-box { width: min(74vw, 240px); }
}
