:root {
  --bg0: #07131a;
  --bg1: #0d2430;
  --bg2: #143445;
  --ink: #e8f2f4;
  --muted: #8fadb8;
  --line: rgba(232, 242, 244, 0.12);
  --accent: #d4a35c;
  --accent-2: #3ec6b0;
  --danger: #e07a6a;
  --ok: #6fbf8a;
  --card: rgba(13, 36, 48, 0.78);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(62, 198, 176, 0.18), transparent 55%),
    radial-gradient(900px 600px at 100% 0%, rgba(212, 163, 92, 0.16), transparent 50%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 45%, #091820);
  background-attachment: fixed;
}

body {
  overflow-x: hidden;
}

#app {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

/* Широкий контейнер только на экране результата (не на главной/форме) */
#app:has(.screen[data-screen="RESULT"].is-active),
#app:has(.screen[data-screen="ROUTE"].is-active) {
  width: min(1200px, calc(100% - 1.5rem));
  padding-top: 1.25rem;
  padding-bottom: 2.5rem;
}

.screen {
  display: none;
  animation: fadeIn 0.45s ease;
}

.screen.is-active {
  display: block;
}

/* Важно: в Telegram WebView атрибут hidden без !important
   проигрывает правилам вроде .share-box { display: flex }. */
[hidden] {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.wizard-panel {
  max-width: 36rem;
  margin: 0 auto;
}

.wizard-head {
  margin-bottom: 1.25rem;
}

.wizard-eyebrow {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.wizard-progress {
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.wizard-progress-fill {
  height: 100%;
  width: 25%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.wizard-step[hidden] {
  display: none !important;
}

.result-qr-panel.share-box[hidden],
.map-share[hidden],
#btn-open-map[hidden] {
  display: none !important;
}

.wizard-nav {
  justify-content: flex-end;
}

.wizard-nav .btn-ghost {
  margin-right: auto;
}

.city-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.5rem;
}

.city-option {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(7, 19, 26, 0.45);
  color: var(--ink);
  padding: 0.95rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.city-option:hover {
  border-color: rgba(224, 185, 120, 0.45);
}

.city-option.is-on {
  border-color: var(--accent);
  background: rgba(224, 185, 120, 0.12);
  box-shadow: inset 0 0 0 1px rgba(224, 185, 120, 0.25);
}

.city-option:active {
  transform: scale(0.99);
}

.hero-panel,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: clamp(1.25rem, 3vw, 2rem);
}

.eyebrow {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--accent-2);
  margin: 0 0 0.75rem;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 520;
  line-height: 1.15;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(1.9rem, 5vw, 3rem);
}

h2 {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
}

.lead {
  color: var(--muted);
  margin: 0 0 1.5rem;
  max-width: 40rem;
  line-height: 1.55;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.4rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(120deg, var(--accent), #e0b978);
  color: #1a1208;
}

.btn-primary:disabled,
.btn-primary.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

label {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 0.4rem;
  color: var(--ink);
}

.field {
  margin-bottom: 1.1rem;
}

input[type="number"],
input[type="text"],
textarea,
select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(7, 19, 26, 0.55);
  color: var(--ink);
  padding: 0.85rem 1rem;
  font: inherit;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(62, 198, 176, 0.45);
  outline-offset: 1px;
}

.city-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(62, 198, 176, 0.12);
  border: 1px solid rgba(62, 198, 176, 0.35);
  color: var(--accent-2);
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.seg button {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(7, 19, 26, 0.4);
  color: var(--ink);
  padding: 0.8rem;
  font: inherit;
  cursor: pointer;
}

.seg button.is-on {
  border-color: rgba(212, 163, 92, 0.7);
  background: rgba(212, 163, 92, 0.16);
}

.places {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.place-tag {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0.45rem 0.8rem;
  font: inherit;
  cursor: pointer;
}

.place-tag.is-on {
  background: rgba(62, 198, 176, 0.18);
  border-color: rgba(62, 198, 176, 0.55);
}

.field-inline label {
  margin-bottom: 0.35rem;
}

.count-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}

.people-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 220px;
}

.people-row select {
  flex: 0 0 auto;
  width: auto;
  min-width: 5.5rem;
  max-width: 8rem;
  padding: 0.45rem 0.65rem;
  font-size: 0.9rem;
}

.people-row input[type="number"] {
  width: 4.75rem;
  flex: 0 0 auto;
  padding: 0.45rem 0.55rem;
  font-size: 0.9rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip-row .place-tag {
  font-size: 0.9rem;
  padding: 0.4rem 0.75rem;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
}

/* Generation */
.gen-wrap {
  text-align: center;
  padding: 1rem 0 0.5rem;
}

.orbit {
  width: min(220px, 56vw);
  height: min(220px, 56vw);
  margin: 0.5rem auto 1.5rem;
  position: relative;
}

.orbit-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--accent-2);
  border-right-color: rgba(212, 163, 92, 0.55);
  animation: spin 1.4s linear infinite;
}

.orbit-core {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #7ad9cb, transparent 35%),
    radial-gradient(circle at 70% 65%, #1c5a6a, #0b2a36 70%);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.35), 0 0 40px rgba(62, 198, 176, 0.2);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
}

.fact-box {
  min-height: 5.5rem;
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(7, 19, 26, 0.45);
  text-align: left;
}

.fact-label {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.5rem;
}

.fact-text {
  margin: 0;
  line-height: 1.55;
  color: var(--ink);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.fact-text.is-out {
  opacity: 0;
  transform: translateY(6px);
}

/* Countdown */
.countdown {
  min-height: 50vh;
  display: grid;
  place-items: center;
  text-align: center;
}

.countdown-num {
  font-family: var(--font-display);
  font-size: clamp(5rem, 22vw, 10rem);
  line-height: 1;
  color: var(--accent);
  animation: countPop 0.7s ease;
  text-shadow: 0 0 40px rgba(212, 163, 92, 0.35);
}

@keyframes countPop {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Result */
.result-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 0 0 1rem;
}

.result-image-wrap {
  margin: 0 0 1.25rem;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #061016;
  aspect-ratio: 16 / 10;
  position: relative;
}

.result-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.result-image-wrap .img-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.route-body {
  font-family: var(--font-body);
  font-size: clamp(0.92rem, 0.25vw + 0.88rem, 1.05rem);
  font-weight: 400;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 1rem;
}

.route-body strong.route-day {
  font-weight: 700;
  color: var(--accent);
}

.route-body strong.route-point {
  font-weight: 700;
  color: var(--ink);
}

.result-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.result-main-panel {
  min-width: 0;
}

.result-qr-panel.share-box {
  margin: 0 auto;
  text-align: center;
  padding-bottom: clamp(1.75rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(370px, 100%);
  max-width: 370px;
  min-width: min(350px, 100%);
  box-sizing: border-box;
}

@media (min-width: 768px) {
  #app:has(.screen[data-screen="RESULT"].is-active),
  #app:has(.screen[data-screen="ROUTE"].is-active) {
    width: min(1480px, calc(100% - 2.5rem));
  }

  .result-image-wrap {
    aspect-ratio: 2 / 1;
  }

  .route-body {
    line-height: 1.62;
  }

  .panel.result-main-panel {
    padding: clamp(1.5rem, 2.2vw, 2.5rem);
  }

  .panel.result-qr-panel {
    padding: clamp(1.5rem, 2vw, 2rem);
    padding-bottom: clamp(2rem, 3vw, 2.75rem);
  }
}

@media (min-width: 900px), (min-width: 720px) and (orientation: landscape) {
  .result-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 1.5rem;
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .result-main-panel {
    flex: 1 1 auto;
    min-width: 0;
  }

  .result-qr-panel {
    flex: 0 0 clamp(350px, 22vw, 370px);
    width: clamp(350px, 22vw, 370px);
    max-width: 370px;
    min-width: 350px;
    position: sticky;
    top: 1rem;
    align-self: flex-start;
    overflow: visible;
    margin-left: 0;
    margin-right: 0;
  }
}

@media (min-width: 1024px) {
  #app:has(.screen[data-screen="RESULT"].is-active),
  #app:has(.screen[data-screen="ROUTE"].is-active) {
    width: min(1680px, calc(100% - 3rem));
  }

  .result-layout {
    gap: 1.75rem;
  }
}

@media (min-width: 1200px) {
  #app:has(.screen[data-screen="RESULT"].is-active),
  #app:has(.screen[data-screen="ROUTE"].is-active) {
    width: min(1840px, 96vw);
  }

  .result-layout {
    gap: 2rem;
  }

  .result-title {
    font-size: clamp(2rem, 2.2vw, 2.6rem);
  }

  .result-qr-panel {
    flex-basis: 360px;
    width: 360px;
  }
}

@media (min-width: 1600px) {
  #app:has(.screen[data-screen="RESULT"].is-active),
  #app:has(.screen[data-screen="ROUTE"].is-active) {
    width: min(1920px, 97vw);
  }
}

.disclaimer {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.share-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.share-box {
  text-align: center;
}

.share-ready {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--ink);
  width: 100%;
  text-align: center;
}

.qr-hint {
  margin: 0.75rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  width: 100%;
  max-width: 100%;
  text-align: center;
}

.qr-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  max-width: 100%;
  margin: 0 auto 0.35rem;
}

.qr-canvas-wrap {
  box-sizing: border-box;
  width: min(240px, 100%);
  max-width: 260px;
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 0.85rem;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 14px;
  line-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-canvas-wrap canvas,
.qr-canvas-wrap img,
.qr-canvas-wrap svg {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  max-width: 100%;
  aspect-ratio: 1;
  image-rendering: pixelated;
  margin: 0 auto;
}

.qr-error {
  margin: 0;
  max-width: 280px;
  color: #f0c2ba;
  font-size: 0.88rem;
  line-height: 1.45;
}

.share-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  margin-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.share-actions .btn {
  width: 100%;
  box-sizing: border-box;
}

.share-actions .btn-primary {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.map-share {
  width: 100%;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.map-share-title {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
  text-align: center;
  width: 100%;
}

.map-qr-hint {
  margin-top: 0.65rem;
  margin-bottom: 0.85rem;
}

.share-row input {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  padding: 0.55rem 0.7rem;
}

.error-box {
  border-color: rgba(224, 122, 106, 0.45);
}

.error-box p {
  color: #f0c2ba;
}

@media (max-width: 640px) {
  #app {
    width: calc(100% - 1.25rem);
    padding-top: 1.25rem;
  }

  .count-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
  }

  .btn-row {
    flex-direction: column;
  }
}
