/* ==========================================================================
   Apple iOS Design System (White Theme) - Telegram Mini App
   ========================================================================== */

:root {
  /* iOS System Colors */
  --ios-bg: #F2F2F7;
  --ios-card-bg: #FFFFFF;
  --ios-card-secondary: #F8F8FA;
  --ios-separator: rgba(60, 60, 67, 0.12);
  --ios-separator-light: rgba(60, 60, 67, 0.06);
  
  /* Labels & Text */
  --text-primary: #000000;
  --text-secondary: #8E8E93;
  --text-tertiary: #AEAEB2;
  --text-placeholder: #C7C7CC;
  
  /* Tint Colors */
  --ios-blue: #007AFF;
  --ios-blue-hover: #0062CC;
  --ios-blue-light: #EBF3FF;
  --ios-green: #34C759;
  --ios-green-light: #E8F8EE;
  --ios-red: #FF3B30;
  --ios-red-light: #FFEBEA;
  --ios-orange: #FF9500;
  
  /* Layout & Geometry */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
  --shadow-float: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-button: 0 4px 14px rgba(0, 122, 255, 0.28);
  
  /* Bar Backgrounds */
  --ios-navbar-bg: rgba(242, 242, 247, 0.92);
  --ios-bottom-bar-bg: rgba(255, 255, 255, 0.94);
  --ios-bottom-sheet-bg: #FFFFFF;
  
  /* Safe Area Support */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  
  /* Animation */
  --spring-ease: cubic-bezier(0.25, 1, 0.5, 1);
  --nav-duration: 0.32s;
}

[data-theme="dark"] {
  --ios-bg: #000000;
  --ios-card-bg: #1C1C1E;
  --ios-card-secondary: #2C2C2E;
  --ios-navbar-bg: rgba(28, 28, 30, 0.94);
  --ios-bottom-bar-bg: rgba(28, 28, 30, 0.94);
  --ios-bottom-sheet-bg: #1C1C1E;
  --ios-separator: rgba(255, 255, 255, 0.14);
  --ios-separator-light: rgba(255, 255, 255, 0.08);
  --text-primary: #FFFFFF;
  --text-secondary: #8E8E93;
  --text-tertiary: #636366;
  --text-placeholder: #48484A;
  --ios-blue-light: rgba(0, 122, 255, 0.20);
  --ios-green-light: rgba(52, 199, 89, 0.20);
  --ios-red-light: rgba(255, 59, 48, 0.20);
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.5), 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-float: 0 8px 30px rgba(0, 0, 0, 0.6);
}

/* Reset & Base Setup */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--ios-bg);
  color: var(--text-primary);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Application Container (iPhone Canvas) */
#app-root {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--ios-bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
}

/* iOS Status / Top Safe Bar */
.ios-safe-top {
  height: var(--safe-top);
  min-height: 8px;
  background-color: var(--ios-navbar-bg);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background-color 0.25s ease;
}

/* Navigation Bar */
.ios-navbar {
  position: sticky;
  top: var(--safe-top);
  background: var(--ios-navbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--ios-separator);
  z-index: 40;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 60px;
}

.nav-right {
  justify-content: flex-end;
}

.nav-center {
  flex: 1;
  text-align: center;
}

.nav-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.nav-title.visible {
  opacity: 1;
  transform: translateY(0);
}

/* iOS Back Button */
.ios-back-btn {
  background: none;
  border: none;
  color: var(--ios-blue);
  font-size: 17px;
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 6px 4px 0;
  border-radius: 8px;
  transition: opacity 0.15s ease;
}

.ios-back-btn:active {
  opacity: 0.4;
}

.ios-back-btn svg {
  width: 12px;
  height: 20px;
  stroke: var(--ios-blue);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* Status Pill in Navbar */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  background: rgba(52, 199, 89, 0.12);
  color: #248A3D;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
}

.live-dot {
  width: 6px;
  height: 6px;
  background-color: var(--ios-green);
  border-radius: 50%;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Screen Management */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  padding-bottom: calc(90px + var(--safe-bottom));
  animation: screenFadeIn 0.25s var(--spring-ease);
}

.screen.active {
  display: flex;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* iOS Large Header Title */
.ios-large-header {
  padding: 16px 20px 8px;
}

.ios-large-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
  color: var(--text-primary);
}

.ios-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
  letter-spacing: -0.2px;
}

/* iOS Search Bar */
.search-container {
  padding: 8px 16px 14px;
}

.ios-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(142, 142, 147, 0.12);
  border-radius: 10px;
  padding: 8px 12px;
  height: 38px;
  transition: background 0.15s ease;
}

.ios-search-box:focus-within {
  background: rgba(142, 142, 147, 0.18);
}

.search-icon svg {
  width: 16px;
  height: 16px;
  fill: var(--text-secondary);
}

.ios-search-input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 16px;
  color: var(--text-primary);
  font-family: inherit;
}

.ios-search-input::placeholder {
  color: var(--text-placeholder);
}

/* iOS Segmented Control */
.segmented-wrapper {
  padding: 0 16px 14px;
}

.ios-segmented-control {
  display: flex;
  background: rgba(118, 118, 128, 0.12);
  padding: 2px;
  border-radius: 9px;
  position: relative;
}

.segment-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.segment-btn.active {
  background: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

/* iOS Grouped List (TableView style) */
.ios-section {
  margin: 0 16px 20px;
}

.ios-section-header {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
  margin-bottom: 6px;
  padding-left: 12px;
}

.ios-card {
  background: var(--ios-card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  border: 0.5px solid var(--ios-separator-light);
}

/* Catalog Row Items */
.crypto-list-group {
  display: flex;
  flex-direction: column;
}

.crypto-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--ios-card-bg);
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, transform 0.1s ease;
}

.crypto-item:active {
  background: #EBEBEF;
}

/* Inset Divider (stops before icon) */
.crypto-item:not(:last-child)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 68px;
  right: 0;
  height: 0.5px;
  background-color: var(--ios-separator);
}

.crypto-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.crypto-info {
  flex: 1;
  min-width: 0;
}

.crypto-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.crypto-symbol {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.network-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.1px;
}

.crypto-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crypto-rates {
  text-align: right;
  margin-left: 8px;
}

.crypto-price {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.crypto-price.price-on-request {
  font-size: 13px;
  font-weight: 700;
  color: var(--ios-blue);
}

.crypto-rate-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.crypto-chevron {
  margin-left: 10px;
  color: var(--text-tertiary);
}

.crypto-chevron svg {
  width: 8px;
  height: 13px;
  stroke: var(--text-placeholder);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

/* ==========================================================================
   Screen 2: Purchase & Calculator Screen
   ========================================================================== */

.hero-coin-card {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.hero-coin-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-coin-titles h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.hero-coin-titles span {
  font-size: 13px;
  color: var(--text-secondary);
}

.hero-coin-rate {
  text-align: right;
}

.hero-rate-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--ios-green);
}

.hero-rate-lbl {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Calculator Boxes */
.exchange-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  margin-bottom: 16px;
}

.calc-card {
  background: var(--ios-card-bg);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  border: 0.5px solid var(--ios-separator-light);
  transition: border-color 0.2s ease;
}

.calc-card:focus-within {
  border-color: rgba(0, 122, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.calc-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.calc-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.calc-currency-tag {
  font-size: 13px;
  font-weight: 600;
  color: var(--ios-blue);
  background: var(--ios-blue-light);
  padding: 2px 8px;
  border-radius: 6px;
}

.calc-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.calc-input {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: var(--text-primary);
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-family: inherit;
}

.calc-input::placeholder {
  color: var(--text-placeholder);
}

.calc-curr-symbol {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Quick Amount Pills (+1000, +5000, etc.) */
.preset-chips {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.preset-chip, .topup-preset-chip {
  background: var(--ios-bg);
  border: 0.5px solid var(--ios-separator);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.preset-chip:active, .topup-preset-chip:active {
  background: #E5E5EA;
  transform: scale(0.95);
}

/* Swap Indicator in Middle */
.calc-divider-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -4px 0;
  z-index: 2;
}

.calc-swap-icon {
  width: 32px;
  height: 32px;
  background: var(--ios-card-bg);
  border: 1px solid var(--ios-separator);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  color: var(--ios-blue);
}

.calc-swap-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--ios-blue);
  stroke-width: 2.2;
  fill: none;
}

/* Wallet Address Box */
.wallet-card {
  padding: 16px;
  margin-bottom: 16px;
}

.wallet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.wallet-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.wallet-network-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.wallet-input-container {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--ios-bg);
  border-radius: 12px;
  border: 1px solid var(--ios-separator);
  padding: 6px 10px;
  transition: border-color 0.2s ease;
}

.wallet-input-container.valid {
  border-color: var(--ios-green);
  background: rgba(52, 199, 89, 0.04);
}

.wallet-input-container.error {
  border-color: var(--ios-red);
  background: rgba(255, 59, 48, 0.04);
}

.wallet-input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 14px;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: -0.2px;
  padding-right: 70px;
}

.wallet-input::placeholder {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-placeholder);
}

.wallet-actions {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.wallet-clear-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 4px;
  display: none;
}

.wallet-clear-btn.show {
  display: block;
}

.wallet-paste-btn {
  background: var(--ios-blue-light);
  color: var(--ios-blue);
  border: none;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.wallet-paste-btn:active {
  opacity: 0.6;
}

.wallet-hint-text {
  font-size: 12px;
  margin-top: 6px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.wallet-hint-text.error {
  color: var(--ios-red);
}

.wallet-hint-text.success {
  color: var(--ios-green);
}

/* Payment Method Selection */
.payment-methods-card {
  margin-bottom: 20px;
}

.payment-method-row {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease;
}

.payment-method-row:active {
  background: #F2F2F5;
}

.payment-method-row:not(:last-child)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 60px;
  right: 0;
  height: 0.5px;
  background: var(--ios-separator);
}

.pm-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  font-size: 18px;
  flex-shrink: 0;
}

.pm-details {
  flex: 1;
  min-width: 0;
}

.pm-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.pm-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.pm-badge {
  font-size: 10px;
  font-weight: 700;
  background: rgba(0, 122, 255, 0.1);
  color: var(--ios-blue);
  padding: 2px 6px;
  border-radius: 6px;
}

.pm-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* iOS Radio Circle */
.pm-radio {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--text-placeholder);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  transition: all 0.2s ease;
}

.payment-method-row.selected .pm-radio {
  border-color: var(--ios-blue);
  background-color: var(--ios-blue);
}

.pm-radio-inner {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #FFFFFF;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
}

.payment-method-row.selected .pm-radio-inner {
  opacity: 1;
  transform: scale(1);
}

/* Sticky Bottom Action Bar (iPhone style) */
.ios-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--ios-bottom-bar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--ios-separator);
  padding: 10px 16px calc(10px + var(--safe-bottom));
  z-index: 45;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.ios-primary-btn {
  width: 100%;
  height: 52px;
  background-color: var(--ios-blue);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-button);
  transition: all 0.15s ease;
}

.ios-primary-btn:active {
  background-color: var(--ios-blue-hover);
  transform: scale(0.985);
}

.ios-primary-btn:disabled {
  background-color: #C7C7CC;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #FFFFFF;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.ios-primary-btn.loading .btn-spinner {
  display: inline-block;
}

.ios-primary-btn.loading .btn-label {
  display: none;
}

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

/* ==========================================================================
   Screen 3: Order Requisites & Payment Details
   ========================================================================== */

.order-timer-card {
  padding: 16px;
  text-align: center;
  background: var(--ios-card-bg);
  margin-bottom: 16px;
}

.timer-top-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.countdown-timer {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ios-blue);
  font-variant-numeric: tabular-nums;
}

.timer-sub-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Requisites Rows */
.requisites-card {
  padding: 14px 16px;
  margin-bottom: 16px;
}

.req-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
}

.req-row:not(:last-child) {
  border-bottom: 0.5px solid var(--ios-separator);
}

.req-col-left {
  display: flex;
  flex-direction: column;
}

.req-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.req-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.req-value.large-amount {
  font-size: 20px;
  color: var(--ios-blue);
}

.copy-pill-btn {
  background: var(--ios-blue-light);
  color: var(--ios-blue);
  border: none;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.copy-pill-btn:active {
  transform: scale(0.95);
  background: #D8E7FD;
}

.copy-pill-btn.copied {
  background: var(--ios-green-light);
  color: var(--ios-green);
}

/* Steps card */
.steps-card {
  padding: 16px;
  margin-bottom: 20px;
}

.step-item {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.step-item:last-child {
  margin-bottom: 0;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ios-blue);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-text {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.step-text strong {
  color: var(--text-primary);
}

/* ==========================================================================
   iOS Sheet Modal (Payment Confirmation & Status)
   ========================================================================== */

.ios-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99;
  display: none;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ios-modal-backdrop.active {
  display: flex;
  opacity: 1;
}

.ios-bottom-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--ios-bottom-sheet-bg);
  color: var(--text-primary);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  box-shadow: var(--shadow-float);
  text-align: center;
  transform: translateY(100%);
  transition: transform 0.3s var(--spring-ease), background-color 0.25s ease;
}

.ios-modal-backdrop.active .ios-bottom-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: var(--ios-separator);
  margin: -10px auto 18px;
}

.modal-icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--ios-green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.modal-icon-circle.processing {
  background: var(--ios-blue-light);
}

.modal-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 24px;
}

.modal-tx-info {
  background: var(--ios-bg);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-align: left;
}

.modal-tx-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.modal-tx-row:last-child {
  margin-bottom: 0;
}

.modal-tx-row strong {
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

/* Toast Message */
.ios-toast {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: rgba(26, 26, 26, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 20px;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s var(--spring-ease);
}

.ios-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Header User Actions (Profile & Theme Toggle)
   ========================================================================== */
.nav-user-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ios-circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--ios-separator);
  background: var(--ios-card-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: transform 0.15s ease, background-color 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  padding: 0;
  overflow: hidden;
}

.ios-circle-btn:active {
  transform: scale(0.92);
}

.profile-nav-btn {
  border: 2px solid var(--ios-blue);
  background: var(--ios-card-secondary);
}

.profile-nav-btn svg,
.profile-nav-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.theme-nav-btn {
  font-size: 16px;
  color: var(--text-primary);
  background: var(--ios-card-bg);
}

.notif-nav-btn {
  position: relative;
  overflow: visible;
  color: var(--text-primary);
  background: var(--ios-card-bg);
}

.notif-nav-btn svg {
  stroke: var(--text-primary);
  transition: transform 0.2s ease;
}

.notif-nav-btn:active svg {
  transform: rotate(15deg);
}

.notif-badge-dot {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--ios-red);
  border: 2px solid var(--ios-card-bg);
  box-shadow: 0 0 6px rgba(255, 59, 48, 0.7);
  animation: notifPulse 2s infinite ease-in-out;
}

@keyframes notifPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.18); opacity: 0.85; }
}

/* ==========================================================================
   SCREEN: AUTH / REGISTRATION (Screen Auth)
   ========================================================================== */
#screen-auth {
  display: none;
  padding-bottom: 40px;
}

#screen-auth.active {
  display: block;
}

.auth-hero {
  text-align: center;
  padding: 24px 16px 16px;
}

.auth-logo-badge {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 122, 255, 0.35);
}

.auth-logo-badge svg {
  width: 34px;
  height: 34px;
  fill: #FFFFFF;
}

.auth-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.auth-form-card {
  padding: 16px;
}

.auth-field-group {
  margin-bottom: 14px;
}

.auth-field-group:last-child {
  margin-bottom: 0;
}

.auth-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  padding-left: 2px;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--ios-card-secondary);
  border: 1px solid var(--ios-separator);
  border-radius: var(--radius-md);
  padding: 0 14px;
  height: 48px;
  transition: all 0.2s ease;
}

.auth-input-wrap:focus-within {
  border-color: var(--ios-blue);
  background: var(--ios-card-bg);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.auth-input-wrap.error {
  border-color: var(--ios-red);
  background: var(--ios-red-light);
}

.auth-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-primary);
}

.auth-input::placeholder {
  color: var(--text-placeholder);
  font-weight: 400;
}

/* Avatar Picker Grid */
.avatar-picker-section {
  margin-top: 10px;
  margin-bottom: 16px;
}

.avatar-grid {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
}

.avatar-grid::-webkit-scrollbar {
  display: none;
}

.avatar-chip {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--ios-card-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0;
}

.avatar-chip:active {
  transform: scale(0.92);
}

.avatar-chip.selected {
  border-color: var(--ios-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.3);
  transform: scale(1.05);
}

.avatar-chip svg,
.avatar-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.custom-avatar-upload-btn {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px dashed var(--ios-separator);
  background: var(--ios-card-secondary);
  color: var(--text-secondary);
  font-size: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-avatar-upload-btn:hover {
  border-color: var(--ios-blue);
  color: var(--ios-blue);
}

.auth-error-hint {
  color: var(--ios-red);
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
  text-align: center;
  min-height: 18px;
}

/* Auth Success Fullscreen Splash */
.auth-success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.auth-success-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.auth-success-box {
  background: var(--ios-card-bg);
  border-radius: 28px;
  padding: 32px 24px;
  width: 85%;
  max-width: 340px;
  text-align: center;
  transform: scale(0.85);
  transition: transform 0.4s var(--spring-ease);
  box-shadow: var(--shadow-float);
}

.auth-success-overlay.active .auth-success-box {
  transform: scale(1);
}

.success-icon-pulsar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--ios-green-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  animation: pulseGreen 1.6s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 199, 89, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 14px rgba(52, 199, 89, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 199, 89, 0); }
}

.success-icon-pulsar svg {
  width: 40px;
  height: 40px;
}

.success-splash-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.success-splash-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ==========================================================================
   USER PROFILE MODAL SHEET
   ========================================================================== */
.profile-hero {
  text-align: center;
  padding: 10px 0 20px;
  border-bottom: 1px solid var(--ios-separator-light);
  margin-bottom: 16px;
}

.profile-avatar-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
}

.profile-avatar-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--ios-card-bg);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  overflow: hidden;
  background: var(--ios-card-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-avatar-img svg,
.profile-avatar-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-edit-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ios-blue);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2.5px solid var(--ios-card-bg);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4);
  transition: transform 0.15s ease, background-color 0.2s ease;
}

.profile-avatar-edit-badge:hover {
  transform: scale(1.1);
  background: var(--ios-blue-hover);
}

.profile-avatar-edit-badge:active {
  transform: scale(0.92);
}

.profile-avatar-edit-badge svg {
  display: block;
  stroke: #FFFFFF;
}

.profile-username {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.profile-badge-verified {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--ios-green-light);
  color: var(--ios-green);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--ios-card-secondary);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.stat-box-lbl {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-box-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.stat-box-val.green {
  color: var(--ios-green);
}

/* 3D Avatars Quick Selection Section */
.profile-preset-section {
  background: var(--ios-card-secondary);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--ios-separator-light);
}

.profile-preset-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.profile-preset-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.profile-preset-subtitle {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.profile-avatar-picker-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.profile-preset-avatar-item {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--ios-card-bg);
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.profile-preset-avatar-item:hover {
  transform: scale(1.12);
}

.profile-preset-avatar-item:active {
  transform: scale(0.92);
}

.profile-preset-avatar-item.active {
  border-color: var(--ios-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.35);
  transform: scale(1.1);
}

.profile-preset-avatar-item svg {
  width: 100%;
  height: 100%;
  display: block;
}

.profile-actions-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-btn-row {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid var(--ios-separator);
  background: var(--ios-card-secondary);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.profile-btn-row svg {
  stroke: currentColor;
  flex-shrink: 0;
}

.profile-btn-row:active {
  transform: scale(0.98);
}

.profile-btn-row.primary-topup {
  background: var(--ios-blue);
  color: #FFFFFF;
  border: none;
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.28);
}

.profile-btn-row.primary-topup svg {
  stroke: #FFFFFF;
}

.profile-btn-row.danger {
  color: var(--ios-red);
  background: var(--ios-red-light);
  border: none;
}

.profile-btn-row.danger svg {
  stroke: var(--ios-red);
}

/* ==========================================================================
   TOP-UP BALANCE MODAL
   ========================================================================== */
.topup-card {
  padding: 16px;
  margin-bottom: 16px;
}

.topup-input-row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0 16px;
}

.topup-input {
  font-size: 32px;
  font-weight: 800;
  text-align: center;
  width: 180px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
}

.topup-curr {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-secondary);
}

.topup-success-badge {
  background: var(--ios-green-light);
  color: var(--ios-green);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
  display: none;
}

.topup-success-badge.show {
  display: block;
}

/* ==========================================================================
   FLOATING TELEGRAM SUPPORT BUTTON
   ========================================================================== */
.fab-telegram {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  left: max(16px, calc(50% - 240px + 16px));
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2AABEE 0%, #229ED9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(42, 171, 238, 0.45);
  z-index: 46;
  text-decoration: none;
  border: 2px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, bottom 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.fab-telegram svg {
  display: block;
  width: 24px;
  height: 24px;
  fill: #FFFFFF;
  margin-right: 2px;
  margin-top: 1px;
}

.fab-telegram:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 10px 24px rgba(42, 171, 238, 0.6);
}

.fab-telegram:active {
  transform: scale(0.92);
}

.fab-telegram.elevated {
  bottom: calc(82px + var(--safe-bottom));
}


