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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 1200px;
    width: 95%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    grid-gap: 20px;
}

.game-section {
    grid-column: 1;
}

.stats-section {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

h1 {
    color: #333;
    margin-bottom: 20px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    grid-column: 1 / -1;
}

.puzzle-container {
    display: inline-block;
    background: #34495e;
    border-radius: 15px;
    padding: 15px;
    margin: 20px 0;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.3);
    max-width: 100%;
}

.puzzle-grid {
    position: relative;
    width: 300px;
    height: 300px;
    max-width: 100%;
    margin: 0 auto;
}

.tile {
    width: 90px;
    height: 90px;
    background: linear-gradient(145deg, #3498db, #2980b9);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 2.5em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    position: absolute;
    user-select: none;
}

.tile:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    background: linear-gradient(145deg, #5dade2, #3498db);
}

.tile:active {
    transform: translateY(-2px) scale(1.02);
}

.tile.empty {
    background: transparent;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    cursor: default;
}

.tile.empty:hover {
    transform: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tile.highlight {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    animation: pulse 0.6s ease-in-out;
}

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

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(145deg, #27ae60, #229954);
    color: white;
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(39, 174, 96, 0.4);
}

.btn-secondary {
    background: linear-gradient(145deg, #f39c12, #e67e22);
    color: white;
    box-shadow: 0 4px 8px rgba(243, 156, 18, 0.3);
}

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

.btn-danger {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    color: white;
    box-shadow: 0 4px 8px rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(231, 76, 60, 0.4);
}

.info {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
    flex-wrap: wrap;
    gap: 10px;
    background: rgba(236, 240, 241, 0.7);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.status {
    margin: 15px 0;
    font-size: 18px;
    font-weight: bold;
    padding: 15px;
    border-radius: 10px;
    transition: all 0.3s ease;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status.success {
    background: linear-gradient(145deg, #d5f4e6, #a8e6cf);
    color: #27ae60;
    border: 2px solid #27ae60;
}

.status.solving {
    background: linear-gradient(145deg, #fef9e7, #fcf3cf);
    color: #f39c12;
    border: 2px solid #f39c12;
}

.difficulty-selector {
    margin: 15px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.difficulty-selector label {
    font-weight: bold;
    color: #2c3e50;
    font-size: 18px;
    margin-right: 5px;
}

.difficulty-select {
    padding: 10px 15px;
    border-radius: 12px;
    background: linear-gradient(145deg, #f5f7fa, #c3cfe2);
    border: 2px solid #7f8c8d;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    color: #2c3e50;
    transition: all 0.3s ease;
    appearance: none;
    -webkit-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%232c3e50" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

.difficulty-select:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: #764ba2;
}

.difficulty-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

#customMovesContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
}

#customMovesContainer label {
    margin-right: 10px;
}

#customMoves {
    padding: 6px;
    border-radius: 5px;
    border: 1px solid #ccc;
    width: 60px;
    text-align: center;
}

.goal-state {
    background: rgba(236, 240, 241, 0.7);
    padding: 20px;
    border-radius: 15px;
    margin-top: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.goal-state h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.goal-grid {
    display: inline-grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    background: #ecf0f1;
    padding: 10px;
    border-radius: 10px;
    margin: 10px auto;
    max-width: 100%;
}

.chart-container {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    height: 100%;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chart-container canvas {
    flex: 1;
    width: 100% !important;
    height: 100% !important;
    min-height: 250px;
}

@media (max-width: 900px) {
    .container {
        grid-template-columns: 1fr;
        padding: 20px;
    }
    
    .game-section, .stats-section {
        grid-column: 1;
    }
    
    .puzzle-container {
        padding: 10px;
    }
    
    .chart-container {
        min-height: 250px;
    }
    
    h1 {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
        width: 100%;
    }
    
    .puzzle-grid {
        width: 250px;
        height: 250px;
    }
    
    .tile {
        width: 75px;
        height: 75px;
        font-size: 2em;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    button {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .info {
        justify-content: center;
        gap: 15px;
        flex-direction: column;
    }
    
    .chart-container {
        min-height: 200px;
    }
    
    h1 {
        font-size: 1.8em;
    }
}

@media (min-width: 1400px) {
    .container {
        grid-template-columns: 1fr 1.5fr;
    }
    
    .puzzle-grid {
        width: 400px;
        height: 400px;
    }
    
    .tile {
        width: 120px;
        height: 120px;
        font-size: 3em;
    }
    
    .chart-container {
        min-height: 400px;
    }
}