:root {
  --cyan: #00e5ff;
  --violet: #7c4dff;
  --bg: #04070c;
  --panel: rgba(10, 20, 34, 0.82);
  --text: #e8f4fb;
  --muted: #8aa3b8;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ============ landing ============ */
#landing {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 700px at 30% 20%, #0c1c30 0%, transparent 60%),
    radial-gradient(900px 600px at 80% 85%, #140f2e 0%, transparent 55%),
    var(--bg);
  z-index: 30;
  overflow-y: auto;
}
.landing-inner {
  text-align: center;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
  max-width: 420px;
}
.logo { width: 84px; height: 84px; filter: drop-shadow(0 0 18px rgba(0, 229, 255, 0.45)); }
.kicker {
  margin: 18px 0 6px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  letter-spacing: 5px;
  color: var(--cyan);
}
#landing h1 { margin: 0 0 4px; font-size: 34px; font-weight: 800; letter-spacing: 0.5px; }
.subtitle { margin: 0 0 30px; color: var(--muted); font-size: 15px; letter-spacing: 2px; text-transform: uppercase; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 30px;
  font-size: 17px;
  font-weight: 700;
  color: #032028;
  background: linear-gradient(120deg, var(--cyan), #46b4ff);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 0 28px rgba(0, 229, 255, 0.35), 0 6px 22px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease;
}
.btn-primary:active { transform: scale(0.96); }

.hint { margin-top: 18px; font-size: 13px; color: var(--muted); }

.qr-tile {
  display: inline-block;
  margin: 14px auto 20px;
  padding: 12px;
  background: #f4fbff;
  border-radius: 16px;
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.25), 0 8px 26px rgba(0, 0, 0, 0.5);
}
.qr-tile img { display: block; width: 168px; height: 168px; image-rendering: pixelated; }

.btn-ghost {
  padding: 10px 20px;
  font-size: 14px;
  color: var(--muted);
  background: transparent;
  border: 1px solid rgba(138, 163, 184, 0.35);
  border-radius: 999px;
  cursor: pointer;
}
.btn-ghost:active { background: rgba(0, 229, 255, 0.08); }
.landing-links { margin-top: 26px; font-size: 14px; color: var(--muted); display: flex; gap: 12px; justify-content: center; }
.landing-links a { color: var(--cyan); text-decoration: none; border-bottom: 1px dotted rgba(0, 229, 255, 0.5); }

/* ============ AR shell ============ */
#ar-shell { position: fixed; inset: 0; z-index: 10; }
#ar-container { position: absolute; inset: 0; }
#ar-container video, #ar-container canvas { position: absolute; inset: 0; }

#btn-close {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: 16px;
  z-index: 40;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(8, 14, 24, 0.6);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

/* ============ overlays ============ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: rgba(4, 7, 12, 0.45);
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
.overlay p { margin: 0; font-size: 16px; text-shadow: 0 2px 8px #000; }
.overlay .scan-sub { font-size: 13px; color: var(--muted); margin-top: -12px; }

.spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(0, 229, 255, 0.15);
  border-top-color: var(--cyan);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.scan-frame {
  position: relative;
  width: min(72vw, 340px);
  aspect-ratio: 1050 / 600;
  animation: breathe 2.4s ease-in-out infinite;
}
.scan-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.5;
  border-radius: 10px;
}
.scan-frame span {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 3px solid var(--cyan);
  filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.8));
}
.scan-frame span:nth-child(1) { top: -8px; left: -8px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.scan-frame span:nth-child(2) { top: -8px; right: -8px; border-left: 0; border-bottom: 0; border-radius: 0 8px 0 0; }
.scan-frame span:nth-child(3) { bottom: -8px; left: -8px; border-right: 0; border-top: 0; border-radius: 0 0 0 8px; }
.scan-frame span:nth-child(4) { bottom: -8px; right: -8px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.035); opacity: 0.82; } }

.error-box {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 18px;
  padding: 28px 26px;
  max-width: 360px;
  backdrop-filter: blur(10px);
}
.error-box h2 { margin: 0 0 8px; font-size: 20px; }
.error-box p { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

/* ============ dock ============ */
#dock {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 35;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid rgba(0, 229, 255, 0.22);
  border-radius: 22px;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55), 0 0 22px rgba(0, 229, 255, 0.12);
  animation: dock-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes dock-in { from { transform: translate(-50%, 90px); opacity: 0; } }
#dock button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 68px;
  padding: 9px 0;
  background: transparent;
  border: 0;
  border-radius: 14px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
#dock button:active { background: rgba(0, 229, 255, 0.14); }
#dock svg { width: 24px; height: 24px; color: var(--cyan); }

/* ============ toast ============ */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(112px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  background: var(--panel);
  border: 1px solid rgba(0, 229, 255, 0.3);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}
