: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: 760px) {
    .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; }
}
