/* Legacy small-screen overrides removed; see responsive section below. */
.math-game-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.game-header {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 20px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.game-header h1 {
    font-size: 42px;
    margin-bottom: 10px;
}

.game-header p {
    font-size: 20px;
    opacity: 0.95;
}

.game-setup {
    background: white;
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.setup-controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: flex-end;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-group label {
    font-weight: bold;
    color: #667eea;
    font-size: 16px;
}

.control-group input,
.control-group select {
    padding: 8px 12px;
    font-size: 14px;
    border: 2px solid #667eea;
    border-radius: 5px;
    cursor: pointer;
    background: white;
}

.start-game-btn {
    padding: 10px 25px;
    font-size: 16px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.start-game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 15px 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 20px;
}

.score-display,
.timer-display,
.matches-display {
    font-size: 20px;
    font-weight: bold;
    color: #667eea;
}

.score-display span,
.timer-display span,
.matches-display span {
    color: #764ba2;
}

.game-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.left-panel {
    width: 280px;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.panel-header {
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.panel-header h2 {
    font-size: 24px;
    margin: 0 0 10px 0;
    color: white;
}

.panel-header p {
    font-size: 14px;
    margin: 0;
    opacity: 0.95;
}

.left-panel h3 {
    color: #667eea;
    font-size: 20px;
    margin-bottom: 15px;
    text-align: center;
}

.instructions-list {
    list-style: none;
    padding: 0;
}

.instructions-list li {
    padding: 10px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 5px;
    font-size: 14px;
    color: #555;
    border-left: 4px solid #667eea;
}

.middle-panel {
    flex: 1;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.equations-section,
.answers-section {
    flex: 1;
}

.equations-section h3,
.answers-section h3 {
    color: #667eea;
    font-size: 20px;
    margin-bottom: 15px;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.items-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.equation-item,
.answer-item {
    padding: 12px 15px;
    background: #f8f9fa;
    border: 2px solid #667eea;
    border-radius: 5px;
    font-size: 18px;
    font-weight: bold;
    color: #555;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    user-select: none;
}

.equation-item:hover,
.answer-item:hover {
    background: #667eea15;
    transform: scale(1.05);
}

.equation-item.selected,
.answer-item.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: scale(1.08);
}

.equation-item.matched,
.answer-item.matched {
    background: #d4edda;
    color: #155724;
    border-color: #28a745;
    cursor: default;
    opacity: 0.8;
}

.equation-item.wrong,
.answer-item.wrong {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
    animation: shake 0.5s;
}

.equation-item.hint,
.answer-item.hint {
    background: #fff3cd;
    color: #856404;
    border-color: #ffc107;
    animation: pulse 1s;
}

.ads-panel {
    width: 280px;
    padding: 20px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.ads-panel h3 {
    color: #667eea;
    font-size: 20px;
    margin-bottom: 15px;
    text-align: center;
}

.ad-box {
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.ad-placeholder {
    width: 100%;
    height: 250px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 18px;
    font-weight: bold;
}

.game-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.hint-btn,
.reset-btn {
    flex: 1;
    max-width: 200px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.hint-btn {
    background: #ffc107;
    color: #333;
}

.hint-btn:hover {
    background: #ffb300;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
}

.reset-btn {
    background: #dc3545;
    color: white;
}

.reset-btn:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.celebration-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.celebration-content {
    background: white;
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.celebration-content h2 {
    color: #667eea;
    font-size: 42px;
    margin-bottom: 20px;
}

.celebration-content p {
    font-size: 24px;
    color: #555;
    margin-bottom: 20px;
}

.play-again-btn {
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.play-again-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

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

@media (max-width: 1200px) {
    .game-layout {
        flex-wrap: wrap;
    }

    .ads-panel {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .game-info {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        width: 100%;
        justify-content: space-between;
    }

    .start-game-btn {
        width: 100%;
    }

    .game-layout {
        flex-direction: column;
        gap: 16px;
    }

    .left-panel {
        width: 100%;
    }

    .panel-header h2 {
        font-size: 20px;
    }

    .panel-header p {
        font-size: 12px;
    }

    .items-list {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .game-actions {
        flex-direction: column;
    }

    .hint-btn,
    .reset-btn {
        max-width: 100%;
    }
}

@media (max-width: 600px) {
    .math-game-container {
        padding: 10px;
    }

    .middle-panel {
        padding: 16px;
        width: 100%;
        max-width: 100%;
    }

    .items-list {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    }

    .equation-item,
    .answer-item {
        font-size: 16px;
        padding: 10px 8px;
    }
}