* {
    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;
}

.game-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 30px;
    max-width: 600px;
    width: 100%;
}

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

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

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


.difficulty-selection {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.difficulty-selection label {
    font-weight: bold;
    color: #555;
    font-size: 1.1em;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
    color: #333;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.radio-label:hover {
    background: #e3f2fd;
}

.radio-label input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.radio-label input[type="radio"]:checked + span {
    font-weight: bold;
    color: #1976d2;
}

.radio-label:has(input[type="radio"]:checked) {
    background: #e3f2fd;
    border: 2px solid #1976d2;
}

.radio-label:has(input[type="radio"]:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

.radio-label:has(input[type="radio"]:disabled):hover {
    background: transparent;
}

.maze-container {
    display: flex;
    justify-content: center;
    margin-bottom: 25px;
    perspective: 1000px;
}

.maze-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 2px;
    width: 400px;
    height: 400px;
    border: 3px solid #333;
    border-radius: 8px;
    background: #222;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 10px 20px rgba(0, 0, 0, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.1);
    transform: rotateX(15deg) rotateY(-5deg);
    transform-style: preserve-3d;
}

.cell {
    background: linear-gradient(145deg, #f0f0f0, #e0e0e0);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
    border-radius: 4px;
    box-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.2),
        inset 1px 1px 2px rgba(255, 255, 255, 0.8),
        inset -1px -1px 2px rgba(0, 0, 0, 0.1);
    transform-style: preserve-3d;
}

.cell:hover {
    background: linear-gradient(145deg, #e3f2fd, #bbdefb) !important;
    transform: translateZ(5px) scale(1.05);
    box-shadow: 
        4px 4px 8px rgba(0, 0, 0, 0.3),
        inset 1px 1px 2px rgba(255, 255, 255, 0.9),
        inset -1px -1px 2px rgba(0, 0, 0, 0.1);
}


.cell.start {
    background: linear-gradient(145deg, #66bb6a, #4caf50) !important;
    color: white;
    box-shadow: 
        3px 3px 6px rgba(0, 0, 0, 0.3),
        inset 1px 1px 2px rgba(255, 255, 255, 0.3),
        inset -1px -1px 2px rgba(0, 0, 0, 0.2);
    transform: translateZ(2px);
}

.cell.start::after {
    content: "START";
    font-size: 0.7em;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.cell.end {
    background: linear-gradient(145deg, #ef5350, #f44336) !important;
    color: white;
    box-shadow: 
        3px 3px 6px rgba(0, 0, 0, 0.3),
        inset 1px 1px 2px rgba(255, 255, 255, 0.3),
        inset -1px -1px 2px rgba(0, 0, 0, 0.2);
    transform: translateZ(2px);
}

.cell.end::after {
    content: "END";
    font-size: 0.7em;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.cell.visited {
    background: #2196f3 !important;
    color: white;
}

.cell.current {
    background: #ff9800 !important;
    color: white;
    animation: pulse 1s infinite;
}

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

.cell.invalid {
    background: #ffebee !important;
    animation: shake 0.5s ease-in-out;
}

.cell.computed-path {
    background: #c8e6c9 !important;
    border: 2px solid #4caf50 !important;
    animation: pathGlow 2s ease-in-out infinite;
}

.cell.path-tracing {
    background: #ffeb3b !important;
    border: 3px solid #ff9800 !important;
    animation: traceHighlight 0.5s ease-in-out;
    z-index: 10;
    position: relative;
}

.cell.solution-path {
    background: #4caf50 !important;
    border: 3px solid #2e7d32 !important;
    animation: solutionGlow 1.5s ease-in-out infinite;
}

.cell.traced-path {
    background: rgba(255, 255, 0, 0.7) !important;
    border: 2px solid #ffeb3b !important;
    animation: tracedPathGlow 0.5s ease-in-out;
}

.cell.invalid-move {
    background: #ffcdd2 !important;
    border: 3px solid #f44336 !important;
    animation: invalidMoveFlash 0.5s ease-in-out;
}

@keyframes solutionGlow {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(76, 175, 80, 0.6);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 25px rgba(76, 175, 80, 1);
        transform: scale(1.05);
    }
}

@keyframes pathGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(76, 175, 80, 0.5); }
    50% { box-shadow: 0 0 15px rgba(76, 175, 80, 0.8); }
}

@keyframes traceHighlight {
    0% { 
        transform: scale(1);
        box-shadow: 0 0 0 rgba(255, 193, 7, 0);
    }
    50% { 
        transform: scale(1.2);
        box-shadow: 0 0 20px rgba(255, 193, 7, 0.8);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 0 0 rgba(255, 193, 7, 0);
    }
}

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

@keyframes tracedPathGlow {
    0% { 
        transform: scale(1);
        box-shadow: 0 0 0 rgba(255, 235, 59, 0);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(255, 235, 59, 0.8);
    }
    100% { 
        transform: scale(1);
        box-shadow: 0 0 0 rgba(255, 235, 59, 0);
    }
}

@keyframes invalidMoveFlash {
    0% { 
        background: #ffcdd2 !important;
        transform: scale(1);
    }
    25% { 
        background: #f44336 !important;
        transform: scale(1.1);
    }
    50% { 
        background: #ffcdd2 !important;
        transform: scale(1);
    }
    75% { 
        background: #f44336 !important;
        transform: scale(1.1);
    }
    100% { 
        background: #ffcdd2 !important;
        transform: scale(1);
    }
}

/* L-barrier patterns - 3D brick walls */
.cell.pattern-a {
    position: relative;
}

.cell.pattern-a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 12px;
    background: 
        linear-gradient(90deg, 
            #8B4513 0%, #A0522D 20%, #8B4513 40%, 
            #A0522D 60%, #8B4513 80%, #A0522D 100%);
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.7),
        0 3px 6px rgba(0, 0, 0, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
    z-index: 15;
    transform: translateZ(8px) rotateX(25deg);
    border-radius: 2px;
}

.cell.pattern-a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 12px;
    height: 100%;
    background: 
        linear-gradient(180deg, 
            #8B4513 0%, #A0522D 20%, #8B4513 40%, 
            #A0522D 60%, #8B4513 80%, #A0522D 100%);
    box-shadow: 
        6px 0 12px rgba(0, 0, 0, 0.7),
        3px 0 6px rgba(0, 0, 0, 0.5),
        inset 2px 0 4px rgba(255, 255, 255, 0.2),
        inset -2px 0 4px rgba(0, 0, 0, 0.3);
    z-index: 15;
    transform: translateZ(8px) rotateY(-25deg);
    border-radius: 2px;
}

.cell.pattern-b {
    position: relative;
}

.cell.pattern-b::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 12px;
    background: 
        linear-gradient(90deg, 
            #8B4513 0%, #A0522D 20%, #8B4513 40%, 
            #A0522D 60%, #8B4513 80%, #A0522D 100%);
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.7),
        0 3px 6px rgba(0, 0, 0, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.2),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3);
    z-index: 15;
    transform: translateZ(8px) rotateX(25deg);
    border-radius: 2px;
}

.cell.pattern-b::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 100%;
    background: 
        linear-gradient(180deg, 
            #8B4513 0%, #A0522D 20%, #8B4513 40%, 
            #A0522D 60%, #8B4513 80%, #A0522D 100%);
    box-shadow: 
        -6px 0 12px rgba(0, 0, 0, 0.7),
        -3px 0 6px rgba(0, 0, 0, 0.5),
        inset -2px 0 4px rgba(255, 255, 255, 0.2),
        inset 2px 0 4px rgba(0, 0, 0, 0.3);
    z-index: 15;
    transform: translateZ(8px) rotateY(25deg);
    border-radius: 2px;
}

.cell.pattern-c {
    position: relative;
}

.cell.pattern-c::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 12px;
    background: 
        linear-gradient(90deg, 
            #8B4513 0%, #A0522D 20%, #8B4513 40%, 
            #A0522D 60%, #8B4513 80%, #A0522D 100%);
    box-shadow: 
        0 -6px 12px rgba(0, 0, 0, 0.7),
        0 -3px 6px rgba(0, 0, 0, 0.5),
        inset 0 -2px 4px rgba(255, 255, 255, 0.2),
        inset 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 15;
    transform: translateZ(8px) rotateX(-25deg);
    border-radius: 2px;
}

.cell.pattern-c::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 12px;
    height: 100%;
    background: 
        linear-gradient(180deg, 
            #8B4513 0%, #A0522D 20%, #8B4513 40%, 
            #A0522D 60%, #8B4513 80%, #A0522D 100%);
    box-shadow: 
        6px 0 12px rgba(0, 0, 0, 0.7),
        3px 0 6px rgba(0, 0, 0, 0.5),
        inset 2px 0 4px rgba(255, 255, 255, 0.2),
        inset -2px 0 4px rgba(0, 0, 0, 0.3);
    z-index: 15;
    transform: translateZ(8px) rotateY(-25deg);
    border-radius: 2px;
}

.cell.pattern-d {
    position: relative;
}

.cell.pattern-d::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 12px;
    background: 
        linear-gradient(90deg, 
            #8B4513 0%, #A0522D 20%, #8B4513 40%, 
            #A0522D 60%, #8B4513 80%, #A0522D 100%);
    box-shadow: 
        0 -6px 12px rgba(0, 0, 0, 0.7),
        0 -3px 6px rgba(0, 0, 0, 0.5),
        inset 0 -2px 4px rgba(255, 255, 255, 0.2),
        inset 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 15;
    transform: translateZ(8px) rotateX(-25deg);
    border-radius: 2px;
}

.cell.pattern-d::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 100%;
    background: 
        linear-gradient(180deg, 
            #8B4513 0%, #A0522D 20%, #8B4513 40%, 
            #A0522D 60%, #8B4513 80%, #A0522D 100%);
    box-shadow: 
        -6px 0 12px rgba(0, 0, 0, 0.7),
        -3px 0 6px rgba(0, 0, 0, 0.5),
        inset -2px 0 4px rgba(255, 255, 255, 0.2),
        inset 2px 0 4px rgba(0, 0, 0, 0.3);
    z-index: 15;
    transform: translateZ(8px) rotateY(25deg);
    border-radius: 2px;
}

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

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

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

#new-game-btn {
    background: #4caf50;
    color: white;
}

#new-game-btn:hover {
    background: #45a049;
}

#reset-btn {
    background: #ff9800;
    color: white;
}

#reset-btn:hover {
    background: #f57c00;
}


#find-solutions-btn {
    background: #ff5722;
    color: white;
}

#find-solutions-btn:hover {
    background: #d84315;
}

#show-soln-btn {
    background: #607d8b;
    color: white;
}

#show-soln-btn:hover {
    background: #455a64;
}

.game-message {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.1em;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.game-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.game-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Responsive design */
@media (max-width: 600px) {
    .game-container {
        padding: 20px;
        margin: 10px;
    }
    
    .maze-grid {
        width: 300px;
        height: 300px;
    }
    
    .cell {
        font-size: 0.8em;
    }
    
    .cell.start::after,
    .cell.end::after {
        font-size: 0.6em;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .controls {
        flex-direction: column;
    }
    
    .difficulty-selection {
        flex-direction: column;
        gap: 10px;
    }
    
    .radio-group {
        flex-direction: column;
        gap: 10px;
    }
}
