/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

#gameContainer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header Styles */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.game-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #4a5568;
}

.score-display {
    display: flex;
    gap: 20px;
    font-size: 1.2rem;
    font-weight: 600;
    color: #2d3748;
}

/* Screen Management */
.screen {
    display: none;
    animation: fadeIn 0.5s ease-in-out;
}

.screen.active {
    display: block;
}

/* Mode Selection Styles */
.mode-container {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.mode-container h2 {
    font-size: 2.2rem;
    margin-bottom: 40px;
    color: #2d3748;
}

.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.mode-card {
    background: linear-gradient(135deg, #c066d9 0%, #c23d4f 100%);
    padding: 30px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.mode-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.mode-card:nth-child(2) {
    background: linear-gradient(135deg, #3a7acc 0%, #0099cc 100%);
}

.mode-card:nth-child(3) {
    background: linear-gradient(135deg, #2eb85c 0%, #26b8a3 100%);
}

.mode-card:nth-child(4) {
    background: linear-gradient(135deg, #c8526b 0%, #ccb300 100%);
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.mode-card h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.mode-card p {
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.4;
}

/* Difficulty Selection Styles */
.difficulty-container {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.difficulty-container h2 {
    font-size: 2.2rem;
    margin-bottom: 40px;
    color: #2d3748;
}

.difficulty-grid {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 30px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    flex-wrap: wrap;
}

.difficulty-card {
    flex: 0 0 280px;
    max-width: 280px;
    background: linear-gradient(135deg, #4d5bb8 0%, #5a3a7a 100%);
    padding: 30px;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.difficulty-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.difficulty-card:nth-child(2) {
    background: linear-gradient(135deg, #c066d9 0%, #c23d4f 100%);
}

.difficulty-card:nth-child(3) {
    background: linear-gradient(135deg, #3a7acc 0%, #0099cc 100%);
}

.difficulty-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.difficulty-card h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.difficulty-card p {
    font-size: 1rem;
    opacity: 0.9;
    line-height: 1.4;
}

/* Game Screen Styles */
.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3a7acc 0%, #0099cc 100%);
    width: 0%;
    transition: width 0.3s ease;
}

.pack-info {
    font-weight: 600;
    color: #4a5568;
    font-size: 1.1rem;
}

/* Cards Container - 2x2 Grid Layout */
.cards-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Game Card Styles */
.game-card {
    min-height: 350px;
    transition: all 0.3s ease;
}

.game-card:hover {
    transform: translateY(-2px);
}

.card-content {
    padding: 20px;
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card-question {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-bottom: 8px;
    padding: 5px;
    border-radius: 8px;
}

.flag-image {
    width: 100%;
    max-width: 200px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    border: 3px solid rgba(255, 255, 255, 0.9);
    margin: 0 auto 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    background: rgba(255, 255, 255, 0.1);
}

.question-text {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 10px;
}

.question-subtitle {
    font-size: 1rem;
    color: #718096;
}

.card-answer {
    margin-top: auto;
    flex-shrink: 0;
}

/* Radio Button Styling - Responsive Grid Layout */
.radio-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 8px;
    width: 85%;
    max-width: 300px;
    margin: 5px auto 0 auto;
    align-items: center;
    justify-items: center;
}

/* MOBILE OVERRIDE: Card-based selection with maximum specificity */
@media (max-width: 768px) {
    /* Force mobile layout for all radio groups */
    .flip-card-front .radio-group,
    .continent-mode .radio-group,
    .radio-group {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
        max-width: none !important;
        margin: 15px auto 0 auto !important;
        padding: 0 10px !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
    }
    
    /* Override ALL radio option styles for mobile */
    .flip-card-front .radio-option,
    .flip-card-front[style*="background:"] .radio-option,
    .continent-mode .radio-option,
    .radio-option {
        background: rgba(255, 255, 255, 0.95) !important;
        border: 2px solid #e2e8f0 !important;
        border-radius: 12px !important;
        padding: 16px 20px !important;
        margin: 0 !important;
        min-height: 60px !important;
        width: 100% !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        transition: all 0.2s ease !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }
    
    /* Mobile hover states */
    .flip-card-front .radio-option:hover,
    .flip-card-front[style*="background:"] .radio-option:hover,
    .continent-mode .radio-option:hover,
    .radio-option:hover,
    .radio-option:active {
        background: rgba(58, 122, 204, 0.1) !important;
        border-color: #3a7acc !important;
        transform: translateY(-1px) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    }
    
    /* Mobile radio button inputs */
    .flip-card-front .radio-option input[type="radio"],
    .flip-card-front[style*="background:"] .radio-option input[type="radio"],
    .continent-mode .radio-option input[type="radio"],
    .radio-option input[type="radio"] {
        width: 20px !important;
        height: 20px !important;
        margin-right: 16px !important;
        flex-shrink: 0 !important;
    }
    
    /* Mobile text styling */
    .flip-card-front .radio-text,
    .flip-card-front[style*="background:"] .radio-text,
    .continent-mode .radio-text,
    .radio-text {
        font-size: 1rem !important;
        font-weight: 500 !important;
        line-height: 1.3 !important;
        text-align: left !important;
        color: #2d3748 !important;
    }
    
    /* Mobile selected state */
    .flip-card-front .radio-option:has(input:checked),
    .flip-card-front[style*="background:"] .radio-option:has(input:checked),
    .continent-mode .radio-option:has(input:checked),
    .radio-option:has(input:checked) {
        background: rgba(58, 122, 204, 0.15) !important;
        border-color: #3a7acc !important;
        box-shadow: 0 4px 12px rgba(58, 122, 204, 0.2) !important;
    }
    
    .flip-card-front .radio-option:has(input:checked) .radio-text,
    .flip-card-front[style*="background:"] .radio-option:has(input:checked) .radio-text,
    .continent-mode .radio-option:has(input:checked) .radio-text,
    .radio-option:has(input:checked) .radio-text {
        font-weight: 600 !important;
        color: #2d3748 !important;
    }
}

.radio-option {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 6px 4px;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    min-height: 35px;
    border-radius: 6px;
    width: 100%;
}

.radio-option:hover {
    background: rgba(58, 122, 204, 0.1);
}

.radio-option input[type="radio"] {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 0;
}

.radio-text {
    cursor: pointer;
    line-height: 1.3;
    font-weight: 500;
    text-align: left;
    word-break: break-word;
    flex-grow: 1;
}

/* Selected radio button styling */
.radio-option:has(input:checked) {
    background: rgba(58, 122, 204, 0.15);
    font-weight: 600;
    color: #2d3748;
}

/* Locked radio buttons styling */
.radio-group.locked .radio-option {
    cursor: not-allowed;
    opacity: 0.7;
}

.radio-group.locked .radio-option input[type="radio"] {
    cursor: not-allowed;
}

.radio-group.locked .radio-text {
    cursor: not-allowed;
}

/* Correct answer styling when locked */
.radio-group.locked .radio-option:has(input:checked) {
    background: rgba(72, 187, 120, 0.15);
    color: #2d3748;
}

/* Button Styles */
.back-btn, .check-btn, .next-btn, .continue-btn, .restart-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn {
    background: #718096;
    color: white;
}

.back-btn:hover {
    background: #4a5568;
}

.check-btn {
    background: linear-gradient(135deg, #3a7acc 0%, #0099cc 100%);
    color: white;
    font-size: 1.2rem;
    padding: 15px 40px;
}

.check-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.4);
}

.check-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.next-btn {
    background: linear-gradient(135deg, #359959 0%, #26b8a3 100%);
    color: white;
    font-size: 1.2rem;
    padding: 15px 40px;
}

.next-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.4);
}

.game-actions {
    text-align: center;
}

/* Results Screen */
.results-container {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.results-container h2 {
    font-size: 2.5rem;
    margin-bottom: 30px;
    color: #2d3748;
}

.results-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 40px;
}

.stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    color: #4facfe;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 1.1rem;
    color: #718096;
    font-weight: 500;
}

.results-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.continue-btn {
    background: linear-gradient(135deg, #359959 0%, #26b8a3 100%);
    color: white;
    padding: 15px 30px;
}

.restart-btn {
    background: linear-gradient(135deg, #c066d9 0%, #c23d4f 100%);
    color: white;
    padding: 15px 30px;
}

.continue-btn:hover, .restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Responsive Design */
@media (max-width: 768px) {
    #gameContainer {
        padding: 15px;
    }
    
    .game-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .mode-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }
    
    .difficulty-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(3, 1fr);
    }
    
    .game-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .cards-container {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, auto);
        max-width: 400px;
        gap: 20px;
    }
    
    .game-card {
        min-height: auto;
        margin-bottom: 20px;
    }
    
    .card-content {
        padding: 20px 15px;
    }
    
    .flag-image {
        max-width: 250px !important;
        height: 140px !important;
        margin: 0 auto 12px !important;
    }
    
    .question-text {
        font-size: 1.4rem !important;
        margin-bottom: 8px !important;
    }
    
    .question-subtitle {
        font-size: 1.1rem !important;
        margin-bottom: 15px !important;
    }
    
    .results-stats {
        flex-direction: column;
        gap: 20px;
    }
    
    .results-actions {
        flex-direction: column;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* Skip Link for Accessibility - Hidden by default */
.skip-link {
    position: absolute;
    top: -1000px;
    left: -1000px;
    width: 1px;
    height: 1px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.skip-link:focus {
    position: absolute;
    top: 6px;
    left: 6px;
    width: auto;
    height: auto;
    clip: auto;
    overflow: visible;
}

/* Mode and Difficulty Description */
.mode-description, .difficulty-description {
    text-align: center;
    font-size: 1.1rem;
    color: #4a5568;
    margin-bottom: 30px;
    line-height: 1.6;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Make mode cards behave as buttons */
.mode-card, .difficulty-card {
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    width: 100%;
    font-family: inherit;
    font-size: inherit;
}

/* Restore original mode card styling - Darker tones */
.mode-card {
    background: linear-gradient(135deg, #c066d9 0%, #c23d4f 100%);
    padding: 30px;
    border-radius: 15px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.difficulty-card {
    background: linear-gradient(135deg, #4d5bb8 0%, #5a3a7a 100%);
    padding: 30px;
    border-radius: 15px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.mode-card:focus, .difficulty-card:focus {
    outline: 3px solid #4facfe;
    outline-offset: 2px;
}

/* Footer Styles */
.game-footer {
    background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    color: white;
    padding: 40px 20px 20px;
    margin-top: 50px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-section h3 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: #4facfe;
}

.footer-section p {
    line-height: 1.6;
    margin-bottom: 15px;
    color: #e2e8f0;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section li {
    padding: 5px 0;
    color: #e2e8f0;
    position: relative;
    padding-left: 20px;
}

.footer-section li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #4facfe;
    font-weight: bold;
}

.footer-bottom {
    border-top: 1px solid #4a5568;
    padding-top: 20px;
    text-align: center;
    color: #a0aec0;
    font-size: 0.9rem;
}

.footer-bottom p {
    margin: 5px 0;
}

/* SEO-friendly hidden content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Enhanced accessibility for game elements */
[role="status"] {
    font-weight: 600;
}

[aria-live="polite"] {
    position: relative;
}

/* Print styles for SEO */
@media print {
    .game-footer {
        display: block !important;
        background: #fff !important;
        color: #000 !important;
    }
    
    .footer-content {
        display: block !important;
    }
    
    .footer-section {
        margin-bottom: 20px;
    }
    
    .skip-link {
        display: none;
    }
}

/* Additional responsive adjustments */
@media (max-width: 768px) {
    .footer-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .mode-description, .difficulty-description {
        font-size: 1rem;
        padding: 0 10px;
    }
    
    /* Mobile radio button adjustments - Stack vertically on small screens */
    .radio-option {
        padding: 12px 10px !important;
        font-size: 0.9rem !important;
        min-height: 48px !important;
        justify-content: flex-start !important;
        width: 100% !important;
        border-radius: 8px !important;
    }
    
    .radio-option input[type="radio"] {
        width: 18px !important;
        height: 18px !important;
        margin-right: 12px !important;
        flex-shrink: 0 !important;
    }
    
    .radio-text {
        font-size: 0.9rem !important;
        line-height: 1.4 !important;
        text-align: left !important;
    }
}