:root {
    --font-main: 'Metal Mania', cursive;
    --font-gothic-1: 'Creepster', cursive;
    --font-gothic-2: 'UnifrakturMaguntia', serif;
    --font-gothic-3: 'Metal Mania', cursive;
    --bg-dark: #0a0a0f;
    --bg-card: #12121a;
    --fog-color: #0a0a0f;
    --wall-color: #2a2a3a;
    --path-color: #101018;
    --player-color: #4a9;
    --exit-color: #c84;
    --trail-color: #4a9;
    --text-light: #ccc;
    --text-dim: #666;
    --border-color: #2a2a35;
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-dark);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    overflow-x: hidden;
    position: relative;
}

/* Floating particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}
.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #66aacc;
    border-radius: 50%;
    box-shadow: 0 0 8px 3px rgba(100, 180, 220, 0.5), 0 0 16px 6px rgba(60, 140, 180, 0.25);
    opacity: 0;
    animation: float 10s ease-in-out infinite;
}
.particle.small { width: 2px; height: 2px; }
.particle.large { width: 4px; height: 4px; }
.particle:nth-child(1) { left: 5%; top: 90%; animation-delay: 0s; animation-duration: 12s; }
.particle:nth-child(2) { left: 10%; top: 85%; animation-delay: 2s; animation-duration: 9s; }
.particle:nth-child(3) { left: 15%; top: 95%; animation-delay: 4s; animation-duration: 11s; }
.particle:nth-child(4) { left: 20%; top: 80%; animation-delay: 1s; animation-duration: 10s; }
.particle:nth-child(5) { left: 25%; top: 88%; animation-delay: 3s; animation-duration: 13s; }
.particle:nth-child(6) { left: 8%; top: 92%; animation-delay: 5s; animation-duration: 8s; }
.particle:nth-child(7) { left: 18%; top: 78%; animation-delay: 6s; animation-duration: 11s; }
.particle:nth-child(8) { left: 22%; top: 82%; animation-delay: 7s; animation-duration: 10s; }
.particle:nth-child(9) { left: 12%; top: 75%; animation-delay: 1.5s; animation-duration: 12s; }
.particle:nth-child(10) { left: 28%; top: 93%; animation-delay: 4.5s; animation-duration: 9s; }
.particle:nth-child(11) { left: 72%; top: 88%; animation-delay: 0.5s; animation-duration: 11s; }
.particle:nth-child(12) { left: 78%; top: 92%; animation-delay: 2.5s; animation-duration: 10s; }
.particle:nth-child(13) { left: 82%; top: 85%; animation-delay: 4.2s; animation-duration: 13s; }
.particle:nth-child(14) { left: 88%; top: 90%; animation-delay: 1.2s; animation-duration: 9s; }
.particle:nth-child(15) { left: 93%; top: 80%; animation-delay: 3.5s; animation-duration: 12s; }
.particle:nth-child(16) { left: 75%; top: 95%; animation-delay: 5.5s; animation-duration: 8s; }
.particle:nth-child(17) { left: 85%; top: 78%; animation-delay: 6.5s; animation-duration: 11s; }
.particle:nth-child(18) { left: 95%; top: 85%; animation-delay: 7.5s; animation-duration: 10s; }
.particle:nth-child(19) { left: 80%; top: 75%; animation-delay: 0.8s; animation-duration: 12s; }
.particle:nth-child(20) { left: 90%; top: 93%; animation-delay: 3.8s; animation-duration: 9s; }

@keyframes float {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    50% {
        opacity: 0.4;
        transform: translateY(-40vh) translateX(15px) scale(0.8);
    }
    100% {
        transform: translateY(-100vh) translateX(-10px) scale(0.4);
        opacity: 0;
    }
}

.container {
    max-width: 600px;
    width: 100%;
    background: var(--bg-card);
    border-radius: 8px;
    padding: 25px;
    border: 1px solid var(--border-color);
    position: relative;
    z-index: 10;
}

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

h1 {
    font-size: 1.8em;
    color: var(--text-light);
    letter-spacing: 3px;
    font-weight: normal;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.85em;
    margin-top: 5px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: var(--bg-card);
    border-radius: 4px;
}

.maze-info {
    color: var(--text-dim);
    font-size: 0.9em;
}

.maze-info .label {
    margin-right: 5px;
}

#mazeNumber {
    color: var(--text-light);
}

.stats-bar {
    display: flex;
    gap: 20px;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.7em;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#timer, #moves {
    color: var(--text-light);
    font-size: 1.1em;
}

/* Maze Canvas */
.game-board {
    margin: 15px auto;
    max-width: 100%;
    background: var(--fog-color);
    border-radius: 4px;
    overflow: hidden;
}

#mazeCanvas {
    display: block;
    cursor: pointer;
}

/* Mobile D-pad controls */
.mobile-controls {
    display: grid;
    grid-template-areas:
        ". up ."
        "left . right"
        ". down .";
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
    gap: 5px;
    justify-content: center;
    margin: 15px auto;
}

.dpad-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-light);
    font-size: 1.2em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dpad-btn:active {
    background: var(--border-color);
}

.dpad-up { grid-area: up; }
.dpad-down { grid-area: down; }
.dpad-left { grid-area: left; }
.dpad-right { grid-area: right; }

/* Hide on desktop, show on touch devices */
@media (hover: hover) and (pointer: fine) {
    .mobile-controls {
        display: none;
    }
}

.controls-hint {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.75em;
    margin-bottom: 15px;
}

.controls-hint p {
    margin: 3px 0;
}

.mobile-hint {
    display: none;
}

@media (hover: none) and (pointer: coarse) {
    .mobile-hint {
        display: block;
    }
}

.message {
    text-align: center;
    min-height: 20px;
    font-size: 0.9em;
    margin: 10px 0;
    color: var(--text-dim);
}

.message.success {
    color: var(--player-color);
}

.message.error {
    color: var(--exit-color);
}

.actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 3px;
    font-family: var(--font-main);
    font-size: 0.85em;
    cursor: pointer;
    background: transparent;
    color: var(--text-dim);
}

.btn-primary {
    background: var(--border-color);
    color: var(--text-light);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-light);
    border: 1px solid var(--border-color);
}

.btn-link {
    padding: 5px 10px;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
}

.modal-content {
    background-color: var(--bg-card);
    margin: 15% auto;
    padding: 25px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 90%;
    max-width: 400px;
}

.close {
    color: var(--text-dim);
    float: right;
    font-size: 24px;
    cursor: pointer;
    line-height: 16px;
}

.modal h2 {
    color: var(--text-light);
    margin-bottom: 20px;
    font-weight: normal;
    font-size: 1.2em;
    letter-spacing: 2px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.stat-box {
    background: var(--bg-dark);
    padding: 15px;
    border-radius: 3px;
    text-align: center;
}

.stat-value {
    font-size: 1.5em;
    color: var(--text-light);
    margin-bottom: 5px;
}

.stat-name {
    font-size: 0.75em;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.help-content {
    color: var(--text-dim);
    line-height: 1.6;
    font-size: 0.9em;
}

.help-content p {
    margin-bottom: 12px;
}

.help-content strong {
    color: var(--text-light);
}

.help-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.help-content li {
    margin-bottom: 6px;
}

/* Victory Modal */
.victory-content {
    text-align: center;
}

.victory-title {
    color: var(--player-color);
    font-size: 1.4em;
    margin-bottom: 20px;
    letter-spacing: 3px;
}

.victory-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 20px 0;
    color: var(--text-dim);
}

.victory-stat span:last-child {
    color: var(--text-light);
}

.victory-puzzle {
    font-size: 0.85em;
    color: var(--text-dim);
    margin: 15px 0 25px;
}

.victory-share-btn {
    margin: 10px 5px;
}

.victory-footer {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    font-size: 0.8em;
}

.victory-footer p {
    margin: 5px 0;
}

.victory-footer a {
    color: var(--text-dim);
    text-decoration: none;
}

/* Calendar Modal */
.calendar-info {
    margin: 15px 0;
    color: var(--text-dim);
}

.calendar-input {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin: 15px 0;
}

.calendar-input input[type="date"] {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-main);
    font-size: 0.9em;
    color: var(--text-light);
    background: var(--bg-dark);
}

/* Footer */
.footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.85em;
    color: var(--text-dim);
}

.footer p {
    margin: 5px 0;
}

.footer a {
    color: var(--text-light);
    text-decoration: none;
}

.footer a:hover {
    color: var(--player-color);
}

.footer .toms-link {
    margin-top: 10px;
    font-size: 0.9em;
}

.footer .toms-link a {
    color: var(--text-dim);
}

/* Responsive */
@media (max-width: 500px) {
    h1 {
        font-size: 1.4em;
    }

    .game-info {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .stats-bar {
        justify-content: space-around;
    }

    .actions {
        gap: 10px;
    }

    .modal-content {
        margin: 25% auto;
        padding: 20px;
    }
}
