/* SektELO premium UI — shared across every view. */
:root {
    --ink-950: #091525;
    --ink-900: #10233f;
    --ink-800: #173452;
    --ink-700: #284966;
    --ink-600: #4f6578;
    --ink-500: #718292;
    --paper: #f5f3ee;
    --surface: rgba(255, 255, 255, 0.92);
    --line: rgba(16, 35, 63, 0.11);
    --line-strong: rgba(16, 35, 63, 0.2);
    --gold: #c99a45;
    --gold-dark: #9b6f24;
    --gold-soft: #fbf3df;
    --teal: #28776f;
    --teal-dark: #185c56;
    --teal-soft: #e8f4f1;
    --danger: #b8474f;
    --danger-soft: #faecec;
    --shadow-sm: 0 8px 24px rgba(10, 25, 43, 0.07);
    --shadow-md: 0 18px 50px rgba(10, 25, 43, 0.12);
    --shadow-lg: 0 30px 80px rgba(10, 25, 43, 0.17);
    --radius-md: 18px;
    --radius-lg: 28px;
    --ease: 180ms cubic-bezier(.2, .8, .2, 1);
}

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

html {
    min-height: 100%;
    color-scheme: light;
    background: var(--paper);
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 0 1rem 4rem;
    overflow-x: hidden;
    color: var(--ink-900);
    background:
        radial-gradient(circle at 8% 5%, rgba(201, 154, 69, 0.13), transparent 28rem),
        radial-gradient(circle at 92% 12%, rgba(40, 119, 111, 0.1), transparent 30rem),
        linear-gradient(180deg, #fbfaf7 0%, var(--paper) 58%, #efede7 100%);
    font-family: Inter, "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

body::before, body::after {
    position: fixed;
    z-index: 0;
    width: 20rem;
    height: 20rem;
    border-radius: 50%;
    pointer-events: none;
    content: "";
    opacity: 0.35;
}

body::before {
    top: -14rem;
    right: -7rem;
    border: 1px solid rgba(201, 154, 69, 0.25);
}

body::after {
    bottom: -15rem;
    left: -8rem;
    border: 1px solid rgba(40, 119, 111, 0.22);
}

.container {
    position: relative;
    z-index: 1;
    width: min(100%, 1120px);
    max-width: 1120px;
    margin-inline: auto;
    padding-inline: 0;
}

.narrow-shell { max-width: 720px; }

h1, h2, h3, h4, h5, h6 {
    color: var(--ink-950);
    font-family: "Segoe UI Variable Display", Inter, "Segoe UI", sans-serif;
    letter-spacing: -0.025em;
}

h1 {
    margin: 0;
    color: var(--ink-950);
    font-size: clamp(2.35rem, 6vw, 4rem);
    font-weight: 780;
    line-height: 1.02;
    text-align: center;
}

a { color: var(--teal-dark); }
button, input, select, textarea { font: inherit; }
button, .btn, [role="button"] { -webkit-tap-highlight-color: transparent; }

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

button:focus-visible, .btn:focus-visible, a:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(201, 154, 69, 0.38);
    outline-offset: 2px;
}

/* Shared page heading */
.page-heading {
    max-width: 760px;
    margin: 0 auto 1.7rem;
    padding-top: clamp(2rem, 7vw, 4.5rem);
    text-align: center;
}

.page-kicker, .hero-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 0.75rem;
    color: var(--gold-dark);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.page-kicker::before, .page-kicker::after,
.hero-kicker::before, .hero-kicker::after {
    width: 1.35rem;
    height: 1px;
    background: currentColor;
    content: "";
    opacity: 0.55;
}

.page-intro {
    max-width: 590px;
    margin: 0.75rem auto 0;
    color: var(--ink-600);
    font-size: 1rem;
}

/* Home */
.page-home { padding-top: 1rem; }
.home-shell { width: min(100%, 1080px); }

.home-hero {
    position: relative;
    display: grid;
    min-height: 320px;
    place-items: center;
    overflow: hidden;
    margin-top: 1rem;
    padding: 3.25rem 1.5rem 5.75rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    color: #fff;
    background:
        radial-gradient(circle at 88% 10%, rgba(201, 154, 69, 0.25), transparent 16rem),
        radial-gradient(circle at 6% 100%, rgba(59, 139, 130, 0.22), transparent 20rem),
        linear-gradient(135deg, #0b192b 0%, #102d49 58%, #173e50 100%);
    box-shadow: var(--shadow-lg);
    isolation: isolate;
}

.home-hero::before {
    position: absolute;
    inset: 1rem;
    z-index: -1;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: calc(var(--radius-lg) - 9px);
    content: "";
}

.home-hero::after {
    position: absolute;
    top: -6rem;
    right: -5rem;
    z-index: -1;
    width: 18rem;
    height: 18rem;
    border: 1px solid rgba(230, 196, 132, 0.2);
    border-radius: 50%;
    content: "";
}

.hero-content { text-align: center; }

.brand-mark {
    display: grid;
    width: 3rem;
    height: 3rem;
    place-items: center;
    margin: 0 auto 1rem;
    border: 1px solid rgba(230, 196, 132, 0.48);
    border-radius: 14px;
    color: #f4d99e;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.12);
    font-size: 0.9rem;
    font-weight: 850;
    letter-spacing: 0.08em;
}

.home-hero .hero-kicker { color: #e3bf78; }

.home-hero h1 {
    color: #fff;
    font-size: clamp(3.2rem, 10vw, 5.35rem);
    letter-spacing: -0.055em;
    text-shadow: 0 6px 30px rgba(0, 0, 0, 0.18);
}

.home-hero h1 span { color: #e2bd75; }

.hero-copy {
    max-width: 580px;
    margin: 0.85rem auto 0;
    color: rgba(255, 255, 255, 0.7);
    font-size: clamp(0.98rem, 2vw, 1.12rem);
}

.home-panel {
    position: relative;
    z-index: 2;
    margin: -3.35rem 2rem 0;
    padding: 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(18px);
}

.home-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    margin-bottom: 1.35rem;
}

.search-field { position: relative; }
.search-field::before {
    position: absolute;
    top: 50%;
    left: 1rem;
    width: 0.85rem;
    height: 0.85rem;
    border: 2px solid var(--ink-500);
    border-radius: 50%;
    content: "";
    pointer-events: none;
    transform: translateY(-58%);
}

.search-field::after {
    position: absolute;
    top: calc(50% + 6px);
    left: 1.72rem;
    width: 0.42rem;
    height: 2px;
    background: var(--ink-500);
    content: "";
    pointer-events: none;
    transform: rotate(45deg);
    transform-origin: left center;
}

#search-bar {
    width: 100%;
    max-width: none;
    height: 3.45rem;
    margin: 0;
    padding: 0.85rem 1rem 0.85rem 3rem;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    color: var(--ink-900);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: inset 0 1px 2px rgba(10, 25, 43, 0.04);
    transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

#search-bar:focus {
    border-color: rgba(40, 119, 111, 0.72);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(40, 119, 111, 0.1);
    outline: 0;
}

#ny-liga-btn, .install-app-btn {
    min-height: 3.45rem;
    margin: 0;
    padding: 0.85rem 1.4rem;
    border: 0;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
    box-shadow: 0 10px 24px rgba(24, 92, 86, 0.2), inset 0 1px rgba(255, 255, 255, 0.2);
    font-weight: 750;
    cursor: pointer;
    transition: transform var(--ease), box-shadow var(--ease), filter var(--ease);
}

#ny-liga-btn:hover, .install-app-btn:hover {
    background: linear-gradient(135deg, #31857c 0%, var(--teal-dark) 100%);
    box-shadow: 0 14px 30px rgba(24, 92, 86, 0.25);
    filter: saturate(1.04);
    transform: translateY(-1px);
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.35rem 0.25rem 0.85rem;
}
.section-heading h2 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.section-meta { margin: 0; color: var(--ink-500); font-size: 0.82rem; font-weight: 650; }

.table-shell, .ranking-card, .summary-card, .match-builder-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.home-panel .table-shell { box-shadow: none; }

.page-home table, .ranking-card table, .summary-card table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    box-shadow: none;
}

.page-home th, .page-home td,
.ranking-card th, .ranking-card td,
.summary-card th, .summary-card td {
    padding: 1rem 1.15rem;
    border: 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.page-home th, .ranking-card th, .summary-card th {
    color: var(--ink-500);
    background: rgba(16, 35, 63, 0.035);
    font-size: 0.71rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.page-home tbody tr, .ranking-card tbody tr, .summary-card tbody tr {
    background: transparent;
    transition: background var(--ease), transform var(--ease);
}

.page-home tbody tr:hover, .ranking-card tbody tr:hover, .summary-card tbody tr:hover {
    background: rgba(40, 119, 111, 0.055);
}

.page-home tbody tr:last-child td, .ranking-card tbody tr:last-child td,
.summary-card tbody tr:last-child td { border-bottom: 0; }
.page-home #ligor-tbody td:first-child { color: var(--ink-950); font-weight: 800; }

#loader {
    padding: 2rem;
    color: var(--ink-500);
    font-size: 0.95rem;
    text-align: center;
}

/* Buttons */
.btn, .app-btn {
    --bs-btn-border-radius: 12px;
    display: inline-flex;
    min-height: 2.8rem;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.62rem 1rem;
    border-radius: 12px;
    font-weight: 720;
    letter-spacing: -0.01em;
    transition: transform var(--ease), box-shadow var(--ease), background var(--ease), border-color var(--ease);
}

.btn:hover, .app-btn:hover { transform: translateY(-1px); }
.btn:active, .app-btn:active { transform: translateY(0); }

.btn-primary {
    border-color: var(--ink-900) !important;
    color: #fff !important;
    background: linear-gradient(135deg, var(--ink-800), var(--ink-900)) !important;
    box-shadow: 0 9px 20px rgba(16, 35, 63, 0.16);
}

.btn-success {
    border-color: var(--teal) !important;
    color: #fff !important;
    background: linear-gradient(135deg, #35877d, var(--teal-dark)) !important;
    box-shadow: 0 9px 20px rgba(24, 92, 86, 0.15);
}

.btn-info { border-color: #bed3df !important; color: var(--ink-800) !important; background: #e9f4f6 !important; }
.btn-warning {
    border-color: #d8ad5e !important;
    color: #422d0d !important;
    background: linear-gradient(135deg, #efd18c, #d4a750) !important;
    box-shadow: 0 9px 20px rgba(155, 111, 36, 0.12);
}

.btn-secondary, .btn-outline-secondary {
    border-color: var(--line-strong) !important;
    color: var(--ink-700) !important;
    background: rgba(255, 255, 255, 0.74) !important;
}

.btn-danger, .btn-danger-custom, .app-btn-danger {
    border-color: var(--danger) !important;
    color: #fff !important;
    background: var(--danger) !important;
}

.btn-custom { margin: 0; }

/* Forms */
.form-control, .form-select, .select2-container .select2-selection--single {
    min-height: 3rem;
    border-color: var(--line-strong);
    border-radius: 12px;
    color: var(--ink-900);
    background-color: rgba(255, 255, 255, 0.92);
    box-shadow: inset 0 1px 2px rgba(10, 25, 43, 0.03);
}

.form-control, .form-select { padding: 0.72rem 0.9rem; }
textarea.form-control { min-height: 6.5rem; }
.form-control::placeholder { color: #8b98a3; }

.form-control:focus, .form-select:focus, .select2-container--focus .select2-selection--single {
    border-color: rgba(40, 119, 111, 0.7);
    box-shadow: 0 0 0 4px rgba(40, 119, 111, 0.1);
}

.form-label {
    margin-bottom: 0.45rem;
    color: var(--ink-700);
    font-size: 0.82rem;
    font-weight: 780;
    letter-spacing: 0.015em;
}

.form-container, .match-builder-card {
    max-width: 680px;
    margin: 0 auto;
    padding: clamp(1.15rem, 4vw, 2rem);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(16px);
}

.form-container::before, .match-builder-card::before, .composer-card::before {
    display: block;
    width: 2.6rem;
    height: 3px;
    margin-bottom: 1.4rem;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--gold), #e5c57d);
    content: "";
}

.form-actions, .summary-actions, .history-actions, .composer-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.7rem;
    margin-top: 1.25rem;
}

/* League */
.league-heading { margin-bottom: 1.35rem; }

.action-deck {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 17px;
    background: rgba(255, 255, 255, 0.64);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.65rem;
    margin: 0;
}

.notification-badge {
    min-width: 1.45rem;
    min-height: 1.45rem;
    margin-left: 0.15rem;
    padding: 0.12rem 0.4rem;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 999px;
    background: var(--danger);
    line-height: 1.05;
}

.ranking-card { overflow: visible; }

.ranking-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto;
    gap: 0.8rem;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--line);
}

.ranking-toolbar .form-control { margin: 0 !important; }
.ranking-toolbar .nav-tabs {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 0.25rem;
    margin: 0 !important;
    padding: 0.25rem;
    border: 0;
    border-radius: 12px;
    background: rgba(16, 35, 63, 0.055);
}
.ranking-toolbar .nav-item { display: flex; }
.ranking-toolbar .nav-link {
    min-height: 2.5rem;
    padding: 0.48rem 0.75rem;
    border: 0;
    border-radius: 9px;
    color: var(--ink-600);
    font-weight: 720;
    white-space: nowrap;
}
.ranking-toolbar .nav-link.active {
    color: var(--ink-900);
    background: #fff;
    box-shadow: 0 4px 12px rgba(10, 25, 43, 0.08);
}
.ranking-toolbar .form-check { min-height: auto; margin: 0 !important; white-space: nowrap; }
.form-check-input:checked { border-color: var(--teal); background-color: var(--teal); }
.form-check-label { color: var(--ink-600); font-size: 0.84rem; font-weight: 650; }

.league-table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius-md) var(--radius-md); }
.ranking-card .table { --bs-table-striped-bg: rgba(16, 35, 63, 0.025); --bs-table-hover-bg: rgba(40, 119, 111, 0.055); }
.ranking-card tbody td:first-child { width: 5.5rem; color: var(--gold-dark); font-size: 0.9rem; font-weight: 850; }
.ranking-card tbody td:nth-child(2) { color: var(--ink-900); font-weight: 680; }
.ranking-card tbody td:nth-child(3) { font-variant-numeric: tabular-nums; font-weight: 820; }

.star {
    display: inline-grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    margin-right: 0.35rem;
    border-radius: 50%;
    color: var(--ink-500);
    font-size: 1.08rem;
    transition: background var(--ease), color var(--ease), transform var(--ease);
}
.star:hover { background: var(--gold-soft); transform: scale(1.06); }
.star.filled { color: var(--gold); }
.chevron {
    display: inline-grid;
    width: 1.5rem;
    height: 1.5rem;
    place-items: center;
    float: none;
    margin-left: 0.2rem;
    color: var(--ink-500);
    font-size: 0.74rem;
}

.extra-info {
    padding: 1.15rem;
    color: var(--ink-700);
    background: linear-gradient(180deg, rgba(234, 241, 248, 0.75), rgba(255, 255, 255, 0.95));
}
.chart-panel, .teammate-panel { border-color: var(--line); border-radius: 15px; box-shadow: var(--shadow-sm); }
.teammate-row, .shared-match-card { border-color: var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.8); }
.teammate-rank { background: var(--ink-900); }
.teammate-bar span { background: linear-gradient(90deg, var(--teal), var(--gold)); }
.teammate-count-pill, .shared-stat { color: var(--teal-dark); background: var(--teal-soft); }
.shared-stat strong { color: var(--teal-dark); }

/* Match builder */
.match-builder-card { max-width: 820px; }
.team-container {
    margin-bottom: 0.9rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: rgba(250, 250, 248, 0.86);
    box-shadow: none;
}
.team-header { margin-bottom: 0.55rem; }
.team-header h5 { margin: 0; font-size: 1rem; font-weight: 800; }
.team-header input[type="radio"] { width: 1.15rem; height: 1.15rem; accent-color: var(--gold); }
.player-badge {
    margin: 0.35rem 0.4rem 0 0;
    padding: 0.42rem 0.75rem 0.42rem 2rem;
    border: 1px solid rgba(40, 119, 111, 0.16);
    border-radius: 999px;
    color: var(--teal-dark);
    background: var(--teal-soft);
    font-weight: 680;
}
.player-badge button.remove {
    top: -5px;
    right: -5px;
    width: 1.35rem;
    height: 1.35rem;
    border: 2px solid #fff;
    color: #fff;
    background: var(--danger);
    line-height: 1;
}
.favorite-star { color: var(--gold-dark); }
.select2-container { width: 100% !important; }
.select2-container .select2-selection--single { height: 3rem; padding: 0.55rem; }
.select2-container--default .select2-selection--single .select2-selection__arrow { top: 0.7rem; right: 0.5rem; }

/* Guestbook */
.guestbook-shell { max-width: 860px; }
.composer-card, .comment-card {
    border-color: var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.composer-card { position: relative; padding: clamp(1rem, 4vw, 1.6rem); }
.comment-card { padding: 1rem 1.1rem; }
.comment-card.reply { border-left-color: var(--gold); }
.comment-author { color: var(--ink-900); }
.comment-meta, .player-help, .reaction-names { color: var(--ink-500); }
.reaction-btn, .reaction-add-btn, .emoji-btn, .thread-toggle-btn { border-color: var(--line); background: rgba(255, 255, 255, 0.85); }
.reaction-btn.active { border-color: rgba(40, 119, 111, 0.4); color: var(--teal-dark); background: var(--teal-soft); }
.emoji-btn { border-radius: 10px; }

/* History and summary */
.history-toolbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}
.history-toolbar .mb-3, .history-toolbar .history-actions { margin: 0 !important; }
.match-row {
    margin-bottom: 0.85rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
.match-row:hover { border-color: rgba(40, 119, 111, 0.25); background: #fff; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.badge-team, .badge-loser {
    display: inline-flex;
    align-items: center;
    margin: 0.25rem 0.25rem 0.25rem 0;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 760;
}
.badge-team { color: var(--teal-dark); background: var(--teal-soft); }
.badge-loser { color: #8b3c43; background: var(--danger-soft); }
.details { border-color: var(--line); border-radius: 12px; background: rgba(245, 243, 238, 0.55); }
.toggle-btn {
    display: grid;
    min-width: 2.6rem;
    min-height: 2.6rem;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--ink-700);
    background: #fff;
    font-size: 0.85rem;
}
.pagination { gap: 0.35rem; margin-top: 1.25rem; }
.page-link { min-width: 2.5rem; border-color: var(--line); border-radius: 10px !important; color: var(--ink-700); text-align: center; }
.active-page .page-link { border-color: var(--ink-900); color: #fff; background: var(--ink-900); }
.summary-card { max-width: 860px; margin: 0 auto; }
.summary-card .table-responsive { margin: 0 !important; }
.rating-up { color: var(--teal-dark) !important; }
.rating-down { color: var(--danger) !important; }

/* Overlays and helpers */
#global-loader { background: rgba(245, 243, 238, 0.82) !important; backdrop-filter: blur(12px); }
.spinner-border { color: var(--gold) !important; }
.install-app-btn {
    position: fixed;
    bottom: max(1rem, env(safe-area-inset-bottom));
    left: 50%;
    z-index: 1000;
    width: min(calc(100% - 2rem), 360px);
    transform: translateX(-50%);
}
.install-app-btn:hover { transform: translateX(-50%) translateY(-1px); }

.app-toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 1100; display: grid; gap: 0.5rem; }
.app-toast { padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: 12px; color: var(--ink-900); background: #fff; box-shadow: var(--shadow-md); }
.app-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
    place-items: center;
    padding: 1rem;
    background: rgba(9, 21, 37, 0.54);
    backdrop-filter: blur(8px);
}
.app-modal-backdrop.is-open { display: grid; }
.app-modal { width: min(100%, 480px); overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.65); border-radius: 20px; background: #fff; box-shadow: var(--shadow-lg); }
.app-modal-header, .app-modal-body, .app-modal-footer { padding: 1rem 1.2rem; }
.app-modal-header { border-bottom: 1px solid var(--line); }
.app-modal-title { margin: 0; font-size: 1.2rem; }
.app-modal-footer { display: flex; justify-content: flex-end; gap: 0.65rem; border-top: 1px solid var(--line); background: var(--paper); }
.app-modal-body .form-label { display: block; }
.app-modal-body .form-control { display: block; width: 100%; margin-top: 0.4rem; }
.app-btn {
    border: 1px solid var(--line-strong);
    color: var(--ink-700);
    background: #fff;
    cursor: pointer;
}
.app-btn-primary {
    border-color: var(--ink-900);
    color: #fff;
    background: linear-gradient(135deg, var(--ink-800), var(--ink-900));
    box-shadow: 0 9px 20px rgba(16, 35, 63, 0.16);
}
.modal-help { margin: 0.7rem 0 0; color: var(--ink-500); font-size: 0.86rem; }
.league-code {
    margin-top: 0.75rem;
    padding: 1rem;
    border: 1px dashed rgba(155, 111, 36, 0.4);
    border-radius: 12px;
    color: var(--gold-dark);
    background: var(--gold-soft);
    font-size: 1.35rem;
    font-weight: 850;
    letter-spacing: 0.12em;
    text-align: center;
}
.pagination-ellipsis { color: var(--ink-500); background: transparent; }

@media (max-width: 860px) {
    .home-panel { margin-inline: 1rem; }
    .ranking-toolbar { grid-template-columns: 1fr 1fr; }
    .ranking-toolbar > #searchInput { grid-column: 1 / -1; }
    .ranking-toolbar .form-check { justify-self: end; }
}

/* Mobile-first refinements */
@media (max-width: 576px) {
    body {
        padding: 0 0.75rem calc(2.5rem + env(safe-area-inset-bottom));
        font-size: 15px;
    }

    body::before, body::after { display: none; }
    .page-heading { margin-bottom: 1.15rem; padding-top: 1.6rem; }
    .page-heading h1 { font-size: clamp(2rem, 10vw, 2.7rem); }
    .page-summary .page-heading h1 {
        font-size: 1.85rem;
        letter-spacing: -0.045em;
    }
    .page-kicker, .hero-kicker { margin-bottom: 0.55rem; font-size: 0.64rem; }
    .page-intro { margin-top: 0.55rem; padding-inline: 0.35rem; font-size: 0.9rem; }

    .home-hero {
        min-height: 280px;
        margin: 0 -0.75rem;
        padding: 2.8rem 1.35rem 5rem;
        border-radius: 0 0 26px 26px;
    }
    .home-hero::before { inset: 0.75rem; border-radius: 0 0 18px 18px; }
    .home-hero h1 { font-size: clamp(3.2rem, 17vw, 4.25rem); }
    .brand-mark { width: 2.7rem; height: 2.7rem; margin-bottom: 0.7rem; }
    .hero-copy { font-size: 0.93rem; line-height: 1.45; }
    .home-panel { margin: -2.85rem 0 0; padding: 0.85rem; border-radius: 20px; }
    .home-actions { grid-template-columns: 1fr; gap: 0.6rem; margin-bottom: 1rem; }
    #search-bar, #ny-liga-btn { width: 100%; min-width: 0; max-width: none; height: 3.25rem; min-height: 3.25rem; margin: 0; }
    .section-heading { padding-inline: 0.2rem; }

    .page-home table, .page-home thead, .page-home tbody,
    .page-home th, .page-home td, .page-home tr { display: block; }
    .page-home thead { display: none; }
    .page-home #ligor-tbody tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0;
        margin: 0;
        padding: 0.35rem;
        border: 0;
        border-bottom: 1px solid var(--line);
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }
    .page-home #ligor-tbody tr:last-child { border-bottom: 0; }
    .page-home #ligor-tbody td { min-width: 0; padding: 0.7rem; border: 0; font-size: 0.96rem; }
    .page-home #ligor-tbody td::before {
        margin-bottom: 0.12rem;
        color: var(--ink-500);
        font-size: 0.62rem;
        font-weight: 800;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }
    .page-home #ligor-tbody td:first-child { grid-column: 1 / -1; padding-bottom: 0.5rem; font-size: 1.12rem; }
    .page-home #ligor-tbody td:first-child::after {
        display: inline-block;
        width: 0.45rem;
        height: 0.45rem;
        margin-left: 0.45rem;
        border-top: 2px solid var(--gold);
        border-right: 2px solid var(--gold);
        content: "";
        transform: rotate(45deg) translateY(-1px);
    }

    .form-control, .form-select, .select2-container .select2-selection--single { font-size: 16px; }
    .form-container, .match-builder-card { margin: 0; padding: 1rem; border-radius: 18px; }
    .form-actions, .summary-actions, .composer-actions { display: grid; grid-template-columns: 1fr; gap: 0.55rem; }
    .form-actions .btn, .summary-actions .btn, .composer-actions .btn { width: 100%; margin: 0; }

    .action-deck { padding: 0.6rem; border-radius: 16px; }
    .button-group { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .button-group .btn { width: 100%; min-height: 3rem; margin: 0; padding-inline: 0.55rem; font-size: 0.86rem; }
    #addMatchBtn { grid-column: 1 / -1; order: -1; }
    #backBtn.btn-secondary { color: var(--ink-600) !important; background: rgba(255, 255, 255, 0.5) !important; }

    .ranking-card { border-radius: 17px; }
    .ranking-toolbar { grid-template-columns: 1fr auto; gap: 0.65rem; padding: 0.75rem; }
    .ranking-toolbar > #searchInput { grid-column: 1 / -1; min-height: 3rem; }
    .ranking-toolbar .nav-tabs { min-width: 0; }
    .ranking-toolbar .nav-link { min-height: 2.45rem; padding-inline: 0.65rem; font-size: 0.82rem; }
    .ranking-toolbar .form-check { justify-self: end; }
    .ranking-toolbar .form-check-label { max-width: 6rem; line-height: 1.15; white-space: normal; }
    .league-table-wrap { overflow: hidden; }
    .ranking-card th, .ranking-card td { padding: 0.72rem 0.4rem; font-size: 0.82rem; }
    .ranking-card th { font-size: 0.58rem; letter-spacing: 0.05em; }
    .ranking-card th:first-child, .ranking-card td:first-child { width: 2.15rem; padding-left: 0.65rem; padding-right: 0.2rem; }
    .ranking-card th:nth-child(3), .ranking-card td:nth-child(3) { width: 3.4rem; text-align: right; }
    .ranking-card th:nth-child(4), .ranking-card td:nth-child(4) { width: 3.25rem; padding-right: 0.65rem; text-align: right; }
    .ranking-card .star { width: 1.6rem; height: 1.6rem; margin-right: 0.1rem; font-size: 0.95rem; }
    .ranking-card .chevron { width: 1.1rem; height: 1.1rem; margin-left: 0.05rem; font-size: 0.63rem; }
    .ranking-card td:nth-child(2) small {
        display: inline-block;
        max-width: 9rem;
        overflow: hidden;
        font-size: 0.68rem !important;
        letter-spacing: -0.04em;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .player-detail-grid { grid-template-columns: 1fr; }
    .shared-match-panel { margin-left: 0; }
    .shared-match-summary, .shared-match-card { grid-template-columns: 1fr; }

    .team-header { flex-direction: row; align-items: center; }
    .team-header h5 { margin: 0; }
    .d-flex.mt-2 { flex-direction: row; }

    .composer-card { position: relative; bottom: auto; margin: 0 0 1.25rem; border-radius: 18px; box-shadow: var(--shadow-md); }
    .comment-card.reply { margin-left: 0.75rem; }

    .history-toolbar { grid-template-columns: 1fr; gap: 0.6rem; padding: 0.7rem; }
    .history-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .history-actions .btn { width: 100%; margin: 0; font-size: 0.86rem; }
    #pagination { flex-wrap: wrap; justify-content: center; }
    .match-row { padding: 0.85rem; border-radius: 14px; }
    .match-row .d-flex > div { min-width: 0; }
    .badge-team, .badge-loser { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .summary-card { border-radius: 17px; }
    .summary-card th, .summary-card td { padding: 0.8rem 0.55rem; font-size: 0.78rem; }
    .summary-card th { font-size: 0.58rem; letter-spacing: 0.045em; }
    .app-modal-footer { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Team generator */
[hidden] { display: none !important; }

.btn-team-generator {
    position: relative;
    overflow: hidden;
    border-color: #5d4375 !important;
    color: #fff !important;
    background: linear-gradient(135deg, #73508d 0%, #43345e 58%, #26314c 100%) !important;
    box-shadow: 0 10px 24px rgba(67, 52, 94, 0.2) !important;
}

.btn-team-generator::after {
    position: absolute;
    top: -50%;
    left: -35%;
    width: 32%;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
    content: "";
    transform: rotate(18deg);
    transition: left 420ms ease;
}

.btn-team-generator:hover::after { left: 112%; }

.page-team-generator {
    padding-bottom: 5rem;
    background:
        radial-gradient(circle at 50% -10%, rgba(115, 80, 141, 0.14), transparent 32rem),
        radial-gradient(circle at 92% 28%, rgba(201, 154, 69, 0.11), transparent 28rem),
        linear-gradient(180deg, #fbfaf7 0%, var(--paper) 58%, #efede7 100%);
}

.team-generator-shell { max-width: 1040px; }
.team-generator-heading { max-width: 750px; margin-inline: auto; text-align: center; }
.team-generator-heading .page-intro { max-width: 620px; margin-inline: auto; }

.generator-setup-card,
.probability-section {
    margin-top: 1.25rem;
    padding: clamp(1rem, 3vw, 2rem);
    border: 1px solid rgba(16, 35, 63, 0.1);
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(16px);
}

.probability-section { margin-top: 1rem; }

.generator-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.35rem;
}

.generator-section-heading > div:first-child {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.generator-section-heading h2 { margin: 0; font-size: clamp(1.35rem, 4vw, 1.75rem); }

.step-number {
    display: inline-grid;
    flex: 0 0 auto;
    width: 2.45rem;
    height: 2.45rem;
    place-items: center;
    border: 1px solid rgba(201, 154, 69, 0.35);
    border-radius: 50%;
    color: var(--gold-dark);
    background: var(--gold-soft);
    font-size: 0.73rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.generator-controls {
    display: grid;
    grid-template-columns: minmax(180px, 0.55fr) minmax(260px, 1.45fr);
    gap: 0.8rem;
    margin-bottom: 1.15rem;
}

.generator-controls .form-label {
    margin-bottom: 0.38rem;
    color: var(--ink-600);
    font-size: 0.75rem;
    font-weight: 850;
    letter-spacing: 0.065em;
    text-transform: uppercase;
}

.generator-controls .form-control,
.generator-controls .form-select { min-height: 3.25rem; border-radius: 13px; }

.roster-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.8rem;
    padding: 0.75rem 0.2rem;
}

.roster-toolbar > div:first-child { display: flex; align-items: baseline; gap: 0.55rem; }
.roster-toolbar strong { color: var(--ink-950); }
.roster-toolbar span { color: var(--ink-500); font-size: 0.8rem; }
.text-button,
.pagination-button {
    min-height: 2.35rem;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-700);
    background: rgba(255, 255, 255, 0.8);
    font-size: 0.78rem;
    font-weight: 750;
    transition: var(--ease);
}

.text-button:hover,
.pagination-button:hover:not(:disabled) { border-color: rgba(201, 154, 69, 0.55); color: var(--gold-dark); }

.generator-loader,
.generator-empty {
    padding: 2.2rem 1rem;
    color: var(--ink-500);
    text-align: center;
}

.generator-player-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
    max-height: 25rem;
    padding: 0.25rem;
    overflow: auto;
    overscroll-behavior: contain;
}

.generator-player-card {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
    min-height: 4.3rem;
    padding: 0.65rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: rgba(249, 248, 244, 0.82);
    cursor: pointer;
    transition: transform var(--ease), border-color var(--ease), background var(--ease), box-shadow var(--ease);
    -webkit-tap-highlight-color: transparent;
}

.generator-player-card:hover { transform: translateY(-1px); border-color: rgba(201, 154, 69, 0.4); }
.generator-player-card:has(input:checked) {
    border-color: rgba(40, 119, 111, 0.42);
    background: linear-gradient(135deg, #f8fcfb, var(--teal-soft));
    box-shadow: inset 0 0 0 1px rgba(40, 119, 111, 0.1);
}

.generator-player-card input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.generator-avatar {
    display: grid;
    width: 2.45rem;
    height: 2.45rem;
    place-items: center;
    border-radius: 50%;
    color: var(--ink-800);
    background: linear-gradient(145deg, #f6e7c8, #ead2a5);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.03em;
}

.generator-player-copy { min-width: 0; }
.generator-player-copy strong,
.generator-player-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.generator-player-copy strong { font-size: 0.9rem; }
.generator-player-copy small { color: var(--ink-500); font-size: 0.72rem; }
.generator-favorite { margin-left: 0.35rem; color: var(--gold); font-size: 0.78rem; vertical-align: 0.04em; }

.generator-check {
    display: grid;
    width: 1.45rem;
    height: 1.45rem;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    color: transparent;
    background: #fff;
    font-size: 0.73rem;
    font-weight: 900;
    transition: var(--ease);
}

.generator-player-card:has(input:checked) .generator-check {
    border-color: var(--teal);
    color: #fff;
    background: var(--teal);
}

.generator-estimate {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    margin-top: 1rem;
    padding: 0.85rem;
    border: 1px solid rgba(40, 119, 111, 0.14);
    border-radius: 17px;
    background: var(--teal-soft);
}

.generator-estimate > div {
    padding: 0.35rem 0.5rem;
    border-right: 1px solid rgba(40, 119, 111, 0.14);
}

.generator-estimate > div:nth-child(2) { border-right: 0; }
.generator-estimate span,
.probability-stats span { display: block; color: var(--ink-500); font-size: 0.67rem; font-weight: 850; letter-spacing: 0.07em; text-transform: uppercase; }
.generator-estimate strong { display: block; margin-top: 0.1rem; color: var(--teal-dark); font-size: 1.28rem; }
.generator-estimate p { grid-column: 1 / -1; margin: 0; padding: 0.25rem 0.5rem 0; color: var(--ink-600); font-size: 0.82rem; }
.generator-estimate.is-warning { border-color: rgba(184, 71, 79, 0.22); background: var(--danger-soft); }
.generator-estimate.is-warning strong { color: var(--danger); }

.generator-calculate-btn {
    width: 100%;
    min-height: 3.5rem;
    margin-top: 0.75rem;
    border-radius: 14px !important;
    font-weight: 850 !important;
}

.draw-button {
    min-height: 3rem;
    border: 1px solid rgba(231, 195, 123, 0.55) !important;
    color: #13213a !important;
    background: linear-gradient(135deg, #f7e7b9, #d2a34e) !important;
    box-shadow: 0 10px 28px rgba(201, 154, 69, 0.23) !important;
    font-weight: 900 !important;
}

.probability-explainer {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid rgba(115, 80, 141, 0.17);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(115, 80, 141, 0.08), rgba(201, 154, 69, 0.08));
}

.formula-mark {
    display: grid;
    width: 3.2rem;
    height: 3.2rem;
    place-items: center;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(145deg, #73508d, #43345e);
    font-size: 1.25rem;
    font-weight: 900;
}

.probability-explainer h3 { margin: 0 0 0.28rem; font-size: 1rem; }
.probability-explainer p { margin: 0; color: var(--ink-600); font-size: 0.84rem; }
.probability-explainer .formula-detail { margin-top: 0.38rem; color: var(--ink-700); font-weight: 700; }

.probability-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin: 0 0 1rem;
}

.probability-stats > div {
    padding: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(249, 248, 244, 0.76);
}

.probability-stats strong { display: block; margin-top: 0.15rem; color: var(--ink-950); font-size: 1rem; }

.probability-list-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.65rem;
}

.probability-list-header h3 { margin: 0; font-size: 1.1rem; }
.probability-list-header p,
.probability-list-tools > span { margin: 0; color: var(--ink-500); font-size: 0.72rem; }
.probability-list-tools { display: flex; align-items: center; justify-content: flex-end; gap: 0.45rem; }
.restore-configurations-button,
.configuration-toggle-button {
    min-height: 1.9rem;
    padding: 0.22rem 0.58rem;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--ink-700);
    background: rgba(255, 255, 255, 0.88);
    font-size: 0.65rem;
    font-weight: 800;
    white-space: nowrap;
    transition: var(--ease);
}
.restore-configurations-button { color: var(--teal-dark); border-color: rgba(40, 119, 111, 0.26); }
.configuration-toggle-button:hover:not(:disabled),
.restore-configurations-button:hover { border-color: var(--gold); color: var(--gold-dark); }
.configuration-toggle-button:disabled { cursor: not-allowed; opacity: 0.36; }
.probability-list { display: grid; gap: 0.4rem; }

.probability-card {
    padding: 0.58rem 0.65rem;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.82);
    transition: opacity var(--ease), border-color var(--ease), background var(--ease);
}

.probability-card.is-excluded { border-color: rgba(184, 71, 79, 0.18); background: rgba(250, 236, 236, 0.45); }
.probability-card.is-excluded .probability-teams { opacity: 0.46; }
.probability-card.is-excluded .probability-card-topline > div:first-child strong { color: var(--danger); font-size: 0.72rem; }
.probability-card.is-excluded .configuration-toggle-button { border-color: rgba(40, 119, 111, 0.3); color: var(--teal-dark); }

.probability-card-topline,
.probability-card-topline > div,
.balance-label,
.probability-team-heading,
.generator-pagination { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; }
.probability-card-topline > div:first-child { justify-content: flex-start; }
.probability-card-tools { justify-content: flex-end; gap: 0.45rem; }
.probability-card-topline strong { font-size: 0.92rem; }
.configuration-number { color: var(--gold-dark); font-size: 0.66rem; font-weight: 900; }
.balance-label { color: var(--ink-500); font-size: 0.64rem; }

.chance-track {
    height: 0.18rem;
    margin: 0.38rem 0 0.42rem;
    overflow: hidden;
    border-radius: 99px;
    background: #e9e6de;
}

.chance-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--gold)); }
.probability-teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.28rem; }
.probability-team { min-width: 0; padding: 0.38rem 0.48rem; border-radius: 8px; background: #f7f6f2; }
.probability-team-heading span { color: var(--ink-500); font-size: 0.58rem; font-weight: 850; letter-spacing: 0.06em; text-transform: uppercase; }
.probability-team-heading strong { font-size: 0.62rem; }
.probability-team-players { display: flex; flex-wrap: wrap; gap: 0.16rem 0.42rem; margin-top: 0.2rem; }
.probability-team-players > span { position: relative; padding: 0; border: 0; background: transparent; font-size: 0.66rem; }
.probability-team-players > span:not(:last-child)::after { position: absolute; right: -0.28rem; color: var(--ink-500); content: "·"; }
.probability-team-players small { color: var(--ink-500); }

.generator-pagination { justify-content: center; margin-top: 1rem; }
.generator-pagination > span { min-width: 6.5rem; color: var(--ink-600); font-size: 0.78rem; text-align: center; }
.pagination-button:disabled { opacity: 0.4; cursor: not-allowed; }

.draw-arena {
    position: fixed;
    z-index: 3000;
    inset: 0;
    display: grid;
    padding: clamp(1rem, 4vw, 2.5rem);
    overflow: auto;
    place-items: center;
    visibility: hidden;
    opacity: 0;
    color: #fff;
    background:
        radial-gradient(circle at 50% 45%, rgba(115, 80, 141, 0.42), transparent 28rem),
        linear-gradient(150deg, #060b15 0%, #10233f 52%, #08111f 100%);
    pointer-events: none;
    transition: opacity 240ms ease, visibility 240ms ease;
}

.draw-arena.is-open { visibility: visible; opacity: 1; pointer-events: auto; }
body.arena-open { overflow: hidden; }
.draw-arena::before { position: fixed; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, 0.32) 0.7px, transparent 0.7px); background-size: 20px 20px; content: ""; opacity: 0.16; }

.arena-beam {
    position: fixed;
    top: -25vh;
    width: 32vw;
    height: 150vh;
    background: linear-gradient(180deg, rgba(243, 211, 137, 0.24), transparent 66%);
    filter: blur(8px);
    opacity: 0.55;
    pointer-events: none;
    transform-origin: 50% 0;
    animation: arena-sweep 5.2s ease-in-out infinite alternate;
}

.arena-beam-one { left: 8%; transform: rotate(-18deg); }
.arena-beam-two { right: 8%; transform: rotate(18deg); animation-delay: -2.6s; }

@keyframes arena-sweep {
    from { transform: rotate(-24deg) translateX(-8vw); opacity: 0.3; }
    to { transform: rotate(24deg) translateX(8vw); opacity: 0.65; }
}

.arena-close {
    position: fixed;
    z-index: 3;
    top: max(1rem, env(safe-area-inset-top));
    right: 1rem;
    display: grid;
    width: 2.8rem;
    height: 2.8rem;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    font-size: 1.6rem;
}

.arena-content { position: relative; z-index: 2; width: min(100%, 900px); text-align: center; }
.arena-kicker { margin: 0 0 0.2rem; color: #e7c987; font-size: 0.7rem; font-weight: 900; letter-spacing: 0.19em; text-transform: uppercase; }
.arena-content h2 { margin: 0; color: #fff; font-size: clamp(1.8rem, 7vw, 3.4rem); letter-spacing: -0.04em; }

.arena-countdown {
    min-height: clamp(5rem, 19vw, 8rem);
    color: #f0d38f;
    font-size: clamp(4.5rem, 18vw, 8rem);
    font-weight: 950;
    line-height: 1;
    text-shadow: 0 0 40px rgba(231, 201, 135, 0.42);
}

.arena-countdown.count-pop { animation: countdown-pop 520ms cubic-bezier(.2, .9, .15, 1); }
@keyframes countdown-pop { from { opacity: 0; transform: scale(1.7); } to { opacity: 1; transform: scale(1); } }

.shuffle-stage {
    position: relative;
    height: 7rem;
    margin: 0.4rem auto;
    overflow: hidden;
    border-block: 1px solid rgba(255, 255, 255, 0.08);
    mask-image: linear-gradient(90deg, transparent, #000 13%, #000 87%, transparent);
}

.shuffle-player {
    position: absolute;
    top: calc(0.35rem + var(--lane));
    left: 50%;
    min-width: 6.5rem;
    padding: 0.55rem 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
    font-weight: 780;
    animation: shuffle-flight 900ms ease-in-out infinite;
    animation-delay: var(--delay);
    backdrop-filter: blur(7px);
}

@keyframes shuffle-flight {
    from { opacity: 0; transform: translateX(calc(-50% - 58vw + var(--offset))) scale(0.78); }
    50% { opacity: 1; }
    to { opacity: 0; transform: translateX(calc(-50% + 58vw + var(--offset))) scale(1.08); }
}

.revealed-teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.75rem; margin: 1.2rem 0 0; }
.revealed-team {
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-top: 3px solid var(--team-color, #e7c987);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.09);
    box-shadow: 0 22px 55px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(24px) scale(0.95);
    animation: team-reveal 520ms cubic-bezier(.2, .9, .22, 1) forwards;
    animation-delay: var(--team-delay, 0ms);
    backdrop-filter: blur(15px);
}

@keyframes team-reveal { to { opacity: 1; transform: translateY(0) scale(1); } }
.revealed-team:nth-child(1) { --team-color: #e7c987; }
.revealed-team:nth-child(2) { --team-color: #59b8a9; }
.revealed-team:nth-child(3) { --team-color: #d5808a; }
.revealed-team:nth-child(4) { --team-color: #87aadb; }
.revealed-team-label { display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; padding-bottom: 0.55rem; border-bottom: 1px solid rgba(255, 255, 255, 0.12); }
.revealed-team-label span { color: var(--team-color); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.09em; text-transform: uppercase; }
.revealed-team-label strong { color: rgba(255, 255, 255, 0.72); font-size: 0.7rem; }
.revealed-team-rating { opacity: 0; transform: translateY(-4px); transition: opacity 260ms ease, transform 260ms ease; }
.revealed-team-rating.is-visible { opacity: 1; transform: translateY(0); }
.revealed-player-list { display: grid; align-content: start; gap: 0.42rem; min-height: var(--team-list-height); margin-top: 0.6rem; }
.revealed-player-list > div { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; align-items: center; gap: 0.48rem; text-align: left; }
.revealed-player { opacity: 0; transform: translateX(-12px); animation: player-reveal 330ms cubic-bezier(.2, .9, .22, 1) forwards; }
@keyframes player-reveal { to { opacity: 1; transform: translateX(0); } }
.revealed-player-list > div > span { display: grid; width: 2rem; height: 2rem; place-items: center; border-radius: 50%; color: #15223a; background: var(--team-color); font-size: 0.58rem; font-weight: 950; }
.revealed-player-list strong { overflow: hidden; color: #fff; font-size: 0.86rem; text-overflow: ellipsis; white-space: nowrap; }
.revealed-player-list small { color: rgba(255, 255, 255, 0.58); font-size: 0.66rem; }
.draw-probability { min-height: 1.5rem; margin: 1rem 0 0; color: #e7c987; font-size: 0.82rem; font-weight: 750; }
.arena-actions { display: flex; justify-content: center; gap: 0.6rem; margin-top: 0.8rem; }
.arena-finish { border: 1px solid rgba(255, 255, 255, 0.2) !important; color: #fff !important; background: rgba(255, 255, 255, 0.08) !important; }

.confetti-field { position: fixed; z-index: 1; inset: 0; overflow: hidden; pointer-events: none; }
.confetti-field i {
    position: absolute;
    top: -1.5rem;
    left: var(--left);
    width: 0.55rem;
    height: 1.05rem;
    border-radius: 2px;
    background: var(--color, #e7c987);
    opacity: 0;
}

.confetti-field.is-active i { animation: confetti-fall var(--duration, 2.8s) linear var(--delay, 0s) forwards; }

@keyframes confetti-fall {
    8% { opacity: 1; }
    to { transform: translate3d(var(--drift, 0), 110vh, 0) rotate(var(--rotation, 720deg)); opacity: 0.2; }
}

@media (max-width: 767.98px) {
    #addMatchBtn { order: -2; }
    #generateTeamsBtn { grid-column: 1 / -1; order: -1; }
    .team-generator-heading { padding-inline: 0.35rem; }
    .generator-setup-card,
    .probability-section { margin-inline: 0; padding: 0.85rem; border-radius: 19px; }
    .generator-section-heading { align-items: flex-start; margin-bottom: 1rem; }
    .generator-section-heading .btn { min-height: 2.65rem; padding-inline: 0.7rem; font-size: 0.78rem; }
    .generator-controls { grid-template-columns: 1fr; gap: 0.65rem; }
    .roster-toolbar { align-items: flex-start; }
    .roster-toolbar > div:first-child { display: block; }
    .roster-toolbar span { display: block; }
    .generator-player-grid { grid-template-columns: 1fr; max-height: 22rem; }
    .generator-player-card { min-height: 4rem; }
    .probability-heading { display: grid; grid-template-columns: 1fr; }
    .probability-heading .draw-button { width: 100%; }
    .probability-stats { gap: 0.35rem; }
    .probability-stats > div { min-width: 0; padding: 0.65rem 0.45rem; }
    .probability-stats strong { overflow-wrap: anywhere; font-size: 0.78rem; }
    .probability-list-header { display: block; }
    .probability-list-tools { justify-content: space-between; margin-top: 0.35rem; }
    .probability-card { padding: 0.52rem 0.58rem; border-radius: 12px; }
    .probability-card-topline { align-items: flex-start; }
    .probability-card-tools { display: grid; justify-items: end; gap: 0.24rem; }
    .balance-label { display: grid; justify-items: end; gap: 0.12rem; text-align: right; }
    .probability-teams { grid-template-columns: 1fr; }
    .draw-arena { padding: max(4.25rem, env(safe-area-inset-top)) 0.8rem max(1rem, env(safe-area-inset-bottom)); align-items: start; }
    .arena-content { margin: auto 0; }
    .shuffle-stage { height: 6.3rem; }
    .revealed-teams { grid-template-columns: 1fr; gap: 0.5rem; }
    .revealed-team { padding: 0.8rem; border-radius: 14px; }
    .revealed-player-list { gap: 0.3rem; margin-top: 0.45rem; }
    .arena-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .arena-actions .btn { width: 100%; }
}
