/* Main Styles */
body {
    font-family: 'Poppins', sans-serif;
    background-color: #000000;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    color: #e0e0e0;
    overflow: auto;
    position: relative;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
}

/* Golden Particle Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(234, 179, 8, 0.1) 0%, transparent 25%),
        radial-gradient(circle at 80% 70%, rgba(234, 179, 8, 0.1) 0%, transparent 25%);
    animation: goldenPulse 8s infinite alternate;
    z-index: -1;
}

@keyframes goldenPulse {
    0% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.7; }
    100% { opacity: 0.3; transform: scale(1.02); }
}

/* Game Container */
#game-container {
    position: relative;
    box-shadow: 0 0 20px rgba(234, 179, 8, 0.4);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(234, 179, 8, 0.3);
    background-color: #111827;
    transition: all 0.3s ease;
    width: 100%;
    height: 100%;
    aspect-ratio: 1/1;
    max-height: 80vh;
}

#game-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to bottom right,
        rgba(234, 179, 8, 0) 0%,
        rgba(234, 179, 8, 0.05) 20%,
        rgba(234, 179, 8, 0) 40%
    );
    transform: rotate(30deg);
    animation: goldenShine 8s linear infinite;
    z-index: 0;
}

@keyframes goldenShine {
    0% { transform: translateX(-100%) rotate(30deg); }
    100% { transform: translateX(100%) rotate(30deg); }
}

/* Loading Animation */
#loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(17, 24, 39, 0.9);
    z-index: 10;
    transition: opacity 0.5s ease;
}

#loading p {
    margin-top: 0.5rem;
    color: #F59E0B;
    font-size: 0.9rem;
    text-shadow: 0 0 8px rgba(234, 179, 8, 0.5);
}

.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Control Buttons */
.control-btn {
    transition: all 0.2s ease;
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.3);
    border: 1px solid rgba(234, 179, 8, 0.4);
    background: rgba(31, 41, 55, 0.8);
    color: #F59E0B;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
}

.control-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 12px rgba(234, 179, 8, 0.5);
    background: rgba(234, 179, 8, 0.1);
}

.control-btn:active {
    transform: scale(0.95);
    box-shadow: 0 0 5px rgba(234, 179, 8, 0.3);
}

/* Panels */
.panel {
    background: rgba(31, 41, 55, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(234, 179, 8, 0.2);
    border: 1px solid rgba(234, 179, 8, 0.2);
    position: relative;
    overflow: hidden;
}

.panel::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(234, 179, 8, 0.05) 0%,
        rgba(234, 179, 8, 0) 20%,
        rgba(234, 179, 8, 0) 80%,
        rgba(234, 179, 8, 0.05) 100%
    );
    pointer-events: none;
}

/* Stats Cards */
.stats-card {
    background: rgba(55, 65, 81, 0.7);
    border-radius: 8px;
    padding: 0.75rem;
    box-shadow: 0 3px 5px rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.2);
    transition: all 0.3s ease;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 7px rgba(234, 179, 8, 0.2);
}

/* Action Buttons */
#new-maze-btn, #solve-btn, #play-again-btn, #try-again-btn {
    background-color: #F59E0B;
    color: #111827;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 3px 5px rgba(234, 179, 8, 0.3);
    border: 1px solid rgba(234, 179, 8, 0.5);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

#new-maze-btn:hover, #solve-btn:hover, 
#play-again-btn:hover, #try-again-btn:hover {
    background-color: #FBBF24;
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(234, 179, 8, 0.4);
}

#new-maze-btn:active, #solve-btn:active, 
#play-again-btn:active, #try-again-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 3px rgba(234, 179, 8, 0.3);
}

#solve-btn.solving {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { 
        background-color: #D97706;
        box-shadow: 0 0 8px rgba(234, 179, 8, 0.5);
    }
    50% { 
        background-color: #F59E0B;
        box-shadow: 0 0 15px rgba(234, 179, 8, 0.8);
    }
    100% { 
        background-color: #D97706;
        box-shadow: 0 0 8px rgba(234, 179, 8, 0.5);
    }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 1rem 0;
}

.stat-item {
    background: rgba(55, 65, 81, 0.7);
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(234, 179, 8, 0.3);
    box-shadow: 0 2px 3px rgba(234, 179, 8, 0.1);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 6px rgba(234, 179, 8, 0.2);
}

.stat-label {
    font-size: 0.75rem;
    color: #9CA3AF;
    margin-bottom: 0.2rem;
}

.stat-value {
    font-size: 1rem;
    font-weight: bold;
    color: #F59E0B;
    text-shadow: 0 0 6px rgba(234, 179, 8, 0.5);
}

/* Text Styles */
h1, h2 {
    color: #F59E0B;
    text-shadow: 0 0 8px rgba(234, 179, 8, 0.5);
}

h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
    position: relative;
}

h1::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #F59E0B, transparent);
    box-shadow: 0 0 8px rgba(234, 179, 8, 0.5);
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

p {
    color: #E5E7EB;
}

/* Modal Styles */
#win-modal, #lose-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

#win-modal.show, #lose-modal.show {
    opacity: 1;
    pointer-events: all;
}

#win-modal > div, #lose-modal > div {
    background: rgba(31, 41, 55, 0.95);
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(234, 179, 8, 0.5);
    border: 2px solid rgba(234, 179, 8, 0.5);
    transform: scale(0.9);
    transition: all 0.3s ease;
    width: 100%;
    max-width: 24rem;
    text-align: center;
}

#win-modal.show > div, #lose-modal.show > div {
    transform: scale(1);
}

#win-modal svg {
    filter: drop-shadow(0 0 8px rgba(234, 179, 8, 0.7));
}

#lose-modal svg {
    filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.7));
}

/* Responsive Adjustments */
@media (max-width: 640px) {
    body {
        padding-bottom: 20px;
        overflow-y: auto;
    }
    
    #game-container {
        max-height: 70vh;
    }
    
    .flex-col {
        flex-direction: column;
    }
    
    .lg\:flex-row {
        flex-direction: column;
    }
    
    .lg\:w-64 {
        width: 100%;
        margin-top: 0.75rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.1rem;
    }
    
    .control-btn {
        width: 60px !important;
        height: 60px !important;
        font-size: 24px !important;
    }
    
    #new-maze-btn, #solve-btn, #play-again-btn, #try-again-btn {
        padding: 12px !important;
    }
}

/* Prevent zooming on mobile */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #111827;
}

::-webkit-scrollbar-thumb {
    background: rgba(234, 179, 8, 0.5);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(234, 179, 8, 0.7);
}


/* Mobile-specific optimizations */
@media (max-width: 768px) {
    /* Disable complex animations and shadows on mobile */
    body::before {
        display: none;
    }
    
    #game-container::before {
        display: none;
    }
    
    .panel::after {
        display: none;
    }
    
    /* Simplify controls */
    .control-btn {
        width: 85px !important;
        height: 85px !important;
        font-size: 48px !important;
        box-shadow: none !important;
    }
    
    /* Disable complex shadows and effects */
    .stats-card, .stat-item {
        box-shadow: none !important;
    }
    
    /* Optimize modal performance */
    #win-modal, #lose-modal {
        transform: translateZ(0);
        backface-visibility: hidden;
        perspective: 1000;
    }
    
    /* Disable particle effects */
    #game-container {
        box-shadow: none;
    }
}

/* Hardware acceleration for better performance */
#game-container, canvas {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000;
    will-change: transform;
}