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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(45deg, #0a0a23, #1a1a3a, #2a1810, #0a0a23);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: white;
    overflow-x: auto;
    perspective: 1000px;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* 3D Floating Particles */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.4), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255, 255, 255, 0.3), transparent);
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: sparkle 20s linear infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes sparkle {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    100% {
        transform: translateY(-100vh) rotate(360deg);
    }
}

/* Preloader Styles */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a23 0%, #2a1810 100%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    /* justify-content: center; */
    align-items: center;
    transition: all 0.8s ease-out;
    padding-top: 200px;
}

.preloader.hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
}

.maze-loader {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
    animation: cube3d 2s linear infinite;
}

.maze-loader::before,
.maze-loader::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, #ff6b9d, #c44569, #f8b500);
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(255, 107, 157, 0.5);
}

.maze-loader::before {
    transform: rotateY(0deg) translateZ(50px);
}

.maze-loader::after {
    transform: rotateY(90deg) translateZ(50px);
}

@keyframes cube3d {
    0% {
        transform: rotateX(0deg) rotateY(0deg);
    }

    100% {
        transform: rotateX(360deg) rotateY(360deg);
    }
}

.loading-text {
    margin-top: 30px;
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 3px;
    background: linear-gradient(45deg, #ff6b9d, #c44569, #f8b500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: textGlow 2s ease-in-out infinite alternate;
}

@keyframes textGlow {
    from {
        text-shadow: 0 0 20px rgba(255, 107, 157, 0.5);
    }

    to {
        text-shadow: 0 0 40px rgba(255, 107, 157, 0.8);
    }
}

/* Main Game Header */
header {
    font-size: 2em;
    font-weight: 900;
    margin: 10px 0;
    background: linear-gradient(45deg, #ff6b9d, #c44569, #f8b500, #ff6b9d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(255, 107, 157, 0.5);
    transform: perspective(500px) rotateX(15deg);
    animation: titleFloat 3s ease-in-out infinite;
}

@keyframes titleFloat {

    0%,
    100% {
        transform: perspective(500px) rotateX(15deg) translateY(0px);
    }

    50% {
        transform: perspective(500px) rotateX(15deg) translateY(-10px);
    }
}

.game-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-bottom: 30px;
    padding: 0 20px;
    transform: perspective(800px) rotateX(5deg);
}

.info-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 30px;
    margin-bottom: 20px;
    max-width: 420px;
}

.level-info,
.timer {
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.2), rgba(196, 69, 105, 0.2));
    padding: 15px 30px;
    border-radius: 20px;
    backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 107, 157, 0.3);
    font-weight: 700;
    font-size: 1em;
    flex: 1;
    text-align: center;
    box-shadow:
        0 8px 32px rgba(255, 107, 157, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateZ(20px);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.level-info::before,
.timer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.level-info:hover::before,
.timer:hover::before {
    left: 100%;
}

.level-info:hover,
.timer:hover {
    transform: translateZ(30px) scale(1.05);
    box-shadow: 0 15px 60px rgba(255, 107, 157, 0.4);
}

.game-container {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    flex-wrap: wrap;
    justify-content: center;
    transform: perspective(1000px) rotateX(2deg);
}

/* 3D Canvas Styling */
canvas {
    border: 4px solid rgba(255, 107, 157, 0.4);
    border-radius: 20px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    background: white;
    transform: perspective(800px) rotateX(5deg) rotateY(-2deg) translateZ(30px);
    transition: all 0.3s ease;
    position: relative;
}

canvas::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: linear-gradient(45deg, #ff6b9d, #c44569, #f8b500);
    border-radius: 25px;
    z-index: -1;
    opacity: 0.6;
    filter: blur(15px);
}

canvas:hover {
    transform: perspective(800px) rotateX(2deg) rotateY(-1deg) translateZ(40px) scale(1.02);
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.6),
        0 0 100px rgba(255, 107, 157, 0.3);
}

.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
    transform: perspective(600px) rotateY(5deg);
}

.settings {
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.1), rgba(196, 69, 105, 0.1));
    padding: 20px;
    border-radius: 25px;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 107, 157, 0.3);
    width: 500px;
    box-shadow:
        0 15px 45px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateZ(20px);
    transition: all 0.3s ease;
}

.settings:hover {
    transform: translateZ(30px) scale(1.02);
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.4);
}

.settings h3 {
    margin-bottom: 20px;
    font-size: 1em;
    color: white;
    text-align: center;
    text-shadow: 0 2px 10px rgba(255, 107, 157, 0.5);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 5px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    transform: perspective(300px) translateZ(10px);
}

.settings label {
    margin-bottom: 8px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.settings input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: none;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    box-shadow:
        inset 0 3px 10px rgba(0, 0, 0, 0.1),
        0 2px 10px rgba(255, 107, 157, 0.2);
    transition: all 0.3s ease;
}

.settings input[type="text"]:focus {
    outline: none;
    box-shadow:
        inset 0 3px 10px rgba(0, 0, 0, 0.1),
        0 0 20px rgba(255, 107, 157, 0.5);
    transform: scale(1.05);
}

.btn {
    background: linear-gradient(45deg, #ff6b9d, #c44569);
    color: white;
    border: none;
    padding: 15px 15px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow:
        0 8px 25px rgba(255, 107, 157, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    width: 100%;
    margin-top: 15%;
    transform: perspective(200px) translateZ(15px);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: perspective(200px) translateZ(25px) scale(1.05);
    box-shadow:
        0 15px 40px rgba(255, 107, 157, 0.6),
        0 0 30px rgba(255, 107, 157, 0.3);
}

.btn:active {
    transform: perspective(200px) translateZ(10px) scale(0.98);
}

.controls {
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.1), rgba(196, 69, 105, 0.1));
    padding: 30px;
    border-radius: 25px;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 107, 157, 0.3);
    display: grid;
    grid-template-areas:
        ". up ."
        "left . right"
        ". down .";
    gap: 15px;
    min-width: 180px;
    box-shadow:
        0 15px 45px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: translateZ(20px);
    transition: all 0.3s ease;
}

.controls:hover {
    transform: translateZ(30px) scale(1.02);
}

.controls h3 {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 15px;
    font-size: 1em;
    text-shadow: 0 2px 10px rgba(255, 107, 157, 0.5);
}

.control-btn {
    width: 60px;
    height: 60px;
    background: linear-gradient(145deg, rgba(255, 107, 157, 0.3), rgba(196, 69, 105, 0.3));
    border: 2px solid rgba(255, 107, 157, 0.4);
    border-radius: 15px;
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: perspective(200px) translateZ(15px);
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.control-btn:hover {
    background: linear-gradient(145deg, rgba(255, 107, 157, 0.5), rgba(196, 69, 105, 0.5));
    transform: perspective(200px) translateZ(25px) scale(1.1);
    box-shadow:
        0 15px 40px rgba(255, 107, 157, 0.4),
        0 0 30px rgba(255, 107, 157, 0.3);
}

.control-btn:active {
    transform: perspective(200px) translateZ(5px) scale(0.9);
}

.up {
    grid-area: up;
}

.right {
    grid-area: right;
}

.down {
    grid-area: down;
}

.left {
    grid-area: left;
}

/* Enhanced Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: linear-gradient(135deg, rgba(255, 107, 157, 0.2), rgba(196, 69, 105, 0.2));
    backdrop-filter: blur(20px);
    padding: 50px;
    border-radius: 30px;
    text-align: center;
    color: white;
    max-width: 500px;
    width: 90%;
    transform: perspective(600px) rotateX(20deg) scale(0.8);
    transition: all 0.4s ease;
    border: 3px solid rgba(255, 107, 157, 0.4);
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.modal.active .modal-content {
    transform: perspective(600px) rotateX(0deg) scale(1);
}

.modal h2 {
    font-size: 2.5em;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #ff6b9d, #f8b500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(255, 107, 157, 0.5);
}

.modal p {
    font-size: 1.4em;
    margin-bottom: 30px;
    opacity: 0.9;
}

.modal-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

footer {
    margin-top: 50px;
    text-align: center;
    opacity: 0.7;
    font-size: 1em;
    margin-bottom: 30px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

footer a {
    color: white;
    text-decoration: none;
}

footer a:hover {
    color: #ff6b9d;
    text-shadow: 0 0 10px rgba(255, 107, 157, 0.5);
}

@media (max-width: 768px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }

    .game-info {
        flex-direction: column;
        gap: 15px;
    }

    header {
        font-size: 1.5em;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .info-row {
        flex-direction: column;
        gap: 15px;
    }

    .controls-panel {
        transform: none;
    }

    .settings {
        width: 90%;
        max-width: 400px;
    }
}