:root {
  color-scheme: dark;
  --bg: linear-gradient(180deg, #1c1c1c 0%, #54081b 100%);
  --text: #fff;
  --button: #fff;
  --button-text: #2d161c;
  --muted: #c8b6bb;
  --accent: #dc143c;
  --radius: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: #1c1c1c;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 280px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 18px;
  line-height: 1.45;
}

button, input, textarea, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; }

.main {
  display: none;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(20px + var(--safe-top)) max(16px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(16px, var(--safe-left));
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--bg);
}

.main.is-active { display: flex; }

.header {
  width: min(100%, 560px);
  text-align: center;
}

.header h1, .header h2, .header h3, .header p { margin: 0; }
.header h1 { font-size: clamp(22px, 6vw, 30px); line-height: 1.25; }
.header h2 { font-size: clamp(22px, 6vw, 28px); line-height: 1.2; }
.header h3 { font-size: clamp(20px, 5.5vw, 26px); line-height: 1.25; }
.header p { margin-top: 12px; }

.collage-block {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, 560px);
  height: clamp(310px, 57dvh, 620px);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.collage__image { min-width: 0; min-height: 0; }
.collage__image img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); }

.image-block {
  width: min(100%, 560px);
  min-height: 280px;
  flex: 1 1 auto;
  overflow: hidden;
  border-radius: var(--radius);
}

.image-block img { width: 100%; height: 100%; min-height: 280px; object-fit: cover; }

.buttons-block {
  display: flex;
  width: min(100%, 560px);
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.button {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 58px;
  padding: 12px 18px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: var(--button);
  color: var(--button-text);
  font-weight: 700;
  cursor: pointer;
}

.button--start { padding-right: 62px; }
.button--start::after {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(145deg, #800000, var(--accent));
  content: url("../images/arrow.svg");
  line-height: 42px;
  transform: translateY(-50%);
}

.button--no { border: 2px solid #e2aba7; background: transparent; color: #fff; }
.button--skip { min-height: 40px; background: transparent; color: #b8aeb1; }
.button:disabled { background: #858585; color: #eee; cursor: not-allowed; opacity: .8; }
.buttons-block--grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }

.question-page, .final-page { padding: 0; gap: 0; justify-content: flex-start; }

.question-photo, .final-photo {
  width: 100%;
  height: clamp(300px, 58vh, 650px);
  height: clamp(300px, 58dvh, 650px);
  min-height: 300px;
  overflow: hidden;
  background: #eee;
}

.question-photo img, .final-photo img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }

.question-panel, .final-panel {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  margin-top: -20px;
  padding: 24px max(16px, var(--safe-right)) calc(24px + var(--safe-bottom)) max(16px, var(--safe-left));
  flex-direction: column;
  align-items: center;
  gap: 26px;
  border-radius: 20px 20px 0 0;
  background: var(--bg);
  box-shadow: 0 -20px 36px rgb(23 23 23 / 55%);
}

.header--question p { font-size: clamp(16px, 4.4vw, 19px); }

.choice-page { justify-content: flex-start; }
.header--choose p { color: #e2cbd1; font-size: 15px; font-style: italic; }

.choose-block { width: min(100%, 560px); }

.choose-block--cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choose-block--cards .choose-item:nth-child(3) { grid-column: 1 / -1; width: calc(50% - 6px); justify-self: center; }

.choose-item {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  background: #fff;
  color: #111;
  box-shadow: 0 2px 10px rgb(140 140 140 / 30%);
  cursor: pointer;
}

.choose-item::after {
  position: absolute;
  inset: 0;
  border: 0 solid var(--accent);
  border-radius: inherit;
  content: "";
  pointer-events: none;
  transition: border-width .16s ease;
}

.choose-item--active::after { border-width: 4px; }
.choose-item span { display: block; padding: 7px 4px; font-weight: 600; }
.choose__image { width: 100%; aspect-ratio: 1.45 / 1; object-fit: cover; }

.choose-block--distance {
  display: grid;
  grid-template-columns: 42% 1fr;
  gap: 9px;
  align-items: stretch;
}

.choose__image--big {
  grid-row: 1 / span 5;
  width: 100%;
  height: 100%;
  min-height: 305px;
  border-radius: var(--radius);
  object-fit: cover;
}

.choose-item--row { display: flex; min-height: 52px; align-items: center; justify-content: center; border: 1px solid #b3b3b3; box-shadow: none; }
.choose-item--row span { padding: 8px 10px; font-size: 16px; line-height: 1.2; }

.final-panel { gap: 24px; }
.header--final p { font-size: clamp(16px, 4.5vw, 19px); }
.button--download { width: min(100%, 560px); }

@media (max-height: 700px) {
  .main { gap: 13px; padding-top: calc(14px + var(--safe-top)); }
  .collage-block { height: 350px; }
  .header p { margin-top: 8px; }
  .question-photo, .final-photo { height: 340px; }
  .question-panel, .final-panel { gap: 18px; padding-top: 20px; }
  .choose-block--cards { gap: 9px; }
  .choose__image { aspect-ratio: 1.8 / 1; }
  .choose-item span { padding: 4px; font-size: 15px; }
}

@media (max-width: 340px) {
  body { font-size: 16px; }
  .main { padding-right: max(10px, var(--safe-right)); padding-left: max(10px, var(--safe-left)); }
  .choose-block--distance { grid-template-columns: 39% 1fr; }
  .choose-item--row span { font-size: 14px; }
}

@media (min-width: 881px) {
  .main { max-width: 1120px; padding-right: 34px; padding-left: 34px; }
  .page-1, .page-2, .choice-page { justify-content: center; }
  .question-page, .final-page {
    display: none;
    max-width: 1120px;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 30px;
    flex-direction: row;
    align-items: stretch;
  }
  .question-page.is-active, .final-page.is-active { display: flex; }
  .question-photo, .final-photo { width: 54%; height: auto; min-height: calc(100vh - 60px); border-radius: 14px; }
  .question-panel, .final-panel { width: 46%; margin: 0; justify-content: center; border-radius: 0 14px 14px 0; box-shadow: none; }
}

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