@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background-color: #534552;
    font-family: 'Press Start 2P', monospace;
    color: #ffffff;
    overflow: hidden;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.hidden {
    display: none !important;
}

#start-screen {
    position: relative;
    width: 90vmin;
    height: 60vmin;
    border: 4px solid #000000;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    overflow: hidden;
    background-color: #000000;
}

#bg-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#bg-layer img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    image-rendering: pixelated;
}

#title-wrapper {
    position: absolute;
    top: 14%;
    left: 12.5%;
    width: 58%;
    z-index: 5;
}

h1 {
    font-size: 2.2vmin;
    color: #ffffff;
    font-weight: normal;
    text-transform: uppercase;
    line-height: 1.3;
    text-shadow: 3px 3px 0 #000000;
}

#menu {
    position: absolute;
    top: 28.5%;
    left: 3%;
    display: grid;
    grid-template-rows: repeat(2, auto);
    row-gap: 1.8vmin;
    z-index: 6;
}

#menu button {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.6vmin;
    padding: 0;
    height: 9vmin;
    width: 29.5vmin;
    background-color: #ffffff;
    color: #000000;
    border: 3px solid #000000;
    cursor: pointer;
    box-shadow: 3px 3px 0 #000000;
    display: grid;
    place-items: center;
}

#replay, #btn-home, #btn-close-credits {
    font-family: 'Press Start 2P', monospace;
    font-size: 1.4vmin;
    padding: 1vmin 2vmin;
    background-color: #ffffff;
    color: #000000;
    border: 3px solid #000000;
    cursor: pointer;
    box-shadow: 3px 3px 0 #000000;
    text-align: center;
}

#menu button:active, #replay:active, #btn-home:active, #btn-close-credits:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #000000;
}

#alien-hero {
    position: absolute;
    bottom: 5%;
    left: 20%;
    width: 18vmin;
    height: 18vmin;
    z-index: 4;
}

#cow-hero {
    position: absolute;
    bottom: 5%;
    right: 15%;
    width: 18vmin;
    height: 18vmin;
    z-index: 4;
}

#alien-hero img, #cow-hero img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

#credits-modal {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10;
    place-items: center;
}

#credits-modal.active {
    display: grid;
}

#credits-modal article {
    background: #1a1a24;
    border: 3px solid #ffffff;
    padding: 4vmin;
    text-align: center;
    display: grid;
    grid-template-rows: repeat(3, auto);
    row-gap: 2vmin;
}

main#game-screen {
    position: relative;
    width: 90vmin;
    height: 90vmin;
    overflow: hidden;
}

#game-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#game-bg img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

#game-header {
    position: absolute;
    top: 3.5%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    z-index: 5;
    display: grid;
    justify-items: center;
    row-gap: 1vmin;
}

#game-header h1 {
    font-size: 1.6vmin;
    white-space: nowrap;
}

#turn-banner {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 1.5vmin;
    align-items: center;
    background: rgba(37, 37, 51, 0.95);
    padding: 0.8vmin 1.8vmin;
    border: 3px solid #000000;
    box-shadow: 3px 3px 0 #000000;
}

.turn-icon {
    width: 4vmin;
    height: 4vmin;
    display: grid;
    place-items: center;
}

#turn-text {
    font-size: 1.4vmin;
}

#status-section {
    position: absolute;
    top: 20.5%;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    z-index: 5;
    text-align: center;
}

#message {
    font-size: 1.6vmin;
    min-height: 2.5vmin;
    color: #ffaa00;
    text-shadow: 2px 2px 0 #000000;
}

#board-section {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48vmin;
    height: 48vmin;
    z-index: 4;
}

#grille {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2vmin;
}

#grille .case {
    border: none;
    display: grid;
    place-items: center;
    background: transparent;
    cursor: pointer;
    outline: none;
    padding: 0;
}

#grille .case:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sprite-icon {
    display: grid;
    width: 85%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.sprite-icon::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 100%;
    height: 110%;
    background-repeat: no-repeat;
    background-size: 100% 715%;
    image-rendering: pixelated;
    animation: spriteLoop 6s steps(1, end) infinite;
}

.sprite-icon.alien::after {
    background-image: url('../SPRITE EXTRA.png');
}

.sprite-icon.cow::after {
    background-image: url('../SPRITE VACHE.png');
}

@keyframes spriteLoop {
    0% {
        background-position: 0 0%;
    }
    3% {
        background-position: 0 17%;
    }
    6% {
        background-position: 0 33%;
    }
    9% {
        background-position: 0 50%;
    }
    12% {
        background-position: 0 67%;
    }
    15% {
        background-position: 0 83%;
    }
    18% {
        background-position: 0 100%;
    }
    21%, 100% {
        background-position: 0 0%;
    }
}

#game-nav {
    position: absolute;
    bottom: 5.5%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 2vmin;
}

#board-section {
    position: relative;
}

.win-line {
    position: absolute;
    z-index: 10;
    background-color: #ffffff;
    border: 2px solid #000000;
    box-shadow: 2px 2px 0 #000000;
    transform-origin: left center;
    animation: drawLine 0.4s ease-out forwards;
    pointer-events: none;
}

.win-line.alien {
    background-color: #00ff00;
}

.win-line.cow {
    background-color: #ffffff;
}

@keyframes drawLine {
    0% {
        width: 0;
    }
    100% {
        width: var(--line-length);
    }
}