/* ---------- Font: KarmaSans (put KarmaSans.ttf in the .assets folder next to this file) ---------- */
@font-face {
    font-family: "KarmaSans";
    src: url("/fonts/KumbhSans.ttf") format("truetype");
    font-style: normal;
    font-display: swap;
}

/* ---------- Palette (60 / 30 / 10) ----------
   60%  near-black base       --bg
   30%  dark neutral surfaces --surface, --surface-2, --line
   10%  blue accent           --blue, --blue-strong
   Contrast on --bg: --text 18:1, --mute 8.7:1, --blue 5.3:1. White on --blue-strong 6.7:1. */
:root {
    color-scheme: dark;
    --bg: #0a0a0a;
    --surface: #131417;
    --surface-2: #1b1d22;
    --line: #2a2e37;
    --line-strong: #3b4150;
    --text: #f4f6fb;
    --mute: #a3acbd;
    --blue: #3b82f6;
    --blue-strong: #1d4ed8;
    --blue-hover: #2563eb;
    --blue-soft: rgba(59, 130, 246, .16);
    --ok: #15803d;
    --bad: #b91c1c;
    --ok-text: #4ade80;
    --bad-text: #f87171
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none
}

html,
body {
    height: 100%;
    margin: 0
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "KarmaSans", "Noto Sans Devanagari", "Nirmala UI", "Mukta", sans-serif;
    font-synthesis: none;
    font-weight: normal;
    line-height: 1.4;
    display: flex;
    justify-content: center
}

main {
    width: 100%;
    max-width: 1040px;
    padding: 32px 28px;
    display: flex;
    flex-direction: column;
    min-height: 100%
}

.screen {
    display: none;
    flex: 1;
    flex-direction: column;
    justify-content: center
}

.screen.on {
    display: flex;
    animation: in .3s
}

@keyframes in {
    from {
        opacity: 0;
        transform: translateY(8px)
    }

    to {
        opacity: 1;
        transform: none
    }
}

h1,
h2,
.q,
button,
.opt {
    font-family: inherit;
    font-weight: normal
}

h1 {
    font-size: 52px;
    line-height: 1.15;
    margin: 0 0 12px;
    text-align: center
}

.sub {
    color: var(--mute);
    text-align: center;
    font-size: 22px;
    margin: 0 0 36px
}

.center {
    text-align: center
}

.row {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 24px
}

/* ---------- Buttons ---------- */
button {
    font: inherit;
    color: inherit;
    cursor: pointer;
    touch-action: manipulation
}

button:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 3px
}

.btn {
    background: var(--blue-strong);
    color: #fff;
    border: 2px solid var(--blue-strong);
    border-radius: 12px;
    padding: 16px 44px;
    font-size: 22px;
    transition: background .15s, border-color .15s, transform .15s
}

.btn:hover:not(:disabled) {
    background: var(--blue-hover);
    border-color: var(--blue)
}

.btn:active:not(:disabled) {
    transform: scale(.97)
}

.btn:disabled {
    opacity: .35;
    cursor: not-allowed
}

.btn.ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line-strong);
    font-size: 18px;
    padding: 13px 26px
}

.btn.ghost:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: var(--blue)
}

/* ---------- Topic list: slim rows ---------- */
.topics {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 520px;
    margin: 0 auto
}

.topic {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    text-align: left;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 20px;
    transition: border-color .15s, background .15s
}

.topic .ic {
    width: 24px;
    height: 24px;
    flex: none;
    display: grid;
    place-items: center;
    font-size: 22px;
    color: var(--blue)
}

.topic .ic svg {
    width: 22px;
    height: 22px
}

.topic .name {
    flex: 1
}

.topic .soon {
    font-size: 14px;
    color: var(--mute)
}

.topic:hover:not(:disabled) {
    border-color: var(--line-strong);
    background: var(--surface-2)
}

.topic.sel {
    border-color: var(--blue);
    background: var(--blue-soft)
}

.topic.sel::after {
    content: "";
    width: 9px;
    height: 16px;
    border: solid var(--blue);
    border-width: 0 3px 3px 0;
    transform: rotate(45deg) translate(-2px, -2px);
    flex: none
}

.topic:disabled {
    opacity: .45;
    cursor: not-allowed
}

#topic-actions {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 28px
}

#topic-actions.on {
    display: flex;
    animation: in .25s
}

/* ---------- Quiz ---------- */
.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px
}

.meta {
    color: var(--mute);
    font-size: 19px
}

.meta b {
    color: var(--blue);
    font-size: 22px;
    font-weight: normal
}

.pips {
    display: flex;
    gap: 8px
}

.pip {
    width: 44px;
    height: 8px;
    border-radius: 4px;
    background: var(--line)
}

.pip.done {
    background: var(--ok)
}

.pip.cur {
    background: var(--blue)
}

.timer {
    position: relative;
    width: 84px;
    height: 84px;
    flex: none
}

.timer svg {
    transform: rotate(-90deg)
}

.timer circle {
    fill: none;
    stroke-width: 7
}

.timer .bg {
    stroke: var(--line)
}

.timer .fg {
    stroke: var(--blue);
    stroke-linecap: round;
    stroke-dasharray: 226.2;
    transition: stroke-dashoffset .25s linear, stroke .2s
}

.timer.low .fg {
    stroke: var(--bad-text)
}

.timer.life .fg {
    stroke: var(--text)
}

.timer span {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 28px
}

.play {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 24px;
    align-items: start
}

.side {
    display: flex;
    flex-direction: column;
    gap: 12px
}

.aid {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 18px;
    transition: border-color .15s, background .15s
}

.aid svg {
    width: 22px;
    height: 22px;
    flex: none;
    color: var(--blue)
}

.aid:hover:not(:disabled) {
    border-color: var(--blue);
    background: var(--surface-2)
}

.aid:disabled {
    opacity: .4;
    cursor: not-allowed
}

.life-bar {
    display: none;
    background: var(--blue-soft);
    border: 2px solid var(--blue);
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 16px;
    font-size: 18px
}

.life-bar.on {
    display: block
}

.q {
    font-size: 32px;
    line-height: 1.35;
    text-align: center;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: 14px;
    padding: 30px 26px;
    margin-bottom: 20px
}

.opts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px
}

.opt {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: 12px;
    padding: 18px 20px;
    font-size: 22px;
    min-height: 80px;
    transition: border-color .15s, background .15s
}

.opt:hover {
    border-color: var(--line-strong)
}

.opt i {
    font-style: normal;
    color: var(--blue)
}

.opt.sel {
    border-color: var(--blue);
    background: var(--blue-soft)
}

.opt.ok {
    background: var(--ok);
    border-color: var(--ok);
    color: #fff
}

.opt.bad {
    background: var(--bad);
    border-color: var(--bad);
    color: #fff
}

.opt.ok i,
.opt.bad i {
    color: #fff
}

.opts.lock .opt {
    pointer-events: none
}

.foot {
    min-height: 130px;
    text-align: center;
    margin-top: 24px
}

.msg {
    font-size: 26px;
    margin-bottom: 16px
}

.msg.ok {
    color: var(--ok-text)
}

.msg.bad {
    color: var(--bad-text)
}

.big {
    font-size: 72px;
    text-align: center;
    margin-bottom: 8px
}

.reveal {
    display: none;
    max-width: 640px;
    margin: 0 auto;
    text-align: left;
    background: var(--surface);
    border: 2px solid var(--line);
    border-radius: 12px;
    padding: 20px 24px;
    font-size: 20px
}

.reveal.on {
    display: block
}

.reveal p {
    margin: 0 0 10px
}

.reveal .ans {
    color: var(--blue);
    margin: 0
}

/* ---------- Confirm dialog ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .78);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10
}

.modal.on {
    display: flex
}

.modal-box {
    width: 100%;
    max-width: 460px;
    background: var(--surface);
    border: 2px solid var(--line-strong);
    border-radius: 14px;
    padding: 28px;
    text-align: center;
    animation: in .2s
}

.modal-box h2 {
    font-size: 28px;
    margin: 0 0 10px
}

.modal-box p {
    color: var(--mute);
    font-size: 18px;
    margin: 0 0 6px
}

.modal-box .row {
    margin-top: 22px
}

.modal-box .btn {
    padding: 13px 26px;
    font-size: 19px
}

/* ---------- Small screens ---------- */
@media(max-width:820px) {
    .play {
        grid-template-columns: 1fr
    }

    .side {
        flex-direction: row;
        order: -1
    }

    .aid {
        justify-content: center;
        padding: 12px
    }
}

@media(max-width:700px) {
    .opts {
        grid-template-columns: 1fr
    }

    .q {
        font-size: 24px
    }

    h1 {
        font-size: 36px
    }

    .sub {
        font-size: 18px
    }

    .pip {
        width: 26px
    }
}

@media(prefers-reduced-motion:reduce) {
    * {
        animation: none !important;
        transition: none !important
    }
}

/* ---------- v2 tweaks ---------- */
#s-topic h1 { margin-bottom: 44px }

.topic { transition: border-color .15s, background .15s, opacity .15s }
.topic .ic.lg svg { width: 23px; height: 23px }
.topics.has-sel .topic:not(.sel):not(:disabled) { border-color: transparent; opacity: .5 }
.topics.has-sel .topic:not(.sel):not(:disabled):hover { opacity: .85 }

#topic-actions { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 14px }

/* Dim the supporting content so attention stays on the question */
.meta, .meta b { color: #7d8696 }
.pips { opacity: .6 }
.aid { background: transparent; border-color: transparent; color: var(--mute); opacity: .7 }
.aid svg { color: inherit }
.aid:hover:not(:disabled) { opacity: 1; color: var(--text); background: var(--surface-2); border-color: var(--line-strong) }

/* End-screen icons */
.big { line-height: 0; margin-bottom: 22px }
.big svg { width: 104px; height: 104px }
.big.win svg { color: var(--blue) }
.big.lose svg { color: var(--bad-text) }
.big.quit svg { color: var(--text) }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20 }

@media(max-width:700px) { .big svg { width: 80px; height: 80px } }

/* ---------- Language screen ---------- */
.langbtn { justify-content: center; font-size: 26px; padding: 18px 20px }
.langbtn .name { flex: none }
#s-topic .row .btn.ghost { margin-top: 0 }