html, body { height: 100%; overflow: hidden; background: #000; }

#cam { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#stage { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
#debug { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.plane {
  position: absolute; left: 0; top: 0; transform-origin: 0 0;
  opacity: 0; transition: opacity .45s ease; will-change: transform, opacity;
  backface-visibility: hidden; overflow: hidden;
}
.plane.on { opacity: 1; }
.plane video { width: 100%; height: 100%; display: block; background: transparent; pointer-events: none; }
.plane video::-webkit-media-controls { display: none !important; }

.glass { background: rgba(20, 18, 16, .55); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,.12); }

.hud { position: fixed; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 16px 0; gap: 10px; pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.hud-top-right { display: flex; gap: 8px; }
.chip { padding: 6px 14px; border-radius: 999px; font-size: 13.5px; max-width: 50vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 8px; vertical-align: 1px; }

.finder {
  position: absolute; left: 50%; top: 50%; width: min(62vw, 62vh); aspect-ratio: 1; transform: translate(-50%, -50%);
  pointer-events: none; transition: opacity .3s ease, transform .3s ease;
}
.finder i { position: absolute; width: 38px; height: 38px; border: 3px solid var(--accent); }
.finder i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.finder i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.finder i:nth-child(3) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.finder i:nth-child(4) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.scanline {
  position: absolute; left: 6%; right: 6%; height: 2px; top: 0;
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  box-shadow: 0 0 14px var(--accent); animation: scan 2.4s ease-in-out infinite;
}
@keyframes scan { 0%, 100% { top: 4%; } 50% { top: 96%; } }
.tracking .finder { opacity: 0; transform: translate(-50%, -50%) scale(1.15); }

.hint {
  position: absolute; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  padding: 10px 18px; border-radius: 999px; font-size: 14.5px; white-space: nowrap; transition: opacity .3s ease;
  pointer-events: none;
}
.tracking .hint { opacity: 0; }

.gate {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, #2a1d14 0%, var(--bg) 70%); z-index: 10;
}
.gate-card { text-align: center; display: grid; gap: 14px; justify-items: center; max-width: 380px; }
.gate h1 { font-size: 30px; }
.gate h1 span { color: var(--accent); }
.gate p { margin: 0; }
.gate .btn.primary { padding: 14px 32px; font-size: 16px; }

/* Website additions */
.small { font-size: 13px; }
.btn.icon { width: 48px; height: 48px; padding: 0; font-size: 20px; border-radius: 50%; }
.btn.big { padding: 16px 40px; font-size: 18px; min-height: 56px; }
.gate-sub { font-family: var(--serif); font-size: 20px; margin: -6px 0 0; }
.gate-sub:empty { display: none; }
.chip { margin-right: auto; }

.playbar {
  position: absolute; left: 0; right: 0; bottom: max(24px, env(safe-area-inset-bottom));
  display: flex; justify-content: center; gap: 10px; padding: 0 16px;
}
.playbar .btn { min-height: 48px; padding: 10px 20px; }
.tracking .hint { opacity: 0; }

dialog#sheet {
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 20px;
  padding: 22px; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
}
dialog#sheet::backdrop { background: rgba(0,0,0,.6); }
#sheet h2 { font-size: 22px; margin-bottom: 10px; }
#sheetBody { margin-bottom: 18px; line-height: 1.6; white-space: pre-line; }
#sheetBody ul { margin: 0; padding-left: 20px; white-space: normal; }
#sheetBody li { margin-bottom: 8px; }

/* Positioning guidance: artwork-shaped frame and rotate hint */
.rotate {
  position: absolute; left: 50%; top: calc(max(14px, env(safe-area-inset-top)) + 60px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-radius: 999px;
  font-size: 14.5px; max-width: calc(100vw - 32px); pointer-events: none;
}
.rotate .phone {
  flex: none; width: 14px; height: 22px; border: 2px solid var(--accent-2); border-radius: 3px;
  animation: turn-side 1.8s ease-in-out infinite;
}
.rotate.upright .phone { animation-name: turn-up; }
@keyframes turn-side { 0%, 25% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
@keyframes turn-up { 0%, 25% { transform: rotate(90deg); } 60%, 100% { transform: rotate(0); } }

/* Frame follows the recognised artwork and turns green when it's framed well */
.finder.following { transition: left .15s ease, top .15s ease, width .15s ease, height .15s ease; }
.finder.following .scanline { display: none; }
.finder.locked i { border-color: var(--ok); }

