:root {
  --night: #1b1f3b; --night-soft: #2c3160; --lantern: #f5a524; --lantern-deep: #c97f06;
  --paper: #f6f7fb; --surface: #ffffff; --ink: #1f2236; --muted: #5c6079; --line: #dfe2ec;
  --focus: #3b6ef5; --radius: 14px;
  --font: "Hind Siliguri", "Noto Sans Bengali", system-ui, sans-serif;
  --display: "Tiro Bangla", "Noto Serif Bengali", "Hind Siliguri", serif;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12142a; --surface: #1a1d38; --ink: #eceefa; --muted: #a3a7c4; --line: #2d3156; --night-soft: #3a4080;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--paper); color: var(--ink); font-size: 17px; line-height: 1.6; padding-bottom: 96px; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; background: var(--night); color: #fff; position: sticky; top: 0; z-index: 50; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-icon { width: 36px; height: 36px; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--display); font-size: 22px; }
.brand-tag { font-size: 12px; font-weight: 500; color: #b9bde6; }
.navlink { color: #fff; text-decoration: none; font-size: 15px; padding: 5px 12px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; }
.navlink:hover { background: rgba(255,255,255,.1); }

.wrap { max-width: 860px; margin: 0 auto; padding: 0 18px; }
.hero { padding: 30px 0 10px; }
.hero h1 { font-family: var(--display); font-weight: 400; font-size: clamp(30px, 5vw, 46px); line-height: 1.25; margin: 0 0 10px; }
.lead { color: var(--muted); margin: 0; max-width: 640px; }
.challenge { display: inline-block; background: var(--lantern); color: #3b2500; font-weight: 600; padding: 6px 14px; border-radius: 999px; margin: 0 0 14px; }
.loading { color: var(--muted); }

.group { margin-top: 30px; }
.group h2 { display: flex; align-items: baseline; gap: 10px; font-size: 20px; margin: 0 0 12px; }
.group h2 .gi { font-size: 22px; }
.group h2 .gc { margin-left: auto; font-size: 14px; font-weight: 500; color: var(--muted); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.item { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1.5px solid var(--line); cursor: pointer; user-select: none; transition: border-color .12s, background .12s; }
.item input { position: absolute; opacity: 0; pointer-events: none; }
.item .box { flex: none; width: 26px; height: 26px; margin-top: 1px; border-radius: 7px; border: 2px solid var(--muted);
  display: flex; align-items: center; justify-content: center; color: transparent; font-weight: 700; transition: all .12s; }
.item .txt { flex: 1; }
.item .em { flex: none; font-size: 22px; line-height: 1.3; width: 28px; text-align: center; }
.item .pct { display: none; font-size: 13px; color: var(--muted); margin-top: 2px; }
.item .pct .bar { display: block; height: 4px; border-radius: 2px; background: var(--line); margin-top: 4px; overflow: hidden; }
.item .pct .bar i { display: block; height: 100%; background: var(--lantern); }
body.show-pct .item .pct { display: block; }
.item:hover { border-color: var(--night-soft); }
.item:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.item.on { border-color: var(--lantern); background: rgba(245,165,36,.08); }
.item.on .box { background: var(--lantern); border-color: var(--lantern); color: #1b1f3b; }

.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; display: flex; align-items: center; gap: 14px;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--night); color: #fff; }
.bb-progress { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 14px; max-width: 520px; }
.bb-track { height: 6px; background: rgba(255,255,255,.18); border-radius: 3px; overflow: hidden; }
.bb-fill { display: block; height: 100%; width: 0; background: var(--lantern); transition: width .2s; }
.bb-btn { background: var(--lantern) !important; color: #3b2500 !important; }

.btn-primary, .btn-secondary { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; font-weight: 600; text-decoration: none; line-height: 1.3; }
.btn-primary { background: var(--ink); color: var(--surface); border: 0; padding: 10px 20px; font-size: 16px; }
.btn-secondary { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); padding: 9px 18px; font-size: 16px; }
.btn-link, .linkbtn { background: none; border: 0; color: var(--focus); text-decoration: underline; padding: 0; font-size: 15px; }

.result { scroll-margin-top: 76px; margin: 40px 0 20px; padding: 28px 24px; border-radius: 22px; background: var(--night); color: #fff; text-align: center; }
.r-kicker { margin: 0; color: #b9bde6; }
.r-score { margin: 0; }
.r-score strong { font-family: var(--display); font-weight: 400; font-size: clamp(80px, 18vw, 140px); line-height: 1.05; color: var(--lantern); }
.r-title { font-size: 26px; font-weight: 700; margin: 0 0 4px; }
.r-rank { color: #d9dcf7; margin: 0 0 18px; }
.r-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; text-align: left; max-width: 560px; margin: 0 auto 16px; font-size: 15px; }
.rg { display: flex; flex-direction: column; gap: 3px; }
.rg span { display: flex; justify-content: space-between; }
.rg .t { height: 6px; background: rgba(255,255,255,.15); border-radius: 3px; overflow: hidden; }
.rg .t i { display: block; height: 100%; background: var(--lantern); }
.r-rare { background: rgba(255,255,255,.08); border-radius: 12px; padding: 10px 14px; margin: 0 auto 18px; max-width: 560px; }
.r-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: center; }
.result .btn-primary { background: var(--lantern); color: #3b2500; }
.result .btn-secondary { color: #fff; border-color: #fff; }
.result .btn-link { color: #b9bde6; }
.r-hint { font-size: 14px; color: #b9bde6; margin: 16px 0 0; }

.foot { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); padding: 18px; max-width: 860px; margin: 20px auto 0; }
.foot a { color: inherit; }
.foot-dev { font-size: 13px; color: var(--ink); }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 1000;
  background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: 12px; max-width: min(92vw, 460px); font-size: 15px; text-align: center; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* dialogs (developer popup + share card), same as acheki */
.dlg { border: 0; border-radius: 20px; padding: 26px 24px 22px; width: min(92vw, 420px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(10,12,40,.35); max-height: 90vh; overflow-y: auto; }
.dlg::backdrop { background: rgba(14,16,40,.55); }
.dlg-close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; }
.dlg h2 { font-family: var(--display); font-weight: 400; font-size: 26px; margin: 0 0 4px; }
.dev { text-align: center; }
.dev-photo { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; margin: 0 auto 12px; display: block; }
.dev-initials { display: flex; align-items: center; justify-content: center; background: var(--night); color: var(--lantern); font-size: 34px; font-weight: 700; box-shadow: 0 0 0 4px rgba(245,165,36,.25); }
.dev-en { margin: 0; color: var(--muted); font-size: 15px; }
.dev-role { margin: 2px 0 12px; font-weight: 500; }
.dev-about { margin: 0 0 12px; font-size: 15px; color: var(--muted); text-align: left; }
.dev-email { margin: 0 0 12px; font-size: 15px; }
.dev-email a { color: var(--ink); }
.dev-social { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 16px; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; font-size: 14px; color: var(--ink); text-decoration: none; }
.dev-donate { border-top: 1px solid var(--line); padding-top: 14px; text-align: left; }
.dev-donate h3 { font-size: 17px; margin: 0 0 4px; }
.dev-donate p { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.bkash { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 10px; background: var(--paper); border-radius: 12px; padding: 10px 14px; }
.bkash-label { font-size: 13px; color: var(--muted); }
.bkash-num { font-size: 22px; letter-spacing: .5px; }
.bkash .btn-small { grid-column: 2; grid-row: 1 / span 2; }
.btn-small { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.btn-link { font-size: 14px; }
.card-preview img { width: 100%; height: auto; display: block; border-radius: 12px; background: var(--night); aspect-ratio: 1; margin: 10px 0 14px; }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* own memories */
.custom { margin-top: 34px; padding: 18px; border: 1.5px dashed var(--night-soft); border-radius: var(--radius); background: var(--surface); }
.custom h2 { display: flex; gap: 10px; align-items: baseline; font-size: 20px; margin: 0 0 6px; }
.custom-lead { margin: 0 0 12px; font-size: 15px; color: var(--muted); }
.custom-form { display: flex; gap: 8px; }
.custom-form input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 9px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); }
.custom-form input:focus { border-color: var(--lantern); outline: none; }
.custom-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.custom-list li { display: inline-flex; align-items: center; gap: 8px; background: rgba(245,165,36,.12); border: 1.5px solid var(--lantern); border-radius: 999px; padding: 5px 6px 5px 14px; font-size: 15px; }
.custom-list button { border: 0; background: transparent; color: var(--muted); font-size: 18px; line-height: 1; width: 26px; height: 26px; border-radius: 50%; }
.custom-list button:hover { background: rgba(0,0,0,.08); color: var(--ink); }
.r-custom { background: rgba(255,255,255,.08); border-radius: 12px; padding: 10px 14px; margin: 0 auto 18px; max-width: 560px; text-align: left; }
.r-custom b { display: block; color: #b9bde6; font-weight: 500; font-size: 14px; margin-bottom: 4px; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .brand-tag { display: none; }
  .items { grid-template-columns: 1fr; }
  .r-groups { grid-template-columns: 1fr; }
  .result { padding: 24px 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
