/* ── Wedding palette ─────────────────────────────────────────────────────────── */
:root {
  --cream:  #FBF6EF;
  --card:   #FFFDFA;
  --rose:   #C98B8B;
  --rose-d: #B06E6E;
  --sage:   #8AA079;
  --gold:   #D8B26E;
  --cocoa:  #4A3F3A;
  --muted:  #9B8B82;
  --good:   #7C9A6A;
  --bad:    #C98B8B;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(74, 63, 58, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--cocoa);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* the peeking cats hang off the edge — never scroll sideways */
}

body {
  background-image:
    radial-gradient(circle at 15% 12%, rgba(216, 178, 110, 0.10), transparent 40%),
    radial-gradient(circle at 85% 88%, rgba(138, 160, 121, 0.12), transparent 42%);
  background-attachment: fixed;
}

/* Mobile-only web app: everything lives in a phone-width column, centered on any
   screen. On desktop it just looks like a phone in the middle of the page. */
.app {
  min-height: 100dvh;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
}

/* ── Screens ─────────────────────────────────────────────────────────────────── */
/* position:relative so the peeking cats anchor to the card column, not the window */
.screen { display: none; position: relative; width: 100%; }
.screen--active { display: block; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 24px 26px;
  border: 1px solid rgba(216, 178, 110, 0.25);
}

/* ── Typography bits ─────────────────────────────────────────────────────────── */
.eyebrow {
  text-align: center;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  margin: 0 0 6px;
}
.couple {
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  font-size: 2.1rem;
  color: var(--rose-d);
  margin: 0 0 4px;
  line-height: 1.15;
}
.intro {
  text-align: center;
  color: var(--cocoa);
  font-size: 1rem;
  line-height: 1.5;
  margin: 6px 0 22px;
}

.welcome-card { position: relative; }

.couple-photo-frame {
  position: relative;
  width: 244px;
  height: 244px;
  margin: 20px auto 16px;
  border-radius: 50%;
  border: 4px solid var(--gold);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: linear-gradient(135deg, rgba(201,139,139,0.18), rgba(138,160,121,0.18));
  display: flex;
  align-items: center;
  justify-content: center;
}
.couple-photo-fallback { font-size: 3.4rem; }
.couple-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Form ────────────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 18px; }
.field__label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
  padding-left: 4px;
}
#name-input {
  width: 100%;
  padding: 15px 16px;
  font-size: 1.05rem;
  border: 2px solid rgba(138, 160, 121, 0.35);
  border-radius: 14px;
  background: #fff;
  color: var(--cocoa);
  outline: none;
  transition: border-color 0.2s;
}
#name-input:focus { border-color: var(--sage); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 16px;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn--primary { background: var(--rose); color: #fff; }
.btn--primary:hover { background: var(--rose-d); }
.btn--primary:disabled { background: #dcc9c4; cursor: not-allowed; }
.btn--ghost {
  background: transparent;
  color: var(--sage);
  border: 2px solid var(--sage);
  margin-top: 20px;
}

/* Auto-advance countdown: a sage fill sweeps across the Next button over 3s */
#next-btn { position: relative; overflow: hidden; }
#next-btn > span { position: relative; z-index: 1; }
#next-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.22);
  transform: scaleX(0);
  transform-origin: left center;
  z-index: 0;
}
#next-btn.btn--counting::after {
  transform: scaleX(1);
  transition: transform var(--autoadvance, 3s) linear;
}

/* ── Quiz ────────────────────────────────────────────────────────────────────── */
.quiz-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.progress-label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.score-pill {
  background: var(--gold);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
}
.progress-bar {
  height: 8px;
  background: rgba(138, 160, 121, 0.18);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 22px;
}
.progress-bar__fill {
  height: 100%;
  width: 0;
  background: var(--sage);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.question {
  font-size: 1.3rem;
  line-height: 1.35;
  margin: 0 0 20px;
  color: var(--cocoa);
}

.options { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.option {
  width: 100%;
  min-height: 54px;
  text-align: left;
  padding: 14px 16px;
  font-size: 1.02rem;
  background: #fff;
  color: var(--cocoa);
  border: 2px solid rgba(201, 139, 139, 0.35);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.08s;
}
.option:hover { border-color: var(--rose); }
.option:active { transform: scale(0.99); }
.option--locked { cursor: default; }
.option--locked:hover { border-color: rgba(201, 139, 139, 0.35); }
.option--correct { border-color: var(--good); background: rgba(124, 154, 106, 0.14); font-weight: 600; }
.option--wrong { border-color: var(--bad); background: rgba(201, 139, 139, 0.14); }

.feedback {
  text-align: center;
  min-height: 1.4em;
  font-weight: 600;
  margin: 16px 0 6px;
}
.feedback--good { color: var(--good); }
.feedback--bad { color: var(--rose-d); }

/* Evidence photo — revealed after answering, on questions that have one */
.evidence {
  margin: 4px 0 2px;
  text-align: center;
  animation: evidence-in 0.4s ease;
}
.evidence[hidden] { display: none; }
.evidence img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: 14px;
  border: 3px solid var(--gold);
  box-shadow: var(--shadow);
}
.evidence figcaption {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
}
@keyframes evidence-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: none; }
}

/* ── Result ──────────────────────────────────────────────────────────────────── */
.result-cat {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--gold);
  box-shadow: var(--shadow);
  margin: 8px auto 12px;
}
.result-score {
  text-align: center;
  font-family: Georgia, serif;
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--rose-d);
}
.result-message {
  text-align: center;
  color: var(--cocoa);
  line-height: 1.5;
  margin: 6px 0 22px;
}

/* ── Leaderboard ─────────────────────────────────────────────────────────────── */
.leaderboard { border-top: 1px solid rgba(216, 178, 110, 0.3); padding-top: 18px; }
.leaderboard__title { text-align: center; margin: 0 0 14px; font-size: 1.05rem; color: var(--cocoa); }
.leaderboard__list { list-style: none; margin: 0; padding: 0; }
.lb-row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 6px;
  background: rgba(138, 160, 121, 0.07);
}
.lb-row--me {
  background: rgba(216, 178, 110, 0.22);
  outline: 2px solid var(--gold);
}
.lb-rank { color: var(--muted); font-weight: 700; text-align: center; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; color: var(--sage); }
.leaderboard__you { text-align: center; color: var(--muted); font-weight: 600; margin: 14px 0 0; }
.loading { text-align: center; color: var(--muted); }

@media (max-width: 360px) {
  .couple { font-size: 1.8rem; }
  .couple-photo-frame { width: 210px; height: 210px; }
}

/* ── Desktop: render the app inside a phone device frame ─────────────────────────
   On real phones the app fills the screen. On anything wider we frame it as a phone
   sitting on a neutral backdrop, so it always reads as a mobile app. */
@media (min-width: 480px) {
  body {
    background: #EAE3D9;
    background-image:
      radial-gradient(circle at 20% 10%, rgba(216, 178, 110, 0.10), transparent 45%),
      radial-gradient(circle at 80% 90%, rgba(138, 160, 121, 0.10), transparent 45%);
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
  }
  .app {
    width: 384px;
    max-width: 384px;
    min-height: 0;
    height: min(832px, calc(100dvh - 48px));
    margin: 0;
    align-items: safe center; /* center when it fits, scroll (no top clip) when tall */
    border-radius: 46px;
    border: 12px solid #211d1a;
    box-shadow: 0 26px 60px rgba(33, 29, 26, 0.38);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    /* cream interior + soft glow, so inside the "phone" matches the mobile look */
    background:
      radial-gradient(circle at 15% 10%, rgba(216, 178, 110, 0.12), transparent 42%),
      radial-gradient(circle at 85% 90%, rgba(138, 160, 121, 0.14), transparent 44%),
      var(--cream);
  }
  .app::-webkit-scrollbar { display: none; }
}
