:root {
  --bg: #fff7f4;
  --card: #ffffff;
  --accent: #ff6b8b;
  --accent-deep: #e84a6f;
  --accent-soft: #ffe4ea;
  --text: #2d2a32;
  --muted: #8a8593;
  --border: #f0e6e1;
  --gold: #f5a623;
  --green: #4caf7d;
  --radius: 18px;
  --shadow: 0 2px 12px rgba(120, 70, 80, 0.08);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

/* ---------- Onboarding ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, #fff7f4 0%, #ffe4ea 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.onboarding-card {
  background: var(--card);
  border-radius: 24px;
  padding: 32px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}
.onboarding-heart { font-size: 56px; margin-bottom: 12px; }
.onboarding-card h1 { margin: 0 0 12px; font-size: 26px; letter-spacing: -0.3px; }
.ob-message {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 16px;
  white-space: pre-line;
}
.ob-label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.onboarding-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  margin-bottom: 16px;
  outline: none;
  background: var(--bg);
}
.onboarding-card input:focus { border-color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; width: 100%; }
.btn-primary:active { background: var(--accent-deep); }
.btn-ghost {
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.btn-block { width: 100%; }

/* ---------- App shell ---------- */
#app { padding-bottom: calc(76px + var(--safe-bottom)); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 247, 244, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: calc(14px + env(safe-area-inset-top, 0px)) 20px 12px;
  border-bottom: 1px solid var(--border);
}
.header-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.view { padding: 20px 20px 28px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  z-index: 20;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  border-radius: 12px;
}
.tab.active { color: var(--accent-deep); }
.tab-icon { font-size: 22px; }
.tab-label { font-size: 11px; font-weight: 600; }

/* ---------- Home ---------- */
.hero {
  background: linear-gradient(135deg, #ff6b8b 0%, #ff8e53 100%);
  border-radius: var(--radius);
  padding: 22px;
  color: #fff;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.hero h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: -0.3px; }
.hero p { margin: 0; opacity: 0.92; font-size: 15px; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; }
.stat-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }

.section-title {
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -0.2px;
}

/* ---------- Lesson cards ---------- */
.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.lesson-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color 0.15s ease;
}
.lesson-card:active { border-color: var(--accent); }
.lesson-emoji { font-size: 30px; }
.lesson-title { font-size: 14px; font-weight: 700; margin: 8px 0 6px; }
.lesson-progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.lesson-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}
.lesson-stars { font-size: 11px; color: var(--gold); margin-top: 6px; }

/* ---------- Sign list / dictionary ---------- */
.search-bar {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  font-size: 16px;
  background: var(--card);
  outline: none;
  margin-bottom: 16px;
  font-family: inherit;
}
.search-bar:focus { border-color: var(--accent); }

.sign-list { display: flex; flex-direction: column; gap: 10px; }
.sign-card {
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.sign-card img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
  background: var(--accent-soft);
  flex-shrink: 0;
}
.sign-card .sign-word { font-size: 16px; font-weight: 600; }

/* ---------- Sign detail (modal) ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(45, 42, 50, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  background: var(--bg);
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-handle {
  width: 40px; height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin: 0 auto 16px;
}
.modal-card h3 { margin: 0 0 12px; font-size: 22px; letter-spacing: -0.3px; }
.modal-card img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 14px;
  background: var(--accent-soft);
  margin-bottom: 14px;
}
.modal-hint { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ---------- Quiz ---------- */
.quiz-question { font-size: 16px; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.quiz-prompt { font-size: 20px; font-weight: 700; margin: 0 0 16px; letter-spacing: -0.3px; }
.quiz-gif {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 14px;
  background: var(--accent-soft);
  margin-bottom: 18px;
}
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-option {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s ease;
}
.quiz-option:active { transform: scale(0.97); }
.quiz-option.correct { background: #e6f7ee; border-color: var(--green); color: #2c7a4f; }
.quiz-option.wrong { background: #ffe4ea; border-color: var(--accent); color: var(--accent-deep); }
.quiz-result {
  text-align: center;
  padding: 24px 0;
}
.quiz-result .big { font-size: 48px; margin-bottom: 8px; }
.quiz-result h3 { margin: 0 0 8px; font-size: 22px; }

/* ---------- Fingerspell ---------- */
.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.letter-cell {
  background: var(--card);
  border-radius: 12px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow);
  border: 1.5px solid transparent;
}
.letter-cell:active { border-color: var(--accent); }

.trainer-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.trainer-box img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  margin: 8px auto;
  display: block;
}
.trainer-actions { display: flex; gap: 10px; margin-top: 12px; }
.trainer-actions .btn { flex: 1; }

/* ---------- Empty / misc ---------- */
.muted-note { color: var(--muted); font-size: 13px; text-align: center; padding: 20px 0; }

.credits {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
}
.credits a { color: var(--accent-deep); }
