/* Modal Component Styles */
/* Unified modal system for game modals, settings modal, and winner display */

/* Base Modal Container */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Default: fixed to screen */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: var(--z-modal-overlay);
    align-items: center;
    justify-content: center;
}

/* Game Over Modal & Settings Modal - positioned relative to game board container */
#game-over-modal,
#board-settings-modal {
    position: absolute; /* Relative to game board parent */
}

/* Show modal - must use flex to center content */
.modal[style*="display: block"],
.modal.show {
    display: flex !important;
}

.modal-content {
    background-color: var(--grey2-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-glow-xl);
    min-width: 320px;
    width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    z-index: var(--z-modal);
    position: relative;
}

/* Shared Modal Header Container (for both game-over and settings) */
.modal-header-container {
    background-color: var(--grey1-color);
    padding: 1rem;
    padding-top: 2.5rem; /* Extra padding at top to avoid X button overlap */
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.modal-header-container h3,
.modal-header-container #winner-text {
    margin: 0;
    font-size: 1.5rem;
    font-weight: var(--font-weight-bold);
    color: var(--text-color);
}

.modal-header-container #winner-subtext {
    font-size: 1rem;
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary-color);
}

/* Small Modal Variant (for simple dialogs) */
.modal-content.small {
    width: 300px;
    max-width: 90vw;
    text-align: center;
}

/* Modal Animation */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content {
    animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--accent-color);
    font-size: 1.3rem;
    font-weight: var(--font-weight-semibold);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary-color);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-s);
    transition: all var(--transition-base);
}

.modal-close:hover {
    background-color: var(--secondary-button-color);
    color: var(--text-color);
}

.modal-body {
    padding: 1.5rem;
}

#modal-buttons {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 15px;
}


/* Settings Modal Specific Styles */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-group label {
    font-weight: var(--font-weight-medium);
    color: var(--text-color);
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}
