* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Tamil-identity palette: deep indigo primary, turmeric accent, sage success,
     soft coral for errors/warnings — replacing the generic template violet. */
  --brand-start: #4338CA;
  --brand-end: #1E1B4B;
  --brand-solid: #312E81;
  --brand-soft: #E0E7FF;
  --brand-ink: #312E81;
  --accent: #D97706;
  --accent-soft: rgba(217,119,6,0.14);
  --success: #6B8F71;
  --success-soft: #E3EAE4;
  --warn: #E07A5F;
  --ink: #1E1B4B;
  --ink-soft: #57547E;
  --ink-faint: #8481A6;
  --line: #E5E3F1;
  --surface: #FFFFFF;
  --radius-lg: 18px;
  --radius-md: 12px;
}

button { font-family: inherit; }

button:focus-visible,
input:focus-visible,
.pet-card:focus-visible,
.habit-item:focus-visible {
  outline: 2px solid var(--brand-solid);
  outline-offset: 2px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #fef6e4 0%, #e0f7fa 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  color: #2d2d2d;
  transition: background 0.8s ease, color 0.8s ease;
}

/* ---------- Time-of-day skies (IST) ---------- */
body.morning   { background: linear-gradient(160deg, #fff3b0 0%, #cdeffd 100%); }
body.afternoon { background: linear-gradient(160deg, #aee1ff 0%, #e8f9ff 100%); }
body.evening   { background: linear-gradient(160deg, #ffb88c 0%, #de6262 100%); }
body.night {
  background: linear-gradient(160deg, #0F172A 0%, #1E1B4B 100%);
  color: #FEF3C7;
  --night-card: #1E293B;
  --night-border: rgba(217,119,6,0.25);
  --night-shadow: 0 6px 20px rgba(0,0,0,0.45);
}
/* Cards need their own lighter, bordered surface so they read as distinct
   panels against the dark sky gradient instead of blending into it. */
body.night .pet-stage,
body.night .habits-card,
body.night .heatmap-card,
body.night .quote-card,
body.night .ladder-card,
body.night .leaderboard-card {
  background: var(--night-card);
  border: 1px solid var(--night-border);
  box-shadow: var(--night-shadow);
  color: #f0f0f5;
}
body.night .habit-text { color: #FEF3C7; }
body.night .habit-item { border-bottom-color: #3a4068; }
body.night .xp-text, body.night .habits-header span { color: rgba(254,243,199,0.62); }

.time-badge {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 0 14px;
  opacity: 0.95;
}

#app { width: 100%; max-width: 480px; }

.hidden { display: none !important; }

/* ---------- Select Screen ---------- */
#select-screen { text-align: center; padding-top: 40px; }
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 2px;
}
.brand-mark-img {
  width: 36px;
  height: 36px;
  border-radius: 9px;
}
.brand-word {
  font-family: "Baloo Thambi 2", system-ui, sans-serif;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.3px;
  background: linear-gradient(90deg, var(--brand-start), var(--brand-end));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-tamil {
  font-family: "Baloo Thambi 2", system-ui, sans-serif;
  font-size: 19px;
  font-weight: 600;
  color: var(--brand-solid);
  margin-bottom: 16px;
}
.tagline {
  font-size: 18px;
  font-weight: 700;
  color: #444;
  margin-bottom: 12px;
}
.mission {
  font-size: 14px;
  line-height: 1.6;
  color: #777;
  background: rgba(255,255,255,0.55);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 26px;
  text-align: left;
}
#select-screen h1 { font-size: 22px; margin-bottom: 6px; }
.subtitle { color: #777; margin-bottom: 28px; }

.pet-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.pet-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}
.pet-card:hover { transform: translateY(-4px); border-color: var(--brand-solid); }
.pet-card:active { transform: translateY(-1px) scale(0.98); }
.pet-card .emoji { font-size: 48px; display: block; margin-bottom: 8px; }
.pet-card .name { font-weight: 600; font-size: 15px; }

/* ---------- Restore link ---------- */
.restore-link {
  display: block;
  margin: 18px auto 0;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
}

/* ---------- Game Screen ---------- */
#game-screen { position: relative; }

/* ---------- What's New ---------- */
.whatsnew { position: absolute; top: 0; right: 0; z-index: 30; }
.whatsnew-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--ink-soft);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  transition: transform 0.1s, background 0.15s;
}
.whatsnew-btn:active { transform: scale(0.96); }
body.night .whatsnew-btn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #d9d9e6;
}
.wn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: wnPulse 2.2s ease-out infinite;
}
@keyframes wnPulse {
  0%   { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(217, 119, 6, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
}
.whatsnew-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(280px, 80vw);
  background: #fff;
  color: var(--ink);
  border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
  padding: 16px;
  z-index: 40;
}
.wn-arrow {
  position: absolute;
  top: -6px;
  right: 16px;
  width: 12px;
  height: 12px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 2px;
}
.wn-head { font-weight: 800; font-size: 14px; color: var(--ink); }
.wn-list { list-style: none; margin: 12px 0 14px; display: flex; flex-direction: column; gap: 12px; }
.wn-item { display: flex; gap: 10px; align-items: flex-start; text-align: left; }
.wn-emoji { font-size: 17px; line-height: 1.35; flex-shrink: 0; }
.wn-text strong { display: block; font-size: 13px; color: var(--ink); margin-bottom: 1px; }
.wn-text span { font-size: 12px; color: var(--ink-soft); line-height: 1.45; }

.game-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-bottom: 6px;
}
.game-brand-mark { width: 26px; height: 26px; border-radius: 7px; }
.game-brand-word {
  font-family: "Baloo Thambi 2", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--brand-start), var(--brand-end));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.lb-kolam { width: 20px; height: 20px; border-radius: 5px; vertical-align: -3px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.pet-name { font-size: 22px; font-weight: 700; }
.level-badge {
  background: var(--brand-solid);
  color: white;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
}

.pet-stage {
  background: var(--surface);
  border-radius: 20px;
  padding: 18px 16px 16px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  margin-bottom: 12px;
  position: relative;
}
.pet-emoji {
  font-size: 72px;
  margin-bottom: 4px;
  transition: transform 0.3s, filter 0.4s, opacity 0.4s;
  display: inline-block;
  position: relative;
  z-index: 1;
}
.pet-emoji::before {
  content: "";
  position: absolute;
  left: 50%; top: 56%;
  width: 100px; height: 100px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--brand-soft) 0%, rgba(255,243,214,0) 70%);
  border-radius: 50%;
  z-index: -1;
}
body.night .pet-emoji::before { background: radial-gradient(circle, rgba(217,119,6,0.22) 0%, rgba(217,119,6,0) 70%); }
.pet-emoji.tired { filter: grayscale(70%); opacity: 0.6; }
.pet-emoji.bounce { animation: petBounce 0.5s ease; }
.pet-emoji.happy { animation: petFloat 2.5s ease-in-out infinite; }

@keyframes petBounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.25) rotate(-6deg); }
  60% { transform: scale(0.95) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes petFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.pet-mood {
  font-size: 13px;
  color: #888;
  margin-bottom: 10px;
  min-height: 16px;
}
body.night .pet-mood { color: rgba(254,243,199,0.62); }

/* ---------- Confetti ---------- */
#confetti-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 200;
}
.confetti-piece {
  position: absolute;
  top: -12px;
  width: 9px; height: 14px;
  opacity: 0.9;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(105vh) rotate(720deg); opacity: 0.8; }
}
.xp-bar-wrap { padding: 0 8px; }
.xp-bar {
  background: #eee;
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}
.xp-fill {
  background: linear-gradient(90deg, var(--accent), var(--brand-solid));
  height: 100%;
  width: 0%;
  transition: width 0.4s ease;
}
.xp-text { font-size: 12px; color: #888; margin-top: 6px; }

.habits-card, .heatmap-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}
.habits-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.habits-header h2 { font-size: 16px; }
.habits-header span { font-size: 12px; color: #999; }

.habit-list { list-style: none; }
.habit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.habit-item:last-child { border-bottom: none; }
.habit-item:active { background: var(--brand-soft); border-radius: 8px; }
.habit-checkbox {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid #ddd;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.habit-item.done .habit-checkbox {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.habit-item.done .habit-text { text-decoration: line-through; color: #aaa; }
.habit-text { font-size: 14px; }

/* Modals have a white surface even in night mode — force readable text there. */
.modal .habit-text,
body.night .modal .habit-text { color: var(--ink); }
.modal .habit-item,
body.night .modal .habit-item { border-bottom-color: var(--line); }
.modal .habit-item.done .habit-text,
body.night .modal .habit-item.done .habit-text { color: #aaa; }

.link-btn {
  background: none;
  border: none;
  color: #6c757d;
  font-size: 13px;
  cursor: pointer;
  padding: 8px 4px;
}
.link-btn:active { opacity: 0.6; }

.heatmap-card h2 { font-size: 16px; margin-bottom: 12px; }
.heatmap {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
}
.heat-cell {
  aspect-ratio: 1;
  border-radius: 5px;
  background: #eee;
}

.reset-btn, .secure-pin-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--brand-solid);
  color: var(--brand-solid);
  padding: 10px;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 4px;
  transition: transform 0.1s;
}
.reset-btn:active, .secure-pin-btn:active { transform: scale(0.98); }
.secure-pin-btn { margin-bottom: 8px; }
body.night .reset-btn { border-color: var(--accent); color: var(--accent); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-content {
  background: white;
  border-radius: 18px;
  padding: 22px;
  width: 100%;
  max-width: 420px;
  color: var(--ink);
}
.modal-content h2 { margin-bottom: 14px; }
.manage-hint {
  font-size: 13px;
  color: #888;
  background: #f7f7f2;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  line-height: 1.4;
}
.manage-count { font-size: 12px; color: #999; margin-bottom: 10px; }
.manage-count.over { color: var(--warn); font-weight: 600; }
.manage-list { list-style: none; max-height: 240px; overflow-y: auto; margin-bottom: 14px; }
.manage-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid #f2f2f2;
  font-size: 14px;
  gap: 8px;
}
.manage-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.manage-item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.manage-item button {
  background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px;
  padding: 6px 8px;
  white-space: nowrap;
}
.manage-edit-input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--brand-solid);
  font-size: 14px;
}
.add-habit-row { display: flex; gap: 8px; margin-bottom: 16px; }
.add-habit-row input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 14px;
}
.add-habit-row button, .primary-btn {
  background: var(--brand-solid);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.1s, opacity 0.1s;
}
.primary-btn { width: 100%; }
.add-habit-row button:active, .primary-btn:active { transform: scale(0.97); opacity: 0.9; }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Pet emoji tap + evolution CTA ---------- */
.pet-emoji { cursor: pointer; }
.evo-cta {
  background: var(--brand-soft);
  color: var(--brand-ink);
  border: 1px solid rgba(49,46,129,0.35);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
  transition: transform 0.1s;
}
.evo-cta:active { transform: scale(0.96); }
body.night .evo-cta { color: #FBBF24; background: rgba(217,119,6,0.15); }

/* ---------- Modal shared extras ---------- */
.modal-actions { display: flex; gap: 10px; }
.modal-actions .primary-btn, .modal-actions .ghost-btn, .modal-actions .danger-btn { flex: 1; }
.ghost-btn {
  background: none;
  border: 1px solid #ddd;
  color: #777;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.1s;
}
.ghost-btn:active { transform: scale(0.97); background: #f5f5f5; }
.danger-btn {
  background: var(--warn);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.1s;
}
.danger-btn:active { transform: scale(0.97); }

/* Name modal */
.name-modal-content { text-align: center; }
.name-modal-emoji { font-size: 64px; margin-bottom: 8px; }
.name-modal-sub { color: #888; font-size: 14px; margin-bottom: 18px; }
#name-input, #restore-name-input, #email-input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid #ddd;
  font-size: 16px;
  text-align: center;
  margin-bottom: 16px;
  box-sizing: border-box;
}
#name-input:focus, #restore-name-input:focus, #email-input:focus { outline: none; border-color: var(--brand-solid); }

.pin-input {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid #ddd;
  font-size: 24px;
  letter-spacing: 10px;
  text-align: center;
  margin-bottom: 8px;
  font-family: monospace;
}
.pin-input:focus { outline: none; border-color: var(--brand-solid); }
.pin-hint { color: var(--ink-faint); font-size: 12px; margin-bottom: 16px; line-height: 1.5; }

/* Evolution modal */
.evo-sub, .info-body { color: #777; font-size: 14px; line-height: 1.55; margin-bottom: 18px; }
.evo-stages {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.evo-stage { text-align: center; }
.evo-stage .evo-emoji { font-size: 44px; display: block; }
.evo-stage .evo-level { font-size: 11px; color: #999; font-weight: 600; }
.evo-arrow { font-size: 20px; color: #ccc; }

/* Habit info icon */
.habit-info-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: #bbb;
  font-size: 17px;
  cursor: pointer;
  padding: 10px;
  min-width: 38px;
  min-height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
}
.habit-info-btn:hover, .habit-info-btn:active { color: var(--success); background: var(--success-soft); }

/* Secure-pet banner */
.secure-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--brand-soft);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--brand-ink);
}
.secure-banner button {
  background: none;
  border: none;
  color: var(--brand-ink);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
  padding: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
body.night .secure-banner { background: rgba(217,119,6,0.15); color: #FBBF24; }
body.night .secure-banner button { color: #FBBF24; }

/* ---------- Install guide ---------- */
.install-guide {
  position: relative;
  background: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 100%);
  border: 1.5px solid rgba(49,46,129,0.18);
  border-radius: 16px;
  padding: 16px 16px 20px;
  margin-bottom: 16px;
}
.install-guide-dismiss {
  position: absolute;
  top: 10px; right: 12px;
  background: none; border: none;
  font-size: 14px; color: #9CA3AF;
  cursor: pointer; padding: 2px 4px;
  line-height: 1;
}
.ig-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-ink);
  margin-bottom: 4px;
  padding-right: 20px;
}
.ig-sub {
  font-size: 12px;
  color: #6B7280;
  margin: 0 0 14px;
  line-height: 1.4;
}
.ig-install-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  background: var(--brand-solid);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
}
.ig-install-btn:active { transform: scale(0.97); opacity: 0.9; }
body.night .install-guide {
  background: linear-gradient(135deg, rgba(217,119,6,0.10) 0%, rgba(217,119,6,0.05) 100%);
  border-color: rgba(217,119,6,0.25);
}
body.night .ig-sub { color: rgba(254,243,199,0.65); }

/* ---------- Certificate (deliberately separate "prestige" sub-brand —
   not tied to Thunai's violet/cream palette or rounded font) ---------- */
.cert-trigger-btn { display: block; width: 100%; text-align: center; }

.cert-modal-content { text-align: center; }
.cert-loading { padding: 50px 0; color: var(--ink-soft); font-size: 14px; }
.cert-preview-img {
  width: 100%;
  max-width: 260px;
  border-radius: 10px;
  margin: 0 auto 16px;
  display: block;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

.cert-template {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 540px;
  height: 960px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 64px 44px;
  text-align: center;
}
.cert-t1 { background: #FDFCF0; color: #1B3022; }
.cert-t2 { background: #1B3022; color: #D4AF37; }
.cert-t3 { background: #0B0B0E; color: #D4AF37; }

.cert-wordmark {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: 5px;
}

.cert-headline {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 800;
  font-size: 88px;
  line-height: 1.08;
  margin: 28px 0 12px;
}
/* No gradient-clip text here: html2canvas (which rasterizes this template
   into the shareable image) doesn't support background-clip:text - it was
   painting the gradient as a solid gold box behind equally-gold text,
   making the headline unreadable. Plain solid gold (inherited from
   .cert-t2/.cert-t3 above) renders correctly. */

.cert-subtitle {
  font-family: "Inter", sans-serif;
  font-size: 17px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 36px;
}

.cert-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  width: 100%;
  padding: 26px 0;
  border-top: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  opacity: 0.95;
}
.cert-stat { flex: 1; min-width: 0; }
.cert-stat-value {
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 24px;
  white-space: nowrap;
}
.cert-stat-label {
  font-family: "Inter", sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.65;
  margin-top: 6px;
}

.cert-gl-badge {
  margin-top: 28px;
  border: 2px solid #D4AF37;
  color: #D4AF37;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
  padding: 10px 22px;
  border-radius: 999px;
}
.cert-t1 .cert-gl-badge { color: #1B3022; border-color: #1B3022; }

.cert-footer {
  font-family: "Inter", sans-serif;
  font-size: 13px;
  letter-spacing: 1px;
  opacity: 0.55;
}

/* ---------- Motivational Quote ---------- */
.quote-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}
.quote-mark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  color: var(--brand-solid);
  opacity: 0.5;
  margin-bottom: 2px;
}
.quote-text {
  font-size: 14px;
  line-height: 1.6;
  font-style: italic;
  color: var(--ink);
  margin-bottom: 8px;
}
body.night .quote-text { color: #f0f0f5; }
.quote-author {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: right;
}
body.night .quote-author { color: #b9bcd6; }

/* On wide screens there's room beside the dashboard — let the quote float
   there instead of sitting inline. On a phone (the common case, since this
   app is mostly used installed on a home screen) it just stays in-flow. */
@media (min-width: 1100px) {
  .quote-card {
    position: fixed;
    top: 50%;
    right: 32px;
    transform: translateY(-50%);
    width: 260px;
    margin-bottom: 0;
  }
}

/* ---------- Growth Ladder ---------- */
.ladder-card {
  background: white;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}
.ladder-card h2 { font-size: 16px; margin-bottom: 14px; }

.ladder { position: relative; display: flex; flex-direction: column; }
.ladder::before {
  content: "";
  position: absolute;
  left: 23px;
  top: 24px;
  bottom: 24px;
  width: 3px;
  background: #ececec;
  border-radius: 3px;
}
body.night .ladder::before { background: #3a4068; }

.rung {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  position: relative;
  z-index: 1;
}
.rung-badge {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  background: #f1f1f1;
  border: 2px solid #e2e2e2;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.rung.reached .rung-badge { background: var(--success-soft); border-color: var(--success); }
.rung.current .rung-badge {
  background: var(--brand-soft);
  border-color: var(--brand-solid);
  box-shadow: 0 0 0 5px rgba(49,46,129,0.22);
  animation: rungPulse 2s ease-in-out infinite;
}
.rung.locked .rung-badge { filter: grayscale(60%); opacity: 0.5; }
@keyframes rungPulse {
  0%,100% { box-shadow: 0 0 0 5px rgba(49,46,129,0.20); }
  50% { box-shadow: 0 0 0 9px rgba(49,46,129,0.08); }
}

.rung-title { font-size: 14px; font-weight: 600; }
.rung.current .rung-title { color: var(--brand-ink); }
body.night .rung.current .rung-title { color: #FBBF24; }
.rung-sub { font-size: 12px; color: #999; }
body.night .rung-sub { color: #b9bcd6; }

/* ---------- Name error ---------- */
.name-error {
  color: var(--warn);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 10px;
  font-weight: 600;
}

/* ---------- Streak & freeze row ---------- */
.streak-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 13px;
}
.streak-row:active { background: var(--brand-soft); }
.streak-badge { font-weight: 700; color: var(--ink); }
.freeze-badge { font-weight: 700; color: var(--accent); }
body.night .streak-row { border-color: var(--night-border); }
body.night .streak-badge { color: #FEF3C7; }

/* Streak info modal — turns ice blue when a freeze protected yesterday. */
#streak-modal-content.frozen {
  background: linear-gradient(160deg, #EFF8FF 0%, #DCEEFB 100%);
}
#streak-modal-content.frozen .name-modal-emoji { filter: drop-shadow(0 0 8px rgba(56,189,248,0.5)); }
#streak-modal-frozen-note { color: #0369A1; font-weight: 600; }

/* ---------- Yesterday banner ---------- */
.yesterday-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: #FEF3C7;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #78350F;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.yesterday-banner:active { background: #FDE68A; }
.yb-icon { font-size: 15px; flex-shrink: 0; }
.yb-text { flex: 1; font-weight: 600; }
.yb-cta { font-weight: 700; color: #B45309; flex-shrink: 0; }
body.night .yesterday-banner {
  background: rgba(217, 119, 6, 0.18);
  color: #FCD34D;
}
body.night .yb-cta { color: #FBBF24; }

/* ---------- Email collection modal ---------- */
.email-xp-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent), #F59E0B);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  margin: 0 auto 14px;
  letter-spacing: 0.02em;
}

/* ---------- Leaderboard ---------- */
.leaderboard-card {
  background: white;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}
.lb-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.lb-header h2 { font-size: 16px; }
.lb-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.lb-tab {
  flex: 1;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #e5e5e5;
  background: #f7f7f2;
  color: #888;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.lb-tab.active { background: var(--brand-solid); color: white; border-color: var(--brand-solid); }
body.night .lb-tab { background: #24304a; border-color: #3a4068; color: rgba(254,243,199,0.62); }
body.night .lb-tab.active { background: var(--brand-solid); color: white; }

.lb-list { list-style: none; padding: 0; margin: 0; }
.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--line);
}
body.night .lb-row { border-bottom-color: #3a4068; }
.lb-row:last-child { border-bottom: none; }
/* Turmeric tint, not the old pale-mint, so the "you" row is unmistakable
   at a glance and the name text (deep indigo ink) stays high-contrast on top. */
.lb-row.me { background: var(--accent-soft); border-radius: 8px; }
body.night .lb-row.me { background: rgba(217, 119, 6, 0.28); }
.lb-rank { width: 26px; font-weight: 700; color: #999; font-size: 14px; text-align: center; }
.lb-emoji { font-size: 24px; }
.lb-name { flex: 1; font-size: 14px; font-weight: 600; }
.lb-name .lb-lv { font-weight: 400; color: #aaa; font-size: 12px; margin-left: 6px; }
.lb-strength { font-weight: 700; color: var(--accent); font-size: 14px; }
.lb-empty, .lb-loading { text-align: center; color: #999; font-size: 13px; padding: 16px 0; }

/* "View full list" trigger on the card */
.lb-view-more {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: none;
  color: var(--brand-ink);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.lb-view-more:active { transform: scale(0.98); }
body.night .lb-view-more { color: #FBBF24; border-color: var(--night-border); }

/* Full-list modal: scope tabs/rows back to the light look since the modal
   card is always white, even in the night theme. */
.lb-modal-content { position: relative; }
.modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--ink-faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.modal-x:hover, .modal-x:active { background: #f1f1f1; color: var(--ink); }

.lb-modal-list {
  max-height: 60vh;
  overflow-y: auto;
  position: relative;
  margin: 4px 0 0;
  -webkit-overflow-scrolling: touch;
}
body.night .lb-modal-content .lb-tab { background: #f7f7f2; color: #888; border-color: #e5e5e5; }
body.night .lb-modal-content .lb-tab.active { background: var(--brand-solid); color: #fff; border-color: var(--brand-solid); }
body.night .lb-modal-content .lb-row { border-bottom-color: var(--line); }
#lb-modal-close { margin-top: 14px; }

/* Sticky-anchor "You" row pinned at the bottom of the full-list modal.
   The gold top-line (certificate accent) sets it apart as intentional. */
.lb-mine {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1.5px solid var(--accent);
}
.lb-mine .lb-row { border-bottom: none; cursor: pointer; }
.lb-mine .lb-name::after {
  content: "You";
  margin-left: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #92400E;
  background: rgba(217, 119, 6, 0.16);
  border: 1px solid rgba(217, 119, 6, 0.55);
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
/* Brief turmeric flash on the real row when you tap the pinned anchor to find it. */
@keyframes lbFlash {
  0%   { background: rgba(217, 119, 6, 0.5); }
  100% { background: var(--accent-soft); }
}
.lb-row.me.lb-flash { animation: lbFlash 1.5s ease-out; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 100;
  transition: opacity 0.3s;
}
