:root {
  --bg: #0f0a1f;
  --surface: #1a1330;
  --surface-2: #251b45;
  --text: #f3eefc;
  --muted: #a99cc8;
  --accent: #8b5cf6;
  --accent-strong: #a78bfa;
  --accent-glow: rgba(139, 92, 246, 0.65);
  --gold: #f5c451;
  --radius: 16px;
  --font-display: "Unbounded", "Noto Sans Devanagari", system-ui, sans-serif;
  --font-body: "Inter", "Noto Sans Devanagari", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(139, 92, 246, 0.25), transparent 60%),
    var(--bg);
}

.screen[hidden] { display: none; }

/* ---------- Стартовый экран ---------- */

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 48px 16px 32px;
  text-align: center;
}
.landing .title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(36px, 12vw, 64px);
  line-height: 1.02;
  margin: 0;
}
.landing .title span { display: block; }
.landing .title .year { color: var(--gold); }
.landing .lead { margin: 0; color: var(--muted); font-size: 17px; line-height: 1.4; }
.landing .voters { color: var(--muted); font-size: 15px; }
.landing .voters b { color: var(--text); font-size: 20px; }
.landing .start { max-width: 360px; margin-top: 8px; font-size: 19px; padding: 18px; }
.landing .qr-button { max-width: 200px; margin-top: 16px; }

/* ---------- Выбор языка ---------- */

.langpick {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  max-width: 420px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 32px 16px;
}
.langpick h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.25;
  text-align: center;
}
.langpick h2 span { display: block; margin-top: 8px; font: 400 16px var(--font-body); color: var(--muted); }
.lang-options { display: grid; gap: 12px; }
.lang-options button {
  padding: 20px;
  border: 1px solid var(--surface-2);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: 600 20px var(--font-body);
  cursor: pointer;
}
.lang-options button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.lang-options button:active { transform: scale(0.98); }

/* ---------- Опрос ---------- */

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
}
.brand b { color: var(--gold); font-weight: 700; }

.langs { display: flex; gap: 4px; }
.langs button {
  border: 1px solid var(--surface-2);
  background: transparent;
  color: var(--muted);
  font: 600 12px var(--font-body);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.langs button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.progress {
  height: 4px;
  margin: 16px 0 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.progress > div {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.3s ease;
}

/* SurveyJS: убираем лишние отступы, чтобы вопрос занимал экран */
#survey .sd-root-modern { background: transparent; }
#survey .sd-body.sd-body--static { padding: 8px 0 0; max-width: none; }
#survey .sd-page { padding: 0; }
#survey .sd-question__title { font-family: var(--font-display); font-size: 22px; line-height: 1.3; }

/* Звёзды 1–5: крупные, на всю ширину, выбранные — золотые */
#survey .sd-rating fieldset { display: flex; justify-content: space-between; width: 100%; }
#survey .sd-rating__item-star { flex: 1 1 0; display: flex; justify-content: center; }
#survey .sd-rating__item-star svg { width: 48px; height: 48px; }
#survey .sd-rating__item-star--selected svg,
#survey .sd-rating__item-star--selected use { fill: var(--gold); }

/* Блок после ответа: статистика + «Дальше» */
.after {
  margin-top: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  animation: rise 0.25s ease-out;
}
.after[hidden] { display: none; }
/* до голосования — только кнопка, без карточки */
.after.bare { padding: 0; background: none; border: 0; }
.after.bare .next { margin-top: 0; }
.after #stats[hidden] { display: none; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.after h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.bars { display: grid; gap: 8px; }
.bar {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 14px;
  overflow: hidden;
}
.bar > .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: rgba(139, 92, 246, 0.35);
  transition: width 0.4s ease;
}
.bar.mine > .fill { background: rgba(245, 196, 81, 0.4); }
.bar > span { position: relative; }
.bar .count { color: var(--muted); font-variant-numeric: tabular-nums; }

.avg {
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
}
.avg b { color: var(--gold); font-size: 20px; }

.first { margin: 0; color: var(--gold); font-size: 15px; }

.next {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 16px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font: 700 17px var(--font-body);
  cursor: pointer;
  box-shadow: 0 8px 24px -8px var(--accent-glow);
}
.next:active { transform: scale(0.98); }

.thanks {
  text-align: center;
  padding: 48px 0;
}
.thanks h2 {
  font-family: var(--font-display);
  font-size: 32px;
  margin: 0 0 12px;
}
.thanks .big {
  font-family: var(--font-display);
  font-size: 56px;
  color: var(--gold);
  margin: 24px 0 0;
}
.thanks p { color: var(--muted); }

.thanks section {
  margin-top: 32px;
  padding: 20px 16px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
}
.thanks h3 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 20px;
}
.thanks .share .qr-button { max-width: 240px; margin-top: 16px; }
.thanks .invited { margin: 16px 0 0; }
.thanks .invited b { color: var(--gold); font-size: 18px; }

.tg-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 16px;
  border-radius: 14px;
  background: #2aabee;
  color: #fff;
  font: 700 17px var(--font-body);
  text-decoration: none;
}
.tg-button svg { width: 22px; height: 22px; }

/* ---------- QR-экран ---------- */

.invite {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 16px;
  min-height: 100dvh;
  padding: 16px;
}

.invite .title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(22px, 7vw, 64px);
  line-height: 1.05;
  margin: 0;
}
.invite .title span { display: block; }
.invite .title .year { color: var(--gold); }

.invite .voters {
  margin-top: 16px;
  color: var(--muted);
  font-size: clamp(13px, 2.4vw, 18px);
}
.invite .voters b { color: var(--text); font-size: 1.4em; }

.qr-button {
  justify-self: center;
  width: 100%;
  /* в альбомной ориентации QR не должен вылезать по высоте */
  max-width: min(420px, calc(100dvh - 80px));
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  color: inherit;
}

.qr-frame {
  padding: 8px;
  border-radius: 20px;
  background: #fff;
  border: 3px solid var(--accent);
  animation: glow 2.2s ease-in-out infinite;
}
.qr-frame svg { display: block; width: 100%; height: auto; }

@keyframes glow {
  0%, 100% { box-shadow: 0 0 12px 2px var(--accent-glow), 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 28px 8px var(--accent-glow), 0 0 0 6px rgba(139, 92, 246, 0.15); }
}

.qr-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--accent-strong);
  font-size: clamp(12px, 2.2vw, 16px);
  font-weight: 600;
}
.qr-hint svg { width: 1.2em; height: 1.2em; }

.qr-full {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #fff;
  cursor: zoom-out;
  border: 0;
  padding: 16px;
  width: 100%;
}
.qr-full[hidden] { display: none; }
.qr-full svg { width: min(92vw, 92dvh); height: auto; }

@media (prefers-reduced-motion: reduce) {
  .qr-frame, .after { animation: none; }
}
