/* 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: 200px;
}

.custom-panel {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.custom-panel input {
    width: 72px;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--dark);
    background: white;
}

.custom-panel input:focus {
    outline: none;
    border-color: var(--accent);
}

.custom-panel.hidden {
    display: none !important;
}

/* game container */
#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;
}

/* score / status bar */
.game-stats {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: "mines status time";
    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;
}

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

.time-stat {
    grid-area: time;
    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;
}

#status.win-message {
    color: #4ade80;
    animation: celebrate 0.5s ease;
}

#status.lose-message {
    color: #ef4444;
    animation: celebrate 0.5s ease;
}

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

.board-scroll {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.25rem;
}

.minesweeper-board {
    display: grid;
    gap: 2px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.22);
    border-radius: var(--radius);
    margin: 0 auto;
}

.cell {
    aspect-ratio: 1 / 1;
    min-width: 26px;
    min-height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: background 0.15s ease, transform 0.1s ease;
}

.cell:hover:not(.revealed) {
    background: rgba(255, 255, 255, 0.2);
}

.cell:active:not(.revealed) {
    transform: scale(0.94);
}

.cell.revealed {
    background: rgba(255, 255, 255, 0.04);
    cursor: default;
    border-color: rgba(255, 255, 255, 0.03);
    transform: none;
}

.cell.revealed:hover {
    background: rgba(255, 255, 255, 0.04);
}

.cell.mine {
    background: rgba(239, 68, 68, 0.3);
    color: #ef4444;
    font-size: 1rem;
}

.cell.flag {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.14);
}

.cell.question {
    color: var(--accent);
    background: rgba(6, 182, 212, 0.14);
}

/* action buttons row */
.action-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}

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

.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-score {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 0.5rem;
}

/* best times modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-inner {
    background: var(--light);
    padding: 1.75rem;
    border-radius: var(--radius-lg);
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.modal-title {
    color: var(--primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 1.1rem;
}

.best-times-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
    max-height: 300px;
    overflow-y: auto;
}

.best-times-list li {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--gray-light);
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--dark);
    display: flex;
    justify-content: space-between;
}

.best-times-list li:last-child {
    border-bottom: none;
}

.best-times-list li.empty {
    color: var(--gray);
    font-style: italic;
    justify-content: center;
}

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

    50% {
        transform: scale(1.1);
    }

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

/* responsive */
@media (max-width: 768px) {
    #game-settings {
        gap: 0.75rem 1.25rem;
    }

    #game-settings select {
        min-width: 160px;
    }
}

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

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

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

    .cell {
        font-size: 0.75rem;
        min-width: 22px;
        min-height: 22px;
    }

    .game-over-message {
        font-size: 1.25rem;
    }

    .action-row .btn {
        font-size: 0.8rem;
        padding: 0.45rem 0.75rem;
    }
}

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

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