/* ── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --korean-red:   #C0392B;
  --korean-blue:  #1A3A6B;
  --accent:       #E74C3C;
  --accent-soft:  #FDECEA;
  --gold:         #F39C12;
  --gold-soft:    #FEF9E7;
  --green:        #27AE60;
  --green-soft:   #EAFAF1;
  --bg:           #F5F5F7;
  --surface:      #FFFFFF;
  --surface2:     #F0F0F3;
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --text-muted:   #9CA3AF;
  --border:       rgba(0,0,0,0.08);
  --radius-sm:    8px;
  --radius-md:    14px;
  --radius-lg:    20px;
  --radius-xl:    28px;
  --nav-height:   64px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.14);
}

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

.hidden { display: none !important; }

/* ── LOADING SCREEN ───────────────────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--korean-blue);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 999;
}

.loading-logo {
  font-size: 64px;
  animation: pulse 1.4s ease-in-out infinite;
}

.loading-text {
  color: rgba(255,255,255,0.7);
  font-size: 15px;
  letter-spacing: 0.02em;
}

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

/* ── APP SHELL ────────────────────────────────────────────── */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ── SCREENS ──────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-height) + 8px);
  -webkit-overflow-scrolling: touch;
}

.screen.active { display: flex; }

/* ── BOTTOM NAV ───────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-icon { font-size: 22px; line-height: 1; opacity: 0.45; transition: opacity 0.15s, transform 0.15s; }
.nav-label { font-size: 10px; color: var(--text-muted); font-weight: 500; }
.nav-item.active .nav-icon { opacity: 1; transform: scale(1.1); }
.nav-item.active .nav-label { color: var(--korean-blue); font-weight: 600; }

/* ── HOME SCREEN ──────────────────────────────────────────── */
.home-header {
  background: linear-gradient(135deg, var(--korean-blue) 0%, #2C4A8A 100%);
  padding: 20px 20px 28px;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.greeting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.greeting-label { color: rgba(255,255,255,0.6); font-size: 13px; margin-bottom: 2px; }
.greeting-name { color: #fff; font-size: 22px; font-weight: 700; }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  object-fit: cover;
  background: rgba(255,255,255,0.2);
}

.home-content { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

/* Streak card */
.streak-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.streak-flame { font-size: 36px; }
.streak-info { flex: 1; }
.streak-number { font-size: 32px; font-weight: 800; color: var(--korean-blue); line-height: 1; }
.streak-label { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.streak-badge {
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* XP bar */
.xp-section {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.xp-row { display: flex; justify-content: space-between; margin-bottom: 8px; }
.xp-label { font-size: 13px; color: var(--text-secondary); }
.xp-value { font-size: 13px; font-weight: 600; color: var(--korean-blue); }

.xp-bar-bg {
  height: 8px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--korean-blue), #4A7FD4);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Daily card */
.daily-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.daily-top { display: flex; justify-content: space-between; margin-bottom: 12px; }
.daily-title { font-size: 14px; font-weight: 600; }
.daily-count { font-size: 13px; color: var(--text-secondary); }

.daily-dots { display: flex; gap: 6px; }

.dot {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: var(--surface2);
  transition: background 0.3s;
}

.dot.done { background: var(--green); }
.dot.current { background: var(--korean-blue); animation: blink 1s ease-in-out infinite; }

@keyframes blink { 0%,100% { opacity:1; } 50% { opacity: 0.4; } }

/* Start button */
.btn-start {
  background: var(--korean-red);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 20px rgba(192, 57, 43, 0.35);
  transition: transform 0.12s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.btn-start:active { transform: scale(0.97); box-shadow: 0 2px 10px rgba(192,57,43,0.3); }
.btn-arrow { font-size: 20px; }

/* Stats row */
.stats-row { display: flex; gap: 10px; }

.stat-box {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  border: 1px solid var(--border);
}

.stat-num { font-size: 22px; font-weight: 800; color: var(--korean-blue); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── SCREEN HEADER (shared) ───────────────────────────────── */
.screen-header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.screen-title { font-size: 24px; font-weight: 800; color: var(--text-primary); }
.screen-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }

/* ── LEARN SCREEN ─────────────────────────────────────────── */
.learn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
}

.back-btn {
  background: none;
  border: none;
  font-size: 15px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
}

.learn-deck-name { font-size: 16px; font-weight: 700; }
.learn-progress-label { font-size: 14px; color: var(--text-secondary); font-weight: 600; }

.learn-progress-bar-bg { height: 4px; background: var(--surface2); margin: 0 16px 20px; border-radius: 99px; overflow: hidden; }
.learn-progress-bar-fill { height: 100%; background: var(--korean-blue); border-radius: 99px; transition: width 0.4s ease; }

/* Flashcard flip */
.card-scene {
  flex: 0 0 auto;
  height: 280px;
  margin: 0 16px;
  perspective: 1000px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

.card-inner.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow-lg);
}

.card-front {
  background: linear-gradient(145deg, var(--korean-blue) 0%, #243B8A 100%);
  color: #fff;
}

.card-back {
  background: var(--surface);
  transform: rotateY(180deg);
  border: 2px solid var(--border);
}

.card-hint { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.6; margin-bottom: 12px; }
.card-front .card-hint { color: rgba(255,255,255,0.7); }
.card-back .card-hint { color: var(--text-muted); }

.card-korean { font-size: 52px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; text-align: center; }
.card-romanization { font-size: 16px; opacity: 0.7; margin-top: 8px; font-style: italic; }

.card-uzbek { font-size: 30px; font-weight: 700; color: var(--text-primary); text-align: center; line-height: 1.2; }
.card-example { font-size: 14px; color: var(--text-secondary); text-align: center; margin-top: 12px; line-height: 1.5; }
.card-example-uz { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 4px; line-height: 1.4; font-style: italic; }

.card-tap-hint {
  position: absolute;
  bottom: 20px;
  font-size: 12px;
  opacity: 0.5;
  color: #fff;
}

/* Answer buttons */
.answer-btns {
  display: flex;
  gap: 12px;
  margin: 20px 16px 0;
}

.btn-wrong, .btn-correct {
  flex: 1;
  padding: 16px;
  border: none;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn-wrong { background: var(--accent-soft); color: var(--accent); }
.btn-correct { background: var(--green-soft); color: var(--green); }
.btn-wrong:active, .btn-correct:active { transform: scale(0.96); }
.btn-icon { font-size: 20px; }

.flip-prompt {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-muted);
}

/* Limit wall */
.limit-wall {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
  gap: 12px;
}

.limit-emoji { font-size: 56px; }
.limit-title { font-size: 22px; font-weight: 800; }
.limit-text { font-size: 15px; color: var(--text-secondary); line-height: 1.5; }

.btn-premium {
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  box-shadow: 0 4px 16px rgba(243,156,18,0.35);
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-wait {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
}

/* ── DECKS SCREEN ─────────────────────────────────────────── */
.decks-list { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.deck-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.deck-card:active { transform: scale(0.98); box-shadow: var(--shadow-sm); }
.deck-card.locked { opacity: 0.7; cursor: default; }

.deck-emoji { font-size: 36px; }
.deck-info { flex: 1; }
.deck-name { font-size: 17px; font-weight: 700; }
.deck-desc { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.deck-count { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.deck-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.badge-free { background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.badge-lock { font-size: 18px; }

.deck-skeleton {
  height: 88px;
  background: linear-gradient(90deg, var(--surface2) 25%, #e8e8ec 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-lg);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── PROFILE SCREEN ───────────────────────────────────────── */
.profile-content { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.profile-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.profile-avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--surface2); border: 2px solid var(--border); }
.profile-info { flex: 1; }
.profile-name { font-size: 18px; font-weight: 700; }
.profile-handle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.profile-badge { background: var(--surface2); color: var(--text-secondary); font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 20px; }
.profile-badge.premium { background: var(--gold-soft); color: var(--gold); }

/* Premium block */
.premium-block {
  background: linear-gradient(135deg, #FEF9E7, #FDEBD0);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(243,156,18,0.2);
}

.premium-icon { font-size: 28px; }
.premium-text { flex: 1; }
.premium-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.premium-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.btn-upgrade-small {
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

/* Referral */
.referral-block {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.referral-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.referral-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 12px; }

.referral-link-row { display: flex; gap: 8px; align-items: center; }
.referral-link { flex: 1; background: var(--surface2); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-copy { background: var(--korean-blue); color: #fff; border: none; border-radius: var(--radius-sm); padding: 10px 16px; font-size: 13px; font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.referral-earned { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* Profile stats */
.profile-stats { display: flex; gap: 10px; }
.pstat { flex: 1; background: var(--surface); border-radius: var(--radius-md); padding: 14px 10px; text-align: center; border: 1px solid var(--border); }
.pstat-num { font-size: 24px; font-weight: 800; color: var(--korean-blue); }
.pstat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Payment info */
.payment-info {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  border: 1px solid var(--border);
}

.payment-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.payment-step { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; line-height: 1.4; }
.payment-step a { color: var(--korean-blue); }
.payment-note { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ── UPGRADE MODAL ────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 24px calc(32px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface2);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-emoji { font-size: 48px; text-align: center; margin-bottom: 8px; }
.modal-title { font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 4px; }
.modal-price { font-size: 18px; font-weight: 700; text-align: center; color: var(--gold); margin-bottom: 20px; }
.modal-features { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.modal-feature { font-size: 15px; color: var(--text-secondary); padding-left: 4px; }

.modal-payment { background: var(--surface2); border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 16px; }
.modal-pay-title { font-size: 13px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.06em; }
.modal-pay-step { font-size: 14px; color: var(--text-primary); margin-bottom: 6px; line-height: 1.4; }
.modal-pay-step a { color: var(--korean-blue); }
