@font-face { font-family: 'Fredoka'; font-weight: 600; font-display: swap; src: url('/fonts/fredoka-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: swap; src: url('/fonts/fredoka-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 600; font-display: swap; src: url('/fonts/nunito-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: swap; src: url('/fonts/nunito-latin-800-normal.woff2') format('woff2'); }

:root {
  --purple: #5b3df5; --purple-d: #3f26c9; --sky: #34c3ff; --mint: #22d39a; --sun: #ffc83d; --coral: #ff6b6b; --pink: #ff7bd0;
  --ink: #1d1747; --ink-2: #4b4680; --card: #ffffff; --soft: #f3f0ff; --line: #e3ddff;
  --r: 22px; --shadow: 0 6px 0 rgba(29, 23, 71, .14), 0 14px 30px rgba(29, 23, 71, .12);
  --head: 'Fredoka', ui-rounded, 'Arial Rounded MT Bold', system-ui, sans-serif;
  --body: 'Nunito', ui-rounded, system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--body); font-weight: 600; color: var(--ink); font-size: 18px; line-height: 1.45;
  background: linear-gradient(180deg, #5b3df5 0%, #7a55ff 45%, #9a78ff 100%) fixed;
  min-height: 100vh; padding-bottom: calc(96px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, .head { font-family: var(--head); font-weight: 700; letter-spacing: .2px; margin: 0; }
a { color: var(--purple-d); }
button { font: inherit; cursor: pointer; }

/* floating bubbles */
#sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
#sky span { position: absolute; border-radius: 50%; background: rgba(255,255,255,.12); animation: float 18s ease-in-out infinite; }
#sky span:nth-child(1) { width: 180px; height: 180px; left: -40px; top: 12%; }
#sky span:nth-child(2) { width: 90px; height: 90px; right: 8%; top: 8%; animation-delay: -4s; }
#sky span:nth-child(3) { width: 140px; height: 140px; right: -30px; top: 48%; animation-delay: -8s; }
#sky span:nth-child(4) { width: 60px; height: 60px; left: 20%; top: 70%; animation-delay: -2s; }
#sky span:nth-child(5) { width: 110px; height: 110px; left: 55%; top: 85%; animation-delay: -11s; }
@keyframes float { 50% { transform: translateY(-30px) scale(1.05); } }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(63, 38, 201, .55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-family: var(--head); font-size: 21px; white-space: nowrap; }
.brand-bot { width: 40px; height: 40px; display: inline-block; }
.brand-bot svg { width: 100%; height: 100%; }
.top-right { display: flex; align-items: center; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; background: #fff; font-family: var(--head); font-size: 18px; box-shadow: 0 3px 0 rgba(0,0,0,.15); }
.pill.coins { background: var(--sun); }
.pill.bump { animation: bump .5s; }
@keyframes bump { 30% { transform: scale(1.3) rotate(-6deg); } 60% { transform: scale(.95); } }
.icon-btn { border: 0; background: rgba(255,255,255,.2); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; }

main { max-width: 860px; margin: 0 auto; padding: 18px 14px 20px; outline: none; }

/* bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(29,23,71,.12); border-radius: 24px 24px 0 0; }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; border-radius: 16px; text-decoration: none; color: var(--ink-2); font-family: var(--head); font-size: 14px; }
.tabs a span { font-size: 26px; line-height: 1; transition: transform .2s; }
.tabs a.on { background: var(--soft); color: var(--purple); }
.tabs a.on span { transform: translateY(-3px) scale(1.15); }

/* cards and buttons */
.card { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 18px; padding: 14px 22px; min-height: 54px;
  font-family: var(--head); font-size: 20px; color: #fff; background: var(--purple); box-shadow: 0 6px 0 var(--purple-d); text-decoration: none; transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--purple-d); }
.btn.go { background: var(--mint); box-shadow: 0 6px 0 #14a376; }
.btn.go:active { box-shadow: 0 2px 0 #14a376; }
.btn.sun { background: var(--sun); color: var(--ink); box-shadow: 0 6px 0 #d99c00; }
.btn.ghost { background: var(--soft); color: var(--purple-d); box-shadow: 0 6px 0 var(--line); }
.btn.red { background: var(--coral); box-shadow: 0 6px 0 #d94848; }
.btn.small { min-height: 42px; padding: 8px 14px; font-size: 16px; border-radius: 14px; box-shadow: 0 4px 0 var(--purple-d); }
.btn.small.ghost { box-shadow: 0 4px 0 var(--line); }
.btn.small.go { box-shadow: 0 4px 0 #14a376; }
.btn.small.red { box-shadow: 0 4px 0 #d94848; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.wide { width: 100%; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--ink-2); }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--soft); color: var(--purple-d); font-size: 14px; font-family: var(--head); }

/* Bolt the robot */
.bolt-row { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 16px; }
.bolt { width: 96px; height: 96px; flex: none; animation: hover 3s ease-in-out infinite; }
.bolt svg { width: 100%; height: 100%; }
@keyframes hover { 50% { transform: translateY(-6px) rotate(2deg); } }
.bubble { position: relative; background: #fff; border-radius: 22px; padding: 14px 18px; box-shadow: var(--shadow); font-size: 19px; flex: 1; margin-bottom: 28px; }
.bubble::after { content: ''; position: absolute; left: -12px; bottom: 18px; border: 12px solid transparent; border-right-color: #fff; border-left: 0; }
.bubble b { color: var(--purple); }

/* level */
.level { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.level-badge { width: 70px; height: 70px; border-radius: 50%; background: conic-gradient(var(--sun) var(--p, 0%), #ffeec2 0); display: grid; place-items: center; box-shadow: 0 4px 0 #d99c00; }
.level-badge span { width: 54px; height: 54px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-family: var(--head); font-size: 26px; color: var(--purple); }
.bar { height: 18px; background: var(--soft); border-radius: 999px; overflow: hidden; box-shadow: inset 0 2px 0 rgba(0,0,0,.06); }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--mint), var(--sky)); border-radius: 999px; transition: width .8s cubic-bezier(.2,.9,.3,1.2); }
.bar.sun i { background: linear-gradient(90deg, var(--sun), var(--coral)); }

/* today's mission */
.today { background: linear-gradient(135deg, #ff8a5c, #ff5fa2); color: #fff; }
.today .big-icon { font-size: 64px; line-height: 1; filter: drop-shadow(0 4px 0 rgba(0,0,0,.15)); animation: wiggle 2.4s ease-in-out infinite; }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 80% { transform: rotate(-10deg); } 90% { transform: rotate(10deg); } }
.today h2 { font-size: 30px; }
.today .btn { margin-top: 12px; }
.today .meta { opacity: .95; }

/* mission map */
.map { position: relative; padding: 8px 0; }
.node { position: relative; display: flex; align-items: center; gap: 14px; padding: 10px 12px; margin: 0 0 6px; text-decoration: none; color: var(--ink); border-radius: 20px; }
.node:nth-child(even) { flex-direction: row-reverse; text-align: right; }
.node .dot { width: 76px; height: 76px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 36px; background: #fff; box-shadow: 0 6px 0 rgba(29,23,71,.18); position: relative; }
.node.done .dot { background: var(--sun); box-shadow: 0 6px 0 #d99c00; }
.node.done .dot::after { content: '⭐'; position: absolute; right: -6px; top: -6px; font-size: 24px; }
.node.open .dot { background: var(--mint); box-shadow: 0 6px 0 #14a376; animation: pulse 1.6s infinite; }
.node.locked .dot, .node.tomorrow .dot { background: #e8e5f7; filter: grayscale(1); opacity: .8; }
@keyframes pulse { 0% { outline: 0 solid rgba(34,211,154,.6); } 100% { outline: 16px solid rgba(34,211,154,0); } }
.node .label { background: rgba(255,255,255,.92); padding: 8px 14px; border-radius: 16px; box-shadow: 0 4px 0 rgba(29,23,71,.08); }
.node .label b { font-family: var(--head); font-size: 19px; display: block; }
.node .label small { color: var(--ink-2); font-size: 14px; }
.path-line { position: absolute; left: 50%; top: 40px; bottom: 40px; width: 8px; margin-left: -4px; background: repeating-linear-gradient(180deg, rgba(255,255,255,.7) 0 14px, transparent 14px 26px); border-radius: 4px; z-index: 0; }
.node { z-index: 1; }

/* mission page */
.m-head { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.m-head .big-icon { font-size: 60px; }
.m-head h1 { font-size: 30px; }
.step { position: relative; border-left: 8px solid var(--line); }
.step.done { border-left-color: var(--mint); }
.step .num { position: absolute; left: -24px; top: 14px; width: 38px; height: 38px; border-radius: 50%; background: var(--purple); color: #fff; display: grid; place-items: center; font-family: var(--head); box-shadow: 0 3px 0 var(--purple-d); }
.step.done .num { background: var(--mint); box-shadow: 0 3px 0 #14a376; }
.step h3 { font-size: 22px; margin: 0 0 8px 18px; }
.step .body { margin-left: 18px; }
.step p { margin: 8px 0; }
.step ol { padding-left: 22px; margin: 8px 0; }
.step ol li { margin: 6px 0; }
.video { position: relative; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; background: #000; margin: 6px 0 12px; }
.video iframe, .video img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: cover; }
.video button { position: absolute; inset: 0; border: 0; background: rgba(29,23,71,.25); display: grid; place-items: center; }
.video button span { width: 84px; height: 84px; border-radius: 50%; background: var(--coral); color: #fff; font-size: 38px; display: grid; place-items: center; box-shadow: 0 6px 0 #d94848; padding-left: 6px; }

/* games */
.game-item { background: var(--soft); border-radius: 18px; padding: 14px; margin: 10px 0; }
.game-item .text { font-family: var(--head); font-size: 20px; margin-bottom: 10px; }
.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.choice { border: 0; border-radius: 16px; padding: 14px; min-height: 56px; background: #fff; color: var(--ink); font-family: var(--head); font-size: 19px; box-shadow: 0 5px 0 var(--line); text-align: center; transition: transform .1s; }
.choice:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }
.choice.right { background: var(--mint); color: #fff; box-shadow: 0 5px 0 #14a376; animation: pop .4s; }
.choice.wrong { background: var(--coral); color: #fff; box-shadow: 0 5px 0 #d94848; animation: shake .4s; }
.choice[disabled] { cursor: default; }
.choice .chance { display: block; font-size: 14px; opacity: .9; }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.explain { margin-top: 10px; padding: 10px 14px; background: #fff; border-radius: 14px; border: 3px dashed var(--line); }
.explain.good { border-color: var(--mint); }
.explain.bad { border-color: var(--coral); }

/* quiz */
.quiz { background: linear-gradient(160deg, #fff 0%, #f6f3ff 100%); }
.quiz h2 { font-size: 26px; }
.qcount { display: flex; gap: 6px; margin: 10px 0 16px; }
.qcount i { flex: 1; height: 10px; border-radius: 999px; background: var(--line); }
.qcount i.ok { background: var(--mint); }
.qcount i.meh { background: var(--sun); }
.qcount i.now { background: var(--purple); }
.question { font-family: var(--head); font-size: 23px; margin-bottom: 14px; }
.quiz .choices { grid-template-columns: 1fr; }
.quiz .choice { text-align: left; padding-left: 18px; }

textarea { width: 100%; min-height: 120px; border-radius: 16px; border: 3px solid var(--line); padding: 12px 14px; font: inherit; font-size: 18px; color: var(--ink); resize: vertical; }
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--purple); }
input, select { font: inherit; font-size: 17px; border-radius: 12px; border: 3px solid var(--line); padding: 8px 10px; color: var(--ink); background: #fff; }
.saved { font-size: 14px; color: var(--mint); margin-left: 8px; }

.finish { text-align: center; background: linear-gradient(135deg, var(--sun), #ff9f43); }
.finish ul { text-align: left; display: inline-block; margin: 8px 0; }

/* shop */
.wallet { text-align: center; background: linear-gradient(135deg, var(--sun), #ffad33); }
.wallet .num { font-family: var(--head); font-size: 64px; line-height: 1; }
.rewards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.reward { text-align: center; }
.reward .big-icon { font-size: 54px; }
.reward h3 { font-size: 22px; margin: 6px 0; }
.price { font-family: var(--head); font-size: 22px; color: var(--purple); margin-bottom: 10px; }
.req { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 2px solid var(--soft); }
.req:last-child { border-bottom: 0; }
.status { font-family: var(--head); font-size: 15px; padding: 3px 10px; border-radius: 999px; }
.status.pending { background: #fff1c7; color: #8a5a00; }
.status.approved { background: #d4f8eb; color: #0b7a55; }
.status.declined, .status.cancelled { background: #ffe0e0; color: #a12b2b; }

/* trophies */
.badges { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.badge { text-align: center; padding: 16px 10px; border-radius: 20px; background: var(--soft); }
.badge .ic { font-size: 46px; display: block; }
.badge b { font-family: var(--head); font-size: 17px; display: block; margin-top: 4px; }
.badge.off { filter: grayscale(1); opacity: .45; }
.badge.on { background: linear-gradient(135deg, #fff4c4, #ffe08a); box-shadow: 0 4px 0 #e5b53b; }
.ladder li { margin: 6px 0; }
.ladder li.now { color: var(--purple); font-family: var(--head); }
.kudo { background: #fff6fb; border: 3px solid #ffd1ec; border-radius: 18px; padding: 12px 14px; margin: 10px 0; }
.kudo b { font-family: var(--head); color: #d4378f; }

/* overlay and celebration */
#overlay { position: fixed; inset: 0; z-index: 50; background: rgba(29,23,71,.55); display: grid; place-items: center; padding: 20px; }
.modal { background: #fff; border-radius: 28px; padding: 26px 22px; max-width: 460px; width: 100%; text-align: center; box-shadow: var(--shadow); animation: zoom .45s cubic-bezier(.2,.9,.3,1.4); max-height: 90vh; overflow: auto; }
.modal .big { font-size: 88px; line-height: 1.1; animation: spin-in .8s; }
.modal h2 { font-size: 30px; margin: 6px 0; }
.modal .pts { font-family: var(--head); font-size: 40px; color: var(--purple); }
@keyframes zoom { from { transform: scale(.6); opacity: 0; } }
@keyframes spin-in { from { transform: rotate(-200deg) scale(.2); } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

#toasts { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-family: var(--head); font-size: 18px; box-shadow: var(--shadow); animation: toast 2.6s forwards; }
.toast.plus { background: var(--sun); color: var(--ink); font-size: 24px; }
.toast.err { background: var(--coral); }
@keyframes toast { 0% { transform: translateY(-20px); opacity: 0; } 12%, 80% { transform: none; opacity: 1; } 100% { transform: translateY(-20px); opacity: 0; } }

/* parent area */
.parent h1 { color: #fff; font-size: 28px; margin-bottom: 12px; }
.ptabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; }
.ptabs button { border: 0; border-radius: 999px; padding: 10px 16px; background: rgba(255,255,255,.85); font-family: var(--head); font-size: 16px; color: var(--ink); white-space: nowrap; }
.ptabs button.on { background: var(--ink); color: #fff; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat { background: var(--soft); border-radius: 18px; padding: 14px; text-align: center; }
.stat b { display: block; font-family: var(--head); font-size: 30px; color: var(--purple); }
.stat span { font-size: 14px; color: var(--ink-2); }
.days { display: flex; gap: 8px; align-items: flex-end; height: 140px; padding-top: 10px; }
.days div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; font-size: 12px; color: var(--ink-2); }
.days i { width: 100%; max-width: 44px; background: linear-gradient(180deg, var(--sky), var(--purple)); border-radius: 10px 10px 4px 4px; min-height: 4px; }
.days em { font-style: normal; font-family: var(--head); color: var(--ink); font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 2px solid var(--soft); vertical-align: top; }
th { font-family: var(--head); color: var(--ink-2); font-weight: 600; }
.refl { white-space: pre-wrap; background: var(--soft); border-radius: 12px; padding: 10px 12px; margin: 6px 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 3px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-family: var(--head); font-size: 16px; color: var(--ink); }
.chip.on { border-color: var(--purple); background: var(--purple); color: #fff; }
.pin { display: flex; gap: 10px; justify-content: center; margin: 14px 0; }
.pin input { width: 200px; text-align: center; font-size: 30px; letter-spacing: 10px; font-family: var(--head); }
.form label { display: block; font-family: var(--head); margin: 12px 0 4px; }
.form .rw { display: grid; grid-template-columns: 1fr 90px 90px auto; gap: 8px; align-items: center; margin: 6px 0; }
.form .rw input { width: 100%; }

@media (max-width: 560px) {
  body { font-size: 17px; }
  .brand { font-size: 18px; }
  .brand-bot { width: 34px; height: 34px; }
  .pill { font-size: 16px; padding: 5px 10px; }
  .icon-btn { width: 34px; height: 34px; }
  .bolt { width: 76px; height: 76px; }
  .node .dot { width: 64px; height: 64px; font-size: 30px; }
  .today h2, .m-head h1 { font-size: 25px; }
  .form .rw { grid-template-columns: 1fr 70px 70px; }
  .form .rw button { grid-column: span 3; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* sign in */
body.signed-out .tabs, body.signed-out .top-right { display: none; }
.login { max-width: 460px; margin: 0 auto; }
.login input { width: 100%; font-size: 20px; padding: 12px 14px; }
.pw { display: flex; gap: 8px; }
.pw input { flex: 1; }

/* install card */
.install { background: linear-gradient(135deg, #e7fff6, #d7f3ff); border: 3px dashed var(--mint); }
.install h2 { font-size: 22px; }
.install-steps { padding-left: 24px; }
.install-steps li { margin: 8px 0; }
.share-ic { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: #fff; color: #0a84ff; box-shadow: 0 2px 0 var(--line); font-size: 16px; }
.icon-btn.dark { background: rgba(29,23,71,.08); color: var(--ink); flex: none; }
.top { padding-top: calc(10px + env(safe-area-inset-top)); }
