:root {
  --bg: #140f2e;
  --bg2: #1b1438;
  --card: #211a44;
  --ink: #f5f1ff;
  --muted: #b9b0d6;
  --gold: #ffc83d;
  --gold-deep: #e6a800;
  --accent: #ff5c8a;
  --ok: #34d399;
  --err: #ff6b6b;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a1f5c 0%, var(--bg) 55%) fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.card {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg2);
}

.hero {
  margin: 0;
  position: relative;
  line-height: 0;
}
.hero img {
  width: 100%;
  /* Cap the hero so the upload button stays above the fold on phones.
     The tall portrait is cropped to a band showing the title + faces. */
  height: 38vh;
  max-height: 340px;
  object-fit: cover;
  object-position: center 12%;
  display: block;
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 90px;
  background: linear-gradient(to bottom, rgba(27, 20, 56, 0), var(--bg2));
}

.content {
  padding: 16px 20px 8px;
  flex: 1;
}

h1 {
  font-size: 1.35rem;
  line-height: 1.2;
  margin: 0 0 6px;
  letter-spacing: 0.2px;
}
.lede {
  color: var(--muted);
  margin: 0 0 14px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.btn-primary {
  display: block;
  width: 100%;
  border: 0;
  cursor: pointer;
  padding: 18px 20px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #3a2a00;
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.05s ease, filter 0.15s ease;
}
.btn-primary:active { transform: translateY(1px) scale(0.997); }
.btn-primary:disabled { filter: grayscale(0.5) opacity(0.6); cursor: default; }

.btn-secondary {
  margin-top: 16px;
  background: transparent;
  color: var(--gold);
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  margin: 12px 0 0;
}

.overall {
  margin-top: 22px;
}
.overall-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.bar {
  height: 12px;
  background: #15102e;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.2s ease;
}

.list {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
}
.item .name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}
.item .state { font-size: 1.1rem; }
.item.ok .state { color: var(--ok); }
.item.err { outline: 1px solid var(--err); }
.item.err .state { color: var(--err); }
.item .mini {
  width: 70px;
  height: 6px;
  background: #15102e;
  border-radius: 999px;
  overflow: hidden;
}
.item .mini > div {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.15s ease;
}

.done {
  text-align: center;
  margin-top: 26px;
  padding: 24px 16px;
  background: var(--card);
  border-radius: var(--radius);
}
.done-emoji { font-size: 2.6rem; }
.done h2 { margin: 6px 0 4px; }
.done p { color: var(--muted); margin: 0; }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 20px 16px 28px;
  opacity: 0.8;
}

/* Gallery */
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px;
  position: sticky;
  top: 0;
  background: rgba(20, 15, 46, 0.9);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.gallery-head h1 { font-size: 1.2rem; margin: 0; }
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
}
@media (min-width: 600px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--card);
  overflow: hidden;
  border-radius: 8px;
}
.tile img,
.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tile .badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.75rem;
}
.tile .del {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 30, 40, 0.82);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.tile .del:hover { background: rgba(200, 30, 40, 1); }
.tile.ph {
  background: linear-gradient(135deg, #2a2150, #1b1438);
}
.tile.ph::after {
  content: "▶";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: rgba(255, 255, 255, 0.55);
}
.tile.ph.ph-img::after {
  content: "🖼";
  font-size: 1.6rem;
  opacity: 0.7;
}
.pw-gate {
  max-width: 380px;
  margin: 14vh auto 0;
  padding: 28px 22px;
  background: var(--card);
  border-radius: var(--radius);
  text-align: center;
}
.pw-gate input {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #3a2f63;
  background: #15102e;
  color: var(--ink);
  font-size: 1rem;
  margin: 14px 0;
}
.empty, .loading {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}
.msg-err { color: var(--err); font-size: 0.9rem; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 12px;
}
.lb-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 92dvh;
}
.lightbox img,
.lightbox video {
  max-width: 100%;
  max-height: 92dvh;
  border-radius: 10px;
}
.lb-progress {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.lb-pct {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}
.lb-track {
  width: 150px;
  height: 6px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  overflow: hidden;
}
.lb-bar {
  height: 100%;
  width: 0%;
  background: #fff;
  transition: width 0.12s linear;
}
.lb-vbadge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  color: #fff;
  font-size: 1.6rem;
  pointer-events: none;
}
.lb-note {
  color: rgba(255, 255, 255, 0.85);
  font-size: 1rem;
  padding: 40px;
  text-align: center;
}
.lightbox .close {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 2rem;
  color: #fff;
  background: none;
  border: 0;
  cursor: pointer;
}
