/* =====================================================================
 * MAGER COIN - Telegram Mini App Theme & Animations
 * ===================================================================== */

:root {
  --bg-primary: #0A0D16;
  --bg-secondary: #131728;
  --bg-card: rgba(22, 27, 46, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 215, 0, 0.15);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --gold-glow: #F1C40F;
  --gold-primary: #F39C12;
  --gold-dark: #D35400;
  --accent-purple: #9B59B6;
  --accent-blue: #3498DB;
  --accent-cyan: #00D2D3;
  --success: #2ECC71;
  --danger: #E74C3C;
  --warning: #F39C12;
  --text-main: #FFFFFF;
  --text-muted: #8E9BB0;
  --text-dim: #576574;
  --bottom-nav-height: 70px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 50% 15%, rgba(243, 156, 18, 0.12) 0%, transparent 65%),
    radial-gradient(circle at 10% 85%, rgba(155, 89, 182, 0.14) 0%, transparent 50%),
    radial-gradient(circle at 90% 90%, rgba(52, 152, 219, 0.12) 0%, transparent 50%);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 16px);
}

/* App Container */
.app-viewport {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  padding: 14px 16px;
}

/* Top App Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 16px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px 6px 8px;
  border-radius: 30px;
  backdrop-filter: blur(10px);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-primary), var(--accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  color: #FFF;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.2);
}

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

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: #FFF;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status {
  font-size: 10px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.pill-streak {
  background: rgba(243, 156, 18, 0.15);
  border: 1px solid rgba(243, 156, 18, 0.3);
  color: var(--gold-glow);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.2s;
}

.pill-streak:active {
  transform: scale(0.95);
}

/* Tab Screens */
.tab-screen {
  display: none;
  flex-direction: column;
  flex: 1;
  animation: tabFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-screen.active {
  display: flex;
}

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

/* =====================================================================
 * HOME SCREEN - TAP GAME
 * ===================================================================== */
.score-box {
  text-align: center;
  margin: 12px 0 20px;
}

.coin-counter {
  font-size: 38px;
  font-weight: 900;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-shadow: 0 2px 14px rgba(241, 196, 15, 0.4);
  letter-spacing: 0.5px;
}

.coin-counter-icon {
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 0 10px rgba(243, 156, 18, 0.8));
}

.rupiah-estimate {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

.rupiah-estimate span {
  color: var(--success);
  font-weight: 700;
}

/* Tap Coin Arena */
.coin-arena {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 280px;
  margin: 10px 0;
  touch-action: manipulation;
}

.coin-wrapper {
  position: relative;
  width: 230px;
  height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.coin-pulse {
  position: absolute;
  width: 250px;
  height: 250px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(243, 156, 18, 0.25) 0%, transparent 70%);
  animation: pulseGlow 2.5s infinite ease-in-out;
  pointer-events: none;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(0.95); opacity: 0.4; }
  50% { transform: scale(1.08); opacity: 0.8; }
}

.tap-coin {
  width: 210px;
  height: 210px;
  border-radius: 50%;
  filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.7));
  transition: transform 0.08s ease-out;
  will-change: transform;
}

.coin-wrapper:active .tap-coin {
  transform: scale(0.92);
}

/* Floating Click Feedback Animations (+10 MAGER) */
.floating-number {
  position: absolute;
  color: #FFF;
  font-size: 24px;
  font-weight: 900;
  pointer-events: none;
  text-shadow: 0 0 10px var(--gold-glow), 0 2px 4px rgba(0,0,0,0.8);
  animation: floatUp 0.8s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  z-index: 100;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(0.8);
  }
  50% {
    opacity: 1;
    transform: translateY(-40px) scale(1.15);
  }
  100% {
    opacity: 0;
    transform: translateY(-80px) scale(0.9);
  }
}

/* Energy & Boost Bar */
.game-bottom-controls {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.energy-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 14px 18px;
  backdrop-filter: blur(12px);
}

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

.energy-label {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #FFF;
}

.energy-count {
  font-size: 15px;
  font-weight: 800;
  color: var(--gold-glow);
}

.energy-progress-track {
  width: 100%;
  height: 10px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.energy-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #F39C12, #F1C40F);
  border-radius: 10px;
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(241, 196, 15, 0.7);
}

.energy-timer-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
}

/* Action Buttons (Watch Ads, Boost) */
.btn-ad-watch {
  background: linear-gradient(135deg, rgba(142, 68, 173, 0.8), rgba(41, 128, 185, 0.8));
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFF;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(142, 68, 173, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-ad-watch:active {
  transform: scale(0.97);
}

.btn-ad-watch:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* =====================================================================
 * RANK / LEADERBOARD SCREEN
 * ===================================================================== */
.section-header {
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 800;
  color: #FFF;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.my-rank-banner {
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.15), rgba(142, 68, 173, 0.15));
  border: 1px solid rgba(243, 156, 18, 0.35);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.rank-badge {
  font-size: 18px;
  font-weight: 900;
  color: var(--gold-glow);
}

.leader-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

.leader-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.leader-item.is-me {
  border-color: var(--gold-primary);
  background: rgba(243, 156, 18, 0.08);
}

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

.leader-pos {
  width: 26px;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  color: var(--text-muted);
}

.pos-1 { color: #F1C40F; font-size: 18px; }
.pos-2 { color: #BDC3C7; font-size: 18px; }
.pos-3 { color: #E67E22; font-size: 18px; }

.leader-name {
  font-size: 13px;
  font-weight: 700;
  color: #FFF;
}

.leader-score {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold-glow);
}

/* =====================================================================
 * INVITE / REFERRAL SCREEN
 * ===================================================================== */
.invite-hero {
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.15), rgba(41, 128, 185, 0.15));
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
}

.invite-hero h3 {
  font-size: 18px;
  color: #FFF;
  margin-bottom: 6px;
}

.invite-hero p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

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

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  text-align: center;
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: #FFF;
  margin-bottom: 2px;
}

.stat-value.gold { color: var(--gold-glow); }
.stat-value.green { color: var(--success); }

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

.ref-box {
  background: var(--bg-card);
  border: 1px dashed var(--border-glass);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
}

.ref-code-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.4);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.ref-code-text {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--gold-glow);
}

.btn-copy {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #FFF;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.btn-share-tg {
  width: 100%;
  background: #27A7E7;
  color: #FFF;
  border: none;
  padding: 14px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(39, 167, 231, 0.35);
}

/* =====================================================================
 * WALLET & WITHDRAW SCREEN
 * ===================================================================== */
.wallet-hero {
  background: linear-gradient(135deg, #1B2238 0%, #151829 100%);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  padding: 22px 18px;
  margin-bottom: 18px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.4);
  position: relative;
  overflow: hidden;
}

.wallet-hero::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, rgba(243, 156, 18, 0.25) 0%, transparent 70%);
}

.wallet-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 14px;
}

.wallet-coin-val {
  font-size: 30px;
  font-weight: 900;
  color: #FFF;
}

.wallet-idr-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--success);
}

.withdraw-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 18px;
}

.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-styled, .select-styled {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 12px 14px;
  color: #FFF;
  font-size: 14px;
  outline: none;
}

.input-styled:focus, .select-styled:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 10px rgba(243, 156, 18, 0.25);
}

.select-styled option {
  background: #111;
  color: #FFF;
}

.btn-withdraw-submit {
  width: 100%;
  background: linear-gradient(135deg, var(--gold-glow), var(--gold-primary));
  color: #111;
  font-size: 15px;
  font-weight: 800;
  border: none;
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
  transition: transform 0.15s;
}

.btn-withdraw-submit:active {
  transform: scale(0.98);
}

/* Transaction History List */
.history-section h4 {
  font-size: 14px;
  color: #FFF;
  margin-bottom: 10px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-left {
  display: flex;
  flex-direction: column;
}

.history-title {
  font-size: 12px;
  font-weight: 600;
  color: #FFF;
}

.history-time {
  font-size: 10px;
  color: var(--text-muted);
}

.history-amount {
  font-size: 13px;
  font-weight: 800;
}

.history-amount.plus { color: var(--success); }
.history-amount.minus { color: var(--danger); }

/* =====================================================================
 * BOTTOM NAVIGATION BAR
 * ===================================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  background: rgba(15, 18, 30, 0.94);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: var(--safe-bottom);
  backdrop-filter: blur(16px);
  z-index: 1000;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  flex: 1;
  height: 100%;
  transition: all 0.2s ease;
}

.nav-tab.active {
  color: var(--gold-glow);
}

.nav-icon {
  font-size: 20px;
  transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.nav-tab.active .nav-icon {
  transform: translateY(-2px) scale(1.15);
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
  backdrop-filter: blur(6px);
}

.modal-overlay.active {
  display: flex;
  animation: modalFade 0.2s ease;
}

@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-box {
  width: 100%;
  max-width: 380px;
  background: #171B2B;
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.8);
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: #FFF;
  margin-bottom: 8px;
}

.modal-body {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.daily-ladder-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.daily-day-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 4px;
}

.daily-day-card.claimed {
  border-color: var(--success);
  background: rgba(46, 204, 113, 0.1);
}

.daily-day-card.current {
  border-color: var(--gold-glow);
  background: rgba(241, 196, 15, 0.15);
  animation: pulseCard 1.5s infinite;
}

@keyframes pulseCard {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.day-label { font-size: 11px; color: var(--text-muted); }
.day-reward { font-size: 12px; font-weight: 800; color: var(--gold-glow); }

/* Toasts */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  pointer-events: none;
  width: 90%;
  max-width: 380px;
}

.toast {
  background: rgba(22, 27, 46, 0.95);
  border: 1px solid var(--gold-primary);
  border-radius: 12px;
  padding: 12px 16px;
  color: #FFF;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  margin-bottom: 8px;
  animation: toastSlide 0.3s ease;
}

@keyframes toastSlide {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}
