:root {
  --ink: #171726;
  --muted: #6d6c7d;
  --paper: #ffffff;
  --canvas: #f2f1f8;
  --primary: #f56d73;
  --primary-dark: #d94d58;
  --coral: #f56d73;
  --teal: #56c4bf;
  --gold: #ffdc54;
  --line: #e2e0ec;
  --shadow: 0 12px 35px rgba(35, 31, 78, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(245, 109, 115, 0.13), transparent 32rem),
    radial-gradient(circle at 92% 20%, rgba(86, 196, 191, 0.12), transparent 28rem),
    var(--canvas);
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

body.is-loading { overflow: hidden; }

.startup-loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 15%, rgba(245, 109, 115, 0.24), transparent 36%),
    radial-gradient(circle at 82% 82%, rgba(86, 196, 191, 0.22), transparent 38%),
    #fffaf7;
  opacity: 1;
  visibility: visible;
  transition: opacity 280ms ease, visibility 280ms ease;
}

.startup-loader.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.startup-loader-card {
  width: min(100%, 360px);
  display: grid;
  justify-items: center;
  text-align: center;
}

.startup-loader-logo {
  width: min(68vw, 210px);
  height: auto;
  margin-bottom: 28px;
}

.startup-loader-mark {
  position: relative;
  width: 154px;
  height: 116px;
  margin-bottom: 20px;
}

.startup-question {
  position: absolute;
  display: grid;
  place-items: center;
  width: 66px;
  height: 78px;
  border: 3px solid var(--ink);
  border-radius: 20px 20px 22px 9px;
  color: white;
  font: 900 3.2rem/1 Georgia, serif;
  box-shadow: 0 12px 25px rgba(35, 31, 78, 0.16);
  transform-origin: 50% 85%;
  animation: startup-bob 1.25s ease-in-out infinite;
}

.startup-question::after {
  content: "";
  position: absolute;
  left: 10px;
  bottom: -11px;
  width: 18px;
  height: 18px;
  background: inherit;
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  transform: skewY(-28deg) rotate(26deg);
}

.startup-question-coral { left: 43px; top: 5px; z-index: 3; background: var(--coral); }
.startup-question-teal { right: 0; top: 29px; z-index: 2; background: var(--teal); animation-delay: -0.22s; transform: scale(0.72) rotate(8deg); }
.startup-question-gold { left: 0; top: 35px; z-index: 1; background: var(--gold); color: var(--ink); animation-delay: -0.44s; transform: scale(0.68) rotate(-10deg); }

.startup-sparkle {
  position: absolute;
  top: 0;
  right: 13px;
  color: var(--gold);
  font-size: 1.55rem;
  text-shadow: 0 1px 0 var(--ink);
  animation: startup-sparkle 900ms ease-in-out infinite alternate;
}

.startup-loader-copy {
  min-height: 2.7em;
  margin: 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
}

.startup-loader-track {
  width: min(76vw, 260px);
  height: 9px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #ebe8f0;
}

.startup-loader-track span {
  display: block;
  width: 44%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--teal));
  animation: startup-progress 1.05s ease-in-out infinite;
}

@keyframes startup-bob {
  0%, 100% { translate: 0 0; rotate: -2deg; }
  50% { translate: 0 -8px; rotate: 2deg; }
}

@keyframes startup-sparkle {
  from { transform: scale(0.7) rotate(-8deg); opacity: 0.55; }
  to { transform: scale(1.15) rotate(8deg); opacity: 1; }
}

@keyframes startup-progress {
  from { transform: translateX(-115%); }
  to { transform: translateX(330%); }
}

@media (prefers-reduced-motion: reduce) {
  .startup-question,
  .startup-sparkle,
  .startup-loader-track span { animation: none; }
  .startup-loader-track span { width: 100%; }
}

.app-shell {
  width: min(100%, 500px);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(31, 29, 60, 0.04), 0 0 60px rgba(38, 34, 87, 0.12);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 66px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  border-top: 4px solid var(--primary);
  border-bottom: 1px solid var(--line);
}

.brand {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.brand img { width: 150px; height: 44px; object-fit: contain; }

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #8986b0;
  font-size: 1.55rem;
  cursor: pointer;
}

.icon-button:hover, .icon-button:focus-visible { background: #f0effa; color: var(--primary); }

main { min-height: calc(100vh - 66px); }
.screen { display: none; padding: 18px; }
.screen.active { display: block; animation: screen-in 220ms ease both; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.feed-heading { padding: 16px 2px 20px; }
.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.feed-heading h1 { margin: 0; font-size: clamp(2rem, 9vw, 2.7rem); line-height: 0.98; letter-spacing: -0.05em; }
.feed-heading > p:last-child { margin: 12px 0 0; color: var(--muted); font-size: 1rem; }

.quiz-feed { display: grid; gap: 16px; padding-bottom: 24px; }
.feed-empty { padding: 50px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 20px; }

.quiz-tile {
  overflow: hidden;
  position: relative;
  width: 100%;
  padding: 0;
  text-align: left;
  border: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.quiz-tile:hover { transform: translateY(-3px); box-shadow: 0 18px 45px rgba(35, 31, 78, 0.18); }
.quiz-tile:focus-visible { outline: 4px solid rgba(245, 109, 115, 0.28); outline-offset: 2px; }
.quiz-tile-art { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: #eceaf4; }
.quiz-tile-art img { width: 100%; height: 100%; object-fit: cover; object-position: center 28%; transition: transform 350ms ease; }
.quiz-tile:hover .quiz-tile-art img { transform: scale(1.025); }
.quiz-tile-label {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  font-size: 0.78rem;
  font-weight: 850;
}
.quiz-tile-ribbon {
  position: absolute;
  inset: auto 0 0;
  padding: 10px 14px;
  color: white;
  background: linear-gradient(90deg, rgba(245,109,115,0.96), rgba(86,196,191,0.96));
  font-weight: 900;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}
.quiz-tile-copy { padding: 15px 16px 17px; font-size: 1.15rem; font-weight: 750; line-height: 1.25; }

.play-panel { text-align: center; }
.play-panel > .eyebrow { margin-top: 5px; }
.play-panel h1 { margin: 6px auto 16px; font-size: clamp(1.6rem, 7vw, 2.1rem); line-height: 1.08; letter-spacing: -0.035em; }
.instruction {
  margin: 0 0 16px;
  padding: 15px 16px;
  border-radius: 13px;
  color: white;
  background: var(--ink);
  font-size: 1.2rem;
  line-height: 1.25;
}

.interaction-frame {
  position: relative;
  overflow: hidden;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: #eeeaf0;
  box-shadow: 0 0 0 1px rgba(20,20,40,0.06);
  cursor: crosshair;
  touch-action: manipulation;
}
.interaction-frame img { width: 100%; height: 100%; object-fit: cover; }
.interaction-frame:focus-visible { outline: 5px solid rgba(245, 109, 115, 0.32); outline-offset: 3px; }
.interaction-frame.wrong { animation: shake 360ms ease; }

@keyframes shake {
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

.hotspot-guide {
  position: absolute;
  display: none;
  border: 3px dashed #ff2a6d;
  border-radius: 50%;
  background: rgba(255, 42, 109, 0.1);
  pointer-events: none;
}
.show-hotspot .hotspot-guide { display: block; }
.tap-ripple {
  position: absolute;
  width: 62px;
  height: 62px;
  margin: -31px;
  border: 4px solid white;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.tap-ripple.animate { animation: ripple 520ms ease-out; }
@keyframes ripple { from { opacity: 0.9; transform: scale(0.4); } to { opacity: 0; transform: scale(1.75); } }
.tap-hint { margin: 12px 0 4px; color: var(--muted); font-size: 0.86rem; }

.profile-interaction,
.choice-interaction,
.image-grid-interaction,
.quiz-input-form {
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: var(--shadow);
}
.profile-interaction { aspect-ratio: 1; }
.profile-scene { width: 100%; height: 100%; object-fit: cover; }
.profile-photo-stage {
  position: absolute;
  z-index: 2;
  left: 31%;
  top: 26%;
  width: 53%;
  height: 49%;
  overflow: hidden;
  border: 3px solid #f1dfc2;
  background: linear-gradient(145deg, #56c4bf, #f56d73);
  box-shadow: 0 8px 22px rgba(64, 41, 27, .22);
}
.profile-photo-fallback { display: grid; width: 100%; height: 100%; place-items: center; color: #fff; background-position: center; background-size: cover; font-size: 4rem; font-weight: 900; }
.facebook-profile-overlay { position: absolute; inset: 0; overflow: hidden; }
.facebook-profile-overlay > iframe { display: block; width: 100%; height: 100%; border: 0; }
.profile-tap-target { position: absolute; z-index: 5; inset: 0; width: 100%; border: 0; background: transparent; cursor: pointer; }
.profile-tap-target:focus-visible { outline: 5px solid rgba(245, 109, 115, .42); outline-offset: -6px; }

.quiz-input-form { padding: 14px; text-align: left; }
.form-artwork,
.choice-artwork { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 13px; background: #edf3f1; }
.quiz-fields { display: grid; gap: 12px; margin-top: 14px; }
.quiz-field-label { display: grid; gap: 6px; color: var(--ink); font-weight: 850; }
.quiz-field-label span { font-size: .88rem; }
.quiz-field-input { width: 100%; min-height: 52px; padding: 12px 14px; border: 2px solid #d9d8e3; border-radius: 11px; background: #fff; font-size: 1rem; }
.quiz-field-input:focus { border-color: var(--teal); outline: 4px solid rgba(86, 196, 191, .17); }
.reveal-button { width: 100%; min-height: 56px; margin-top: 14px; border: 0; border-radius: 12px; color: #fff; background: #1877f2; font-size: 1.08rem; font-weight: 900; cursor: pointer; }
.privacy-note { margin: 10px 4px 1px; color: var(--muted); font-size: .74rem; text-align: center; }

.choice-interaction { padding: 12px; }
.choice-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.choice-button { min-height: 50px; padding: 8px 5px; border: 2px solid #d9d8e3; border-radius: 11px; background: #fff; font-size: .8rem; font-weight: 850; cursor: pointer; }
.choice-button:hover,
.choice-button:focus-visible { border-color: var(--primary); background: #fff5f5; outline: none; }
.image-grid-interaction { position: relative; background: #fff; }
.image-grid-artwork { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.image-grid-buttons { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--grid-columns, 3), 1fr); grid-auto-rows: 1fr; }
.image-grid-button { position: relative; display: flex; align-items: flex-end; justify-content: center; min-width: 0; padding: 8px 4px; border: 1px solid rgba(23,23,38,.16); color: #171726; background: transparent; cursor: pointer; font-size: clamp(.7rem, 2.7vw, .9rem); font-weight: 850; }
.image-grid-button span { padding: 4px 7px; border-radius: 999px; background: rgba(255,255,255,.9); box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.image-grid-button:hover,
.image-grid-button:focus-visible { z-index: 2; outline: 4px solid rgba(245,109,115,.6); outline-offset: -4px; background: rgba(255,255,255,.12); }

#resultScreen { padding-top: 14px; }
.generated-result-shell { position: relative; width: 100%; aspect-ratio: 3 / 4; overflow: hidden; border-radius: 20px; background: #eaf7f5; box-shadow: var(--shadow); }
.generated-result-image { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: contain; background: #eaf7f5; }
.facebook-result-overlay { position: absolute; inset: 0; overflow: hidden; background: #eaf7f5; }
.facebook-result-overlay > iframe { display: block; width: 100%; height: 100%; border: 0; }

.primary-button, .secondary-button, .danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.primary-button {
  width: 100%;
  min-height: 58px;
  margin-top: 16px;
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #ff8b78);
  box-shadow: 0 8px 18px rgba(245, 109, 115, 0.28);
  font-size: 1.2rem;
}
.primary-button:hover { background: linear-gradient(135deg, var(--primary-dark), #ed7062); }
.share-button { min-height: 64px; color: #fff; background: #1877f2; box-shadow: 0 8px 18px rgba(24,119,242,.25); font-size: 1.28rem; }
.share-button:hover { background: #0f68da; }
.next-button { color: #237c78; border-color: rgba(86,196,191,0.55); background: #effbfa; }
.text-button { display: block; margin: 14px auto 0; padding: 9px 15px; border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.more-quizzes { margin: 36px -18px -18px; padding: 30px 18px 38px; border-top: 1px solid var(--line); background: linear-gradient(180deg,#f4f8f8,#f7f5f8); }
.more-quizzes > .eyebrow { text-align: center; }
.more-quizzes h2 { margin: 4px 0 20px; font-size: 1.7rem; text-align: center; letter-spacing: -.035em; }
.result-quiz-feed { padding-bottom: 0; }
.secondary-button {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.danger-button { min-height: 42px; padding: 0 14px; color: #b52f41; border: 1px solid #f0bdc4; background: #fff5f6; }
.small-button { min-height: 48px; font-size: 1rem; }
.text-link { display: block; margin-top: 17px; color: var(--primary); font-weight: 750; text-align: center; }
.analytics-note { margin: 14px 0 0; color: var(--muted); font-size: 0.75rem; text-align: center; }

.settings-card { padding-bottom: 20px; }
.language-setting {
  display: grid;
  gap: 8px;
  margin: 20px 0 18px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.language-setting select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7f6fa;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  text-transform: none;
}
.settings-links { display: grid; border-top: 1px solid var(--line); }
.settings-links a {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}
.settings-links a::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 1.25rem; }
.settings-links a:hover,
.settings-links a:focus-visible { color: var(--primary-dark); }

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(14, 13, 25, 0.72);
  backdrop-filter: blur(8px);
}
.modal-card { position: relative; width: min(100%, 440px); padding: 25px; border-radius: 20px; background: #fff; box-shadow: 0 26px 70px rgba(0,0,0,0.28); }
.compact-modal { max-width: 360px; }
.modal-card h2 { margin: 0 0 20px; }
.post-share-prompt {
  position: fixed;
  z-index: 140;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 260ms ease;
}
.post-share-prompt.is-visible { opacity: 1; }
.post-share-banner {
  position: relative;
  width: min(88vw, 540px);
  padding: 32px 26px 28px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.68);
  border-radius: 28px;
  color: #fff;
  background: linear-gradient(135deg, rgba(46,43,76,.86), rgba(188,78,104,.82));
  box-shadow: 0 18px 55px rgba(30,22,48,.34), inset 0 1px 0 rgba(255,255,255,.36);
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,.3);
  backdrop-filter: blur(10px);
}
.post-share-banner p { margin: 0; }
.post-share-sparkle {
  position: absolute;
  top: -14px;
  right: 18px;
  color: #ffe38e;
  font-size: 5rem;
  line-height: 1;
  opacity: .32;
  transform: rotate(12deg);
}
.post-share-praise {
  position: relative;
  font-size: clamp(1.75rem, 7.5vw, 2.8rem);
  font-weight: 950;
  line-height: 1.05;
  letter-spacing: -.035em;
}
.post-share-direction {
  position: relative;
  margin-top: 16px !important;
  color: rgba(255,255,255,.9);
  font-size: clamp(1rem, 4.5vw, 1.35rem);
  font-weight: 750;
  line-height: 1.2;
  letter-spacing: .01em;
}
@media (prefers-reduced-motion: reduce) {
  .post-share-prompt { transition: none; }
}
.modal-card label:not(.checkbox-row) { display: block; margin: 13px 0 6px; color: var(--muted); font-size: 0.82rem; font-weight: 750; }
.modal-card input:not([type="checkbox"]) { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; margin: 16px 0 4px; }
.modal-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #f0eff4; font-size: 1.5rem; cursor: pointer; }

.ad-backdrop { background: rgba(5, 5, 9, 0.94); }
.mock-ad { width: min(100%, 560px); overflow: hidden; border-radius: 20px; background: #fff; }
.ad-sponsor { display: grid; grid-template-columns: 44px 1fr; column-gap: 10px; padding: 16px; align-items: center; }
.ad-sponsor .ad-logo { grid-row: span 2; display: grid; place-items: center; width: 44px; height: 44px; color: #fff; background: #171735; border-radius: 12px; font-weight: 950; }
.ad-sponsor > span:nth-child(2) { font-weight: 900; }
.ad-sponsor small { color: var(--muted); }
.ad-creative { position: relative; overflow: hidden; min-height: 310px; display: grid; align-content: center; justify-items: center; padding: 34px; color: #fff; text-align: center; background: linear-gradient(150deg, #4d3acd, #c6388a 50%, #ff9844); }
.ad-creative p { position: relative; z-index: 2; margin: 0; font-size: clamp(1.8rem, 8vw, 3rem); line-height: 1.05; }
.ad-creative button { position: relative; z-index: 2; margin-top: 25px; padding: 11px 22px; border: 1px solid white; border-radius: 999px; color: #fff; background: rgba(255,255,255,0.12); }
.ad-orb { position: absolute; border-radius: 50%; filter: blur(2px); background: rgba(255,255,255,0.13); }
.ad-orb.one { width: 220px; height: 220px; top: -60px; right: -45px; }
.ad-orb.two { width: 160px; height: 160px; bottom: -40px; left: -20px; }
.ad-progress { height: 4px; background: #dedde4; }
.ad-progress span { display: block; width: 0; height: 100%; background: #1477f8; }
.ad-progress span.running { animation: ad-progress var(--ad-duration, 3s) linear forwards; }
.ad-close { width: calc(100% - 24px); min-height: 48px; margin: 12px; border: 0; border-radius: 11px; color: #fff; background: #171726; font-weight: 850; }
.ad-close:disabled { opacity: 0.55; cursor: wait; }

.share-card-modal { max-height: calc(100vh - 40px); overflow: auto; }
.share-card-modal img { width: 100%; border-radius: 13px; background: #eee; }
.download-button { min-height: 50px; font-size: 1rem; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 24px; max-width: calc(100% - 30px); transform: translate(-50%, 20px); padding: 12px 16px; border-radius: 999px; color: #fff; background: #171726; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: 180ms ease; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }
.site-footer { width: min(100%, 500px); margin: 18px auto 0; padding: 22px 18px 30px; text-align: center; }
.site-footer > img { width: 105px; margin: 0 auto 13px; }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; }
.site-footer a { color: var(--muted); font-size: 0.75rem; text-decoration: none; }
.site-footer a:hover { color: var(--primary-dark); text-decoration: underline; }

@media (max-width: 380px) {
  .screen { padding: 13px; }
}

@media (min-width: 720px) {
  body:not(.admin-body) { padding: 24px 0; }
  .app-shell { min-height: calc(100vh - 48px); border-radius: 24px; overflow: clip; }
}

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