:root {
    color-scheme: dark;
    --bg: #08080e;
    --surface: #14141e;
    --surface-2: #1a1a27;
    --surface-3: #20202f;
    --text: #f7f7fb;
    --muted: #a7a7b8;
    --border: rgba(255, 255, 255, 0.11);
    --border-strong: rgba(255, 255, 255, 0.20);
    --gold: #f5c45e;
    --gold-dark: #d99a28;
    --danger: #ff6974;
    --success: #43d795;
    --match-color: #ff6fb7;
    --birthday-color: #f4c66b;
    --event-color: #51d9ff;
    --boost-without-color: #39d98a;
    --boost-with-color: #ff5c67;
    --age-plus-color: #39d98a;
    --age-minus-color: #ff5c67;
    --shadow: 0 30px 90px rgba(0, 0, 0, 0.42);
}

/* Important : une zone marquée hidden doit toujours rester invisible. */
[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 0%, rgba(133, 93, 255, 0.15), transparent 32%),
        radial-gradient(circle at 92% 20%, rgba(245, 196, 94, 0.08), transparent 30%),
        linear-gradient(145deg, #07070c 0%, #0b0b12 56%, #07070c 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
body.modal-open { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.background-glow {
    position: fixed;
    z-index: -1;
    width: 420px;
    height: 420px;
    border-radius: 999px;
    filter: blur(110px);
    opacity: 0.13;
    pointer-events: none;
}
.background-glow-left { top: -210px; left: -160px; background: #8a68ff; }
.background-glow-right { right: -190px; bottom: -220px; background: #f5c45e; }

.page-shell {
    width: min(1540px, calc(100% - 40px));
    margin: 0 auto;
    padding: 30px 0 36px;
}
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
}
.brand-block { min-width: 0; }
.eyebrow {
    margin: 0 0 7px;
    color: var(--gold);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.18em;
}
h1 {
    margin: 0;
    font-size: clamp(2.35rem, 4.7vw, 4.35rem);
    line-height: 0.96;
    letter-spacing: -0.055em;
}
.header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.button,
.month-nav,
.modal-close {
    border: 0;
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, opacity 150ms ease;
}
.button:hover,
.month-nav:hover,
.modal-close:hover { transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: 0.55; transform: none !important; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 17px;
    border-radius: 13px;
    text-decoration: none;
    font-weight: 820;
    white-space: nowrap;
}
.button-primary {
    color: #1d1406;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    box-shadow: 0 10px 28px rgba(245, 196, 94, 0.16);
}
.button-secondary {
    color: var(--text);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.055);
}
.button-danger-soft {
    color: #ffc6cb;
    border: 1px solid rgba(255, 105, 116, 0.22);
    background: rgba(255, 105, 116, 0.08);
}
.button-danger {
    color: #ffe7e9;
    border: 1px solid rgba(255, 105, 116, 0.34);
    background: rgba(255, 105, 116, 0.14);
}
.button-full { width: 100%; }

.category-legend {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    min-height: 68px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.035);
    backdrop-filter: blur(12px);
}
.legend-symbol {
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    color: #111119;
    font-size: 0.7rem;
    font-weight: 950;
    letter-spacing: 0.03em;
}
.legend-match { background: var(--match-color); }
.legend-birthday { background: var(--birthday-color); }
.legend-event { background: var(--event-color); }
.legend-item > span:last-child { display: grid; min-width: 0; gap: 2px; }
.legend-item strong { font-size: 0.88rem; }
.legend-item small {
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.72rem;
}

.admin-help {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px 9px;
    margin-bottom: 18px;
    padding: 13px 16px;
    border: 1px solid rgba(245, 196, 94, 0.19);
    border-radius: 14px;
    color: #dddde7;
    background: rgba(245, 196, 94, 0.055);
    font-size: 0.86rem;
}
.admin-help strong { color: var(--gold); }

.calendar-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 26px;
    background: linear-gradient(180deg, rgba(28, 28, 41, 0.97), rgba(13, 13, 20, 0.98));
    box-shadow: var(--shadow);
}
.calendar-toolbar {
    display: grid;
    grid-template-columns: 50px 1fr 50px;
    align-items: center;
    gap: 18px;
    padding: 19px 22px;
    border-bottom: 1px solid var(--border);
}
.month-nav {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.045);
    font-size: 2rem;
    line-height: 1;
}
.month-title { text-align: center; }
.month-title h2 {
    margin: 0;
    font-size: clamp(1.35rem, 2.5vw, 1.85rem);
    letter-spacing: -0.035em;
}
.month-title p { margin: 3px 0 0; color: var(--muted); font-size: 0.82rem; }
.calendar-scroll { overflow-x: auto; }
.calendar-min-width { min-width: 760px; }
.weekday-row,
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday-row {
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.025);
}
.weekday-row span {
    padding: 13px 8px;
    color: var(--muted);
    text-align: center;
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.calendar-grid { gap: 1px; background: rgba(255, 255, 255, 0.09); }
.day-cell {
    position: relative;
    min-width: 0;
    min-height: clamp(116px, 10.7vw, 168px);
    padding: 10px;
    overflow: hidden;
    background: #0e0e16;
    outline: none;
    transition: background 150ms ease, box-shadow 150ms ease;
}
.day-cell:nth-child(7n),
.day-cell:nth-child(7n - 1) { background: #11111a; }
.day-cell.outside-month { opacity: 0.42; }
.day-cell.today { box-shadow: inset 0 0 0 2px rgba(245, 196, 94, 0.74); }
.day-cell.admin-day { cursor: pointer; }
.day-cell.admin-day:hover,
.day-cell.admin-day:focus-visible { background: #1a1a27; box-shadow: inset 0 0 0 1px rgba(255,255,255,.17); }
.day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 30px;
    margin-bottom: 7px;
}
.day-number {
    display: inline-grid;
    place-items: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 9px;
    color: #ededf4;
    font-size: 0.84rem;
    font-weight: 900;
}
.day-cell.today .day-number { color: #1a1205; background: var(--gold); }
.day-add-button {
    display: grid;
    place-items: center;
    width: 27px;
    height: 27px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--gold);
    background: rgba(255, 255, 255, 0.045);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 800;
    opacity: 0.45;
}
.day-cell:hover .day-add-button,
.day-add-button:focus-visible { opacity: 1; }
.day-events { display: flex; flex-direction: column; gap: 5px; }
.event-chip {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    min-width: 0;
    width: 100%;
    min-height: 30px;
    gap: 7px;
    padding: 6px 8px 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-left: 4px solid var(--chip-color);
    border-radius: 9px;
    color: #f6f6fa;
    background: #20202d;
    text-align: left;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.event-chip:hover { z-index: 3; filter: brightness(1.12); }
.event-chip.match_off { --chip-color: var(--match-color); }
.event-chip.birthday { --chip-color: var(--birthday-color); }
.event-chip.event { --chip-color: var(--event-color); }
.event-chip.range-chip {
    border-left-width: 0;
    border-color: rgba(255,255,255,.10);
    background: linear-gradient(90deg, var(--event-color), #2589a5);
    color: #071014;
    font-weight: 900;
}
.event-chip.range-start { margin-right: -11px; width: calc(100% + 11px); border-radius: 9px 0 0 9px; }
.event-chip.range-middle { margin-left: -11px; margin-right: -11px; width: calc(100% + 22px); border-radius: 0; }
.event-chip.range-end { margin-left: -11px; width: calc(100% + 11px); border-radius: 0 9px 9px 0; }
.event-chip.range-single { border-radius: 9px; }
.chip-time { flex: 0 0 auto; font-size: 0.65rem; font-weight: 950; opacity: 0.86; }
.chip-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.7rem;
    font-weight: 800;
}
.empty-cell-hint {
    display: block;
    margin-top: 10px;
    color: transparent;
    text-align: center;
    font-size: 0.68rem;
    transition: color 150ms ease;
}
.admin-day:hover .empty-cell-hint { color: var(--muted); }

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 18px;
    overflow-y: auto;
    background: rgba(4, 4, 8, 0.82);
    opacity: 0;
    backdrop-filter: blur(12px);
    transition: opacity 160ms ease;
}
.modal-backdrop.is-open { opacity: 1; }
.modal {
    position: relative;
    width: min(590px, 100%);
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    padding: 28px;
    border: 1px solid var(--border-strong);
    border-radius: 24px;
    background: linear-gradient(180deg, #1b1b28, #111119);
    box-shadow: 0 40px 120px rgba(0,0,0,.68);
    transform: translateY(12px) scale(.985);
    transition: transform 160ms ease;
}
.modal-backdrop.is-open .modal { transform: translateY(0) scale(1); }
.modal-wide, .modal-details { width: min(780px, 100%); }
.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
    background: rgba(255,255,255,.05);
    font-size: 1.35rem;
}
.modal-kicker { margin: 0 48px 6px 0; color: var(--gold); font-size: .7rem; font-weight: 900; letter-spacing: .16em; }
.modal h2 { margin: 0 48px 22px 0; font-size: clamp(1.55rem, 4vw, 2.2rem); letter-spacing: -.04em; }

.loading-shell,
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.loading-card,
.auth-card {
    width: min(470px, 100%);
    padding: 34px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(29,29,43,.97), rgba(14,14,22,.98));
    box-shadow: var(--shadow);
}
.loading-card { display: flex; align-items: center; justify-content: center; gap: 14px; }
.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,.12);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.auth-logo {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 22px;
    border: 1px solid rgba(245,196,94,.48);
    border-radius: 18px;
    color: var(--gold);
    background: rgba(245,196,94,.08);
    font-weight: 950;
}
.auth-card h1 { font-size: clamp(2.1rem, 7vw, 3.25rem); }
.auth-copy { margin: 13px 0 24px; color: var(--muted); line-height: 1.55; }

.stack-form,
.event-form { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #dcdce5; font-size: .82rem; font-weight: 780; }
input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    color: var(--text);
    background: rgba(255,255,255,.055);
}
input, select { min-height: 48px; padding: 0 13px; }
textarea { min-height: 92px; padding: 12px 13px; resize: vertical; }
input[type="color"] { min-height: 54px; padding: 5px; cursor: pointer; }
input:focus,
textarea:focus,
select:focus { border-color: rgba(245,196,94,.68); box-shadow: 0 0 0 3px rgba(245,196,94,.10); }
select option { background: #171722; }
.form-grid { display: grid; gap: 14px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-section,
.settings-panel {
    display: grid;
    gap: 14px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255,255,255,.025);
}
.type-fieldset { margin: 0; padding: 0; border: 0; }
.type-fieldset legend { margin-bottom: 8px; color: #dcdce5; font-size: .82rem; font-weight: 780; }
.type-selector { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.type-selector label { display: block; cursor: pointer; }
.type-selector input { position: absolute; opacity: 0; pointer-events: none; }
.type-selector span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 50px;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
    background: rgba(255,255,255,.035);
    text-align: center;
}
.type-selector b {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    color: #151018;
    background: var(--gold);
    font-size: .62rem;
}
.type-selector strong { font-size: .78rem; }
.type-selector input:checked + span { color: #1c1407; border-color: var(--gold); background: var(--gold); }
.type-selector input:checked + span b { color: var(--gold); background: #1c1407; }
.form-error { min-height: 1.25em; margin: 0; color: #ff9ea6; font-size: .82rem; line-height: 1.4; }
.field-help { margin: -7px 0 0; color: var(--muted); font-size: .77rem; line-height: 1.48; }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 2px; }
.form-spacer { flex: 1 1 auto; }
.settings-panel h3 { margin: 0; font-size: .95rem; }
.color-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.four-colors { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.details-content { display: grid; gap: 13px; }
.date-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 17px 19px;
    border: 1px solid rgba(245,196,94,.28);
    border-radius: 16px;
    background: rgba(245,196,94,.08);
}
.date-hero span { color: #ece7dc; font-weight: 760; }
.date-hero strong { color: var(--gold); font-size: 1.5rem; }
.birthday-banner {
    display: grid;
    place-items: center;
    gap: 3px;
    padding: 14px;
    border: 1px solid var(--birthday-color);
    border-radius: 14px;
    background: rgba(255,255,255,.035);
    text-align: center;
}
.birthday-banner span { color: var(--muted); font-size: .68rem; font-weight: 900; letter-spacing: .13em; }
.birthday-banner strong { font-size: 1.3rem; }
.versus-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 78px minmax(0, 1fr);
    align-items: stretch;
    gap: 14px;
}
.versus-player {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 148px;
    padding: 18px 12px;
    border: 1px solid var(--border);
    border-radius: 19px;
    background: radial-gradient(circle at 50% 8%, rgba(133,93,255,.17), transparent 56%), rgba(255,255,255,.035);
    text-align: center;
}
.versus-player small { color: var(--muted); font-size: .66rem; font-weight: 900; letter-spacing: .12em; }
.versus-player strong { max-width: 100%; margin-top: 8px; overflow-wrap: anywhere; font-size: clamp(1.05rem, 3vw, 1.5rem); }
.versus-mark {
    align-self: center;
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    border: 1px solid rgba(245,196,94,.56);
    border-radius: 21px;
    color: #171008;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    box-shadow: 0 12px 30px rgba(245,196,94,.18);
    font-size: 1.55rem;
    font-weight: 950;
    transform: rotate(-4deg);
}
.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; }
.status-card {
    display: grid;
    place-items: center;
    min-height: 80px;
    padding: 13px;
    border: 2px solid currentColor;
    border-radius: 15px;
    background: rgba(255,255,255,.025);
    text-align: center;
}
.status-card span { font-weight: 950; letter-spacing: .04em; }
.boost-without { color: var(--boost-without-color); }
.boost-with { color: var(--boost-with-color); }
.age-plus { color: var(--age-plus-color); }
.age-minus { color: var(--age-minus-color); }
.detail-row,
.detail-note,
.day-detail-event {
    padding: 14px 15px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: rgba(255,255,255,.035);
}
.detail-row { display: flex; justify-content: space-between; gap: 18px; }
.detail-row span,
.detail-note span { color: var(--muted); font-size: .78rem; font-weight: 750; }
.detail-row strong { text-align: right; }
.detail-note p { margin: 7px 0 0; line-height: 1.5; }
.event-hero-card {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 120px;
    padding: 22px;
    border: 2px solid var(--event-color);
    border-radius: 19px;
    background: rgba(255,255,255,.035);
}
.event-hero-card span { color: var(--muted); font-size: .7rem; font-weight: 900; letter-spacing: .1em; }
.event-hero-card strong { font-size: clamp(1.35rem, 4vw, 2.15rem); }
.event-hero-card em { width: 100%; color: var(--event-color); text-align: center; font-style: normal; font-weight: 900; }
.day-detail-event {
    display: grid;
    grid-template-columns: 85px 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.day-detail-event:hover { border-color: var(--border-strong); }
.day-detail-event span { color: var(--gold); font-weight: 900; }
.day-detail-event strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-detail-event small { color: var(--muted); }

.toast {
    position: fixed;
    z-index: 1500;
    left: 50%;
    bottom: 22px;
    max-width: calc(100% - 32px);
    padding: 12px 17px;
    border: 1px solid rgba(67,215,149,.30);
    border-radius: 999px;
    color: #e2fff1;
    background: rgba(21,62,44,.97);
    box-shadow: 0 18px 55px rgba(0,0,0,.4);
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 10px);
    transition: 170ms ease;
    font-size: .86rem;
    font-weight: 780;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-type="error"] { color: #ffe9eb; border-color: rgba(255,105,116,.32); background: rgba(78,26,32,.97); }
.fatal-error { grid-column: 1 / -1; padding: 70px 20px; color: #ffb7bd; background: #111119; text-align: center; }

@media (max-width: 1050px) {
    .admin-header { align-items: flex-start; }
    .admin-header .header-actions { max-width: 630px; }
    .four-colors { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 820px) {
    .page-shell { width: min(100% - 20px, 1540px); padding-top: 20px; }
    .site-header { display: block; }
    .header-actions { justify-content: flex-start; margin-top: 17px; }
    .category-legend { grid-template-columns: 1fr; }
    .legend-item { min-height: 60px; }
    .calendar-card { border-radius: 19px; }
    .calendar-toolbar { grid-template-columns: 44px 1fr 44px; padding: 15px 12px; gap: 9px; }
    .month-nav { width: 42px; height: 42px; }
    .modal { padding: 24px 18px; border-radius: 20px; }
    .two-columns,
    .color-grid,
    .four-colors { grid-template-columns: 1fr; }
    .type-selector { grid-template-columns: 1fr; }
    .versus-stage { grid-template-columns: 1fr; gap: 10px; }
    .versus-player { min-height: 105px; }
    .versus-mark { width: 58px; height: 58px; margin: -2px auto; }
    .date-hero { align-items: flex-start; flex-direction: column; }
    .detail-row { display: grid; gap: 6px; }
    .detail-row strong { text-align: left; }
    .day-detail-event { grid-template-columns: 68px 1fr; }
    .day-detail-event small { grid-column: 2; }
    .auth-card, .loading-card { padding: 28px 22px; }
}

@media (max-width: 440px) {
    .page-shell { width: 100%; padding: 14px 8px 24px; }
    .header-actions .button { flex: 1 1 auto; }
    .status-grid { grid-template-columns: 1fr; }
    .form-actions { align-items: stretch; }
    .form-actions .button { flex: 1 1 120px; }
    .form-spacer { display: none; }
}

/* =========================================================
   VERSION 4.0 — THÈMES, FOND MODERNE ET OPTIMISATION MOBILE
   ========================================================= */

html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] {
    color-scheme: light;
    --bg: #eef2f8;
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --surface-3: #edf1f7;
    --text: #171923;
    --muted: #667085;
    --border: rgba(31, 41, 55, 0.13);
    --border-strong: rgba(31, 41, 55, 0.24);
    --gold: #c98816;
    --gold-dark: #a86408;
    --danger: #d93b48;
    --success: #158f5b;
    --shadow: 0 28px 75px rgba(35, 47, 66, 0.16);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -3;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,.6), transparent 78%);
}

html[data-theme="light"] body {
    background:
        radial-gradient(circle at 8% -5%, rgba(102, 74, 230, 0.14), transparent 34%),
        radial-gradient(circle at 94% 12%, rgba(245, 196, 94, 0.18), transparent 31%),
        radial-gradient(circle at 54% 105%, rgba(51, 163, 220, 0.10), transparent 37%),
        linear-gradient(145deg, #f8f9fc 0%, #eef2f8 56%, #f8f9fc 100%);
}
html[data-theme="light"] body::before {
    background-image:
        linear-gradient(rgba(28, 39, 61, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(28, 39, 61, .035) 1px, transparent 1px);
}
html[data-theme="light"] .background-glow { opacity: .10; }
html[data-theme="light"] .background-glow-left { background: #7863dc; }
html[data-theme="light"] .background-glow-right { background: #e3a733; }

.theme-toggle { gap: 9px; }
.theme-icon {
    position: relative;
    display: inline-block;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
}
.theme-icon::before,
.theme-icon::after {
    content: "";
    position: absolute;
    border-radius: 50%;
}
html[data-theme="dark"] .theme-icon::before {
    inset: 3px;
    background: var(--gold);
    box-shadow: 0 0 0 1px rgba(245,196,94,.24), 0 0 12px rgba(245,196,94,.42);
}
html[data-theme="dark"] .theme-icon::after {
    inset: 0;
    background:
        linear-gradient(var(--gold), var(--gold)) 50% 0 / 2px 3px no-repeat,
        linear-gradient(var(--gold), var(--gold)) 50% 100% / 2px 3px no-repeat,
        linear-gradient(90deg, var(--gold), var(--gold)) 0 50% / 3px 2px no-repeat,
        linear-gradient(90deg, var(--gold), var(--gold)) 100% 50% / 3px 2px no-repeat;
}
html[data-theme="light"] .theme-icon::before {
    inset: 1px;
    border: 2px solid #3b4253;
    background: #3b4253;
}
html[data-theme="light"] .theme-icon::after {
    top: -1px;
    right: -2px;
    width: 15px;
    height: 15px;
    background: #ffffff;
}

.auth-theme-action {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.mobile-agenda { display: none; }
.mobile-event-count { display: none; }

html[data-theme="light"] .button-secondary,
html[data-theme="light"] .month-nav,
html[data-theme="light"] .modal-close,
html[data-theme="light"] .day-add-button {
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 7px 20px rgba(31, 41, 55, .05);
}
html[data-theme="light"] .button-secondary:hover,
html[data-theme="light"] .month-nav:hover,
html[data-theme="light"] .modal-close:hover { background: #fff; }
html[data-theme="light"] .button-danger-soft {
    color: #ad2633;
    border-color: rgba(198, 43, 57, .22);
    background: rgba(216, 55, 69, .07);
}
html[data-theme="light"] .button-danger {
    color: #9c2530;
    border-color: rgba(198, 43, 57, .28);
    background: rgba(216, 55, 69, .09);
}
html[data-theme="light"] .legend-item {
    background: rgba(255,255,255,.66);
    box-shadow: 0 12px 35px rgba(36, 48, 66, .055);
}
html[data-theme="light"] .admin-help {
    color: #4b5261;
    border-color: rgba(201,136,22,.24);
    background: rgba(255, 246, 224, .72);
}
html[data-theme="light"] .calendar-card {
    background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(246,248,252,.98));
}
html[data-theme="light"] .weekday-row { background: rgba(31,41,55,.035); }
html[data-theme="light"] .calendar-grid { background: rgba(31,41,55,.105); }
html[data-theme="light"] .day-cell { background: #ffffff; }
html[data-theme="light"] .day-cell:nth-child(7n),
html[data-theme="light"] .day-cell:nth-child(7n - 1) { background: #f8f9fc; }
html[data-theme="light"] .day-cell.admin-day:hover,
html[data-theme="light"] .day-cell.admin-day:focus-visible {
    background: #f0f4fa;
    box-shadow: inset 0 0 0 1px rgba(31,41,55,.16);
}
html[data-theme="light"] .day-number { color: #242835; }
html[data-theme="light"] .day-cell.today .day-number { color: #241706; }
html[data-theme="light"] .event-chip {
    color: #222735;
    border-color: rgba(31,41,55,.10);
    background: #f3f5f9;
    box-shadow: 0 4px 13px rgba(31,41,55,.07);
}
html[data-theme="light"] .event-chip.range-chip { color: #071014; }
html[data-theme="light"] .modal-backdrop { background: rgba(27, 34, 48, .54); }
html[data-theme="light"] .modal {
    background: linear-gradient(180deg, #ffffff, #f4f6fa);
    box-shadow: 0 36px 100px rgba(29, 39, 58, .28);
}
html[data-theme="light"] .loading-card,
html[data-theme="light"] .auth-card {
    background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(245,247,251,.99));
}
html[data-theme="light"] .loading-spinner { border-color: rgba(31,41,55,.13); border-top-color: var(--gold); }
html[data-theme="light"] label,
html[data-theme="light"] .type-fieldset legend { color: #343947; }
html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select {
    color: var(--text);
    background: rgba(255,255,255,.9);
}
html[data-theme="light"] select option { background: #fff; }
html[data-theme="light"] .form-section,
html[data-theme="light"] .settings-panel,
html[data-theme="light"] .type-selector span,
html[data-theme="light"] .birthday-banner,
html[data-theme="light"] .status-card,
html[data-theme="light"] .detail-row,
html[data-theme="light"] .detail-note,
html[data-theme="light"] .day-detail-event,
html[data-theme="light"] .event-hero-card {
    background: rgba(255,255,255,.66);
}
html[data-theme="light"] .date-hero span { color: #3e4553; }
html[data-theme="light"] .versus-player {
    background: radial-gradient(circle at 50% 8%, rgba(133,93,255,.10), transparent 56%), rgba(255,255,255,.72);
}
html[data-theme="light"] .toast { box-shadow: 0 18px 55px rgba(31,41,55,.20); }
html[data-theme="light"] .fatal-error { color: #b22835; background: #fff; }

@media (max-width: 820px) {
    .page-shell {
        width: min(100% - 18px, 1540px);
        padding: 16px 0 28px;
    }
    .site-header { margin-bottom: 14px; }
    h1 { font-size: clamp(2.35rem, 13vw, 3.4rem); }
    .header-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        gap: 8px;
        margin-top: 15px;
    }
    .header-actions .button { width: 100%; min-width: 0; padding-inline: 10px; }
    #addEventButton { grid-column: 1 / -1; }

    .category-legend {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 7px;
        margin-bottom: 12px;
    }
    .legend-item {
        flex-direction: column;
        justify-content: center;
        gap: 6px;
        min-height: 76px;
        padding: 9px 5px;
        text-align: center;
        border-radius: 13px;
    }
    .legend-symbol { flex-basis: 31px; width: 31px; height: 31px; border-radius: 9px; }
    .legend-item strong { font-size: .71rem; line-height: 1.05; }
    .legend-item small { display: none; }

    .admin-help {
        display: block;
        margin-bottom: 12px;
        padding: 11px 12px;
        line-height: 1.45;
    }
    .admin-help strong:not(:first-child)::before { content: "\A"; white-space: pre; }

    .calendar-card { border-radius: 18px; }
    .calendar-toolbar { grid-template-columns: 42px 1fr 42px; padding: 12px 9px; gap: 6px; }
    .month-nav { width: 40px; height: 40px; border-radius: 12px; font-size: 1.65rem; }
    .month-title h2 { font-size: 1.28rem; }
    .calendar-scroll { overflow: hidden; }
    .calendar-min-width { min-width: 0; }
    .weekday-row span { padding: 9px 1px; font-size: .58rem; letter-spacing: .035em; }
    .calendar-grid { gap: 1px; }
    .day-cell {
        min-height: 70px;
        padding: 4px 3px 5px;
        cursor: pointer;
    }
    .day-header { min-height: 23px; margin-bottom: 3px; }
    .day-number {
        min-width: 23px;
        height: 23px;
        padding: 0 4px;
        border-radius: 7px;
        font-size: .69rem;
    }
    .day-add-button,
    .empty-cell-hint { display: none; }
    .day-events { gap: 3px; }
    .event-chip {
        min-height: 6px;
        height: 6px;
        padding: 0;
        border: 0;
        border-radius: 999px;
        background: var(--chip-color);
        box-shadow: none;
        pointer-events: none;
    }
    .event-chip.match_off { background: var(--match-color); }
    .event-chip.birthday { background: var(--birthday-color); }
    .event-chip.event { background: var(--event-color); }
    .event-chip:nth-child(n + 4) { display: none; }
    .event-chip.range-chip {
        height: 7px;
        min-height: 7px;
        background: var(--event-color);
    }
    .event-chip.range-start { margin-right: -4px; width: calc(100% + 4px); border-radius: 999px 0 0 999px; }
    .event-chip.range-middle { margin-left: -4px; margin-right: -4px; width: calc(100% + 8px); border-radius: 0; }
    .event-chip.range-end { margin-left: -4px; width: calc(100% + 4px); border-radius: 0 999px 999px 0; }
    .chip-time,
    .chip-label { display: none; }
    .mobile-event-count {
        display: block;
        margin-top: 2px;
        color: var(--muted);
        text-align: center;
        font-size: .55rem;
        font-weight: 850;
    }

    .mobile-agenda {
        display: block;
        margin-top: 14px;
        padding: 15px;
        border: 1px solid var(--border);
        border-radius: 18px;
        background: rgba(255,255,255,.035);
        box-shadow: 0 18px 45px rgba(0,0,0,.10);
    }
    html[data-theme="light"] .mobile-agenda { background: rgba(255,255,255,.72); }
    .mobile-agenda-heading {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 10px;
    }
    .mobile-agenda-heading .eyebrow { margin-bottom: 3px; font-size: .59rem; }
    .mobile-agenda-heading h2 { margin: 0; font-size: 1.16rem; }
    .mobile-agenda-count {
        display: grid;
        place-items: center;
        min-width: 38px;
        height: 38px;
        padding: 0 8px;
        border-radius: 12px;
        color: #1c1407;
        background: var(--gold);
        font-weight: 950;
    }
    .mobile-agenda-help { margin: -2px 0 11px; color: var(--muted); font-size: .73rem; line-height: 1.4; }
    .mobile-agenda-list { display: grid; gap: 8px; }
    .mobile-agenda-empty {
        padding: 17px 12px;
        border: 1px dashed var(--border-strong);
        border-radius: 13px;
        color: var(--muted);
        text-align: center;
        font-size: .82rem;
    }
    .mobile-agenda-item {
        --item-color: var(--event-color);
        display: grid;
        grid-template-columns: 39px minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
        width: 100%;
        min-height: 61px;
        padding: 9px 10px;
        border: 1px solid var(--border);
        border-left: 4px solid var(--item-color);
        border-radius: 13px;
        color: var(--text);
        background: rgba(255,255,255,.035);
        text-align: left;
        cursor: pointer;
    }
    html[data-theme="light"] .mobile-agenda-item { background: rgba(255,255,255,.82); }
    .mobile-agenda-item.match_off { --item-color: var(--match-color); }
    .mobile-agenda-item.birthday { --item-color: var(--birthday-color); }
    .mobile-agenda-item.event { --item-color: var(--event-color); }
    .mobile-agenda-symbol {
        display: grid;
        place-items: center;
        width: 36px;
        height: 36px;
        border-radius: 10px;
        color: #111119;
        background: var(--item-color);
        font-size: .62rem;
        font-weight: 950;
    }
    .mobile-agenda-copy { display: grid; min-width: 0; gap: 3px; }
    .mobile-agenda-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .83rem; }
    .mobile-agenda-copy small { color: var(--muted); font-size: .68rem; }
    .mobile-agenda-action { color: var(--gold); font-size: .68rem; font-weight: 900; }

    .modal-backdrop { align-items: end; padding: 0; }
    .modal {
        width: 100%;
        max-width: none;
        max-height: 92dvh;
        padding: 25px 16px calc(20px + env(safe-area-inset-bottom));
        border-radius: 24px 24px 0 0;
    }
    .modal-close { top: 12px; right: 12px; }
    .modal h2 { margin-right: 44px; }
    .auth-theme-action { top: 12px; right: 12px; }
    .auth-theme-action .button { min-height: 40px; padding-inline: 12px; }
    .auth-shell { align-items: start; padding-top: 78px; }
    .auth-card, .loading-card { width: 100%; }
}

@media (max-width: 440px) {
    .page-shell { width: 100%; padding-inline: 7px; }
    .header-actions { grid-template-columns: 1fr; }
    #addEventButton { grid-column: auto; }
    .header-actions .button { min-height: 46px; }
    .calendar-toolbar { padding-inline: 7px; }
    .day-cell { min-height: 62px; padding-inline: 2px; }
    .weekday-row span { font-size: .54rem; }
    .mobile-agenda { padding: 13px 10px; }
    .mobile-agenda-item { grid-template-columns: 37px minmax(0,1fr); }
    .mobile-agenda-action { display: none; }
    .type-selector { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .type-selector span { flex-direction: column; gap: 4px; min-height: 67px; padding: 6px 3px; }
    .type-selector strong { font-size: .67rem; }
    .versus-stage { gap: 7px; }
    .versus-player { min-height: 92px; }
}

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

html[data-theme="dark"] body {
    background:
        radial-gradient(circle at 10% -4%, rgba(126, 91, 255, .18), transparent 34%),
        radial-gradient(circle at 94% 14%, rgba(245, 196, 94, .10), transparent 31%),
        radial-gradient(circle at 50% 108%, rgba(40, 148, 204, .075), transparent 38%),
        linear-gradient(145deg, #07070c 0%, #0b0b13 56%, #07070c 100%);
}

/* Les bandeaux conservent leurs couleurs en mode clair. */
html[data-theme="light"] .event-chip.range-chip {
    color: #071014;
    background: linear-gradient(90deg, var(--event-color), #2589a5);
}
@media (max-width: 820px) {
    html[data-theme="light"] .event-chip.match_off { background: var(--match-color); }
    html[data-theme="light"] .event-chip.birthday { background: var(--birthday-color); }
    html[data-theme="light"] .event-chip.event,
    html[data-theme="light"] .event-chip.range-chip { background: var(--event-color); }
}


/* =========================================================
   VERSION 4.1 — CONTRASTE DES CATÉGORIES ET DÉCOR AURORA
   ========================================================= */

/* Arrière-plan plus profond, moderne et fixe, sans image externe. */
body {
    background:
        radial-gradient(ellipse 78% 58% at 12% -16%, rgba(112, 78, 255, .22), transparent 67%),
        radial-gradient(ellipse 62% 52% at 104% 8%, rgba(54, 205, 239, .13), transparent 68%),
        radial-gradient(ellipse 62% 56% at -8% 102%, rgba(245, 196, 94, .11), transparent 70%),
        linear-gradient(135deg, #06070d 0%, #0a0d17 48%, #080910 100%);
    background-attachment: fixed;
}
body::before {
    background-image:
        linear-gradient(rgba(255,255,255,.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.022) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,.76), transparent 86%);
}
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    background:
        radial-gradient(circle at 17% 23%, rgba(151, 119, 255, .12) 0 1px, transparent 2px) 0 0 / 42px 42px,
        linear-gradient(118deg, transparent 0 36%, rgba(255,255,255,.025) 36.15% 36.35%, transparent 36.5% 100%),
        linear-gradient(300deg, transparent 0 70%, rgba(245,196,94,.026) 70.15% 70.35%, transparent 70.5% 100%);
    opacity: .72;
    mask-image: radial-gradient(ellipse at 50% 28%, #000 0%, rgba(0,0,0,.72) 48%, transparent 92%);
}

html[data-theme="light"] body {
    background:
        radial-gradient(ellipse 78% 60% at 10% -18%, rgba(116, 87, 235, .23), transparent 66%),
        radial-gradient(ellipse 66% 54% at 104% 4%, rgba(243, 183, 70, .22), transparent 68%),
        radial-gradient(ellipse 72% 56% at 52% 112%, rgba(44, 168, 224, .16), transparent 70%),
        linear-gradient(135deg, #fbfbfd 0%, #eef3fa 48%, #f8f6ef 100%);
    background-attachment: fixed;
}
html[data-theme="light"] body::before {
    background-image:
        linear-gradient(rgba(35,48,72,.043) 1px, transparent 1px),
        linear-gradient(90deg, rgba(35,48,72,.043) 1px, transparent 1px);
    background-size: 48px 48px;
}
html[data-theme="light"] body::after {
    background:
        radial-gradient(circle at 17% 23%, rgba(91, 71, 177, .11) 0 1px, transparent 2px) 0 0 / 42px 42px,
        linear-gradient(118deg, transparent 0 36%, rgba(255,255,255,.52) 36.15% 36.45%, transparent 36.6% 100%),
        linear-gradient(300deg, transparent 0 70%, rgba(201,136,22,.07) 70.15% 70.4%, transparent 70.55% 100%);
    opacity: .64;
}

/* Une identité visuelle explicite pour chaque élément du calendrier. */
.event-chip {
    border-color: color-mix(in srgb, var(--chip-color) 38%, var(--border));
    background:
        linear-gradient(100deg, color-mix(in srgb, var(--chip-color) 13%, transparent), transparent 72%),
        #20202d;
}
.chip-kind {
    display: inline-grid;
    place-items: center;
    flex: 0 0 25px;
    width: 25px;
    height: 20px;
    border: 1px solid color-mix(in srgb, var(--chip-color) 72%, white);
    border-radius: 6px;
    color: #11141b;
    background: var(--chip-color);
    box-shadow: 0 3px 9px color-mix(in srgb, var(--chip-color) 25%, transparent);
    font-size: .56rem;
    font-weight: 950;
    letter-spacing: .025em;
}
.event-chip.range-chip .chip-kind {
    border-color: rgba(7,16,20,.20);
    background: rgba(255,255,255,.72);
}

html[data-theme="light"] .event-chip {
    color: #171b26;
    border-width: 1px;
    border-left-width: 4px;
    border-color: color-mix(in srgb, var(--chip-color) 58%, #cbd3df);
    border-left-color: var(--chip-color);
    background:
        linear-gradient(100deg,
            color-mix(in srgb, var(--chip-color) 25%, white),
            color-mix(in srgb, var(--chip-color) 8%, #f7f9fc) 74%);
    box-shadow:
        0 6px 16px color-mix(in srgb, var(--chip-color) 14%, transparent),
        inset 0 0 0 1px rgba(255,255,255,.66);
}
html[data-theme="light"] .event-chip:hover {
    filter: saturate(1.08) brightness(1.01);
    box-shadow:
        0 9px 22px color-mix(in srgb, var(--chip-color) 20%, transparent),
        inset 0 0 0 1px rgba(255,255,255,.85);
}
html[data-theme="light"] .event-chip.range-chip {
    color: #071014;
    border-left-width: 0;
    border-color: color-mix(in srgb, var(--event-color) 70%, #9eb6c2);
    background: linear-gradient(90deg, var(--event-color), color-mix(in srgb, var(--event-color) 72%, #177d9a));
}

/* Dans la fiche publique, seuls les arobas restent visibles. */
.versus-player {
    min-height: 150px;
    padding: 22px 16px;
}
.versus-player strong {
    margin-top: 0;
    font-size: clamp(1.2rem, 3.2vw, 1.65rem);
    line-height: 1.18;
}
html[data-theme="light"] .versus-player {
    border-color: rgba(42, 51, 68, .22);
    background:
        radial-gradient(circle at 50% 0%, rgba(116,87,235,.13), transparent 62%),
        linear-gradient(145deg, #eef1f6, #e4e9f1);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.92),
        0 12px 28px rgba(43,55,76,.10);
}
html[data-theme="light"] .versus-player strong { color: #171b25; }

@media (max-width: 820px) {
    .chip-kind,
    .chip-time,
    .chip-label { display: none; }
    .versus-player { min-height: 112px; }
}

/* =========================================================
   VERSION 5.0 — COMPTEURS DU MOIS, RECHERCHE ET SAUVEGARDE
   ========================================================= */

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

.legend-item-match { --legend-color: var(--match-color); }
.legend-item-birthday { --legend-color: var(--birthday-color); }
.legend-item-event { --legend-color: var(--event-color); }
.legend-item {
    position: relative;
    overflow: hidden;
}
.legend-item::after {
    content: "";
    position: absolute;
    top: -45px;
    right: -36px;
    width: 120px;
    height: 120px;
    border-radius: 999px;
    background: var(--legend-color, transparent);
    filter: blur(42px);
    opacity: .11;
    pointer-events: none;
}
.legend-copy {
    display: grid;
    min-width: 0;
    flex: 1;
    gap: 3px;
}
.legend-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    gap: 10px;
}
.legend-count {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    min-width: 36px;
    height: 32px;
    padding: 0 9px;
    border: 1px solid color-mix(in srgb, var(--legend-color) 55%, var(--border));
    border-radius: 11px;
    color: color-mix(in srgb, var(--legend-color) 82%, white);
    background: color-mix(in srgb, var(--legend-color) 13%, rgba(255,255,255,.025));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.055);
    font-size: 1rem;
    font-weight: 950;
    line-height: 1;
}
html[data-theme="light"] .legend-count {
    color: color-mix(in srgb, var(--legend-color) 64%, #151923);
    border-color: color-mix(in srgb, var(--legend-color) 54%, #d4dbe5);
    background: color-mix(in srgb, var(--legend-color) 20%, white);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 5px 14px color-mix(in srgb, var(--legend-color) 13%, transparent);
}

.handle-search {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(360px, 580px);
    align-items: center;
    gap: 20px;
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background:
        linear-gradient(100deg, rgba(245,196,94,.065), transparent 44%),
        rgba(255,255,255,.032);
    backdrop-filter: blur(15px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
}
.handle-search-copy {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
}
.handle-search-copy > span:last-child {
    display: grid;
    min-width: 0;
    gap: 3px;
}
.handle-search-copy strong {
    font-size: .92rem;
    line-height: 1.15;
}
.handle-search-copy small {
    color: var(--muted);
    font-size: .74rem;
    line-height: 1.35;
}
.search-icon {
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(245,196,94,.32);
    border-radius: 13px;
    color: #1c1407;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    box-shadow: 0 9px 24px rgba(245,196,94,.14);
    font-size: 1.15rem;
    font-weight: 950;
}
.handle-search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
}
.handle-search-form input[type="search"] {
    width: 100%;
    min-height: 46px;
    padding: 0 15px;
    border: 1px solid var(--border);
    border-radius: 13px;
    outline: none;
    color: var(--text);
    background: rgba(4,5,10,.35);
    transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.handle-search-form input[type="search"]:focus {
    border-color: rgba(245,196,94,.62);
    box-shadow: 0 0 0 4px rgba(245,196,94,.10);
    background: rgba(4,5,10,.52);
}
.handle-search-form input[type="search"]::placeholder { color: color-mix(in srgb, var(--muted) 82%, transparent); }
html[data-theme="light"] .handle-search {
    border-color: rgba(37,48,68,.13);
    background:
        linear-gradient(100deg, rgba(232,164,42,.095), transparent 46%),
        rgba(255,255,255,.72);
    box-shadow: 0 12px 35px rgba(36,48,66,.052), inset 0 1px 0 rgba(255,255,255,.82);
}
html[data-theme="light"] .handle-search-form input[type="search"] {
    color: #171b26;
    border-color: rgba(37,48,68,.16);
    background: rgba(244,247,251,.92);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.84);
}
html[data-theme="light"] .handle-search-form input[type="search"]:focus {
    border-color: rgba(198,132,19,.55);
    background: #fff;
}

.modal-search { width: min(860px, 100%); }
.search-summary {
    display: grid;
    grid-template-columns: 1.35fr 1fr 1fr;
    gap: 10px;
    margin: 18px 0 15px;
}
.search-stat {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 68px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: rgba(255,255,255,.035);
}
.search-stat-total {
    border-color: rgba(245,196,94,.22);
    background: rgba(245,196,94,.065);
}
.search-stat strong {
    display: grid;
    place-items: center;
    min-width: 40px;
    height: 40px;
    padding: 0 8px;
    border-radius: 12px;
    color: #161007;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    font-size: 1.08rem;
    font-weight: 950;
}
.search-stat:not(.search-stat-total) strong {
    color: var(--text);
    border: 1px solid var(--border);
    background: rgba(255,255,255,.06);
}
.search-stat span {
    color: var(--muted);
    font-size: .76rem;
    font-weight: 820;
    line-height: 1.2;
}
.search-results {
    display: grid;
    gap: 9px;
    max-height: min(52vh, 520px);
    overflow: auto;
    padding: 2px 4px 2px 0;
    scrollbar-width: thin;
}
.search-result-item {
    --search-color: var(--match-color);
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 72px;
    padding: 11px 13px;
    border: 1px solid color-mix(in srgb, var(--search-color) 30%, var(--border));
    border-radius: 15px;
    color: var(--text);
    background:
        linear-gradient(100deg, color-mix(in srgb, var(--search-color) 10%, transparent), transparent 56%),
        rgba(255,255,255,.027);
    text-align: left;
    cursor: pointer;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}
.search-result-item.birthday { --search-color: var(--birthday-color); }
.search-result-item:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--search-color) 60%, var(--border));
    background:
        linear-gradient(100deg, color-mix(in srgb, var(--search-color) 15%, transparent), transparent 62%),
        rgba(255,255,255,.045);
}
.search-result-code {
    display: grid;
    place-items: center;
    width: 43px;
    height: 43px;
    border-radius: 12px;
    color: #11141a;
    background: var(--search-color);
    font-size: .68rem;
    font-weight: 950;
}
.search-result-copy {
    display: grid;
    min-width: 0;
    gap: 4px;
}
.search-result-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .91rem;
}
.search-result-copy small {
    overflow: hidden;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .71rem;
}
.search-result-action {
    color: var(--gold);
    font-size: .72rem;
    font-weight: 900;
}
.search-empty {
    display: grid;
    place-items: center;
    min-height: 220px;
    padding: 30px 20px;
    border: 1px dashed var(--border-strong);
    border-radius: 18px;
    text-align: center;
}
.search-empty > span {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 12px;
    border-radius: 16px;
    color: #171005;
    background: linear-gradient(135deg, var(--gold), var(--gold-dark));
    font-size: 1.45rem;
    font-weight: 950;
}
.search-empty strong { font-size: 1.02rem; }
.search-empty p { max-width: 430px; margin: 6px 0 0; color: var(--muted); font-size: .79rem; line-height: 1.45; }
html[data-theme="light"] .search-stat,
html[data-theme="light"] .search-result-item {
    border-color: color-mix(in srgb, var(--search-color, #7f8a9d) 28%, #d3d9e2);
    background:
        linear-gradient(100deg, color-mix(in srgb, var(--search-color, #7f8a9d) 11%, white), transparent 62%),
        rgba(249,250,252,.92);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.88);
}
html[data-theme="light"] .search-stat-total {
    border-color: rgba(198,132,19,.22);
    background: rgba(255,248,231,.92);
}
html[data-theme="light"] .search-stat:not(.search-stat-total) strong {
    color: #1b202b;
    border-color: rgba(37,48,68,.14);
    background: #eef2f7;
}
html[data-theme="light"] .search-result-item:hover {
    border-color: color-mix(in srgb, var(--search-color) 53%, #c8d0dc);
    background:
        linear-gradient(100deg, color-mix(in srgb, var(--search-color) 17%, white), transparent 66%),
        #fff;
}
.security-panel p {
    margin: 0;
    color: var(--muted);
    font-size: .8rem;
    line-height: 1.5;
}

@media (max-width: 920px) {
    .handle-search {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

@media (max-width: 820px) {
    .legend-heading { gap: 5px; }
    .legend-count {
        min-width: 28px;
        height: 27px;
        padding: 0 7px;
        border-radius: 9px;
        font-size: .79rem;
    }
    .handle-search {
        margin-bottom: 12px;
        padding: 11px;
        border-radius: 15px;
    }
    .handle-search-copy small { display: none; }
    .search-icon { flex-basis: 37px; width: 37px; height: 37px; border-radius: 11px; }
    .handle-search-form { grid-template-columns: 1fr; }
    .handle-search-form .button { width: 100%; }
    .search-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .search-stat {
        display: grid;
        place-items: center;
        align-content: center;
        min-height: 76px;
        padding: 8px 5px;
        text-align: center;
        gap: 5px;
    }
    .search-stat strong { min-width: 34px; height: 34px; border-radius: 10px; font-size: .92rem; }
    .search-stat span { font-size: .62rem; }
    .search-result-item { grid-template-columns: 41px minmax(0, 1fr); gap: 9px; min-height: 68px; padding: 10px; }
    .search-result-code { width: 39px; height: 39px; }
    .search-result-action { display: none; }
    .search-result-copy strong { font-size: .82rem; }
    .search-result-copy small { white-space: normal; line-height: 1.35; font-size: .65rem; }
}

@media (max-width: 440px) {
    .handle-search-copy strong { font-size: .82rem; }
    .search-summary { margin-top: 15px; }
    .modal-search h2 { font-size: 1.4rem; overflow-wrap: anywhere; }
}

@media (max-width: 820px) {
    .legend-copy { width: 100%; }
    .legend-heading { justify-content: center; }
}

/* =========================================================
   VERSION 6.0 - IDENTITE, PROFILS, PDF ET SAUVEGARDES
   ========================================================= */

.brand-lockup {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 16px;
}
.site-logo {
    display: block;
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    padding: 5px;
    border: 1px solid rgba(245, 196, 94, .38);
    border-radius: 20px;
    object-fit: cover;
    background: color-mix(in srgb, var(--surface-2) 84%, transparent);
    box-shadow: 0 16px 40px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255,255,255,.08);
}
.site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-top: 24px;
    padding: 17px 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    color: var(--muted);
    background: color-mix(in srgb, var(--surface) 74%, transparent);
    backdrop-filter: blur(18px);
    font-size: .78rem;
}
.site-footer strong { color: var(--text); font-size: .84rem; }

.profile-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    margin-top: 14px;
    padding: 0 13px;
    border: 1px solid color-mix(in srgb, var(--gold) 48%, var(--border));
    border-radius: 999px;
    color: var(--gold);
    background: color-mix(in srgb, var(--gold) 8%, transparent);
    text-decoration: none;
    font-size: .72rem;
    font-weight: 850;
    transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}
.profile-link:hover {
    transform: translateY(-1px);
    border-color: var(--gold);
    background: color-mix(in srgb, var(--gold) 15%, transparent);
}
.versus-player { align-content: center; }

.auth-logo-wrap { margin-bottom: 22px; }
.auth-logo-wrap .auth-logo { margin-bottom: 0; }
.auth-logo-image {
    display: block;
    width: 72px;
    height: 72px;
    padding: 4px;
    border: 1px solid rgba(245,196,94,.48);
    border-radius: 20px;
    object-fit: cover;
    background: rgba(245,196,94,.06);
}
.remember-row {
    grid-template-columns: 22px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 12px 13px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: rgba(255,255,255,.025);
    cursor: pointer;
}
.remember-row input {
    width: 19px;
    min-height: 19px;
    height: 19px;
    margin: 2px 0 0;
    accent-color: var(--gold);
}
.remember-row span { display: grid; gap: 3px; }
.remember-row strong { color: var(--text); font-size: .8rem; }
.remember-row small { color: var(--muted); font-size: .7rem; line-height: 1.4; }
.auth-back-link {
    color: var(--muted);
    text-align: center;
    text-decoration: none;
    font-size: .78rem;
    font-weight: 750;
}
.auth-back-link:hover { color: var(--gold); }

.button-small { min-height: 38px; padding-inline: 13px; font-size: .76rem; }
.logo-settings-panel { gap: 16px; }
.logo-settings-panel p,
.backup-panel p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.52; }
.logo-upload-grid {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    align-items: center;
    gap: 16px;
}
.logo-preview {
    display: grid;
    place-items: center;
    width: 104px;
    height: 104px;
    overflow: hidden;
    border: 1px solid rgba(245,196,94,.35);
    border-radius: 22px;
    color: var(--gold);
    background: radial-gradient(circle at 50% 15%, rgba(245,196,94,.12), transparent 60%), rgba(255,255,255,.035);
    font-weight: 950;
}
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.logo-upload-controls { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 9px; }
.logo-upload-controls small { flex-basis: 100%; color: var(--muted); font-size: .7rem; }
.file-picker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text);
    background: rgba(255,255,255,.055);
    cursor: pointer;
    font-size: .76rem;
    font-weight: 850;
}
.file-picker:hover { border-color: var(--gold); }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.backup-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.backup-panel {
    position: relative;
    align-content: start;
    padding: 19px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255,255,255,.028);
}
.backup-panel h3 { margin: 0; padding-right: 38px; font-size: 1.03rem; }
.backup-step {
    position: absolute;
    top: 16px;
    right: 16px;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    color: #181007;
    background: var(--gold);
    font-weight: 950;
}
.backup-file-picker { width: 100%; min-height: 48px; }

html[data-theme="light"] .site-logo,
html[data-theme="light"] .logo-preview,
html[data-theme="light"] .auth-logo-image {
    background: rgba(255,255,255,.78);
    box-shadow: 0 14px 32px rgba(49,60,80,.10), inset 0 1px 0 #fff;
}
html[data-theme="light"] .site-footer,
html[data-theme="light"] .remember-row,
html[data-theme="light"] .backup-panel {
    border-color: rgba(43,54,75,.15);
    background: rgba(255,255,255,.70);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.8);
}
html[data-theme="light"] .profile-link {
    color: #8d5e08;
    border-color: rgba(176,116,12,.28);
    background: rgba(245,196,94,.14);
}
html[data-theme="light"] .file-picker { color: #1c2230; background: rgba(255,255,255,.82); }

@media (max-width: 1180px) {
    .admin-header .header-actions { justify-content: flex-start; }
}

@media (max-width: 820px) {
    .brand-lockup { gap: 11px; }
    .site-logo { width: 54px; height: 54px; border-radius: 16px; }
    .site-footer { align-items: flex-start; flex-direction: column; gap: 5px; padding: 15px 16px; }
    .backup-grid { grid-template-columns: 1fr; }
    .logo-upload-grid { grid-template-columns: 82px minmax(0, 1fr); }
    .logo-preview { width: 82px; height: 82px; border-radius: 18px; }
    .profile-link { min-height: 31px; margin-top: 10px; padding-inline: 10px; font-size: .66rem; }
    .versus-player { padding-inline: 9px; }
    .admin-header .header-actions .button { flex: 1 1 145px; }
}

@media (max-width: 440px) {
    .site-logo { width: 48px; height: 48px; }
    .logo-upload-grid { grid-template-columns: 1fr; }
    .logo-preview { width: 92px; height: 92px; }
    .logo-upload-controls { width: 100%; }
    .logo-upload-controls .file-picker,
    .logo-upload-controls .button { flex: 1 1 150px; }
    .remember-row { padding: 11px; }
    .profile-link { width: 100%; white-space: normal; line-height: 1.2; }
}
