:root {
  --primary-color: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.5);
  --accent-color: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.5);
  --bg-dark: #0f172a;
  --panel-bg: rgba(15, 23, 42, 0.78);
  --panel-border: rgba(56, 189, 248, 0.3);
  --text-main: #ffffff;
  --text-muted: #94a3b8;
  --success-color: #10b981;
  --success-glow: rgba(16, 185, 129, 0.5);
  --danger-color: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  background-color: #000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Vazirmatn", Tahoma, sans-serif;
  color: var(--text-main);
  direction: rtl;
}

#ar-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  overflow: hidden;
}

#ar-container video {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

#ar-container canvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 2;
}

/* UI Overlay Layer */
.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Top Section (Header + Status + Zoom) */
.top-section {
  width: 100%;
  pointer-events: none;
  z-index: 20;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.9) 0%, rgba(15, 23, 42, 0.4) 75%, transparent 100%);
  padding-bottom: 12px;
}

/* Header Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  pointer-events: auto;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 8px 18px;
  border-radius: 30px;
  border: 1px solid var(--panel-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 12px rgba(56, 189, 248, 0.15);
}

.brand-logo-icon {
  width: 20px;
  height: 20px;
  fill: var(--primary-color);
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.brand-title {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
}

.direct-play-btn {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.direct-play-btn:hover, .direct-play-btn:active {
  background: rgba(56, 189, 248, 0.25);
  border-color: var(--primary-color);
  box-shadow: 0 0 15px var(--primary-glow);
  transform: scale(0.97);
}

/* Status Pill (Glassmorphic HUD) */
.status-pill-container {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 0 20px;
  margin-top: 2px;
}

.status-pill {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  padding: 8px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45), 0 0 12px rgba(56, 189, 248, 0.12);
  transition: all 0.3s ease;
  pointer-events: auto;
}

.status-indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-color);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse-dot 1.4s infinite;
}

.status-pill.tracking .status-indicator-dot {
  background: var(--success-color);
  box-shadow: 0 0 12px var(--success-glow);
  animation: none;
}

.status-pill.tracking {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.18);
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4), 0 0 18px rgba(16, 185, 129, 0.3);
}

@keyframes pulse-dot {
  0% { transform: scale(0.85); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.85); opacity: 0.6; }
}

/* Zoom & Controls Bar */
.controls-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
  pointer-events: auto;
}

.zoom-btn {
  background: rgba(30, 41, 59, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 6px 16px;
  border-radius: 25px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35), 0 0 10px rgba(56, 189, 248, 0.15);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.zoom-btn:hover, .zoom-btn:active {
  transform: scale(0.96);
  border-color: var(--primary-color);
  background: rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 15px var(--primary-glow);
}

.zoom-icon {
  font-size: 14px;
}

/* Cyberpunk Target Reticle */
.reticle-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(88vw, 350px);
  height: 155px; /* Proportionally matched to HOUBER PACK card section */
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.reticle-container.hidden {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.9);
  pointer-events: none;
}

.reticle-frame {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1.5px dashed rgba(56, 189, 248, 0.35);
  border-radius: 18px;
  box-shadow: 0 0 35px rgba(0, 0, 0, 0.6), inset 0 0 25px rgba(56, 189, 248, 0.12);
  overflow: hidden;
  background: rgba(56, 189, 248, 0.03);
}

/* 4 Glowing Neon Corner Brackets */
.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--primary-color);
  border-style: solid;
  filter: drop-shadow(0 0 8px var(--primary-color));
  animation: corner-glow-pulse 2.5s ease-in-out infinite alternate;
}

.corner-tl { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-top-left-radius: 16px; }
.corner-tr { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-top-right-radius: 16px; }
.corner-bl { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-bottom-left-radius: 16px; }
.corner-br { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-bottom-right-radius: 16px; }

@keyframes corner-glow-pulse {
  0% { filter: drop-shadow(0 0 4px var(--primary-color)); opacity: 0.85; }
  100% { filter: drop-shadow(0 0 12px var(--primary-color)); opacity: 1; }
}

/* Moving Laser Scanning Beam */
.laser-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2.5px;
  background: linear-gradient(90deg, transparent 5%, var(--primary-color) 25%, #ffffff 50%, var(--primary-color) 75%, transparent 95%);
  box-shadow: 0 0 14px var(--primary-color), 0 0 25px var(--primary-glow);
  animation: scan-vertical 2.2s ease-in-out infinite alternate;
}

@keyframes scan-vertical {
  0% { top: 6%; opacity: 0.9; }
  100% { top: 94%; opacity: 0.9; }
}

/* Reticle Tip Card */
.reticle-tip {
  position: absolute;
  bottom: -48px;
  left: 0;
  width: 100%;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tip-badge {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 6px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.target-thumbnail {
  width: 32px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  object-fit: cover;
}

/* Floating Tap Hint (When targetFound) */
.tap-hint-container {
  position: absolute;
  bottom: 95px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 15;
}

.tap-hint-container.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(-10px);
}

.tap-hint-pill {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.95), rgba(14, 165, 233, 0.95));
  color: #0f172a;
  padding: 13px 26px;
  border-radius: 40px;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 6px 30px rgba(56, 189, 248, 0.6), 0 0 20px rgba(255, 255, 255, 0.3);
  cursor: pointer;
  animation: bounce-hint 1.8s infinite;
  border: 2px solid #ffffff;
}

@keyframes bounce-hint {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Bottom Hint / Info Bar (Frosted Capsule) */
.bottom-bar {
  padding: 16px 20px 24px;
  display: flex;
  justify-content: center;
  background: transparent;
  pointer-events: auto;
}

.instruction-capsule {
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 30px;
  padding: 9px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.45);
}

.instruction-icon {
  font-size: 14px;
  color: var(--primary-color);
  filter: drop-shadow(0 0 6px var(--primary-glow));
}

.instruction-text {
  font-size: 12.5px;
  color: #e2e8f0;
  font-weight: 500;
  text-align: center;
}

/* Modal Overlays (Loading, Error, Compatibility, Redirecting) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 32px 28px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(56, 189, 248, 0.15);
}

.modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-color);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.modal-icon.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.modal-icon.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.modal-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #fff;
}

.modal-desc {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary {
  background: var(--primary-color);
  color: #0f172a;
  border: none;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.4);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--panel-border);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.15);
}

/* Spinner */
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
  box-shadow: 0 0 15px var(--primary-glow);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Progress Bar */
.progress-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin: 16px 0 10px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary-color);
  box-shadow: 0 0 10px var(--primary-glow);
  transition: width 0.3s ease;
}

/* Debug Overlay */
#debug-overlay {
  position: absolute;
  bottom: 10px;
  left: 10px;
  direction: ltr;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 11px;
  color: #38bdf8;
  z-index: 50;
  pointer-events: none;
  display: none;
}
