/* ==========================================================================
   Challenge Leaderboards
   Palette: #3d5a80 · #98c1d9 · #e0fbfc · #ee6c4d · #293241
   ========================================================================== */

:root {
    --navy: #293241;
    --blue: #3d5a80;
    --sky: #98c1d9;
    --ice: #e0fbfc;
    --orange: #ee6c4d;

    --bg: #f3f6f8;
    --surface: #ffffff;
    --text: #293241;
    --muted: #5b6676;
    --border: #e1e7ec;
    --border-strong: #cbd4dc;
    --danger: #b23a2a;
    --danger-soft: #fbecea;
    --success: #1f7a4d;
    --focus: #3d5a80;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(41, 50, 65, .06);
    --shadow: 0 1px 3px rgba(41, 50, 65, .06), 0 6px 16px rgba(41, 50, 65, .06);
    --shadow-lg: 0 20px 50px rgba(41, 50, 65, .25);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-num: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input { font: inherit; color: inherit; }
a { color: var(--blue); }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex-shrink: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* ---------- Layout ---------- */
.main { padding-bottom: 64px; }
.container { width: 100%; margin: 0; padding: 24px 16px; }
@media (min-width: 600px)  { .container { padding: 28px 24px; } }
@media (min-width: 1280px) { .container { padding: 32px 32px; } }

.stack > * + * { margin-top: 16px; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--navy); color: #fff;
    padding-top: env(safe-area-inset-top);
}
.topbar__inner {
    padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
@media (min-width: 600px)  { .topbar__inner { padding: 10px 24px; } }
@media (min-width: 1280px) { .topbar__inner { padding: 10px 32px; } }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 650; letter-spacing: -.01em; }
.brand__mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--orange); color: var(--navy); }
.brand__mark .icon { width: 20px; height: 20px; }
.brand__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Page head ---------- */
.back-link {
    display: inline-flex; align-items: center; gap: 4px; margin: -4px 0 12px -4px; padding: 4px;
    color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500;
}
.back-link:hover { color: var(--text); }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head__text { min-width: 0; }
.page-head__actions { display: flex; gap: 8px; align-items: center; }
.page-title { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); line-height: 1.2; letter-spacing: -.02em; font-weight: 700; overflow-wrap: anywhere; }
.page-sub { color: var(--muted); margin-top: 4px; font-size: 15px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 15px; line-height: 1; white-space: nowrap;
    cursor: pointer; text-decoration: none;
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn--block { width: 100%; }
.btn--icon { width: 44px; padding: 0; }
.btn--icon.btn--sm { width: 36px; }

.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: #33506f; }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { background: #f6f8fa; border-color: #b8c3cd; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #9b3122; }
.btn--danger:disabled { opacity: .45; }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--danger-soft); color: var(--danger); }
.btn--ghost-light { background: transparent; color: rgba(255,255,255,.85); border-color: rgba(255,255,255,.2); }
.btn--ghost-light:hover { background: rgba(255,255,255,.1); color: #fff; }
.btn--on-color { background: transparent; color: var(--c-fg, #fff); }
.btn--on-color:hover { background: rgba(255,255,255,.18); }

@media (max-width: 420px) {
    .topbar__logout .btn span { display: none; }
    .topbar__logout .btn { width: 36px; padding: 0; }
}

/* ---------- Forms ---------- */
.field { border: 0; margin-inline: 0; padding: 0; min-width: 0; }
.field__label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; padding: 0; }
.field__optional { font-weight: 400; color: var(--muted); margin-left: 4px; }
.field__hint { font-size: 13px; color: var(--muted); margin-top: 6px; min-height: 0; }
.field__hint--player { color: var(--blue); font-weight: 500; }

.input {
    display: block; width: 100%; min-height: 46px; padding: 10px 14px;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-size: 16px; /* prevents iOS zoom */
    transition: border-color .15s, box-shadow .15s;
}
.input:hover { border-color: #b8c3cd; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(61,90,128,.2); }
.input--score { font-family: var(--font-num); font-size: 22px; font-weight: 600; letter-spacing: .02em; }
.input:user-invalid { border-color: var(--danger); }

.saved-note {
    padding: 10px 14px; border-radius: var(--radius-sm);
    background: #e8f5ee; color: var(--success); font-size: 14px; font-weight: 600;
    border-left: 4px solid #7fd1a8;
}
.saved-note--error { background: var(--danger-soft); color: var(--danger); border-left-color: var(--danger); }

/* Player suggestions */
.suggest {
    list-style: none; margin: 6px 0 0; padding: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.suggest__item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 44px; padding: 0 12px; border-radius: 6px; cursor: pointer;
}
.suggest__item[aria-selected="true"], .suggest__item:hover { background: #eef2f7; }
.suggest__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest__name mark { background: none; color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.suggest__meta { font-size: 12px; color: var(--muted); white-space: nowrap; }

.inline-form { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-form .input { flex: 1 1 240px; }

/* Segmented control (sort order) */
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #eef2f5; border-radius: 10px; }
.segmented__opt { position: relative; }
.segmented__opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented__opt span {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 42px; padding: 0 10px; border-radius: 7px;
    font-size: 14px; font-weight: 600; color: var(--muted);
    transition: background-color .15s, color .15s, box-shadow .15s;
}
.segmented__opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented__opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }

/* ---------- Panels & empty states ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
@media (min-width: 768px) { .panel { padding: 28px; } }
.panel__title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }

.create-event { margin-bottom: 24px; animation: drop .18s ease-out; }

.empty { text-align: center; padding: 56px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.empty__icon { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 14px; background: var(--ice); color: var(--blue); margin-bottom: 12px; }
.empty__icon .icon { width: 26px; height: 26px; }
.empty__title { font-size: 18px; font-weight: 700; }
.empty__text { color: var(--muted); margin-top: 4px; }

.first-challenge { max-width: 560px; margin: 0 auto; }
.first-challenge__intro { text-align: center; margin-bottom: 24px; }

/* ---------- Event list ---------- */
.event-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 600px) { .event-list { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }

.event-card {
    position: relative; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
    padding: 18px 20px 18px 24px; min-height: 84px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm); overflow: hidden;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.event-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--blue); }
.event-list li:nth-child(5n+2) .event-card::before { background: var(--orange); }
.event-list li:nth-child(5n+3) .event-card::before { background: var(--sky); }
.event-list li:nth-child(5n+4) .event-card::before { background: var(--navy); }
.event-list li:nth-child(5n+5) .event-card::before { background: #9fd8db; }
.event-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.event-card__name { font-weight: 650; font-size: 17px; overflow-wrap: anywhere; }
.event-card__meta { grid-column: 1; display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); }
.event-card__go { grid-column: 2; grid-row: 1 / span 2; color: var(--muted); transform: rotate(180deg); display: flex; }

/* ---------- Login ---------- */
.page-login .main { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 360px; }
.login__card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px 28px; box-shadow: var(--shadow); }
.login__mark { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px; background: var(--navy); color: var(--orange); }
.login__mark .icon { width: 24px; height: 24px; }
.login__title { text-align: center; font-size: 18px; font-weight: 700; margin-bottom: 20px; letter-spacing: -.01em; }

/* ---------- Challenge colours ---------- */
.board--blue   { --c-bg: #3d5a80; --c-fg: #ffffff; --c-ink: #3d5a80; --c-soft: #eef2f7; }
.board--orange { --c-bg: #ee6c4d; --c-fg: #1a202b; --c-ink: #b8432a; --c-soft: #fdf0ec; }
.board--sky    { --c-bg: #98c1d9; --c-fg: #293241; --c-ink: #2f6f93; --c-soft: #eef5f9; }
.board--navy   { --c-bg: #293241; --c-fg: #ffffff; --c-ink: #293241; --c-soft: #eef0f3; }
.board--ice    { --c-bg: #e0fbfc; --c-fg: #293241; --c-ink: #24737a; --c-soft: #f1fdfd; }

/* ---------- Boards (leaderboards) ---------- */
/* Mobile: 1 per row · Tablet portrait: 2 · Tablet landscape / small laptop: 3 · Desktop: 4 */
.boards { display: grid; gap: 16px; align-items: start; grid-template-columns: 1fr; }
@media (min-width: 600px)  { .boards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1024px) { .boards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .boards { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; } }

.board {
    container: board / inline-size;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
}
.board--ice { border-color: #bfe6e8; }
.board:target { box-shadow: 0 0 0 3px var(--c-bg), var(--shadow); }

.board__head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
    padding: 16px 12px 16px 20px; background: var(--c-bg); color: var(--c-fg);
}
.board--ice .board__head { border-bottom: 1px solid #bfe6e8; }
.board__titles { min-width: 0; }
.board__title { font-size: 20px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; overflow-wrap: anywhere; }
.board__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 6px; font-size: 13px; font-weight: 600; }
.sort-pill {
    display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px 3px 7px; border-radius: 99px;
    background: rgba(255,255,255,.18); font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.board--ice .sort-pill, .board--sky .sort-pill, .board--orange .sort-pill { background: rgba(41,50,65,.1); }
.sort-pill .icon { width: 14px; height: 14px; }
.board--orange .btn--on-color:hover,
.board--sky .btn--on-color:hover,
.board--ice .btn--on-color:hover { background: rgba(41,50,65,.1); }

.board__body { padding: 8px 8px 0; flex: 1; }
.board__empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 15px; }

.board__toggle {
    display: block; width: 100%; margin: 4px 0 0; padding: 12px; min-height: 44px;
    background: none; border: 0; border-top: 1px solid var(--border);
    color: var(--c-ink); font-weight: 600; font-size: 14px; cursor: pointer;
}
.board__toggle:hover { text-decoration: underline; }

.board__foot { padding: 12px 16px 16px; }
.btn--add { background: var(--c-bg); color: var(--c-fg); }
.btn--add:hover { filter: brightness(.95); }
.board--ice .btn--add { border-color: #a9dfe2; }

/* Rows */
.rows { list-style: none; margin: 0; padding: 0; }
.row { border-radius: 10px; }
.row + .row { margin-top: 2px; }
.row details > summary { list-style: none; }
.row details > summary::-webkit-details-marker { display: none; }

.row__main {
    display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto 20px; align-items: center; gap: 10px;
    min-height: 48px; padding: 6px 10px 6px 8px; border-radius: 10px; cursor: pointer;
    transition: background-color .15s;
}
.row__main:hover { background: var(--c-soft); }
.row details[open] > .row__main { background: var(--c-soft); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.row__rank {
    display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
    font-size: 13px; font-weight: 700; color: var(--muted); background: #f1f4f7;
    font-variant-numeric: tabular-nums;
}
.row--rank1 .row__rank { background: var(--c-bg); color: var(--c-fg); box-shadow: 0 0 0 3px var(--c-soft); }
.board--ice .row--rank1 .row__rank { box-shadow: 0 0 0 1px #a9dfe2; }
.row--rank2 .row__rank,
.row--rank3 .row__rank { background: var(--c-soft); color: var(--c-ink); box-shadow: inset 0 0 0 1.5px var(--c-ink); }

.row__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row--rank1 .row__name { font-weight: 700; }
.row__tries { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row__score {
    font-family: var(--font-num); font-weight: 700; font-size: 17px; text-align: right;
    color: var(--c-ink); font-variant-numeric: tabular-nums; min-width: 3ch; white-space: nowrap;
}
.row__chev { display: flex; color: var(--muted); transition: transform .2s; }
.row__chev .icon { width: 16px; height: 16px; }
.row details[open] .row__chev { transform: rotate(180deg); }

@container board (max-width: 340px) {
    .row__main { grid-template-columns: 30px minmax(0, 1fr) auto auto 14px; gap: 8px; padding-right: 6px; }
    .row__tries-label { display: none; }
    .row__tries::after { content: "×"; }
    .board__head { padding-left: 16px; }
}

.row--new .row__main { animation: highlight 2.4s ease-out; }
@keyframes highlight {
    0%, 30% { background: #fff3cd; }
    100% { background: transparent; }
}

/* Attempts (expanded row) */
.attempts {
    list-style: none; margin: 0 0 6px; padding: 4px 8px 8px 52px;
    background: var(--c-soft); border-bottom-left-radius: 10px; border-bottom-right-radius: 10px;
}
.attempt { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 2px 0; font-size: 14px; }
.attempt + .attempt { border-top: 1px solid rgba(41,50,65,.07); }
.attempt__score { font-family: var(--font-num); font-weight: 600; min-width: 5ch; font-variant-numeric: tabular-nums; }
.attempt--best .attempt__score { color: var(--c-ink); }
.attempt--best .attempt__score::after { content: "best"; margin-left: 8px; font-family: var(--font); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--c-ink); }
.attempt__time { color: var(--muted); font-size: 13px; }
@container board (max-width: 320px) { .attempts { padding-left: 16px; } }

/* ---------- Menus ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__list {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 250px; padding: 6px;
    background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); animation: drop .12s ease-out;
}
.menu__item {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px;
    background: none; border: 0; border-radius: 8px; text-align: left; font-size: 15px; font-weight: 500; cursor: pointer;
}
.menu__item:hover:not(:disabled) { background: #f1f4f7; }
.menu__item:disabled { opacity: .45; cursor: not-allowed; }
.menu__item--danger { color: var(--danger); }
.menu__item--danger:hover { background: var(--danger-soft) !important; }

/* ---------- Dialogs ---------- */
.modal {
    width: min(480px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0;
    border: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
    box-shadow: var(--shadow-lg); overflow: auto;
}
.modal::backdrop { background: rgba(41, 50, 65, .55); backdrop-filter: blur(2px); }
.modal[open] { animation: pop .18s ease-out; }

.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 16px 4px 24px; }
.modal__head--color { background: var(--c-bg, var(--blue)); color: var(--c-fg, #fff); padding-bottom: 18px; }
.modal__head--color.board--ice { border-bottom: 1px solid #bfe6e8; }
.modal__title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; padding-top: 6px; }
.modal__sub { font-size: 14px; font-weight: 600; margin-top: 2px; opacity: .9; }
.modal__form { padding: 20px 24px 24px; }
.modal__body { padding: 24px 24px 8px; }
.modal__body > * + * { margin-top: 12px; }
.modal__text { color: var(--muted); }
.modal__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.modal--confirm .modal__actions { padding: 16px 24px 24px; }
.modal__actions--split { justify-content: space-between; }
.modal__actions-right { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 560px) {
    /* Bottom sheet on phones */
    .modal {
        width: 100%; max-width: 100%; margin: auto 0 0; max-height: 92dvh;
        border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom);
    }
    .modal[open] { animation: sheet .22s ease-out; }
    .modal__actions--split { flex-direction: column-reverse; }
    .modal__actions--split > .btn,
    .modal__actions-right,
    .modal__actions-right .btn { width: 100%; }
    .modal__actions-right { flex-direction: column-reverse; }
    .modal--confirm .modal__actions { flex-direction: column-reverse; }
    .modal--confirm .modal__actions .btn { width: 100%; }
}

/* ---------- Toasts ---------- */
.toasts {
    position: fixed; z-index: 100; left: 50%; transform: translateX(-50%);
    top: calc(12px + env(safe-area-inset-top)); width: min(440px, calc(100% - 32px));
    display: grid; gap: 8px; pointer-events: none;
}
.toast {
    padding: 12px 16px; border-radius: var(--radius); background: var(--navy); color: #fff;
    font-size: 15px; font-weight: 500; box-shadow: var(--shadow-lg); pointer-events: auto;
    border-left: 4px solid #7fd1a8; animation: drop .2s ease-out; transition: opacity .3s, transform .3s;
}
.toast--error { background: #fff; color: var(--danger); border: 1px solid #f1c7c0; border-left: 4px solid var(--danger); }
.toast.is-leaving { opacity: 0; transform: translateY(-6px); }

/* ---------- Motion ---------- */
@keyframes drop  { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pop   { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

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

/* ==========================================================================
   Share dialog (QR code)
   ========================================================================== */
.modal--share { width: min(440px, calc(100% - 32px)); }
.modal--share .modal__text { font-size: 14px; margin-top: 4px; }
.qr {
    width: min(260px, 70vw); aspect-ratio: 1; margin: 0 auto;
    padding: 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    display: grid; place-items: center; color: var(--muted); font-size: 14px; text-align: center;
}
.qr svg { width: 100%; height: 100%; display: block; }
.copy-field { display: flex; gap: 8px; }
.copy-field .input { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); }
.share-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.share-actions .btn { padding: 0 10px; }
@media (max-width: 420px) { .share-actions { grid-template-columns: 1fr; } }
.share-reset { text-align: center; }
.link-btn {
    background: none; border: 0; padding: 8px; cursor: pointer;
    color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--danger); }

/* Print sheet: hidden on screen, the only thing printed after "Print" */
.print-sheet { display: none; }
@media print {
    body.is-printing-qr { background: #fff; }
    body.is-printing-qr .topbar,
    body.is-printing-qr .toasts,
    body.is-printing-qr .container > :not(.print-sheet) { display: none !important; }
    body.is-printing-qr .container { padding: 0; }
    body.is-printing-qr .print-sheet {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        min-height: 92vh; text-align: center; color: #293241;
    }
    .print-sheet__kicker { font-size: 16pt; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #3d5a80; }
    .print-sheet__title { font-size: 32pt; font-weight: 800; margin: 6pt 0 24pt; }
    .print-sheet__qr { width: 13cm; height: 13cm; }
    .print-sheet__qr svg { width: 100%; height: 100%; }
    .print-sheet__hint { font-size: 16pt; margin-top: 18pt; }
    @page { margin: 1.5cm; }
}

/* ==========================================================================
   Public read-only page
   ========================================================================== */
.public-head { background: var(--navy); color: #fff; padding-top: env(safe-area-inset-top); }
.public-head__inner {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 24px;
    padding: 20px 16px;
}
@media (min-width: 600px)  { .public-head__inner { padding: 28px 24px; } }
@media (min-width: 1280px) { .public-head__inner { padding: 32px 32px; } }
.public-head__titles { min-width: 0; }
.public-head__kicker { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--sky); }
.public-head__title { font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.5rem); font-weight: 750; line-height: 1.15; letter-spacing: -.02em; overflow-wrap: anywhere; margin-top: 2px; }

.live { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: rgba(255,255,255,.85); }
.live__dot { position: relative; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); }
.live__dot::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--orange);
    animation: pulse 2s ease-out infinite;
}
@keyframes pulse { from { transform: scale(1); opacity: .7; } to { transform: scale(2.8); opacity: 0; } }

.page-public .main { padding-bottom: 40px; }
.board__body--public { padding-bottom: 8px; }
.row--public .row__main { grid-template-columns: 34px minmax(0, 1fr) auto auto; cursor: default; }
.row--public .row__main:hover { background: transparent; }
@container board (max-width: 340px) {
    .row--public .row__main { grid-template-columns: 30px minmax(0, 1fr) auto auto; }
}

.public-missing { max-width: 420px; margin: 18vh auto 0; padding: 0 24px; text-align: center; }
.public-missing__title { font-size: 22px; font-weight: 700; }
.public-missing__text { color: var(--muted); margin-top: 8px; }

/* ==========================================================================
   Top bar event menu + mini QR
   ========================================================================== */
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.menu--topbar > summary { width: 36px; }
.menu--topbar[open] > summary { background: rgba(255,255,255,.14); color: #fff; }
.menu--topbar .menu__list { top: calc(100% + 10px); }
.menu__sep { height: 1px; margin: 6px 4px; background: var(--border); }

.page-head { align-items: center; }
.qr-mini {
    display: inline-flex; align-items: center; gap: 12px; padding: 6px 14px 6px 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); cursor: pointer; text-align: left; color: var(--text);
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.qr-mini:hover { border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.qr-mini__code { display: block; width: 88px; height: 88px; flex-shrink: 0; }
.qr-mini__code svg { display: block; width: 100%; height: 100%; }
.qr-mini__text { display: grid; gap: 2px; }
.qr-mini__title { font-size: 14px; font-weight: 700; }
.qr-mini__hint { font-size: 12px; color: var(--muted); }

/* Phones: keep it compact so the leaderboards stay in view */
@media (max-width: 599px) {
    .qr-mini { padding: 4px 12px 4px 4px; gap: 10px; }
    .qr-mini__code { width: 52px; height: 52px; }
}

/* ==========================================================================
   Versions, archive, deleted events
   ========================================================================== */
.vbadge {
    display: inline-block; vertical-align: 3px; margin-left: 4px; padding: 2px 7px;
    border-radius: 6px; font-size: 12px; font-weight: 700; letter-spacing: .02em; line-height: 1.3;
    background: rgba(255,255,255,.2); color: inherit; font-variant-numeric: tabular-nums;
}
.board--orange .vbadge, .board--sky .vbadge, .board--ice .vbadge { background: rgba(41,50,65,.12); }

.board__dates { margin-top: 6px; font-size: 12px; font-weight: 500; opacity: .85; }
.board--archived .board__head { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.07) 0 10px, transparent 10px 20px); }
.board--archived.board--ice .board__head,
.board--archived.board--sky .board__head { background-image: repeating-linear-gradient(135deg, rgba(41,50,65,.05) 0 10px, transparent 10px 20px); }

a.menu__item { color: inherit; text-decoration: none; }
.menu__item span:not(.menu__count) { white-space: nowrap; }
.menu__count {
    margin-left: auto; min-width: 24px; padding: 1px 8px; border-radius: 99px;
    background: #eef2f5; color: var(--muted); font-size: 12px; font-weight: 700; text-align: center;
}

.notice {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
    margin-bottom: 24px; padding: 16px 20px;
    background: #fff7e6; border: 1px solid #f3d9a4; border-left: 4px solid #e0a32e; border-radius: var(--radius);
}
.notice__text { flex: 1 1 320px; color: #6b4e12; font-size: 15px; }

.event-row { display: flex; align-items: stretch; gap: 8px; }
.event-row .event-card { flex: 1; min-width: 0; }
.event-card--deleted::before { background: var(--border-strong) !important; }
.event-card--deleted .event-card__name { color: var(--muted); }
.event-row__restore { display: flex; align-items: center; }

.subtle-link { margin-top: 32px; text-align: center; font-size: 14px; }
.subtle-link a { color: var(--muted); }
.subtle-link a:hover { color: var(--text); }
@media (max-width: 480px) {
    .event-row { flex-direction: column; }
    .event-row__restore .btn { width: 100%; }
}
