:root {
  --white: #fff;
  --grey-100: #f8f9fc;
  --grey-200: #ebeef3;
  --grey-300: #d2d7e3;
  --grey-500: #8c94a5;
  --grey-600: #5e6675;
  --grey-700: #474d5a;
  --grey-800: #2a2d32;
  /* Secondary copy color — meets WCAG AA (4.5:1 on white) even at 12px. */
  --text-secondary: #5e6675;
  --brand-primary: rgb(114, 101, 227);
  --focus-ring: rgba(114, 101, 227, 0.45);
  --color-social-alpha: #ef3124;
  --spacer-8: 8px;
  --spacer-16: 16px;
  --spacer-24: 24px;
  --spacer-32: 32px;
  --spacer-48: 48px;
}

* { box-sizing: border-box; }

/* Visible keyboard-focus indicator for every interactive control. Mouse clicks
 * (which don't match :focus-visible) stay ring-free. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Visually hidden but exposed to assistive tech (labels, status text). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--grey-800);
  background: var(--white);
}

.layout {
  padding: var(--spacer-24);
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  margin: auto;
}

.card {
  width: 1000px;
  max-width: 100%;
  min-height: 398px;
  background: var(--white);
  border: 1px solid var(--grey-200);
  box-shadow:
    0 8px 28px -6px rgba(115, 133, 168, 0.12),
    0 18px 88px -4px rgba(115, 133, 168, 0.16);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
}

.cover {
  width: 50%;
  background: var(--grey-100);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover img,
.cover svg {
  max-width: 80%;
  height: auto;
}

.content {
  width: 50%;
  padding: var(--spacer-48) 56px 40px;
  position: relative;
}

.arrow-back {
  position: absolute;
  top: var(--spacer-16);
  left: var(--spacer-16);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--grey-100);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .12s ease-in-out;
  --app-icon-color: var(--grey-500);
}
.arrow-back:hover { background: var(--grey-200); }
.arrow-back svg { width: 20px; height: 20px; }

.wrapper {
  min-height: 450px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.wrapper-centered {
  justify-content: center;
}

.logo { margin-bottom: var(--spacer-16); }
.logo svg { width: 60px; height: 60px; }

.title {
  font-size: 20px;
  line-height: 26px;
  font-weight: 500;
  color: var(--grey-800);
  margin-bottom: var(--spacer-16);
}

.title-step {
  font-size: 18px;
  line-height: 24px;
  font-weight: 500;
  color: var(--grey-800);
  margin-bottom: var(--spacer-16);
}

.img-content {
  display: none;
  justify-content: center;
  margin-bottom: var(--spacer-24);
}
.img-content > img,
.img-content > svg {
  height: 234px;
  width: 100%;
}

.policy {
  margin-top: var(--spacer-16);
  font-size: 12px;
  line-height: 16px;
  color: var(--text-secondary);
}
.policy a {
  color: var(--text-secondary);
  text-decoration: underline;
}
.policy a:hover { color: var(--grey-700); }

.consent {
  margin-top: var(--spacer-16);
  margin-bottom: var(--spacer-16);
  display: flex;
  flex-direction: column;
  gap: var(--spacer-8);
  text-align: left;
}
.consent-item {
  display: flex;
  align-items: flex-start;
  gap: var(--spacer-8);
  font-size: 13px;
  line-height: 18px;
  color: var(--grey-800);
  cursor: pointer;
}
.consent-item input[type="checkbox"] {
  margin-top: 2px;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.consent-item a {
  color: var(--grey-800);
  text-decoration: underline;
}

.subtitle {
  font-size: 15px;
  line-height: 20px;
  color: var(--text-secondary);
  margin-bottom: var(--spacer-32);
  word-break: break-all;
}

.subtitle-text {
  word-break: normal;
  overflow-wrap: break-word;
}

.altcha {
  width: 100%;
  margin-bottom: var(--spacer-24);
  display: flex;
  justify-content: center;
}

.btn {
  width: 100%;
  padding: 14px var(--spacer-24);
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
  transition: background-color .12s ease-in-out;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--spacer-8);
  position: relative;
  text-decoration: none;
}

.btn:last-child { margin-bottom: 0; }

/* VK ID One Tap mount point — the SDK renders its button at container width,
 * so the container mirrors .btn's column behavior. */
#vkid-one-tap {
  width: 100%;
  max-width: 100%;
  margin-bottom: var(--spacer-8);
}

.i-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  position: absolute;
  left: var(--spacer-16);
  top: 50%;
  transform: translateY(-50%);
}

.btn-alfa {
  background: var(--color-social-alpha);
  color: var(--white);
}
.btn-alfa:hover { background: #d62a1e; }
.btn-alfa:active { background: #be251a; }
.btn-alfa:disabled { background: var(--grey-300); cursor: not-allowed; }

.btn-telegram {
  background: #37aee2;
  color: var(--white);
  --app-icon-color: var(--white);
}

.btn-call {
  background: var(--grey-100);
  color: var(--grey-800);
  --app-icon-color: var(--grey-500);
}
.btn-call:hover { background: var(--grey-200); }
.btn-call:active { background: var(--grey-300); }
.btn-call:disabled { background: var(--grey-100); color: var(--grey-300); cursor: not-allowed; --app-icon-color: var(--grey-300); }
.btn-telegram:hover { background: #2c8db5; }
.btn-telegram:active { background: #246f8e; }
.btn-telegram:disabled { background: var(--grey-300); cursor: not-allowed; }

.btn-continue {
  background: rgb(114, 101, 227);
  color: var(--white);
  max-width: none;
}
.btn-continue:hover { background: rgb(94, 82, 207); }
.btn-continue:active { background: rgb(78, 67, 184); }
.btn-continue:disabled { background: var(--grey-300); cursor: not-allowed; }

.input-field {
  display: block;
  width: 100%;
  padding: 14px var(--spacer-24);
  border: 1px solid var(--grey-300);
  border-radius: 12px;
  font-family: inherit;
  font-size: 16px;
  line-height: 20px;
  color: var(--grey-800);
  background: var(--white);
  margin-bottom: var(--spacer-16);
  transition: border-color .12s ease-in-out, box-shadow .12s ease-in-out;
}

.input-field::placeholder { color: var(--grey-500); }

.input-field:hover { border-color: var(--grey-500); }

.input-field:focus {
  outline: none;
  border-color: rgb(114, 101, 227);
  box-shadow: 0 0 0 3px rgba(114, 101, 227, 0.15);
}

.input-field:disabled {
  background: var(--grey-100);
  color: var(--grey-500);
  cursor: not-allowed;
}

.countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-bottom: var(--spacer-16);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
  font-weight: 500;
  color: var(--grey-800);
}

.countdown-block {
  background: var(--grey-100);
  border-radius: 8px;
  padding: 6px 12px;
  min-width: 44px;
  text-align: center;
}

.countdown-sep {
  font-weight: 500;
  color: var(--grey-500);
}

.telegram-pending {
  margin-top: var(--spacer-24);
  text-align: center;
  width: 100%;
}

.telegram-pending-title {
  margin: 0 0 var(--spacer-16);
  font-size: 16px;
  font-weight: 500;
  color: var(--grey-800);
}

.telegram-pending-description {
  margin: 0 0 var(--spacer-16);
}

.error {
  margin-top: var(--spacer-16);
  color: var(--color-social-alpha);
  font-size: 13px;
  line-height: 16px;
  white-space: pre-wrap;
}

/*
 * Signup form layout — label-above-input, fields stacked, text-align: left
 * (matches game-pages register form). Used by signin-signup.html.
 */
.form-signup {
  width: 100%;
  max-width: 360px;
  text-align: left;
}

.field {
  margin-bottom: var(--spacer-16);
}

.field-label {
  display: block;
  margin-bottom: var(--spacer-8);
  color: var(--grey-800);
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
}

.field-error {
  margin-top: var(--spacer-8);
  color: var(--color-social-alpha);
  font-size: 12px;
  line-height: 16px;
  min-height: 16px;
}

.field .input-field {
  margin-bottom: 0;
  max-width: 100%;
}

/* Native <select> styled to match .input-field, with a custom chevron */
select.input-field {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'><path d='M5 8l5 5 5-5' stroke='%238c94a5' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--spacer-16) center;
  background-size: 20px 20px;
  padding-right: 44px;
  cursor: pointer;
}

/* Narrow single-column variant — used by /signup form (no `cover` image alongside). */
.card-narrow {
  width: 440px;
  max-width: 100%;
}

.content-narrow {
  width: 100%;
  padding: var(--spacer-32) var(--spacer-32) var(--spacer-24);
}

.form-note {
  margin: var(--spacer-8) 0 var(--spacer-24);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 16px;
  text-align: left;
}

/*
 * tel:-link card used by the OUTGOING_CALL verify branch — the user dials the displayed
 * toll-free number from their phone; sms-gate detects the incoming call and confirms.
 */
.tel-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--spacer-16) var(--spacer-24);
  margin-bottom: var(--spacer-16);
  background: var(--grey-100);
  border: 1px solid var(--grey-200);
  border-radius: 12px;
  text-decoration: none;
  color: var(--grey-800);
  transition: background-color .12s ease-in-out;
}

.tel-link:hover { background: var(--grey-200); }
.tel-link:active { background: var(--grey-300); }

.tel-link-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
}

.tel-link-number {
  font-size: 18px;
  font-weight: 500;
  line-height: 22px;
}

.tel-link-caption {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-secondary);
}

.tel-link-icon {
  width: 24px;
  height: 24px;
  color: var(--grey-500);
  flex-shrink: 0;
}

/* Loader + success state shown in place of the form during submission.
 * `display: flex` would override the user-agent `[hidden] { display: none }` rule,
 * so we re-assert it explicitly. */
.signup-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacer-16);
  padding: var(--spacer-32) 0;
}

.signup-state[hidden] {
  display: none;
}

.signup-state-text {
  font-size: 16px;
  line-height: 22px;
  color: var(--grey-800);
}

.signup-state-hint {
  font-size: 14px;
  line-height: 18px;
  color: var(--text-secondary);
  margin-top: calc(-1 * var(--spacer-8));
}

.signup-state-icon svg { width: 56px; height: 56px; }

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--grey-200);
  border-top-color: rgb(114, 101, 227);
  border-radius: 50%;
  animation: spinner-rotate 0.9s linear infinite;
}

@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

.btn--loading {
  pointer-events: none;
}
.btn--loading > * { visibility: hidden; }
.btn--loading::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 50%;
  margin-top: -9px;
  margin-left: -9px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spinner-rotate 0.7s linear infinite;
}
.btn-call.btn--loading::after {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: var(--grey-500);
}

@media (max-width: 768px) {
  .content-narrow {
    padding: var(--spacer-24) var(--spacer-16);
  }
}

.error-code {
  margin: 0;
  padding: var(--spacer-8) var(--spacer-16);
  background: var(--grey-100);
  border-radius: 8px;
  color: var(--grey-500);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 16px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

#back-to-source-button {
  margin-top: var(--spacer-24);
}

@media (max-width: 768px) {
  .layout {
    padding: var(--spacer-16);
    justify-content: flex-start;
  }
  .card {
    width: 100%;
    min-height: auto;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }
  .cover { display: none; }
  .img-content { display: flex; }
  .content {
    width: 100%;
    padding: 100px 0 24px;
  }
  .wrapper { min-height: auto; }
}
