html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
}

img[src$=".svg"],
svg {
    pointer-events: none;
}

#grille {
    width: 60vmin;
    height: 60vmin;
    display: grid;
    grid-template-columns: repeat(3, 20vmin);
    grid-template-rows: repeat(3, 20vmin);
    aspect-ratio: 1;
    position: relative;
}

#grille .case {
    display: grid;
    place-items: center;
    height: 20vmin;
    width: 20vmin;
    box-sizing: border-box;
    position: relative;
}

#grille .case-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

.grille-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#grille .case::after {
    content: "";
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 80% 80%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
}

#grille[data-current-player="x"] .case:hover::after {
    background-image: url('assets/croix1.svg');
    opacity: 0.3;
}

#grille[data-current-player="o"] .case:hover::after {
    background-image: url('assets/rond1.svg');
    opacity: 0.3;
}

#grille .middle {
    border: solid #013D63;
}

#grille .left {
    border-left: solid #013D63;
}

#grille .bottom {
    border-bottom: solid #013D63;
}

#grille .right {
    border-right: solid #013D63;
}

#grille .top {
    border-top: solid #013D63;
}

#grille .case {
    border-color: transparent;
    z-index: 2;
}

nav {
    margin-top: 1em;
}

body {
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    background-image: url('assets/fond.svg');
    overflow: hidden;
    perspective: 1200px;
}

#message {
    font-family: 'Cedarville Cursive', cursive;
    font-size: 5em;
    text-align: center;
    min-height: 1.5em;
}

#message.message-x {
    color: #FF0000;
}

#message.message-o {
    color: #0051FF;
}

#message.message-bounce {
    animation: message-bounce 0.8s ease-out;
}

@keyframes message-bounce {
    0% {
        transform: translateY(-35px);
        opacity: 0;
    }

    60% {
        transform: translateY(8px);
        opacity: 1;
    }

    80% {
        transform: translateY(-4px);
    }

    100% {
        transform: translateY(0);
    }
}

h1 {
    margin: 0;
    font-family: 'Cedarville Cursive', cursive;
    font-size: 4em;
    text-align: center;
}

.player-wrapper {
    display: flex;
    justify-content: center;
    gap: 2em;
    margin-bottom: 1.5em;
}

.player {
    font-family: 'Cedarville Cursive', cursive;
    display: flex;
    align-items: center;
    text-align: center;
    opacity: 0.3;
    gap: 1em;
    font-size: 28px;
    margin-bottom: 35px;
    transition: opacity 0.25s ease;
}

h2 {
    margin: 0;
}

.player.visible {
    opacity: 1;
    animation: player-bounce 1.4s ease-in-out infinite;
}

.regle {
    position: absolute;
    top: 0;
    left: 0;
    margin-left: 60em;
    margin-top: -1em;
    pointer-events: none;
    z-index: 5;
}

.pencil {
    position: absolute;
    top: 0;
    right: 0;
    margin-top: -5em;
    margin-right: -1em;
    transform: rotate(-17deg);
    z-index: 10;
}

@keyframes player-bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.svg-ligne {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.grille-wrapper {
    display: flex;
    flex-direction: column;
    position: relative;
    justify-content: center;
    align-items: center;
}

.ecran-fin,
.ecran-attente {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100%;
    z-index: 20;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1em;
    padding: 2em;
    box-sizing: border-box;
    overflow: hidden;
    background-color: #ffffff;
    background-image: linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)),
        url('assets/fond.svg');
    background-size: cover;
    background-position: center;
    transform: rotateY(-90deg);
    transform-origin: left center;
    backface-visibility: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.75s cubic-bezier(0.22, 0.61, 0.36, 1),
        opacity 0.15s ease 0.6s, visibility 0s linear 0.75s;
}

.ecran-fin.visible,
.ecran-attente.visible {
    transform: rotateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.75s cubic-bezier(0.22, 0.61, 0.36, 1),
        opacity 0.15s ease, visibility 0s linear;
}

.gif-fin {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 1;
}

.ecran-fin> :not(.gif-fin),
.ecran-attente> :not(.gif-fin) {
    position: relative;
    z-index: 2;
}

.ecran-attente h2 {
    margin: 0;
    font-family: "Cedarville Cursive", cursive;
    font-size: 6em;
    font-weight: 400;
    line-height: 1;
    text-align: center;
}

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5em;
    margin-top: 1em;
}

@media (prefers-reduced-motion: reduce) {

    #grille .case {
        animation: none;
        border-color: transparent;
    }

    .ecran-fin,
    .ecran-fin.visible,
    .ecran-attente,
    .ecran-attente.visible {
        transition: opacity 0.01s linear, visibility 0s linear;
        transform: none;
    }
}

.replay-btn {
    font-family: "Cedarville Cursive", cursive;
    font-size: 2.5em;
    border: none;
    background-color: transparent;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    margin-bottom: 0;
}

.replay-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background-color: rgba(255, 255, 0, 0.6);
    clip-path: inset(0 100% 0 0);
    opacity: 0;
    transition: opacity 0.2s ease, clip-path 0s linear 0.2s;
}

.replay-btn:hover::before {
    clip-path: inset(0);
    opacity: 1;
    transition: clip-path 0.65s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

.replay-instructions {
    font-family: "Cedarville Cursive", cursive;
    font-size: 1.5em;
    color: #013D63;
    margin-top: 0;
}

.cisors {
    position: absolute;
    bottom: 0;
    left: 0;
    right: auto;
    margin-bottom: -2em;
    margin-left: -3em;
    transform: scaleX(-1) rotate(-10deg);
    z-index: 10;
    pointer-events: none !important;
}