.last-war-body {
    margin: 0;
    padding: 0;
    height: 100dvh;
    height: 100vh;
    background-color: #f8f994;
    overflow: hidden;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    -webkit-text-size-adjust: 100%;
}

.last-war-app {
    height: 100dvh;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    --lw-header: 128px;
    --lw-size: min(
        calc(100vw - 20px),
        calc((100dvh - var(--lw-header)) * 5 / 6),
        540px
    );
}

.last-war-header {
    flex-shrink: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
    background: #f8f994;
}

.last-war-back {
    position: static;
    align-self: flex-start;
    margin: 0;
    color: #333;
    border-color: rgba(51, 51, 51, .35);
    background: rgba(255, 255, 255, .72);
    font-size: .8125rem;
    padding: 7px 12px;
}

.last-war-back:hover {
    background: #333;
    color: #fff;
    border-color: #333;
}

.last-war-hint {
    width: 100%;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .82);
    border: 2px solid #333;
    color: #333;
    font-size: .75rem;
    line-height: 1.6;
    text-align: right;
}

.last-war-hint strong {
    color: #166534;
}

.last-war-container {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px calc(8px + env(safe-area-inset-bottom));
}

.last-war-game {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(6, 1fr);
    width: var(--lw-size);
    height: calc(var(--lw-size) * 6 / 5);
    max-width: 100%;
    border-radius: 12px;
    background-color: #333;
    padding: 4px;
    gap: 3px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
}

.last-war-box {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
    border-radius: 6px;
    border: 2px solid #333;
    background-color: #f1c97c;
    background-position: center;
    background-size: 68%;
    background-repeat: no-repeat;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.last-war-box.is-green {
    background-color: #9ff1a5;
    animation: last-war-get-in .3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.last-war-box.is-red {
    background-color: #ff9292;
    animation: last-war-get-in .3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.last-war-init,
.last-war-won {
    z-index: 200;
    position: fixed;
    left: 0;
    right: 0;
    margin: 0 auto;
    text-align: center;
    border: 6px solid #333;
    max-width: 520px;
    transition: transform .35s ease, opacity .35s ease, visibility .35s ease;
}

.last-war-init {
    background-color: #ff9292;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: none;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom));
    max-height: min(52dvh, 420px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(0);
}

.last-war-init.is-hidden {
    transform: translateY(110%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.last-war-won {
    background-color: #9ff1a5;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: none;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    transform: translateY(110%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.last-war-won.is-visible {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.last-war-init h1,
.last-war-won h1 {
    font-size: clamp(1.25rem, 5.5vw, 2rem);
    font-weight: 900;
    color: #333;
    margin: 4px 6px 8px;
}

.last-war-init p,
.last-war-won p {
    font-size: clamp(.875rem, 3.5vw, 1.05rem);
    font-weight: 400;
    color: #333;
    margin: 6px 10px;
    line-height: 1.65;
}

.last-war-guide {
    text-align: right;
    background: rgba(255, 255, 255, .35);
    border-radius: 10px;
    padding: 8px 10px;
    margin: 8px 10px;
    font-size: .8125rem;
    line-height: 1.65;
}

.last-war-guide li {
    margin-bottom: 4px;
}

.last-war-guide li:last-child {
    margin-bottom: 0;
}

.last-war-floating {
    display: inline-block;
    animation: last-war-floating 1.5s ease-in-out infinite;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 4px;
    margin: 12px 0 4px;
    font-weight: 800;
    font-size: 1rem;
    padding: 8px 4px;
}

.last-war-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .28);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .3s ease, visibility .3s ease;
}

.last-war-overlay.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@keyframes last-war-floating {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes last-war-get-in {
    from { background-size: 0%; }
    to { background-size: 68%; }
}

@media (min-width: 641px) {
    .last-war-app {
        --lw-header: 148px;
        --lw-size: min(
            calc(100vw - 40px),
            calc((100dvh - var(--lw-header)) * 5 / 6),
            540px
        );
    }

    .last-war-header {
        flex-direction: row;
        align-items: flex-start;
        gap: 14px;
        padding: calc(12px + env(safe-area-inset-top)) 16px 10px;
    }

    .last-war-hint {
        flex: 1;
        font-size: .875rem;
        padding: 10px 12px;
    }

    .last-war-init,
    .last-war-won {
        left: 16px;
        right: 16px;
        bottom: auto;
        top: 50%;
        width: auto;
        max-width: 480px;
        border-radius: 14px;
        border-bottom: 6px solid #333;
        max-height: calc(100dvh - var(--lw-header) - 24px);
        padding-bottom: 18px;
        transform: translateY(-50%);
    }

    .last-war-init.is-hidden {
        transform: translateY(-50%) scale(.94);
        opacity: 0;
    }

    .last-war-won {
        transform: translateY(-40%) scale(.94);
    }

    .last-war-won.is-visible {
        transform: translateY(-50%) scale(1);
    }

    .last-war-game {
        padding: 6px;
        gap: 4px;
    }

    .last-war-box {
        border-width: 3px;
        border-radius: 8px;
    }
}

@media (max-width: 360px) {
    .last-war-app {
        --lw-header: 118px;
    }

    .last-war-hint {
        font-size: .7rem;
        line-height: 1.5;
    }
}
