:root {
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  color: var(--tg-theme-text-color, #2f2440);
  background: var(--tg-theme-bg-color, #f8f4ff);
  color-scheme: light;
  --page: var(--tg-theme-bg-color, #f8f4ff);
  --surface: var(--tg-theme-secondary-bg-color, rgba(255, 255, 255, .9));
  --text: var(--tg-theme-text-color, #2f2440);
  --muted: var(--tg-theme-hint-color, #81758f);
  --purple: var(--tg-theme-button-color, #8060e8);
  --button-text: var(--tg-theme-button-text-color, #fff);
  --orange: #ff9961;
  --line: rgba(67, 45, 91, .09);
  --shadow: 0 14px 38px rgba(73, 48, 107, .1);
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 92% -5%, rgba(205, 185, 255, .72), transparent 30rem),
    linear-gradient(145deg, #faf7ff 0%, #fffaf3 72%, #f7f0ff 100%);
  color: var(--text);
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.ambient {
  position: fixed;
  width: 22rem;
  height: 22rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: .18;
  pointer-events: none;
}
.ambient-purple { background: #9c7cff; top: -12rem; right: -11rem; }
.ambient-orange { background: #ffad69; bottom: -14rem; left: -12rem; }
#app {
  position: relative;
  width: min(100%, 760px);
  min-height: 100vh;
  margin: auto;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
}
.screen { animation: enter .38s cubic-bezier(.22, .8, .28, 1); }
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: env(safe-area-inset-top);
}
.logo {
  font-size: .92rem;
  font-weight: 950;
  letter-spacing: .17em;
  color: #4a3566;
}
.mini-status {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--line);
  color: #765da0;
}
.hero {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 28px;
  background:
    radial-gradient(circle at 90% 15%, rgba(255, 180, 112, .32), transparent 36%),
    linear-gradient(135deg, rgba(239, 228, 255, .97), rgba(255, 249, 240, .96));
  box-shadow: var(--shadow);
}
.hero::after {
  content: "✦";
  position: absolute;
  right: 20px;
  top: 15px;
  font-size: 3.5rem;
  color: rgba(128, 96, 232, .15);
  transform: rotate(12deg);
}
.eyebrow {
  margin: 0 0 8px;
  color: #8061bc;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .16em;
}
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 {
  max-width: 430px;
  margin: 0;
  font-size: clamp(1.85rem, 8vw, 2.8rem);
  line-height: 1.04;
  letter-spacing: -.035em;
}
.hero-copy {
  max-width: 520px;
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.45;
}
.hero-badges, .card-tags, .metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.soft-badge, .metadata span, .card-tag {
  border-radius: 999px;
  font-size: .72rem;
  white-space: nowrap;
}
.soft-badge {
  padding: 6px 9px;
  color: #634e79;
  background: rgba(255, 255, 255, .68);
  border: 1px solid rgba(103, 79, 130, .08);
}
.primary, .secondary, .reset-button {
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  font-weight: 800;
}
.primary {
  margin-top: 16px;
  padding: 13px 18px;
  color: var(--button-text);
  background: linear-gradient(135deg, var(--purple), #9969ec 58%, var(--orange));
  box-shadow: 0 9px 24px rgba(124, 84, 206, .22);
}
.primary:disabled { cursor: default; opacity: .45; box-shadow: none; }
.catalog-controls { margin-top: 18px; }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 5px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .65);
  border: 1px solid var(--line);
}
.segment {
  min-height: 43px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  transition: color .25s ease, background .25s ease, box-shadow .25s ease;
}
.segment.active {
  color: #fff;
  background: linear-gradient(135deg, #8563dc, #9c72e8);
  box-shadow: 0 6px 16px rgba(102, 72, 171, .18);
}
.search-wrap { position: relative; margin-top: 12px; }
.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #8f80a0;
  pointer-events: none;
}
.search {
  width: 100%;
  height: 48px;
  padding: 0 42px;
  border: 1px solid var(--line);
  border-radius: 17px;
  outline: 0;
  color: var(--text);
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 6px 22px rgba(69, 45, 95, .05);
}
.search:focus { border-color: rgba(128, 96, 232, .5); box-shadow: 0 0 0 3px rgba(128, 96, 232, .09); }
.clear-search {
  position: absolute;
  right: 10px;
  top: 8px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  color: #8b7b99;
  background: transparent;
  cursor: pointer;
}
.tag-strip {
  display: flex;
  gap: 8px;
  margin: 12px -16px 0;
  padding: 0 16px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tag-strip::-webkit-scrollbar { display: none; }
.tag-chip {
  flex: 0 0 auto;
  border: 1px solid rgba(90, 63, 120, .08);
  border-radius: 999px;
  padding: 9px 12px;
  color: #655373;
  background: rgba(255, 255, 255, .72);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 750;
  transition: color .24s ease, background .24s ease, border-color .24s ease, transform .24s ease;
}
.tag-chip:active { transform: scale(.97); }
.tag-chip:nth-child(2n) { background: rgba(255, 243, 225, .88); }
.tag-chip:nth-child(3n) { background: rgba(239, 232, 255, .88); }
.tag-chip.active { color: #fff; background: #8060db; border-color: #8060db; }
.list-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin: 19px 2px 10px;
}
.list-heading h2 { margin: 0; font-size: 1.22rem; }
.see-all {
  border: 0;
  padding: 4px;
  color: #7b5abd;
  background: transparent;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 800;
}
.quiz-list { display: grid; gap: 12px; }
.quiz-card {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  padding: 11px;
  border: 1px solid rgba(76, 52, 105, .08);
  border-radius: 23px;
  color: inherit;
  text-align: left;
  background: var(--surface);
  box-shadow: 0 9px 28px rgba(71, 45, 99, .07);
  cursor: pointer;
  transition: transform .28s cubic-bezier(.22, .8, .28, 1), box-shadow .28s ease;
}
.quiz-card:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(71, 45, 99, .11); }
.quiz-card:active { transform: scale(.992); }
.cover {
  position: relative;
  min-height: 128px;
  overflow: hidden;
  border-radius: 17px;
  background: linear-gradient(145deg, #aa88ef, #ffb36e);
}
.cover::before, .cover::after { position: absolute; content: ""; border-radius: 50%; background: rgba(255, 255, 255, .25); }
.cover::before { width: 90px; height: 90px; right: -28px; top: -24px; }
.cover::after { width: 52px; height: 52px; left: -18px; bottom: -18px; }
.cover-emoji { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.8rem; filter: drop-shadow(0 7px 8px rgba(70, 35, 70, .15)); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.card-body { min-width: 0; padding: 2px 3px 2px 0; }
.card-title-row { display: flex; align-items: flex-start; gap: 6px; }
.card-body h3 { flex: 1; margin: 0; font-size: 1rem; line-height: 1.18; }
.bookmark { color: #a696b4; font-size: 1rem; }
.card-description {
  display: -webkit-box;
  overflow: hidden;
  margin: 6px 0 9px;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.metadata { color: #766985; font-size: .7rem; }
.metadata span { padding: 0; }
.card-tags { margin-top: 9px; overflow: hidden; max-height: 24px; }
.card-tag { padding: 4px 7px; color: #775a9a; background: #f0e9ff; }
.card-cta { display: inline-block; margin-top: 9px; color: #7653bd; font-size: .78rem; font-weight: 900; }
.soon-card { cursor: default; opacity: .78; }
.soon-card:hover { transform: none; box-shadow: 0 9px 28px rgba(71, 45, 99, .07); }
.soon-card .cover { background: linear-gradient(145deg, #d7cbea, #f3d5bd); }
.state-card {
  padding: 30px 22px;
  border: 1px solid var(--line);
  border-radius: 24px;
  text-align: center;
  background: rgba(255, 255, 255, .72);
}
.state-icon { font-size: 2.3rem; }
.state-card h2 { margin: 9px 0 5px; }
.state-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.reset-button, .secondary { margin-top: 15px; padding: 12px 16px; color: #fff; background: #655174; }
.footer { padding: 28px 4px 8px; text-align: center; color: #998da3; font-size: .72rem; }

/* Quiz runtime */
.runtime { padding-top: 16px; }
.runtime-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.runtime-card h1 { margin-top: 12px; }
.runtime-art {
  position: relative;
  overflow: hidden;
  min-height: 168px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 21px;
  font-size: 4rem;
  background: linear-gradient(135deg, #aa88ef, #ffb36e);
}
.runtime-art img { width: 100%; height: 100%; object-fit: cover; }
.runtime-art > span { position: absolute; inset: 0; display: grid; place-items: center; }
.runtime-cover { aspect-ratio: 16 / 8; min-height: 0; }
.start-promise { margin: 14px 0 0; color: var(--muted); font-size: .82rem; }
.share-preview {
  width: 100%;
  margin-bottom: 18px;
  border-radius: 21px;
  box-shadow: 0 10px 26px rgba(70, 44, 94, .12);
  background: linear-gradient(135deg, #aa88ef, #ffb36e);
}
.share-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .75rem;
  text-align: center;
}
.teaser-card { text-align: center; }
.teaser-card .runtime-copy { font-size: 1.05rem; font-weight: 750; }
.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 11px 15px;
  border-radius: 999px;
  color: #fff;
  text-align: center;
  background: #3d2c4b;
  box-shadow: 0 10px 30px rgba(34, 20, 48, .25);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.runtime-copy { color: var(--muted); line-height: 1.55; }
.actions { display: grid; gap: 9px; margin-top: 19px; }
.actions .primary, .actions .secondary { width: 100%; margin: 0; }
.progress { height: 7px; margin: 17px 0 24px; overflow: hidden; border-radius: 99px; background: #eee8f3; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--purple), var(--orange)); transition: width .52s cubic-bezier(.22, .8, .28, 1); will-change: width; }
.question-image { aspect-ratio: 16 / 7; margin-bottom: 16px; overflow: hidden; border-radius: 18px; background: linear-gradient(135deg, #ad8cec, #ffb177); }
.question-image img { width: 100%; height: 100%; object-fit: cover; }
.answer {
  width: 100%;
  margin: 5px 0;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--text);
  text-align: left;
  background: rgba(247, 243, 252, .8);
  cursor: pointer;
  transition: color .24s ease, background .24s ease, border-color .24s ease, transform .24s cubic-bezier(.22, .8, .28, 1), opacity .24s ease;
}
.answer:hover, .answer:focus { border-color: #b394f1; background: #f1eaff; outline: 0; }
.answer.selected { color: #fff; border-color: #8a63df; background: linear-gradient(135deg, #8662df, #ad75e8); transform: scale(.995); }
.answer:disabled { cursor: default; opacity: .58; }
.answer.selected:disabled { opacity: 1; }
.back-link { margin: 0 0 12px; padding: 6px 0; border: 0; color: #7158a0; background: none; cursor: pointer; font-weight: 800; }
.question-stage, .question-panel { width: 100%; }
.answers-stage { display: grid; overflow: hidden; transition: height .34s cubic-bezier(.22, .8, .28, 1); }
.answers-panel { grid-area: 1 / 1; width: 100%; will-change: transform, opacity; }
.answers-enter-right { animation: answers-in-right .34s cubic-bezier(.22, .8, .28, 1) both; }
.answers-enter-left { animation: answers-in-left .34s cubic-bezier(.22, .8, .28, 1) both; }
.answers-exit-left { animation: answers-out-left .34s cubic-bezier(.22, .8, .28, 1) both; pointer-events: none; }
.answers-exit-right { animation: answers-out-right .34s cubic-bezier(.22, .8, .28, 1) both; pointer-events: none; }
.result-traits { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.result-traits span { padding: 7px 10px; border-radius: 999px; color: #6f5295; background: #f0e8ff; font-size: .76rem; font-weight: 750; }
.result-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.result-facts > div { padding: 13px; border-radius: 16px; background: #f8f3fc; }
.result-facts small { display: block; margin-bottom: 5px; color: var(--muted); font-size: .7rem; }
.result-facts strong { display: block; font-size: .86rem; line-height: 1.35; }
.secondary-result { padding: 12px 14px; border-radius: 15px; color: #684c84; background: #fff2e7; font-size: .84rem; }
.result-punchline { margin: 16px 0 0; font-weight: 750; line-height: 1.45; }
.loading-screen { padding-top: 12px; }
.skeleton { position: relative; overflow: hidden; border-radius: 22px; background: rgba(226, 216, 239, .62); }
.skeleton::after { position: absolute; inset: 0; content: ""; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: shimmer 1.2s infinite; }
.skeleton-hero { height: 220px; }
.skeleton-line { width: 60%; height: 42px; margin: 18px 0 12px; }
.skeleton-card { height: 150px; }

@keyframes enter { from { opacity: 0; transform: translateY(7px); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes answers-in-right { from { opacity: .2; transform: translateX(42px); } to { opacity: 1; transform: translateX(0); } }
@keyframes answers-in-left { from { opacity: .2; transform: translateX(-42px); } to { opacity: 1; transform: translateX(0); } }
@keyframes answers-out-left { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(-42px); } }
@keyframes answers-out-right { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(42px); } }

@media (min-width: 640px) {
  #app { padding-inline: 24px; }
  .quiz-list { grid-template-columns: 1fr 1fr; }
  .quiz-card { grid-template-columns: 96px minmax(0, 1fr); }
  .hero { padding: 27px; }
}

@media (max-width: 370px) {
  #app { padding-inline: 12px; }
  .hero { padding: 18px; border-radius: 24px; }
  .hero-copy { font-size: .87rem; margin-bottom: 11px; }
  .soft-badge { font-size: .66rem; padding: 5px 7px; }
  .primary { margin-top: 13px; }
  .catalog-controls { margin-top: 14px; }
  .tag-strip { margin-inline: -12px; padding-inline: 12px; }
  .quiz-card { grid-template-columns: 90px minmax(0, 1fr); gap: 11px; }
  .cover { min-height: 124px; }
  .metadata { gap: 5px; }
  .result-facts { grid-template-columns: 1fr; }
}

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