.rubiks-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
    font-family: Arial, sans-serif;
}

.rubiks-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.size-selector select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.view-switcher {
    display: flex;
    gap: 5px;
}

.view-btn {
    padding: 8px 16px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
}

.view-btn.active {
    background: #007cba;
    color: white;
}

/* Main Layout - Side by Side */
.cube-solution-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin: 20px 0;
}

.cube-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.solution-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #ddd;
}

/* Color Palette */
.color-palette {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.color-btn {
    width: 40px;
    height: 40px;
    border: 3px solid #ccc;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s;
}

.color-btn.active {
    border-color: #333;
    transform: scale(1.1);
}

/* 3D Cube Styles with Animation */
.cube-view-3d {
    perspective: 1000px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 450px;
}

.cube-3d {
    position: relative;
    width: 240px;
    height: 240px;
    transform-style: preserve-3d;
    transition: transform 0.5s ease-in-out;
}

.face {
    position: absolute;
    width: 240px;
    height: 240px;
    display: grid;
    gap: 2px;
    padding: 5px;
    box-sizing: border-box;
    border: 1px solid #333;
}

/* Dynamic grid sizing for different cube sizes */
.face.size-3 { 
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.face.size-4 { 
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.face.size-5 { 
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
}

.face.front { transform: rotateY(0deg) translateZ(120px); }
.face.right { transform: rotateY(90deg) translateZ(120px); }
.face.back { transform: rotateY(180deg) translateZ(120px); }
.face.left { transform: rotateY(-90deg) translateZ(120px); }
.face.top { transform: rotateX(90deg) translateZ(120px); }
.face.bottom { transform: rotateX(-90deg) translateZ(120px); }

.sticker {
    background: white;
    border: 1px solid #333;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: bold;
}

.sticker:hover {
    transform: scale(0.95);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.3);
}

/* Animation for face rotations */
.face-rotating {
    animation: faceRotation 0.6s ease-in-out;
}

@keyframes faceRotation {
    0% { transform: scale(1) rotateZ(0deg); }
    50% { transform: scale(1.05) rotateZ(90deg); }
    100% { transform: scale(1) rotateZ(180deg); }
}

/* Move animation highlight */
.move-highlight {
    box-shadow: 0 0 20px #ff6b6b !important;
    animation: moveGlow 0.8s ease-in-out;
}

@keyframes moveGlow {
    0%, 100% { box-shadow: 0 0 20px #ff6b6b; }
    50% { box-shadow: 0 0 30px #ff6b6b, 0 0 40px #ff6b6b; }
}

/* 2D Flat View */
.cube-view-2d {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.cube-flat {
    display: grid;
    grid-template-areas: 
        ". top . ."
        "left front right back"
        ". bottom . .";
    gap: 10px;
}

.flat-face {
    width: 140px;
    height: 140px;
    display: grid;
    gap: 1px;
    border: 2px solid #333;
}

.flat-face.size-3 { 
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.flat-face.size-4 { 
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    width: 160px;
    height: 160px;
}

#flat-top { grid-area: top; }
#flat-left { grid-area: left; }
#flat-front { grid-area: front; }
#flat-right { grid-area: right; }
#flat-back { grid-area: back; }
#flat-bottom { grid-area: bottom; }

/* Algorithm and Controls */
.algorithm-section {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.algorithm-input {
    display: flex;
    gap: 5px;
}

#algorithm-input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    width: 200px;
}

.execute-btn, .action-btn, .solve-btn, .step-btn, .auto-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.action-btn {
    background: #ddd;
    color: #333;
}

.solve-btn {
    background: #4CAF50;
    color: white;
    font-size: 16px;
}

.execute-btn {
    background: #2196F3;
    color: white;
}

.step-btn {
    background: #FF9800;
    color: white;
}

.auto-btn {
    background: #9C27B0;
    color: white;
}

.action-btn:hover, .solve-btn:hover, .execute-btn:hover, .step-btn:hover, .auto-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* Move History */
.move-history {
    background: white;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    font-family: monospace;
    max-height: 60px;
    overflow-y: auto;
}

/* Solution Panel - Enhanced */
.solution-panel {
    background: white;
    padding: 20px;
    border-radius: 5px;
    border: 1px solid #ccc;
    height: fit-content;
}

.solution-display {
    margin-bottom: 20px;
}

.solution-moves {
    font-family: monospace;
    background: #f5f5f5;
    padding: 10px;
    border-radius: 5px;
    word-break: break-all;
    font-size: 14px;
    margin: 10px 0;
}

.current-step {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #2196F3;
    margin: 15px 0;
}

.current-step span:first-child {
    font-weight: bold;
}

.step-explanation {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    margin: 10px 0;
    border: 1px solid #ddd;
}

.solution-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.solution-progress {
    width: 100%;
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    margin: 10px 0;
}

.solution-progress-bar {
    height: 100%;
    background: #4CAF50;
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Control Panel */
.control-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px 0;
    flex-wrap: wrap;
    gap: 10px;
}

.cube-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Messages */
.message {
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    font-weight: bold;
    transition: opacity 0.3s;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

.success-message {
    background: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #81c784;
}

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 20px;
    border-radius: 5px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s;
}

.close:hover {
    color: #333;
}

/* Instructions */
.instructions {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cube-solution-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .rubiks-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .cube-3d, .face {
        width: 200px;
        height: 200px;
    }
    
    .face.front { transform: rotateY(0deg) translateZ(100px); }
    .face.right { transform: rotateY(90deg) translateZ(100px); }
    .face.back { transform: rotateY(180deg) translateZ(100px); }
    .face.left { transform: rotateY(-90deg) translateZ(100px); }
    .face.top { transform: rotateX(90deg) translateZ(100px); }
    .face.bottom { transform: rotateX(-90deg) translateZ(100px); }
    
    .algorithm-section {
        flex-direction: column;
        align-items: center;
    }
    
    .control-panel {
        flex-direction: column;
        gap: 15px;
    }
    
    .solution-controls {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .cube-3d, .face {
        width: 160px;
        height: 160px;
    }
    
    .flat-face {
        width: 100px;
        height: 100px;
    }
    
    .flat-face.size-4 {
        width: 120px;
        height: 120px;
    }
}
