* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  /* Use 100dvh on browsers that support it so 100vh doesn't sit under the
     mobile address bar / bottom system gesture area. */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  overflow-x: hidden;        /* belt-and-braces against transform overflow */
}

.container {
  width: 100%;
  max-width: 560px;
  /* margin: auto centers when content is short, falls back to top-aligned
     when content is taller than the viewport — so the heading is never
     pushed above the fold on small screens. */
  margin: auto;
}

.card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  padding: 36px 32px;
  animation: fadeInUp 0.5s ease;
  /* Words inside admin-supplied instructions (URLs, app names) shouldn't
     blow out the card width on narrow phones. */
  overflow-wrap: break-word;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

h1 {
  text-align: center;
  color: #1a1a2e;
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.3;
}

/* Bold callouts above the instruction panel and the upload area.
   Same body-text size; weight + soft tint do the work. */
.callout {
  font-size: 0.95rem;
  line-height: 1.45;
  color: #1a1a2e;
  background: #fff8e1;
  border-left: 3px solid #f59e0b;
  padding: 10px 14px;
  border-radius: 4px;
  margin: 0 0 14px;
}
.callout strong { font-weight: 700; }
.upload-section .callout { margin: 8px 0 10px; }

/* Instructions — collapsible "How to earn" panel.
   Closed by default on mobile; JS opens it on ≥601px in app.js. */
.instructions-details {
  background: linear-gradient(180deg, #f8f9ff 0%, #f1f3fb 100%);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid #e7eaf5;
}
.instructions-details > summary {
  list-style: none;            /* hide default ▶ marker */
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  color: #1a1a2e;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.instructions-details > summary::-webkit-details-marker { display: none; }
.instructions-details > summary::marker { content: ''; }
.instructions-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #4f46e5;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.instructions-label { flex: 1; }
.instructions-chevron {
  font-size: 14px;
  color: #6b7280;
  transition: transform 0.2s ease;
}
.instructions-details[open] .instructions-chevron { transform: rotate(180deg); }
.instructions-details[open] > summary { border-bottom: 1px solid #e7eaf5; }

.instructions-section {
  background: transparent;
  padding: 16px 20px 18px;
}
.instructions-section ol {
  padding-left: 20px;
  color: #333;
  line-height: 1.75;
  font-size: 0.94rem;
}
.instructions-section li { margin-bottom: 4px; }

/* Step row — clean numbered label above each CTA */
.step-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 2px;
}
.upload-section .step-row { margin-bottom: 10px; }
.step-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #4f46e5;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}
.step-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a1a2e;
  line-height: 1.3;
}
/* Make Step 2 stand out so users notice they still have to upload. */
.upload-section .step-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.note-box {
  background: #fff5f5;
  border: 2px solid #dc3545;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 16px;
  color: #dc3545;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Buttons */
.actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  /* Guarantee a 48px touch target on mobile (Apple HIG / Material). */
  min-height: 48px;
  /* Stop iOS Safari from adding its default highlight rect on tap. */
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-success {
  background: linear-gradient(135deg, #34d058 0%, #22863a 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(34, 134, 58, 0.28);
}

.btn-success:not(:disabled):hover,
.btn-success:not(:disabled):active {
  background: linear-gradient(135deg, #2db84a 0%, #1f7a33 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(34, 134, 58, 0.38);
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-primary:not(:disabled):hover,
.btn-primary:not(:disabled):active {
  background: linear-gradient(135deg, #4338ca 0%, #3730a3 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.4);
}

.btn-icon {
  font-size: 1.1rem;
}

/* Status messages */
.status-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #d4edda;
  color: #155724;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.check {
  font-size: 1.2rem;
  font-weight: 700;
}

/* Upload */
.upload-section {
  position: relative;
}

.upload-nudge {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fdecea;
  border: 1px solid #f5c2c0;
  color: #b71c1c;
  padding: 12px 14px;
  margin: 0 0 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  animation: nudgeIn 0.25s ease;
}
.upload-nudge[hidden] { display: none; }
.upload-nudge .nudge-icon { font-size: 18px; line-height: 1; }

@keyframes nudgeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Pulse the CTA button when the user taps the disabled upload area. */
@keyframes ctaPulse {
  0%   { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.55); transform: scale(1); }
  50%  { box-shadow: 0 0 0 14px rgba(40, 167, 69, 0); transform: scale(1.03); }
  100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); transform: scale(1); }
}
.btn-success.pulse {
  animation: ctaPulse 0.9s ease-out 2;
}

.upload-label {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 18px 18px;
  border: 2px dashed #90caf9;
  border-radius: 14px;
  background: linear-gradient(180deg, #f5faff 0%, #eaf3ff 100%);
  cursor: pointer;
  color: #1976d2;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-height: 0;
}

.upload-label:hover,
.upload-label:active {
  border-color: #1976d2;
  background: linear-gradient(180deg, #e8f3ff 0%, #d8e9ff 100%);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(25, 118, 210, 0.18);
}

.upload-label input[type="file"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
}

/* Locked / "waiting for step 1" state — premium, not broken-looking */
.upload-label.is-disabled,
.upload-label:has(input[type="file"]:disabled) {
  border-color: #c5d4e6;
  background: repeating-linear-gradient(
    45deg,
    #f3f6fb 0px, #f3f6fb 12px,
    #eaf0f8 12px, #eaf0f8 24px
  );
  color: #6b7a8f;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.upload-label.is-disabled:hover,
.upload-label:has(input[type="file"]:disabled):hover {
  transform: none;
  box-shadow: none;
}

.upload-illustration {
  width: 52px;
  height: 78px;
  color: #1976d2;
  margin-bottom: 2px;
  filter: drop-shadow(0 4px 10px rgba(25, 118, 210, 0.15));
}

.upload-label.is-disabled .upload-illustration,
.upload-label:has(input[type="file"]:disabled) .upload-illustration {
  color: #94a3b8;
  filter: none;
  opacity: 0.7;
}

.upload-headline {
  font-size: 1.05rem;
  font-weight: 600;
  color: #102a43;
}

/* Locked-state hint shown alongside the headline + button. */
.upload-locked-text {
  display: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: #b91c1c;
  align-items: center;
  gap: 6px;
}
.upload-locked-text .lock-icon { font-size: 1rem; }
.upload-label.is-disabled .upload-headline,
.upload-label:has(input[type="file"]:disabled) .upload-headline { color: #6b7a8f; }
.upload-label.is-disabled .upload-locked-text,
.upload-label:has(input[type="file"]:disabled) .upload-locked-text { display: inline-flex; }

.upload-button {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
  color: #fff;
  padding: 12px 26px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(21, 101, 192, 0.32);
  min-height: 44px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.upload-label:hover .upload-button {
  background: linear-gradient(135deg, #1976d2 0%, #0d47a1 100%);
  box-shadow: 0 6px 16px rgba(13, 71, 161, 0.38);
}

.upload-label.is-disabled .upload-button,
.upload-label:has(input[type="file"]:disabled) .upload-button {
  background: linear-gradient(135deg, #b6c2d3 0%, #97a4b8 100%);
  box-shadow: none;
}

.upload-requirements {
  list-style: none;
  margin: 10px 0 0;
  padding: 10px 14px;
  background: #f8f9fa;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #455a64;
  line-height: 1.45;
}

.upload-requirements li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 2px;
}

.upload-requirements li:last-child {
  margin-bottom: 0;
}

.upload-requirements li::before {
  content: "\2713";
  position: absolute;
  left: 4px;
  top: 0;
  color: #2e7d32;
  font-weight: 700;
}

.file-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #e8f5e9;
  border-radius: 8px;
  margin-top: 8px;
}

.file-preview img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #c8e6c9;
  flex-shrink: 0;
}

.file-preview span {
  font-size: 0.85rem;
  color: #2e7d32;
  font-weight: 500;
  /* break-word wraps at word boundaries when possible, then mid-word —
     avoids the ugly mid-letter splits break-all produces. */
  overflow-wrap: anywhere;
  min-width: 0;
}

/* Loading */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
}

.loading-state p {
  color: #666;
  font-size: 0.95rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e0e0e0;
  border-top-color: #007bff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Error */
.error-msg {
  padding: 14px 16px;
  background: #fff5f5;
  color: #dc3545;
  border: 1px solid #f5c6cb;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.6;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Thank You Page */
.thankyou-card {
  text-align: center;
  padding: 48px 32px;
}

.thankyou-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  display: block;
}

.thankyou-card h1 {
  color: #28a745;
  margin-bottom: 12px;
}

.thankyou-card p {
  color: #555;
  font-size: 1.05rem;
  line-height: 1.6;
}

/* Utility color classes (used in dynamic instructions HTML) */
.text-primary { color: #007bff; }
.text-success { color: #28a745; }
.text-danger { color: #dc3545; }

/* ──────────── Responsive ──────────── */
/* Most users land here on phones. Tighten spacing, scale type down, keep
   touch targets ≥44px so nothing shrinks below an acceptable tap area. */
@media (max-width: 600px) {
  body {
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }
  .card {
    padding: 22px 18px;
    border-radius: 14px;
  }
  h1 {
    font-size: 1.3rem;
    margin-bottom: 14px;
  }
  .callout { font-size: 0.92rem; padding: 9px 12px; }
  .instructions-details { margin-bottom: 16px; }
  .instructions-details > summary { padding: 12px 14px; font-size: 0.92rem; }
  .instructions-section { padding: 12px 16px 16px; }
  .instructions-section ol { font-size: 0.92rem; line-height: 1.65; padding-left: 18px; }
  .actions { gap: 10px; }
  .step-row { margin-top: 4px; }
  .step-num { width: 24px; height: 24px; font-size: 12px; }
  .step-title { font-size: 0.92rem; }
  .btn {
    padding: 15px 20px;
    font-size: 1.02rem;
    min-height: 52px;            /* fatter CTA for thumbs */
  }
  .upload-nudge { font-size: 13.5px; }
  .upload-label {
    padding: 14px 14px;
    gap: 5px;
  }
  .upload-illustration { width: 44px; height: 66px; margin-bottom: 0; }
  .upload-headline, .upload-locked-text { font-size: 1rem; }
  .upload-button { padding: 12px 24px; font-size: 0.95rem; }
  .upload-requirements { font-size: 0.8rem; padding: 8px 12px; line-height: 1.4; }
}

/* Very small phones (iPhone SE 1st-gen, older Androids ~320–360px wide). */
@media (max-width: 380px) {
  .card { padding: 20px 14px; border-radius: 12px; }
  h1 { font-size: 1.2rem; }
  .instructions-section { padding: 14px 14px; }
  .upload-label { padding: 12px 12px; gap: 4px; }
  .upload-illustration { width: 38px; height: 57px; margin-bottom: 0; }
  .upload-headline { font-size: 0.95rem; }
  .upload-button { padding: 12px 20px; font-size: 0.9rem; }
  .upload-requirements { padding: 10px 12px; font-size: 0.8rem; }
  .file-preview img { width: 40px; height: 40px; }
  .thankyou-card { padding: 36px 18px; }
  .thankyou-icon { font-size: 3rem; }
  .thankyou-card p { font-size: 0.98rem; }
}

/* Landscape on short phones — keep upload area scrollable, drop big margins. */
@media (max-height: 520px) and (orientation: landscape) {
  body { padding: 12px; }
  .card { padding: 20px 22px; }
  h1 { margin-bottom: 14px; }
  .upload-label { padding: 12px 16px; }
  .upload-illustration { width: 40px; height: 60px; }
}

/* Respect users who've asked the OS to dial back animation. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
