/* Public website: play, daily, leaderboard, account. Tokens in tokens.css. */
.site-header { position: sticky; top: 0; z-index: 100; background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.site-header .inner { max-width: 1100px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.site-nav { display: flex; gap: .25rem; margin-left: auto; align-items: center; }
.site-nav a { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: 0 .8rem; border-radius: var(--radius-sm);
    color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: .95rem; }
.site-nav a:hover { color: var(--text); background: var(--surface-alt); }
.site-nav a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
    display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Bottom tab bar on phones (≤ 5 items, icon + label) */
.tabbar { display: none; }
@media (max-width: 720px) {
    .site-nav { display: none; }
    .tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
        background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
    .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px;
        color: var(--text-muted); text-decoration: none; font-size: .72rem; font-weight: 600; }
    .tabbar a[aria-current="page"] { color: var(--primary); }
    /* Reserve room for the fixed tab bar so the footer isn't hidden under it */
    body { padding-bottom: calc(57px + env(safe-area-inset-bottom)); }
    .site-header .signin-mobile, .site-header .admin-mobile { margin-left: auto; }
    .site-header .inner { padding-top: max(.6rem, env(safe-area-inset-top)); }
    .brand { font-size: 1.05rem; }
    .brand img { width: 30px; height: 30px; }
    .site-footer { padding-bottom: 1rem; }
    .site-footer a { display: inline-flex; align-items: center; min-height: 44px; }
    .msg { max-width: 92%; }
    .card-pad { padding: 1rem; }
    .q-card { padding: 1.1rem; }
    .q-actions .btn { flex: 1 1 auto; }
    /* 16px inputs stop iOS from zooming on focus */
    input, select, textarea { font-size: 16px; }
}
@media (min-width: 721px) { .signin-mobile, .admin-mobile { display: none; } }
.admin-mobile { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-sm); color: var(--text-muted); }
.admin-mobile:hover { background: var(--surface-alt); color: var(--text); }

main.page { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.narrow { max-width: 720px; margin-left: auto; margin-right: auto; }
h1 { font-size: clamp(1.6rem, 3vw + 1rem, 2.25rem); line-height: 1.2; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; margin: 2rem 0 .75rem; }
.lead { color: var(--text-muted); margin: 0 0 1.5rem; max-width: 62ch; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 1.25rem; }

/* Category grid */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.cat-card { position: relative; display: flex; flex-direction: column; gap: .6rem; padding: 1.1rem 1.1rem 1rem; text-decoration: none; color: var(--text);
    border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
    transition: transform .18s var(--ease), border-color .18s var(--ease); overflow: hidden; }
.cat-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--cat); }
.cat-card:hover { transform: translateY(-2px); border-color: var(--cat); }
.cat-card .cat-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
    background: color-mix(in srgb, var(--cat) 15%, transparent); color: var(--cat); }
.cat-card h3 { margin: 0; font-size: 1.08rem; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-alt); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--cat, var(--primary)); border-radius: inherit; transition: width .4s var(--ease); }
.cat-meta { display: flex; justify-content: space-between; font-size: .85rem; color: var(--text-muted); }

/* Question card */
.q-wrap { max-width: 720px; margin: 0 auto; }
.q-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.q-top .crumb { display: inline-flex; align-items: center; gap: .4rem; color: var(--text-muted); text-decoration: none; font-weight: 600; min-height: 44px; }
.q-card { padding: 1.5rem; border-top: 5px solid var(--cat, var(--primary)); }
.q-diff { text-transform: capitalize; }
.q-text { font-size: clamp(1.15rem, 1vw + 1rem, 1.4rem); line-height: 1.45; font-weight: 700; margin: .75rem 0 1.25rem; }
.options { display: grid; gap: .65rem; margin: 0; padding: 0; border: 0; }
.option { width: 100%; display: flex; align-items: center; gap: .85rem; text-align: left; font: inherit; font-weight: 600;
    min-height: 56px; padding: .75rem 1rem; border-radius: 12px; cursor: pointer;
    background: var(--surface); color: var(--text); border: 2px solid var(--border);
    transition: border-color .15s var(--ease), background-color .15s var(--ease), transform .1s var(--ease); }
.option:hover:not([disabled]) { border-color: var(--primary); background: var(--primary-soft); }
.option:active:not([disabled]) { transform: scale(.99); }
.option .key { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
    background: var(--surface-alt); color: var(--text-muted); font-size: .85rem; text-transform: uppercase; }
.option .state { margin-left: auto; display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; }
.option.is-wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); cursor: not-allowed; }
.option.is-right { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.option[disabled] { cursor: default; }
.option.is-dim { opacity: .55; }
.htmx-request .option { pointer-events: none; }
.feedback { margin-top: 1rem; }
.hint-box { margin-top: 1rem; }
.hint-box summary { cursor: pointer; font-weight: 600; color: var(--primary); min-height: 44px; display: flex; align-items: center; gap: .4rem; }
.explain { margin-top: 1.25rem; padding: 1rem 1.1rem; border-radius: 12px; background: var(--surface-alt); }
.explain h3 { margin: 0 0 .4rem; font-size: 1rem; }
.refs { margin: .6rem 0 0; padding-left: 1.1rem; font-size: .9rem; }
.reward { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 1rem 0 0; }
.reward .pill { font-size: .9rem; padding: .3rem .8rem; }
.q-actions { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.25rem; }
.fade-in { animation: fadeIn .22s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Daily */
.daily-steps { display: flex; gap: .5rem; margin: 0 0 1.25rem; padding: 0; list-style: none; }
.daily-steps li { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-alt); }
.daily-steps li.ok { background: var(--success); }
.daily-steps li.bad { background: var(--danger); }
.daily-steps li.now { background: var(--accent); }
.daily-done { text-align: center; padding: 2rem 1.25rem; }
.daily-done .score { font-size: 3rem; font-weight: 800; line-height: 1; margin: .5rem 0; }

/* Leaderboard */
.tabs { display: inline-flex; max-width: 100%; overflow-x: auto; padding: 4px; gap: 4px; background: var(--surface-alt); border-radius: 12px; margin-bottom: 1rem; }
.tabs a { min-height: 40px; flex: none; white-space: nowrap; display: inline-flex; align-items: center; padding: 0 1rem; border-radius: 9px; text-decoration: none;
    color: var(--text-muted); font-weight: 600; }
.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.lb { width: 100%; border-collapse: collapse; }
.lb th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: .6rem .9rem; }
.lb td { padding: .7rem .9rem; border-top: 1px solid var(--border); }
.lb tr.me td { background: var(--primary-soft); }
.lb .rank { width: 64px; font-weight: 800; }
.medal { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: #1F1300; font-size: .85rem; }
.medal-1 { background: var(--gold); } .medal-2 { background: var(--silver); } .medal-3 { background: var(--bronze); color: #fff; }
.lb .who { display: flex; align-items: center; gap: .65rem; }
.lb .who a { color: var(--text); text-decoration: none; font-weight: 600; }
.lb .who a:hover { text-decoration: underline; }
.lb .xp { text-align: right; font-weight: 700; }
.me-card { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 1rem; padding: 1rem 1.25rem; }
@media (max-width: 560px) {
    .lb .col-level { display: none; } .lb td, .lb th { padding: .6rem .5rem; } .lb .rank { width: 48px; }
    .lb .who { gap: .5rem; flex-wrap: wrap; } .lb .who a { overflow-wrap: anywhere; }
    .tabs { display: flex; } .tabs a { flex: 1; justify-content: center; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .daily-done .score { font-size: 2.5rem; }
}

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.stat { padding: 1rem; }
.stat .v { font-size: 1.6rem; font-weight: 800; }
.stat .k { font-size: .85rem; color: var(--text-muted); }

/* Messages */
.thread { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1rem; }
.msg { max-width: 85%; padding: .75rem 1rem; border-radius: 14px; white-space: pre-wrap; }
.msg-user { align-self: flex-end; background: var(--primary-soft); }
.msg-admin { align-self: flex-start; background: var(--surface-alt); }
.msg .meta { display: block; font-size: .75rem; color: var(--text-muted); margin-top: .35rem; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .8rem 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: 0; }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty .icon { width: 40px; height: 40px; color: var(--text-muted); margin-bottom: .5rem; }
.site-footer { border-top: 1px solid var(--border); padding: 1.5rem 1rem; text-align: center; color: var(--text-muted); font-size: .9rem; }
.site-footer a { color: var(--text-muted); margin: 0 .5rem; }
.google-btn { width: 100%; max-width: 340px; background: #fff; color: #1F1F1F; border: 1px solid #DADCE0; }
.google-btn:hover { background: #F7F8F8; }
.google-btn svg { width: 20px; height: 20px; }
