:root {
  --bg: #000;
  --text: #f4f3f7;
  --muted: #8e8a96;
  --line: rgba(255, 255, 255, 0.16);
  --pink: #f27ad9;
  --violet: #8f7cf2;
  --blue: #4f5fe0;
  --display: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --body: var(--display);
}

* { box-sizing: border-box; }

html { background: #0c0b10; }

html, body {
  margin: 0;
  color: var(--text);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

/* Одна мобильная колонка на всех устройствах: до 600px тянется, дальше центрируется.
   Декор (листы, стрелка) — в cqi (1cqi = 1% ширины колонки), поэтому не разъезжается.
   Вертикальные отступы и размеры ужаты через dvh — экран регистрации влезает без прокрутки. */
body {
  max-width: 600px;
  margin: 0 auto;
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
  container-type: inline-size;
}
@media (min-width: 640px) {
  body { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 0 80px rgba(0, 0, 0, 0.8); }
}

a { color: var(--pink); text-underline-offset: 2px; }

/* Фон: бумажные сгибы из макета. PNG на чёрном — фон страницы тоже строго #000 */
.bg-fold {
  position: absolute;
  pointer-events: none;
  z-index: 0;
  background-repeat: no-repeat;
}
.bg-fold-top {
  /* в top.png сверху ~2% пустого поля — поднимаем лист к краю экрана */
  top: -5px;
  right: 0;
  width: 74.7cqi;
  height: 59.2cqi;
  background-image: url('assets/top.png');
  background-size: 90.7cqi 60.5cqi;
  background-position: right -16cqi top;
}
.bg-fold-bottom {
  bottom: 0;
  left: 0;
  width: 100%;
  height: min(40cqi, 17dvh);
  background-image: url('assets/foot.png');
  background-size: cover;
  background-position: 30% top;
}
.scribble {
  position: absolute;
  z-index: 0;
  left: 26%;
  bottom: min(4.8cqi, 2dvh);
  width: min(17cqi, 8dvh);
  color: #fff;
  pointer-events: none;
}

.wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  /* снизу — место под нижний лист; верхняя часть foot.png прозрачная, поэтому отступ меньше высоты листа */
  padding: clamp(12px, 2.6dvh, 18px) 18px min(35cqi, 13dvh);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: clamp(14px, 5dvh, 40px);
}
.logo { height: 18px; display: block; }

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: fade 0.45s ease-out both; /* без transform: иначе .screen станет контейнером для absolute-выноски */
}
.screen.active { display: flex; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
}

.title {
  font-family: var(--display);
  /* «ЗАБИРАЙ ПРИЗ.» ≈ 8.1em в Inter 900 — подгоняем под ширину колонки */
  /* и не выше 6% экрана — чтобы вся форма влезала по высоте */
  font-size: min(60px, calc((100cqi - 40px) / 8.2), 6dvh);
  font-weight: 900;
  text-transform: uppercase;
  line-height: 1.24; /* меньше — бреве «Й» упирается в хвост «Д» строкой выше */
  letter-spacing: -0.03em;
  margin: 0 0 clamp(8px, 2dvh, 16px);
}
.title-sm { font-size: clamp(22px, 7cqi, 28px); line-height: 1.15; }

/* Строки заголовка выезжают по очереди */
.title span { display: inline-block; }
#screen-register.active .title span { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
#screen-register.active .title span:nth-of-type(2) { animation-delay: 0.08s; }
#screen-register.active .title span:nth-of-type(3) { animation-delay: 0.16s; }

.subtitle {
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.4;
  font-weight: 500;
  margin: 0 0 clamp(14px, 3.5dvh, 30px);
  max-width: 360px;
}
.subtitle.small { font-size: 13px; color: var(--muted); }

/* Форма */
.form {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.6dvh, 12px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(10, 10, 12, 0.85);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: clamp(8px, 1.5dvh, 11px) 16px clamp(9px, 1.7dvh, 12px);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field:focus-within {
  border-color: var(--violet);
  box-shadow: 0 0 0 4px rgba(143, 124, 242, 0.14);
}
.shake { animation: shake 0.4s; }
.field.shake { border-color: var(--pink); }
@keyframes shake {
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

.field-label {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  color: var(--text);
  font: 500 17px/1.3 var(--body);
}
.field-input::placeholder { color: #55525c; }

.field-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.25s, transform 0.25s;
}
/* Поле заполнено корректно — иконка загорается */
.field:has(.field-input:valid) .field-icon { color: var(--pink); transform: scale(1.1); }

/* Согласие на обработку ПДн */
.consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 2px 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.consent input {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(10, 10, 12, 0.85) no-repeat center / 14px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, transform 0.15s;
}
.consent input:checked {
  border-color: transparent;
  background-color: var(--pink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b0a10' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
.consent input:active { transform: scale(0.9); }
.consent input:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.consent.shake input { border-color: var(--pink); }

/* Кнопка с загнутым бумажным уголком */
.btn {
  position: relative;
  border: none;
  border-radius: 10px;
  height: clamp(48px, 8.5dvh, 60px);
  margin-top: clamp(0px, 0.8dvh, 8px);
  font: 800 18px/1 var(--display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #0b0a10;
  background: linear-gradient(95deg, var(--pink) 0%, var(--violet) 50%, var(--blue) 100%);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  clip-path: polygon(0 0, calc(100% - 26px) 0, 100% 22px, 100% 100%, 0 100%);
  transition: transform 0.15s, filter 0.2s;
}
.btn::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 26px;
  height: 22px;
  background: linear-gradient(225deg, transparent 50%, #e9e7ef 50%);
}
/* Блик, пробегающий по кнопке */
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.45) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: glint 3.5s ease-in-out 1s infinite;
  pointer-events: none;
}
@keyframes glint {
  0%, 55% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.btn > * { position: relative; }
.btn:hover { filter: brightness(1.08); }
.btn:hover .btn-arrow { transform: translate(2px, -2px); }
.btn:active { transform: scale(0.98); }
.btn:disabled { filter: grayscale(0.5) brightness(0.8); }
.btn:disabled .btn-arrow { animation: pulse 0.9s ease-in-out infinite; }
.btn:disabled::before { animation: none; }
/* arrow.svg подключена маской — цвет задаётся через background */
.btn-arrow {
  width: 24px;
  height: 24px;
  background: #fff;
  -webkit-mask: url('assets/arrow.svg') center / contain no-repeat;
  mask: url('assets/arrow.svg') center / contain no-repeat;
  transition: transform 0.2s;
}

.error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
  margin: 0 2px;
  animation: fade 0.3s;
}
.error-icon { width: 14px; height: 14px; flex-shrink: 0; margin-top: 2px; color: var(--pink); }
.hidden { display: none !important; }

.callout {
  position: absolute;
  z-index: 2;
  right: 18px;
  bottom: min(13cqi, 5.5dvh);
  background: var(--pink);
  color: #0b0a10;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.25;
  padding: 8px 12px;
  border-radius: 3px;
  transform: rotate(-8deg);
  max-width: 120px;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.6);
  animation: wobble 4s ease-in-out infinite;
}
@keyframes wobble {
  0%, 80%, 100% { transform: rotate(-8deg); }
  85% { transform: rotate(-3deg) scale(1.06); }
  90% { transform: rotate(-11deg) scale(1.06); }
  95% { transform: rotate(-6deg); }
}

/* Игровая доска — 3 билборда столбиком, влезают в экран без скролла */
.wrap:has(#screen-game.active) { padding-bottom: 24px; }
body:has(#screen-game.active) :is(.bg-fold-bottom, .scribble) { display: none; }

.board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.billboard {
  position: relative;
  display: block;
  width: min(100%, calc((100dvh - 250px) / 3 * 1.93));
  aspect-ratio: 1005 / 521;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  container-type: inline-size;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  /* наклон за курсором (десктоп), значения ставит app.js */
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.2s ease-out, opacity 0.4s;
}
.billboard:nth-child(2) { animation-delay: 0.08s; }
.billboard:nth-child(3) { animation-delay: 0.16s; }
.billboard:active .billboard-inner { transform: scale(0.97); }

.billboard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.4, 0.1, 0.2, 1);
  transform-style: preserve-3d;
}
.billboard.flipped .billboard-inner { transform: rotateY(180deg) scale(1.04); }
.billboard.flipped { z-index: 1; --rx: 0deg; --ry: 0deg; }
.prize-amt.loading { animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.billboard-face {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background-size: cover;
  background-position: center;
}

.billboard-front.bb-1 { background-image: url('assets/bilbords/1.png'); }
.billboard-front.bb-2 { background-image: url('assets/bilbords/2.png'); }
.billboard-front.bb-3 { background-image: url('assets/bilbords/3.png'); }

/* Блик по билбордам по очереди — подсказка, что их можно нажать */
.billboard-front::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.16) 50%, transparent 60%);
  transform: translateX(-100%);
  animation: glint 3s ease-in-out infinite;
}
.billboard:nth-child(2) .billboard-front::after { animation-delay: 0.35s; }
.billboard:nth-child(3) .billboard-front::after { animation-delay: 0.7s; }
.board.locked .billboard-front::after { animation: none; }

.billboard-back {
  background-image: url('assets/bilbords/win.png');
  transform: rotateY(180deg);
  display: flex;
  align-items: flex-start;
  padding: 10% 8% 0;
}
/* Выигрышный щит «включает подсветку»: вспышка яркости + один блик по экрану */
.billboard.flipped .billboard-back { animation: lit 1.1s ease-out 0.55s both; }
.billboard.flipped .billboard-back::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.35) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: sweep 0.9s ease-in-out 0.75s forwards;
}
@keyframes lit {
  0% { filter: brightness(0.35); }
  30% { filter: brightness(1.35); }
  45% { filter: brightness(0.8); }
  60%, 100% { filter: brightness(1); }
}
@keyframes sweep { to { transform: translateX(100%); } }
.billboard-back .prize-amt {
  font: 900 22px/1 var(--display);
  font-size: 9cqi;
  letter-spacing: -0.02em;
  color: #fff;
}

.board.locked .billboard { pointer-events: none; }
.board.locked .billboard:not(.flipped) { opacity: 0.3; transform: scale(0.96); }

/* Экран результата */
#screen-result { justify-content: center; }
.result-greeting { margin-bottom: 22px; }
#screen-result.active .result-card { animation: pop 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.2) 0.1s both; }
@keyframes pop { from { opacity: 0; transform: scale(0.9) translateY(10px); } }

.result-card {
  aspect-ratio: 1005 / 521;
  border-radius: 10px;
  overflow: hidden;
  background: url('assets/bilbords/win.png') center / cover;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 9% 9% 0;
  margin-bottom: 22px;
  box-shadow: 0 20px 50px -20px rgba(143, 124, 242, 0.6);
  container-type: inline-size;
}

.result-tag {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: max(10px, 2.9cqi);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.result-amount {
  font: 900 11cqi/1 var(--display);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
  margin-bottom: 8px;
  background: linear-gradient(95deg, #fff 30%, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result-label {
  font-size: max(12px, 3.5cqi);
  line-height: 1.35;
  color: #d9d6e0;
  max-width: 60%;
}

/* Страница политики конфиденциальности */
.doc .wrap { padding-bottom: 48px; }
.doc .title-sm { margin-bottom: 24px; }
.doc h2 {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  margin: 32px 0 12px;
}
.doc h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 24px 0 8px;
}
.doc p, .doc li {
  font-size: 14px;
  line-height: 1.55;
  color: #cfccd6;
}
.doc p { margin: 0 0 10px; }
.doc ul { margin: 0 0 12px; padding-left: 20px; }
.doc li { margin-bottom: 6px; }
.doc li::marker { color: var(--pink); }
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.back svg { width: 18px; height: 18px; transform: rotate(-135deg); }

/* Невысокие телефоны: ужимаем текст, чтобы форма влезала в экран целиком */
@media (max-width: 727px) and (max-height: 700px) {
  .subtitle { font-size: 13px; line-height: 1.35; }
  .consent { font-size: 11px; }
  .callout { font-size: 11px; padding: 6px 10px; max-width: 110px; }
}
/* Совсем низкие (iPhone SE и т.п.): стикеру и стрелке нет места рядом с кнопкой */
@media (max-width: 727px) and (max-height: 600px) {
  .callout, .scribble { display: none; }
}

/* Планшеты и десктоп (от 728px): колонка 600px, всё крупнее. Ниже 728px — обычные телефонные размеры. */
@media (min-width: 728px) {
  .wrap { padding-left: 30px; padding-right: 30px; }
  .topbar { margin-bottom: clamp(20px, 5dvh, 56px); }
  .logo { height: 24px; }
  .title-sm { font-size: 38px; }
  .subtitle { font-size: 18px; max-width: 470px; }
  .subtitle.small { font-size: 16px; }
  .field { padding: clamp(10px, 1.5dvh, 15px) 18px clamp(11px, 1.6dvh, 16px); }
  .field-label { font-size: 12px; }
  .field-input { font-size: 20px; }
  .consent { font-size: 14px; }
  .btn { height: clamp(52px, 8.5dvh, 72px); }
  .btn-arrow { width: 30px; height: 30px; }
  .error { font-size: 15px; }
  .callout { right: 30px; font-size: 15px; max-width: 190px; }
  .doc h2 { font-size: 20px; }
  .doc h3 { font-size: 17px; }
  .doc p, .doc li { font-size: 16px; }
}

/* Телефон боком: билборды в ряд, иначе по высоте они крошечные */
@media (orientation: landscape) and (max-height: 520px) {
  .board { flex-direction: row; }
  .billboard { width: auto; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
