/* Copyright (c) 2024-2026 Jericho Crosby (Chalwk). All Rights Reserved. */

.panel {
    background: var(--light);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 2rem;
}

.panel-head h1 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

#game-settings {
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    align-items: center;
}

#game-settings label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    color: var(--dark);
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
}

#game-settings select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    background: white;
    color: var(--dark);
    font-family: var(--font-primary);
    min-width: 140px;
}

#game-container {
    position: relative;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    background: var(--darker);
    border-radius: var(--radius);
    padding: 1rem 0.75rem;
}

.game-stats {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: "score status streak";
    align-items: center;
    width: 100%;
    gap: 0.5rem 0.75rem;
    padding: 0.25rem 0.5rem;
}

.stat-block {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    line-height: 1.1;
}

.score-stat {
    grid-area: score;
    align-items: flex-start;
}

.streak-stat {
    grid-area: streak;
    align-items: flex-end;
}

.stat-block strong {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-block .score {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--accent);
}

.status-block {
    grid-area: status;
    justify-self: center;
    min-width: 0;
}

#status {
    font-weight: bold;
    font-size: 0.95rem;
    text-align: center;
    color: #fff;
    white-space: nowrap;
}

.tower-wrap {
    position: relative;
    display: flex;
    justify-content: center;
    width: 100%;
}

#tower-svg {
    width: 100%;
    max-width: 260px;
    height: auto;
    display: block;
}

.tower-ground {
    fill: #3a3f52;
}

.flag-pole {
    stroke: #8b93a8;
    stroke-width: 3;
    stroke-linecap: round;
}

.flag {
    fill: var(--warning);
    transition: opacity 0.3s ease;
}

.tower-block {
    stroke: rgba(0, 0, 0, 0.25);
    stroke-width: 1.5;
    transition: transform 0.5s ease, opacity 0.5s ease;
    transform-box: fill-box;
    transform-origin: center;
}

.tower-block.falling {
    animation: blockFall 0.6s ease forwards;
}

@keyframes blockFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(140px) rotate(35deg);
        opacity: 0;
    }
}

.rubble-piece {
    fill: #5c6377;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.rubble-piece.show {
    opacity: 1;
}

.game-over-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    border-radius: var(--radius);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    text-align: center;
    padding: 1rem;
}

.game-over-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.game-over-content {
    animation: celebrate 0.5s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.game-over-message {
    color: #fff;
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.game-over-word {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.5rem;
}

.category-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid rgba(6, 182, 212, 0.35);
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
}

#word-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.6rem;
    color: #fff;
    min-height: 2.4rem;
}

.letter-slot {
    width: 1.3rem;
    text-align: center;
    border-bottom: 3px solid var(--gray-light);
    padding-bottom: 0.15rem;
    transition: border-color 0.2s ease;
}

.letter-slot.revealed {
    border-color: var(--success, #4ade80);
}

#keyboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(2.1rem, 1fr));
    gap: 0.4rem;
    max-width: 480px;
    width: 100%;
}

.key {
    padding: 0.5rem 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-light);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.key:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: #06121a;
}

.key:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.key.correct {
    background: rgba(74, 222, 128, 0.25);
    border-color: #4ade80;
    color: #4ade80;
}

.key.wrong {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #ef4444;
}

.win-message {
    color: #4ade80;
}

.lose-message {
    color: #ef4444;
}

@keyframes celebrate {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

@media (max-width: 480px) {
    #game-container {
        padding: 0.75rem 0.5rem;
    }

    #word-display {
        font-size: 1.25rem;
    }

    .key {
        font-size: 0.85rem;
        padding: 0.45rem 0;
    }

    #game-settings {
        gap: 0.5rem 0.75rem;
    }

    #game-settings select {
        min-width: 0;
        padding: 0.4rem 0.5rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 420px) {
    .game-stats {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "score streak"
            "status status";
    }

    .status-block {
        margin-top: 0.15rem;
    }
}