/* Modals Common */
.settings-modal,
.results-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 20px 0;
    animation: fadeIn 0.3s ease;
}

/* Custom Scrollbar for Modals */
.settings-modal::-webkit-scrollbar {
    width: 10px;
}

.settings-modal::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.settings-modal::-webkit-scrollbar-thumb {
    background: #4A4A8C;
    border-radius: 10px;
    border: 2px solid #FFF9C4;
}

.settings-modal {
    scrollbar-width: thin;
    scrollbar-color: #4A4A8C rgba(0, 0, 0, 0.2);
}

.settings-modal.show,
.results-modal.show {
    display: flex;
    align-items: flex-start;
}

.settings-content,
.results-content {
    background: radial-gradient(circle, #FFFFFF 0%, #FFF9C4 100%);
    border: 8px solid #4A4A8C;
    width: 90%;
    max-width: 600px;
    padding: 40px;
    text-align: center;
    animation: slideDown 0.5s ease-out;
    margin: auto;
    flex-shrink: 0;
}

/* Settings Specific */
.settings-title {
    font-size: 32px;
    font-weight: bold;
    color: #4A4A8C;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 0 #FFFFFF;
}

.title-icon {
    width: 45px;
    height: 45px;
    object-fit: contain;
}

.settings-section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 24px;
    font-weight: bold;
    color: #4A4A8C;
    margin-bottom: 15px;
}

/* Checkbox & Radio Styles */
.checkbox-group,
.radio-group,
.radio-group-vertical {
    gap: 12px;
}

.radio-group-vertical {
    display: grid;
    grid-template-columns: 1fr;
    text-align: left;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    align-items: center;
    justify-items: center;
    gap: 15px;
}

.radio-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    align-items: center;
    justify-items: left;
    gap: 15px;
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 22px;
    color: #4A4A8C;
    font-weight: bold;
}

.checkbox-label input,
.radio-label input,
#rangeCustomRadio {
    display: none;
}

.checkbox-custom,
.radio-custom {
    width: 32px;
    height: 32px;
    border: 4px solid #4A4A8C;
    background: #FFFFFF;
    position: relative;
    transition: all 0.3s ease;
}

.checkbox-custom {
    border-radius: 8px;
}

.radio-custom {
    border-radius: 50%;
}

.checkbox-label input:checked+.checkbox-custom {
    background: #228B22;
    border-color: #228B22;
}

.checkbox-label input:checked+.checkbox-custom::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FFFFFF;
    font-size: 24px;
}

.radio-label input:checked+.radio-custom::after,
#rangeCustomRadio:checked~.radio-label .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4A4A8C;
}

/* Results Specific */
.results-title {
    font-size: 42px;
    font-weight: bold;
    color: #4A4A8C;
    margin-bottom: 30px;
    text-shadow: 2px 2px 0 #FFFFFF;
}

.results-stats {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.stat-item {
    background: #FFFFFF;
    border: 4px solid #4A4A8C;
    border-radius: 20px;
    padding: 15px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-icon {
    font-size: 36px;
    width: 50px;
}

.correct-stat .stat-icon {
    color: #228B22;
}

.incorrect-stat .stat-icon {
    color: #DC143C;
}

.stat-label {
    font-size: 24px;
    font-weight: bold;
    color: #4A4A8C;
    flex: 1;
    text-align: left;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #4A4A8C;
}

/* Buttons */
.settings-buttons,
.results-buttons {
    display: flex;
    gap: 15px;
}

.settings-apply-btn,
.settings-cancel-btn,
.results-new-game-btn,
.results-settings-btn {
    flex: 1;
    border: 5px solid;
    border-radius: 20px;
    padding: 16px;
    font-size: 22px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
}

.settings-apply-btn {
    background: linear-gradient(135deg, #90EE90 0%, #32CD32 100%);
    border-color: #228B22;
    color: #0F4D0F;
}

.settings-cancel-btn {
    background: linear-gradient(135deg, #FFB8B8 0%, #FF9999 100%);
    border-color: #E85F5F;
    color: #8B2E2E;
}

.results-new-game-btn {
    background: linear-gradient(135deg, #FFD93D 0%, #FFA500 100%);
    border-color: #FF8C00;
    color: #4A4A8C;
}

.results-settings-btn {
    background: linear-gradient(135deg, #FFFFFF 0%, #E0E0E0 100%);
    border-color: #4A4A8C;
    color: #4A4A8C;
}

@media (max-width: 768px) {

    .settings-content,
    .results-content {
        padding: 30px;
    }

    .settings-title,
    .results-title {
        font-size: 32px;
    }

    .settings-buttons,
    .results-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .settings-apply-btn,
    .settings-cancel-btn,
    .results-new-game-btn,
    .results-settings-btn {
        font-size: 18px;
        padding: 12px;
    }

    .stat-value {
        font-size: 24px;
    }

    .stat-label {
        font-size: 18px;
    }
}

.custom-range-container {
    display: flex;
    align-items: center;
    gap: 8px;
    grid-column: span 1;
    justify-content: center;
}

.custom-input {
    width: 70px;
    height: 44px;
    padding: 0 5px;
    border: 3px solid #4A4A8C;
    border-radius: 12px;
    font-size: 22px;
    font-weight: bold;
    color: #4A4A8C;
    background: #FFF;
    outline: none;
    transition: all 0.3s ease;
    text-align: center;
    opacity: 0.6;
}

#rangeCustomRadio:checked~.custom-input,
.custom-input:focus {
    opacity: 1;
    border-color: #228B22;
    background: #F0FFF0;
}

/* Hide arrows for number input */
.custom-input::-webkit-inner-spin-button,
.custom-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.custom-input {
    -moz-appearance: textfield;
    appearance: textfield;
}

@media (max-width: 768px) {
    .radio-group {
        grid-template-columns: 1fr;
        text-align: left;
        padding-left: 15%;
    }

    .custom-range-container {
        justify-content: flex-start;
    }
}