
/* =========================
   IMPORT KANIT FONT (Google Fonts)
========================= */
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@200;400&display=swap');

/* =========================
   APPLY TO ENTIRE WEBSITE
========================= */
* {
  font-family: 'Kanit', sans-serif !important;
}

body, button, input, textarea, select {
  font-family: 'Kanit', sans-serif !important;
  font-weight: 200 !important; /* บังคับน้ำหนักฟอนต์เป็น Extra-light 200 */
}

:root {
  --primary: #0f766e;
  --primary-light: #14b8a6;
  --accent: #5eead4;

  --bg-dark: #020617;
  --bg-main: #022c22;
  --bg-soft: #064e3b;

  --text-main: #ecfeff;
  --text-sub: #99f6e4;
  --text-dim: #5eead4;

  --danger: #ef4444;
  --success: #22c55e;
}

/* =========================
   RESET & BASE
========================= */
* {
  box-sizing: border-box;
  background-clip: padding-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg-dark);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(circle at top, rgba(20,184,166,.12), transparent 30%),
    linear-gradient(180deg, var(--bg-dark), var(--bg-main));
  color: var(--text-main);
}

img, canvas {
  display: block;
  max-width: 100%;
}

/* =========================
   TOPBAR & LAYOUT
========================= */
.topbar {
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(94,234,212,.15);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.topbar-inner {
  display: flex;
  justify-content: center;
  align-items: center;
}

.brand-logo {
  height: 60px; 
  width: auto;
  max-width: 80%;
  object-fit: contain;
  display: block;
  margin: 10px auto;
  transform: scale(1.8);
  transform-origin: center;
}

@media (min-width: 768px) {
  .brand-logo {
    height: 80px;
    margin: 15px 0;
  }
}

.app-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.member-view { display: none; }
.member-view.active { display: block; }

.tab-page {
  display: none;
  /* เผื่อพื้นที่ให้ Bottom Nav + iOS Safe Area */
  padding-bottom: calc(65px + env(safe-area-inset-bottom) + 20px);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-page.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* =========================
   TYPOGRAPHY
========================= */
.profile-head { text-align: center; margin-bottom: 16px; }
.profile-name { font-size: 34px; font-weight: 900; color: var(--text-main); }
.profile-sub { color: var(--text-dim); margin-top: 8px; }
.section-title { font-size: 18px; font-weight: 900; margin-bottom: 14px; text-align: center; letter-spacing: .5px; }

@media (max-width: 640px) {
  .profile-name { font-size: 28px; }
  .info-value-lg { font-size: 32px; }
}

/* =========================
   BUTTONS
========================= */
.action-btn {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all .15s ease;
}
.action-btn:active { transform: scale(.96); }

.action-btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #001f1c; box-shadow: 0 10px 24px rgba(20,184,166,.35); }
.action-btn.secondary { background: rgba(255,255,255,.08); color: var(--text-main); }

.back-btn {
  display: block;
  margin: 18px auto 0;
  padding: 14px 28px;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #001f1c;
  box-shadow: 0 10px 24px rgba(20,184,166,.35);
  cursor: pointer;
  transition: all .2s ease;
}
.back-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(20,184,166,.45); }
.back-btn:active { transform: scale(.96); }

/* =========================
   MEMBER DASHBOARD (INFO)
========================= */
.info-box {
  background: rgba(255,255,255,.04);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}
.info-label { font-size: 12px; color: var(--text-dim); }
.info-value-lg { font-size: 38px; font-weight: 900; color: var(--accent); }

.rank-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  margin-top: 8px;
}
.rank-newbie { background: #cd7f32; color: #fff; }
.rank-pro { background: #94a3b8; color: #fff; }
.rank-legend { background: #fbbf24; color: #451a03; }

.rank-progress-wrap {
  max-width: 260px;
  margin: 18px auto 0;
  text-align: center;
}
.rank-progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}
.rank-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--primary-light));
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(94,234,212,0.4);
}
.rank-progress-text { font-size: 13px; color: var(--text-dim); }
.rank-progress-text span { color: var(--text-main); font-weight: 900; }

/* =========================
   STAMP WALLET
========================= */
.stamp-wallet-card {
  margin-top: 20px;
  background: linear-gradient(145deg, #022c22, #021a16);
  border: 1px solid rgba(94, 234, 212, 0.2);
  border-radius: 20px;
  padding: 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 15px 35px rgba(0,0,0,0.5), inset 0 0 20px rgba(20,184,166,0.15);
}

.stamp-wallet-left { display: flex; align-items: center; gap: 14px; }
.stamp-glow-icon {
  width: 60px; height: 60px; border-radius: 50%;
  background: radial-gradient(circle at center, rgba(20,184,166,0.2), transparent);
  border: 1px solid rgba(94,234,212,0.3);
  padding: 8px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 15px rgba(20,184,166,0.4);
  animation: pulseGlow 2s infinite alternate;
}
.stamp-glow-icon img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }

@keyframes pulseGlow {
  0% { box-shadow: 0 0 10px rgba(20,184,166,0.2); transform: scale(1); }
  100% { box-shadow: 0 0 25px rgba(94,234,212,0.6); transform: scale(1.05); }
}

.stamp-wallet-info h3 { margin: 0; font-size: 13px; color: var(--text-dim); font-weight: normal; }
.stamp-wallet-info .amount { font-size: 32px; font-weight: 900; color: var(--accent); line-height: 1; margin-top: 4px; }

.jump-gacha-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #001f1c; border: none; border-radius: 999px; padding: 10px 16px;
  font-size: 12px; font-weight: 800; cursor: pointer; display: flex; flex-direction: column; align-items: center;
  box-shadow: 0 4px 10px rgba(20,184,166,0.3); transition: transform 0.1s ease;
}
.jump-gacha-btn:active { transform: scale(0.95); }

/* =========================
   PREMIUM GACHA UI
========================= */
.cs-gacha-container {
  display: flex; flex-direction: column; width: 100%; max-width: 480px; margin: 0 auto; padding-bottom: 10px;
}
.gacha-premium-header { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 20px; padding: 0 4px; }
.gacha-premium-header .g-title { font-size: 20px; font-weight: 900; color: var(--accent); text-shadow: 0 0 10px rgba(94, 234, 212, 0.4); }
.g-stamp-badge {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: linear-gradient(135deg, rgba(20,184,166,0.15), rgba(2,44,34,0.8));
  border: 1px solid rgba(94,234,212,0.4);
  box-shadow: 0 4px 15px rgba(0,0,0,0.4), inset 0 0 10px rgba(20,184,166,0.2);
}
.g-stamp-badge img { width: 22px; height: 22px; filter: drop-shadow(0 0 5px rgba(20,184,166,0.6)); }
.g-stamp-badge span { font-size: 16px; font-weight: 900; color: #fff; }

.gacha-center-wrapper { margin: auto 0; display: flex; flex-direction: column; align-items: center; width: 100%; }

.gacha-idle-state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; transition: opacity 0.4s ease; z-index: 1; }
.idle-pulse-circle {
  width: 70px; height: 70px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.03); border: 2px dashed rgba(94, 234, 212, 0.3);
  animation: idlePulse 2.5s infinite alternate; z-index: 2; margin-bottom: 20px;
}

/* =========================
   CUSTOM GACHA MACHINE (IMAGE MAPPING)
========================= */
.gacha-machine-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 760 / 1024;
  background-image: url('https://i.im.ge/QMTm6za/GACHAAA.png');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  margin: 0 auto;
}
.gacha-machine-wrap::after { display: none; }
.gacha-spin-btn { display: none !important; }

/* =========================
   1. IDLE STATE & GLASS WINDOW (จัดให้อยู่กึ่งกลาง)
========================= */
#gacha-glass-window {
  position: absolute !important;
  top: 24% !important;   
  left: 9% !important;
  width: 82% !important;
  height: 36% !important; 
  overflow: hidden !important;
  z-index: 1 !important;
  margin: 0 !important; /* ป้องกัน margin จากเว็บหลัก */
  padding: 0 !important; /* ป้องกัน padding จากเว็บหลัก */
  box-sizing: border-box !important;
}

#gacha-idle {
  position: absolute !important;
  top: 50% !important;  
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* อนิเมชั่น Idle ใหม่ ให้ดูลอยๆ มีแสงออร่า */
.idle-pulse-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.3) 0%, rgba(94, 234, 212, 0) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: floatPulse 2.5s ease-in-out infinite;
}
.idle-pulse-circle span {
  font-size: 55px;
  font-weight: 900;
  color: #5eead4;
  text-shadow: 0 0 15px #5eead4, 0 0 30px #5eead4;
}

@keyframes floatPulse {
  0% { transform: scale(1) translateY(0); opacity: 0.6; }
  50% { transform: scale(1.1) translateY(-12px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 0.6; }
}

/* =========================
   2. HOLE BUTTON (ปุ่มซ้ายมือ พร้อมเอฟเฟกต์ PUSH)
========================= */
.spin-hole-btn {
  position: absolute;
  left: 15.65%;  
  top: 73.7%; 
  width: 17%;   
  height: 13%;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(94, 234, 212, 0.6);
  border-radius: 12px;
  cursor: pointer;
  z-index: 20;
  animation: btnGlowPulse 1.5s infinite alternate;
  transition: all 0.1s;
}

/* ใส่คำว่า PUSH ตรงกลางรู */
.spin-hole-btn::after {
  content: 'PUSH';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-weight: 900;
  font-size: 15px;
  text-shadow: 0 0 8px #5eead4;
  letter-spacing: 1px;
}

@keyframes btnGlowPulse {
  0% { box-shadow: 0 0 5px rgba(94, 234, 212, 0.2), inset 0 0 10px rgba(94, 234, 212, 0.2); }
  100% { box-shadow: 0 0 20px rgba(94, 234, 212, 0.8), inset 0 0 25px rgba(94, 234, 212, 0.6); border-color: #5eead4; }
}

.spin-hole-btn:active {
  transform: scale(0.92); /* เวลากดให้บุ๋มลงไป */
  background: rgba(94, 234, 212, 0.5);
  box-shadow: inset 0 0 30px rgba(94, 234, 212, 1);
}
.spin-hole-btn:active::after {
  color: #001f1c; /* เปลี่ยนสีตัวอักษรตอนกด */
  text-shadow: none;
}

/* =========================
   3. BOTTOM CHUTE & PRIZE REVEAL (อัปไซส์รางวัลและจัดตำแหน่ง)
========================= */
.bottom-chute {
  position: absolute !important;
  left: 36.5% !important;    
  bottom: 2% !important;   
  width: 26% !important;   
  height: 12% !important;  
  z-index: 15 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* บังคับขนาดแคปซูลไข่เป็น 100px ขั้นเด็ดขาด */
.gacha-capsule-container {
  position: relative !important;
  top: 0 !important;
  width: 100px !important;
  height: 100px !important;
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none !important;
}

.egg-half {
  width: 100px !important;
  height: 50px !important;
  background-size: 100px 100px !important;
}

.egg-half.top { 
  border-radius: 50px 50px 0 0 !important; 
}

.egg-half.bottom { 
  border-radius: 0 0 50px 50px !important; 
}
.gacha-capsule-container.opening .egg-half.top { 
  transform: translateY(-40px) rotate(-20deg) scale(0.8) !important; 
}
.gacha-capsule-container.opening .egg-half.bottom { 
  transform: translateY(40px) rotate(20deg) scale(0.8) !important; 
}

/* =========================
   4. PRIZE REVEAL (แก้ปัญหาทับตู้ & อ่านยาก)
========================= */
.prize-reveal {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  /* เริ่มต้นให้เล็กๆ และซ่อนไว้ก่อน */
  transform: translate(-50%, -50%) scale(0.5) !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  opacity: 0 !important;
  /* เพิ่ม transition ให้เด้งสมูทๆ */
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

/* ตอนไข่เปิด บังคับให้รางวัล "เด้งลอยขึ้นมา" เหนือรู และขยายใหญ่ขึ้น */
.gacha-capsule-container.opening .prize-reveal { 
  opacity: 1 !important; 
  /* ดันแกน Y ขึ้นไปด้านบน (-120%) เพื่อให้พ้นกรอบรูด้านล่าง */
  transform: translate(-50%, -120%) scale(1.1) !important; 
  transition-delay: 0.2s !important; 
  z-index: 50 !important;
}

/* สร้างแสงออร่าซ้อนกัน 2 ชั้นด้านหลังรูปรางวัล ให้ตัดกับสีตู้ */
.prize-reveal img { 
  width: 75px !important; 
  height: 75px !important; 
  object-fit: contain !important;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 1)) drop-shadow(0 0 25px rgba(94, 234, 212, 0.8)) !important;
}

/* ทำป้ายพื้นหลังทึบให้ข้อความ เพื่อให้อ่านง่าย 100% ในทุกสถานการณ์ */
.prize-reveal-text { 
  font-size: 14px !important; 
  font-weight: 900 !important;
  margin-top: 12px !important; 
  padding: 6px 16px !important;
  background: rgba(15, 23, 42, 0.9) !important; /* พื้นหลังสีเข้มทึบ */
  border: 2px solid #5eead4 !important; /* ขอบสีอควา */
  border-radius: 20px !important; /* ทรงป้ายแคปซูล */
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), 0 0 15px rgba(94, 234, 212, 0.4) !important;
  color: #ffffff !important; /* บังคับตัวหนังสือสีขาว */
  white-space: nowrap !important;
  backdrop-filter: blur(4px) !important; /* เบลอฉากหลังนิดๆ */
}

/* อนิเมชั่นไข่ไหลออกมาจากช่อง */
@keyframes popOutChute {
  0% { transform: translateY(-20px) scale(0.5); opacity: 0; }
  60% { transform: translateY(10px) scale(1.1); opacity: 1; }
  80% { transform: translateY(-5px) scale(0.95); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; filter: drop-shadow(0 0 15px rgba(94,234,212,0.8)); }
}
.gacha-capsule-container.dropping {
  animation: popOutChute 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
}

.prize-pool-premium {
  margin-top: 30px; padding: 16px; width: 100%; border-radius: 16px;
  background: linear-gradient(145deg, rgba(255,255,255,0.04), rgba(0,0,0,0.3));
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.pool-header { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 12px; }
.pool-header::before, .pool-header::after { content: ""; height: 1px; flex: 1; background: linear-gradient(90deg, transparent, rgba(94,234,212,0.3), transparent); }
.prize-list-mini { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.prize-list-mini > :last-child:nth-child(odd) { grid-column: span 2; }
.prize-badge { background: rgba(0, 0, 0, 0.5); padding: 12px 8px; border-radius: 12px; font-size: 12px; font-weight: 700; color: #fff; border: 1px solid rgba(255, 255, 255, 0.05); border-left-width: 4px; display: flex; align-items: center; justify-content: center; text-align: center; box-shadow: inset 0 0 10px rgba(0,0,0,0.5); }

/* Gacha Animation Base */
/* Gacha Animation Base (Updated to Kinetic Burst) */
:root { --egg-img: url('https://i.im.ge/ee8Csr/GACHA.png'); }

.gacha-capsule-container { 
  position: absolute; 
  top: -100px; /* Hidden above initial */
  width: 120px; 
  height: 120px; 
  z-index: 10; 
  opacity: 0; 
  transform: scale(0.5); 
  transition: opacity 0.2s ease;
  pointer-events: none; /* Prevent tapping during animation */
}

.gacha-capsule-container.dropping { opacity: 1; animation: eggDrop 1.5s cubic-bezier(0.36, 0, 0.66, -0.56) forwards; }
.egg-half { position: absolute; width: 120px; height: 60px; background-image: var(--egg-img); background-size: 120px 120px; background-repeat: no-repeat; transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s; }
.egg-half.top { top: 0; border-radius: 60px 60px 0 0; background-position: top center; transform-origin: bottom center; }
.egg-half.bottom { bottom: 0; border-radius: 0 0 60px 60px; background-position: bottom center; transform-origin: top center; }
.gacha-capsule-container.opening .egg-half.top { transform: translateY(-80px) rotate(-20deg) scale(0.8); opacity: 0; }
.gacha-capsule-container.opening .egg-half.bottom { transform: translateY(80px) rotate(20deg) scale(0.8); opacity: 0; }
.prize-reveal { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: 0; transform: scale(0); transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); transition-delay: 0.3s; z-index: 5; }
.gacha-capsule-container.opening .prize-reveal { opacity: 1; transform: scale(1.2); }
.prize-reveal img { width: 80px; height: 80px; object-fit: contain; filter: drop-shadow(0 0 15px rgba(255,255,255,0.5)); }
.prize-reveal-text { margin-top: 10px; font-weight: 900; font-size: 16px; text-align: center; text-shadow: 0 2px 4px rgba(0,0,0,0.8); }
.particle { position: absolute; top: 50%; left: 50%; width: 8px; height: 8px; border-radius: 50%; pointer-events: none; opacity: 0; }
.dummy-egg { position: absolute; width: 90px; height: 90px; scale: 1.7; background-image: var(--egg-img); background-size: cover; background-position: center; border-radius: 50%; z-index: 8; top: -120px; opacity: 0; pointer-events: none; }

/* =========================
   UNIFIED HISTORY CARDS (ปรับดีไซน์ให้ดูเป็นการ์ดเดียวกันทั้งประวัติแลกของและประวัติแต้ม)
========================= */
.history-card { margin-top: 20px; background: linear-gradient(135deg, var(--bg-dark), var(--bg-soft)); border-radius: 18px; padding: 16px; box-shadow: inset 0 0 20px rgba(20,184,166,.12); }
.history-scroll-area { max-height: 260px; overflow-y: auto; padding-right: 6px; display: flex; flex-direction: column; gap: 8px; }
.history-scroll-area::-webkit-scrollbar { width: 4px; }
.history-scroll-area::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.05); border-radius: 10px; }
.history-scroll-area::-webkit-scrollbar-thumb { background: rgba(94, 234, 212, 0.3); border-radius: 10px; }

.unified-history-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.05), rgba(0,0,0,0.2));
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  flex-shrink: 0; 
  height: auto; 
}
.uh-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; width: 100%; }
.uh-title { font-size: 14px; font-weight: 800; color: var(--text-main); line-height: 1.3; white-space: normal; word-break: break-word; }
.uh-amount { font-size: 14px; font-weight: 900; white-space: nowrap; }
.uh-amount.plus { color: var(--success); }
.uh-amount.minus { color: var(--danger); }
.uh-amount.neutral { color: var(--text-dim); }
.uh-footer { display: flex; justify-content: space-between; align-items: center; font-size: 11px; width: 100%; margin-top: 4px; }
.uh-date { color: var(--text-dim); font-weight: 600; }
.uh-badge { padding: 4px 10px; border-radius: 999px; font-weight: 800; font-size: 10px; border: 1px solid transparent; white-space: nowrap; }
.uh-badge.success { background: rgba(34,197,94,0.15); color: #4ade80; border-color: rgba(34,197,94,0.3); }
.uh-badge.warning { background: rgba(245,158,11,0.15); color: #fbbf24; border-color: rgba(245,158,11,0.3); }
.uh-badge.neutral { background: rgba(255,255,255,0.1); color: #cbd5e1; border-color: rgba(255,255,255,0.2); }
.uh-badge.danger { background: rgba(239,68,68,0.15); color: #f87171; border-color: rgba(239,68,68,0.3); }
.uh-action-btn { width: 100%; padding: 10px; border-radius: 10px; border: none; font-weight: 800; font-size: 13px; cursor: pointer; background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #001f1c; display: flex; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 4px 10px rgba(20,184,166,0.2); margin-top: 6px; }

/* =========================
   REWARDS & PRODUCTS GRID
========================= */
.reward-grid, .product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 14px; }
@media (max-width: 380px) { .product-grid { grid-template-columns: 1fr; } }

.reward-card, .product-card {
  background: linear-gradient(145deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid rgba(94,234,212,.2); border-radius: 16px; padding: 12px;
  text-align: center; transition: all .2s ease; position: relative; overflow: hidden;
}
.reward-card:hover, .product-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(0,0,0,.5); }

.reward-img { width: 100%; height: 110px; object-fit: cover; border-radius: 12px; }
.reward-name { font-weight: 900; margin-top: 8px; }
.reward-points { color: var(--accent); font-weight: 900; margin-top: 4px; }
.reward-stock { font-size: 12px; color: var(--text-dim); }
.reward-btn { margin-top: 8px; width: 100%; padding: 10px; border-radius: 999px; border: none; font-weight: 800; color: #ffffff; cursor: pointer; background: linear-gradient(135deg, var(--primary), var(--primary-light)); }
.reward-btn:active { transform: scale(.96); }
.reward-btn:disabled { color: rgba(255,255,255,.6); }
.reward-sold { position: absolute; top: 10px; right: 10px; background: red; color: white; font-size: 10px; padding: 4px 6px; border-radius: 6px; }

.product-page { padding-bottom: 90px; }
.product-header { font-size: 22px; font-weight: 900; text-align: center; padding: 18px; color: var(--text-main); letter-spacing: .5px; }
.product-badge-new { position: absolute; top: 10px; left: 10px; z-index: 10; background: linear-gradient(135deg, #22c55e, #4ade80); color: #00210f; font-size: 11px; font-weight: 900; padding: 4px 8px; border-radius: 999px; }
.product-image-wrap { position: relative; height: 160px; background: #021a16; display: flex; align-items: center; justify-content: center; }
.product-img { width: 100%; height: 100%; object-fit: contain; transition: transform .3s ease; }
.product-card:hover .product-img { transform: scale(1.08); }
.product-info { padding: 14px; }
.product-name { font-size: 14px; font-weight: 900; color: var(--text-main); line-height: 1.3; }
.product-desc { font-size: 12px; color: var(--text-dim); margin-top: 4px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-bottom { margin-top: 10px; display: flex; justify-content: space-between; align-items: center; }
.product-price { font-size: 14px; font-weight: 900; color: var(--accent); }
.product-btn { border: none; padding: 6px 12px; border-radius: 999px; font-size: 11px; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #001f1c; cursor: pointer; transition: .2s; }

/* =========================
   NEWS & BANNER
========================= */
.news-grid { display: grid; gap: 14px; margin-top: 10px; }
.news-card { background: linear-gradient(145deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); border: 1px solid rgba(94,234,212,.2); border-radius: 16px; overflow: hidden; cursor: pointer; transition: all .25s ease; }
.news-card:hover { transform: translateY(-4px) scale(1.01); box-shadow: 0 20px 40px rgba(0,0,0,.5); }
.news-img { width: 100%; height: 140px; object-fit: cover; }
.news-body { padding: 10px; }
.news-title { font-weight: 900; }
.news-date { font-size: 11px; opacity: .6; }

.banner-wrap { overflow: hidden; border-radius: 16px; touch-action: pan-y; overscroll-behavior-x: none; }
.banner-slider { display: flex; transition: transform 0.4s ease; touch-action: pan-y; }
.banner-item { min-width: 100%; position: relative; }
.banner-item img { width: 100%; height: 160px; object-fit: cover; -webkit-user-drag: none; user-select: none; pointer-events: none; }
.banner-item::before { content: ""; position: absolute; inset: 0; z-index: 5; }
.banner-overlay { position: absolute; bottom: 0; width: 100%; padding: 12px; background: linear-gradient(transparent, rgba(0,0,0,.8)); z-index: 10; pointer-events: none; }
.banner-title { font-weight: 900; }
.banner-dots { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.banner-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.3); }
.banner-dot.active { background: white; }

/* =========================
   QR VIEW
========================= */
.qr-card {
  background: linear-gradient(135deg, var(--bg-dark), var(--bg-soft)); border-radius: 18px; padding: 18px;
  box-shadow: 0 0 30px rgba(20,184,166,.25), inset 0 0 20px rgba(20,184,166,.15);
}
.qr-grid { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.qr-box { width: 240px; height: 240px; background: white; border-radius: 12px; padding: 10px; display: flex; align-items: center; justify-content: center; }
.member-code-inline { margin-top: 12px; font-size: 16px; font-weight: 800; text-align: center; letter-spacing: 1px; color: var(--text-main); }
.timer-circle { width: 120px; height: 120px; margin: auto; position: relative; display: flex; align-items: center; justify-content: center; }
.timer-circle::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 10px solid rgba(255,255,255,.15); border-top-color: var(--primary-light); animation: spin 1s linear infinite; }
.timer-inner { position: relative; z-index: 2; text-align: center; }
.timer-seconds { font-size: 28px; font-weight: 900; line-height: 1; }
.timer-label { font-size: 12px; opacity: .8; margin-top: 4px; }
#redeem-qr-box { display: flex; align-items: center; justify-content: center; margin-top: 12px; background: white; padding: 16px; border-radius: 12px; width: fit-content; margin-left: auto; margin-right: auto; }
.redeem-warning { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.4); color: #fecaca; font-size: 13px; padding: 10px; border-radius: 10px; margin: 12px 0; line-height: 1.4; }

/* =========================
   MODALS
========================= */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.modal.hidden { display: none; }
.modal-card { background: var(--bg-main); padding: 20px; border-radius: 16px; text-align: center; width: 90%; max-width: 320px; }
.modal-actions { margin-top: 12px; display: flex; gap: 10px; color: white; }
.modal-btn { flex: 1; padding: 10px; border-radius: 999px; border: none; font-weight: 800; color: white; }
.modal-btn.confirm { background: linear-gradient(135deg, #22c55e, #4ade80); }
.modal-btn.cancel { background: rgba(255,255,255,.1); }

.news-modal img { width: 100%; border-radius: 12px; margin-bottom: 10px; }
.product-modal-card { padding: 0; overflow: hidden; max-width: 360px; }
.product-modal-image-wrap { background: #021a16; height: 220px; display: flex; align-items: center; justify-content: center; }
.product-modal-image { width: 100%; height: 100%; object-fit: contain; }
.product-modal-body { padding: 16px; text-align: center; }
.product-modal-name { font-size: 18px; font-weight: 900; color: var(--text-main); }
.product-modal-price { margin-top: 6px; font-size: 16px; font-weight: 900; color: var(--accent); }
.product-modal-desc { margin-top: 10px; font-size: 13px; color: var(--text-dim); line-height: 1.6; white-space: pre-line; }
.product-modal-close { margin-top: 14px; width: 100%; padding: 12px; border-radius: 999px; border: none; font-weight: 800; cursor: pointer; background: linear-gradient(135deg, #0f766e, #14b8a6); color: #001f1c; }

/* =========================
   BOTTOM NAVIGATION
========================= */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; width: 100%; height: 65px;
  background: #111; display: flex; justify-content: space-around; align-items: center; z-index: 999; border-top: 1px solid #222;
  /* รองรับ iPhone รุ่นใหม่ๆ ไม่ให้แถบไปทับ Home Indicator */
  padding-bottom: env(safe-area-inset-bottom);
  box-sizing: content-box;
}
.nav-item { color: #777; font-size: 22px; transition: 0.2s; min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; cursor: pointer; }
.nav-item.active { color: #fff; transform: scale(1.15); }
.nav-icon { width: 22px; height: 22px; stroke-linecap: round; stroke-linejoin: round; stroke: #777; fill: none; stroke-width: 2; transition: 0.2s; display: block; }
.nav-item.active .nav-icon { stroke: #fff; }
.nav-item span { font-size: 12px; display: block; margin-top: 2px; color: #777; line-height: 1; }
.nav-item.active span { color: #fff; }

/* =========================
   SIDEBAR & LOGIN
========================= */
.login-screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(180deg, #020617, #022c22); z-index: 999999; padding: 20px; text-align: center; }
.login-screen.hidden { display: none !important; }
.login-logo { height: 100px; margin-bottom: 25px; animation: float 3s ease-in-out infinite; }
.login-btn { width: 100%; max-width: 280px; padding: 14px; border-radius: 999px; font-weight: 800; font-size: 15px; border: none; margin-bottom: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 10px; transition: all 0.2s; }
.login-btn:active { transform: scale(0.96); }
.btn-line { background: #06C755; color: white; box-shadow: 0 4px 15px rgba(6, 199, 85, 0.3); }

.menu-btn { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-main); padding: 8px; cursor: pointer; z-index: 100; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 9999998; opacity: 0; visibility: hidden; transition: all 0.3s ease; }
.sidebar-overlay.active { opacity: 1; visibility: visible; }
.sidebar { position: fixed; top: 0; right: -280px; width: 280px; height: 100%; background: var(--bg-dark); border-left: 1px solid rgba(94, 234, 212, 0.2); z-index: 9999999; transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5); }
.sidebar.active { right: 0; }
.sidebar-header { padding: 24px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.sidebar-header h3 { margin: 0; color: var(--accent); font-weight: 900; }
.close-btn { background: rgba(255,255,255,0.1); border: none; color: white; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.sidebar-menu { padding: 20px 0; flex: 1; overflow-y: auto; }
.menu-item { padding: 16px 24px; color: var(--text-main); font-size: 15px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 12px; transition: background 0.2s; }
.menu-item:hover { background: rgba(255, 255, 255, 0.05); }
.menu-item.logout { color: var(--danger); margin-top: 20px; border-top: 1px solid rgba(255, 255, 255, 0.05); }

.lang-toggle-wrap { margin-top: auto; padding: 20px; display: flex; justify-content: center; align-items: center; gap: 20px; }
.lang-btn { font-size: 16px; font-weight: 800; color: var(--text-dim); cursor: pointer; transition: all 0.2s ease; padding-bottom: 2px; }
.lang-btn:hover { color: white; }
.lang-btn.active { color: #0f766e; border-bottom: 2px solid #14b8a6; }
.lang-divider { width: 2px; height: 20px; background-color: var(--text-main); }

/* =========================
   UTILITIES & ANIMATIONS
========================= */
.empty { text-align: center; padding: 20px; color: #666; font-size: 14px; }
.fade-in { animation: fadeIn 0.4s ease forwards; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton Loading */
.skeleton-card { padding: 12px; }
.skeleton { background: linear-gradient(90deg, #2a2a2a, #333, #2a2a2a); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px; }
.skeleton-img { height: 140px; margin-bottom: 10px; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* Loading Screen */
.loading-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg, #020617, #022c22); z-index: 99999; }
.loading-screen.hidden { display: none; }
.loading-card { text-align: center; }
.loading-logo { width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 50%; border: 4px solid rgba(255,255,255,.2); border-top-color: var(--primary-light); animation: spin 1s linear infinite; }

/* =========================
   ADMIN (Optional)
========================= */
.admin-body { background: linear-gradient(180deg, var(--bg-dark), var(--bg-main)); color: var(--text-main); }
.admin-header { text-align: center; padding: 28px 16px 10px; }
.admin-title { font-size: 28px; font-weight: 900; color: var(--accent); }
.admin-subtitle { font-size: 14px; color: var(--text-dim); margin-top: 6px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; padding: 16px; }
.admin-card { background: linear-gradient(145deg, rgba(255,255,255,.05), rgba(255,255,255,.02)); border: 1px solid rgba(94,234,212,.15); border-radius: 16px; padding: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.4), inset 0 0 15px rgba(20,184,166,.08); transition: all .2s ease; }
.admin-input { width: 100%; margin-bottom: 10px; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,.1); background: rgba(0,0,0,.3); color: var(--text-main); outline: none; transition: all .15s ease; }
.admin-input:focus { border-color: var(--primary-light); box-shadow: 0 0 0 2px rgba(20,184,166,.2); }
.admin-button { width: 100%; padding: 12px; border-radius: 999px; border: none; font-weight: 800; cursor: pointer; transition: all .15s ease; background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #001f1c; }
.admin-button.green { background: linear-gradient(135deg, #22c55e, #4ade80); color: #00210f; }
.admin-button.red { background: linear-gradient(135deg, #ef4444, #f87171); color: #2a0000; }
.status-box { margin-top: 10px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,.05); font-size: 13px; text-align: center; }
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 999999; display: flex; flex-direction: column; gap: 10px; }
.toast { min-width: 220px; padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; color: #001f1c; animation: toastIn .25s ease; }
.toast.success { background: linear-gradient(135deg, #22c55e, #4ade80); }
.toast.error { background: linear-gradient(135deg, #ef4444, #f87171); color: #2a0000; }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* DB Analytics */
.db-container { max-width: 920px; margin: 40px auto 20px; padding: 20px 16px; border-top: 1px dashed rgba(94,234,212,.3); }
.db-header { text-align: center; margin-bottom: 24px; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.mcard { background: linear-gradient(145deg, rgba(255,255,255,.05), rgba(255,255,255,.01)); border: 1px solid rgba(94,234,212,.15); border-radius: 16px; padding: 16px 14px; }
@media (min-width: 768px) { .metrics { grid-template-columns: repeat(4, 1fr); } }

/* =========================
   DASHBOARD ANALYTICS (RESTORED)
========================= */
.db-container { max-width: 920px; margin: 40px auto 20px; padding: 20px 16px; border-top: 1px dashed rgba(94,234,212,.3); }
.db-header { text-align: center; margin-bottom: 24px; }
.db-header h2 { font-size: 24px; font-weight: 900; color: var(--accent); margin-bottom: 4px; }
.db-header span { font-size: 13px; color: var(--text-dim); }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
@media (min-width: 768px) { .metrics { grid-template-columns: repeat(4, 1fr); } }

.mcard { background: linear-gradient(145deg, rgba(255,255,255,.05), rgba(255,255,255,.01)); border: 1px solid rgba(94,234,212,.15); border-radius: 16px; padding: 16px 14px; box-shadow: inset 0 0 10px rgba(20,184,166,.05); }
.mcard .label { font-size: 11px; color: var(--text-dim); margin-bottom: 6px; }
.mcard .val { font-size: 22px; font-weight: 900; color: var(--text-main); }
.mcard .delta { font-size: 11px; margin-top: 6px; font-weight: 700; }
.mcard .delta.up { color: var(--success); }
.mcard .delta.down { color: var(--danger); }

.db-row { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
@media (min-width: 768px) { .db-row { grid-template-columns: 1fr 1fr; } }

.prize-list, .member-list, .timeline { display: flex; flex-direction: column; margin-top: 10px; }
.prize-row, .member-row, .tl-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.prize-row:last-child, .member-row:last-child, .tl-row:last-child { border-bottom: none; }

.prize-row .name { font-size: 13px; font-weight: 600; }
.prize-row .cnt { font-size: 13px; font-weight: 900; color: var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

.avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex-shrink: 0; background: rgba(94,234,212,.1); color: var(--accent); }
.member-info { flex: 1; margin-left: 12px; }
.member-name { font-size: 13px; font-weight: 800; }
.member-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px;}
.member-pts { font-size: 13px; font-weight: 900; color: var(--text-main); }

.funnel { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.funnel-row { display: flex; align-items: center; gap: 10px; }
.funnel-name { font-size: 12px; width: 90px; flex-shrink: 0; color: var(--text-dim); }
.funnel-bar { height: 22px; border-radius: 6px; display: flex; align-items: center; padding-left: 8px; font-size: 11px; font-weight: 900; color: #000; }

.tl-row { align-items: flex-start; gap: 12px; }
.tl-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; background: rgba(255,255,255,.05); }
.tl-main { flex: 1; }
.tl-title { font-size: 13px; font-weight: 800; color: var(--text-main); }
.tl-sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.tl-time { font-size: 11px; color: rgba(255,255,255,.4); }

/* =========================
   BUTTON FONT OVERRIDE (แก้ปุ่มให้อ่านง่าย)
========================= */
button, 
.btn, 
.button,
a.btn {
  font-weight: 400 !important; /* ปรับความหนาให้เป็นระดับปกติ (Regular) */
  font-size: 16px !important; /* ปรับขนาดให้ใหญ่ขึ้น (ลองแก้ตัวเลข 16 เป็น 18 ได้ถ้ายังเล็กไป) */
  letter-spacing: 0.1px !important; /* ถ่างช่องไฟตัวอักษรนิดนึงให้อ่านง่ายขึ้น */
}


