@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0f1e;
  --glass: rgba(255,255,255,0.08);
  --glass-h: rgba(255,255,255,0.16);
  --border: rgba(255,255,255,0.14);
  --text: #f0f4ff;
  --muted: rgba(240,244,255,0.45);
  --accent: #3b82f6;
  --accent2: #60a5fa;
  --danger: #ef4444;
  --gold: #fbbf24;
  --blur: blur(20px);
  --r: 16px;
  --r-sm: 10px;
}

body {
  font-family: 'Inter', sans-serif;
  background: #0a0f1e;
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  position: relative;
}

.background-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: #020208;
  animation: subtleHueShift 20s infinite alternate;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.background-container.hide { display: none; }
.noise {
  position: fixed; top: -50%; left: -50%; width: 200%; height: 200%; z-index: 1;
  background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMDAiIGhlaWdodD0iMzAwIj48ZmlsdGVyIGlkPSJub2lzZSI+PGZlVHVyYnVsZW5jZSB0eXBlPSJmcmFjdGFsTm9pc2UiIGJhc2VGcmVxdWVuY3k9IjAuOCIgbnVtT2N0YXZlcz0iMyIgc3RpdGNoVGlsZXM9InN0aXRjaCIvPjwvZmlsdGVyPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbHRlcj0idXJsKCNub2lzZSkiIG9wYWNpdHk9IjAuMDciLz48L3N2Zz4=');
  animation: moveNoise 10s steps(10) infinite;
  pointer-events: none;
}
.big-btn.snap {
  background: #4caf50;
  color: white;
}
.big-btn.snap.active {
  background: #ff9800;
}
.blob {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.blob1 { width: 900px; height: 900px; background: radial-gradient(circle, #00AFFF 0%, rgba(0,175,255,0) 70%); animation: morphAndMove1 5s infinite alternate; }
.blob2 { width: 650px; height: 650px; background: radial-gradient(circle, #007BFF 0%, rgba(0,123,255,0) 70%); animation: morphAndMove2 7s infinite alternate; }
.blob3 { width: 750px; height: 750px; background: radial-gradient(circle, #5865F2 0%, rgba(88,101,242,0) 70%); animation: morphAndMove3 4s infinite alternate; }

@keyframes subtleHueShift {
  from { filter: blur(100px) brightness(0.85) hue-rotate(0deg); }
  to { filter: blur(100px) brightness(0.85) hue-rotate(45deg); }
}
@keyframes moveNoise { to { transform: translate3d(2%, 5%, 0); } }
@keyframes morphAndMove1 {
  0% { transform: translate(-50%, -50%) translate(-10%, -10%) scale(0.7); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) translate(15%, 5%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(5%, -5%) scale(0.8); opacity: 0.7; }
}
@keyframes morphAndMove2 {
  0% { transform: translate(-50%, -50%) translate(5%, -20%) scale(0.8); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) translate(-10%, 15%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(10%, 10%) scale(0.7); opacity: 0.6; }
}
@keyframes morphAndMove3 {
  0% { transform: translate(-50%, -50%) translate(-15%, 20%) scale(0.9); opacity: 0.6; }
  50% { transform: translate(-50%, -50%) translate(10%, -15%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(-10%, 5%) scale(0.8); opacity: 0.6; }
}

.glass {
  background: var(--glass);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

#splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  padding: 2rem;
  background: radial-gradient(ellipse 80% 60% at 50% 30%, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.6) 100%);
}
.logo-wrap { height: 140px; display: flex; align-items: center; justify-content: center; }
#logo-img { max-height: 100px; width: auto; }
.splash-card { width: 100%; max-width: 340px; padding: 1.8rem 1.6rem; display: flex; flex-direction: column; gap: 1.1rem; text-align: center; }
.splash-title { font-size: 1rem; font-weight: 600; line-height: 1.55; }
.splash-sub { font-size: 0.8rem; color: var(--muted); line-height: 1.7; }
.btn-start {
  padding: 1rem 2rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 32px rgba(59,130,246,.45), 0 4px 16px rgba(0,0,0,.3);
  transition: transform 0.15s;
}
.btn-start:active { transform: scale(0.97); }
.no-webxr-msg {
  display: none;
  padding: 0.9rem 1.1rem;
  border-radius: var(--r-sm);
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.35);
  font-size: 0.8rem;
}

#ar-canvas { position: fixed; inset: 0; display: none; z-index: 2; }

#hud {
  position: fixed;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 20;
}
#top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  pointer-events: all;
}
#step-pill {
  flex: 1;
  padding: 0.6rem 1.1rem;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 600;
  pointer-events: none;
  margin-right: 1rem;
  text-align: center;
}
#pt-badge {
  padding: 0.5rem 0.9rem;
  border-radius: var(--r-sm);
  font-size: 0.7rem;
  text-align: center;
}
#pt-badge strong { display: block; font-size: 1.3rem; color: var(--gold); }

#right-tools {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: all;
}
.mode-btn {
  width: 80px;
  padding: 10px 0;
  border-radius: 40px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}
.mode-btn:active { transform: scale(0.95); background: rgba(255,255,255,0.2); }
.mode-btn:disabled { opacity: 0.3; pointer-events: none; }
.mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

#bottom-bar {
  position: absolute;
  bottom: 30px;
  left: 16px;
  right: 16px;
  display: flex;
  gap: 12px;
  pointer-events: all;
}
.big-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 40px;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: none;
  backdrop-filter: blur(16px);
  background: rgba(255,255,255,0.12);
  color: white;
  transition: transform 0.1s, background 0.2s;
}
.big-btn:active { transform: scale(0.97); background: rgba(255,255,255,0.2); }
.big-btn.danger { background: rgba(239,68,68,0.7); }
.big-btn.close { background: rgba(96,165,250,0.7); }
.big-btn.primary { background: rgba(59,130,246,0.9); box-shadow: 0 0 12px rgba(59,130,246,.4); }
.big-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.tap-ring {
  position: fixed;
  z-index: 30;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  animation: ring-out 0.5s ease-out forwards;
  pointer-events: none;
}
@keyframes ring-out {
  from { transform: scale(0.2); opacity: 1; }
  to { transform: scale(1.8); opacity: 0; }
}

#fp-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10,15,30,0.85);
  backdrop-filter: blur(10px);
  display: none;
  flex-direction: column;
}
#fp-header {
  padding: 1.3rem 1.2rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
}
.fp-logo { font-size: 1rem; font-weight: 600; color: var(--text); }
.fp-logo span { color: var(--accent); }
#fp-meta { font-size: 0.72rem; color: var(--muted); margin-top: 3px; }
#fp-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
}
#fp-canvas { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: 0 8px 48px rgba(0,0,0,.6); }
#fp-actions {
  padding: 1rem 1rem 2.2rem;
  display: flex;
  gap: 0.6rem;
  background: var(--glass);
  border-top: 1px solid var(--border);
}
.tb-btn {
  flex: 1;
  padding: 0.7rem 0.2rem;
  border-radius: var(--r);
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: var(--blur);
  color: var(--text);
  transition: background 0.15s, transform 0.1s;
}
.tb-btn:active { transform: scale(0.97); background: var(--glass-h); }
.tb-btn.primary { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 20px rgba(59,130,246,.4); }
.tb-btn.danger-btn { background: rgba(239,68,68,.18); border-color: rgba(239,68,68,.4); }
.tb-btn.close-btn { background: rgba(96,165,250,.18); border-color: rgba(96,165,250,.4); }

#fallback-canvas {
  position: fixed;
  inset: 0;
  display: none;
  cursor: crosshair;
  z-index: 15;
}
#fallback-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: none;
  background: radial-gradient(ellipse 70% 50% at 50% 60%, rgba(59,130,246,.1) 0%, transparent 70%);
}