/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #4c4ba2 100%);
    min-height: 100vh;
    padding: 15px;
    color: #333;
}

a {
    color: rgba(255, 255, 255, 0.715);
}

a:visited {
    color: rgba(255, 255, 255, 0.915)
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transition: filter 0.3s ease;
}

.container.blurred {
    filter: blur(2px);
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #5e4ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Main content */
.main-content {
    padding: 30px;
}

/* Three-column game layout */
.game-layout {
    display: flex;
    gap: 25px;
    align-items: stretch;
}

/* Desktop: three columns side by side */
@media (min-width: 880px) {
    .game-layout {
        flex-direction: row;
    }

    .target-section,
    .user-color-section {
        flex: 1;
    }

    .middle-section {
        flex: 1.25;
        display: flex;
        flex-direction: column;
        gap: 25px;
    }
}

/* Tablet/Small Desktop: color boxes on top, controls below */
@media (max-width: 879px) {
    .game-layout {
        flex-direction: column;
        gap: 0;
    }

    .target-section,
    .user-color-section {
        flex: 1;
        min-width: 0;
    }

    /* Create a grid for the color boxes at the top */
    .game-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 25px;
    }

    /* Color boxes in top row */
    .target-section {
        grid-column: 1;
        grid-row: 1;
    }

    .user-color-section {
        grid-column: 2;
        grid-row: 1;
    }

    /* Middle section spans full width below */
    .middle-section {
        grid-column: 1 / -1;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        gap: 25px;
    }
}

/* Section styling */
section {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    min-width: 0;
}

section h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #495057;
    font-weight: 600;
}

/* Target Color Section */
.target-section,
.user-color-section {
    display: flex;
    flex-direction: column;
}

.color-box {
    width: 100%;
    height: 200px;
    border-radius: 10px;
    border: 2px solid #dee2e6;
    transition: background 0.3s ease;
}

.color-box-large {
    width: 100%;
    height: 100%;
    min-height: 300px;
    border-radius: 10px;
    border: 2px solid #dee2e6;
    transition: background 0.3s ease;
    position: relative;
}

.color-box-large.hidden::before {
    content: "Press Start Round";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: #6c757d;
    text-align: center;
    width: 100%;
    padding: 20px;
    z-index: 1;
}

.color-box-large.hidden {
    background: repeating-linear-gradient(
        45deg,
        #f8f9fa,
        #f8f9fa 10px,
        #e9ecef 10px,
        #e9ecef 20px
    ) !important;
}

/* RGB Gradient Bars (in modal) */
.rgb-bars-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0px;
}

#colorWheel {
    cursor: default;
    background: white;
    max-width: 100%;
    height: auto;
}

/* RGB Sliders */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.slider-container {
    display: grid;
    grid-template-columns: 60px 1fr;
    align-items: center;
    gap: 15px;
}

.slider-container label {
    font-weight: 600;
    color: #495057;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 5px;
    outline: none;
    transition: opacity 0.2s;
}

.slider:hover {
    opacity: 0.9;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Individual slider colors - solid backgrounds */
.red-slider {
    background: #ff0000;
}

.red-slider::-webkit-slider-thumb {
    background: #ff0000;
}

.red-slider::-moz-range-thumb {
    background: #ff0000;
}

.green-slider {
    background: #00ff00;
}

.green-slider::-webkit-slider-thumb {
    background: #00ff00;
}

.green-slider::-moz-range-thumb {
    background: #00ff00;
}

.blue-slider {
    background: #0000ff;
}

.blue-slider::-webkit-slider-thumb {
    background: #0000ff;
}

.blue-slider::-moz-range-thumb {
    background: #0000ff;
}

.value-input {
    font-weight: 600;
    font-size: 1.1rem;
    color: #495057;
    text-align: center;
    background: white;
    padding: 4px 5px;
    border-radius: 8px;
    border: 2px solid #dee2e6;
    width: 70px;
    transition: border-color 0.2s;
}

.value-input:focus {
    outline: none;
    border-color: #667eea;
}

.value-input::-webkit-outer-spin-button,
.value-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.value-input[type=number] {
    -moz-appearance: textfield;
}

/* Game Controls Section */
.controls-section {
    display: flex;
    flex-direction: column;
}

.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.game-btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#settingsModal .game-btn {
    padding: 10px 20px;
    font-size: 0.95rem;
}

.start-round-btn {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    font-size: 1.2rem;
    padding: 20px 40px;
}

.start-round-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.submit-btn {
    background: linear-gradient(135deg, #28a745 0%, #20803a 100%);
    color: white;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.new-color-btn {
    background: linear-gradient(135deg, #667eea 0%, #5e4ba2 100%);
    color: white;
}

.new-color-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.score-display {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin-top: 10px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    border: 2px solid #dee2e6;
    flex: 1;
}

.score-label {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
}

.score-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #495057;
}

/* Timer Display */
.timer-display {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 15px;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.timer-label {
    display: block;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.timer-value {
    display: block;
    color: white;
    font-size: 2.0rem;
    font-weight: 700;
}

.timer-display.warning {
    background: linear-gradient(135deg, #ff4757 0%, #e84118 100%);
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-content-wide {
    max-width: 900px;
}

#settingsModal .modal-content {
    max-width: 500px;
    padding: 15px;
}

#settingsModal .modal-content h2 {
    margin-bottom: 12px;
    font-size: 1.4rem;
}

/* Results Modal Two-Column Layout */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 20px;
}

.results-column {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

@media (max-width: 880px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

/* Settings Modal Specific Styles */
.settings-section {
    margin-bottom: 12px;
}

.settings-section:last-of-type {
    margin-bottom: 15px;
}

.settings-section h3 {
    font-size: 0.95rem;
    color: #495057;
    margin-bottom: 8px;
    font-weight: 600;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-group.horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-group.horizontal .radio-label {
    flex: 1 1 0;
    min-width: 100px;
    justify-content: center;
    padding: 10px 12px;
}

.radio-label:hover:not(:has(input:disabled)) {
    background: #e9ecef;
    border-color: #667eea;
}

.radio-label input[type="radio"] {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.radio-label input[type="radio"]:disabled {
    cursor: not-allowed;
}

.radio-label:has(input:disabled) {
    opacity: 0.6;
    cursor: not-allowed;
}

.radio-label:has(input:checked) {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.radio-label span {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Game Over Modal Styles */
.gameover-stats {
    margin-bottom: 15px;
}

.final-score {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #5e4ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 15px;
}

.final-score-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 5px;
    opacity: 0.95;
}

.final-score-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-box {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid #dee2e6;
}

.stat-box-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stat-box-value {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: #495057;
}

.gameover-buttons {
    display: flex;
    gap: 10px;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    text-align: center;
    color: #495057;
    margin-bottom: 25px;
    font-size: 2rem;
}

.results-comparison {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
}

.comparison-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.comparison-label {
    font-weight: 600;
    color: #495057;
    text-align: center;
    font-size: 1.1rem;
}

.comparison-box .color-box {
    height: 120px;
}

.rgb-values {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    color: #6c757d;
}

.results-stats {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.results-stats.score-breakdown {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #81c784;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #dee2e6;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-item.total {
    margin-top: 10px;
    padding-top: 15px;
    border-top: 2px solid #667eea;
    font-size: 1.1rem;
}

.stat-label {
    font-weight: 600;
    color: #495057;
}

.stat-value {
    font-weight: 700;
    color: #667eea;
}

.stat-item.total .stat-value {
    font-size: 1.5rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .main-content {
        padding: 20px;
    }

    h1 {
        font-size: 2rem;
    }

    #colorWheel {
        width: 100%;
        max-width: 350px;
        height: auto;
    }

    .results-comparison {
        flex-direction: column;
    }

    .score-display {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .final-score-value {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    section {
        padding: 15px;
    }

    #colorWheel {
        width: 100%;
        max-width: 300px;
        height: auto;
    }

    .color-box {
        height: 150px;
    }
}

/* Colorblind Simulation Filters */
.vision-deuteranopia {
    filter: url('#deuteranopia-filter');
}

.vision-protanopia {
    filter: url('#protanopia-filter');
}

.vision-tritanopia {
    filter: url('#tritanopia-filter');
}
