* {
    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;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    color: #666;
    font-size: 1.1em;
}

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

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

.control-group label {
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

select, input[type="number"] {
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
    background: white;
}

select {
    cursor: pointer;
}

input[type="number"] {
    width: 100px;
}

select:hover, input[type="number"]:hover {
    border-color: #667eea;
}

select:focus, input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 2px solid #ddd;
}

.btn-secondary:hover {
    background: #e0e0e0;
    border-color: #ccc;
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.puzzles-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 40px;
    margin-bottom: 30px;
}

.puzzle-section {
    text-align: center;
}

.puzzle-section h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.5em;
}

canvas {
    border: 3px solid #333;
    border-radius: 10px;
    max-width: 100%;
    height: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.export-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.batch-export {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
}

.batch-export h2 {
    color: #333;
    font-size: 1.5em;
    margin-bottom: 10px;
}

.batch-export p {
    color: #666;
    margin-bottom: 15px;
    font-size: 1em;
}

#batchCount {
    font-weight: 600;
    color: #667eea;
}

.loading {
    text-align: center;
    font-size: 1.2em;
    color: #667eea;
    font-weight: 600;
    padding: 20px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .puzzles-container {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        width: 100%;
    }
}
