/* StarLedger Mini App — Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

:root {
  --bg:           #090C15;
  --bg2:          #0D1120;
  --surface:      rgba(255,255,255,0.04);
  --surface-md:   rgba(255,255,255,0.07);
  --surface-hi:   rgba(255,255,255,0.10);
  --border:       rgba(255,255,255,0.09);
  --border-hi:    rgba(255,255,255,0.16);

  --gold:         #FFB800;
  --gold-dim:     rgba(255,184,0,0.12);
  --gold-glow:    rgba(255,184,0,0.22);
  --gold-border:  rgba(255,184,0,0.28);

  --text:         #FFFFFF;
  --muted:        rgba(255,255,255,0.48);
  --muted2:       rgba(255,255,255,0.24);

  --success:      #4ADE80;
  --success-dim:  rgba(74,222,128,0.12);
  --error:        #FF5C5C;
  --error-dim:    rgba(255,92,92,0.12);
  --blue:         #7BA3FF;
  --purple:       #A78BFA;
  --purple-dim:   rgba(167,139,250,0.12);

  --r:            18px;
  --r-sm:         12px;
  --r-xs:         8px;

  --nav-h:        62px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── App Shell ────────────────────────────────────────────────────────────── */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.screen-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.24s ease, transform 0.24s ease;
  scrollbar-width: none;
}
.screen::-webkit-scrollbar { display: none; }
.screen.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Bottom Navigation ────────────────────────────────────────────────────── */
.bottom-nav {
  display: flex;
  background: rgba(13,17,32,0.95);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(24px);
  padding: 6px 0 max(8px, env(safe-area-inset-bottom, 8px));
  flex-shrink: 0;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 7px 0 5px;
  transition: color 0.2s ease;
  position: relative;
}
.nav-tab.active { color: var(--gold); }

.nav-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
.nav-tab.active .nav-icon { transform: scale(1.18); }

.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.nav-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold);
  margin-top: 2px;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.nav-tab.active .nav-dot {
  opacity: 1;
  transform: scale(1);
}

/* ── Page Header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-top: 2px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 11px;
}

.header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 2px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--gold);
  overflow: hidden;
  flex-shrink: 0;
}
.header-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}

.header-greeting {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}
.header-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1;
  margin-top: 2px;
}

.rate-badge {
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: 100px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  letter-spacing: 0.2px;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 12px;
  transition: background 0.15s;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Input ────────────────────────────────────────────────────────────────── */
.input-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-bottom: 7px;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 14px;
  gap: 10px;
  margin-bottom: 12px;
  transition: border-color 0.2s, background 0.2s;
}
.input-wrap:focus-within {
  border-color: var(--gold-border);
  background: rgba(255,184,0,0.04);
}

.input-icon { font-size: 17px; color: var(--muted2); flex-shrink: 0; }

.input-wrap input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  padding: 14px 0;
  width: 0;
}
.input-wrap input::placeholder { color: var(--muted2); font-weight: 400; font-size: 15px; }
.input-wrap input[type=number] { -moz-appearance: textfield; }
.input-wrap input[type=number]::-webkit-outer-spin-button,
.input-wrap input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ── Quick chips ──────────────────────────────────────────────────────────── */
.chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.chip:active     { transform: scale(0.93); }
.chip.active,
.chip:hover      {
  background: var(--gold-dim);
  border-color: var(--gold-border);
  color: var(--gold);
}

/* ── Preview row ──────────────────────────────────────────────────────────── */
.preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  margin-bottom: 14px;
}
.preview-label { font-size: 13px; color: var(--muted); }
.preview-value { font-size: 17px; font-weight: 800; color: var(--success); letter-spacing: -0.4px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 15px;
  border-radius: var(--r-sm);
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.15s;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.btn-gold {
  background: linear-gradient(135deg, #FFB800 0%, #FF9500 100%);
  color: #000;
  box-shadow: 0 4px 20px rgba(255,184,0,0.28);
}
.btn-gold:active { box-shadow: 0 2px 8px rgba(255,184,0,0.18); }

.btn-purple {
  background: linear-gradient(135deg, #9333EA 0%, #7C3AED 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(147,51,234,0.25);
}

.btn-green {
  background: linear-gradient(135deg, #4ADE80 0%, #22C55E 100%);
  color: #000;
  box-shadow: 0 4px 20px rgba(74,222,128,0.22);
}

.btn-outline {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--surface-md); }

.btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.btn-row .btn { flex: 1; padding: 12px; font-size: 13px; }

/* ── Balance Hero ─────────────────────────────────────────────────────────── */
.balance-hero {
  background: linear-gradient(145deg, #131829 0%, #0D1020 60%, #0A0D18 100%);
  border: 1px solid rgba(107,158,255,0.14);
  border-radius: 24px;
  padding: 30px 24px 26px;
  text-align: center;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.balance-hero::before {
  content: '';
  position: absolute;
  top: -50px; right: -50px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(107,158,255,0.10) 0%, transparent 70%);
  pointer-events: none;
}
.balance-hero::after {
  content: '';
  position: absolute;
  bottom: -30px; left: -30px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(167,139,250,0.08) 0%, transparent 70%);
  pointer-events: none;
}

.balance-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 10px;
}

.balance-amount {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -2.5px;
  line-height: 1;
  background: linear-gradient(145deg, #FFFFFF 40%, rgba(255,255,255,0.65));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.balance-ton {
  font-size: 17px;
  color: var(--blue);
  font-weight: 600;
  letter-spacing: -0.3px;
}

/* ── Stats Grid ───────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px 10px;
  text-align: center;
}
.stat-value {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 3px;
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

/* ── Section Title ────────────────────────────────────────────────────────── */
.section-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-bottom: 10px;
  padding: 0 2px;
}

/* ── Transaction List ─────────────────────────────────────────────────────── */
.tx-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.tx-item:last-child { border-bottom: none; }

.tx-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-xs);
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.tx-icon.gift {
  background: var(--purple-dim);
  border-color: rgba(167,139,250,0.25);
}
.tx-icon.bonus { background: var(--success-dim); border-color: rgba(74,222,128,0.25); }

.tx-info { flex: 1; min-width: 0; }
.tx-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date  { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tx-amount { font-size: 15px; font-weight: 800; color: var(--success); letter-spacing: -0.3px; flex-shrink: 0; }

.tx-empty {
  text-align: center;
  padding: 28px 0;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.tx-empty .tx-empty-icon { font-size: 32px; opacity: 0.4; }

/* ── Referral Box ─────────────────────────────────────────────────────────── */
.referral-box {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
  margin-bottom: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  line-height: 1.6;
}

.ref-stats {
  display: flex;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.ref-stat {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  background: rgba(255,255,255,0.03);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.ref-stat-value { font-size: 17px; font-weight: 800; color: var(--success); letter-spacing: -0.5px; }
.ref-stat-label { font-size: 11px; color: var(--muted); margin-top: 3px; font-weight: 500; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(14px);
  background: rgba(18,23,38,0.96);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 100px;
  padding: 11px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  backdrop-filter: blur(24px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.26s cubic-bezier(0.4,0,0.2,1);
  z-index: 9999;
  white-space: nowrap;
  max-width: 88vw;
  text-overflow: ellipsis;
  overflow: hidden;
}
#toast.show      { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success   { border-color: rgba(74,222,128,0.35); color: var(--success); }
#toast.error     { border-color: rgba(255,92,92,0.35);  color: var(--error);   }

/* ── Modal Sheet ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-sheet {
  width: 100%;
  background: #0F1422;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 20px 20px max(28px, env(safe-area-inset-bottom, 28px));
  transform: translateY(100%);
  transition: transform 0.36s cubic-bezier(0.32,0.72,0,1);
}
.modal-overlay.active .modal-sheet { transform: translateY(0); }

.modal-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.16);
  border-radius: 2px;
  margin: 0 auto 22px;
}
.modal-title { font-size: 19px; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.3px; }
.modal-sub   { font-size: 13px; color: var(--muted); margin-bottom: 20px; line-height: 1.5; }

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.info-row:last-of-type { border-bottom: none; margin-bottom: 4px; }
.info-label { color: var(--muted); }
.info-value { font-weight: 700; }

.modal-note {
  margin: 16px 0;
  padding: 13px 14px;
  background: rgba(255,184,0,0.07);
  border: 1px solid rgba(255,184,0,0.18);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: rgba(255,210,80,0.9);
  line-height: 1.5;
}

/* ── Loading Screen ───────────────────────────────────────────────────────── */
#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 14px;
  transition: opacity 0.4s;
}
#loading.hidden { opacity: 0; pointer-events: none; }

@keyframes star-pulse {
  0%, 100% { transform: scale(1)   rotate(-5deg);  opacity: 0.85; }
  50%       { transform: scale(1.2) rotate(10deg); opacity: 1;    }
}
.loading-star { font-size: 52px; animation: star-pulse 1.1s ease-in-out infinite; }
.loading-text { font-size: 14px; color: var(--muted); font-weight: 500; }

/* ── Access Denied ────────────────────────────────────────────────────────── */
#access-denied {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  z-index: 9998;
  gap: 12px;
}
#access-denied.show { display: flex; }
.denied-icon  { font-size: 52px; }
.denied-title { font-size: 22px; font-weight: 800; }
.denied-sub   { font-size: 14px; color: var(--muted); max-width: 240px; line-height: 1.5; }

/* ── Skeleton Loader ──────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -300% 0; }
  100% { background-position:  300% 0; }
}
.skel {
  background: linear-gradient(
    90deg,
    var(--surface) 25%,
    rgba(255,255,255,0.08) 50%,
    var(--surface) 75%
  );
  background-size: 300% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
  pointer-events: none;
}

/* ── Info banner inside card ──────────────────────────────────────────────── */
.info-banner {
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: var(--r-xs);
  padding: 10px 12px;
  font-size: 12px;
  color: rgba(255,215,80,0.9);
  line-height: 1.5;
  margin-bottom: 12px;
}
