* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2rem;
}

.header-controls {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    background-color: #34495e;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
    font-size: 1rem;
}

.btn:hover {
    background-color: #2c3e50;
}

.btn-primary {
    background-color: #3498db;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.setup-panel {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    width: 100%;
}

.setup-section {
    margin-bottom: 2rem;
}

.setup-section h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.upload-label {
    display: inline-block;
    padding: 1rem 2rem;
    background-color: #3498db;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-bottom: 1rem;
}

.upload-label:hover {
    background-color: #2980b9;
}

.upload-label input {
    display: none;
}

.default-images h4 {
    margin-bottom: 1rem;
}

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

.image-option {
    width: 100%;
    aspect-ratio: 3/2;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.3s;
}

.image-option:hover {
    border-color: #3498db;
}

.image-option.selected {
    border-color: #2ecc71;
}

.image-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.difficulty-options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 1rem 2rem;
    border: 2px solid #3498db;
    background-color: white;
    color: #3498db;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1rem;
}

.difficulty-btn:hover {
    background-color: #3498db;
    color: white;
}

.difficulty-btn.selected {
    background-color: #3498db;
    color: white;
}

#start-puzzle {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    margin-top: 2rem;
}

.hidden {
    display: none !important;
}

.game-area {
    width: 100%;
    max-width: 1400px;
}

.game-info {
    background-color: white;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.puzzle-container {
    display: flex;
    gap: 2rem;
}

.puzzle-board {
    flex: 1;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    aspect-ratio: 3/2;
}

.piece-tray {
    width: 200px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    max-height: 600px;
    overflow-y: auto;
}

.puzzle-piece {
    position: absolute;
    cursor: move;
    transition: transform 0.2s;
    z-index: 1;
}

.puzzle-piece:hover {
    z-index: 10;
    transform: scale(1.05);
}

.puzzle-piece.dragging {
    z-index: 100;
    cursor: grabbing;
}

.puzzle-piece.placed {
    cursor: default;
    z-index: 0;
}

.puzzle-piece.placed:hover {
    transform: none;
}

.drop-zone {
    position: absolute;
    border: 1px dashed #bdc3c7;
}

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

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.modal-content p {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .puzzle-container {
        flex-direction: column;
    }

    .piece-tray {
        width: 100%;
        max-height: 200px;
    }

    header {
        flex-direction: column;
        gap: 1rem;
    }
}