:root {
  /* Core Palette - High Contrast & Glossy (3D Rose-Gold & Pink Neon from EG144) */
  --bg-deep: #020612;
  --bg-glow: #1b0a2a;
  
  /* Glassmorphism */
  --glass-bg: linear-gradient(135deg, rgba(20, 45, 95, 0.45) 0%, rgba(8, 18, 45, 0.65) 100%);
  --glass-bevel: inset 1px 1px 2px rgba(255, 255, 255, 0.25), inset -1px -1px 2px rgba(0, 0, 0, 0.6);
  --glass-border: 1.5px solid rgba(0, 229, 255, 0.35);
  --gold-border: 1.5px solid rgba(243, 161, 131, 0.6);

  /* Accents & Gradients */
  --neon-cyan: #00E5FF;
  --neon-pink: #FF2A85;
  --rose-gold: #F3A183;
  
  /* 3D Metallic Gradients */
  --gold-metallic: linear-gradient(180deg, #FFF8E7 0%, #F5D1B0 35%, #D28566 70%, #8A3F24 100%);
  --silver-metallic: linear-gradient(180deg, #FFFFFF 0%, #E2E8F0 45%, #94A3B8 80%, #475569 100%);
  --rose-metallic-btn: linear-gradient(180deg, #FAD0C4 0%, #E2886B 45%, #B85233 90%, #8A3216 100%);
  
  /* Text */
  --text-white: #FFFFFF;
  --text-main: #FFFFFF;
  --text-gold: #FFE0D2;
  --text-muted: #9EB2DC;
  --text-sub: #9EB2DC;

  /* Fonts */
  --font-numbers: 'Rajdhani', sans-serif;
  --font-heading: 'Rajdhani', sans-serif;
  --font-thai: 'Prompt', sans-serif;
  --font-body: 'Prompt', sans-serif;

  /* ความกว้างตัวแอป: เต็มจอ 100% บนมือถือ/iPhone Pro Max/Surface Duo และจำกัดคอลัมน์บนจอคอมพิวเตอร์ */
  --app-width: 100%;
}

@media (min-width: 769px) {
  :root {
    --app-width: 480px;
  }
}

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

[hidden] {
  display: none !important;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  background-color: #010308;
  color: var(--text-white);
  font-family: var(--font-thai);
  font-size: 13px;
  line-height: 1.5;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

/* ================= APP CONTAINER & BACKGROUND ================= */
#app-wrapper {
  width: 100%;
  max-width: var(--app-width, 100%);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  background: 
    radial-gradient(circle at 80% 10%, rgba(255, 42, 133, 0.25) 0%, transparent 45%),
    radial-gradient(circle at 20% 35%, rgba(0, 229, 255, 0.2) 0%, transparent 50%),
    radial-gradient(circle at 50% 60%, rgba(243, 161, 131, 0.15) 0%, transparent 60%),
    linear-gradient(165deg, #0d1b40 0%, #050d21 50%, #020612 100%);
  box-shadow: 0 0 50px rgba(0,0,0,0.8);
}

#app-wrapper::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    radial-gradient(1px 1px at 25px 35px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 85px 120px, var(--rose-gold), transparent),
    radial-gradient(1px 1px at 150px 70px, var(--neon-cyan), transparent),
    radial-gradient(2px 2px at 300px 200px, #fff, transparent),
    radial-gradient(1px 1px at 350px 400px, var(--neon-pink), transparent);
  background-size: 400px 500px;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

.app-content {
  position: relative;
  z-index: 1;
  width: 100%;
  flex: 1;
  padding-bottom: 96px;
}

/* เมื่อยังไม่ล็อกอิน ให้ซ่อนส่วนเนื้อหาสมาชิกและแถบล่างทั้งหมด เพื่อไม่ให้โผล่ซ้อนด้านล่างในมือถือ */
body.not-logged-in .member-shell,
body.not-logged-in nav.bottom-nav {
  display: none !important;
}

.page-tab { display: none; }
.page-tab.active { display: block; animation: tabIn .25s ease; }
@keyframes tabIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ================= TYPOGRAPHY UTILITIES ================= */
.metallic-number {
  font-family: var(--font-numbers);
  background: var(--gold-metallic);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0px 3px 5px rgba(0, 0, 0, 0.7));
  font-weight: 700;
  display: inline-block;
}

.silver-number {
  font-family: var(--font-numbers);
  background: var(--silver-metallic);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.7));
  font-weight: 700;
  display: inline-block;
}

/* ================= LIVE TICKER BAR ================= */
.ticker-bar {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 1000;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(8,18,45,.97), rgba(20,45,95,.97), rgba(8,18,45,.97));
  border-bottom: 1px solid rgba(243,161,131,.45);
  box-shadow: 0 2px 14px rgba(0,0,0,.55);
  flex-shrink: 0;
}
.ticker-row { display: flex; align-items: center; height: 34px; }
.ticker-tag {
  flex-shrink: 0; display: flex; align-items: center; gap: 5px; height: 100%; padding: 0 10px;
  background: linear-gradient(180deg, #F3A183, #B85233); color: #2A0E06;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; white-space: nowrap;
  box-shadow: 2px 0 10px rgba(0,0,0,.5);
}
.ticker-live { width: 6px; height: 6px; border-radius: 50%; background: #0B3D2C; animation: tkLive 1.2s infinite; }
@keyframes tkLive { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
.ticker-view { flex: 1; min-width: 0; overflow: hidden; position: relative; height: 100%; }
.ticker-track {
  position: absolute; top: 0; left: 0; height: 100%; display: flex; align-items: center;
  white-space: nowrap; will-change: transform;
  animation: tkScroll var(--dur, 36s) linear infinite;
}
@keyframes tkScroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ticker-bar:hover .ticker-track { animation-play-state: paused; }
.ticker-item { display: inline-flex; align-items: center; gap: 6px; padding: 0 16px; font-size: 12px; color: var(--text-white); }
.ticker-item b { color: var(--text-gold); font-weight: 600; }
.ticker-amt { font-family: var(--font-numbers); color: #00FFC8; font-weight: 700; }
.ticker-sep { color: rgba(243,161,131,.4); }
.ticker-empty { padding: 0 16px; font-size: 12px; color: var(--text-muted); }

/* ================= HEADER (RESPONSIVE 320px - 420px) ================= */
header {
  padding: 14px 14px 10px;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.brand-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid rgba(243, 161, 131, 0.7);
  box-shadow: 0 4px 12px rgba(0,0,0,0.7), 0 0 14px rgba(243, 161, 131, 0.35);
}

.brand-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.brand-title {
  font-family: var(--font-numbers);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.6px;
  background: var(--gold-metallic);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallet-addr {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  cursor: pointer;
  font-family: var(--font-numbers);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallet-chip {
  display: inline-flex; align-items: center; gap: 5px; width: fit-content; max-width: 100%; margin-top: 3px;
  padding: 2px 8px 2px 6px; border-radius: 999px;
  background: linear-gradient(135deg, rgba(243,161,131,0.22), rgba(255,42,133,0.12));
  border: 1px solid rgba(243,161,131,0.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 2px 8px rgba(243,161,131,0.22);
  backdrop-filter: blur(6px);
}
.chip-dot {
  width: 6px; height: 6px; border-radius: 50%; background: #00FFC8; flex-shrink: 0;
  box-shadow: 0 0 6px rgba(0,255,200,0.9); animation: chipPulse 2s infinite;
}
@keyframes chipPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.chip-name {
  font-size: 10.5px; font-weight: 700; letter-spacing: .2px; color: var(--text-gold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.profile-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none;
  padding: 0; cursor: pointer; width: 52px; flex-shrink: 0;
}
.avatar-ring {
  position: relative; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; overflow: visible; transition: transform .18s;
  background: conic-gradient(from 210deg, #FFF8E7, #F3A183, #C26342, #F3A183, #FFF8E7);
  padding: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.55), 0 0 12px rgba(243,161,131,.45);
}
.avatar-img, .avatar-initial {
  width: 100%; height: 100%; border-radius: 50%; display: block; object-fit: cover;
  background: radial-gradient(circle at 35% 30%, #3a2540, #140b1e);
}
.avatar-initial {
  display: flex; align-items: center; justify-content: center; font-family: var(--font-numbers);
  font-size: 15px; font-weight: 700; color: var(--text-gold);
}
.avatar-edit {
  position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--rose-metallic-btn); color: #3D0D02; font-size: 8.5px; line-height: 14px; text-align: center;
  border: 1.5px solid #050D21; font-weight: 700;
}
.avatar-name {
  font-size: 10px; font-weight: 600; color: var(--text-gold); max-width: 52px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.signout-btn {
  background: linear-gradient(180deg, #FF4B91 0%, #C4145A 100%);
  border: 1px solid #FF9EC5;
  box-shadow: 0 4px 12px rgba(255, 42, 133, 0.4), inset 0 1px 1px rgba(255,255,255,0.5);
  color: white;
  padding: 6px 10px;
  border-radius: 20px;
  font-family: var(--font-thai);
  font-size: 11.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ================= LOGIN OVERLAY ================= */
.login-overlay {
  width: 100%;
  min-height: calc(100vh - 34px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 16px 32px;
}
.login-inner {
  margin: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
}
.login-title {
  font-family: var(--font-numbers);
  background: var(--gold-metallic);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 34px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 1px;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.6));
}
.login-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
  max-width: 340px;
  line-height: 1.55;
}
.wallet-btn {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 11px 14px;
  border-radius: 13px;
  font-family: var(--font-thai);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 8px;
  transition: all .22s;
  border: 1.5px solid rgba(243,161,131,0.6);
}
.wallet-btn:active { transform: scale(0.97); }
.wallet-btn.primary {
  background: var(--rose-metallic-btn);
  color: #3D0D02;
  border-color: #FFE0D8;
  box-shadow: 0 6px 20px rgba(184,82,51,0.5);
}
.wallet-btn.secondary {
  background: var(--glass-bg);
  color: var(--text-gold);
  backdrop-filter: blur(12px);
  box-shadow: var(--glass-bevel);
}
.wb-badge:empty { display: none; }
.wb-icon { font-size: 16px; line-height: 1; }
#login-msg {
  color: var(--text-gold);
  margin-top: 10px;
  font-size: 13px;
  min-height: 20px;
  text-align: center;
  max-width: 340px;
  line-height: 1.55;
}

.sponsor-card {
  width: 100%; max-width: 340px; margin-bottom: 14px; padding: 12px 14px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(20,45,95,.6), rgba(8,18,45,.8));
  border: 1.5px solid rgba(243,161,131,.55); backdrop-filter: blur(12px);
  box-shadow: inset 1px 1px 2px rgba(255,255,255,.2), 0 6px 20px rgba(0,0,0,.5);
}
.sponsor-label {
  font-size: 12px; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600;
  text-align: center; margin-bottom: 8px;
}
.sponsor-row { display: flex; align-items: center; gap: 12px; }
.sponsor-ring {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; padding: 2.5px;
  background: conic-gradient(from 210deg, #FFF8E7, #F3A183, #C26342, #F3A183, #FFF8E7);
  box-shadow: 0 3px 10px rgba(0,0,0,.55), 0 0 14px rgba(243,161,131,.45); display: block;
}
.sponsor-initial {
  width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #3a2540, #140b1e);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-numbers); font-size: 19px; font-weight: 700; color: var(--text-gold);
}
.sponsor-text { min-width: 0; flex: 1; }
.sponsor-name { font-size: 15px; font-weight: 700; color: #FFF8E7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sponsor-wallet { font-family: var(--font-numbers); font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.dev-login {
  width: 100%;
  max-width: 340px;
  padding: 13px;
  border-radius: 16px;
  background: rgba(5, 13, 33, 0.82);
  border: 1.5px dashed rgba(243, 161, 131, 0.5);
}
.dev-login-label {
  font-size: 12.5px;
  color: var(--text-gold);
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}
.dev-input {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(243,161,131,0.45);
  background: rgba(2, 6, 18, 0.92);
  color: #fff;
  font-family: var(--font-numbers);
  font-size: 12.5px;
  outline: none;
  margin-bottom: 8px;
  text-align: center;
}
.s10-dev-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.s10-dev-preset-btn {
  padding: 8px 6px;
  border-radius: 9px;
  border: 1px solid rgba(0, 229, 255, 0.45);
  background: rgba(0, 229, 255, 0.12);
  color: #E0FFFA;
  font-family: var(--font-thai);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.s10-dev-preset-btn:hover {
  background: rgba(0, 229, 255, 0.24);
  border-color: var(--neon-cyan);
}

/* ================= SALES CARD & MAIN BALANCE CARD ================= */
.sales-card {
  position: relative; overflow: hidden; margin: 0 14px 12px; padding: 14px 15px; border-radius: 16px;
  background: var(--glass-bg); border: var(--glass-border);
  box-shadow: var(--glass-bevel), 0 0 22px rgba(0,229,255,.14);
}
.sales-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.sales-title { font-size: 12px; letter-spacing: 0.5px; color: var(--text-muted); font-weight: 600; }
.sales-live {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  color: #00FFC8; padding: 2px 8px; border-radius: 999px; flex-shrink: 0;
  background: rgba(0,255,200,.12); border: 1px solid rgba(0,255,200,.35);
}
.sales-live i { width: 5px; height: 5px; border-radius: 50%; background: #00FFC8; animation: tkLive 1.2s infinite; font-style: normal; }
.sales-value {
  font-family: var(--font-numbers); font-size: 28px; font-weight: 700; line-height: 1.15;
  background: var(--gold-metallic); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 5px rgba(0,0,0,.6));
}
.sales-sub { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 12.5px; color: var(--text-muted); }
.sales-sub b { color: var(--text-gold); font-family: var(--font-numbers); font-size: 13.5px; }

.main-balance-card {
  margin: 0 14px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border-radius: 18px;
  border: 2px solid rgba(243, 161, 131, 0.7);
  box-shadow: 
    var(--glass-bevel),
    0 0 25px rgba(243, 161, 131, 0.25),
    0 10px 25px rgba(0, 0, 0, 0.6);
  padding: 16px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  position: relative;
}

.balance-left { min-width: 0; flex: 1; }
.balance-left .card-label {
  font-size: 12px;
  color: var(--text-gold);
  letter-spacing: 0.4px;
  margin-bottom: 2px;
  font-weight: 600;
}

.balance-value {
  font-size: 34px;
  line-height: 1.05;
  margin-bottom: 6px;
}

.balance-unit {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.unit-pill {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.sdt-floating-box {
  background: linear-gradient(145deg, rgba(15, 25, 55, 0.9), rgba(5, 10, 25, 0.95));
  border: 1.5px solid rgba(0, 229, 255, 0.5);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.2), inset 0 0 10px rgba(243, 161, 131, 0.2);
  border-radius: 14px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 76px;
  flex-shrink: 0;
}

.coin-3d-wrapper {
  width: 32px;
  height: 32px;
  margin-bottom: 2px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.6));
}

.sdt-label { font-size: 11px; color: var(--text-gold); font-weight: 700; white-space: nowrap; }
.sdt-val { font-size: 18px; line-height: 1.1; }

/* ================= BONUS & SUB-PANELS ================= */
.bonus-section {
  padding: 15px 14px 0;
}

.bonus-total-panel {
  background: var(--glass-bg);
  border: var(--glass-border);
  box-shadow: var(--glass-bevel), 0 8px 20px rgba(0,0,0,0.4);
  border-radius: 16px;
  padding: 20px 12px 14px;
  text-align: center;
  position: relative;
  margin-bottom: 12px;
  backdrop-filter: blur(12px);
}

.bonus-ribbon {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #102552 0%, #20458a 50%, #102552 100%);
  border: 1px solid var(--rose-gold);
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-gold);
  letter-spacing: 0.4px;
  white-space: nowrap;
  max-width: 92%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bonus-val {
  font-size: 30px;
  line-height: 1.15;
}

.sub-panels-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.sub-panel {
  flex: 1;
  min-width: 0;
  background: var(--glass-bg);
  border: var(--glass-border);
  box-shadow: var(--glass-bevel), 0 6px 15px rgba(0,0,0,0.4);
  border-radius: 14px;
  padding: 11px 8px;
  text-align: center;
  backdrop-filter: blur(12px);
}

.sub-panel.gold-tint {
  border: var(--gold-border);
  background: linear-gradient(135deg, rgba(60, 30, 50, 0.45) 0%, rgba(20, 10, 30, 0.65) 100%);
}

.sub-title {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 3px;
  font-weight: 600;
}

.sub-val {
  font-size: 20px;
}

/* 3D Rose Gold Metallic Button */
.accordion-btn {
  width: 100%;
  background: var(--rose-metallic-btn);
  border: 1.5px solid #FFE0D8;
  box-shadow: 
    0 6px 20px rgba(184, 82, 51, 0.5),
    inset 0 2px 2px rgba(255, 255, 255, 0.7),
    inset 0 -2px 3px rgba(90, 20, 5, 0.7);
  border-radius: 12px;
  padding: 11px 12px;
  color: #3D0D02;
  font-family: var(--font-thai);
  font-size: 13.5px;
  font-weight: 700;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform .15s;
  text-align: center;
}
.accordion-btn:active { transform: scale(0.98); }

.accordion-btn.secondary-cyan {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.2), rgba(0, 110, 160, 0.35));
  border-color: rgba(0, 229, 255, 0.65);
  color: #E0FFFA;
  box-shadow: var(--glass-bevel), 0 4px 14px rgba(0, 229, 255, 0.2);
}

/* ================= SUPER 10: 10-TIER MATRIX & PILLS ================= */
.section-title {
  font-size: 13px;
  color: var(--text-gold);
  letter-spacing: 0.5px;
  font-weight: 700;
  padding: 14px 14px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.s10-matrix-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 14px 10px;
}

.s10-matrix-card {
  background: var(--glass-bg);
  border: var(--glass-border);
  box-shadow: var(--glass-bevel), 0 4px 12px rgba(0,0,0,0.45);
  border-radius: 14px;
  padding: 10px;
  backdrop-filter: blur(12px);
  position: relative;
  cursor: pointer;
  transition: transform .15s, border-color .2s;
  min-width: 0;
}
.s10-matrix-card:active { transform: scale(0.98); }
.s10-matrix-card.unlocked {
  border: 1.5px solid rgba(243, 161, 131, 0.7);
  box-shadow: var(--glass-bevel), 0 0 16px rgba(243, 161, 131, 0.2);
}
.s10-matrix-card.next-unlock {
  border: 1.5px solid rgba(0, 229, 255, 0.7);
  box-shadow: var(--glass-bevel), 0 0 16px rgba(0, 229, 255, 0.22);
}
.s10-matrix-card.locked {
  opacity: 0.68;
  border: 1px dashed rgba(158, 178, 220, 0.35);
}

.s10-mc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}
.s10-mc-tier {
  font-family: var(--font-numbers);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.s10-mc-badge {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.s10-mc-badge.ok { background: rgba(0,255,200,0.16); color: #00FFC8; border: 1px solid rgba(0,255,200,0.4); }
.s10-mc-badge.next { background: rgba(0,229,255,0.16); color: #00E5FF; border: 1px solid rgba(0,229,255,0.4); }
.s10-mc-badge.lock { background: rgba(255,255,255,0.08); color: var(--text-muted); }

.s10-mc-price {
  font-family: var(--font-numbers);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 6px;
}
.s10-mc-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 5px;
}
.s10-mc-stats b { color: var(--text-white); font-family: var(--font-numbers); }

/* ================= PACKAGES TAB ================= */
.pkg-card {
  background: var(--glass-bg);
  border: 2px solid rgba(243,161,131,0.7);
  border-radius: 18px;
  padding: 16px 14px;
  text-align: center;
  backdrop-filter: blur(16px);
  box-shadow: var(--glass-bevel), 0 0 22px rgba(243,161,131,0.2);
  margin: 0 14px 12px;
}
.pkg-card.locked-pkg {
  border: 1.5px dashed rgba(158, 178, 220, 0.35);
  box-shadow: var(--glass-bevel);
  opacity: 0.78;
}
.pkg-price { font-size: 34px; font-family: var(--font-numbers); font-weight: 700; line-height: 1.1; }
.pkg-detail { display: grid; grid-template-columns: repeat(3, 1fr); margin: 12px 0; gap: 6px; }
.pkg-detail-item {
  min-width: 0; background: rgba(5,13,33,0.85); border: var(--glass-border);
  border-radius: 12px; padding: 9px 4px; display: flex; flex-direction: column; justify-content: center;
}
.pkg-detail-label { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; font-weight: 600; }
.pkg-detail-val { font-size: 15px; font-family: var(--font-numbers); font-weight: 700; line-height: 1.2; }

/* ================= NETWORK / BINARY TREE TAB ================= */
.s10-tier-strip {
  display: flex;
  gap: 6px;
  padding: 4px 14px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.s10-tier-strip::-webkit-scrollbar { display: none; }

.s10-tier-pill {
  flex: 0 0 auto;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-numbers);
  cursor: pointer;
  border: 1px solid rgba(243,161,131,0.45);
  background: rgba(5,13,33,0.85);
  color: var(--text-muted);
  transition: all .18s;
}
.s10-tier-pill.active {
  background: var(--rose-metallic-btn);
  color: #3D0D02;
  border-color: #FFE0D8;
  box-shadow: 0 0 14px rgba(243,161,131,0.45);
}
.s10-tier-pill.has-node {
  border-color: rgba(0,255,200,0.6);
  color: #00FFC8;
}
.s10-tier-pill.active.has-node {
  color: #3D0D02;
}

.s10-subtree-switch {
  display: flex;
  gap: 6px;
  margin: 0 14px 10px;
  padding: 4px;
  border-radius: 13px;
  background: rgba(5, 13, 33, 0.85);
  border: 1px solid rgba(243, 161, 131, 0.35);
}
.s10-subtree-btn {
  flex: 1;
  min-width: 0;
  padding: 8px 6px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-thai);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s;
}
.s10-subtree-btn.active {
  background: linear-gradient(135deg, rgba(0,229,255,0.25), rgba(255,42,133,0.22));
  color: #FFF8E7;
  border: 1px solid rgba(0,229,255,0.6);
  box-shadow: 0 0 12px rgba(0,229,255,0.25);
}

.s10-mynodes-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.s10-mynodes-bar::-webkit-scrollbar { display: none; }

.network-breadcrumb {
  display: flex; align-items: center; gap: 6px; padding: 0 14px 10px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap;
}
.breadcrumb-btn {
  padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer;
  border: 1px solid rgba(243,161,131,0.5); background: rgba(5,13,33,0.85); color: var(--text-gold); font-family: var(--font-thai);
}

.tree-container { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 4px 8px 0; }
.tree-row { display: flex; justify-content: center; gap: 3px; width: 100%; align-items: stretch; }
.tree-level-tag { font-size: 13px; letter-spacing: 0.3px; font-weight: 700; text-align: center; padding: 2px 0; }
.tree-node {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 10px; padding: 5px 2px; min-height: 52px; text-align: center; transition: transform .18s; position: relative;
  overflow: hidden;
}
.tree-node.clickable { cursor: pointer; }
.tree-node.clickable:active { transform: scale(0.93); }
.node-addr {
  font-family: var(--font-numbers); font-size: 10.5px; font-weight: 700;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lv4 .node-addr { font-size: 9px; }
.node-name {
  font-size: 9.5px; font-weight: 600; margin-top: 1px; max-width: 100%; padding: 0 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2;
}
.lv4 .node-name { font-size: 8.5px; }
.node-pv {
  font-size: 9px; opacity: .9; font-family: var(--font-numbers); margin-top: 1px;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lv4 .node-pv { font-size: 8px; }
.tree-node.empty {
  background: rgba(255,255,255,0.035); border: 1.5px dashed rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.35); font-size: 11px;
}
.lv1 { background: linear-gradient(135deg, rgba(255,248,231,0.2), rgba(243,161,131,0.3)); border: 2px solid #F3A183; color: #FFF8E7; box-shadow: 0 0 16px rgba(243,161,131,0.45); }
.lv2 { background: linear-gradient(135deg, rgba(0,229,255,0.14), rgba(0,136,255,0.2)); border: 1.5px solid rgba(0,229,255,0.65); color: #E0FFFA; box-shadow: 0 0 12px rgba(0,229,255,0.3); }
.lv3 { background: linear-gradient(135deg, rgba(255,42,133,0.14), rgba(184,20,92,0.2)); border: 1.5px solid rgba(255,42,133,0.65); color: #FFE8F0; box-shadow: 0 0 12px rgba(255,42,133,0.3); }
.lv4 { background: linear-gradient(135deg, rgba(157,78,221,0.16), rgba(90,24,154,0.22)); border: 1.5px solid rgba(157,78,221,0.7); color: #F3E8FF; box-shadow: 0 0 12px rgba(157,78,221,0.35); }
.tree-node.drill {
  border-radius: 12px;
  background: radial-gradient(circle at 35% 30%, rgba(224,255,250,0.35), rgba(0,255,200,0.22) 45%, rgba(0,110,80,0.35));
  border: 2px solid #00FFC8; color: #E0FFFA; box-shadow: 0 0 16px rgba(0,255,200,0.55);
}

.pv-summary {
  display: flex; gap: 8px; margin: 12px 14px 0; padding: 12px 10px;
  background: var(--glass-bg); border: var(--glass-border); border-radius: 14px;
}
.pv-summary.grid-2x2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.pv-col { flex: 1; text-align: center; min-width: 0; }
.pv-label { font-size: 11px; color: var(--text-muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-val { font-size: 15.5px; margin-top: 2px; font-family: var(--font-numbers); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ================= HISTORY & CYCLE RECEIPTS TAB ================= */
.filter-scroll { position: relative; margin-bottom: 12px; }
.history-filters {
  display: flex; gap: 6px; padding: 2px 14px; overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.history-filters::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto; padding: 7px 13px; border-radius: 20px; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; border: 1px solid rgba(243,161,131,0.4);
  background: rgba(5,13,33,0.85); color: var(--text-muted); transition: all .2s;
}
.filter-chip.active { background: rgba(255,42,133,0.22); border-color: #FF2A85; color: #FF9EC5; }

.tx-list { padding: 0 14px; }
.tx-item {
  background: var(--glass-bg); border: var(--glass-border); border-radius: 13px;
  padding: 11px 12px; margin-bottom: 8px; display: flex; justify-content: space-between;
  align-items: center; gap: 8px; box-shadow: var(--glass-bevel);
}
.tx-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tx-type { font-size: 13px; font-weight: 700; }
.tx-desc { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-date { font-size: 11px; color: var(--text-muted); font-family: var(--font-numbers); }
.tx-amount { font-size: 15px; font-weight: 700; font-family: var(--font-numbers); text-align: right; white-space: nowrap; flex-shrink: 0; }
.tx-amount.positive { color: #00FFC8; }
.tx-amount.negative { color: #FF2A85; }

.s10-receipt-card {
  background: var(--glass-bg);
  border: 1.5px solid rgba(243, 161, 131, 0.55);
  box-shadow: var(--glass-bevel), 0 6px 18px rgba(0,0,0,0.45);
  border-radius: 15px;
  padding: 13px;
  margin-bottom: 10px;
}
.s10-rc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.s10-rc-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  padding: 3px 0;
  color: var(--text-muted);
}
.s10-rc-row b { color: var(--text-white); font-family: var(--font-numbers); text-align: right; }

/* ================= REFERRAL TAB ================= */
.ref-section { padding: 0 14px 12px; }
.ref-card {
  background: var(--glass-bg); border: var(--glass-border); border-radius: 16px;
  padding: 14px; margin-bottom: 10px; backdrop-filter: blur(12px); box-shadow: var(--glass-bevel);
}
.leg-card.leg-left { border-color: rgba(0,229,255,0.6); box-shadow: var(--glass-bevel), 0 0 16px rgba(0,229,255,0.14); }
.leg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.leg-title { font-size: 14.5px; font-weight: 700; color: var(--text-gold); }
.leg-sub { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-top: 2px; }
.ref-link-box { display: flex; align-items: center; gap: 6px; }
.ref-link-input {
  flex: 1; min-width: 0; background: rgba(5,13,33,0.9); border: 1px solid rgba(243,161,131,0.4);
  border-radius: 9px; padding: 9px 10px; font-family: var(--font-numbers); font-size: 12px; color: #fff; outline: none;
}
.ref-copy-btn {
  padding: 9px 12px; border-radius: 9px; background: var(--rose-metallic-btn);
  color: #3D0D02; font-weight: 700; font-size: 12px; cursor: pointer; border: none; white-space: nowrap; flex-shrink: 0;
}
.leg-actions { display: flex; gap: 6px; margin-top: 8px; }
.line-share-btn {
  flex: 1; min-width: 0; padding: 9px 10px; border-radius: 11px; background: #007A33; color: #fff;
  font-size: 12.5px; font-weight: 700; cursor: pointer; border: 1px solid rgba(0, 255, 136, 0.45);
  display: flex; align-items: center; justify-content: center; gap: 6px; font-family: var(--font-thai);
}
.qr-toggle-btn {
  padding: 9px 12px; border-radius: 11px; border: 1px solid rgba(243,161,131,0.5);
  background: rgba(5,13,33,0.85); color: var(--text-gold); font-family: var(--font-thai);
  font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.ref-qr-box {
  display: flex; flex-direction: column; align-items: center; padding: 14px;
  background: #fff; border-radius: 12px; margin-top: 10px;
}

/* ================= MODAL & TOAST ================= */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.82); z-index: 10500;
  display: none; align-items: center; justify-content: center; backdrop-filter: blur(6px); padding: 16px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: linear-gradient(135deg, #0d1b40, #050d21); border: 2px solid rgba(243,161,131,0.7);
  border-radius: 18px; padding: 20px 16px; width: 100%; max-width: 370px; text-align: center;
  max-height: 85vh; overflow-y: auto; box-shadow: 0 12px 36px rgba(0,0,0,0.8);
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--text-gold); margin-bottom: 12px; }
.modal-input {
  width: 100%; padding: 11px; border-radius: 10px; border: 1.5px solid rgba(243,161,131,0.5);
  background: rgba(5,13,33,0.9); color: #fff; font-family: var(--font-numbers);
  font-size: 17px; text-align: center; margin-bottom: 12px; outline: none;
}
.modal-info { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; }
.modal-btn {
  flex: 1; padding: 11px; border-radius: 10px; font-family: var(--font-thai);
  font-size: 13.5px; font-weight: 700; cursor: pointer; border: none;
}
.modal-btn.confirm { background: var(--rose-metallic-btn); color: #3D0D02; }
.modal-btn.cancel { background: rgba(255,255,255,0.1); color: var(--text-muted); border: 1px solid rgba(255,255,255,0.15); }

#toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(20px);
  z-index: 11000; background: linear-gradient(135deg, #0d1b40, #050d21);
  border: 1.5px solid rgba(243,161,131,0.7); border-radius: 12px; padding: 10px 16px;
  font-size: 13px; color: #fff; max-width: calc(100vw - 32px); width: max-content; text-align: center;
  opacity: 0; pointer-events: none; transition: all .28s; box-shadow: 0 8px 26px rgba(0,0,0,0.7);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { border-color: rgba(0,255,200,0.8); }
#toast.err { border-color: rgba(255,42,133,0.85); }

/* ================= BOTTOM NAVIGATION (FIXED AT BOTTOM OF VIEWPORT) ================= */
.top-quick-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(243, 161, 131, 0.25);
}

.top-nav-pill {
  padding: 6px 4px !important;
  border-radius: 10px !important;
  background: rgba(15, 30, 68, 0.75) !important;
  border: 1px solid rgba(0, 229, 255, 0.28) !important;
  color: var(--text-muted);
  font-size: 11px !important;
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
  justify-content: center;
}

.top-nav-pill.active {
  background: linear-gradient(135deg, rgba(255, 42, 133, 0.35), rgba(243, 161, 131, 0.25)) !important;
  border-color: #FF2A85 !important;
  color: #FFFFFF !important;
  box-shadow: 0 0 12px rgba(255, 42, 133, 0.45);
}

nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-width, 100%);
  height: 74px;
  background: linear-gradient(180deg, rgba(6, 15, 38, 0.96) 0%, rgba(2, 6, 18, 0.99) 100%);
  backdrop-filter: blur(20px);
  border-top: 1.5px solid rgba(243, 161, 131, 0.85);
  box-shadow: 0 -10px 30px rgba(0,0,0,0.85), inset 0 1px 0 rgba(243, 161, 131, 0.5), 0 -4px 18px rgba(243, 161, 131, 0.35);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0 6px;
  z-index: 2000;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-thai);
  position: relative;
  flex: 1;
  min-width: 0;
  transition: all 0.25s ease;
}

.nav-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  border: 1.5px solid transparent;
  transition: all 0.25s ease;
}

.nav-item svg {
  stroke: var(--text-muted);
  transition: stroke 0.25s ease, filter 0.25s ease;
}

.nav-item.active {
  color: #FF2A85;
  font-weight: 700;
}

.nav-item.active .nav-icon-box {
  box-shadow: inset 0 0 14px rgba(255, 42, 133, 0.6), 0 0 20px rgba(255, 42, 133, 0.7);
  border: 1.5px solid #FF2A85;
  background: linear-gradient(135deg, rgba(255, 42, 133, 0.2) 0%, rgba(180, 20, 80, 0.12) 100%);
}

.nav-item.active .nav-icon-box svg {
  stroke: #FF2A85;
  filter: drop-shadow(0 0 8px rgba(255, 42, 133, 0.95));
}

/* =================================================================
   RESPONSIVE BREAKPOINTS: iPhone (SE / Pro / Pro Max) & Surface Duo
   ================================================================= */

/* 1. หน้าจอเล็กมาก (iPhone SE 1st Gen 320px / Galaxy Fold จอนอก 344px) */
@media (max-width: 359px) {
  header { padding: 12px 10px 8px; }
  .sales-card, .main-balance-card, .pkg-card { margin-left: 10px; margin-right: 10px; }
  .bonus-section, .s10-matrix-grid, .tx-list, .ref-section { padding-left: 10px; padding-right: 10px; }
  .s10-subtree-switch, .pv-summary { margin-left: 10px; margin-right: 10px; }
  .s10-tier-strip, .s10-mynodes-bar, .network-breadcrumb, .history-filters, .section-title { padding-left: 10px; padding-right: 10px; }
  .balance-value { font-size: 28px; }
  .sales-value, .bonus-val { font-size: 25px; }
}

/* 2. หน้าจอ iPhone ทุกรุ่น (375px, 390px, 414px, 430px Pro Max) */
@media (max-width: 480px) {
  nav.bottom-nav {
    height: calc(74px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* 3. หน้าจอ Surface Duo (540x720 Portrait / 720x540 Landscape) & Foldable/Phablet (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
  header {
    padding: 16px 20px 12px;
  }
  .brand-logo-img { width: 50px; height: 50px; }
  .brand-title { font-size: 22px; }
  .wallet-addr { font-size: 13px; }
  .chip-name { font-size: 11.5px; }
  .profile-btn { width: 64px; }
  .avatar-ring { width: 38px; height: 38px; }
  .avatar-name { font-size: 11px; max-width: 64px; }

  .login-subtitle, .wallet-btn, .sponsor-card, .dev-login, #login-msg {
    max-width: 440px;
  }

  .sales-card, .main-balance-card, .pkg-card {
    margin-left: 20px;
    margin-right: 20px;
  }
  .bonus-section, .s10-matrix-grid, .tx-list, .ref-section {
    padding-left: 20px;
    padding-right: 20px;
  }
  .s10-subtree-switch, .pv-summary {
    margin-left: 20px;
    margin-right: 20px;
  }
  .s10-tier-strip, .s10-mynodes-bar, .network-breadcrumb, .history-filters, .section-title {
    padding-left: 20px;
    padding-right: 20px;
  }

  /* ผังไบนารี 4 ชั้น 15 โหนด บนจอ Surface Duo กว้าง 540px-720px ขยายให้อ่านง่ายเต็มตา */
  .tree-container { padding: 6px 16px 0; gap: 8px; }
  .tree-row { gap: 5px; }
  .tree-node { min-height: 60px; padding: 7px 4px; border-radius: 12px; }
  .node-addr { font-size: 12px; }
  .lv4 .node-addr { font-size: 10.5px; }
  .node-name { font-size: 11px; }
  .lv4 .node-name { font-size: 9.5px; }
  .node-pv { font-size: 10px; }
  .lv4 .node-pv { font-size: 9px; }
}

/* 4. Surface Duo แนวนอน (720x540) หรือจอพับกางออก (640px - 768px): แสดง Matrix 3 คอลัมน์ & แพ็กเกจ 2 คอลัมน์ */
@media (min-width: 640px) and (max-width: 768px) {
  .s10-matrix-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  #packages-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 20px;
  }
  #packages-list .pkg-card {
    margin: 0;
  }
}

