:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --ink: #1d2233;
  --muted: #6b7185;
  --line: #e3e6ef;
  --brand: #5b4fe0;
  --brand-2: #8a5cf6;
  --ok: #17924f;
  --ok-bg: #e7f7ee;
  --bad: #c9372c;
  --bad-bg: #fdecea;
  --warn: #b26b00;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(29, 34, 51, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 16px;
}
a { color: var(--brand); }
code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .9em;
  background: #eef0f7;
  border-radius: 5px;
  padding: .05em .35em;
  word-break: break-word;
}

/* Header & footer */
.site-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  padding: .8rem 1.2rem;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.site-header nav a { color: #fff; text-decoration: none; margin-left: 1rem; opacity: .9; font-weight: 500; }
.site-header nav a:hover { opacity: 1; text-decoration: underline; }
.site-footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem 3rem; }

main { max-width: 760px; margin: 0 auto; padding: 1.2rem 1rem; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.3rem; margin-bottom: 1rem;
}
.muted { color: var(--muted); font-size: .9rem; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .4rem; }
h2 { font-size: 1.25rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }

/* Home */
.hero { text-align: center; padding: 1.6rem 1.2rem; }
.hero p { color: var(--muted); margin: .3rem 0 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin: 1rem 0 0; }
.stat { background: #f1f0ff; border-radius: 10px; padding: .6rem .3rem; text-align: center; }
.stat b { display: block; font-size: 1.25rem; color: var(--brand); }
.stat span { font-size: .75rem; color: var(--muted); }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.mode {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 1rem; font: inherit; color: inherit; box-shadow: var(--shadow);
  transition: transform .08s, border-color .15s;
}
.mode:hover:not(:disabled) { border-color: var(--brand); transform: translateY(-2px); }
.mode:disabled { opacity: .5; cursor: not-allowed; }
.mode .icon { font-size: 1.6rem; }
.mode b { display: block; font-size: 1.05rem; margin: .2rem 0; }
.mode small { color: var(--muted); }
.mode.wide { grid-column: 1 / -1; }
.domain-pick { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .8rem; }
.domain-pick button { font: inherit; text-align: left; padding: .6rem .8rem; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.domain-pick button:hover { border-color: var(--brand); }

/* Play */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; font-weight: 600; }
.pill { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: .2rem .7rem; font-size: .9rem; }
.pill.timer.low { color: var(--bad); border-color: var(--bad); }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 1rem; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .3s; }
.qmeta { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.tag { font-size: .75rem; background: #f1f0ff; color: var(--brand); border-radius: 6px; padding: .1rem .5rem; font-weight: 600; }
.tag.Easy { background: var(--ok-bg); color: var(--ok); }
.tag.Hard { background: var(--bad-bg); color: var(--bad); }
.question { font-size: 1.1rem; font-weight: 600; margin: 0 0 1rem; }
.options { display: grid; gap: .6rem; }
.opt {
  display: flex; gap: .7rem; align-items: flex-start; width: 100%; text-align: left;
  font: inherit; color: inherit; background: #fff; cursor: pointer;
  border: 2px solid var(--line); border-radius: 12px; padding: .75rem .9rem;
  transition: border-color .12s, background .12s;
}
.opt:hover:not(:disabled) { border-color: var(--brand); }
.opt:disabled { cursor: default; }
.opt .letter {
  flex: 0 0 auto; width: 1.9rem; height: 1.9rem; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; background: #eef0f7;
}
.opt.chosen { border-color: var(--brand); background: #f4f2ff; }
.opt.chosen .letter { background: var(--brand); color: #fff; }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.right .letter { background: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .letter { background: var(--bad); color: #fff; }

.feedback { margin-top: 1rem; border-radius: 12px; padding: 1rem; }
.feedback.ok { background: var(--ok-bg); }
.feedback.no { background: var(--bad-bg); }
.feedback .verdict { font-weight: 800; font-size: 1.05rem; }
.feedback p { margin: .5rem 0 0; }
.feedback .src { font-size: .85rem; word-break: break-all; }
.points-pop { color: var(--ok); font-weight: 800; margin-left: .4rem; }

.actions { display: flex; gap: .6rem; justify-content: space-between; flex-wrap: wrap; margin-top: 1rem; }
.btn {
  font: inherit; font-weight: 700; cursor: pointer; border: 0; border-radius: 10px;
  padding: .7rem 1.2rem; background: linear-gradient(120deg, var(--brand), var(--brand-2)); color: #fff;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid var(--bad); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.3rem, 1fr)); gap: .35rem; margin-top: 1rem; }
.grid button { font: inherit; font-size: .8rem; padding: .35rem 0; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.grid button.done { background: #f1f0ff; border-color: var(--brand); }
.grid button.flag { background: #fff6e0; border-color: var(--warn); }
.grid button.cur { outline: 2px solid var(--ink); }

/* Results */
.score-ring { text-align: center; }
.score-ring .big { font-size: 3.2rem; font-weight: 900; line-height: 1; background: linear-gradient(120deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score-ring .badge { font-size: 2.4rem; }
.bars { display: grid; gap: .55rem; margin-top: .6rem; }
.bar-row { display: grid; grid-template-columns: 11rem 1fr 3.5rem; gap: .6rem; align-items: center; font-size: .9rem; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; }
.review-item { border-top: 1px solid var(--line); padding: .8rem 0; }
.review-item:first-child { border-top: 0; }
.review-item .q { font-weight: 600; }
.review-item .ans { font-size: .92rem; margin: .3rem 0; }

/* Info + text pages */
.info, .page { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem; margin-top: 1.5rem; }
.domains { width: 100%; border-collapse: collapse; font-size: .92rem; }
.domains th, .domains td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
.domains th { color: var(--muted); font-weight: 600; }

@media (max-width: 560px) {
  .modes, .domain-pick { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .bar-row { grid-template-columns: 7.5rem 1fr 3rem; font-size: .8rem; }
  .site-header nav a { margin-left: .7rem; font-size: .9rem; }
  h1 { font-size: 1.35rem; }
}

/* All questions page */
main.wide { max-width: 900px; }
.bank-tools {
  display: flex; gap: .6rem; flex-wrap: wrap; align-items: center;
  position: sticky; top: 0; z-index: 5; background: var(--card); padding: .7rem 0;
}
.bank-tools input {
  flex: 1 1 260px; font: inherit; padding: .65rem .9rem;
  border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
.bank-tools input:focus { outline: none; border-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: #fff; padding: .6rem .9rem; cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; font-weight: 700; }
.jump { display: flex; flex-wrap: wrap; gap: .4rem; margin: .3rem 0 1rem; }
.jump a { font-size: .8rem; background: #f1f0ff; color: var(--brand); border-radius: 6px; padding: .15rem .55rem; text-decoration: none; font-weight: 600; }
.dom { scroll-margin-top: 4.5rem; }
.dom h2 { border-bottom: 2px solid var(--line); padding-bottom: .35rem; margin-top: 1.8rem; }
.dom h2 small { font-size: .8rem; font-weight: 500; }
details.sub { border: 1px solid var(--line); border-radius: 12px; margin: .6rem 0; background: #fff; }
details.sub > summary {
  cursor: pointer; padding: .75rem 1rem; font-weight: 700; list-style: none;
  display: flex; justify-content: space-between; gap: .5rem;
}
details.sub > summary::-webkit-details-marker { display: none; }
details.sub > summary::after { content: "▸"; color: var(--muted); }
details.sub[open] > summary::after { content: "▾"; }
.qa { padding: 1rem; border-top: 1px solid var(--line); scroll-margin-top: 4.5rem; }
.qa .question { font-size: 1rem; margin: 0 0 .5rem; }
.qa .tag { text-decoration: none; }
.qa p { margin: .4rem 0; }
.qa-opts { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .35rem; }
.qa-opts li { padding: .45rem .7rem; border-radius: 8px; background: #f7f8fc; }
.qa-opts li.right { background: var(--ok-bg); box-shadow: inset 0 0 0 1px var(--ok); }
.ans-line { font-weight: 700; color: var(--ok); }
.qa.flash { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: #fff1c2; } to { background: transparent; } }

/* Results: score per sub-skill */
table.subs { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.subs td { padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
table.subs tr:nth-child(even) td { background: #f7f8fc; }
table.subs td:nth-child(2) { text-align: right; white-space: nowrap; }
table.subs td:last-child { text-align: right; font-weight: 700; width: 4rem; }
table.subs small { font-weight: 600; margin-left: .3rem; }
a.mode { text-decoration: none; }

/* Support boxes: coffee QR + YouTube / Instagram (added by support.js) */
.promo {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem; text-align: center; font-size: .9rem;
}
.promo img { width: 100%; height: auto; display: block; border-radius: 8px; }
.promo p { margin: .35rem 0 .6rem; }
.promo .upi { font-size: .8rem; margin: .4rem 0 0; word-break: break-all; }
.copy-upi { font: inherit; font-size: .8rem; font-weight: 600; margin-top: .5rem; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .3rem .7rem; cursor: pointer; }
.copy-upi:hover { border-color: var(--brand); color: var(--brand); }
.promo-btn {
  display: block; margin-top: .5rem; padding: .6rem .7rem; border-radius: 10px;
  font-weight: 700; text-decoration: none; color: #fff;
}
.promo-btn.yt { background: #e62117; }
.promo-btn.ig { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); }
.promo-btn.upi-btn { background: #1a73e8; }
.touch-only { display: none; }
@media (hover: none) and (pointer: coarse) { .touch-only { display: block; } }

/* Phones and tablets: once, at the bottom of the page */
.support-bottom {
  max-width: 760px; margin: 1.5rem auto 0; padding: 0 1rem;
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start;
}
.support-bottom .coffee img { max-width: 260px; margin: 0 auto; }
@media (max-width: 560px) { .support-bottom { grid-template-columns: 1fr; } }

/* Wide screens: a column centred in the empty space on each side of the content.
   (Kept after the phone rules so it wins on wide screens.) */
.rail { display: none; }
@media (min-width: 1240px) {
  body { --content: 760px; }
  body.wide-page { --content: min(900px, calc(100vw - 480px)); }
  main.wide { max-width: var(--content); }
  .rail {
    --space: calc((100vw - var(--content)) / 2);          /* empty space beside the content */
    --w: clamp(200px, calc(var(--space) - 48px), 300px);  /* column width */
    display: flex; flex-direction: column; gap: 1rem;
    position: fixed; top: 72px; bottom: 16px; width: var(--w); overflow-y: auto; z-index: 3;
  }
  .rail-left { left: calc((var(--space) - var(--w)) / 2); }
  .rail-right { right: calc((var(--space) - var(--w)) / 2); }
  .rail .promo { padding: 1.1rem; font-size: .95rem; }
  .rail .promo-btn { padding: .75rem; font-size: 1rem; }
  .support-bottom { display: none; }
}

/* Back button on text pages */
.back-link {
  display: inline-block; margin-bottom: .8rem; padding: .35rem .8rem; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem;
}
.back-link:hover { border-color: var(--brand); color: var(--brand); }

/* Short laptop screens: shrink the QR a little so both side boxes fit without scrolling */
@media (min-width: 1240px) {
  .rail .coffee img { max-height: calc(100vh - 440px); width: auto; max-width: 100%; margin: 0 auto; }
}
