/* --- BASE & LAYOUT STYLES --- */
body,
html {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    background-color: #0d204d; /* Fallback background */
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    display: block;
    cursor: pointer;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
}

/* --- SPLASH SCREEN STYLES --- */
#splash-screen {
    position: fixed;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 1s ease-out;
}

.game-title {
    color: #fff;
    font-size: 3em;
    text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #0f0, 0 0 40px #0f0;
    animation: glow 1.5s ease-in-out infinite alternate;
}

.loading-bar-container {
    width: 60%;
    max-width: 300px;
    height: 20px;
    border: 2px solid #fff;
    border-radius: 10px;
    margin-top: 20px;
}

.loading-bar {
    width: 0;
    height: 100%;
    background-color: #fff;
    border-radius: 8px;
    animation: loading 2s forwards;
}

/* --- UI ELEMENTS (LEVEL & MUSIC) --- */
#level-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 10;
}

#level-display {
    font-size: 1.8em;
    color: white;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
}

#music-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10;
}

#music-toggle {
    width: 35px;
    height: 35px;
    cursor: pointer;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
}

.music-on {
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>');
}

.music-off {
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/></svg>');
}

/* --- GUIDE PANEL STYLES --- */
#guide-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    max-width: 320px;
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    border: 2px solid white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    text-align: center;
    z-index: 50;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

#guide-panel.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    pointer-events: none; /* Make it unclickable when hidden */
}

#guide-panel h2 {
    margin-top: 0;
    font-size: 1.8em;
}

#guide-panel p {
    font-size: 1.1em;
    line-height: 1.4;
}

#close-guide-btn {
    background-color: #fff;
    color: #000;
    border: none;
    border-radius: 8px;
    padding: 10px 25px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    transition: transform 0.2s ease;
}

#close-guide-btn:hover {
    transform: scale(1.05);
}

.guide-visual {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    align-items: center;
    justify-items: center;
    width: 100px;
    height: 100px;
    margin: 15px auto;
}

.guide-visual .cube {
    grid-column: 2;
    grid-row: 2;
    width: 35px;
    height: 35px;
    background-color: white;
    box-shadow: 0 0 15px white;
}

.guide-visual .arrow {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
}

.guide-visual .up {
    grid-column: 2;
    grid-row: 1;
    border-bottom: 15px solid rgba(255, 255, 255, 0.7);
}
.guide-visual .down {
    grid-column: 2;
    grid-row: 3;
    border-top: 15px solid rgba(255, 255, 255, 0.7);
}
.guide-visual .left {
    grid-column: 1;
    grid-row: 2;
    border-right: 15px solid rgba(255, 255, 255, 0.7);
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
}
.guide-visual .right {
    grid-column: 3;
    grid-row: 2;
    border-left: 15px solid rgba(255, 255, 255, 0.7);
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
}

/* --- KEYFRAME ANIMATIONS --- */
@keyframes glow {
    from {
        text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #0ff, 0 0 40px #0ff;
    }
    to {
        text-shadow: 0 0 20px #fff, 0 0 30px #f0f, 0 0 40px #f0f, 0 0 50px #f0f;
    }
}

@keyframes loading {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}