/* ==========================================================
   Marki Draakoni Seiklus — stiilid (mobiil eelkõige: iPhone 12 mini 375×812 ja uuemad)
   ========================================================== */
:root {
  color-scheme: dark;
  --bg: #0d1022;
  --bg-2: #141935;
  --card: rgba(29, 35, 68, 0.92);
  --card-2: rgba(40, 48, 90, 0.95);
  --line: rgba(255, 255, 255, 0.12);
  --line-2: rgba(255, 255, 255, 0.2);
  --text: #f8fafc;
  --muted: #9aa6bf;
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.16);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.14);
  --cyan: #22d3ee;
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.12);
  --orange: #fb923c;
  --orange-soft: rgba(249, 115, 22, 0.16);
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --font-display: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --tabbar-h: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.35;
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: 0.5; cursor: default; }
img { max-width: 100%; display: block; }

/* iOS-il background-attachment: fixed ei tööta — kasutame fikseeritud kihti */
.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle at 12% 6%, rgba(99, 102, 241, 0.25) 0%, transparent 42%),
    radial-gradient(circle at 90% 18%, rgba(168, 85, 247, 0.2) 0%, transparent 46%),
    radial-gradient(circle at 50% 92%, rgba(6, 182, 212, 0.13) 0%, transparent 50%),
    linear-gradient(180deg, #0b0e1b 0%, #11162d 100%);
}

/* ---------------- Ülariba ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 14px) 8px calc(var(--sal) + 14px);
  background: rgba(13, 16, 34, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 24px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.35);
}
.hello { flex: 1; min-width: 0; }
.hello h1 { font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; line-height: 1.1; }
.hello p { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 1.1rem;
  background: var(--card); border: 1px solid var(--line);
}
.icon-btn:active { transform: scale(0.93); }
.dot-badge {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff; font-size: 0.68rem; font-weight: 800;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

.netbar {
  display: none; margin: 8px calc(var(--sar) + 14px) 0 calc(var(--sal) + 14px);
  padding: 7px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; text-align: center;
  background: rgba(148, 163, 184, 0.14); border: 1px solid var(--line); color: #cbd5e1;
}
.netbar.show { display: block; }

.install-hint {
  display: none; align-items: center; gap: 10px;
  margin: 10px calc(var(--sar) + 14px) 0 calc(var(--sal) + 14px);
  padding: 10px 12px; border-radius: var(--r-md);
  background: rgba(99, 102, 241, 0.16); border: 1px solid rgba(99, 102, 241, 0.4); font-size: 0.84rem;
}
.install-hint.show { display: flex; }
.install-hint b { color: #c7d2fe; }
.install-hint .x { margin-left: auto; font-size: 1rem; color: var(--muted); padding: 4px 6px; }

/* ---------------- Vaated ---------------- */
main {
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: 12px calc(var(--sar) + 14px) calc(var(--tabbar-h) + var(--sab) + 24px) calc(var(--sal) + 14px);
}
.view { display: none; flex-direction: column; gap: 14px; animation: viewIn 0.22s ease; }
.view.active { display: flex; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px;
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 2px -4px; }
.section-head h2, .section-head h3 { font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

/* ---------------- Kangelase kaart ---------------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(140deg, rgba(49, 38, 112, 0.92) 0%, rgba(17, 24, 48, 0.92) 100%);
  border: 1px solid rgba(139, 92, 246, 0.38);
}
.hero::before {
  content: ''; position: absolute; top: -70px; right: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.3) 0%, transparent 70%); pointer-events: none;
}
.hero-top { display: flex; gap: 14px; align-items: center; position: relative; }
.dragon {
  position: relative; width: 84px; height: 84px; flex-shrink: 0; border-radius: 24px;
  display: grid; place-items: center; font-size: 46px;
  background: linear-gradient(135deg, #4f46e5, #9333ea);
  box-shadow: 0 8px 26px rgba(99, 102, 241, 0.45);
  animation: floaty 3.2s ease-in-out infinite;
}
.dragon .acc { position: absolute; right: -8px; top: -8px; font-size: 24px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.dragon .lvl {
  position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #1e1b4b; font-weight: 800; font-size: 0.72rem;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap; box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.dragon.hop { animation: hop 0.65s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px) rotate(2deg); } }
@keyframes hop {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.2, 0.85) translateY(5px); }
  55% { transform: scale(0.9, 1.2) translateY(-20px) rotate(-3deg); }
  80% { transform: scale(1.08, 0.94) translateY(-3px); }
}
.hero-info { flex: 1; min-width: 0; }
.hero-info h2 { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; color: var(--gold); line-height: 1.15; }
.hero-info p { font-size: 0.8rem; color: #c3cbe0; margin-top: 3px; }
.xpbar { margin-top: 10px; }
.xpbar-meta { display: flex; justify-content: space-between; font-size: 0.72rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.track { position: relative; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.09); overflow: hidden; }
.fill {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #a855f7, #fbbf24);
  transition: width 0.7s cubic-bezier(0.34, 1.3, 0.64, 1);
}
.fill.green { background: linear-gradient(90deg, #10b981, #34d399); }

.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; position: relative; }
.stat {
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-sm); padding: 9px 6px; text-align: center; min-width: 0;
}
.stat .v { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.stat .k { font-size: 0.68rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-top: 2px; }
.stat.wallet .v { color: var(--gold); }
.stat.fire .v { color: var(--orange); }
.ring { --p: 0; width: 44px; height: 44px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--green) calc(var(--p) * 1%), rgba(255,255,255,0.1) 0); }
.ring > span { width: 34px; height: 34px; border-radius: 50%; background: #1a2045; display: grid; place-items: center;
  font-size: 0.72rem; font-weight: 800; }
.ring.done { background: conic-gradient(var(--gold) 100%, transparent 0); }

.daily-note { margin-top: 12px; font-size: 0.8rem; padding: 8px 12px; border-radius: var(--r-sm);
  background: var(--green-soft); border: 1px solid rgba(16, 185, 129, 0.3); position: relative; }
.daily-note b { color: #6ee7b7; }

/* ---------------- Järgmine soov (kodulehel) ---------------- */
.next-goal { display: flex; gap: 12px; align-items: center; }
.next-goal .emo { width: 52px; height: 52px; border-radius: 16px; flex-shrink: 0; font-size: 28px; display: grid; place-items: center;
  background: var(--gold-soft); border: 1px solid rgba(251, 191, 36, 0.4); }
.next-goal .body { flex: 1; min-width: 0; }
.next-goal .t { font-weight: 800; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.next-goal .s { font-size: 0.78rem; color: var(--muted); margin: 2px 0 6px; }
.next-goal .chev { color: var(--muted); font-size: 1.2rem; }
.empty-goal { text-align: center; padding: 18px 14px; }
.empty-goal .big { font-size: 2.4rem; }

/* ---------------- Nupud ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: var(--r-md);
  font-weight: 800; font-size: 0.98rem; color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
  transition: transform 0.12s;
}
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn.block { width: 100%; }
.btn.green { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35); }
.btn.gold { background: linear-gradient(135deg, #f59e0b, #ef4444); box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35); }
.btn.cyan { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.btn.ghost { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); box-shadow: none; color: #dbe2f0; }
.btn.danger { background: var(--red-soft); border: 1px solid rgba(239, 68, 68, 0.5); box-shadow: none; color: #fca5a5; }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: 0.85rem; border-radius: var(--r-sm); }

.math-cta {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  box-shadow: 0 8px 22px rgba(14, 165, 233, 0.32);
}
.math-cta:active { transform: scale(0.98); }
.math-cta .ic { font-size: 2rem; }
.math-cta .t { font-family: var(--font-display); font-size: 1.08rem; font-weight: 600; }
.math-cta .s { font-size: 0.78rem; opacity: 0.9; }
.math-cta .pill { margin-left: auto; background: rgba(255, 255, 255, 0.22); padding: 5px 10px; border-radius: 999px; font-weight: 800; font-size: 0.82rem; white-space: nowrap; }
.math-cta.done { background: linear-gradient(135deg, rgba(16, 185, 129, 0.4), rgba(16, 185, 129, 0.2)); box-shadow: none; border: 1px solid rgba(16, 185, 129, 0.4); }

/* ---------------- Kategooriad ---------------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 8px 13px; border-radius: 999px; font-size: 0.84rem; font-weight: 700;
  background: var(--card); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.active { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-color: transparent; }

/* ---------------- Ülesanded ---------------- */
.tasks { display: flex; flex-direction: column; gap: 10px; }
.task {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px; transition: transform 0.12s, background 0.2s;
}
.task.done { background: var(--green-soft); border-color: rgba(16, 185, 129, 0.35); }
.task.pending { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.3); }
.task .ic { width: 46px; height: 46px; flex-shrink: 0; border-radius: 14px; font-size: 1.6rem; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1); }
.task .body { flex: 1; min-width: 0; }
.task .t { font-weight: 700; font-size: 0.95rem; line-height: 1.22;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.badge { font-size: 0.7rem; font-weight: 800; padding: 2px 7px; border-radius: 8px; white-space: nowrap;
  background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.badge.pts { background: var(--gold-soft); color: #fde047; border: 1px solid rgba(251, 191, 36, 0.4); }
.badge.photo { background: rgba(34, 211, 238, 0.14); color: #67e8f9; }
.badge.fire { background: var(--orange-soft); color: var(--orange); }
.badge.wait { background: rgba(251, 191, 36, 0.14); color: #fcd34d; }
.badge.ok { background: var(--green-soft); color: #6ee7b7; }
.act {
  width: 58px; height: 58px; flex-shrink: 0; border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 4px 14px rgba(16, 185, 129, 0.38);
  font-size: 1.35rem; line-height: 1;
}
.act small { font-size: 0.66rem; font-weight: 800; }
.act:active:not(:disabled) { transform: scale(0.9); }
.act.photo { background: linear-gradient(135deg, #0ea5e9, #6366f1); box-shadow: 0 4px 14px rgba(14, 165, 233, 0.38); }
.act.math { background: linear-gradient(135deg, #f59e0b, #ef4444); box-shadow: 0 4px 14px rgba(245, 158, 11, 0.38); }
.act.done { background: rgba(255, 255, 255, 0.1); box-shadow: none; color: #34d399; }
.act.wait { background: rgba(251, 191, 36, 0.14); box-shadow: none; }

/* ---------------- Soovid / ajajoon ---------------- */
.pace { display: flex; gap: 12px; align-items: stretch; }
.pace .num { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; color: var(--gold); line-height: 1; }
.pace .lbl { font-size: 0.74rem; color: var(--muted); font-weight: 700; margin-top: 4px; }
.spark { flex: 1; display: flex; align-items: flex-end; gap: 5px; height: 58px; min-width: 0; }
.spark .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; justify-content: flex-end; }
.spark .bar { width: 100%; border-radius: 5px 5px 2px 2px; background: linear-gradient(180deg, #a855f7, #6366f1); min-height: 3px; }
.spark .bar.neg { background: var(--red); }
.spark .bar.zero { background: rgba(255, 255, 255, 0.1); }
.spark .d { font-size: 0.6rem; color: var(--muted); font-weight: 700; }

.timeline { position: relative; padding-left: 30px; display: flex; flex-direction: column; gap: 14px; }
.timeline::before { content: ''; position: absolute; left: 13px; top: 18px; bottom: 18px; width: 3px; border-radius: 2px;
  background: linear-gradient(180deg, var(--gold), var(--primary-2) 40%, rgba(255,255,255,0.12)); }
.tl-item { position: relative; }
.tl-node { position: absolute; left: -30px; top: 14px; width: 29px; height: 29px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.9rem; background: #1b2150; border: 2px solid var(--primary-2); z-index: 1; }
.tl-item.now .tl-node { background: var(--gold); border-color: #fde68a; font-size: 1rem; }
.tl-item.ready .tl-node { background: var(--green); border-color: #6ee7b7; }
.tl-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; }
.tl-item.now .tl-card { background: var(--gold-soft); border-color: rgba(251, 191, 36, 0.45); }
.tl-item.ready .tl-card { border-color: rgba(16, 185, 129, 0.5); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12); }
.tl-head { display: flex; gap: 10px; align-items: center; }
.tl-emo { font-size: 1.9rem; flex-shrink: 0; }
.tl-title { font-weight: 800; font-size: 0.98rem; line-height: 1.2; word-break: break-word; }
.tl-cost { font-size: 0.78rem; color: var(--gold); font-weight: 800; margin-top: 2px; }
.tl-order { margin-left: auto; display: flex; flex-direction: column; gap: 4px; }
.tl-order button { width: 32px; height: 26px; border-radius: 8px; background: rgba(255,255,255,0.08); font-size: 0.75rem; }
.tl-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 0.76rem; color: var(--muted); font-weight: 700; margin: 8px 0 5px; }
.tl-meta .eta { color: #c7d2fe; }
.tl-actions { display: flex; gap: 8px; margin-top: 10px; }
.tl-note { font-size: 0.78rem; color: var(--muted); margin-top: 4px; font-style: italic; }

.goal-mini { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.05); border: 1px dashed var(--line-2); }
.goal-mini .e { font-size: 1.5rem; }
.goal-mini .x { margin-left: auto; color: var(--muted); padding: 6px; }
.goal-done { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--green-soft); font-size: 0.86rem; }

/* ---------------- Saavutused ---------------- */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ach { text-align: center; padding: 12px 6px; border-radius: var(--r-md); background: var(--card); border: 1px solid var(--line); }
.ach .i { font-size: 2rem; }
.ach .n { font-size: 0.74rem; font-weight: 800; margin-top: 4px; line-height: 1.15; }
.ach .p { font-size: 0.64rem; color: var(--muted); margin-top: 3px; }
.ach.locked .i { filter: grayscale(1); opacity: 0.35; }
.ach.locked .n { color: var(--muted); }
.ach.unlocked { background: linear-gradient(160deg, rgba(251, 191, 36, 0.18), rgba(29, 35, 68, 0.92)); border-color: rgba(251, 191, 36, 0.45); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kv > div { background: rgba(255,255,255,0.05); border-radius: var(--r-sm); padding: 10px; }
.kv b { display: block; font-family: var(--font-display); font-size: 1.3rem; }
.kv span { font-size: 0.72rem; color: var(--muted); font-weight: 700; }
.levels { display: flex; flex-direction: column; gap: 6px; }
.lv { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; padding: 6px 8px; border-radius: 10px; }
.lv.cur { background: var(--gold-soft); border: 1px solid rgba(251, 191, 36, 0.4); }
.lv.lock { opacity: 0.45; }
.lv .e { font-size: 1.3rem; width: 28px; text-align: center; }
.lv .x { margin-left: auto; color: var(--muted); font-weight: 700; font-size: 0.78rem; }

.tx-list { display: flex; flex-direction: column; }
.tx { display: flex; justify-content: space-between; gap: 10px; padding: 9px 2px; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 0.84rem; }
.tx:last-child { border-bottom: 0; }
.tx .r { min-width: 0; }
.tx .d { font-size: 0.7rem; color: var(--muted); }
.tx .p { font-weight: 800; white-space: nowrap; }
.tx .p.plus { color: #34d399; }
.tx .p.minus { color: #f87171; }

.rules { font-size: 0.84rem; color: #cbd5e1; display: flex; flex-direction: column; gap: 6px; }
.rules li { list-style: none; padding-left: 4px; }

/* ---------------- Alumine menüü ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; justify-content: space-around;
  padding: 6px calc(var(--sar) + 8px) calc(var(--sab) + 6px) calc(var(--sal) + 8px);
  background: rgba(13, 16, 34, 0.9);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.tab { position: relative; flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border-radius: 14px; color: var(--muted); font-size: 0.7rem; font-weight: 800; }
.tab .i { font-size: 1.4rem; line-height: 1.1; transition: transform 0.15s; }
.tab.active { color: #fff; background: rgba(99, 102, 241, 0.2); }
.tab.active .i { transform: scale(1.12); }
.tab .dot-badge { top: 0; right: calc(50% - 26px); }

/* ---------------- Lehed (bottom sheets) ---------------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(4, 6, 14, 0.7);
  opacity: 0; pointer-events: none; transition: opacity 0.22s;
}
.sheet-wrap.open { opacity: 1; pointer-events: auto; }
.sheet {
  width: 100%; max-width: 560px;
  max-height: calc(100vh - var(--sat) - 10px);
  max-height: calc(100dvh - var(--sat) - 10px);
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: #161b38; border: 1px solid var(--line); border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 10px calc(var(--sar) + 18px) calc(var(--sab) + 20px) calc(var(--sal) + 18px);
  transform: translateY(40px); transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.sheet-wrap.open .sheet { transform: none; }
.sheet.full { height: calc(100dvh - var(--sat) - 10px); display: flex; flex-direction: column; }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.2); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h3 { flex: 1; font-family: var(--font-display); font-size: 1.28rem; font-weight: 600; line-height: 1.15; }
.close { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.1); font-size: 1rem; color: var(--muted); flex-shrink: 0; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 0.78rem; color: var(--muted); font-weight: 700; margin-bottom: 5px; }
.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line-2); color: #fff;
  font-size: 16px; /* 16px => iOS ei suumi */
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25); }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }

.emoji-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.emoji-pick button { height: 46px; font-size: 1.5rem; border-radius: 12px; background: rgba(255,255,255,0.06); border: 2px solid transparent; }
.emoji-pick button.sel { border-color: var(--gold); background: var(--gold-soft); }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; font-size: 0.9rem; }
.switch { position: relative; width: 50px; height: 30px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(255,255,255,0.15); transition: 0.2s; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: 0.2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }

/* Foto */
.photo-zone { border: 2px dashed rgba(34, 211, 238, 0.45); border-radius: var(--r-md); padding: 22px 14px; text-align: center;
  background: rgba(34, 211, 238, 0.05); margin-bottom: 14px; }
.photo-zone .big { font-size: 3.2rem; }
.photo-zone img { max-height: 42vh; margin: 0 auto; border-radius: 12px; border: 2px solid var(--cyan); }
.link-btn { display: block; margin: 12px auto 0; font-size: 0.84rem; font-weight: 700; color: #cbd5e1; padding: 8px 12px;
  border-radius: 999px; background: rgba(255,255,255,0.07); border: 1px solid var(--line); }

/* ---------------- Matemaatika ---------------- */
.math-modes { display: grid; gap: 10px; margin: 6px 0 14px; }
.mode-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r-md); text-align: left;
  background: rgba(255,255,255,0.06); border: 2px solid var(--line); }
.mode-card.sel { border-color: var(--primary-2); background: rgba(139, 92, 246, 0.16); }
.mode-card .i { font-size: 2rem; }
.mode-card b { display: block; font-size: 1rem; }
.mode-card span { font-size: 0.78rem; color: var(--muted); }
.math-top { display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem; font-weight: 800; color: var(--cyan); }
.math-need { text-align: center; font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-top: 8px; min-height: 1.2em; }
.math-q {
  flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--font-display); font-weight: 600; font-size: clamp(2rem, 11vw, 3rem);
  letter-spacing: 1px; min-height: 110px; padding: 10px 0; line-height: 1.2;
}
.math-q .hl { color: var(--gold); }
.math-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-bottom: 6px; }
.math-opt { min-height: 74px; border-radius: var(--r-md); font-family: var(--font-display); font-size: 1.9rem; font-weight: 600;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.14); transition: transform 0.1s; }
.math-opt:active:not(:disabled) { transform: scale(0.95); }
.math-opt.correct { background: var(--green); border-color: #6ee7b7; opacity: 1; }
.math-opt.wrong { background: var(--red); border-color: #fca5a5; opacity: 1; animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.math-result { text-align: center; }
.math-result .big { font-size: 4rem; margin: 6px 0; }
.math-result h4 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; }
.mistakes { text-align: left; margin: 14px 0; display: flex; flex-direction: column; gap: 6px; }
.mistakes div { padding: 8px 12px; border-radius: 10px; background: var(--red-soft); font-size: 0.9rem; }
.mistakes b { color: #6ee7b7; }

/* ---------------- Vanem ---------------- */
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 10px 0 18px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); }
.pin-dots i.on { background: var(--gold); border-color: var(--gold); }
.pin-dots.err { animation: shake 0.35s; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 0 auto; }
.pinpad button { height: 62px; border-radius: 18px; font-size: 1.5rem; font-weight: 700; background: rgba(255,255,255,0.08); }
.pinpad button:active { background: rgba(255,255,255,0.18); }

.ptabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -18px 14px; padding: 0 18px; scrollbar-width: none; }
.ptabs::-webkit-scrollbar { display: none; }
.ptab { position: relative; flex-shrink: 0; padding: 8px 12px; border-radius: 12px; font-size: 0.82rem; font-weight: 800;
  background: rgba(255,255,255,0.06); color: var(--muted); }
.ptab.active { background: var(--primary); color: #fff; }
.ptab .dot-badge { top: -6px; right: -6px; }
.plist { display: flex; flex-direction: column; gap: 8px; }
.pitem { padding: 10px 12px; border-radius: var(--r-sm); background: rgba(255,255,255,0.05); border: 1px solid var(--line); }
.pitem .h { display: flex; gap: 10px; align-items: center; }
.pitem .h .e { font-size: 1.4rem; }
.pitem .h .t { flex: 1; min-width: 0; font-weight: 700; font-size: 0.9rem; }
.pitem .sub { font-size: 0.74rem; color: var(--muted); }
.pitem .a { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.pitem img { margin-top: 8px; border-radius: 10px; max-height: 50vh; }
.pitem.pen { background: var(--red-soft); border-color: rgba(239, 68, 68, 0.28); display: flex; align-items: center; gap: 10px; }
.subhead { font-weight: 800; font-size: 0.9rem; margin: 16px 0 8px; }
.subhead:first-child { margin-top: 0; }
.chart { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding-top: 16px; }
.chart .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; min-width: 0; }
.chart .bar { width: 100%; border-radius: 4px 4px 2px 2px; background: linear-gradient(180deg, #a855f7, #6366f1); min-height: 2px; }
.chart .bar.goal { background: linear-gradient(180deg, #fbbf24, #f59e0b); }
.chart .v { font-size: 0.6rem; font-weight: 800; }
.chart .d { font-size: 0.56rem; color: var(--muted); }
table.mini { width: 100%; border-collapse: collapse; font-size: 0.76rem; }
table.mini th { color: var(--muted); text-align: left; padding: 4px; font-weight: 700; border-bottom: 1px solid var(--line); }
table.mini td { padding: 5px 4px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.meter { margin-bottom: 9px; }
.meter .l { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 700; margin-bottom: 3px; }
.meter .track { height: 7px; }
.warn { padding: 10px 12px; border-radius: var(--r-sm); background: rgba(251, 191, 36, 0.12); border: 1px solid rgba(251, 191, 36, 0.4); font-size: 0.84rem; margin-bottom: 12px; }

/* ---------------- Tähistamine ---------------- */
.celebrate { text-align: center; padding: 10px 0 4px; }
.celebrate .big { font-size: 5rem; animation: pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
.celebrate h3 { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; margin: 6px 0; color: var(--gold); }
.celebrate p { color: #cbd5e1; margin-bottom: 18px; }
@keyframes pop { from { transform: scale(0.2) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; z-index: 300;
  bottom: calc(var(--tabbar-h) + var(--sab) + 14px);
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100vw - 28px);
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-radius: 18px;
  background: #1e1b4b; border: 1px solid var(--gold); box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  font-weight: 700; font-size: 0.88rem; transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.err { border-color: var(--red); }

.float-pts { position: fixed; z-index: 400; pointer-events: none; font-family: var(--font-display); font-weight: 700; font-size: 1.5rem;
  color: var(--gold); text-shadow: 0 2px 8px rgba(0,0,0,0.6); animation: floatUp 1.1s ease-out forwards; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(0) scale(0.6); } 20% { opacity: 1; transform: translateY(-10px) scale(1.2); } 100% { opacity: 0; transform: translateY(-70px) scale(1); } }

#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 500; }

.update-bar { position: fixed; left: 14px; right: 14px; top: calc(var(--sat) + 8px); z-index: 600; display: none;
  align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: #312e81; border: 1px solid #818cf8; font-size: 0.86rem; font-weight: 700; }
.update-bar.show { display: flex; }
.update-bar button { margin-left: auto; }

.loading { text-align: center; padding: 50px 10px; color: var(--muted); }
.loading .big { font-size: 3rem; animation: floaty 2s infinite; }

@media (min-width: 420px) {
  .task .t { font-size: 1rem; }
  .badge-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ==========================================================
   KONTROLLTÖÖ (14P) JA ELUHÄKKIDE STIILID
   ========================================================== */
.kt-card {
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.95), rgba(49, 46, 129, 0.95));
  border: 2px solid #818cf8;
  box-shadow: 0 12px 28px -6px rgba(99, 102, 241, 0.35);
  position: relative;
  overflow: hidden;
}
.kt-card::after {
  content: "📝";
  position: absolute;
  right: -8px;
  bottom: -10px;
  font-size: 4rem;
  opacity: 0.08;
  pointer-events: none;
}
.kt-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.badge-sub {
  font-size: 0.74rem;
  color: #c7d2fe;
  font-weight: 700;
}
.badge.gold {
  background: var(--gold);
  color: #0f172a;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 12px;
}
.kt-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #fff;
  line-height: 1.2;
}
.kt-desc {
  font-size: 0.82rem;
  color: #cbd5e1;
  margin-bottom: 12px;
  line-height: 1.4;
}
.kt-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.kt-link {
  text-align: center;
  display: block;
  font-size: 0.82rem;
  color: #a5b4fc;
  text-decoration: none;
  font-weight: 700;
  padding: 4px 0;
  transition: color 0.15s;
}
.kt-link:hover {
  color: #e0e7ff;
}

/* Lifehacks Sheet Tabs */
.lh-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(13, 16, 34, 0.6);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
}
.lh-tab-btn {
  padding: 8px 4px;
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  transition: all 0.12s;
}
.lh-tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}
