*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: #1a1f2e;
  overflow-x: hidden;
}

body {
  font-family: 'Montserrat', sans-serif;
  color: #ffffff;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
}

/* ─── ФОНОВАЯ АНИМАЦИЯ ЗВЕЗД ─── */
.stars-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.star {
  position: absolute;
  background: #ffffff;
  border-radius: 50%;
  animation: twinkle 3s infinite;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

.star.type-1 {
  width: 2px;
  height: 2px;
  animation-duration: 2s;
}

.star.type-2 {
  width: 3px;
  height: 3px;
  animation-duration: 3s;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}

.star.type-3 {
  width: 1px;
  height: 1px;
  animation-duration: 4s;
}

.star.type-4 {
  width: 4px;
  height: 4px;
  animation-duration: 2.5s;
  box-shadow: 0 0 10px rgba(255, 255, 255, 1);
}

@keyframes twinkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes float-up {
  0% {
    transform: translateY(100vh) translateX(0) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: scale(1);
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) translateX(100px) scale(0.5);
    opacity: 0;
  }
}

@keyframes float-diagonal {
  0% {
    transform: translate(100vw, 100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: scale(1);
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translate(-100vw, -100vh) scale(0.3);
    opacity: 0;
  }
}

@keyframes float-slow {
  0% {
    transform: translateY(100vh) translateX(-50px) scale(0);
    opacity: 0;
  }
  15% {
    opacity: 0.8;
    transform: scale(1);
  }
  85% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(-100vh) translateX(50px) scale(0.2);
    opacity: 0;
  }
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
  background: transparent;
  position: relative;
  z-index: 2;
}

/* ─── PAGE WRAP ─── */
.page-wrap {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* ─── LOGO ─── */
.logo-block {
  margin-bottom: 18px;
}

.logo-circle {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.logo-img {
  width: 72px;
  height: 72px;
  display: block;
  object-fit: cover;
}

/* ─── TITLE ─── */
.page-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: #ffffff;
  margin-bottom: 24px;
  line-height: 1.35;
}

/* ─── FIELD CARD ─── */
.field-card {
  width: 100%;
  background: #232b3e;
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 12px;
}

.field-label {
  font-size: 12px;
  color: #7a8499;
  font-weight: 500;
  margin-bottom: 10px;
  text-align: center;
  letter-spacing: 0.2px;
}

/* ─── INPUT ─── */
.field-input {
  width: 100%;
  background: #2e3a52;
  border: 1px solid #3a4a66;
  border-radius: 12px;
  outline: none;
  color: #ffffff;
  font-size: 16px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 500;
  padding: 16px;
  caret-color: #4a7eff;
  transition: border-color 0.2s, background 0.2s;
}

.field-input:focus {
  border-color: #4a7eff;
  background: #364460;
}

.field-input::placeholder {
  color: #7a8499;
}

/* ─── USERNAME INPUT WITH CHECK BUTTON ─── */
.username-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.username-input-wrap .field-input {
  padding-right: 50px;
}

.check-user-btn {
  position: absolute;
  right: 8px;
  width: 36px;
  height: 36px;
  background: #2e3a52;
  border: 1px solid #3a4a66;
  border-radius: 10px;
  color: #7a8499;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.check-user-btn:not(:disabled):hover {
  background: #364460;
  border-color: #4a7eff;
  color: #4a7eff;
}

.check-user-btn:not(:disabled):active {
  transform: scale(0.95);
}

.check-user-btn:disabled {
  background: #263045;
  border-color: #2a3448;
  color: #4a5c78;
  cursor: default;
}

.check-user-btn.checked {
  background: rgba(74, 126, 255, 0.12);
  border-color: #4a7eff;
  color: #4a7eff;
}

.check-user-btn.checking {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.7;
  }
}

.check-user-btn.checking svg {
  animation: spin 2s linear infinite;
}

.check-user-btn.checking circle {
  animation: dash 1.5s ease-in-out infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes dash {
  0% {
    stroke-dashoffset: 60;
  }
  50% {
    stroke-dashoffset: 15;
  }
  100% {
    stroke-dashoffset: 60;
  }
}

/* ─── PAYMENT SELECT ─── */
.payment-select {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.payment-current {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #2e3a52;
  border: 1px solid #3a4a66;
  border-radius: 12px;
  padding: 16px;
  transition: border-color 0.2s, background 0.2s;
}

.payment-select.open .payment-current {
  border-color: #4a7eff;
  background: #364460;
}

.payment-current span {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: #ffffff;
}

.chevron {
  width: 18px;
  height: 18px;
  color: #7a8499;
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.payment-select.open .chevron {
  transform: rotate(180deg);
}

/* ─── PM ICON ─── */
.pm-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.pm-icon.sbp {
  background: #ffffff;
  border-radius: 8px;
  padding: 3px;
}

.pm-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.pm-icon.card {
  background: #2e3a52;
}

.pm-img-invert {
  filter: invert(1) brightness(1.2);
}

/* ─── DROPDOWN ─── */
.payment-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 14px);
  left: -18px;
  right: -18px;
  background: #232b3e;
  border-radius: 16px;
  z-index: 50;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  border: 1px solid #2e3a52;
}

.payment-select.open .payment-dropdown {
  display: block;
}

.pd-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 500;
  color: #ffffff;
  border-bottom: 1px solid #1e2636;
  transition: background 0.15s;
}

.pd-option:last-child {
  border-bottom: none;
}

.pd-option:hover {
  background: rgba(255,255,255,0.04);
}

.pd-option span {
  flex: 1;
}

.pd-option.active {
  color: #4a7eff;
}

.pd-option.active span {
  color: #4a7eff;
}

.check {
  width: 16px;
  height: 16px;
  color: #4a7eff;
  flex-shrink: 0;
}

.pd-option:not(.active) .check {
  display: none;
}

/* ─── AMOUNT BLOCK ─── */
.amount-block {
  text-align: center;
  background: #2e3a52;
  border: 1px solid #3a4a66;
  border-radius: 12px;
  padding: 20px 16px;
  transition: border-color 0.2s, background 0.2s;
}

.amount-block:focus-within {
  border-color: #4a7eff;
  background: #364460;
}

.amount-input-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.amount-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 36px;
  font-weight: 800;
  font-family: 'Montserrat', sans-serif;
  color: #ffffff;
  caret-color: #4a7eff;
  min-width: 1ch;
  max-width: 220px;
  width: 1ch;
  text-align: center;
  padding: 0;
  -moz-appearance: textfield;
  appearance: textfield;
}

.amount-input::placeholder {
  color: #ffffff;
}

.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.amount-unit {
  font-size: 28px;
  font-weight: 600;
  color: #7a8499;
  flex-shrink: 0;
}

.amount-presets {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.preset-btn {
  flex: 1;
  background: #2e3a52;
  border: 1px solid #3a4a66;
  border-radius: 10px;
  color: #c0cce0;
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.preset-btn:hover {
  background: #364460;
  border-color: #4a7eff;
  color: #4a7eff;
}

.preset-btn:active {
  transform: scale(0.95);
}

.preset-btn.active {
  background: rgba(74,126,255,0.12);
  border-color: #4a7eff;
  color: #4a7eff;
}

/* ─── SUBMIT ─── */
.submit-btn {
  width: 100%;
  background: #3a6eff;
  border: none;
  border-radius: 14px;
  color: #fff;
  padding: 17px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  margin-top: 4px;
  margin-bottom: 16px;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  letter-spacing: 0.2px;
}

.submit-btn:not([disabled]):hover {
  background: #2a5ee0;
}

.submit-btn:not([disabled]):active {
  transform: scale(0.98);
}

.submit-btn[disabled] {
  background: #263045;
  color: #4a5c78;
  cursor: default;
}

/* ─── SUPPORT LINK ─── */
.support-link {
  font-size: 13px;
  color: #4a5568;
  text-decoration: none;
  transition: color 0.2s;
}

.support-link:hover {
  color: #7a8499;
}

/* ─── RESPONSIVE DESIGN ─── */

/* Мобильные устройства (320px - 480px) */
@media screen and (max-width: 480px) {
  #app {
    padding: 16px 12px 32px;
  }
  
  .page-wrap {
    max-width: 100%;
  }
  
  .logo-circle {
    width: 60px;
    height: 60px;
    border-radius: 15px;
  }
  
  .logo-img {
    width: 60px;
    height: 60px;
  }
  
  .page-title {
    font-size: 22px;
    margin-bottom: 20px;
  }
  
  .field-card {
    margin-bottom: 16px;
    padding: 16px;
  }
  
  .field-label {
    font-size: 11px;
    margin-bottom: 8px;
  }
  
  .field-input {
    padding: 14px;
    font-size: 15px;
  }
  
  .check-user-btn {
    width: 32px;
    height: 32px;
    right: 6px;
  }
  
  .payment-current {
    padding: 14px;
  }
  
  .payment-current span {
    font-size: 14px;
  }
  
  .pm-icon {
    width: 26px;
    height: 26px;
  }
  
  .amount-block {
    padding: 16px 12px;
  }
  
  .amount-input {
    font-size: 28px;
    max-width: 180px;
  }
  
  .amount-unit {
    font-size: 22px;
  }
  
  .preset-btn {
    padding: 8px 4px;
    font-size: 12px;
  }
  
  .submit-btn {
    padding: 15px;
    font-size: 15px;
  }
  
  .payment-dropdown {
    left: -12px;
    right: -12px;
  }
  
  .pd-option {
    padding: 12px 14px;
    font-size: 14px;
  }
}

/* Малые планшеты (481px - 768px) */
@media screen and (min-width: 481px) and (max-width: 768px) {
  #app {
    padding: 20px 16px 36px;
  }
  
  .page-wrap {
    max-width: 420px;
  }
  
  .logo-circle {
    width: 68px;
    height: 68px;
  }
  
  .logo-img {
    width: 68px;
    height: 68px;
  }
  
  .page-title {
    font-size: 24px;
  }
  
  .amount-input {
    font-size: 32px;
    max-width: 200px;
  }
  
  .amount-unit {
    font-size: 25px;
  }
}

/* Планшеты (769px - 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  #app {
    padding: 24px 20px 40px;
  }
  
  .page-wrap {
    max-width: 460px;
  }
  
  .page-title {
    font-size: 26px;
  }
}

/* Большие экраны (1025px и выше) */
@media screen and (min-width: 1025px) {
  #app {
    padding: 32px 24px 48px;
  }
  
  .page-wrap {
    max-width: 480px;
  }
  
  .page-title {
    font-size: 28px;
  }
  
  .field-card {
    margin-bottom: 24px;
  }
}

/* Очень маленькие экраны (менее 320px) */
@media screen and (max-width: 319px) {
  #app {
    padding: 12px 8px 24px;
  }
  
  .page-title {
    font-size: 20px;
  }
  
  .field-input {
    padding: 12px;
    font-size: 14px;
  }
  
  .amount-input {
    font-size: 24px;
  }
  
  .preset-btn {
    font-size: 11px;
    padding: 6px 3px;
  }
}

/* Горизонтальная ориентация мобильных устройств */
@media screen and (max-height: 600px) and (orientation: landscape) {
  #app {
    padding: 12px 16px 24px;
    min-height: 100vh;
    align-items: flex-start;
    padding-top: 20px;
  }
  
  .page-wrap {
    max-width: 500px;
    margin: 0 auto;
  }
  
  .logo-block {
    margin-bottom: 12px;
  }
  
  .page-title {
    font-size: 20px;
    margin-bottom: 16px;
  }
  
  .field-card {
    margin-bottom: 12px;
  }
  
  .amount-block {
    padding: 12px 10px;
  }
}

/* Высокие экраны (iPhone X и подобные) */
@media screen and (min-height: 812px) {
  #app {
    justify-content: center;
  }
}

/* Устранение проблем с сенсорными устройствами */
@media (hover: none) and (pointer: coarse) {
  .preset-btn:hover,
  .check-user-btn:hover,
  .submit-btn:hover {
    transform: none;
  }
  
  .preset-btn:active,
  .check-user-btn:active,
  .submit-btn:active {
    transform: scale(0.95);
  }
}

/* Оптимизация анимации звезд для мобильных устройств */
@media screen and (max-width: 768px) {
  .star.type-4 {
    width: 3px;
    height: 3px;
  }
  
  @keyframes float-up {
    0% {
      transform: translateY(100vh) translateX(0) scale(0);
      opacity: 0;
    }
    10% {
      opacity: 0.8;
      transform: scale(1);
    }
    90% {
      opacity: 0.8;
    }
    100% {
      transform: translateY(-100vh) translateX(50px) scale(0.3);
      opacity: 0;
    }
  }
}

/* Отключение анимации на устройствах с низкой производительностью */
@media screen and (max-width: 480px) and (max-height: 700px) {
  .stars-container {
    opacity: 0.6;
  }
  
  .star {
    animation-duration: 4s !important;
  }
}
