/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #0f1f3d;
  --navy-mid:   #1a3260;
  --blue:       #2563eb;
  --blue-light: #3b82f6;
  --blue-soft:  #dbeafe;
  --blue-xsoft: #eff6ff;
  --white:      #ffffff;
  --off-white:  #f8fafc;
  --border:     #e2e8f0;
  --text:       #0f172a;
  --text-muted: #64748b;
  --success:    #10b981;
  --error:      #ef4444;

  /* Responsive camera size */
  --cam-size: min(260px, 62vw);
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--off-white);
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ── Confetti canvas ── */
#confetti-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

/* ── Screens ── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}
.screen.active { display: flex; }

/* ── Brand header ── */
.brand-header {
  width: 100%;
  background: var(--navy);
  padding: clamp(14px, 3vw, 20px) clamp(16px, 4vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 16px rgba(0,0,0,0.25);
  flex-shrink: 0;
}
.brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 600;
  color: var(--white);
  letter-spacing: 0.3px;
}
.brand span { color: #60a5fa; }
.brand.small { font-size: clamp(18px, 4vw, 24px); }
.tagline {
  font-size: clamp(9px, 2vw, 12px);
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Hero strip ── */
.hero-strip {
  width: 100%;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  padding: clamp(28px, 6vw, 52px) clamp(16px, 5vw, 48px);
  text-align: center;
  position: relative; overflow: hidden;
  flex-shrink: 0;
}
.hero-strip::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}
.hero-tag {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: clamp(9px, 2vw, 11px); font-weight: 600;
  letter-spacing: 2px; text-transform: uppercase;
  color: #93c5fd; margin-bottom: 12px;
  position: relative; z-index: 1;
}
.hero-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #3b82f6;
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 0%,100%{opacity:1} 50%{opacity:0.4} }

.event-emoji {
  font-size: clamp(36px, 8vw, 52px);
  margin-bottom: 8px;
  position: relative; z-index: 1;
}
.event-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(24px, 6vw, 48px);
  font-weight: 600; color: var(--white);
  line-height: 1.1; position: relative; z-index: 1;
  margin-bottom: 6px;
}
.event-name em { font-style: italic; color: #60a5fa; }
.event-date {
  font-size: clamp(12px, 2.5vw, 14px);
  color: rgba(255,255,255,0.5);
  font-weight: 400; position: relative; z-index: 1;
  margin-bottom: 14px;
}
.pill-row {
  display: flex; justify-content: center;
  gap: 8px; flex-wrap: wrap;
  position: relative; z-index: 1;
}
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: clamp(10px, 2vw, 12px); font-weight: 700;
  padding: 5px 14px; border-radius: 20px;
}
.pill.blue {
  background: rgba(37,99,235,0.25); color: #93c5fd;
  border: 1px solid rgba(37,99,235,0.3);
}

/* ── Screen body ── */
.screen-body {
  width: 100%;
  max-width: min(480px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 32px) clamp(14px, 4vw, 24px) clamp(32px, 6vw, 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 3vw, 18px);
  flex: 1;
}

/* On large screens, center content nicely */
@media (min-width: 768px) {
  .screen-body {
    max-width: 520px;
    padding: 36px 32px 64px;
  }
}

@media (min-width: 1024px) {
  .screen-body {
    max-width: 560px;
    padding: 48px 40px 80px;
  }
  /* On desktop, hero strip is less tall */
  .hero-strip {
    padding: 48px 80px;
  }
}

/* ── Hint text ── */
.hint {
  font-size: clamp(13px, 3vw, 15px);
  color: var(--text-muted); font-weight: 500;
  text-align: center; max-width: 300px; line-height: 1.6;
}
.small-note {
  font-size: clamp(10px, 2vw, 12px);
  color: #cbd5e1; font-weight: 500; text-align: center;
}

/* ── Step indicator ── */
.step-row {
  display: flex; align-items: center;
  gap: 0; margin-bottom: 2px;
}
.step {
  width: clamp(26px, 6vw, 32px);
  height: clamp(26px, 6vw, 32px);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(11px, 2.5vw, 13px); font-weight: 700;
  background: var(--border); color: var(--text-muted);
  flex-shrink: 0; transition: all .3s;
}
.step.active { background: var(--blue); color: var(--white); box-shadow: 0 2px 10px rgba(37,99,235,.35); }
.step.done   { background: var(--success); color: var(--white); }
.step-line {
  width: clamp(28px, 8vw, 48px); height: 3px;
  background: var(--border); border-radius: 2px;
  flex-shrink: 0; transition: background .3s;
}
.step-line.done { background: var(--success); }
.step-label {
  font-size: clamp(11px, 2.5vw, 13px); font-weight: 600;
  color: var(--text-muted); margin-bottom: 2px; margin-top: 2px;
}

/* ── Camera ── */
.cam-wrapper {
  position: relative;
  width: var(--cam-size);
  height: var(--cam-size);
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto;
  box-shadow: 0 0 0 4px var(--white), 0 0 0 7px var(--blue),
              0 8px 32px rgba(37,99,235,0.2);
  background: var(--blue-xsoft);
  flex-shrink: 0;
}

/* Larger camera on tablets/desktop */
@media (min-width: 480px) {
  :root { --cam-size: 280px; }
}
@media (min-width: 768px) {
  :root { --cam-size: 300px; }
}
@media (min-width: 1024px) {
  :root { --cam-size: 320px; }
}

#video {
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
  display: none; transform: scaleX(-1);
}
.cam-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid rgba(37,99,235,0.25);
  pointer-events: none;
}
.scan-bar {
  position: absolute; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  top: 10%; animation: scan 2s ease-in-out infinite;
  opacity: 0; transition: opacity .4s;
}
.scan-bar.active { opacity: 1; }
@keyframes scan { 0%,100%{top:10%} 50%{top:84%} }

.cam-placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; cursor: pointer;
}
.cam-icon { font-size: clamp(40px, 10vw, 56px); }
.cam-text  { font-size: clamp(11px, 2.5vw, 13px); font-weight: 600; color: var(--text-muted); }

.cam-status {
  min-height: 20px;
  font-size: clamp(12px, 2.5vw, 14px);
  font-weight: 600; color: var(--blue);
  text-align: center; width: 100%;
}

/* ── Upload fallback ── */
.upload-fallback-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: clamp(12px, 2.5vw, 14px); color: var(--blue);
  font-weight: 600; cursor: pointer;
  padding: 10px 20px;
  border: 1.5px dashed var(--blue-light);
  border-radius: 10px;
  transition: all 0.2s; width: 100%;
  justify-content: center;
}
.upload-fallback-label:hover { background: var(--blue-xsoft); }

/* ── Buttons ── */
.btn-primary {
  display: inline-flex; align-items: center;
  justify-content: center; gap: 8px;
  background: var(--navy); color: var(--white);
  border: none; border-radius: 10px;
  padding: clamp(12px, 3vw, 15px) clamp(20px, 5vw, 32px);
  font-size: clamp(14px, 3vw, 16px); font-weight: 700;
  cursor: pointer; font-family: 'Plus Jakarta Sans', sans-serif;
  transition: background .2s, transform .15s;
  white-space: nowrap; width: 100%;
  letter-spacing: 0.2px;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover  { background: var(--navy-mid); transform: translateY(-1px); }
.btn-primary:active { transform: scale(.98); }
.btn-primary.blue   { background: var(--blue); }
.btn-primary.blue:hover { background: #1d4ed8; }
.btn-primary.sm { padding: 9px 20px; font-size: 13px; width: auto; }

.btn-secondary {
  display: inline-flex; align-items: center;
  justify-content: center; gap: 6px;
  background: var(--white); color: var(--navy);
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: clamp(10px, 2.5vw, 13px) clamp(16px, 4vw, 24px);
  font-size: clamp(13px, 2.5vw, 15px); font-weight: 600;
  cursor: pointer; font-family: 'Plus Jakarta Sans', sans-serif;
  transition: all .15s; width: 100%;
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:hover { background: var(--blue-xsoft); border-color: var(--blue-light); }
.btn-secondary.sm { width: auto; padding: 9px 18px; font-size: 13px; }

.btn-ghost {
  background: none; border: none; color: var(--text-muted);
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif; padding: 4px 8px;
  -webkit-tap-highlight-color: transparent;
}

.btn-row {
  display: flex; gap: 10px; align-items: center;
  flex-wrap: wrap; justify-content: center; width: 100%;
}

/* ── Results ── */
.results-hero { text-align: center; width: 100%; }
.found-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--blue-xsoft); border: 1px solid var(--blue-soft);
  color: var(--blue); font-size: clamp(13px, 3vw, 15px); font-weight: 700;
  padding: 7px 18px; border-radius: 20px; margin-bottom: 6px;
}
.found-badge-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.results-sub { font-size: clamp(11px, 2.5vw, 13px); color: var(--text-muted); font-weight: 500; }

/* Photo grid — 3 cols on small, 4 on tablet, 5 on desktop */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(6px, 2vw, 10px);
  width: 100%;
}
@media (min-width: 480px) {
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 768px) {
  .photo-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 1024px) {
  .photo-grid { grid-template-columns: repeat(6, 1fr); }
}

.photo-thumb {
  aspect-ratio: 1;
  border-radius: 10px; overflow: hidden;
  position: relative; cursor: pointer;
  border: 2.5px solid transparent;
  transition: border-color .2s, transform .15s;
  background: var(--off-white);
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  -webkit-tap-highlight-color: transparent;
}
.photo-thumb:active { transform: scale(.96); }
.photo-thumb.selected { border-color: var(--blue); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.select-mark {
  position: absolute; top: 4px; right: 4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--blue); border: 2px solid var(--white);
  display: none; align-items: center; justify-content: center;
  font-size: 9px; color: var(--white); font-weight: 900;
}
.photo-thumb.selected .select-mark { display: flex; }

/* ── Download bar ── */
.download-bar {
  width: 100%;
  background: var(--white); border-radius: 14px;
  border: 1px solid var(--border);
  padding: clamp(10px, 2.5vw, 14px) clamp(12px, 3vw, 18px);
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 4px 20px rgba(15,31,61,0.10);
  position: sticky; bottom: 12px;
}
.dl-info {
  font-size: clamp(12px, 2.5vw, 14px);
  color: var(--text-muted); font-weight: 600;
}
.dl-info span { color: var(--navy); font-weight: 700; }
.dl-btns { display: flex; gap: 8px; align-items: center; }

/* ── No match ── */
.nomatch-wrap {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: clamp(32px, 8vw, 64px) 24px;
  text-align: center; gap: 14px; flex: 1;
}
.nomatch-emoji { font-size: clamp(52px, 12vw, 72px); }
.nomatch-title { font-size: clamp(18px, 4vw, 22px); font-weight: 700; color: var(--navy); }
.nomatch-sub   {
  font-size: clamp(13px, 2.5vw, 15px); color: var(--text-muted);
  font-weight: 500; line-height: 1.6; max-width: 300px;
}

/* ── Match overlay ── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(255,255,255,0.97);
  display: flex; align-items: center; justify-content: center;
}
.overlay.hidden { display: none; }
.overlay-card {
  text-align: center; padding: 24px;
  animation: pop-in .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop-in { 0%{transform:scale(0);opacity:0} 100%{transform:scale(1);opacity:1} }
.overlay-emoji { font-size: clamp(56px, 14vw, 80px); }
.overlay-title { font-size: clamp(20px, 5vw, 26px); font-weight: 700; color: var(--navy); margin-top: 16px; }
.overlay-sub   { font-size: clamp(13px, 3vw, 15px); color: var(--text-muted); font-weight: 500; margin-top: 8px; }

/* ── Landscape phones fix ── */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-strip { padding: 16px 24px; }
  .event-emoji { font-size: 28px; margin-bottom: 4px; }
  .event-name { font-size: 22px; }
  :root { --cam-size: min(180px, 40vh); }
  .screen-body { padding: 12px 16px 24px; gap: 10px; }
}

/* ── Very small phones (iPhone SE, 320px) ── */
@media (max-width: 360px) {
  :root { --cam-size: 200px; }
  .btn-primary { font-size: 14px; padding: 12px 20px; }
  .screen-body { padding: 16px 12px 40px; gap: 12px; }
}

/* ── Large desktop ── */
@media (min-width: 1280px) {
  .brand-header { padding: 20px 60px; }
  .hero-strip { padding: 64px 120px; }
  .screen-body { max-width: 600px; }
}
