:root {
  color-scheme: dark;
  --bg: #0f111a;
  --surface: #1c2030;
  --surface-strong: #171d24;
  --surface-dark: #171d24;
  --line: #252b32;
  --line-active: rgba(71, 60, 250, 0.72);
  --text: #ffffff;
  --muted: #a7afb7;
  --accent: #473cfa;
  --accent-strong: #473cfa;
  --accent-ink: #ffffff;
  --success: #48ff91;
  --danger: #ec504e;
  --radius-lg: 24px;
  --radius-md: 8px;
  font-family: "Roboto", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  height: 100vh;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button, input { font: inherit; }

.page-shell {
  display: flex;
  flex-direction: column;
  width: min(1120px, calc(100% - 48px));
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}

.hero {
  flex: 0 0 auto;
  padding: clamp(14px, 4.5vh, 48px) 0 clamp(16px, 3.8vh, 38px);
}

.hero__top {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: clamp(24px, 3vw, 38px);
  align-items: center;
}

.logo-placeholder {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1920 / 346;
  object-fit: contain;
}

.hero h1 {
  max-width: 790px;
  margin: 0;
  font-size: calc(clamp(38px, min(6vw, 8vh), 72px) - 4px);
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.hero p {
  max-width: 520px;
  margin: clamp(10px, 1.8vh, 18px) 0 0;
  color: var(--muted);
  font-size: clamp(12px, 1.6vh, 15px);
  line-height: 1.5;
}

.form-card {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.form-card__header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: clamp(15px, 2.4vh, 24px) 34px clamp(13px, 2vh, 20px);
  border-bottom: 1px solid var(--line);
}

.form-card h2 {
  margin: 5px 0 0;
  font-size: clamp(17px, 2.5vh, 22px);
  font-weight: 500;
  letter-spacing: -0.025em;
}

.progress { color: var(--accent); font-size: 14px; font-weight: 700; }
.progress__muted { color: var(--muted); }

.fields-grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(0, 1fr));
  grid-auto-flow: column;
  gap: clamp(7px, 1.3vh, 12px);
  min-height: 0;
  padding: clamp(12px, 2vh, 22px) 34px;
}

#telegram-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

.field {
  position: relative;
  display: flex;
  align-self: center;
  align-items: center;
  height: 60%;
  min-height: 0;
  padding: clamp(7px, 1.2vh, 11px) 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.field:focus-within {
  border-color: var(--line-active);
  background: var(--surface-dark);
  transform: translateY(-1px);
}

.field.field--error {
  border-color: var(--danger);
}

.field.field--error .field__number {
  color: var(--danger);
}

.field__number {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(27px, 4vh, 34px);
  height: 100%;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
  transform: none;
  transition: color 160ms ease, background-color 160ms ease;
}

.field:focus-within .field__number,
.field--filled .field__number { background: transparent; color: var(--accent); }

.field input {
  width: 100%;
  height: 100%;
  min-height: 27px;
  max-height: 100%;
  border: 0;
  padding-left: 47px;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: normal;
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex: 0 0 auto;
  padding: clamp(10px, 1.7vh, 17px) 34px;
  border-top: 1px solid var(--line);
  background: var(--surface-strong);
}

.button {
  min-height: clamp(40px, 5.5vh, 46px);
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: transform 160ms ease, opacity 160ms ease, background-color 160ms ease;
}

.button:not(:disabled):active { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: 0.35; }

.button--ghost { background: transparent; color: var(--muted); }
.button--ghost:not(:disabled):hover { background: var(--surface-dark); color: var(--text); }

.button--primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(228px, 28vw);
  min-width: min(228px, 28vw);
  padding: 0 36px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  opacity: 0.35;
}

.button--primary.button--ready {
  opacity: 1;
}

.button--primary.button--ready:hover {
  background: var(--accent-strong);
  box-shadow: 0 8px 24px rgba(71, 60, 250, 0.24);
  transform: translateY(-1px);
}

.button--primary:not(.button--ready):active {
  transform: none;
}

.toast {
  position: fixed;
  right: 28px;
  bottom: 28px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 17px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-dark);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transform: translateY(15px);
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast--visible { opacity: 1; transform: translateY(0); }
.toast__icon { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 8px; background: rgba(72, 255, 145, 0.14); }
.toast__icon svg { width: 15px; fill: none; stroke: var(--success); stroke-width: 2.2; }

.toast--error .toast__icon { background: rgba(236, 80, 78, 0.14); }
.toast--error .toast__icon svg { stroke: var(--danger); }

@media (max-width: 720px) {
  .page-shell { width: min(100% - 28px, 620px); }
  .hero { padding: clamp(8px, 2vh, 18px) 2px clamp(10px, 2.2vh, 20px); }
  .hero__top {
    grid-template-columns: 1fr;
    gap: clamp(8px, 1.5vh, 12px);
  }
  .hero h1 { font-size: calc(clamp(32px, min(10vw, 6.2vh), 48px) - 4px); }
  .form-card { flex: 0 0 auto; }
  #telegram-form { flex: 0 0 auto; }
  .fields-grid {
    flex: 0 0 auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(6, clamp(38px, 6vh, 68px));
    column-gap: 7px;
    row-gap: clamp(8px, 2vh, 26px);
    padding: 10px 12px;
  }
  .form-card__header { padding: 12px 14px 10px; }
  .form-footer { padding: 9px 12px; }
  .field { height: 100%; padding: 6px 7px; }
  .field__number { left: 7px; }
  .field input { padding-left: 35px; font-size: 14px; }
}

@media (max-width: 460px) {
  .hero p { max-width: 340px; font-size: 11px; }
  .form-footer { flex-direction: row; }
  .button { justify-content: center; min-height: 38px; padding: 0 12px; }
  .button--ghost { flex: 0 0 auto; }
  .button--primary {
    flex: 0 1 67%;
    width: min(228px, 67%);
    min-width: min(180px, 67%);
    padding: 0 20px;
    font-size: 15px;
  }
  .toast { right: 14px; bottom: 14px; left: 14px; }
}

@media (max-height: 720px) {
  .hero p { display: none; }
  .hero h1 br { display: none; }
  .form-card h2 { margin-top: 0; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .hero { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 8px; }
  .hero h1 { margin: 0; font-size: 20px; }
  .form-card__header { display: none; }
  .fields-grid {
    grid-template-rows: repeat(6, 30px);
    row-gap: 5px;
  }
}

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