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

body {
    font-family: 'Press Start 2P', cursive;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #fff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    max-width: 1000px;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    border: 4px solid #00ff00;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.5);
}

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

h1 {
    font-size: 1.5rem;
    color: #00ff00;
    text-shadow: 2px 2px #ff00ff;
    margin-bottom: 20px;
    line-height: 1.5;
}

h2 {
    font-size: 1.2rem;
    color: #ffff00;
    margin-bottom: 15px;
}

.progress-bar {
    background: #1a1a1a;
    border: 2px solid #00ff00;
    height: 40px;
    position: relative;
    margin-top: 20px;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7rem;
    z-index: 2;
    color: #fff;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #00ffff);
    width: 0%;
    transition: width 0.5s ease;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

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

.instructions {
    font-size: 0.7rem;
    color: #00ffff;
    margin: 10px 0;
    line-height: 1.5;
}

.game-stats {
    font-size: 0.8rem;
    color: #ffff00;
    margin-bottom: 15px;
    text-align: center;
}

/* Maze specific */
.maze-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.legend {
    display: flex;
    gap: 30px;
    font-size: 0.7rem;
    color: #00ffff;
}

/* Canvas styling */
canvas {
    border: 4px solid #00ff00;
    background: #000;
    display: block;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}

#mazeCanvas {
    cursor: crosshair;
}

/* Memory Game */
.memory-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
}

.memory-card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid #00ff00;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.memory-card:hover {
    transform: scale(1.05);
}

.memory-card.flipped {
    background: #000;
}

.memory-card.matched {
    background: #00ff00;
    border-color: #ffff00;
    animation: pulse 0.5s;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Quiz */
.quiz-progress {
    font-size: 0.7rem;
    color: #00ffff;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-around;
}

.quiz-question {
    font-size: 0.8rem;
    color: #ffff00;
    margin: 30px 0;
    line-height: 1.8;
    min-height: 80px;
}

.quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
}

.quiz-answer-btn {
    background: #1a1a1a;
    border: 3px solid #00ff00;
    color: white;
    padding: 15px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s;
    line-height: 1.5;
}

.quiz-answer-btn:hover {
    background: #333;
    border-color: #ffff00;
}

.quiz-answer-btn.correct {
    background: #00ff00;
    color: #000;
    animation: pulse 0.5s;
}

.quiz-answer-btn.wrong {
    background: #ff0000;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Buttons */
.start-btn {
    background: #00ff00;
    border: 3px solid #000;
    color: #000;
    padding: 15px 40px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.start-btn:hover {
    background: #00cc00;
    transform: scale(1.1);
}

/* Victory screen */
.victory-screen {
    text-align: center;
    padding: 40px 20px;
}

.victory-content {
    background: rgba(0, 255, 0, 0.1);
    border: 3px solid #00ff00;
    border-radius: 10px;
    padding: 40px;
}

.victory-message {
    font-size: 1rem;
    color: #00ff00;
    margin-top: 30px;
    animation: blink 1s infinite;
    line-height: 1.8;
}

@keyframes blink {
    0%, 50%, 100% { opacity: 1; }
    25%, 75% { opacity: 0.5; }
}

.mini-game-screen {
    text-align: center;
}

/* Reaction Time Game */
.reaction-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    padding: 40px;
    min-height: 400px;
}

.reaction-status {
    font-size: 1.2rem;
    color: #ffff00;
    text-align: center;
}

.reaction-instruction {
    font-size: 0.8rem;
    color: #00ffff;
    text-align: center;
    line-height: 1.8;
    min-height: 60px;
}

.reaction-target {
    width: 200px;
    height: 200px;
    background: #00ff00;
    border: 4px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.reaction-target:hover {
    transform: scale(1.1);
}

.reaction-target:active {
    transform: scale(0.95);
}

footer {
    text-align: center;
    margin-top: 30px;
    font-size: 0.6rem;
    color: #00ffff;
    line-height: 1.5;
}

/* Virtual D-Pad Controls */
.virtual-dpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    width: 200px;
    margin: 20px auto;
    display: none; /* Hidden by default, shown on mobile */
}

.dpad-btn {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #00ff00 0%, #00cc00 100%);
    border: 3px solid #fff;
    color: #000;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    box-shadow: 0 4px 0 #006600;
}

.dpad-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #006600;
    background: linear-gradient(135deg, #00cc00 0%, #009900 100%);
}

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

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

.dpad-center {
    grid-column: 2;
    grid-row: 2;
    background: transparent;
    border: none;
    box-shadow: none;
    cursor: default;
}

.dpad-center:active {
    transform: none;
}

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

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

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 1rem;
    }

    h2 {
        font-size: 0.9rem;
    }

    #mazeCanvas {
        width: 100%;
        height: auto;
    }

    canvas {
        width: 100%;
        height: auto;
    }

    .memory-board {
        grid-template-columns: repeat(3, 1fr);
    }

    .legend {
        flex-direction: column;
        gap: 10px;
    }

    /* Show virtual D-pad on mobile */
    .virtual-dpad {
        display: grid !important;
    }

    .instructions {
        font-size: 0.6rem;
    }

    .dpad-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    /* Device is touch-based */
    .virtual-dpad {
        display: grid !important;
    }
}
