:root {
  --color-brand: #6a5acd;
  --color-brand-dark: #534ab7;
  --color-bg: #f4f6f9;
  --color-card: #ffffff;
  --color-text-main: #181c32;
  --color-text-muted: #a1a5b7;
}

*{box-sizing:border-box;margin:0;padding:0;font-family:var(--font-sans,system-ui,sans-serif);-webkit-tap-highlight-color:transparent;}

body {
  background: #1e1e2d;
  color: var(--color-text-main);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  margin: 0;
}

body > div:first-child {
  width: 100%;
  max-width: 450px;
  background: var(--color-bg) !important;
  position: relative !important;
  box-shadow: 0 0 40px rgba(0,0,0,0.6);
  min-height: 100vh !important;
  overflow-x: hidden;
  padding-bottom: 90px;
}

@keyframes fadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}
@keyframes shake{0%,100%{transform:translateX(0)}20%{transform:translateX(-6px)}40%{transform:translateX(6px)}60%{transform:translateX(-4px)}80%{transform:translateX(4px)}}
@keyframes pop{0%{transform:scale(0.8);opacity:0}60%{transform:scale(1.15)}100%{transform:scale(1);opacity:1}}
@keyframes coinRain{0%{transform:translateY(0) rotate(0deg);opacity:1}100%{transform:translateY(-70px) rotate(360deg);opacity:0}}
@keyframes progressPulse{0%,100%{opacity:1}50%{opacity:0.7}}

.screen{display:none;animation:fadeIn 0.3s ease}
.screen.active{display:block}

/* Header */
.coin-bar {
  background: rgba(244, 246, 249, 0.85);
  backdrop-filter: blur(12px);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { font-size: 20px; font-weight: 800; color: var(--color-text-main); letter-spacing: -0.5px; }
.xp-bar-wrap { flex: 1; max-width: 130px; margin: 0 14px; }
.xp-label { font-size: 10px; font-weight: 700; color: var(--color-text-muted); margin-bottom: 4px; display: flex; justify-content: space-between; }
.xp-bar { height: 6px; background: #e4e6ef; border-radius: 4px; overflow: hidden; }
.xp-fill { height: 100%; background: var(--color-brand); border-radius: 4px; transition: width 0.5s ease; }
.coin-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(295deg, #114d89, #e94f12);
  border-radius: 20px; padding: 8px 10px;
  font-size: 12px; font-weight: 800; color: #fff;
  cursor: pointer; box-shadow: 0 4px 12px rgba(233,79,18,0.3);
  transition: transform 0.15s;
}
.coin-chip:hover { transform: scale(1.05); }
.coin-dot {
  width: 18px;
  height: 18px;
  background: url('img/dollar.png') center/contain no-repeat;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  flex-shrink: 0;
}

/* Bottom Nav */
.nav-tabs {
  position: fixed;
  bottom: 0; 
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 450px;
  background: var(--color-card);
  display: flex;
  justify-content: space-around;
  padding: 12px 10px 24px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
  z-index: 90;
  border-radius: 24px 24px 0 0;
}
.nav-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--color-text-muted); text-align: center; line-height: 1.2;
  cursor: pointer; padding: 8px 4px; border-radius: 16px; transition: all 0.2s; flex: 1;
}
.nav-tab.active { color: var(--color-brand); background: rgba(106, 90, 205, 0.08); }
.nav-tab::before { font-size: 20px; margin-bottom: 4px; }
#tab-home::before { content: '🏠'; }
#tab-leaderboard::before { content: '🏆'; }
#tab-achievements::before { content: '🎖️'; }
#tab-daily::before { content: '🎁'; }
#tab-puzzle::before { content: '🧩'; }

/* Slider Hero */
.hero-slider {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 10px 20px 20px; gap: 16px; scrollbar-width: none;
}
.hero-slider::-webkit-scrollbar { display: none; }
.slider-card {
  min-width: 88%; border-radius: 24px; padding: 24px;
  scroll-snap-align: center; box-shadow: 0 10px 20px rgba(0,0,0,0.08);
  position: relative; overflow: hidden;
}
.slide-1 { background: linear-gradient(135deg, #182848, #4b6cb7); color: #fff; }
.slide-2 { background: linear-gradient(135deg, #ff9966, #ff5e62); color: #fff; }
.slide-title { font-size: 22px; font-weight: 800; margin-bottom: 6px; }
.slide-sub { font-size: 14px; opacity: 0.9; margin-bottom: 16px; line-height: 1.4; }
.play-btn { background: #fff; color: #182848; font-weight: 800; padding: 10px 20px; border-radius: 20px; font-size: 13px; display: inline-block; cursor: pointer; }
.streak-strip { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.25); backdrop-filter: blur(8px); border-radius: 20px; padding: 8px 16px; font-size: 13px; font-weight: 700; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }

/* Stats Row */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 0 20px 24px; }
.stat-box { background: var(--color-card); border-radius: 18px; padding: 16px 10px; text-align: center; box-shadow: 0 4px 15px rgba(0,0,0,0.03); cursor: pointer; transition: transform 0.15s; }
.stat-box:active { transform: scale(0.95); }
.stat-val { font-size: 20px; font-weight: 800; color: var(--color-text-main); }
.stat-lbl { font-size: 11px; font-weight: 700; color: var(--color-text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }

/* Sections */
.section-title { font-size: 18px; font-weight: 800; color: var(--color-text-main); padding: 0 20px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
.section-link { font-size: 13px; color: var(--color-brand); font-weight: 700; cursor: pointer; }

/* Cat Grid */
.cat-grid { display: flex; flex-direction: column; gap: 14px; padding: 0 20px 24px; }
.cat-card { background: var(--color-card); border-radius: 20px; padding: 16px; display: flex; align-items: center; box-shadow: 0 4px 20px rgba(0,0,0,0.04); cursor: pointer; transition: transform 0.2s ease; border: 1px solid rgba(0,0,0,0.02); }
.cat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(0,0,0,0.06); }
.cat-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 26px; margin-right: 16px; flex-shrink: 0; }
.cat-info { flex: 1; }
.cat-name { font-size: 16px; font-weight: 800; color: var(--color-text-main); margin-bottom: 6px; }
.cat-meta { display: flex; align-items: center; gap: 10px; }
.cat-fee { display: inline-flex; align-items: center; gap: 1px; font-size: 13px; font-weight: 700; color: #F5A623; }
.cat-badge { font-size: 10px; padding: 4px 10px; border-radius: 8px; font-weight: 800; text-transform: uppercase; }


/* Recent Strip */
.recent-strip { padding: 0 20px 24px; }
.recent-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--color-card); border-radius: 16px; margin-bottom: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); }
.recent-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.recent-name { flex: 1; font-weight: 800; font-size: 15px; }
.recent-score { color: var(--color-text-muted); font-size: 13px; font-weight: 600; margin-top: 2px; }

/* Modal */
.modal-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; backdrop-filter: blur(4px); }
.modal { background: var(--color-card); border-radius: 28px; padding: 30px 24px; width: 100%; animation: pop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); box-shadow: 0 15px 40px rgba(0,0,0,0.2); }
.modal-icon { font-size: 48px; text-align: center; margin-bottom: 16px; }
.modal-title { font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 8px; color: var(--color-text-main); }
.modal-sub { font-size: 14px; color: var(--color-text-muted); text-align: center; margin-bottom: 24px; line-height: 1.5; font-weight: 500; }
.btn { padding: 14px 24px; border-radius: 16px; cursor: pointer; font-size: 15px; font-weight: 800; border: none; background: #f4f6f9; color: var(--color-text-main); transition: transform 0.1s; }
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--color-brand); color: #fff; box-shadow: 0 6px 16px rgba(106,90,205,0.3); }

.btn-row { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }
.btn-row .btn { flex: 1; text-align: center; }
.fee-confirm { background: #fffcf8; border: 2px dashed #ffecce; border-radius: 20px; padding: 18px; text-align: center; margin-bottom: 20px; }
.fee-confirm-label { font-size: 13px; color: #a47e45; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.fee-confirm-val { font-size: 28px; font-weight: 800; color: #F5A623; margin-top: 6px; }

/* Quiz Styles */
.warmup-area { padding: 0; }
.warmup-q { font-size: 18px; font-weight: 800; margin-bottom: 20px; line-height: 1.5; color: var(--color-text-main); }
.warmup-progress { display: flex; gap: 6px; margin-bottom: 24px; }
.warmup-dot { flex: 1; height: 6px; border-radius: 3px; background: #e4e6ef; transition: background 0.3s; }
.warmup-dot.done { background: var(--color-brand); }

.warmup-feedback { padding: 14px; border-radius: 12px; font-size: 14px; font-weight: 700; margin-bottom: 16px; display: none; text-align: center; }
.feedback-correct { background: #e8fff3; color: #186b40; }
.feedback-wrong { background: #ffe5e5; color: #851e35; }

.quiz-header { background: var(--color-card); padding: 18px 20px; display: flex; align-items: center; gap: 16px; box-shadow: 0 4px 10px rgba(0,0,0,0.02); }
.q-counter { font-size: 15px; color: var(--color-text-muted); font-weight: 800; }
.q-progress { flex: 1; height: 8px; background: #e4e6ef; border-radius: 4px; }
.q-progress-fill { height: 100%; background: var(--color-brand); border-radius: 4px; transition: width 0.4s ease; }
.timer-chip { display: flex; align-items: center; gap: 8px; background: #f4f6f9; border-radius: 16px; padding: 8px 14px; font-size: 15px; font-weight: 800; color: var(--color-text-main); }
.timer-icon { width: 12px; height: 12px; border-radius: 50%; background: #50cd89; }
.timer-warn .timer-icon { background: #f1416c; animation: progressPulse 0.5s infinite; }

.quiz-body { padding: 30px 20px; }
.q-category-label { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--color-brand); margin-bottom: 12px; }
.q-text { font-size: 22px; font-weight: 800; margin-bottom: 30px; line-height: 1.4; color: var(--color-text-main); }
.options-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.option { padding: 12px 10px; min-height: 60px; border-radius: 18px; cursor: pointer; font-size: 13px; font-weight: 700; background: var(--color-card); border: 2px solid #e4e6ef; display: flex; align-items: center; gap: 8px; transition: all 0.2s; box-shadow: 0 4px 10px rgba(0,0,0,0.02); }
.option-letter { width: 28px; height: 28px; border-radius: 9px; background: #f4f6f9; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #7e8299; transition: all 0.2s; }
.option:active { transform: scale(0.98); }
.option.correct { background: #e8fff3; border-color: #50cd89; color: #186b40; }
.option.correct .option-letter { background: #50cd89; color: #fff; }
.option.wrong { background: #ffe5e5; border-color: #f1416c; color: #851e35; }
.option.wrong .option-letter { background: #f1416c; color: #fff; }

.streak-flash { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 36px; font-weight: 800; color: #50cd89; pointer-events: none; animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; z-index: 99; text-shadow: 0 4px 20px rgba(80,205,137,0.4); }

.result-card { background: var(--color-card); border-radius: 28px; padding: 36px 24px; text-align: center; margin: 20px; box-shadow: 0 15px 40px rgba(0,0,0,0.1); }
.result-score-ring { width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 24px; display: flex; align-items: center; justify-content: center; font-size: 36px; font-weight: 800; box-shadow: inset 0 0 0 8px rgba(255,255,255,0.2); }
.result-grade { font-size: 22px; font-weight: 800; margin-bottom: 6px; color: var(--color-text-main); }
.result-sub { font-size: 14px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 24px; }
.coin-award { display: inline-flex; align-items: center; gap: 8px; background: linear-gradient(135deg, #FFD700, #F5A623); border-radius: 20px; padding: 12px 24px; font-size: 20px; font-weight: 800; color: #fff; margin-bottom: 24px; box-shadow: 0 8px 20px rgba(245,166,35,0.3); }
.breakdown-row { display: flex; justify-content: space-between; font-size: 14px; padding: 10px 0; border-bottom: 1px solid #f4f6f9; font-weight: 600; }
.breakdown-row:last-child { border: none; }

.leaderboard-item { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--color-card); border-radius: 16px; margin-bottom: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); }
.lb-rank { font-size: 18px; min-width: 32px; text-align: center; font-weight: 800; }
.lb-av { width: 44px; height: 44px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; }
.lb-info { flex: 1; }
.lb-name { font-size: 15px; font-weight: 800; color: var(--color-text-main); }
.lb-cat { font-size: 12px; font-weight: 600; color: var(--color-text-muted); margin-top: 2px; }
.lb-coin { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 800; color: #F5A623; }

.toast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background: #181c32; color: #fff; padding: 12px 24px; border-radius: 24px; font-size: 14px; font-weight: 700; z-index: 999; transition: opacity 0.3s; pointer-events: none; white-space: nowrap; opacity: 0; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.toast.show { opacity: 1; }
.coin-float { position: absolute; pointer-events: none; font-size: 20px; font-weight: 800; color: #F5A623; animation: coinRain 1s ease-out forwards; z-index: 1000; text-shadow: 0 2px 10px rgba(245,166,35,0.4); }
