/*
 * The Legends of Mechatron website: the app's colours (lom_app colors.dart),
 * Roboto, light and dark mode, mobile first. Pages use the partials in
 * views/partials and the components below; no page-specific stylesheets.
 */
:root {
    --bg: #17142A;
    --surface: #211E34;
    --surface-2: #363347;
    --text: #D1D1D1;
    --muted: #8C8A94;
    --green: #22BF84;
    --orange: #FF9151;
    --red: #FF6156;
    --on-accent: #10251c;
    /* accent colours for text; darker in the light theme */
    --green-ink: var(--green);
    --orange-ink: var(--orange);
    --red-ink: var(--red);
    --radius: 14px;
    --shadow: 0 6px 24px rgb(0 0 0 / 0.25);
    --maxw: 1080px;
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg: #E8E8E8;
    --surface: #F6F6F7;
    --surface-2: #D4D4D4;
    --text: #2E2D33;
    --muted: #6B6A70;
    --green-ink: #0E7A52;
    --orange-ink: #B4500F;
    --red-ink: #B8322A;
    --shadow: 0 6px 24px rgb(0 0 0 / 0.08);
    color-scheme: light;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg: #E8E8E8;
        --surface: #F6F6F7;
        --surface-2: #D4D4D4;
        --text: #2E2D33;
        --muted: #6B6A70;
        --green-ink: #0E7A52;
        --orange-ink: #B4500F;
        --red-ink: #B8322A;
        --shadow: 0 6px 24px rgb(0 0 0 / 0.08);
        color-scheme: light;
    }
}

*, *::before, *::after { box-sizing: border-box; }
/* components set display; hidden must still win */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 Roboto, system-ui, sans-serif;
    -webkit-text-size-adjust: 100%;
}

main { flex: 1; }
img { max-width: 100%; }
a { color: var(--green-ink); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); }
h2 { font-size: clamp(1.3rem, 3.5vw, 1.7rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.section { padding: 32px 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.center { text-align: center; }
.stack { display: grid; gap: 14px; align-content: start; }
.flush { margin: 0; }
.note { margin: 14px 0 0; }

/* --- buttons and forms --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: 1px solid var(--surface-2);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--green); border-color: var(--green); color: var(--on-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--green) 85%, white); }
.btn-danger { background: var(--red); border-color: var(--red); color: #2a0f0d; }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.field { display: grid; gap: 6px; font-weight: 500; }
.field input, .field select {
    width: 100%;
    /* 16px: smaller inputs make iOS zoom in when focused */
    font: 400 16px/1.4 Roboto, system-ui, sans-serif;
    padding: 12px 14px;
    border: 1px solid var(--surface-2);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
}
.field input:focus { outline: 2px solid var(--green); outline-offset: 1px; border-color: transparent; }
.form-error { color: var(--red-ink); font-weight: 500; margin: 0; }

input[type="range"] { accent-color: var(--green); width: 100%; }

/* --- header --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--surface-2);
}
.site-nav { display: flex; align-items: center; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; margin-right: auto; }
.brand img { width: 28px; height: 28px; }
.nav-toggle { display: none; }
.nav-toggle-label { cursor: pointer; font-size: 1.5rem; padding: 4px 8px; order: 2; }
.links { display: none; list-style: none; margin: 0; padding: 0 0 12px; width: 100%; order: 3; }
.links a { display: block; padding: 10px 4px; color: var(--text); text-decoration: none; }
.links a:hover { color: var(--green-ink); }
.nav-toggle:checked ~ .links { display: block; }

.account { position: relative; order: 1; }
.account summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.account summary::-webkit-details-marker { display: none; }
.account .name { display: none; }
.account ul {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 180px;
    list-style: none;
    margin: 0;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--surface-2);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.account li a, .account li button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}
.account li a:hover, .account li button:hover { background: var(--surface-2); }
.account form { margin: 0; }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--surface-2) center / cover no-repeat;
    flex: none;
}

@media (min-width: 800px) {
    .nav-toggle-label { display: none; }
    .links { display: flex; gap: 22px; width: auto; padding: 0; order: 0; }
    .links a { padding: 0; }
    .account { order: 0; }
    .account .name { display: inline; }
}

/* --- cards and grids --- */
.card {
    background: var(--surface);
    border: 1px solid var(--surface-2);
    border-radius: var(--radius);
    padding: 20px;
}
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--orange) 20%, transparent); color: var(--orange-ink); font-size: 0.85rem; font-weight: 600; }

/* --- home --- */
.hero { padding: 56px 16px 32px; }
.eyebrow { color: var(--orange-ink); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 8px; font-size: 0.85rem; }
.eyebrow.green { color: var(--green-ink); }
.hero h1 { font-size: clamp(2.2rem, 8vw, 4rem); margin-bottom: 14px; }
.accent { color: var(--green-ink); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 36em; }

.ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ranking li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.ranking .place { width: 28px; text-align: center; font-size: 1.2rem; }
.ranking .who { flex: 1; font-weight: 500; }
.ranking .points { font-variant-numeric: tabular-nums; color: var(--green-ink); font-weight: 700; }

.game-card { display: flex; gap: 14px; align-items: center; text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.15s; }
.game-card:hover { border-color: var(--green); transform: translateY(-2px); }
.game-card img { width: 56px; height: 56px; object-fit: contain; border-radius: 12px; flex: none; }
.game-card h3 { margin: 0 0 2px; }
.game-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.faq { border-bottom: 1px solid var(--surface-2); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 600; font-size: 1.05rem; }
.faq p { margin: 10px 0 0; color: var(--muted); }

/* --- game stats --- */
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.page-head img { width: 72px; height: 72px; object-fit: contain; }
.page-head h1 { margin: 0; }
.stat-card { display: grid; justify-items: center; align-content: start; gap: 14px; }
.stat-card h2 { justify-self: start; font-size: 1.15rem; }
.donut {
    width: min(70vw, 220px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: conic-gradient(var(--segments, var(--surface-2) 0 100%));
    display: grid;
    place-items: center;
    position: relative;
}
.donut::before { content: ""; position: absolute; inset: 18%; border-radius: 50%; background: var(--surface); }
.donut span { position: relative; text-align: center; font-size: 2rem; font-weight: 700; line-height: 1.1; }
.donut small { display: block; font-size: 0.85rem; font-weight: 400; color: var(--muted); }
.legend { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 10px; }
.legend .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.legend .value { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.legend .pct { color: var(--muted); width: 3.5em; text-align: right; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-top: 14px; }
.fact { text-align: center; }
.fact strong { display: block; font-size: 1.8rem; }
.tone-green { background: var(--green); }
.tone-orange { background: var(--orange); }
.tone-red { background: var(--red); }
.tone-muted { background: var(--muted); }

/* --- login and other small pages --- */
.auth-page { display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(100%, 400px); display: grid; gap: 16px; text-align: left; }
.auth-logo { width: 52px; height: 52px; }
.auth-card h1 { font-size: 1.6rem; margin: 0; }
.auth-card ol { padding-left: 1.2em; margin: 0; display: grid; gap: 6px; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: 0.95em; }

/* --- account --- */
.profile-head { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.profile-head h1 { margin: 0; line-height: 1.1; overflow-wrap: anywhere; }
.profile-head .avatar { width: 84px; height: 84px; }
.avatar-button .avatar { display: block; }
.avatar-button { display: block; position: relative; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; flex: none; transition: transform 0.15s; }
.avatar-button:hover { transform: scale(1.04); }
.avatar-button:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
.edit-badge { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: var(--on-accent); font-size: 0.95rem; box-shadow: 0 0 0 3px var(--bg); }
.avatar.big { width: 120px; height: 120px; margin: 0 auto; }
dialog {
    width: min(92vw, 560px);
    max-height: 85dvh;
    border: 1px solid var(--surface-2);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 20px;
    box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / 0.6); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 14px 10px; padding: 6px 4px; }
.icon-grid button {
    position: relative;
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    border-radius: 50%;
    /* border-box: buttons have default padding, the image must fill the whole circle */
    background: var(--bg) center / cover no-repeat border-box;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.icon-grid button:hover { transform: scale(1.06); }
.icon-grid button:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.icon-grid button.current { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--green); }
/* locked: grey, with a lock */
.icon-grid button.locked { filter: grayscale(1) brightness(0.65); }
.icon-grid button.locked::after {
    content: "🔒";
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    border-radius: 50%;
    background: var(--surface-2);
    filter: grayscale(1);
}
/* on sale: in colour, a glowing ring and a price tag */
.icon-grid button.on-sale { filter: none; animation: sale-glow 2.4s ease-in-out infinite; }
.icon-grid button.on-sale::after { display: none; }
.sale-tag {
    position: absolute;
    top: -8px;
    right: -12px;
    padding: 2px 7px;
    border-radius: 999px;
    background: linear-gradient(110deg, var(--orange) 0%, var(--red) 45%, #ffd27a 55%, var(--orange) 70%, var(--red) 100%) 0 0 / 250% 100%;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 1px rgb(0 0 0 / 0.35);
    box-shadow: 0 2px 8px rgb(255 97 86 / 0.45);
    transform: rotate(10deg);
    animation: sale-shine 3s linear infinite;
    pointer-events: none;
}
@keyframes sale-glow {
    0%, 100% { box-shadow: 0 0 0 3px var(--orange), 0 0 10px 2px rgb(255 145 81 / 0.35); }
    50% { box-shadow: 0 0 0 3px var(--red), 0 0 20px 6px rgb(255 97 86 / 0.55); }
}
@keyframes sale-shine { to { background-position: -250% 0; } }
@media (prefers-reduced-motion: reduce) {
    .icon-grid button.on-sale, .sale-tag { animation: none; }
    .icon-grid button.on-sale { box-shadow: 0 0 0 3px var(--orange); }
}
.price { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin: 0; }
.price s { color: var(--muted); }
.price strong { font-size: 2rem; color: var(--orange-ink); }
.icon-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 14px 0 0; font-size: 0.85rem; color: var(--muted); }

/* --- admin --- */
.chip-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.chip-nav a { padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--surface-2); color: var(--text); text-decoration: none; font-size: 0.92rem; }
.chip-nav a:hover { border-color: var(--green); }
.admin-section { margin: 0 0 34px; scroll-margin-top: 80px; }
.admin-section > h2 { margin-bottom: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--surface-2); border-radius: var(--radius); padding: 14px 16px; }
.tile strong { display: block; font-size: 1.7rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 0.88rem; }
.tile small { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bars li { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; align-items: center; gap: 10px; font-size: 0.92rem; }
.bars .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .track { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bars .fill { display: block; height: 100%; border-radius: 6px; background: var(--green); min-width: 3px; }
.bars .fill.orange { background: var(--orange); }
.bars .num { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3ch; text-align: right; }
.columns { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px; }
.columns .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.columns .bar-stack { width: 100%; max-width: 34px; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 2px 2px; overflow: hidden; background: var(--surface-2); min-height: 3px; }
.columns .bar-stack i { display: block; }
.columns .col small { font-size: 0.68rem; color: var(--muted); white-space: nowrap; }
.legend-inline { display: flex; gap: 16px; font-size: 0.85rem; color: var(--muted); margin-top: 10px; }
.legend-inline span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--c); vertical-align: -1px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--surface-2); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--surface-2); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 500; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .who { display: flex; align-items: center; gap: 10px; }
.table .avatar { width: 28px; height: 28px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; margin-left: 6px; background: var(--surface-2); color: var(--text); }
.pill.green { background: color-mix(in srgb, var(--green) 22%, transparent); color: var(--green-ink); }
.pill.red { background: color-mix(in srgb, var(--red) 22%, transparent); color: var(--red-ink); }
.pill.orange { background: color-mix(in srgb, var(--orange) 22%, transparent); color: var(--orange-ink); }
.dot-easy, .dot-medium, .dot-hard { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }
.dot-easy { background: var(--green); }
.dot-medium { background: var(--orange); }
.dot-hard { background: var(--red); }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rows li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--bg); }
.rows li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rows li .side { color: var(--muted); font-size: 0.88rem; white-space: nowrap; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--surface-2); cursor: pointer; }
.switch:last-of-type { border-bottom: 0; }
.switch small { display: block; color: var(--muted); }
.switch input { appearance: none; width: 46px; height: 26px; border-radius: 999px; background: var(--surface-2); position: relative; cursor: pointer; flex: none; transition: background 0.15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(20px); }
.field textarea { width: 100%; font: 400 16px/1.4 Roboto, system-ui, sans-serif; padding: 12px 14px; border: 1px solid var(--surface-2); border-radius: 10px; background: var(--bg); color: var(--text); resize: vertical; min-height: 90px; }
.field select { appearance: auto; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-form input { width: 110px; font: 400 16px/1.4 Roboto, system-ui, sans-serif; padding: 9px 12px; border: 1px solid var(--surface-2); border-radius: 10px; background: var(--bg); color: var(--text); }
.status-line { min-height: 1.4em; margin: 6px 0 0; font-size: 0.9rem; color: var(--muted); }
.status-line.error { color: var(--red-ink); }
.status-line.ok { color: var(--green-ink); }
dialog.wide { width: min(94vw, 760px); }
.admin-dialog-head { display: flex; align-items: center; gap: 14px; }
.admin-dialog-head .avatar { width: 56px; height: 56px; }
.admin-dialog-head h2 { margin: 0; }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.mini-stats div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.mini-stats strong { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.mini-stats span { font-size: 0.8rem; color: var(--muted); }
.icon-grid.small { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 10px 8px; }
.icon-grid button.owned { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--green); }

/* --- stats: the game pages and the home page (src/web/stats) --- */
:root {
    --gold: linear-gradient(135deg, #FFE48A 0%, #F4B400 42%, #FFF2B8 55%, #C98A00 100%);
    --silver: linear-gradient(135deg, #F4F6FA 0%, #AEB6C2 42%, #FFFFFF 55%, #8A93A1 100%);
    --bronze: linear-gradient(135deg, #F6C39A 0%, #C8743E 42%, #FFD9B8 55%, #8F4A1E 100%);
    --platinum: linear-gradient(135deg, #E9F7FF 0%, #9FD4F2 38%, #FFFFFF 52%, #7BB6D9 72%, #C9B8FF 100%);
    --display: Oswald, Roboto, system-ui, sans-serif;
}
/* the colours of each game's icon */
.game-take6 { --game-a: #FFA35C; --game-b: #FF5A4F; }
.game-ohHell { --game-a: #F0567A; --game-b: #8E1F4A; }
.game-fourWins { --game-a: #5B8DEF; --game-b: #3C4FC4; }
.game-hangman { --game-a: #B07CF0; --game-b: #6C47C2; }
.game-werewolf { --game-a: #5A52B8; --game-b: #221D4A; }
.game-ttt { --game-a: #34D399; --game-b: #139A6C; }
.game-tttBig { --game-a: #2CC5D2; --game-b: #1A7D9C; }
.game-wordle { --game-a: #5B5680; --game-b: #2A2645; }

.block { margin-top: 22px; }
.rank-big { font-family: var(--display); font-weight: 700; font-size: clamp(3.2rem, 12vw, 5.5rem); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* the banner of a game page */
.game-page { padding-top: 20px; }
.game-hero {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
    padding: 24px;
    border-radius: calc(var(--radius) + 6px);
    color: #fff;
    background:
        radial-gradient(120% 140% at 100% 0%, rgb(255 255 255 / 0.2), transparent 55%),
        radial-gradient(80% 90% at 0% 100%, rgb(0 0 0 / 0.18), transparent 60%),
        linear-gradient(135deg, var(--game-a, var(--green)), var(--game-b, #139A6C));
    box-shadow: var(--shadow);
}
@media (min-width: 800px) {
    .game-hero { grid-template-columns: 1.1fr 1fr; align-items: center; padding: 32px; }
    .game-hero .hero-stats, .game-hero .hero-actions { grid-column: 1 / -1; }
}
.game-hero-top { display: flex; align-items: center; gap: 16px; }
.game-hero-icon { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 10px 28px rgb(0 0 0 / 0.3); flex: none; }
.game-hero h1 { margin: 0; color: #fff; }
.game-hero .eyebrow { color: rgb(255 255 255 / 0.8); }
.hero-intro, .rank-sub, .hero-actions { color: rgb(255 255 255 / 0.9); }
.rank-line { margin: 0 0 4px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 1.2rem; }
.game-hero .rank-big { text-shadow: 0 6px 24px rgb(0 0 0 / 0.25); }
.game-hero .btn-primary { background: #fff; color: #1D1A2E; }
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.hero-stat { padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--surface-2); min-width: 0; }
.game-hero .hero-stat { background: rgb(255 255 255 / 0.14); border-color: rgb(255 255 255 / 0.2); }
.hero-stat strong { display: block; font-family: var(--display); font-size: 1.7rem; line-height: 1.15; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-stat span { font-size: 0.85rem; color: var(--muted); }
.game-hero .hero-stat span { color: rgb(255 255 255 / 0.85); }

/* rankings with avatars; the viewer's own row stands out */
.ranking.board li { gap: 10px; padding: 8px 12px; }
.ranking.board .place { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); font-size: 0.9rem; font-weight: 700; }
.ranking .place.medal-gold { background: var(--gold); color: #3B2A00; }
.ranking .place.medal-silver { background: var(--silver); color: #2E3440; }
.ranking .place.medal-bronze { background: var(--bronze); color: #3A1E08; }
.ranking .avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.ranking .name-cell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ranking .name-cell .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking .extra { font-size: 0.8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking li.me { background: color-mix(in srgb, var(--green) 14%, var(--bg)); box-shadow: inset 0 0 0 2px var(--green); }
.ranking li.gap { background: none; justify-content: center; padding: 0; color: var(--muted); letter-spacing: 0.3em; }
.board-card .ranking { margin-top: 4px; }
#season .ranking.board { margin-top: 6px; }

/* the podium: rank order 1-2-3 in the markup, shown 2-1-3 */
.podium { list-style: none; margin: 18px 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "second first third"; align-items: end; gap: 10px; }
.podium .pos-1 { grid-area: first; }
.podium .pos-2 { grid-area: second; }
.podium .pos-3 { grid-area: third; }
.podium li { display: flex; flex-direction: column; align-items: center; min-width: 0; text-align: center; }
.podium-person { display: grid; justify-items: center; gap: 4px; padding-bottom: 10px; max-width: 100%; }
.podium-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.pos-1 .podium-avatar { width: 88px; height: 88px; }
.podium-avatar.medal-gold { box-shadow: 0 0 0 4px var(--bg), 0 0 0 8px #F4B400, 0 0 34px rgb(244 180 0 / 0.5); }
.podium-avatar.medal-silver { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px #AEB6C2; }
.podium-avatar.medal-bronze { box-shadow: 0 0 0 4px var(--bg), 0 0 0 7px #C8743E; }
.podium-crown { width: 36px; height: 36px; margin-bottom: -4px; color: #F4B400; filter: drop-shadow(0 2px 8px rgb(244 180 0 / 0.55)); }
.podium .who { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.podium li.me .who { color: var(--green-ink); }
.podium .points { font-family: var(--display); font-size: 1.5rem; font-weight: 700; color: var(--green-ink); font-variant-numeric: tabular-nums; }
.podium-block { width: 100%; display: grid; place-items: start center; padding-top: 8px; border-radius: 12px 12px 4px 4px; font-family: var(--display); font-size: 1.7rem; font-weight: 700; color: rgb(0 0 0 / 0.5); box-shadow: inset 0 2px 0 rgb(255 255 255 / 0.5); }
.pos-1 .podium-block { height: 124px; background: var(--gold); }
.pos-2 .podium-block { height: 88px; background: var(--silver); }
.pos-3 .podium-block { height: 62px; background: var(--bronze); }

/* hall of fame */
.fame-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(160px, 190px); gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 10px; }
.fame-card { scroll-snap-align: start; display: grid; justify-items: center; align-content: start; gap: 6px; padding: 16px 12px; text-align: center; border-radius: var(--radius); background: linear-gradient(165deg, color-mix(in srgb, #F4B400 22%, var(--surface)), var(--surface) 62%); border: 1px solid color-mix(in srgb, #F4B400 35%, var(--surface-2)); }
.fame-card strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fame-season { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--orange-ink); }
.fame-people { display: flex; }
.fame-people img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 3px #F4B400; background: var(--surface-2); }
.fame-people img + img { margin-left: -12px; }
.titles { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.titles li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: var(--bg); }
.titles li > span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.titles .avatar { width: 32px; height: 32px; border-radius: 50%; }
.crowns { display: flex; align-items: center; gap: 4px; font-family: var(--display); font-size: 1.2rem; font-weight: 700; }
.crowns .glyph { width: 18px; height: 18px; color: #F4B400; }
.mini-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.mini-facts div { padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.mini-facts strong { display: block; font-family: var(--display); font-size: 1.6rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.mini-facts span { font-size: 0.82rem; color: var(--muted); }

/* trophies: a metal disc per tier */
.glyph { width: 1em; height: 1em; fill: currentColor; flex: none; }
.trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.trophy { position: relative; display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--surface-2); }
.trophy.tier-gold, .trophy.tier-platinum { border-color: color-mix(in srgb, #F4B400 45%, var(--surface-2)); background: linear-gradient(160deg, color-mix(in srgb, #F4B400 10%, var(--surface)), var(--surface) 60%); }
.trophy.untracked { border-style: dashed; }
.medal { position: relative; overflow: hidden; width: 58px; height: 58px; flex: none; display: grid; place-items: center; border-radius: 50%; color: rgb(0 0 0 / 0.55); background: var(--metal, var(--surface-2)); box-shadow: inset 0 2px 4px rgb(255 255 255 / 0.55), inset 0 -3px 6px rgb(0 0 0 / 0.25), 0 4px 12px rgb(0 0 0 / 0.25); }
.medal .glyph { width: 28px; height: 28px; }
.medal::after { content: ""; position: absolute; inset: -50%; background: linear-gradient(115deg, transparent 42%, rgb(255 255 255 / 0.6) 50%, transparent 58%); transform: translateX(-60%); transition: transform 0.9s ease; }
.trophy:hover .medal::after { transform: translateX(60%); }
.tier-bronze { --metal: var(--bronze); }
.tier-silver { --metal: var(--silver); }
.tier-gold { --metal: var(--gold); }
.tier-platinum { --metal: var(--platinum); }
.trophy.locked .medal { color: var(--muted); box-shadow: inset 0 0 0 2px var(--surface-2); background: var(--bg); }
.trophy.locked .medal::after { display: none; }
.trophy-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.trophy-text strong { line-height: 1.2; }
.tier-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tier-bronze .tier-label { color: #C8743E; }
.tier-silver .tier-label { color: #8A93A1; }
.tier-gold .tier-label { color: #D49B00; }
.tier-platinum .tier-label { color: #4FA3D6; }
.progress { display: block; height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.progress i { display: block; height: 100%; width: var(--p, 0%); border-radius: inherit; background: linear-gradient(90deg, var(--green), color-mix(in srgb, var(--green) 55%, #fff)); }
.cabinet-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.cabinet-game { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--surface-2); color: var(--text); text-decoration: none; transition: border-color 0.15s; }
.cabinet-game:hover { border-color: var(--green); }
.cabinet-game img { width: 32px; height: 32px; border-radius: 8px; }
.tier-dots { display: flex; gap: 4px; width: 100%; min-height: 12px; }
.tier-dots i { width: 12px; height: 12px; border-radius: 50%; }
.dot-bronze { background: var(--bronze); }
.dot-silver { background: var(--silver); }
.dot-gold { background: var(--gold); }
.dot-platinum { background: var(--platinum); }

/* records, roles and the 12 months */
.records { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.records li { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; padding: 9px 12px; border-radius: 10px; background: var(--bg); }
.records b { text-align: right; font-variant-numeric: tabular-nums; }
.records .small { grid-column: 1 / -1; }
.role-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.role-bars li { display: grid; grid-template-columns: 7.5em 1fr auto; align-items: center; gap: 10px; font-size: 0.92rem; }
.role-bar { display: flex; width: var(--w); min-width: 6px; height: 12px; overflow: hidden; border-radius: 6px; }
.role-bar i { display: block; }
.history-cols { display: flex; align-items: flex-end; gap: 6px; height: 180px; }
.history-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.history-bar { width: 100%; max-width: 30px; height: var(--h); min-height: 2px; display: flex; flex-direction: column-reverse; overflow: hidden; border-radius: 6px 6px 2px 2px; background: var(--surface-2); }
.history-bar i { display: block; }
.history-total, .history-label { font-size: 0.7rem; color: var(--muted); white-space: nowrap; }
.history .legend-inline span::before { content: none; }
.history .legend-inline .dot { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }

/* the home page */
.home-hero { position: relative; }
.home-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(40% 60% at 25% 40%, color-mix(in srgb, var(--green) 24%, transparent), transparent 70%),
        radial-gradient(35% 55% at 75% 30%, color-mix(in srgb, var(--orange) 18%, transparent), transparent 70%);
    /* fades out well before the edges of the box */
    -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent);
    mask-image: radial-gradient(closest-side, #000 55%, transparent);
}
.home-hero .hero-stats { max-width: 640px; margin: 6px 0 22px; }
.you-rank { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.you-rank .rank-big { color: var(--green-ink); }
.you-rank span { color: var(--muted); line-height: 1.4; }
.you-rank b { color: var(--text); font-size: 1.25rem; }
.gap-bar { display: grid; gap: 6px; margin-bottom: 12px; }
.missions { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 12px; }
.missions li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.missions .progress { grid-column: 1 / -1; }
.missions .small { grid-column: 1 / -1; }
.missions li.done .mission-title { color: var(--muted); text-decoration: line-through; }
.mission-reward { font-weight: 700; font-size: 0.9rem; color: var(--green-ink); }
.up-next { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.up-next li { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.up-next li > span:last-child { display: grid; gap: 2px; min-width: 0; }
.up-next a { color: var(--text); text-decoration: none; }
.up-next a:hover strong { text-decoration: underline; }
.up-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); }
.up-icon .glyph { width: 20px; height: 20px; }
.up-green .up-icon { background: color-mix(in srgb, var(--green) 25%, transparent); color: var(--green-ink); }
.up-orange .up-icon { background: color-mix(in srgb, var(--orange) 25%, transparent); color: var(--orange-ink); }
.game-card { border-top: 4px solid var(--game-a, var(--surface-2)); }
.game-card .quick { display: inline-block; margin-top: 6px; font-size: 0.82rem; font-weight: 600; color: var(--green-ink); }

/* motion (public/js/fx.js): only with scripts, never with "reduce motion" */
@property --sweep { syntax: '<percentage>'; inherits: false; initial-value: 100%; }
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; animation: reveal-anyway 0s 3s forwards; }
.js .reveal.in { opacity: 1; transform: none; animation: none; }
@keyframes reveal-anyway { to { opacity: 1; transform: none; } }
.js .rank-big { animation: pop 0.7s 0.1s cubic-bezier(0.2, 1.4, 0.4, 1) both; }
@keyframes pop { from { opacity: 0; transform: scale(0.4); } }
.reveal.in .progress i { animation: grow-x 1.1s 0.15s ease both; }
.reveal.in .history-bar { animation: grow-y 0.9s ease both; }
.reveal.in .podium-block { animation: grow-y 0.8s ease both; }
.reveal.in .pos-2 .podium-block { animation-delay: 0.12s; }
.reveal.in .pos-3 .podium-block { animation-delay: 0.24s; }
@keyframes grow-x { from { width: 0; } }
@keyframes grow-y { from { height: 0; } }
.donut.draw {
    -webkit-mask: radial-gradient(circle closest-side, #000 64%, transparent 65%), conic-gradient(#000 var(--sweep), transparent 0);
    mask: radial-gradient(circle closest-side, #000 64%, transparent 65%), conic-gradient(#000 var(--sweep), transparent 0);
    animation: sweep 1.2s ease-out both;
}
@keyframes sweep { from { --sweep: 0%; } to { --sweep: 100%; } }
@media (prefers-reduced-motion: reduce) {
    .js .reveal { opacity: 1; transform: none; transition: none; animation: none; }
    .reveal.in .progress i, .reveal.in .history-bar, .reveal.in .podium-block, .donut.draw, .js .rank-big { animation: none; }
    .medal::after { transition: none; }
}

/* --- footer --- */
.site-footer { padding: 28px 16px; color: var(--muted); font-size: 0.9rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
