:root {
  --sber: #00a650;
  --sber-dark: #00843d;
  --gold: #ffd700;
  --gold-gradient: linear-gradient(135deg, #ffb800, #ffd700, #ffea80);
  --light: #e6f4ea;
  --bg-gradient: linear-gradient(135deg, #f0f9f3 0%, #d4efe0 50%, #b8e6cd 100%);
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-gradient);
  color: #1e1e1e;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow-x: hidden;
}

.container { max-width: 500px; margin: 0 auto; padding: 0 16px; padding-bottom: 90px; }

h1 {
  text-align: center;
  font-size: 30px;
  color: var(--sber-dark);
  margin: 20px 0 6px;
  font-weight: 900;
}
.subtitle {
  text-align: center;
  color: #555;
  font-size: 15px;
  margin-bottom: 24px;
}

/* Профиль в шапке (старый, для совместимости) */
.profile {
  background: white;
  border-radius: 24px;
  padding: 20px;
  margin: 0 0 12px;
  box-shadow: 0 10px 40px rgba(0,166,80,0.18);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Профиль внутри главного экрана */
.profile-home {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(0,166,80,0.15);
}

/* Прогресс-бар на главной странице */
.home-progress-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}
.home-progress-caption {
  margin: -10px 0 18px;
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
  color: #555;
}
.home-progress-bar {
  flex: 1;
  height: 14px;
  background: #e8e8e8;
  border-radius: 7px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.home-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--sber), #00d66f, var(--gold));
  border-radius: 6px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}
.home-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.4), transparent);
  border-radius: 6px 6px 0 0;
}
.home-progress-gift {
  font-size: 24px;
  animation: pulse-gift 2s ease-in-out infinite;
}
@keyframes pulse-gift {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--sber);
  color: white;
  font-size: 32px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0,166,80,0.3);
}
.rank-info {
  flex: 1;
  margin-left: 4px;
}
.rank {
  font-size: 19px;
  font-weight: 800;
  color: var(--sber-dark);
}
.to-next {
  font-size: 13px;
  color: #666;
  margin-top: 4px;
}
.points {
  font-size: 38px;
  font-weight: 900;
  color: var(--sber);
  text-shadow: 0 2px 10px rgba(0,166,80,0.2);
  margin-right: 8px;
}

/* КРАСИВЫЙ БЛОК С РАНГАМИ В ЛИЧНОМ КАБИНЕТЕ */
.ranks-progress {
  background: linear-gradient(135deg, rgba(0,166,80,0.12), rgba(0,166,80,0.05));
  border: 2px solid rgba(0,166,80,0.15);
  border-radius: 24px;
  padding: 20px;
  margin: 24px 0;
  position: relative;
  overflow: hidden;
}
.ranks-title {
  font-size: 18px;
  font-weight: 900;
  color: var(--sber-dark);
  text-align: center;
  margin-bottom: 20px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.ranks-list {
  display: flex;
  align-items: flex-start;
  position: relative;
  padding: 0 8px;
  justify-content: space-between;
}
.rank-item {
  text-align: center;
  flex: 1;
  position: relative;
  z-index: 2;
}
.rank-item.active .rank-circle {
  background: var(--gold-gradient);
  color: #8B5A00;
  transform: scale(1.25);
  box-shadow: 0 0 30px rgba(255,215,0,0.6);
}
.rank-item.active .rank-label {
  font-weight: 900;
  color: var(--sber-dark);
  font-size: 15px;
}
.rank-circle {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
  border: 4px solid #ddd;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(4px);
}
.rank-label {
  font-size: 11px;
  color: #666;
  line-height: 1.3;
  transition: all 0.3s;
}
.rank-points {
  font-size: 12px;
  font-weight: bold;
  color: var(--sber-dark);
  margin-top: 4px;
}

/* Прогресс-линия между рангами */
.progress-line {
  position: absolute;
  top: 27px; /* Центр круга ранга (54px / 2) */
  left: 12%;
  right: 12%;
  height: 6px;
  background: #ddd;
  border-radius: 3px;
  overflow: hidden;
  z-index: 1;
}
.progress-fill {
  height: 100%;
  background: var(--gold-gradient);
  width: 0%;
  border-radius: 3px;
  transition: width 0.8s ease;
}

.card { background: white; border-radius: 24px; padding: 20px; margin: 16px 0; box-shadow: 0 8px 30px rgba(0,0,0,0.1); display: none; }
.card.active { display: block; animation: fadeIn 0.5s; }
@keyframes fadeIn { from {opacity:0; transform:translateY(15px)} to {opacity:1; transform:none} }

.mission {
  background: #f8fff9;
  border: 2px solid #d4f0dd;
  border-radius: 20px;
  padding: 18px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
}
.mission:active { transform: scale(0.98); }
.mission.legendary {
  background: var(--gold-gradient);
  color: white;
  border: none;
  box-shadow: 0 10px 30px rgba(255,183,0,0.4);
}
.mission button {
  background: var(--sber);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 14px;
  font-weight: bold;
  float: right;
  margin-top: 12px;
  font-size: 15px;
}
.mission.legendary button {
  background: white;
  color: #b8860b;
}

.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: white;
  display: flex;
  padding: 12px 20px env(safe-area-inset-bottom);
  box-shadow: 0 -8px 30px rgba(0,0,0,0.12);
  border-radius: 24px 24px 0 0;
  backdrop-filter: blur(10px);
  z-index: 100;
}
.nav-btn {
  flex: 1;
  padding: 14px;
  text-align: center;
  font-size: 26px;
  border-radius: 18px;
  transition: all 0.3s;
}
.nav-btn.active {
  background: var(--sber);
  color: white;
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0,166,80,0.3);
}

.success {
text-align: center;
    padding: 40px 20px;
    background: white;
    border-radius: 24px;
    
    /* Делаем его модальным окном по центру */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 350px;
    z-index: 10000; /* Поверх всего */
    
    border: 4px solid var(--sber);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    display: none; /* Скрыто по умолчанию */
}
.confetti { position:fixed; top:0; left:0; width:100%; height:100%; pointer-events:none; z-index:999; }
    .overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
  background: rgba(0,0,0,0.75); backdrop-filter: blur(10px);
  z-index: 1000; display: none; align-items: center; justify-content: center; 
  padding: 20px; transition: opacity 0.3s;
}
.modal {
  background: white; border-radius: 24px; width: 100%; max-width: 420px; 
  padding: 24px; max-height: 95vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.close-btn { 
  float: right; font-size: 32px; cursor: pointer; color: #aaa; 
  line-height: 1; margin-top: -8px;
}
.close-btn:hover { color: #000; }
.btn {
  background: var(--sber); color: white; border: none; padding: 16px; border-radius: 16px; font-size: 17px; font-weight: 700; width: 100%; margin: 12px 0; cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { transform: scale(1.02); }
.btn:active { transform: scale(0.98); }
.btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}
.btn-dark { background: var(--sber-dark); }

/* === ГЛАВНАЯ КНОПКА === */
.main-action {
  text-align: center;
  padding: 20px 0;
}
.main-action-text {
  font-size: 18px;
  color: #555;
  margin-bottom: 20px;
}
.big-button {
  width: 100%;
  padding: 30px 20px;
  background: linear-gradient(145deg, #00d66f, #00a650);
  border: none;
  border-radius: 24px;
  cursor: pointer;
  box-shadow: 0 10px 40px rgba(0,166,80,0.4);
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.big-button:hover {
  transform: translateY(-4px);
  box-shadow: 0 15px 50px rgba(0,166,80,0.5);
}
.big-button:active {
  transform: scale(0.98);
}
.big-button-icon {
  font-size: 48px;
  display: block;
}
.big-button-title {
  font-size: 17px;
  font-weight: 900;
  color: rgba(255,255,255,0.98);
  text-align: center;
  line-height: 1.15;
}
.big-button-text {
  font-size: 20px;
  font-weight: 800;
  color: white;
}
.big-button-hint {
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  font-weight: 500;
}
.bonus-info {
  margin-top: 20px;
  padding: 16px;
  background: rgba(0,166,80,0.08);
  border-radius: 16px;
  font-size: 14px;
  color: #555;
  line-height: 1.8;
}

/* === ФОРМА === */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #333;
  margin-bottom: 8px;
}
.form-input, .form-textarea {
  width: 100%;
  padding: 12px 8px;
  border: none;
  border-bottom: 2px solid #e0e0e0;
  border-radius: 0;
  font-size: 16px;
  transition: border-color 0.2s;
  margin-bottom: 8px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  color: #1e1e1e;
  caret-color: var(--sber);
}
.form-input::placeholder, .form-textarea::placeholder {
  color: #bbb;
  opacity: 1;
}
.form-input:focus::placeholder, .form-textarea:focus::placeholder {
  color: #ccc;
}
.form-input:focus, .form-textarea:focus {
  outline: none;
  border-bottom-color: var(--sber);
}
.form-textarea {
  height: 80px;
  resize: none;
  border: 2px solid #e0e0e0;
  border-radius: 14px;
  padding: 14px 16px;
}
.form-textarea:focus {
  border-color: var(--sber);
}

/* Кнопка помощи */
.help-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--sber);
  background: white;
  color: var(--sber);
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.help-btn:hover {
  background: var(--sber);
  color: white;
}

/* Кнопка "Не могу найти ID" */
.cant-find-btn {
  background: none;
  border: none;
  color: var(--sber);
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
  margin-top: 4px;
}
.cant-find-btn:hover {
  color: var(--sber-dark);
}
.cant-find-btn.active {
  color: #e53935;
}

/* Маркер обязательного поля */
.required-mark {
  color: #e53935;
  font-weight: bold;
}

/* Подсказка под полем терминала */
.terminal-hint {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 8px;
  animation: fadeIn 0.3s;
}
.terminal-hint.hint-first {
  background: rgba(0,166,80,0.1);
  color: var(--sber-dark);
  border: 1px solid rgba(0,166,80,0.3);
}
.terminal-hint.hint-duplicate {
  background: #fff4e0;
  color: #b8860b;
  border: 1px solid rgba(184,134,11,0.3);
}
.terminal-hint.hint-repeat {
  background: #ffebee;
  color: #c62828;
  border: 1px solid rgba(198,40,40,0.3);
}

/* Неактивное поле */
.form-input:disabled {
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}

/* Блок ручного ввода адреса */
.manual-address-block {
  background: #f8f8f8;
  padding: 16px;
  border-radius: 14px;
  margin-bottom: 20px;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}
.manual-hint {
  font-size: 13px;
  color: #666;
  margin-bottom: 12px;
}

/* Radio buttons */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.radio-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #f8f8f8;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: 2px solid transparent;
}
.radio-item:hover {
  background: #f0f0f0;
}
.radio-item input {
  display: none;
}
.radio-custom {
  width: 22px;
  height: 22px;
  border: 2px solid #ccc;
  border-radius: 50%;
  position: relative;
  transition: all 0.2s;
}
.radio-item input:checked + .radio-custom {
  border-color: var(--sber);
}
.radio-item input:checked + .radio-custom::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: var(--sber);
  border-radius: 50%;
}
.radio-item input:checked ~ .radio-text {
  font-weight: 600;
  color: var(--sber-dark);
}
.radio-item:has(input:checked) {
  border-color: var(--sber);
  background: rgba(0,166,80,0.05);
}
.radio-text {
  font-size: 15px;
  color: #333;
}

/* Фото превью */
.btn-photo {
  background: var(--sber-dark);
}
.photo-preview {
  margin: 16px 0;
  border-radius: 16px;
  overflow: hidden;
}
.photo-preview img {
  width: 100%;
  display: block;
  border-radius: 16px;
}

/* Кнопка отправки */
.btn-submit {
  background: var(--sber);
  margin-top: 10px;
  font-size: 15px;
}
.btn-submit:disabled {
  background: #ccc;
}
.submit-hint {
  text-align: center;
  font-size: 13px;
  color: #999;
  margin-top: 8px;
}
.submit-hint.hidden {
  display: none;
}

/* Модальное окно помощи */
.help-modal {
  max-width: 360px;
}
.help-content {
  padding: 16px 0;
}
.help-content p {
  margin-bottom: 12px;
  color: #555;
}
.help-content ul {
  list-style: none;
  margin-bottom: 16px;
}
.help-content li {
  padding: 8px 0;
  color: #333;
}
.help-image-placeholder {
  background: #f0f0f0;
  border-radius: 16px;
  padding: 30px;
  text-align: center;
  margin: 16px 0;
}
.help-image-placeholder span {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}
.help-image-placeholder p {
  color: #999;
  font-size: 14px;
  margin: 0;
}
.help-tip {
  background: #fff8e1;
  padding: 12px;
  border-radius: 12px;
  font-size: inherit;
}

/* === ЛИДЕРБОРД === */
.leaderboard-container {
  background: #fff4e0;
  padding: 16px;
  border-radius: 20px;
  margin-bottom: 16px;
}
.leaderboard-loading {
  text-align: center;
  color: #999;
  padding: 20px;
}
.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  background: rgba(255,255,255,0.6);
  transition: all 0.2s;
}
.leaderboard-item:last-child {
  margin-bottom: 0;
}
.leaderboard-item.top-1 {
  background: linear-gradient(135deg, #ffd700, #ffea80);
  box-shadow: 0 4px 15px rgba(255,215,0,0.3);
}
.leaderboard-item.top-2 {
  background: linear-gradient(135deg, #e8e8e8, #f5f5f5);
}
.leaderboard-item.top-3 {
  background: linear-gradient(135deg, #cd7f32, #daa06d);
  color: white;
}
.leaderboard-position {
  font-size: 20px;
  font-weight: 900;
  width: 36px;
  text-align: center;
}
.leaderboard-info {
  flex: 1;
  margin-left: 12px;
}
.leaderboard-user {
  font-weight: 700;
  font-size: 15px;
  color: #333;
}
.leaderboard-rank {
  font-size: 12px;
  color: #666;
}
.leaderboard-points {
  font-weight: 800;
  font-size: 16px;
  color: var(--sber);
}
.leaderboard-item.top-3 .leaderboard-user,
.leaderboard-item.top-3 .leaderboard-rank {
  color: white;
}
.leaderboard-item.top-3 .leaderboard-points {
  color: #fff;
}
.user-position-block {
  background: rgba(0,166,80,0.1);
  padding: 16px;
  border-radius: 16px;
  text-align: center;
  border: 2px solid var(--sber);
}
.leaderboard-empty {
  text-align: center;
  color: #999;
  padding: 30px 20px;
  font-size: 15px;
}

/* === МОБИЛЬНАЯ АДАПТАЦИЯ === */
@media screen and (max-width: 480px) {
  .container {
    padding: 0 12px;
    padding-bottom: 80px;
  }
  
  h1 {
    font-size: 24px;
    margin: 16px 0 4px;
  }
  
  .subtitle {
    font-size: 13px;
    margin-bottom: 16px;
  }
  
  .profile {
    padding: 14px;
    border-radius: 18px;
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .avatar {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }
  
  .rank {
    font-size: 16px;
  }
  
  .to-next {
    font-size: 12px;
  }
  
  .points {
    font-size: 28px;
  }
  
  .card {
    padding: 16px;
    border-radius: 18px;
    margin: 12px 0;
  }
  
  /* Модальное окно */
  .overlay {
    padding: 12px;
    align-items: flex-start;
    padding-top: 5vh;
  }
  
  .modal {
    padding: 16px;
    border-radius: 18px;
    max-height: 90vh;
  }
  
  .modal h2 {
    font-size: 18px;
    margin-bottom: 16px !important;
  }
  
  .close-btn {
    font-size: 28px;
  }
  
  /* Форма */
  .form-group {
    margin-bottom: 16px;
  }
  
  .form-label {
    font-size: 14px;
    margin-bottom: 6px;
  }
  
  .form-input {
    padding: 10px 8px;
    font-size: 16px; /* Важно! 16px предотвращает zoom на iOS */
  }
  
  .form-textarea {
    padding: 12px;
    font-size: 16px;
    height: 70px;
  }
  
  .radio-item {
    padding: 12px;
    gap: 10px;
  }
  
  .radio-custom {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }
  
  .radio-text {
    font-size: 14px;
  }
  
  .btn {
    padding: 14px;
    font-size: 15px;
    border-radius: 14px;
    margin: 10px 0;
  }
  
  .btn-photo {
    padding: 12px;
    font-size: 14px;
  }
  
  .photo-preview {
    margin: 12px 0;
  }
  
  .submit-hint {
    font-size: 12px;
  }
  
  .home-progress-caption {
    font-size: 12px;
    margin: -8px 0 14px;
  }
  
  /* Главная кнопка */
  .big-button {
    padding: 24px 16px;
    border-radius: 18px;
  }
  
  .big-button-icon {
    font-size: 40px;
  }
  
  .big-button-title {
    font-size: 15px;
  }
  
  .big-button-text {
    font-size: 17px;
  }
  
  .big-button-hint {
    font-size: 12px;
  }
  
  .bonus-info {
    padding: 12px;
    font-size: 13px;
  }
  
  /* Навигация */
  .nav {
    padding: 10px 16px;
    border-radius: 18px 18px 0 0;
  }
  
  .nav-btn {
    padding: 10px;
    font-size: 22px;
    border-radius: 14px;
  }
  
  /* Ранги в профиле */
  .ranks-progress {
    padding: 14px;
    border-radius: 18px;
  }
  
  .ranks-title {
    font-size: 15px;
    margin-bottom: 16px;
  }
  
  .rank-circle {
    width: 44px;
    height: 44px;
    font-size: 20px;
    border-width: 3px;
  }
  
  .rank-label {
    font-size: 10px;
  }
  
  .rank-points {
    font-size: 10px;
  }
  
  /* Ручной ввод адреса */
  .manual-address-block {
    padding: 12px;
  }
  
  .manual-hint {
    font-size: 12px;
  }
  
  .cant-find-btn {
    font-size: 13px;
  }
  
  /* Помощь */
  .help-btn {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }
  
  .help-modal {
    max-width: 100%;
  }
  
  .help-content li {
    font-size: 14px;
  }
}

/* Очень маленькие экраны */
@media screen and (max-width: 360px) {
  h1 {
    font-size: 20px;
  }
  
  .profile {
    padding: 12px;
  }
  
  .avatar {
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  
  .rank {
    font-size: 14px;
  }
  
  .points {
    font-size: 24px;
  }
  
  .rank-circle {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }
  
  .big-button-text {
    font-size: 15px;
  }
  
  .radio-text {
    font-size: 13px;
  }
}


#photoMenu {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
}

#photoMenuBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s;
}

#photoMenuSheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

#photoMenuTitle {
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  color: #333;
  padding-bottom: 4px;
}

#photoMenuSheet button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 500;
}

#photoMenuCamera {
  background: #00a650;
  color: #fff;
}

#photoMenuGallery {
  background: #f0f0f0;
  color: #333;
}

#photoMenuCancel {
  background: transparent;
  color: #999;
}

#photoMenu.open #photoMenuBackdrop {
  opacity: 1;
}

#photoMenu.open #photoMenuSheet {
  transform: translateY(0);
}