:root {
    --color-bg: #f4f6f5;
    --color-surface: #ffffff;
    --color-border: #dfe3e1;
    --color-text: #1f2924;
    --color-muted: #6b7670;
    --color-primary: #1f6f4f;
    --color-primary-dark: #164f38;
    --color-danger: #b3452c;
    --color-success: #1f6f4f;
    --color-success-bg: #e2f3ea;
    --color-danger-bg: #f7e6e1;
    --color-danger-border: #e2b3a4;
    --color-input-bg: #ffffff;
    --radius: 8px;
}

:root[data-theme="dark"] {
    --color-bg: #141e1a;
    --color-surface: #1c2924;
    --color-border: #33453d;
    --color-text: #e7efe9;
    --color-muted: #93a89d;
    --color-primary: #34a374;
    --color-primary-dark: #2a8a63;
    --color-danger: #e2795a;
    --color-success: #34a374;
    --color-success-bg: rgba(52, 163, 116, 0.18);
    --color-danger-bg: rgba(226, 121, 90, 0.18);
    --color-danger-border: rgba(226, 121, 90, 0.4);
    --color-input-bg: #1c2924;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.7rem;
    background: var(--color-primary-dark);
    color: #fff;
}

.site-header .logo {
    position: absolute;
    top: 4px;
    left: 4px;
    display: flex;
    align-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    z-index: 1;
}

.site-header .logo-icone {
    width: 60px;
    height: 60px;
    margin:0 0 0 2px;

}

.site-header .logo-texte {
    margin-top:-1rem;
    margin-left: -0.4rem;
}

.site-header nav a {
    color: #eaf3ee;
    text-decoration: none;
    margin-left: 0.5rem;
    font-size: 0.95rem;
}

.site-header nav a:hover { text-decoration: underline; }

.site-header nav a.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    vertical-align: middle;
}

.site-header nav a.nav-icon:hover {
    background: rgba(255, 255, 255, 0.24);
    text-decoration: none;
}

.site-header nav a.nav-icon svg {
    width: 1.1rem;
    height: 1.1rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-left: 0.5rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    vertical-align: middle;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.24); }

.icon-btn svg { width: 1.1rem; height: 1.1rem; display: block; }

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-left: 0.5rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
    vertical-align: middle;
}

.theme-toggle:hover { background: rgba(255, 255, 255, 0.24); }

.theme-toggle svg { width: 1.1rem; height: 1.1rem; display: block; }

.theme-toggle .icon-lune { display: none; }

:root[data-theme="dark"] .theme-toggle .icon-soleil { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-lune { display: block; }

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
}

.switch-label {
    color: var(--color-text);
}

.switch {
    position: relative;
    display: inline-block;
    width: 2.75rem;
    height: 1.5rem;
    flex-shrink: 0;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--color-border);
    border-radius: 999px;
    transition: background 0.15s ease;
}

.switch-slider::before {
    content: "";
    position: absolute;
    top: 0.15rem;
    left: 0.15rem;
    width: 1.2rem;
    height: 1.2rem;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.15s ease;
}

.switch input:checked + .switch-slider {
    background: var(--color-primary);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(1.25rem);
}

.switch input:focus-visible + .switch-slider {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

#select-langue {
    width: auto;
    flex-shrink: 0;
    padding: 0.35rem 1.8rem 0.35rem 0.6rem;
    font-size: 0.9rem;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0.5rem;
}

h1 { font-size: 1.1rem; margin:0.5rem 0 }
h2 { font-size: 1rem; margin: 0 0 0.5rem 0; }

.partie-col-titre {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.5rem 0;
}

.subtitle { 
    color: var(--color-muted);
    margin-top: 0; 
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    margin-bottom: 1.2rem;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: #fff;
    border: 1px solid transparent;
    border-radius: var(--radius);
    text-decoration: none;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.2;
    vertical-align: middle;
    cursor: pointer;
}

.btn:hover { background: var(--color-primary-dark); }

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover { background: var(--color-bg); }

.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: #8c331f; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.85rem; }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;

}

th, td {
    text-align: left;
    padding: 0.5rem;
    font-size: 0.92rem;
}

th { background: var(--color-bg); font-weight: 600; }

table tr { box-shadow: inset 0 -1px 0 0 var(--color-border); }

tbody tr:last-child { box-shadow: none; }

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }

.score-positif { color: var(--color-success); font-weight: 600; }
.score-negatif { color: var(--color-danger); font-weight: 600; }

form .field {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    font-size: 0.9rem;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--color-input-bg);
    color: var(--color-text);
}

.actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    justify-content: center;
    text-align:center;
    margin: 1rem 0;
}

.empty-state {
    text-align: center;
    color: var(--color-muted);
    padding: 0.5rem;
}

.error-box {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid var(--color-danger-border);
    border-radius: var(--radius);
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
}

.preview-box {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    margin: 1rem 0;
    font-size: 0.92rem;
}

.preview-box .row { display: flex; justify-content: space-between; padding: 0.15rem 0; }
.preview-box .row strong { font-weight: 600; }

.totaux-list { list-style: none; padding: 0; margin: 0; }
.totaux-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0.2rem;
    border-bottom: 1px solid var(--color-border);
}
.totaux-list li:last-child { border-bottom: none; }
.totaux-list .rang { color: var(--color-muted); width: 1rem; display: inline-block; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1rem;
}

.btn-icon-text {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-icon-text .btn-icon {
    display: inline-flex;
    align-items: center;
    width: 1rem;
    height: 1rem;
}

.btn-icon-text .btn-icon svg { width: 100%; height: 100%; }

.btn-icon-text .btn-text { display: none; }
.btn-icon-text { padding: 0.45rem 0.6rem; }

.btn-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-with-icon .btn-icon {
    display: inline-flex;
    align-items: center;
    width: 1rem;
    height: 1rem;
}

.btn-with-icon .btn-icon svg { width: 100%; height: 100%; }

@media (max-width: 560px) {
    .form-grid { grid-template-columns: 1fr; }

    .col-date { display: none; }
    .col-manche-extra { display: none; }

    .table-wrap { overflow-x: hidden; }
    .table-wrap thead { display: none; }

    .btn-with-icon .btn-text { display: none; }
    .btn-with-icon { padding: 0.45rem 0.6rem; }

    .btn-with-icon.btn-keep-label .btn-text { display: inline; }
    .btn-with-icon.btn-keep-label { padding: 0.5rem 1rem; }
}

.avatar-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.avatar-item {
    display: inline-flex;
    cursor: pointer;
    padding: 3px;
    border-radius: 50%;
    border: 2px solid transparent;
}

.avatar-item input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.avatar-item:has(input:checked) {
    border-color: var(--color-text);
}

.avatar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    color: #fff;
    background: var(--color-muted);
}

.avatar-icon svg {
    width: 68%;
    height: 68%;
}

.couleur-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.couleur-item {
    display: inline-flex;
    cursor: pointer;
    padding: 3px;
    border-radius: 50%;
    border: 2px solid transparent;
}

.couleur-item input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.couleur-item:has(input:checked) {
    border-color: var(--color-text);
}

.couleur-swatch {
    display: inline-block;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.15);
}

.joueur-choice-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.6rem;
}

.joueur-choice-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    text-align: center;
    min-height: 3rem;
    padding: 0.3rem;
    border-radius: var(--radius);
    border: 3px solid transparent;
    color: #fff;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;

}

.joueur-choice-avatar {
    width: 4rem;
    height: 4rem;
    background: rgba(255, 255, 255, 0.28);
    flex-shrink: 0;
}

.joueur-choice-nom {
    font-size: 0.8rem;
    word-break: break-word;
}

.joueur-choice-item input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.joueur-choice-item:has(input:checked) {
    border-color: var(--color-text);
    box-shadow: 0 0 0 2px #fff inset;
}

.joueur-choice-item.joueur-choice-none {
    background: var(--color-surface);
    color: var(--color-text);
    border: 3px solid var(--color-border);
}

.joueur-choice-item.joueur-choice-none:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-success-bg);
    box-shadow: none;
}

.joueur-choice-item.is-hidden {
    display: none;
}

.option-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.6rem;
}

.option-list-wide {
    grid-template-columns: 1fr;
}

.option-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 3rem;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    border: 2px solid var(--color-border);
    background: var(--color-input-bg);
    color: var(--color-text);
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.2;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.option-item input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.option-item:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-success-bg);
    color: var(--color-primary-dark);
}

.wizard-number-input {
    width: 100%;
    padding: 0.9rem;
    font-size: 1.6rem;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
}

.points-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.points-stepper .wizard-number-input {
    width: 4.5rem;
    flex: none;
    padding: 0.6rem 0.3rem;
    font-size: 1.3rem;
    appearance: textfield;
    -moz-appearance: textfield;
}

.points-stepper .wizard-number-input::-webkit-inner-spin-button,
.points-stepper .wizard-number-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.btn-step {
    flex: none;
    border: none;
    border-radius: var(--radius);
    padding: 0.55rem 0.75rem;
    background: var(--color-primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.btn-step:hover {
    background: var(--color-primary-dark);
}

.btn-step-sm {
    padding: 0.4rem 0.55rem;
    font-size: 0.78rem;
}

.points-section + .points-separator {
    margin: 1.4rem 0;
    border: none;
    border-top: 1px solid var(--color-border);
}

.wizard-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 20, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}

.wizard-modal {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1.4rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.wizard-close {
    position: absolute;
    top: 0.6rem;
    right: 0.7rem;
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--color-muted);
    text-decoration: none;
    cursor: pointer;
}

.wizard-progress {
    color: var(--color-muted);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
}

.wizard-step h2 {
    margin-top: 0;
    font-size:01rem;
}

.wizard-error {
    color: var(--color-danger);
    font-size: 0.9rem;
    margin-top: 0.6rem;
    min-height: 1.2em;
}

.wizard-nav {
    display: flex;
    gap: 0.6rem;
    margin-top: 1.4rem;
}

.wizard-nav .btn {
    flex: 1;
    text-align: center;
    min-height: 3rem;
    font-size: 1.05rem;
}

@media (max-width: 560px) {
    .wizard-overlay { padding: 0.6rem; }
    .wizard-modal {
        max-width: none;
        width: 100%;
        max-height: calc(100vh - 1.2rem);
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    }
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 20, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 100;
}

.modal-box {
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1.4rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 0.6rem;
    right: 0.7rem;
    width: 2.2rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--color-muted);
    text-decoration: none;
    cursor: pointer;
}

.modal-box-confirm {
    max-width: 380px;
    text-align: center;
}

.modal-box-confirm h2 {
    margin-top: 0;
}

.modal-box-confirm .actions {
    margin-bottom: 0;
}

@media (max-width: 560px) {
    .modal-overlay { padding: 0.6rem; }
    .modal-box {
        max-width: none;
        width: 100%;
        max-height: calc(100vh - 1.2rem);
        box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    }

    .avatar-list,
    .couleur-list {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        justify-items: center;
        gap: 0.4rem;
    }

    .joueur-choice-list {
        grid-template-columns: repeat(2, 1fr);
    }

    .joueur-choice-avatar {
        width: 3rem;
        height: 3rem;
    }
}

/* ---- animations d'apparition/disparition des modales ---- */
@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes modal-scale-in {
    from { opacity: 0; transform: translateY(14px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes modal-scale-out {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(10px) scale(0.96); }
}

.modal-overlay,
.wizard-overlay {
    animation: modal-fade-in 0.18s ease both;
}

.modal-overlay.is-closing,
.wizard-overlay.is-closing {
    animation: modal-fade-out 0.15s ease both;
}

.modal-box,
.wizard-modal {
    animation: modal-scale-in 0.22s cubic-bezier(0.22, 0.9, 0.35, 1.1) both;
}

.modal-overlay.is-closing .modal-box,
.wizard-overlay.is-closing .wizard-modal {
    animation: modal-scale-out 0.15s ease both;
}

.wizard-step {
    animation: modal-fade-in 0.2s ease both;
}

@keyframes wizard-modal-in-from-right {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes wizard-modal-in-from-left {
    from { opacity: 0; transform: translateX(-60px); }
    to { opacity: 1; transform: translateX(0); }
}

.wizard-modal.slide-next {
    animation: wizard-modal-in-from-right 0.25s cubic-bezier(0.22, 0.9, 0.35, 1.1) both;
}

.wizard-modal.slide-prev {
    animation: wizard-modal-in-from-left 0.25s cubic-bezier(0.22, 0.9, 0.35, 1.1) both;
}

@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .wizard-overlay,
    .modal-box,
    .wizard-modal,
    .wizard-step,
    .wizard-modal.slide-next,
    .wizard-modal.slide-prev,
    .modal-overlay.is-closing,
    .wizard-overlay.is-closing,
    .modal-overlay.is-closing .modal-box,
    .wizard-overlay.is-closing .wizard-modal {
        animation: none;
    }
}

.joueur-nom-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.joueur-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    color: #fff;
}

.joueur-icon svg {
    width: 68%;
    height: 68%;
}

.manche-heure {
    display: block;
    font-size: 0.70rem;
    color: var(--color-muted);
}

.parties-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.partie-card {
    display: block;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
    text-decoration: none;
    color: var(--color-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.partie-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.partie-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}

.partie-card-date {
    font-weight: 600;
}

.partie-card-manches {
    color: var(--color-muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.partie-card-joueurs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    color: var(--color-muted);
    font-size: 0.9rem;
}

.partie-card-joueur {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--color-bg);
    border-radius: 999px;
    padding: 0.15rem 0.6rem 0.15rem 0.15rem;
}

.joueur-icon-sm {
    width: 1.3rem;
    height: 1.3rem;
}

.partie-col-scores .card {
    margin-bottom: 0;
}

.actions-column {
    flex-direction: column;
    align-items: stretch;
}

.actions-column .btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (min-width: 700px) {
    .partie-layout {
        display: flex;
        align-items: flex-start;
        gap: 1.2rem;
    }

    .partie-col-scores {
        flex: 0 0 260px;
        position: sticky;
        top: 4.5rem;
    }

    .partie-col-manches {
        flex: 1 1 auto;
        min-width: 0;
        margin-top:0.6rem;
    }
}

@media (min-width: 700px) and (max-width: 800px) {
    .col-bouts-points { display: none; }
}
