@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,wght@0,400;0,500;0,600;1,400;1,500&family=Work+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* Neutrals — warm paper-to-ink ramp */
  --neutral-0: #FFFFFF;
  --neutral-50: #FBFAF7;
  --neutral-100: #F7F5F0;
  --neutral-200: #EDE8DF;
  --neutral-300: #DDD5C7;
  --neutral-400: #B8AC99;
  --neutral-500: #8C8171;
  --neutral-600: #675D4F;
  --neutral-700: #453D33;
  --neutral-800: #2E2822;
  --neutral-900: #221E1A;

  /* Primary — deep emerald */
  --emerald-50: #EAF2EE;
  --emerald-100: #CFE3DA;
  --emerald-500: #1F4D3E;
  --emerald-600: #193F32;
  --emerald-700: #153328;
  --emerald-900: #0B1A14;

  /* Accent — warm gold */
  --gold-50: #FBF4E3;
  --gold-200: #E8CC8A;
  --gold-500: #C9A24B;
  --gold-600: #A8843A;

  --feedback-danger: #B3261E;
  --feedback-danger-bg: #FBEAE9;

  /* Semantic surfaces */
  --surface-page: var(--neutral-100);
  --surface-card: var(--neutral-50);
  --surface-elevated: var(--neutral-0);
  --surface-inverse: var(--emerald-900);
  --surface-sunken: var(--neutral-200);

  /* Semantic text */
  --text-primary: var(--neutral-900);
  --text-secondary: var(--neutral-600);
  --text-tertiary: var(--neutral-500);
  --text-inverse: var(--neutral-50);

  /* Semantic borders */
  --border-subtle: var(--neutral-300);
  --border-strong: var(--neutral-400);

  /* Semantic accents */
  --accent-primary: var(--emerald-500);
  --accent-primary-hover: var(--emerald-600);
  --accent-primary-active: var(--emerald-700);
  --accent-gold: var(--gold-500);
  --accent-gold-hover: var(--gold-600);

  --font-display: 'Newsreader', ui-serif, Georgia, serif;
  --font-sans: 'Work Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;

  --leading-tight: 1.1;
  --leading-snug: 1.3;
  --leading-normal: 1.5;
  --leading-relaxed: 1.7;

  --tracking-tight: -0.02em;
  --tracking-normal: 0em;
  --tracking-wide: 0.04em;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px;

  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-xl: 24px; --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(34,30,26,0.06);
  --shadow-md: 0 4px 12px rgba(34,30,26,0.08);
  --shadow-lg: 0 16px 40px rgba(34,30,26,0.14);

  --ease-out: cubic-bezier(0,0,0.2,1);
  --duration-fast: 120ms;
  --duration-base: 200ms;
  --duration-slow: 360ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
}

.wrap {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 20px 40px;
  display: flex;
  flex-direction: column;
}

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 0 20px;
}

.logo {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 24px;
  color: var(--text-primary);
}

.event-name {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.card {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.challenge-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.challenge-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--gold-50);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.challenge-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-primary);
  margin-bottom: 4px;
}

.challenge-text {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"] {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  font-family: var(--font-sans);
  font-size: 15px;
  margin-bottom: 16px;
  background: var(--surface-elevated);
  color: var(--text-primary);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out), opacity var(--duration-fast) var(--ease-out);
}

.btn-primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--text-inverse);
}
.btn-primary:hover { background: var(--accent-primary-hover); }

.btn-primary:disabled {
  opacity: 0.5;
}

.btn-gold {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--neutral-900);
}
.btn-gold:hover { background: var(--accent-gold-hover); }

.btn-secondary {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--accent-primary);
  border: 1px solid var(--border-subtle);
}

.hint {
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: 14px;
  line-height: 1.5;
}

.status {
  text-align: center;
  padding: 40px 20px;
}

.status .emoji { font-size: 40px; margin-bottom: 12px; }
.status h2 { font-family: var(--font-display); font-weight: 500; margin: 0 0 8px; font-size: 22px; }
.status p { color: var(--text-secondary); margin: 0 0 20px; font-size: 14px; }

.footer-note {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Gallery page */
.gallery-meta {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.section-label {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.leaderboard-card {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  padding: 6px;
  margin-bottom: 20px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px;
  border-radius: var(--radius-md);
}
.lb-row.you { background: var(--emerald-50); }

.lb-rank {
  width: 24px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 13px;
  color: var(--text-tertiary);
}
.lb-rank.gold { color: var(--accent-gold); }
.lb-rank.silver { color: var(--neutral-400); }
.lb-rank.bronze { color: #B8794F; }

.lb-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-sunken);
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-count {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.gallery-grid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--surface-sunken);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
  font-size: 14px;
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-primary);
  margin-right: 6px;
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.35; }
  100% { opacity: 1; }
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.tabs a {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-tertiary);
  border: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
}

.tabs a.active {
  background: var(--accent-primary);
  color: var(--text-inverse);
  border-color: var(--accent-primary);
}

/* Grand reveal reel player */
.reel-overlay {
  position: fixed;
  inset: 0;
  background: var(--neutral-900);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.reel-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.reel-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--neutral-50);
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
}
.reel-close:hover { background: rgba(255, 255, 255, 0.22); }

.reel-title-card,
.reel-outro-card {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.reel-title-card.visible,
.reel-outro-card.visible {
  display: flex;
  opacity: 1;
}

.reel-title-text {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(28px, 6vw, 48px);
  color: var(--neutral-50);
  max-width: 800px;
}

.reel-outro-logo {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 40px;
  color: var(--gold-500);
  margin-bottom: 10px;
}
.reel-outro-sub {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--neutral-400);
}

.reel-stage {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.reel-stage.visible { opacity: 1; }

.reel-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.reel-img.front { opacity: 1; }
.reel-img.kenburns.front {
  animation: reel-kenburns 4.5s ease-out forwards;
}

@keyframes reel-kenburns {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.08) translate(-1%, -1%); }
}

.reel-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 40px;
  text-align: center;
  padding: 0 24px;
  font-family: var(--font-sans);
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 500;
  color: var(--neutral-50);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reel-caption.show {
  opacity: 1;
  transform: translateY(0);
}
