:root {
  --bg: #0e0d12;
  --surface: #17151c;
  --surface-2: #221f29;
  --border: #2c2933;
  --text: #efeaf4;
  --sub: #9692a3;
  --accent: #7c3aed;
  --accent-2: #a78bfa;
  --danger: #f87171;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--text); }

.header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(14, 13, 18, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center; gap: 16px;
}
.header h1 {
  margin: 0; font-size: 16px; font-weight: 600;
  letter-spacing: -0.01em;
}
.header .crumb {
  color: var(--sub); font-size: 13px;
}
.header .crumb a:after { content: ' / '; color: var(--sub); margin: 0 4px; }
.header-spacer { flex: 1; }
.header .count {
  color: var(--sub); font-size: 12px;
  background: var(--surface-2);
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border);
}

.container { padding: 24px; max-width: 1600px; margin: 0 auto; }

.empty {
  text-align: center; padding: 80px 24px;
  color: var(--sub);
}
.empty h2 { color: var(--text); margin: 0 0 8px; font-weight: 500; }
.spinner {
  display: inline-block; width: 22px; height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Event grid (homepage) ───────────────────────────── */
.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: transform 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  display: block; color: inherit;
}
.event-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.event-card .name {
  font-size: 17px; font-weight: 600; margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.event-card .meta {
  color: var(--sub); font-size: 13px;
  display: flex; gap: 12px; align-items: center;
}
.event-card .pill {
  background: var(--accent); color: white;
  padding: 2px 9px; border-radius: 999px; font-size: 11px;
  font-weight: 600; letter-spacing: 0.02em;
}

/* ── Photo grid ──────────────────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.photo {
  position: relative;
  aspect-ratio: 3/2;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface);
  cursor: zoom-in;
  border: 1px solid transparent;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.photo:hover { border-color: var(--accent); }
.photo img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
  transition: opacity 0.4s ease;
  opacity: 0;
}
.photo img.loaded { opacity: 1; }

/* ── Lightbox ────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.93);
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 24px;
  user-select: none;
}
.lightbox.on { display: flex; }
.lightbox img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 80px rgba(0,0,0,0.6);
}
.lightbox .lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(255,255,255,0.08);
  color: white;
  border: none;
  width: 52px; height: 52px;
  border-radius: 50%;
  font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease;
}
.lightbox .lb-nav:hover { background: rgba(255,255,255,0.18); }
.lightbox .lb-prev { left: 18px; }
.lightbox .lb-next { right: 18px; }
.lightbox .lb-close {
  position: absolute; top: 18px; right: 18px;
  background: rgba(255,255,255,0.08);
  color: white; border: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 20px; cursor: pointer;
}
.lightbox .lb-counter {
  position: absolute; top: 22px; left: 24px;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
}
.lightbox .lb-download {
  position: absolute; bottom: 22px; right: 24px;
  background: var(--accent); color: white;
  text-decoration: none;
  padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  transition: background 0.15s ease;
}
.lightbox .lb-download:hover { background: var(--accent-2); color: white; }

.btn {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 8px;
  font-size: 13px; cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: white;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }

/* ── Gate / login screen ─────────────────────────────── */
.gate {
  max-width: 420px;
  margin: 80px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  text-align: center;
}
.gate h2 {
  margin: 0 0 8px; font-size: 22px; font-weight: 600;
  letter-spacing: -0.01em;
}
.gate p {
  color: var(--sub); font-size: 14px; line-height: 1.55;
  margin: 0 0 24px;
}
.gate input {
  width: 100%;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 16px;
  font-family: ui-monospace, Menlo, monospace;
  text-align: center;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}
.gate input:focus {
  outline: none;
  border-color: var(--accent);
}
.gate button {
  width: 100%;
  background: var(--accent); color: white;
  border: none;
  padding: 14px;
  border-radius: 10px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.gate button:hover { background: var(--accent-2); }
.gate .err {
  color: var(--danger); font-size: 13px;
  margin: -4px 0 14px; min-height: 18px;
}
.gate .small {
  color: var(--sub); font-size: 11px;
  margin-top: 18px;
}
.gate .small a { color: var(--accent-2); }
.welcome {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px 6px 16px;
  font-size: 13px;
  color: var(--text);
}
.welcome .who { font-weight: 600; }
.welcome .x {
  background: transparent; border: none; color: var(--sub);
  cursor: pointer; font-size: 14px; padding: 2px 6px;
}
.welcome .x:hover { color: var(--text); }

/* ── Selfie matcher ──────────────────────────────────── */
.gate .or {
  display: flex; align-items: center; gap: 12px;
  color: var(--sub); font-size: 11px;
  margin: 18px 0 14px;
  text-transform: uppercase; letter-spacing: 0.12em;
}
.gate .or::before, .gate .or::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.gate .selfie-btn {
  width: 100%;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: 10px;
  font-size: 15px; font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: border-color 0.15s ease;
}
.gate .selfie-btn:hover { border-color: var(--accent); }

.selfie-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}
.selfie-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 28px 24px;
  width: 100%; max-width: 440px;
  text-align: center;
}
.selfie-card h3 {
  margin: 0 0 6px; font-size: 18px; font-weight: 600;
  letter-spacing: -0.01em;
}
.selfie-card p {
  color: var(--sub); font-size: 13px; line-height: 1.5;
  margin: 0 0 20px;
}
.selfie-preview {
  width: 220px; height: 220px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--border);
  overflow: hidden;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.selfie-preview img, .selfie-preview video, .selfie-preview canvas {
  width: 100%; height: 100%; object-fit: cover;
}
.selfie-preview .placeholder {
  color: var(--sub); font-size: 48px;
}
.selfie-stage {
  color: var(--sub); font-size: 12px;
  margin-bottom: 12px; min-height: 18px;
  font-family: ui-monospace, Menlo, monospace;
}
.selfie-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 12px;
}
.selfie-actions .btn { flex: 1; min-width: 120px; }
.selfie-card .err {
  color: var(--danger); font-size: 13px;
  min-height: 18px; margin: 4px 0 8px;
}

/* ── Download-all overlay ────────────────────────────── */
.dl-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.dl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 32px 24px;
  width: 100%; max-width: 380px;
  text-align: center;
}
.dl-card h3 {
  margin: 0 0 18px; font-size: 16px; font-weight: 600;
}
.dl-bar {
  height: 8px; width: 100%;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}
.dl-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
  border-radius: 999px;
}
.dl-stat {
  color: var(--sub); font-size: 12px;
  margin-bottom: 18px; font-family: ui-monospace, Menlo, monospace;
}

@media (max-width: 640px) {
  .header { padding: 12px 14px; flex-wrap: wrap; }
  .header .welcome { font-size: 12px; padding: 5px 12px 5px 14px; }
  .container { padding: 14px; }
  .photo-grid { gap: 4px; }
  .event-grid { grid-template-columns: 1fr; gap: 12px; }
}
