:root {
  --card: #ffffff;
  --card-2: #f4f2ff;
  --text: #1f1d3a;
  --muted: #6b6890;
  --line: #e6e3f5;
  --primary: #6c5ce7;
  --primary-ink: #ffffff;
  --gold: #f5b301;
  --ontime: #10b981;
  --late: #f59e0b;
  --qada: #8b5cf6;
  --missed: #ef4444;
  --excused: #94a3b8;
  --shadow: 0 10px 30px rgba(20, 10, 60, .18);
  --radius: 22px;
  --sky-a: #38bdf8;
  --sky-b: #a5f3fc;
  --sky-ink: #0c2340;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --card: #1c1a33; --card-2: #26234a; --text: #f1efff; --muted: #a9a5cc; --line: #34305c;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  }
}
:root[data-theme="dark"] {
  --card: #1c1a33; --card-2: #26234a; --text: #f1efff; --muted: #a9a5cc; --line: #34305c;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Baloo Bhaijaan 2', system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(170deg, var(--sky-a), var(--sky-b)) fixed;
  background-color: var(--sky-a);
  min-height: 100vh;
  transition: background .8s;
}
body.sky-night   { --sky-a: #0f0c29; --sky-b: #302b63; --sky-ink: #fff; }
body.sky-dawn    { --sky-a: #2d1b69; --sky-b: #f8a5c2; --sky-ink: #fff; }
body.sky-morning { --sky-a: #4facfe; --sky-b: #b5f1ff; --sky-ink: #0c2340; }
body.sky-noon    { --sky-a: #1e90ff; --sky-b: #87e0ff; --sky-ink: #0c2340; }
body.sky-asr     { --sky-a: #f6a623; --sky-b: #ffe08a; --sky-ink: #3b2200; }
body.sky-sunset  { --sky-a: #c0392b; --sky-b: #f39c12; --sky-ink: #fff; }
body.sky-night::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 20%, #fff, transparent), radial-gradient(1px 1px at 30% 70%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 55% 15%, #fff, transparent), radial-gradient(1px 1px at 75% 45%, #fff, transparent),
    radial-gradient(2px 2px at 88% 12%, #fff, transparent), radial-gradient(1px 1px at 20% 90%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 65% 85%, #fff, transparent), radial-gradient(1px 1px at 45% 40%, #fff, transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .5; } to { opacity: 1; } }

#app { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
#app.wide { max-width: 980px; }
button { font: inherit; cursor: pointer; border: 0; }
input, select { font: inherit; color: var(--text); background: var(--card-2); border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; width: 100%; min-width: 0; }
input:focus, select:focus { outline: none; border-color: var(--primary); }
a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.hidden { display: none !important; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.btn { background: var(--primary); color: var(--primary-ink); border-radius: 14px; padding: 10px 18px; font-weight: 700; font-size: 1rem; transition: transform .1s, filter .2s; }
.btn:active { transform: scale(.96); }
.btn.big { font-size: 1.35rem; padding: 14px 26px; border-radius: 18px; width: 100%; }
.btn.ghost { background: var(--card-2); color: var(--text); }
.btn.green { background: var(--ontime); }
.btn.orange { background: var(--late); }
.btn.purple { background: var(--qada); }
.btn.red { background: var(--missed); }
.btn.small { padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btn:disabled { opacity: .5; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; color: var(--sky-ink); margin-bottom: 14px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; background: var(--c, var(--primary)); box-shadow: 0 0 0 3px rgba(255,255,255,.7); flex-shrink: 0; }
.avatar.lg { width: 84px; height: 84px; font-size: 48px; }
.topbar .name { font-weight: 800; font-size: 1.3rem; line-height: 1; }
.topbar .lvl { font-size: .85rem; opacity: .9; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.92); color: #1f1d3a; border-radius: 999px; padding: 4px 12px; font-weight: 800; font-size: 1.05rem; box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.pill .ico { font-size: 1.2rem; }
.iconbtn { background: rgba(255,255,255,.25); color: var(--sky-ink); width: 40px; height: 40px; border-radius: 12px; font-size: 1.2rem; display: grid; place-items: center; }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 22px 18px; position: relative; overflow: hidden; }
.hero .label { color: var(--muted); font-weight: 600; }
.hero .pname { font-size: 2.6rem; font-weight: 800; line-height: 1.1; margin: 4px 0; }
.hero .count { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.hero .hint { margin: 6px 0 14px; color: var(--muted); }
.hero.ontime { box-shadow: 0 0 0 4px var(--ontime), var(--shadow); animation: glow 1.6s ease-in-out infinite alternate; }
.hero.late { box-shadow: 0 0 0 4px var(--late), var(--shadow); }
.hero.qada { box-shadow: 0 0 0 4px var(--qada), var(--shadow); }
@keyframes glow { from { box-shadow: 0 0 0 4px var(--ontime), var(--shadow); } to { box-shadow: 0 0 0 8px rgba(16,185,129,.35), var(--shadow); } }

/* ---------- prayer list ---------- */
.prayers { display: grid; gap: 10px; }
.prayer { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); border-inline-start: 6px solid var(--line); }
.prayer .pi { font-size: 1.8rem; width: 40px; text-align: center; }
.prayer .pn { font-weight: 800; font-size: 1.2rem; }
.prayer .pt { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.prayer.ontime { border-color: var(--ontime); }
.prayer.late { border-color: var(--late); }
.prayer.qada { border-color: var(--qada); }
.prayer.active { border-color: var(--primary); }
.prayer.locked { opacity: .6; }
.chip { border-radius: 999px; padding: 4px 12px; font-weight: 700; font-size: .9rem; color: #fff; white-space: nowrap; }
.chip.ontime { background: var(--ontime); }
.chip.late { background: var(--late); }
.chip.qada { background: var(--qada); }
.chip.missed { background: var(--missed); }
.chip.excused, .chip.none { background: var(--excused); }

/* ---------- week & streak ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.week .d { font-size: .8rem; color: var(--muted); }
.week .dot { aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: 1.1rem; background: var(--card-2); margin: 4px auto 0; width: 100%; max-width: 44px; }
.dot.complete { background: var(--ontime); }
.dot.partial { background: var(--late); }
.dot.missed { background: var(--missed); }
.dot.excused { background: var(--excused); }
.dot.open { background: var(--card-2); box-shadow: inset 0 0 0 3px var(--primary); }
.bar { height: 14px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f97316, #facc15); transition: width .6s; }
.bar.purple > i { background: linear-gradient(90deg, #6c5ce7, #a78bfa); }
.flame { font-size: 2.4rem; display: inline-block; animation: flicker 1.2s ease-in-out infinite alternate; }
@keyframes flicker { from { transform: scale(1) rotate(-3deg); } to { transform: scale(1.12) rotate(3deg); } }
.flame.out { filter: grayscale(1); opacity: .5; animation: none; }

/* ---------- shop ---------- */
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.reward { background: var(--card); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); text-align: center; display: flex; flex-direction: column; gap: 8px; }
.reward .re { font-size: 2.6rem; }
.reward .rt { font-weight: 700; line-height: 1.25; flex: 1; }
.reward .rc { font-weight: 800; color: var(--gold); font-size: 1.1rem; }

/* ---------- badges ---------- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.badge { background: var(--card); border-radius: 18px; padding: 12px 8px; text-align: center; box-shadow: var(--shadow); }
.badge .bi { font-size: 2.4rem; }
.badge .bn { font-weight: 700; font-size: .9rem; line-height: 1.2; }
.badge .bh { font-size: .75rem; color: var(--muted); }
.badge.locked .bi { filter: grayscale(1); opacity: .35; }

/* ---------- family ---------- */
.fam { display: flex; align-items: center; gap: 12px; }
.fam .rank { font-size: 1.8rem; width: 36px; text-align: center; }
.dots5 { display: flex; gap: 4px; }
.dots5 i { width: 14px; height: 14px; border-radius: 50%; background: var(--card-2); display: block; }
.dots5 i.ontime { background: var(--ontime); }
.dots5 i.late { background: var(--late); }
.dots5 i.qada { background: var(--qada); }

/* ---------- bottom nav ---------- */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; justify-content: center; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--card); box-shadow: 0 -6px 24px rgba(0,0,0,.12); }
.nav .in { display: flex; width: 100%; max-width: 560px; }
.nav button { flex: 1; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; font-weight: 700; font-size: .85rem; padding: 4px 0; border-radius: 12px; }
.nav button span { font-size: 1.5rem; line-height: 1.2; }
.nav button.on { color: var(--primary); background: var(--card-2); }
.nav .count { background: var(--missed); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 6px; margin-inline-start: 2px; }

/* ---------- login ---------- */
.brand { text-align: center; color: var(--sky-ink); margin: 18px 0 22px; }
.brand h1 { font-size: 2.4rem; font-weight: 800; }
.who { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.who button { background: var(--card); color: var(--text); border-radius: 22px; padding: 18px 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; transition: transform .12s; }
.who button:active { transform: scale(.95); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 280px; margin: 0 auto; direction: ltr; }
.pinpad button { background: var(--card-2); color: var(--text); font-size: 1.6rem; font-weight: 800; border-radius: 16px; padding: 12px 0; }
.pindots { display: flex; justify-content: center; gap: 12px; margin: 14px 0; direction: ltr; }
.pindots i { width: 16px; height: 16px; border-radius: 50%; background: var(--line); display: block; }
.pindots i.on { background: var(--primary); }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(10, 6, 30, .55); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.modal { background: var(--card); border-radius: 26px; padding: 22px; width: 100%; max-width: 400px; max-height: 88vh; overflow: auto; text-align: center; animation: pop .35s cubic-bezier(.2,1.6,.4,1); }
.modal .big-emoji { font-size: 4.5rem; line-height: 1.1; }
.modal h2 { font-size: 1.6rem; margin: 6px 0; }
.modal .actions { display: flex; gap: 10px; margin-top: 16px; }
.modal .actions .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--text); color: var(--card); padding: 10px 18px; border-radius: 14px; font-weight: 700; box-shadow: var(--shadow); animation: fade .2s; max-width: calc(100vw - 32px); }
.floatpts { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 25; font-size: 3.4rem; font-weight: 800; color: var(--gold); text-shadow: 0 4px 0 #b45309, 0 8px 24px rgba(0,0,0,.3); pointer-events: none; animation: floatup 1.6s ease-out forwards; }
@keyframes floatup { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

/* ---------- parent ---------- */
.ptabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.ptabs button { background: rgba(255,255,255,.85); color: #1f1d3a; border-radius: 12px; padding: 8px 14px; font-weight: 700; white-space: nowrap; }
.ptabs button.on { background: var(--primary); color: #fff; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 5px 3px; text-align: center; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; }
.cell { width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center; background: var(--card-2); color: #fff; font-weight: 800; font-size: .85rem; }
.cell.ontime { background: var(--ontime); }
.cell.late { background: var(--late); }
.cell.qada { background: var(--qada); }
.cell.miss { background: var(--missed); }
tr.excused .cell { background: var(--excused); }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.form .row label { flex: 1; }
.emojis { display: flex; flex-wrap: wrap; gap: 6px; }
.emojis button { font-size: 1.5rem; width: 42px; height: 42px; border-radius: 12px; background: var(--card-2); }
.emojis button.on { box-shadow: 0 0 0 3px var(--primary); }
.colors button { width: 30px; height: 30px; border-radius: 50%; }
.colors button.on { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--text); }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.ev-pos { color: var(--ontime); font-weight: 800; }
.ev-neg { color: var(--missed); font-weight: 800; }
.section-title { color: var(--sky-ink); font-weight: 800; font-size: 1.2rem; margin: 18px 4px 8px; }

@media (max-width: 380px) {
  .hero .pname { font-size: 2.1rem; }
  .avatar { width: 44px; height: 44px; font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
