:root {
  --bg-primary: #060911;
  --cyan-neon: #00f0ff;
  --cyan-glow: rgba(0, 240, 255, 0.5);
  --pink-neon: #ff0055;
  --pink-glow: rgba(255, 0, 85, 0.5);
  --green-neon: #00ff66;
  --amber-neon: #ffb700;
  --border-neon: rgba(0, 240, 255, 0.35);
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --font-tech: 'Orbitron', monospace;
  --font-mono: 'Share Tech Mono', monospace;
  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  background: radial-gradient(circle at 50% 30%, rgba(0, 240, 255, 0.05) 0%, #060911 80%);
}

/* ============================================================
   1. 상단 HUD 헤더
============================================================ */
.hud-header {
  height: 50px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-neon);
  background: rgba(6, 9, 17, 0.85);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--cyan-neon);
  box-shadow: 0 0 10px var(--cyan-neon);
  animation: pulse-glow 1.5s infinite alternate;
}

@keyframes pulse-glow {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 8px var(--cyan-neon)); }
}

.brand-title {
  font-family: var(--font-tech);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #fff;
  text-shadow: 0 0 12px var(--cyan-glow);
}

.brand-ver {
  font-size: 10px;
  font-weight: 600;
  color: var(--cyan-neon);
  background: rgba(0, 240, 255, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(0, 240, 255, 0.4);
}

.hud-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cyan-neon);
}

.status-badge {
  padding: 2px 8px;
  background: rgba(0, 255, 102, 0.12);
  border: 1px solid var(--green-neon);
  color: var(--green-neon);
  border-radius: 4px;
  font-size: 10px;
  letter-spacing: 1px;
}

/* ============================================================
   2. 메인 뷰파인더 & HUD 오버레이
============================================================ */
.viewport-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

#hud-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* 코너 브래킷 */
.hud-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--cyan-neon);
  pointer-events: none;
  z-index: 10;
  opacity: 0.85;
}

.top-left { top: 12px; left: 12px; border-right: none; border-bottom: none; }
.top-right { top: 12px; right: 12px; border-left: none; border-bottom: none; }
.bottom-left { bottom: 12px; left: 12px; border-right: none; border-top: none; }
.bottom-right { bottom: 12px; right: 12px; border-left: none; border-top: none; }

/* 양옆 텔레메트리 */
.side-telemetry {
  position: absolute;
  top: 16px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: 10px;
  z-index: 10;
  pointer-events: none;
  background: rgba(6, 9, 17, 0.65);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(0, 240, 255, 0.15);
  backdrop-filter: blur(4px);
}

.side-telemetry.left { left: 14px; }
.side-telemetry.right { right: 14px; text-align: right; }

.telemetry-label {
  font-size: 9px;
  letter-spacing: 1px;
  color: rgba(0, 240, 255, 0.8);
}
.telemetry-label.mt { margin-top: 6px; }

.telemetry-val {
  font-family: var(--font-tech);
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.telemetry-val.green { color: var(--green-neon); }

.telemetry-code {
  font-size: 8px;
  color: rgba(255,255,255,0.3);
  margin-top: 2px;
}

/* 타겟 안내 가이드 */
.target-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.reticle-circle {
  width: 200px;
  height: 250px;
  border: 1.5px dashed rgba(0, 240, 255, 0.45);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  box-shadow: inset 0 0 30px rgba(0, 240, 255, 0.12);
}

.guide-text {
  margin-top: 14px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(6, 9, 17, 0.85);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(0, 240, 255, 0.35);
  letter-spacing: 0.3px;
}

/* ============================================================
   3. 스캔 진행 중 오버레이
============================================================ */
.scanning-modal {
  position: absolute;
  inset: 0;
  background: rgba(6, 9, 17, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 30;
}

.scan-laser {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--cyan-neon);
  box-shadow: 0 0 18px var(--cyan-neon), 0 0 35px var(--cyan-neon);
  animation: laser-sweep 1.2s infinite ease-in-out alternate;
}

@keyframes laser-sweep {
  0% { top: 15%; opacity: 0.3; }
  50% { opacity: 1; }
  100% { top: 85%; opacity: 0.3; }
}

.scan-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  padding: 24px;
}

.scan-spinner {
  width: 64px;
  height: 64px;
  border: 3.5px solid rgba(0, 240, 255, 0.15);
  border-top-color: var(--cyan-neon);
  border-right-color: var(--pink-neon);
  border-radius: 50%;
  animation: spin-scan 0.8s infinite linear;
}

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

.scan-title {
  font-family: var(--font-tech);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--cyan-neon);
  text-shadow: 0 0 10px var(--cyan-glow);
}

.scan-status-msg {
  font-size: 13px;
  color: #e6edf3;
  min-height: 20px;
}

.scan-progress-bar {
  width: 220px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(0, 240, 255, 0.3);
}

.scan-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan-neon), var(--pink-neon));
  transition: width 0.1s linear;
}

.scan-pct {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--cyan-neon);
}

/* ============================================================
   4. 하단 컨트롤 바
============================================================ */
.hud-controls {
  padding: 12px 16px;
  background: rgba(6, 9, 17, 0.95);
  border-top: 1px solid var(--border-neon);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hud-btn {
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hud-btn:active {
  transform: scale(0.95);
}

.secondary-btn {
  width: 76px;
  height: 56px;
  background: rgba(13, 19, 33, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--cyan-neon);
  gap: 3px;
}

.secondary-btn span {
  font-size: 10px;
  color: var(--text-muted);
}

.upload-label {
  display: flex;
  cursor: pointer;
}

.main-scan-btn {
  flex: 1;
  height: 56px;
  background: linear-gradient(135deg, #00d2ff 0%, #0066ff 100%);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 22px rgba(0, 210, 255, 0.55);
  flex-direction: row;
  gap: 8px;
}

.main-scan-btn .btn-glow {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: shine 2.5s infinite;
}

@keyframes shine {
  0% { left: -100%; }
  50%, 100% { left: 100%; }
}

.main-scan-btn .btn-icon {
  font-size: 20px;
}

.main-scan-btn .btn-text {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.sound-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: center;
}

.sound-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.sound-label input { display: none; }

.toggle-switch {
  width: 30px;
  height: 16px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  position: relative;
  transition: background 0.2s;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.sound-label input:checked + .toggle-switch {
  background: var(--cyan-neon);
}
.sound-label input:checked + .toggle-switch::after {
  transform: translateX(14px);
}

.sound-text {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ============================================================
   🔥 5. 새로운 풀스크린 인스타 스토리 / AR 포토카드 모달
============================================================ */
.photocard-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
  animation: modal-fade-in 0.35s ease-out;
}

@keyframes modal-fade-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.photocard-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* 사진이 꽉 차는 메인 래퍼 */
.photocard-image-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#result-face-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* 상하단 어두운 그라데이션 비네팅 (텍스트 가독성 극대화) */
.photocard-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(6, 9, 17, 0.75) 0%,
    rgba(6, 9, 17, 0) 22%,
    rgba(6, 9, 17, 0) 55%,
    rgba(6, 9, 17, 0.92) 88%,
    rgba(6, 9, 17, 1) 100%
  );
  pointer-events: none;
}

/* 사진 중앙 얼굴 락온 타겟 박스 (SF 감성) */
.face-target-box {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 270px;
  pointer-events: none;
  border: 1px dashed rgba(0, 240, 255, 0.4);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}

.ft-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid var(--cyan-neon);
  filter: drop-shadow(0 0 6px var(--cyan-neon));
}
.ft-tl { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.ft-tr { top: -2px; right: -2px; border-left: none; border-bottom: none; }
.ft-bl { bottom: -2px; left: -2px; border-right: none; border-top: none; }
.ft-br { bottom: -2px; right: -2px; border-left: none; border-top: none; }

.ft-center-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  background: var(--pink-neon);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--pink-neon);
}

.ft-tag {
  position: absolute;
  top: -12px;
  left: 10px;
  background: var(--cyan-neon);
  color: #000;
  font-family: var(--font-tech);
  font-size: 10px;
  font-weight: 900;
  padding: 1px 6px;
  letter-spacing: 1px;
}

/* 상단 헤더 HUD 바 */
.photo-top-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.photo-badge {
  font-family: var(--font-tech);
  font-size: 13px;
  font-weight: 800;
  padding: 5px 12px;
  background: rgba(0, 240, 255, 0.2);
  color: #fff;
  border: 1.5px solid var(--cyan-neon);
  border-radius: 20px;
  backdrop-filter: blur(8px);
  text-shadow: 0 0 8px var(--cyan-glow);
}

.photo-badge.red {
  background: rgba(255, 0, 85, 0.25);
  border-color: var(--pink-neon);
  color: #ff99bb;
  font-family: var(--font-sans);
  font-size: 12px;
  text-shadow: 0 0 8px var(--pink-glow);
}

.photo-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

/* 하단 팩폭 텍스트 오버레이 */
.photo-bottom-hud {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
  z-index: 10;
}

.photo-fortune-title {
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8), 0 0 15px rgba(255, 183, 0, 0.6);
}

.photo-punchline {
  font-size: 15px;
  font-weight: 700;
  color: #ffea79;
  line-height: 1.4;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  padding: 0 10px;
}

.photo-stats-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cyan-neon);
}

.stat-sep {
  color: rgba(255, 255, 255, 0.4);
}

/* 하단 액션 버튼 바 */
.photocard-actions {
  padding: 12px 16px 20px;
  background: #060911;
  border-top: 1px solid rgba(0, 240, 255, 0.25);
  display: flex;
  gap: 10px;
  z-index: 20;
}

.action-btn {
  flex: 1;
  height: 52px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  transition: all 0.2s;
}

.action-btn:active {
  transform: scale(0.96);
}

.save-card-btn {
  flex: 1.3;
  background: linear-gradient(135deg, #00f0ff 0%, #0077ff 100%);
  color: #000;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.45);
}

.rescan-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.hidden {
  display: none !important;
}
