html {
    width: 100%;
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

body {
    width: 100%;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;

    background-color: #121213;
    color: white;

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

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#game {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    width: 100%;
    max-width: 700px;
    margin: 0 auto;

    padding: 24px 0;
}

#board {
    display: grid;

    grid-template-columns: repeat(5, 62px);
    grid-template-rows: repeat(6, 62px);

    gap: 6px;
}

.tile {
    width: 62px;
    height: 62px;

    border: 2px solid #3a3a3c;

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

    font-size: 32px;
    font-weight: bold;
    text-transform: uppercase;
}

#keyboard {
    margin-top: 26px;
    width: min(700px, 96vw);
}

.keyboard-row {
    display: flex;
    justify-content: center;

    gap: 5px;
    margin-bottom: 6px;
}

.key {
    min-width: 38px;
    height: 52px;
    padding: 0 10px;

    border: none;
    border-radius: 4px;

    background-color: #818384;
    color: white;

    font-size: 15px;
    font-weight: bold;

    cursor: pointer;

    position: relative;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.key-wide {
    min-width: 70px;
}

.tile.correct,
.key.correct,
.example-tile.correct {
    background-color: #5BC8AF;
    border-color: #5BC8AF;
}

.tile.present,
.key.present,
.example-tile.present {
    background-color: #A78BFA;
    border-color: #A78BFA;
}

.tile.absent,
.key.absent,
.example-tile.absent {
    background-color: #475569;
    border-color: #475569;
}

.tile.typed {
    overflow: hidden;
}

.tile.typed span {
    display: inline-block;
    animation: ink 140ms ease-out;
}

@keyframes ink {
    0% {
        opacity: 0;
        transform: scale(0.55);
        filter: blur(2px);
    }

    70% {
        opacity: 1;
        transform: scale(1.08);
        filter: blur(0);
    }

    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

.tile.reveal {
    animation: inkReveal 420ms ease-out forwards;
}

@keyframes inkReveal {
    0% {
        transform: translateY(4px);
        opacity: 0.65;
        filter: blur(1.5px);
        box-shadow: 0 0 0 rgba(255, 255, 255, 0);
    }

    55% {
        transform: translateY(-2px);
        opacity: 1;
        filter: blur(0);
        box-shadow: 0 0 18px rgba(255, 255, 255, 0.12);
    }

    100% {
        transform: translateY(0);
        opacity: 1;
        filter: blur(0);
        box-shadow: none;
    }
}

.tile.win {
    animation: winGlow 650ms ease-out;
}

@keyframes winGlow {
    0% {
        box-shadow: 0 0 0 rgba(91, 200, 175, 0);
        filter: brightness(1);
    }

    45% {
        box-shadow:
            0 0 18px rgba(91, 200, 175, 0.55),
            inset 0 0 12px rgba(255, 255, 255, 0.18);

        filter: brightness(1.18);
    }

    100% {
        box-shadow: 0 0 0 rgba(91, 200, 175, 0);
        filter: brightness(1);
    }
}

.tile.invalid {
    animation: invalidFlash 320ms ease;
}

@keyframes invalidFlash {
    0% {
        background: #121213;
        border-color: #3a3a3c;
    }

    40% {
        background: #ef4444;
        border-color: #ef4444;
    }

    100% {
        background: #121213;
        border-color: #3a3a3c;
    }
}

.key-variants {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);

    transform: translateX(-50%);

    display: flex;
    gap: 4px;

    padding: 5px;

    background-color: #1e293b;
    border: 1px solid #64748b;
    border-radius: 10px;

    z-index: 20;
}

.key-variants::after {
    content: "";

    position: absolute;
    top: 100%;
    left: 50%;

    transform: translateX(-50%);

    border: 6px solid transparent;
    border-top-color: #64748b;
}

.key-variant {
    width: 42px;
    height: 48px;

    border: none;
    border-radius: 7px;

    background-color: #818384;
    color: white;

    font-size: 20px;
    font-weight: bold;

    cursor: pointer;
}

#game-actions {
    display: flex;
    gap: 10px;

    margin-top: 18px;
    margin-bottom: 0;
}

#game-actions button {
    width: 105px;
    padding: 8px 10px;

    border: none;
    border-radius: 8px;

    background: transparent;
    color: #9ca3af;

    font-size: 14px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background-color 120ms ease,
        color 120ms ease;
}

#game-actions button:hover {
    color: white;
    background-color: #1c1c1e;
}

#game-actions button:disabled {
    opacity: 0.45;
    cursor: default;
}

#hint-button:disabled {
    opacity: 0.45;
    cursor: default;
}

.key.hint {
    background-color: #e9b949;
    color: #172033;

    box-shadow: 0 0 14px rgba(233, 185, 73, 0.45);
    animation: hintGlow 650ms ease-out;
}

.key[data-hint-letter]::after {
    content: attr(data-hint-letter);

    position: absolute;
    top: -8px;
    right: -5px;

    min-width: 20px;
    height: 20px;
    padding: 0 4px;

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

    border-radius: 10px;

    background-color: #e9b949;
    color: #172033;

    font-size: 12px;
    font-weight: 800;
}

@keyframes hintGlow {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(233, 185, 73, 0);
    }

    45% {
        transform: scale(1.08);
        box-shadow: 0 0 22px rgba(233, 185, 73, 0.7);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 14px rgba(233, 185, 73, 0.45);
    }
}

.key[data-result-variant]::before {
    content: attr(data-result-variant);

    position: absolute;
    top: -8px;
    left: -5px;

    min-width: 20px;
    height: 20px;
    padding: 0 4px;

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

    border-radius: 10px;

    color: white;

    font-size: 12px;
    font-weight: 800;
}

.key[data-result-state="correct"]::before {
    background-color: #5bc8af;
}

.key[data-result-state="present"]::before {
    background-color: #b69cff;
}

.key[data-result-state="absent"]::before {
    background-color: #4b5563;
}

.key-variant.correct {
    background-color: #5bc8af;
}

.key-variant.present {
    background-color: #b69cff;
}

.key-variant.absent {
    background-color: #4b5563;
}

.modal {
    position: fixed;
    inset: 0;

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

    background-color: rgba(0, 0, 0, 0.65);

    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    position: relative;

    width: min(560px, 92vw);
    max-height: 85vh;
    overflow-y: auto;

    padding: 32px;

    border: 1px solid #475569;
    border-radius: 16px;

    background-color: #1e293b;
    color: white;

    animation: modalPop 260ms ease-out;
}

@keyframes modalPop {
    0% {
        opacity: 0;
        transform: scale(0.92) translateY(8px);
    }

    70% {
        opacity: 1;
        transform: scale(1.02) translateY(0);
    }

    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h2 {
    margin-top: 0;
}

.modal-content p {
    line-height: 1.5;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;

    border: none;
    background: none;
    color: white;

    font-size: 28px;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.example-word {
    display: flex;
    justify-content: center;

    gap: 5px;
    margin: 16px 0 10px;
}

.example-tile {
    width: 42px;
    height: 42px;

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

    border: 2px solid #3a3a3c;

    font-size: 22px;
    font-weight: bold;
    text-transform: uppercase;
}

.result-content {
    width: min(400px, 90vw);
    padding: 36px 32px 30px;

    text-align: center;
}

.result-emoji {
    font-size: 38px;
    line-height: 1;

    margin-bottom: 18px;
}

.result-title {
    margin: 0;

    font-size: 23px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.result-subtitle {
    margin: 8px 0 26px;

    color: #a8a8ad;

    font-size: 15px;
    line-height: 1.4;
}

.result-share {
    width: 100%;

    padding: 12px 20px;

    border: none;
    border-radius: 10px;

    background-color: #5BC8AF;
    color: #172033;

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

    cursor: pointer;

    transition:
        transform 120ms ease,
        filter 120ms ease;
}

.result-share:hover {
    filter: brightness(1.07);
}

.result-share:active {
    transform: scale(0.98);
}


/* MOBILE */

@media (max-width: 600px) {

    body {
        min-height: 100svh;

        justify-content: flex-start;

        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(8px, env(safe-area-inset-bottom));

        overflow-x: hidden;
        overflow-y: auto;
    }

    #game {
        width: 100%;
        max-width: 430px;

        height: auto;

        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;

        margin: 0 auto;
        padding: 0 8px;
    }

    #board {
        grid-template-columns: repeat(5, 58px);
        grid-template-rows: repeat(6, 58px);

        gap: 5px;

        margin: 0 auto;
    }

    .tile {
        width: 58px;
        height: 58px;

        font-size: 30px;
    }

    #keyboard {
        width: 100%;

        margin-top: 18px;
        margin-left: auto;
        margin-right: auto;

        padding: 0;
    }

    .keyboard-row {
        width: 100%;

        display: flex;
        justify-content: center;

        gap: 4px;
        margin-bottom: 6px;
    }

    .key {
        flex: 1 1 0;

        min-width: 0;
        height: 50px;
        padding: 0;

        font-size: 14px;
    }

    .key-wide {
        flex: 1.45 1 0;
        min-width: 0;
    }

    #game-actions {
        width: 100%;

        display: flex;
        justify-content: center;

        margin-top: 8px;
        margin-bottom: 0;

        gap: 8px;
    }

    #game-actions button {
        width: 96px;
        min-width: 96px;

        padding: 7px 8px;

        font-size: 13px;
    }

    .modal-content {
        width: min(92vw, 520px);
        max-height: 82svh;

        padding: 24px 20px;
    }

    .result-content {
        width: min(90vw, 380px);
        padding: 32px 24px 26px;
    }

    .example-word {
        gap: 4px;
    }

    .example-tile {
        width: 38px;
        height: 38px;

        font-size: 20px;
    }
}