*, *:before, *:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #060b13;
  font-family: "Noto Serif Devanagari", Tiro Devanagari Hindi, serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #0e1e38 0%, #060b13 100%);
}

#camera-feed {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  background: #060b13;
}

#ar-canvas {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
}

#ui-root {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  pointer-events: none;
}

#ui-root .interactive {
  pointer-events: auto;
}

/* Premium Radial Screen Backdrop with Glassmorphism */
.screen {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background: radial-gradient(circle at center, rgba(14, 30, 56, 0.9) 0%, rgba(6, 11, 19, 0.95) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #FF9933 0%, #FFFFFF 50%, #128807 100%);
  opacity: 0.8;
}

.screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Elegant Logo Styles */
.brand-logo {
  width: min(240px, 60vw);
  height: auto;
  margin-bottom: 2rem;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
  animation: fadeInDown 1.2s ease-out;
}

/* Saffron & Gold Ceremonial Greeting Typography */
.greeting {
  color: #ffffff;
  font-family: Tiro Devanagari Hindi, "Noto Serif Devanagari", serif;
  font-size: clamp(1.3rem, 4.5vw, 1.85rem);
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.02em;
  max-width: 18em;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.8);
  margin-bottom: 1rem;
  background: linear-gradient(135deg, #FF9933 0%, #FFFFFF 50%, #34C759 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: fadeInUp 1s ease-out;
}

.sub-instruction {
  color: #ffd27a;
  font-size: clamp(1rem, 3.8vw, 1.25rem);
  line-height: 1.5;
  margin-bottom: 2.5rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  letter-spacing: 0.03em;
  animation: fadeInUp 1.2s ease-out;
}

/* Saffron Metallic Action Button with Shimmer & Ripple Effects */
.start-btn {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: 1px solid rgba(255, 153, 51, 0.5);
  background: linear-gradient(135deg, #ff6f00 0%, #e65100 100%);
  color: #ffffff;
  font-family: inherit;
  font-weight: 600;
  font-size: 1.15rem;
  padding: 1rem 3rem;
  border-radius: 50px;
  cursor: pointer;
  letter-spacing: 0.05em;
  box-shadow: 0 8px 30px rgba(230, 81, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.3);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
  animation: pulseButton 2s infinite;
}

.start-btn:active {
  transform: scale(0.96);
  box-shadow: 0 4px 15px rgba(230, 81, 0, 0.3);
}

.start-btn:disabled {
  opacity: 0.6;
  cursor: wait;
  background: linear-gradient(135deg, #555 0%, #333 100%);
  box-shadow: none;
  border-color: #444;
}

.hint {
  margin-top: 1.5rem;
  color: rgba(245, 230, 200, 0.6);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.error-msg {
  color: #ffb4a8;
  font-size: 0.95rem;
  margin-top: 1.25rem;
  max-width: 18em;
  background: rgba(255, 180, 168, 0.1);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 180, 168, 0.25);
}

/* Polished Heads Up Display (HUD) */
.hud {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

.hud.visible {
  opacity: 1;
}

.hud-top {
  margin-top: max(1.5rem, env(safe-area-inset-top));
  padding: 1rem;
  text-align: center;
  background: linear-gradient(180deg, rgba(6, 11, 19, 0.85) 0%, rgba(6, 11, 19, 0) 100%);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-logo {
  width: min(150px, 38vw);
  height: auto;
  margin-bottom: 0.5rem;
  opacity: 0.95;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6));
}

.hud-greeting {
  color: #ffffff;
  font-family: Tiro Devanagari Hindi, serif;
  font-size: clamp(0.95rem, 3.8vw, 1.2rem);
  line-height: 1.45;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
  max-width: 22em;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.hud-bottom {
  margin-top: auto;
  margin-bottom: max(3rem, calc(env(safe-area-inset-bottom) + 1.75rem));
  text-align: center;
  width: 100%;
}

/* Saffron Glow Drag Instruction Button */
.pull-hint {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: 1px solid rgba(255, 153, 51, 0.4);
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff8ee;
  font-family: inherit;
  font-weight: 500;
  font-size: clamp(1rem, 4vw, 1.25rem);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  padding: 0.85rem 1.75rem;
  background: rgba(14, 30, 56, 0.65);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 153, 51, 0.25);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  cursor: pointer;
  pointer-events: auto;
}

.pull-hint:active {
  transform: scale(0.96);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.pull-hint.hidden {
  opacity: 0;
  pointer-events: none;
}

.pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff9933;
  box-shadow: 0 0 #ff9933b3;
  animation: pulseRing 1.6s ease-out infinite;
}

/* End Card with Bottom-Centered Glassmorphism layout */
.end-card {
  position: absolute;
  top: auto;
  right: 5%;
  bottom: max(3.5rem, calc(env(safe-area-inset-bottom) + 2rem));
  left: auto;
  width: 55%;
  max-width: 440px;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.75rem 2rem;
  background: rgba(6, 11, 19, 0.82);
  border: 1px solid rgba(255, 153, 51, 0.25);
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 18px rgba(255, 153, 51, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 1.2s cubic-bezier(0.2, 0.8, 0.2, 1), transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

.end-card:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, #FF9933 0%, #FFFFFF 50%, #128807 100%);
  opacity: 0.85;
}

.end-card.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.end-card .brand-logo {
  margin-bottom: 1.25rem;
  width: min(200px, 60vw);
  height: auto;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 1s ease-out 0.2s, transform 1s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s;
}

.end-card.visible .brand-logo {
  opacity: 1;
  transform: scale(1);
}

.end-card .greeting {
  margin-top: 0;
  margin-bottom: 0.25rem;
  text-align: center;
  font-size: clamp(1.15rem, 4.2vw, 1.55rem);
  line-height: 1.55;
  width: 100%;
  max-width: 18em;
  min-height: 3.1em; /* Constant space to prevent card jumping during typing */
  background: linear-gradient(135deg, #FF9933 0%, #FFFFFF 50%, #34C759 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: none;
}

.orient-warn {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: #060b13f9;
  color: #ffd27a;
  font-size: 1.25rem;
  padding: 2rem;
  text-align: center;
  backdrop-filter: blur(10px);
}

/* Keyframes for Dynamic Animations */
@keyframes pulseRing {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 153, 51, 0.7);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(255, 153, 51, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 153, 51, 0);
  }
}

@keyframes pulseButton {
  0% {
    box-shadow: 0 8px 30px rgba(230, 81, 0, 0.4);
  }
  50% {
    box-shadow: 0 8px 35px rgba(230, 81, 0, 0.75), 0 0 12px rgba(255, 111, 0, 0.5);
  }
  100% {
    box-shadow: 0 8px 30px rgba(230, 81, 0, 0.4);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .orient-warn {
    display: flex;
  }
}

@media (max-width: 600px) {
  .end-card {
    right: 5%;
    left: 5%;
    width: 90%;
    margin: 0 auto;
  }
}
