/* =====================================================================
   Flipeven Counter — stile unico per app e sito
   ===================================================================== */

:root {
    --bg: #f3efe6;
    --surface: #ffffff;
    --surface-2: #f7f4ee;
    --ink: #1c2430;
    --muted: #6b7380;
    --line: #e5dfd3;
    --brand: #0b6e77;
    --brand-ink: #ffffff;
    --brand-soft: #d9efef;
    --gold: #f2b134;
    --danger: #d64545;
    --ok: #2e9e6b;
    --shadow: 0 1px 2px rgba(28, 36, 48, .06), 0 6px 18px rgba(28, 36, 48, .06);
    --radius: 18px;
    --radius-sm: 12px;

    /* Colori dei giocatori */
    --p0: #e4572e; --p1: #2e86ab; --p2: #e0a21b; --p3: #3bb273;
    --p4: #7768ae; --p5: #e15a97; --p6: #17a2b8; --p7: #8c5a3c;
    --p8: #ff7f0e; --p9: #5b8c2a; --p10: #a23b72; --p11: #4a5bdc;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f151b;
        --surface: #17202a;
        --surface-2: #1d2833;
        --ink: #edf1f5;
        --muted: #98a3af;
        --line: #2a3643;
        --brand: #2bb3bd;
        --brand-ink: #062a2e;
        --brand-soft: #123c41;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Apple SD Gothic Neo", "Malgun Gothic",
        "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK JP", "Noto Sans CJK KR", "Noto Sans CJK SC", sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h1:focus, h1:focus-visible { outline: none; } /* il router mette il focus sul titolo a ogni pagina */
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; margin-top: 1.1rem; }
a { color: var(--brand); }
p { margin: .4rem 0; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; justify-content: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.full { width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.row-gap { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ------------------------------------------------------------- struttura */

/* overflow-x: clip = niente scorrimento laterale: sul telefono la pagina non si "allontana" mai */
.app-shell { position: relative; max-width: 760px; margin: 0 auto; padding: 0 14px 96px; overflow-x: clip; }
.content { min-width: 0; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 2px 2px;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-size: 1.15rem; }
.brand b { color: var(--brand); }
.brand img { border-radius: 9px; }

.topbar-actions { display: flex; gap: 8px; }

/* Seconda riga: "← Partite" a sinistra, storico e impostazioni a destra */
.topnav { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 6px 2px 4px; }
.topnav-actions { margin-left: auto; display: flex; gap: 8px; }
.back-link {
    display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px 0 12px;
    border-radius: 99px; background: var(--surface); box-shadow: var(--shadow);
    color: var(--ink); font-weight: 700; text-decoration: none;
    animation: fade-in .2s ease both;
}
.back-link span { color: var(--brand); font-size: 1.2rem; line-height: 1; }
.back-link:active { transform: scale(.97); }

.topbar-link {
    width: 40px; height: 40px; border-radius: 50%;
    display: grid; place-items: center; text-decoration: none; font-weight: 700;
    background: var(--surface); color: var(--muted); box-shadow: var(--shadow);
}
.topbar-link.active { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand), var(--shadow); }

.content > * + * { margin-top: 14px; }

.footer { text-align: center; margin-top: 28px; }
.footer a { color: var(--muted); }

.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.center-card { text-align: center; padding: 28px 18px; }
.page-title { margin: 6px 2px 4px; }
.section-title { margin: 18px 4px 8px; color: var(--muted); font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; }

/* ------------------------------------------------------------- pulsanti */

.btn {
    appearance: none; border: 0; cursor: pointer; text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 44px; padding: 0 16px; border-radius: 999px;
    font: inherit; font-weight: 600;
    background: var(--surface-2); color: var(--ink);
    transition: transform .08s ease, background-color .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: 1.05rem; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.btn-xs { min-height: 28px; padding: 0 10px; font-size: .8rem; }
.btn-round { width: 44px; padding: 0; font-size: 1.3rem; }
.danger-text { color: var(--danger); }

.icon-btn {
    appearance: none; border: 0; background: transparent; cursor: pointer;
    min-width: 40px; height: 40px; border-radius: 12px; font-size: 1.1rem; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.small { min-width: 30px; height: 30px; font-size: .9rem; }

.chip {
    appearance: none; border: 0; cursor: pointer; font: inherit;
    padding: 6px 12px; border-radius: 999px; background: var(--surface-2); color: var(--ink);
    box-shadow: inset 0 0 0 1.5px var(--line);
}
.chip-on { background: var(--brand); color: var(--brand-ink); box-shadow: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.badge {
    display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
    background: var(--brand-soft); color: var(--brand); font-size: .75rem; font-weight: 700; vertical-align: middle;
}

.me {
    display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px;
    background: var(--ink); color: var(--bg); font-size: .7rem; font-weight: 700; vertical-align: middle;
}

.dot {
    display: inline-block; flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%;
    background: var(--c, var(--brand)); margin-right: 8px; vertical-align: middle;
}

/* ------------------------------------------------------------- moduli */

.input {
    font: inherit; color: var(--ink); background: var(--surface-2);
    border: 1.5px solid var(--line); border-radius: var(--radius-sm);
    min-height: 44px; padding: 0 12px; width: 100%;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-num { width: 110px; }
.input-code { font-size: 1.6rem; letter-spacing: .25em; text-transform: uppercase; text-align: center; font-weight: 700; min-height: 60px; }
.input-big { font-size: 2.4rem; text-align: center; font-weight: 800; min-height: 72px; font-variant-numeric: tabular-nums; }
.input-score { width: 92px; text-align: center; font-weight: 700; }
select.input { padding-right: 32px; }
.label { display: block; font-weight: 600; margin: .6rem 0 .3rem; }
.hint { color: var(--muted); font-size: .85rem; }
.error { color: var(--danger); font-weight: 600; }

.form-section h2 { margin-bottom: .75rem; }
.name-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.name-list li { display: flex; align-items: center; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper-value { min-width: 2ch; text-align: center; font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice {
    appearance: none; border: 0; cursor: pointer; font: inherit; color: var(--ink); text-align: left;
    display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: var(--radius-sm);
    background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line);
}
.choice small { color: var(--muted); }
.choice-icon { font-size: 1.6rem; }
.choice-on { box-shadow: inset 0 0 0 2.5px var(--brand); background: var(--brand-soft); }

.radio-list { display: grid; gap: 8px; }
.radio {
    display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--radius-sm);
    background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line); cursor: pointer;
}
.radio input { margin-top: 4px; accent-color: var(--brand); width: 18px; height: 18px; }
.radio small { display: block; color: var(--muted); }
.radio-on { box-shadow: inset 0 0 0 2px var(--brand); }
.radio-list.compact .radio { padding: 9px 11px; }

.switch { display: flex; gap: 10px; align-items: center; margin: 12px 0; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--danger); }

.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; }

.sticky-actions {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; gap: 10px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ------------------------------------------------------------- home */

.hero { position: relative; overflow: hidden; padding: 22px 18px; }
.hero h1 { font-size: 1.7rem; max-width: 15ch; }
.hero p { max-width: 46ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.hero-cards { position: absolute; right: 14px; top: 10px; width: 120px; height: 110px; pointer-events: none; }
.mini-card {
    position: absolute; width: 52px; height: 72px; border-radius: 10px;
    display: grid; place-items: center; font-weight: 900; font-size: 1.35rem; color: #fff;
    box-shadow: var(--shadow);
}
.mini-card.c1 { background: var(--p1); transform: rotate(-16deg); right: 58px; top: 14px; }
.mini-card.c2 { background: var(--p0); transform: rotate(-2deg); right: 30px; top: 6px; }
.mini-card.c3 { background: var(--gold); transform: rotate(14deg); right: 4px; top: 16px; color: #3a2a00; }

/* minmax(0, 1fr) + min-width: 0: i testi lunghi si accorciano con "…" invece di allargare la pagina */
.game-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.game-item { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 14px; min-width: 0; }
.game-item-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-decoration: none; color: var(--ink); }
.game-item-icon { font-size: 1.4rem; }
.game-item-text { display: flex; flex-direction: column; min-width: 0; }
.game-item-text b, .game-item-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------- partita */

.game > * + * { margin-top: 12px; }
.game-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.game-title h1 { margin: 2px 0 0; }

.share-chip {
    appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700;
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
    background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow); white-space: nowrap;
}
.share-chip .code { letter-spacing: .12em; padding: 1px 8px; border-radius: 8px; background: rgba(255, 255, 255, .2); }
.conn { width: 9px; height: 9px; border-radius: 50%; background: #f5c542; }
.conn-connected { background: #6ee7a8; }
.conn-disconnected { background: #ff7b7b; }

.banner { border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.banner-info { background: var(--surface-2); color: var(--muted); }
.banner-warn { background: #fff1d6; color: #6b4a00; }
.banner-win { background: linear-gradient(120deg, #fff4d4, #ffe0c2); color: #4a2e00; animation: pop-in .5s ease both; }
@media (prefers-color-scheme: dark) {
    .banner-warn { background: #3a2f12; color: #ffe2a3; }
    .banner-win { background: linear-gradient(120deg, #4a3a10, #4a2a14); color: #ffe7c2; }
}

.open-in-app {
    display: block; text-align: center; padding: 10px; border-radius: var(--radius-sm);
    background: var(--brand-soft); text-decoration: none; font-weight: 600;
}

/* classifica */
.scoreboard { padding: 8px 10px; }
.standings { list-style: none; margin: 0; padding: 0; }
.standing {
    display: flex; align-items: center; gap: 12px; padding: 10px 6px;
    border-bottom: 1px solid var(--line);
    animation: slide-in .35s ease both;
}
.standing:last-child { border-bottom: 0; }
.standing.over .total { color: var(--brand); }
.standing.winner { background: linear-gradient(90deg, rgba(242, 177, 52, .16), transparent); border-radius: 12px; }
.rank {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 800; font-size: .9rem;
    background: var(--surface-2); color: var(--muted);
}
.rank-1 { background: var(--gold); color: #3a2a00; }
.rank-2 { background: #cfd6de; color: #2b3440; }
.rank-3 { background: #e3b48a; color: #3d2410; }
.standing-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.standing-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.standing-meta span + span { margin-left: 2px; }
.bar { display: block; height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--c); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.total {
    font-size: 1.7rem; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right;
    animation: bump .45s ease;
}

/* round in corso */
.pill-count { font-size: .85rem; font-weight: 700; color: var(--muted); background: var(--surface-2); padding: 3px 10px; border-radius: 999px; }
.round-rows { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.round-row {
    display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 4px 6px 4px 10px;
    border-radius: var(--radius-sm); background: var(--surface-2);
}
.round-row.mine { box-shadow: inset 0 0 0 2px var(--brand); }
.round-row.done { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.round-row.mine.done { box-shadow: inset 0 0 0 2px var(--brand); }
.round-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick { display: flex; align-items: center; gap: 2px; }
.waiting { padding-right: 8px; }
.score-pill {
    appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 800; font-size: 1.1rem;
    min-width: 72px; height: 40px; padding: 0 12px; border-radius: 999px;
    background: var(--brand-soft); color: var(--brand); font-variant-numeric: tabular-nums;
    animation: pop-in .3s ease both;
}
.score-pill:disabled { cursor: default; }
.score-pill.tag-bust { background: #fde3e3; color: var(--danger); }
.score-pill.tag-flip7 { background: #fff1c9; color: #8a5a00; }

/* tabella */
/* position: relative: anche le etichette invisibili restano dentro la tabella che scorre */
.table-wrap { position: relative; overflow-x: auto; margin: 8px -6px 0; padding: 0 6px; }
.rounds { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
.rounds th, .rounds td { padding: 8px 8px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line); }
.rounds thead th { font-size: .8rem; color: var(--muted); font-weight: 700; }
.rounds thead .dot { width: 8px; height: 8px; margin-right: 4px; }
.rounds .rn { color: var(--muted); font-weight: 700; text-align: left; position: sticky; left: 0; background: var(--surface); }
.rounds tfoot th { border-bottom: 0; font-size: 1.05rem; font-weight: 900; padding-top: 10px; }
.rounds tr.open td { background: var(--surface-2); }
.rounds td.editable { cursor: pointer; }
.rounds td.editable:hover { background: var(--brand-soft); }
.rounds td.empty { color: var(--muted); }
.rounds td.tag-bust { color: var(--danger); }
.rounds td.tag-flip7 { color: #b07800; font-weight: 800; }
.rounds .actions { width: 1%; }

/* giocatori */
.player-rows { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 4px; }
.player-row { display: flex; align-items: center; gap: 6px; min-height: 46px; border-bottom: 1px solid var(--line); }
.player-row:last-child { border-bottom: 0; }
.player-name { font-weight: 600; }
.settings { margin-top: 14px; padding-top: 6px; border-top: 1px dashed var(--line); }

.history { margin: 6px 0 0; padding-left: 18px; }
.wins { display: flex; gap: 6px; flex-wrap: wrap; }

/* ------------------------------------------------------------- finestre */

.modal-backdrop {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(10, 16, 22, .5);
    display: flex; align-items: flex-end; justify-content: center;
    animation: fade-in .18s ease both;
}
.modal {
    width: 100%; max-width: 560px; max-height: 92vh; overflow: auto;
    background: var(--surface); border-radius: 22px 22px 0 0;
    padding: 6px 16px calc(16px + env(safe-area-inset-bottom));
    animation: sheet-up .25s cubic-bezier(.2, .8, .2, 1) both;
}
@media (min-width: 640px) {
    .modal-backdrop { align-items: center; }
    .modal { border-radius: 22px; }
}
.modal-header { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--surface); padding: 8px 0; z-index: 1; }
.modal-header h2 { margin: 0; }
.modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.segmented button { appearance: none; border: 0; background: transparent; font: inherit; font-weight: 700; min-height: 38px; border-radius: 999px; color: var(--muted); cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.number-entry { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }

.card-grid { display: grid; gap: 7px; }
.card-grid.numbers { grid-template-columns: repeat(7, 1fr); }
.card-grid.mods { grid-template-columns: repeat(6, 1fr); }
.play-card {
    appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 900; font-size: 1.05rem;
    aspect-ratio: 5 / 7; border-radius: 9px; background: var(--surface-2); color: var(--ink);
    box-shadow: inset 0 0 0 1.5px var(--line);
    transition: transform .12s ease, background-color .12s ease;
}
.play-card:disabled { opacity: .35; }
.play-card.on { background: var(--brand); color: var(--brand-ink); box-shadow: none; transform: translateY(-3px); }
.play-card.mod { aspect-ratio: auto; min-height: 46px; font-size: .95rem; }
.play-card.mod.on { background: var(--gold); color: #3a2a00; }
.play-card.x2.on { background: #e15a97; color: #fff; }

.breakdown {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; margin-top: 12px;
    padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-variant-numeric: tabular-nums;
}
.breakdown-total { margin-left: auto; font-size: 1.4rem; }
.breakdown.flip7 { background: #fff1c9; color: #6b4a00; }
.breakdown.busted { background: #fde3e3; color: var(--danger); }
.flip7-badge { font-weight: 900; animation: pulse 1s ease-in-out infinite; }

.share-panel .qr { display: block; margin: 8px auto; width: 220px; height: 220px; border-radius: 12px; image-rendering: pixelated; background: #fff; padding: 6px; }
.big-code { text-align: center; font-size: 2.2rem; font-weight: 900; letter-spacing: .25em; margin-top: 6px; }
.link-text { text-align: center; color: var(--muted); font-size: .85rem; word-break: break-all; }

.seat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.seat {
    appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; color: var(--ink);
    min-height: 54px; border-radius: var(--radius-sm); background: var(--surface-2);
    box-shadow: inset 0 0 0 2px var(--c);
}

.toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
    z-index: 60; max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 14px;
    background: #222b36; color: #fff; box-shadow: var(--shadow); animation: toast-in .25s ease both;
}

.loading { text-align: center; padding: 48px 0; }
.spinner {
    width: 36px; height: 36px; margin: 0 auto 12px; border-radius: 50%;
    border: 4px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite;
}

.prose ol, .prose ul { padding-left: 20px; }
.prose li { margin: 6px 0; }
.example { margin: 12px 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--brand-soft); }

/* ------------------------------------------------------------- benvenuto e lingue */

.welcome { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.welcome-card { width: 100%; max-width: 520px; text-align: center; padding: 24px 18px; animation: pop-in .4s ease both; }
.welcome-card h2 { margin-top: 18px; }
.welcome-card .label, .welcome-card .hint { text-align: left; }
.welcome-card .btn { margin-top: 16px; }
.welcome-logo { border-radius: 16px; }

.language-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* Impostazioni: riga che si apre (es. Lingua) */
.setting-row {
    appearance: none; border: 0; background: transparent; cursor: pointer; font: inherit; color: var(--ink);
    width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 0; text-align: left;
}
.setting-label { flex: 1; font-weight: 800; font-size: 1.1rem; }
.setting-value { color: var(--brand); font-weight: 700; }
.setting-expand { margin-top: 12px; animation: slide-in .22s ease both; }
.language {
    appearance: none; border: 0; cursor: pointer; font: inherit; color: var(--ink); text-align: left;
    display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px;
    border-radius: var(--radius-sm); background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line);
}
.language.on { box-shadow: inset 0 0 0 2.5px var(--brand); background: var(--brand-soft); font-weight: 700; }
.language-code {
    font-size: .7rem; font-weight: 800; letter-spacing: .05em; color: var(--muted);
    background: var(--surface); border-radius: 6px; padding: 2px 6px;
}

/* ------------------------------------------------------------- storico */

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; text-align: center; }
.stat { display: flex; flex-direction: column; padding: 8px 4px; border-radius: var(--radius-sm); background: var(--surface-2); }
.stat b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); }

.content > .list-toolbar { margin-top: 26px; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.list-toolbar .section-title { margin: 0 4px; }

.sort-toggle { display: inline-flex; padding: 3px; gap: 2px; border-radius: 99px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.sort-toggle button {
    appearance: none; border: 0; background: transparent; cursor: pointer; font: inherit; font-size: .85rem; font-weight: 700;
    color: var(--muted); padding: 6px 14px; border-radius: 99px; transition: background .15s, color .15s;
}
.sort-toggle button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

.history-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.history-item { padding: 6px 12px 10px; min-width: 0; }
.history-item.won { box-shadow: var(--shadow), inset 4px 0 0 var(--gold); }
.history-head {
    appearance: none; border: 0; background: transparent; cursor: pointer; font: inherit; color: var(--ink);
    width: 100%; display: flex; align-items: center; gap: 12px; padding: 6px 0; text-align: left;
}
.history-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.history-text b, .history-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-details { animation: slide-in .22s ease both; padding-bottom: 2px; }
.history-details .btn { margin-top: 2px; }
.medal { font-size: 1.8rem; }
.chevron { color: var(--muted); }
.final-list.compact li { animation: none; padding: 6px 8px; }
.final-list .me-row { background: var(--brand-soft); }
.empty-icon { font-size: 2.6rem; margin: 0; }

/* ------------------------------------------------------------- vittoria */

.celebration {
    position: fixed; inset: 0; z-index: 50; overflow: hidden;
    display: grid; place-items: center; padding: 16px;
    background: radial-gradient(circle at 50% 30%, rgba(11, 110, 119, .92), rgba(6, 30, 36, .96));
    animation: fade-in .3s ease both;
}
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i {
    position: absolute; top: -20px;
    width: var(--w, 8px); height: calc(var(--w, 8px) * 1.6); border-radius: 2px;
    animation: confetti-fall var(--dur, 3s) linear var(--delay, 0s) forwards;
    opacity: 0;
}
.celebration-card {
    position: relative; width: 100%; max-width: 460px; max-height: 92vh; overflow: auto;
    background: var(--surface); color: var(--ink); border-radius: 26px;
    padding: 20px 18px 18px; text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    animation: card-rise .55s cubic-bezier(.2, .9, .25, 1.2) .1s both;
}
.trophy { font-size: 4rem; line-height: 1; animation: trophy-pop .8s cubic-bezier(.2, .9, .3, 1.4) .35s both; }
.winner-name {
    font-size: 2rem; margin: 6px 0 0; color: var(--c);
    animation: pop-in .5s ease .6s both;
}
.winner-sub { margin-top: 2px; animation: fade-in .4s ease .8s both; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 16px 0 8px; height: 170px; }
.step { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 31%; max-width: 120px; }
.step-name { font-weight: 800; font-size: .9rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; animation: fade-in .3s ease both; }
.step-total { font-weight: 900; color: var(--muted); font-variant-numeric: tabular-nums; animation: fade-in .3s ease both; }
.step-block {
    width: 100%; margin-top: 4px; border-radius: 12px 12px 4px 4px;
    display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 1.3rem;
    background: var(--c); transform-origin: bottom;
    animation: grow-up .7s cubic-bezier(.2, .9, .3, 1.2) both;
}
.step-1 .step-block { height: 104px; animation-delay: 1.15s; box-shadow: 0 0 0 3px var(--gold); }
.step-2 .step-block { height: 76px; animation-delay: .95s; }
.step-3 .step-block { height: 56px; animation-delay: .8s; }
.step-1 .step-name, .step-1 .step-total { animation-delay: 1.6s; }
.step-2 .step-name, .step-2 .step-total { animation-delay: 1.4s; }
.step-3 .step-name, .step-3 .step-total { animation-delay: 1.25s; }

.final-list { list-style: none; padding: 0; margin: 10px 0 0; text-align: left; }
.final-list li {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px;
    animation: slide-in .4s ease both; animation-delay: calc(1.7s + var(--i) * .12s);
}
.final-list li.over { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 18%, transparent), transparent); }
.final-list .rank { width: 26px; height: 26px; font-size: .8rem; }
.final-list .name { flex: 1; min-width: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.final-list .pts { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.final-list .badge { margin: 0; }

/* ------------------------------------------------------------- animazioni */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(.85); } 70% { transform: scale(1.04); } 100% { opacity: 1; transform: scale(1); } }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(40px); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); color: var(--brand); } 100% { transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes card-rise { from { opacity: 0; transform: translateY(60px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes trophy-pop { 0% { opacity: 0; transform: scale(.2) rotate(-25deg); } 60% { opacity: 1; transform: scale(1.25) rotate(8deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes grow-up { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes confetti-fall {
    0% { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translate3d(var(--drift, 0), 105vh, 0) rotate(var(--spin, 720deg)); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
    .confetti { display: none; }
}

/* ------------------------------------------------------------- schermi piccoli */

@media (max-width: 480px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .input-score { width: 76px; }
    .choice-grid { grid-template-columns: minmax(0, 1fr); }
    .hero-cards { position: static; display: flex; width: auto; height: 46px; margin-bottom: 8px; }
    .hero-cards .mini-card { position: static; width: 32px; height: 44px; font-size: .9rem; border-radius: 7px; margin-right: -4px; }
    .card-grid.numbers { grid-template-columns: repeat(5, 1fr); }
    .card-grid.mods { grid-template-columns: repeat(3, 1fr); }
    .total { font-size: 1.45rem; }
}

/* Errore non gestito di Blazor */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    padding: 12px 16px; background: #fff3cd; color: #5c4400; box-shadow: var(--shadow);
}
#blazor-error-ui .dismiss { float: right; cursor: pointer; }
