/* ====== GLOBAL ====== */

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem;
    box-sizing: border-box;
}

/* ====== LAYOUT ====== */

.gameWrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.gameHeader {
    width: 100%;
    text-align: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #bab5a1;
}

.gameGrid {
    display: grid;
    position: relative;
    justify-content: center;
    grid-template-rows: repeat(3, minmax(75px, 100px));
    grid-template-columns: repeat(3, minmax(75px, 100px));
    gap: 12px;
    margin-bottom: 2rem;
    padding: 10px;
    background-color: rgba(186, 181, 161, 0.1);
    border-radius: 8px;
}

.status {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 2rem;
    align-items: center;

    font-size: 1.3rem;
    font-weight: 600;
    color: #454138;
    letter-spacing: 2px;
    text-align: center;
    min-height: 1.5em;

    text-transform: capitalize;
}

.gameFooter {
    width: 100%;
    display: flex;
    justify-content: center;
    border-top: 2px solid #bab5a1;
    padding-top: 1.5em;
}

.score-label.active {
    position: relative;
    z-index: 1;
}

.scores {
    display: flex;
    max-width: 324px;
    width: 100%;
    margin: 1rem auto;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 10px 5px;
}

.score-item:not(:last-child) {
    border-right: 2px solid #bab5a1;
}

.score-label {
    font-size: 0.8em;
    margin-bottom: 0.4rem;
    border: none;
    outline: none;
    appearance: none;
    border-radius: 0;
    font-weight: 550;
    transition-duration: 0.2s;
    transition-duration: 0.2s;
    position: relative;
    z-index: 1;

    display: inline-block;
    padding: 0;
    position: relative;
    width: 100%;
    cursor: text;
}

.score-label::before {
    content: "";
    transition: all 0.2s;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
}

.score-label::after {
    content: "";
    transition: all 0.2s;
    transition-timing-function: ease-out;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0;
    background-color: #454138;
    z-index: -1;
}

.score-label.active {
    background-color: #454138;
    color: #dcd8c0;
    box-shadow: 0.2em 0.2em 0.1em 0 #bab5a1;
    background-color: transparent;
}

.score-label.active::before {
    top: -0.2rem;
    bottom: -0.2rem;
    border: solid #454138;
    border-width: 0.1rem 0;
}
.score-label.active::after {
    width: 100%;
}

.ghost-input {
    width: 100%;
    border: none;
    outline: none;
    text-align: center;
    color: inherit;
    font-family: inherit;
    font-weight: inherit;
    font-size: inherit;
    text-transform: inherit;
    padding: 0.35rem 0.5rem;
    background-color: inherit;
    position: relative;
    z-index: 2;
}

.ghost-input:not(:focus, .active) {
    background-color: transparent;
}

.ghost-input:focus {
    background-color: inherit;
}

.score-label .ghost-input:focus {
    color: #454138;
    background-color: #bab5a1;
    transition-duration: 0.4s;
}

.score-label .ghost-input:hover {
    color: #454138;
    background-color: #dcd8c0;
    transition-duration: 0.4s;
}

.score-label.active .ghost-input:focus {
    color: #454138;
    background-color: #dcd8c0;
    transition-duration: 0.4s;
}

.ghost-input.readonly {
    cursor: default;
    pointer-events: none;
    user-select: none;
}

.value {
    font-size: 1.4rem;
    font-weight: bold;
    color: #454138;
}

.animate-score {
    animation: score-pop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ====== CELL STYLES ====== */

.cell {
    position: relative;
    user-select: none;

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

    font-size: 3rem;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.65);

    background-color: #dcd8c0;
    overflow: hidden;

    transition:
        background-color 0.24s,
        color 0.24s,
        box-shadow 0.24s,
        transform 0.24s;
}

/* ====== CELL INTERACTION ====== */

.cell:not(:has(span)) {
    cursor: pointer;
}

.cell:has(span) {
    cursor: default;
    pointer-events: none;
}

.cell:hover {
    background-color: #454138;
    color: #dcd8c0;
    box-shadow: 0px 6px 6px 0px #bab5a1;
}

/* ====== CELL CONTENT ====== */

.cell span:not(:empty) {
    display: block;
    transform-origin: center;
    animation: appear 0.24s cubic-bezier(0.5, 1.8, 0.1, 1.1) forwards;
}

/* ====== CELL WIN LOSE HIGHLIGHT ====== */

.cell.highlight-winner {
    color: #dcd8c0 !important;
    box-shadow: inset 0 0 0 2px #bab5a1;
    transform: scale(1.03);
    z-index: 2;
    transition: transform 0.12s cubic-bezier(0.5, 1.8, 0.1, 1.1);
}

.cell.highlight-winner:after {
    content: "";
    position: absolute;
    inset: 0;

    background-color: #454138;
    z-index: -1;

    transform-origin: left center;
    animation: slide 0.12s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.cell.highlight-winner span {
    animation: blink 0.12s steps(3) 2;
}

.cell.highlight-other {
    background-color: #bab5a1;
    opacity: 0.6;
    transform: scale(0.97);
    transition: all 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ====== ANIMATIONS ====== */

@keyframes appear {
    0% {
        transform: scale(0.3);
        opacity: 0.3;
    }
    60% {
        transform: scale(1.01);
        opacity: 0.9;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes slide {
    from {
        transform: scaleX(0);
    }
    to {
        transform: scaleX(1);
    }
}

@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

@keyframes score-pop {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.4);
        color: #bab5a1;
    }
    100% {
        transform: scale(1);
    }
}
