body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
    background-color: black;
    color: black;
    transition: background-color 1s ease-in-out;
}

body.complete {
    background-color: red;
}

header {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
    box-sizing: border-box;
}

header a {
    color: white;
    text-decoration: none;
}

header a:hover {
    text-decoration: underline;
}

p {
    margin: 0; 
    word-break: break-word;
    font-size: 1.5em;
    padding: 20px;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    box-sizing: border-box;
    gap: 5px;
}

@media (max-width: 900px) {
    main {
        width: 90vw;
        font-size: 1.2em;
    }
}

.row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
}

.square {
    width: calc(100vw / 5);
    height: calc(100vh / 5);
    overflow: scroll;
    color: transparent;
    user-select: none;
    background-color: white;
}
.square:hover,
.square.revealed {
    color: white;
    background-color: black;
    transition: color 0.5s ease-in-out;
}

.square img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
    opacity: 0;
    transition: opacity 0.5s ease-in-out, filter 1s ease-in-out;
}

.square:hover img,
.square.revealed img {
    opacity: 1;
}

.complete .square img {
    filter: invert(1);
    animation: negative 1s steps(1) 1s infinite;
}

/* Snaps between negative and normal; starts once the 1s fade to negative is done */
@keyframes negative {
    0%  { filter: invert(1); }
    50% { filter: invert(0); }
}

.complete .square {
    background-color: transparent;
    transition: color 0.5s ease-in-out, background-color 1s ease-in-out;
}

/* Let the growing sentences spill out over the grid, but not scroll the page */
body.complete {
    overflow: hidden;
}

.complete .square {
    overflow: visible;
}

.complete .square p {
    position: relative;
    z-index: 1;
}
