:root {
  --sc-yellow: #FFFC00;
  --sc-black: #000000;
  --sc-white: #FFFFFF;
  font-family: 'Public Sans', 'Snapchat Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--sc-yellow);
  color: var(--sc-black);
  font-family: 'Public Sans', 'Snapchat Sans', system-ui, sans-serif;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

button, a { font-family: inherit; }

/* ---------- App screen (first viewport, mimics the Snapchat camera screen) ---------- */
.app-screen {
  height: 100svh;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background-color: var(--sc-yellow);
  background-image: linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)), url("bg-pattern.png");
  background-size: cover, cover;
  background-position: center, center;
  background-repeat: no-repeat, no-repeat;
}

/* ---------- Stage (main generator) ---------- */
.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 12px 24px;
  min-height: 0;
}

.main-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

@media (max-width: 860px) {
  .stage {
    flex-direction: column;
    gap: 20px;
  }
}

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

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 0;
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.05s forwards;
}

.icon-pill,
.icon-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sc-black);
  color: var(--sc-yellow);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, transform 0.12s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}
.icon-pill:hover,
.icon-circle:hover { background: #1a1a1a; }
.icon-pill:active,
.icon-circle:active { transform: scale(0.95); }

.icon-pill {
  border-radius: 999px;
  padding: 10px 16px;
}
.ca-value {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.3px;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-circle {
  width: 40px;
  height: 40px;
  border-radius: 999px;
}

/* ---------- Viewfinder ---------- */
.viewfinder-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-height: 0;
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.15s forwards;
}

.viewfinder-wrap::before {
  content: "";
  position: absolute;
  width: min(50vw, 340px);
  aspect-ratio: 9 / 16;
  max-height: 52svh;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0) 70%);
  filter: blur(10px);
  animation: glow-pulse 3.5s ease-in-out infinite;
  pointer-events: none;
}

@keyframes glow-pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.08); opacity: 1; }
}

.viewfinder {
  position: relative;
  display: grid;
  place-items: center;
  width: min(50vw, 340px);
  aspect-ratio: 9 / 16;
  max-height: 52svh;
  border-radius: 32px;
  background: #111111;
  border: 3px dashed rgba(0, 0, 0, 0.55);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.25s ease, box-shadow 0.25s ease;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}
.viewfinder:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
}
.viewfinder.drag-over {
  border-color: var(--sc-black);
  background: #1a1a1a;
  transform: scale(1.02);
}
.viewfinder.has-image {
  border-style: solid;
  border-color: transparent;
}

.vf-layer {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.ghost-icon {
  color: var(--sc-yellow);
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.upload-hint {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 252, 0, 0.7);
  letter-spacing: 0.3px;
}

.vf-media { object-fit: cover; }

.vf-media.reveal {
  animation: mediaPopIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes mediaPopIn {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.vf-media.result {
  object-fit: contain;
  background: var(--sc-white);
}

/* ---------- Loading overlay ---------- */
.vf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 2;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 4px solid rgba(255, 252, 0, 0.25);
  border-top-color: var(--sc-yellow);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--sc-yellow);
  text-transform: uppercase;
}

/* ---------- Username field ---------- */
.username-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.username-wrap.pop-in {
  animation: fadeInUp 0.45s ease forwards;
}

.add-to-gallery-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sc-black);
}

.add-to-gallery-msg {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-align: right;
  letter-spacing: 0.2px;
}

.point-arrow {
  color: var(--sc-black);
  animation: point-nudge 1.3s ease-in-out infinite;
}
@keyframes point-nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(6px); }
}

.username-field {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--sc-black);
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}

.at-sign {
  color: var(--sc-yellow);
  font-weight: 900;
  font-size: 14px;
}

.username-field input {
  border: none;
  background: transparent;
  color: var(--sc-white);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  outline: none;
  width: 160px;
}
.username-field input::placeholder { color: rgba(255, 255, 255, 0.35); }

.username-field:focus-within {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.25), 0 4px 14px rgba(0, 0, 0, 0.15);
}

.confirm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: 6px;
  border-radius: 999px;
  border: none;
  background: var(--sc-yellow);
  color: var(--sc-black);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s ease, transform 0.12s ease, opacity 0.12s ease;
}
.confirm-btn:hover:not(:disabled) { transform: scale(1.08); }
.confirm-btn:active:not(:disabled) { transform: scale(0.92); }
.confirm-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.confirm-btn.confirmed {
  background: #2ecc40;
  opacity: 1;
  cursor: default;
}

.username-hint {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.55);
}
.username-hint.error { color: #b00000; }
.username-hint.success { color: #146c1e; }

/* ---------- Bottom bar ---------- */
.bottombar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 16px 0 4px;
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.3s forwards;
}

.cooldown-hint {
  margin: 4px 0 0;
  font-size: 11px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.45);
  text-align: center;
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.35s forwards;
}

.side-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--sc-black);
  color: var(--sc-yellow);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, opacity 0.12s ease, transform 0.12s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
}
.side-btn:hover { background: #1a1a1a; }
.side-btn:active { transform: scale(0.92); }
.side-btn:disabled,
.side-btn[aria-disabled="true"] {
  opacity: 0.25;
  pointer-events: none;
}

.shutter-btn {
  width: 78px;
  height: 78px;
  border-radius: 999px;
  border: 4px solid var(--sc-black);
  background: transparent;
  padding: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.3);
}
.shutter-btn:not(:disabled) {
  animation: shutter-glow 2.4s ease-in-out infinite;
}
@keyframes shutter-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.25); }
  50% { box-shadow: 0 0 22px 4px rgba(0, 0, 0, 0.25); }
}
.shutter-ring {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: var(--sc-black);
  transition: background 0.15s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.shutter-btn:disabled {
  border-color: rgba(0, 0, 0, 0.25);
  cursor: not-allowed;
  animation: none;
  box-shadow: none;
}
.shutter-btn:disabled .shutter-ring {
  background: rgba(0, 0, 0, 0.2);
}
.shutter-btn:not(:disabled):hover { transform: scale(1.06); }
.shutter-btn:not(:disabled):hover .shutter-ring { transform: scale(1.08); }
.shutter-btn:not(:disabled):active .shutter-ring { transform: scale(0.82); }
.shutter-btn.loading { animation: shutter-glow 0.7s ease-in-out infinite; }
.shutter-btn.loading .shutter-ring { animation: pulse 0.7s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
}


/* ---------- Scroll cue ---------- */
.scroll-cue {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-bottom: 16px;
  color: rgba(0, 0, 0, 0.55);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.35s forwards, bob 1.8s ease-in-out 1s infinite;
  transition: color 0.15s ease;
}
.scroll-cue:hover { color: var(--sc-black); }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* ---------- Gallery ---------- */
.gallery {
  position: relative;
  min-height: 100svh;
  padding: 56px 24px 80px;
  background:
    radial-gradient(rgba(255, 252, 0, 0.06) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--sc-black);
  border-radius: 36px 36px 0 0;
  box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.25);
}

.gallery-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0 0 28px;
}

.gallery-title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.3px;
  text-align: center;
  position: relative;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.gallery-title::after {
  content: "";
  display: block;
  width: 36px;
  height: 3px;
  margin: 10px auto 0;
  background: var(--sc-yellow);
  border-radius: 999px;
}
.gallery-title.in-view { opacity: 1; transform: translateY(0); }

.gallery-panel {
  position: relative;
  max-width: 1140px;
  margin: 0 auto;
  padding: 28px;
  border-radius: 24px;
  background: #0c0c0c;
  border: 1px solid rgba(255, 252, 0, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 20px 50px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease 0.1s, transform 0.6s ease 0.1s;
}
.gallery-panel.in-view { opacity: 1; transform: translateY(0); }

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

@media (max-width: 860px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}

.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: rgba(255, 255, 255, 0.35);
  font-weight: 700;
  font-size: 14px;
  padding: 60px 0;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  border: 1px solid rgba(255, 252, 0, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: mediaPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.gallery-item:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 10px 30px rgba(255, 252, 0, 0.15);
  border-color: rgba(255, 252, 0, 0.4);
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.gallery-item-user {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 18px 10px 8px;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0));
  color: var(--sc-yellow);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  text-align: center;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gallery-item-user:hover { text-decoration: underline; }

.gallery-sentinel {
  height: 1px;
  max-width: 1100px;
  margin: 0 auto;
}
