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

body {
    background-color: #0e2340;
    color: #d1e7ff;
    font-family: Arial, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Prevent zoom on double tap on mobile */
    touch-action: manipulation;
}

.game-container {
    display: flex;
    gap: 2rem;
    padding: 2rem;
    max-width: 1920px;
    width: 100%;
    height: 100vh;
}

.game-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0; /* Allow flex item to shrink */
}

#mazeCanvas {
    background-color: #0e2340;
    border: 2px solid #d1e7ff;
    box-shadow: 0 0 20px rgba(209, 231, 255, 0.2);
    max-width: 100%;
    max-height: 100%;
    touch-action: none; /* Prevent default touch behaviors */
}

.game-info {
    width: 300px;
    padding: 1rem;
    background-color: rgba(209, 231, 255, 0.1);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 0; /* Allow flex item to shrink */
    overflow-y: auto; /* Allow scrolling on very small screens */
}

.stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stats div {
    font-size: 1.2rem;
    padding: 0.5rem;
    background-color: rgba(209, 231, 255, 0.1);
    border-radius: 5px;
}

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

button {
    padding: 0.8rem;
    background-color: #26ff67;
    border: none;
    border-radius: 5px;
    color: #0e2340;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px; /* Minimum touch target size */
    touch-action: manipulation; /* Prevent zoom on tap */
}

button:hover {
    background-color: #1fcc52;
}

#difficultySlider {
    width: 100%;
    margin: 1rem 0;
    -webkit-appearance: none;
    appearance: none;
    height: 10px;
    background: rgba(209, 231, 255, 0.2);
    border-radius: 5px;
    outline: none;
}

#difficultySlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #26ff67;
    border-radius: 50%;
    cursor: pointer;
}

.instructions {
    padding: 1rem;
    background-color: rgba(209, 231, 255, 0.1);
    border-radius: 5px;
}

.instructions h3 {
    margin-bottom: 1rem;
    color: #26ff67;
}

.instructions p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.8;
}

.copyright {
    margin-top: auto;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    color: #ffffff;
    opacity: 0.8;
    border-top: 1px solid rgba(209, 231, 255, 0.1);
}

.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(14, 35, 64, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease-out;
}

.level-dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: rgba(20, 20, 20, 0.85);
    border: 1px solid #cccccc;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    color: #ffffff;
    box-shadow: 
        0 0 30px rgba(38, 255, 103, 0.2),
        0 0 60px rgba(38, 255, 103, 0.1);
    min-width: 300px;
    animation: dialogAppear 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

@keyframes dialogAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -45%) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.level-dialog h2 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #26ff67;
    font-weight: 600;
    text-shadow: 0 0 15px rgba(38, 255, 103, 0.5);
}

.level-dialog .stats-container {
    background: rgba(38, 255, 103, 0.1);
    border-radius: 10px;
    padding: 20px;
    margin: 1rem 0;
}

.level-dialog p {
    font-size: 18px;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
}

.level-dialog .highlight {
    color: #26ff67;
    font-weight: 600;
}

.level-dialog button {
    background: #26ff67;
    color: black;
    border: none;
    border-radius: 5px;
    padding: 10px 20px;
    margin-top: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.level-dialog button:hover {
    background: #4dff8a;
    transform: translateY(-2px);
    box-shadow: 
        0 5px 25px rgba(38, 255, 103, 0.3),
        0 0 0 2px rgba(38, 255, 103, 0.3);
}

.level-dialog button:active {
    transform: translateY(0);
    box-shadow: 0 0 0 2px rgba(38, 255, 103, 0.5);
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    body {
        overflow: auto; /* Allow scrolling on mobile */
        align-items: flex-start;
        padding: 0;
    }
    
    .game-container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        height: auto;
        min-height: 100vh;
    }
    
    .game-area {
        order: 1;
        height: 60vh;
        min-height: 300px;
    }
    
    .game-info {
        order: 2;
        width: 100%;
        padding: 1rem;
        gap: 1rem;
        max-height: none;
        overflow-y: visible;
    }
    
    #mazeCanvas {
        width: 100% !important;
        height: 100% !important;
        object-fit: contain;
    }
    
    .stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    
    .stats div {
        font-size: 1rem;
        padding: 0.8rem;
        text-align: center;
    }
    
    .controls {
        gap: 0.8rem;
    }
    
    button {
        padding: 1rem;
        font-size: 1.1rem;
        min-height: 48px; /* Larger touch target for mobile */
    }
    
    .instructions {
        padding: 0.8rem;
    }
    
    .instructions h3 {
        font-size: 1.1rem;
        margin-bottom: 0.8rem;
    }
    
    .instructions p {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }
    
    #difficultySlider {
        height: 15px; /* Larger slider for easier touch interaction */
        margin: 0.8rem 0;
    }
    
    #difficultySlider::-webkit-slider-thumb {
        width: 25px;
        height: 25px;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 0.5rem;
    }
    
    .game-area {
        height: 50vh;
        min-height: 250px;
    }
    
    .game-info {
        padding: 0.8rem;
    }
    
    .stats {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
    
    .stats div {
        font-size: 0.9rem;
        padding: 0.6rem;
    }
    
    button {
        padding: 0.8rem;
        font-size: 1rem;
        min-height: 44px;
    }
    
    .instructions h3 {
        font-size: 1rem;
    }
    
    .instructions p {
        font-size: 0.8rem;
    }
}

/* Touch controls for mobile */
.mobile-controls {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background-color: rgba(209, 231, 255, 0.1);
    border-radius: 10px;
    margin-top: 1rem;
}

@media (max-width: 768px) {
    .mobile-controls {
        display: flex;
        flex-wrap: wrap;
    }
}

.d-pad {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 5px;
    width: 150px;
    height: 150px;
}

.d-pad-btn {
    background-color: #26ff67;
    border: none;
    border-radius: 8px;
    color: #0e2340;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.d-pad-btn:active {
    background-color: #1fcc52;
    transform: scale(0.95);
}

.d-pad-up {
    grid-column: 2;
    grid-row: 1;
}

.d-pad-left {
    grid-column: 1;
    grid-row: 2;
}

.d-pad-right {
    grid-column: 3;
    grid-row: 2;
}

.d-pad-down {
    grid-column: 2;
    grid-row: 3;
}

.mobile-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-action-buttons button {
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
    min-width: 100px;
} 