:root {
    --night:  #0F2326;
    --felt:   #15333A;
    --felt-2: #1B3F47;
    --felt-3: #224A53;
    --line:   rgba(241, 235, 221, 0.10);
    --line-2: rgba(241, 235, 221, 0.20);
    --ivory:  #F1EBDD;
    --mist:   #9DB3B0;
    --brass:  #D4AE6A;
    --brass-2:#E6C48A;
    --ink:    #17323A;
    --red:    #E08A80;
    --green:  #8FD3A8;
    --bronze: #C98B5A;
    --silver: #B9C4C6;
    --gold:   #D4AE6A;
    --platinum: #9FD8E6;
    --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
    --body:    'Instrument Sans', -apple-system, 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: clip; }
body {
    font: 400 16px/1.55 var(--body);
    color: var(--ivory);
    background-color: var(--night);
    background-image: radial-gradient(ellipse 70% 45% at 75% 0%, rgba(212,174,106,.09), transparent 70%);
    background-repeat: no-repeat;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--mist); }
.small { font-size: .88rem; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 1.5rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding-top: 1.5rem; padding-bottom: 1rem; }
.brand { display: flex; align-items: center; gap: .65rem; font: 700 1.05rem var(--display); text-decoration: none; }
.brand-chip { width: 30px; height: 30px; border-radius: 8px; background: var(--brass); color: var(--ink); display: grid; place-items: center; font-weight: 800; }
.back { color: var(--mist); text-decoration: none; font-weight: 500; }
.back:hover { color: var(--ivory); }
.back .short { display: none; }

main { padding-top: 1.5rem; padding-bottom: 5rem; }
.loading { color: var(--mist); padding: 3rem 0; }

/* ── Buttons and fields ───────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    font-weight: 600; font-size: .98rem; line-height: 1;
    padding: .85rem 1.25rem; border-radius: 999px;
    border: 1px solid var(--line-2); background: transparent;
    cursor: pointer; text-decoration: none;
    transition: background-color .15s ease, border-color .15s ease;
}
.btn:hover { border-color: var(--ivory); }
.btn.primary { background: var(--brass); color: var(--ink); border-color: var(--brass); }
.btn.primary:hover { background: var(--brass-2); }
.btn.danger { color: var(--red); border-color: rgba(224,138,128,.45); }
.btn.small { padding: .5rem .85rem; font-size: .88rem; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .55; cursor: progress; }
.link { background: none; border: 0; color: var(--brass); cursor: pointer; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.link:hover { color: var(--brass-2); }

.field { display: grid; gap: .4rem; font-weight: 600; font-size: .92rem; }
.field .hint { font-weight: 400; font-size: .84rem; color: var(--mist); }
input[type=text], input[type=email], input[type=password] {
    width: 100%; font-size: 1rem; font-weight: 400;
    background: var(--night); border: 1px solid var(--line-2); border-radius: 12px;
    padding: .8rem .95rem; outline: none; transition: border-color .15s ease;
}
input:focus { border-color: var(--brass); }
input.bad { border-color: var(--red); }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; font-size: .94rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--brass); flex: none; }
.err { color: var(--red); font-size: .9rem; font-weight: 500; }
.note { color: var(--green); font-size: .92rem; }
form { display: grid; gap: 1rem; }

/* ── Cards ─────────────────────────────────────────────── */
.card { background: var(--felt); border: 1px solid var(--line); border-radius: 20px; padding: 1.6rem; }
.card h2 { font: 700 1.35rem/1.2 var(--display); letter-spacing: -.02em; }
.card h3 { font: 700 1.05rem/1.2 var(--display); }
.card + .card { margin-top: 1rem; }

/* ── Signed-out landing ───────────────────────────────── */
.guest { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 2rem; align-items: start; }
.guest h1 { font: 800 clamp(2.2rem, 5vw, 3.4rem)/1 var(--display); letter-spacing: -.035em; text-wrap: balance; }
.guest .lede { color: var(--mist); font-size: 1.1rem; margin-top: 1rem; max-width: 34rem; }
.guest-progress { margin-top: 1.6rem; display: flex; gap: .8rem; flex-wrap: wrap; }
.pill { background: var(--felt); border: 1px solid var(--line); border-radius: 14px; padding: .8rem 1rem; min-width: 120px; }
.pill b { display: block; font: 700 1.5rem/1.1 var(--display); }
.pill span { color: var(--mist); font-size: .88rem; }
.perks { margin-top: 1.6rem; display: grid; gap: .55rem; color: var(--mist); }
.perks li { list-style: none; display: flex; gap: .6rem; }
.perks li::before { content: '✦'; color: var(--brass); }

.tabs { display: flex; gap: .3rem; background: var(--night); border-radius: 999px; padding: 4px; margin-bottom: 1.3rem; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: .6rem; font-weight: 600; color: var(--mist); cursor: pointer; }
.tabs button[aria-selected=true] { background: var(--felt-3); color: var(--ivory); }
.or { display: flex; align-items: center; gap: .8rem; color: var(--mist); font-size: .85rem; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.center { text-align: center; }

/* ── Profile header ───────────────────────────────────── */
.profile { display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; }
.avatar {
    width: 84px; height: 84px; border-radius: 50%; flex: none;
    display: grid; place-items: center; font-size: 2.4rem; color: var(--ink);
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.45), transparent 60%), var(--av, var(--brass));
    box-shadow: inset 0 0 0 4px rgba(0,0,0,.12), 0 10px 30px -10px rgba(0,0,0,.6);
}
.who { flex: 1; min-width: 220px; }
.who h1 { font: 800 2.1rem/1.05 var(--display); letter-spacing: -.03em; }
.who .meta { color: var(--mist); margin-top: .3rem; }
.levelbar { margin-top: .8rem; max-width: 420px; }
.levelbar .row { display: flex; justify-content: space-between; font-size: .86rem; color: var(--mist); margin-bottom: .35rem; }
.levelbar .row b { color: var(--ivory); font-weight: 600; }
.bar { height: 8px; border-radius: 999px; background: var(--night); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--brass); }
.stats3 { display: flex; gap: .7rem; flex-wrap: wrap; }

.banner { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: .9rem 1.1rem; border-radius: 14px; background: rgba(212,174,106,.1); border: 1px solid rgba(212,174,106,.35); margin-top: 1.2rem; }

.sections { display: flex; gap: .3rem; margin: 2rem 0 1.2rem; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.sections a { padding: .7rem 1rem; text-decoration: none; color: var(--mist); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.sections a[aria-current=page] { color: var(--ivory); border-color: var(--brass); }

/* ── Achievements ─────────────────────────────────────── */
.filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.chip { border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: .4rem .85rem; font-size: .9rem; color: var(--mist); cursor: pointer; }
.chip[aria-pressed=true] { background: var(--felt-3); color: var(--ivory); border-color: transparent; }
.group-head { display: flex; align-items: baseline; gap: .8rem; margin: 1.8rem 0 .8rem; }
.group-head h2 { font: 700 1.3rem var(--display); letter-spacing: -.02em; }
.group-head span { color: var(--mist); font-size: .9rem; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; }
.badge { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; align-items: start; padding: 1rem; border-radius: 16px; background: rgba(21,51,58,.6); border: 1px solid var(--line); }
.badge.earned { background: var(--felt); border-color: color-mix(in srgb, var(--t) 40%, transparent); }
.medal {
    grid-row: span 3; width: 54px; height: 54px; border-radius: 50%;
    display: grid; place-items: center; font-size: 1.6rem; color: var(--ink);
    background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.5), transparent 60%), var(--t);
    box-shadow: inset 0 0 0 3px rgba(0,0,0,.14);
}
.badge:not(.earned) .medal { background: var(--felt-2); color: var(--mist); box-shadow: inset 0 0 0 2px var(--line-2); }
.badge b { font-weight: 700; line-height: 1.3; }
.badge p { color: var(--mist); font-size: .9rem; line-height: 1.45; }
.badge .foot { display: flex; justify-content: space-between; gap: .5rem; font-size: .8rem; color: var(--mist); margin-top: .35rem; }
.badge .foot .pts { color: var(--brass); font-weight: 600; }
.badge .bar { height: 6px; margin-top: .5rem; }
.badge .bar i { background: var(--t); }

.sect { border: 1px solid var(--line); border-radius: 16px; margin-bottom: .6rem; background: rgba(21,51,58,.35); }
.sect summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 1.1rem; }
.sect summary::-webkit-details-marker { display: none; }
.sect summary::after { content: '+'; color: var(--mist); font-size: 1.3rem; line-height: 1; margin-left: .2rem; }
.sect[open] summary::after { content: '−'; }
.sect summary span { color: var(--mist); font-size: .9rem; margin-left: auto; }
.sect .badges { padding: 0 1rem 1rem; }
.meta a { color: var(--brass); }
.meta .sep { display: inline-block; width: .4rem; }

/* ── Games list ───────────────────────────────────────── */
.games { display: grid; gap: .5rem; }
.game { display: grid; grid-template-columns: 46px minmax(0,1fr) auto; gap: 1rem; align-items: center; padding: .8rem 1rem; border-radius: 14px; background: var(--felt); border: 1px solid var(--line); text-decoration: none; }
.game:hover { border-color: var(--line-2); }
.game .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--ivory); color: var(--ink); font-size: 1.4rem; }
.game .nm { font-weight: 700; }
.game .sub { color: var(--mist); font-size: .88rem; }
.game .n { text-align: right; font-size: .9rem; color: var(--mist); }
.game .n b { display: block; color: var(--ivory); font: 700 1.2rem var(--display); }

/* ── Settings ─────────────────────────────────────────── */
.settings { display: grid; gap: 1rem; }
.settings .card { display: grid; gap: 1rem; }
.settings .card > p { color: var(--mist); margin-top: -.6rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.icons, .colors { display: flex; gap: .4rem; flex-wrap: wrap; }
.icons button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--night); font-size: 1.3rem; cursor: pointer; }
.icons button[aria-pressed=true] { background: var(--ivory); color: var(--ink); border-color: var(--ivory); }
.colors button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.colors button[aria-pressed=true] { border-color: var(--ivory); }
.row-end { display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap; }
.sessions { display: grid; gap: .4rem; }
.session { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem .9rem; border-radius: 12px; background: var(--night); }
.session .sub { color: var(--mist); font-size: .85rem; }
.tag { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--green); color: var(--ink); margin-left: .4rem; }

.toast { position: fixed; left: 50%; bottom: 1.4rem; transform: translate(-50%, 20px); background: var(--ivory); color: var(--ink); padding: .75rem 1.2rem; border-radius: 12px; font-weight: 600; box-shadow: 0 14px 30px rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 50; max-width: calc(100% - 2rem); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); color: #2a0e0b; }

@media (max-width: 820px) {
    .guest { grid-template-columns: 1fr; gap: 1.6rem; }
    .guest > .card { order: -1; }
    .guest h1 { font-size: 2rem; }
    .back .long { display: none; }
    .back .short { display: inline; }
    .topbar { padding-top: 1.1rem; }
    main { padding-top: 1rem; }
    .two { grid-template-columns: 1fr; }
    .wrap { padding: 0 1.1rem; }
    .card { padding: 1.25rem; }
    .who h1 { font-size: 1.7rem; }
    .avatar { width: 68px; height: 68px; font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
