/* =========================================================
   COLOR CORRECTION
   ========================================================= */

/* ---------------------------------------------------------
   RESET
--------------------------------------------------------- */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family:
        Arial,
        Helvetica,
        sans-serif;

    background: #101218;
    color: #f2f2f2;
}

button,
input {
    font: inherit;
}


/* =========================================================
   APPLICATION
   ========================================================= */

.app {
    width: 100%;
    max-width: 1400px;

    margin: 0 auto;
    padding: 30px 20px;
}


/* =========================================================
   ECRANS
   ========================================================= */

.screen {
    display: none;
}

.screen.active {
    display: block;
}


/* =========================================================
   CARTES
   ========================================================= */

.card {
    background: #1b1f29;

    border: 1px solid #343a48;
    border-radius: 18px;

    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.35);
}


/* =========================================================
   ECRAN DE DEPART
   ========================================================= */

.start-card {
    width: 100%;
    max-width: 600px;

    margin: 100px auto;
    padding: 45px;
}

.start-card h1 {
    margin: 0 0 15px;

    font-size: 42px;
    line-height: 1.1;
}

.start-card p {
    margin: 0 0 30px;

    color: #b8becb;
    font-size: 17px;
    line-height: 1.5;
}


/* =========================================================
   FORMULAIRE
   ========================================================= */

.start-card label {
    display: block;

    margin-bottom: 10px;

    color: #ffffff;
    font-weight: 700;
}

#playerName {
    display: block;

    width: 100%;
    height: 50px;

    margin-top: 8px;
    padding: 0 15px;

    background: #11141b;
    color: #ffffff;

    border: 1px solid #3a4050;
    border-radius: 10px;

    outline: none;
}

#playerName:focus {
    border-color: #6c5ce7;

    box-shadow:
        0 0 0 3px rgba(108, 92, 231, 0.15);
}

#playerName::placeholder {
    color: #737987;
}


/* =========================================================
   BOUTONS
   ========================================================= */

button {
    display: block;

    width: 100%;
    height: 50px;

    margin-top: 20px;

    padding: 0 20px;

    border: 0;
    border-radius: 10px;

    background: #6c5ce7;
    color: #ffffff;

    font-size: 16px;
    font-weight: 700;

    cursor: pointer;

    transition:
        background 0.2s ease,
        transform 0.15s ease,
        opacity 0.2s ease;
}

button:hover {
    background: #7b6cf0;
}

button:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.5;

    cursor: not-allowed;

    transform: none;
}


/* =========================================================
   MESSAGES D'ERREUR
   ========================================================= */

.error {
    min-height: 20px;

    margin: 15px 0 0;

    color: #ff6b6b;

    font-size: 14px;
}


/* =========================================================
   HEADER DU JEU
   ========================================================= */

.topbar {
    display: flex;

    justify-content: space-between;
    align-items: center;

    width: 100%;

    margin-bottom: 25px;
    padding: 18px 22px;

    background: #1b1f29;

    border: 1px solid #343a48;
    border-radius: 14px;

    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.25);
}

#roundLabel {
    font-size: 18px;
    font-weight: 700;
}

#playerLabel {
    color: #aeb5c3;

    font-size: 15px;
}


/* =========================================================
   LAYOUT DU JEU
   ========================================================= */

.game-layout {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        360px;

    gap: 25px;

    align-items: start;
}


/* =========================================================
   IMAGE
   ========================================================= */

.image-card {
    display: flex;

    justify-content: center;
    align-items: center;

    min-width: 0;
    min-height: 400px;

    padding: 20px;

    background: #1b1f29;

    border: 1px solid #343a48;
    border-radius: 18px;

    box-shadow:
        0 20px 50px rgba(0, 0, 0, 0.30);
}

#gameCanvas {
    display: block;

    max-width: 100%;
    max-height: 75vh;

    width: auto;
    height: auto;

    border-radius: 10px;

    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.35);
}


/* =========================================================
   CONTROLES
   ========================================================= */

.controls {
    width: 100%;

    padding: 28px;
}

.controls h2 {
    margin: 0 0 30px;

    font-size: 28px;
}


/* =========================================================
   CONTROLE INDIVIDUEL
   ========================================================= */

.control {
    margin-bottom: 28px;
}

.control:last-of-type {
    margin-bottom: 10px;
}


/* =========================================================
   EN-TETE DU CONTROLE
   ========================================================= */

.control-header {
    display: flex;

    justify-content: space-between;
    align-items: center;

    margin-bottom: 10px;
}

.control-header span {
    color: #ffffff;

    font-size: 15px;
    font-weight: 700;
}

.control-header output {
    min-width: 50px;

    color: #b8becb;

    text-align: right;

    font-size: 15px;
    font-weight: 700;
}


/* =========================================================
   BARRES DE COULEUR
   ========================================================= */

.color-bar {
    position: relative;

    width: 100%;
    height: 30px;

    overflow: visible;

    border-radius: 15px;

    cursor: pointer;

    user-select: none;
    touch-action: none;

    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.18),
        0 3px 8px rgba(0, 0, 0, 0.35);

    transition:
        box-shadow 0.15s ease,
        transform 0.1s ease;
}

.color-bar:hover {
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.30),
        0 4px 12px rgba(0, 0, 0, 0.45);
}

.color-bar:active {
    transform: scaleY(1.08);
}


/* =========================================================
   BARRE TEINTE
   ========================================================= */

.hue-bar {
    background:
        var(
            --hue-gradient,
            linear-gradient(
                to right,
                hsl(240, 100%, 50%),
                hsl(180, 100%, 50%),
                hsl(120, 100%, 50%),
                hsl(60, 100%, 50%),
                hsl(0, 100%, 50%),
                hsl(300, 100%, 50%),
                hsl(240, 100%, 50%)
            )
        );
}


/* =========================================================
   BARRE SATURATION
   ========================================================= */

.saturation-bar {
    background:
        var(
            --saturation-gradient,
            linear-gradient(
                to right,
                #888888,
                #ff0000
            )
        );
}


/* =========================================================
   BARRE LUMINOSITE
   ========================================================= */

.brightness-bar {
    background:
        var(
            --brightness-gradient,
            linear-gradient(
                to right,
                #000000 0%,
                #808080 50%,
                #ffffff 100%
            )
        );
}


/* =========================================================
   MARQUEUR
   ========================================================= */

.color-marker {
    position: absolute;

    top: 50%;

    width: 24px;
    height: 24px;

    transform:
        translate(-50%, -50%);

    border-radius: 50%;

    background: #ffffff;

    border: 3px solid #22252d;

    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.65);

    pointer-events: none;

    transition:
        left 0.05s linear;
}


/* =========================================================
   BOUTON DE VALIDATION
   ========================================================= */

#validateBtn {
    margin-top: 25px;
}


/* =========================================================
   RESULTATS
   ========================================================= */

.result-card {
    width: 100%;
    max-width: 650px;

    margin: 60px auto;

    padding: 40px;

    text-align: center;
}

.result-card h1 {
    margin: 0 0 30px;

    font-size: 40px;
}


/* =========================================================
   LISTE DES SCORES
   ========================================================= */

#scores {
    display: flex;

    flex-direction: column;

    gap: 10px;

    margin-bottom: 25px;
}

.score-line {
    display: flex;

    justify-content: space-between;
    align-items: center;

    padding: 15px 18px;

    background: #11141b;

    border: 1px solid #343a48;
    border-radius: 10px;
}

.score-line span {
    color: #b8becb;
}

.score-line strong {
    color: #ffffff;
}


/* =========================================================
   TOTAL / MOYENNE
   ========================================================= */

.total,
.average {
    display: flex;

    justify-content: space-between;
    align-items: center;

    margin-top: 12px;
    padding: 18px;

    background: #11141b;

    border-radius: 10px;
}

.total strong,
.average strong {
    color: #7b6cf0;

    font-size: 22px;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {

    .app {
        padding: 20px 15px;
    }

    .game-layout {
        grid-template-columns: 1fr;
    }

    .controls {
        max-width: none;
    }

    .image-card {
        min-height: 250px;
    }

    #gameCanvas {
        max-height: 60vh;
    }
}


@media (max-width: 600px) {

    .start-card {
        margin: 30px auto;

        padding: 30px 22px;
    }

    .start-card h1 {
        font-size: 32px;
    }

    .topbar {
        flex-direction: column;

        gap: 8px;

        align-items: flex-start;
    }

    .image-card {
        padding: 10px;

        min-height: 200px;
    }

    .controls {
        padding: 22px 18px;
    }

    .controls h2 {
        font-size: 24px;
    }

    .result-card {
        margin: 30px auto;

        padding: 30px 20px;
    }

    .result-card h1 {
        font-size: 32px;
    }
/* =========================================================
   RESULTAT D'UNE MANCHE
========================================================= */

.round-result-card {
    width: min(1100px, 95vw);
    text-align: center;
}


.round-result-label {
    margin-top: -10px;
    margin-bottom: 30px;
    opacity: 0.75;
    font-size: 1.1rem;
}


.result-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}


.result-image-block h2 {
    margin-bottom: 15px;
}


.result-image-frame {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.15);
}


.result-image-frame canvas,
.result-image-frame img {
    display: block;
    max-width: 100%;
    max-height: 500px;
    width: auto;
    height: auto;
    object-fit: contain;
}


.round-score {
    margin: 35px 0 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}


.round-score span {
    font-size: 1rem;
    opacity: 0.7;
}


.round-score strong {
    font-size: 3rem;
    line-height: 1;
}


/* =========================================================
   RESPONSIVE RESULTAT
========================================================= */

@media (max-width: 700px) {

    .result-images {
        grid-template-columns: 1fr;
        gap: 25px;
    }


    .result-image-frame canvas,
    .result-image-frame img {
        max-height: 350px;
    }


    .round-score strong {
        font-size: 2.5rem;
    }
}