:root {
    --bg: #05070a;
    --primary: #00f2ff;
    --danger: #00ff88;
    --mana: #bc13fe;
    --success: #00ff88;
    --potion: #ffcc00;
    --shield: #00ff88;
    --void: #0066ff;
    --locked: #2a2a2a;
    --gold: #ffd700;
    --bacteria: #39ff14;
}
* {
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}
body {
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
}
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #000;
}
canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
#ui {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: none;
    z-index: 5;
    display: none;
}
.stat {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.7);
    padding: 6px 16px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1);
}
#mana-count { color: var(--mana); }
#level-display { color: var(--primary); }
#potion-active { color: var(--potion); display: none; }
#shield-active { color: var(--shield); display: none; }

.screen {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    text-align: center;
    backdrop-filter: blur(10px);
    padding: 20px;
}

h1 { font-size: clamp(32px, 10vw, 64px); margin: 0 0 10px 0; color: var(--primary); letter-spacing: 4px; text-transform: uppercase; text-shadow: 0 0 20px var(--primary); }
.menu-btn {
    background: rgba(255,255,255,0.05);
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 14px 30px;
    font-size: 18px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s;
    text-transform: uppercase;
    font-weight: bold;
    border-radius: 8px;
    width: 260px;
}
.menu-btn:hover {
    background: var(--primary);
    color: black;
    box-shadow: 0 0 30px var(--primary);
}

.footer-tribute {
    position: absolute;
    bottom: 20px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
    text-align: center;
    line-height: 1.6;
}
.footer-tribute strong {
    color: var(--primary);
    font-weight: normal;
}

#level-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-top: 20px;
    max-width: 95vw;
}
.grid-btn {
    width: 50px;
    height: 50px;
    background: #111;
    border: 1px solid #333;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-radius: 8px;
    font-size: 16px;
}
.grid-btn.locked {
    background: var(--locked);
    color: #444;
    opacity: 0.5;
    cursor: not-allowed;
}

.msg { font-size: 24px; margin: 15px 0; font-weight: bold; }
.death { color: #ff3366; }
.win { color: var(--success); }

#joystick-container {
    position: absolute;
    bottom: 40px;
    left: 40px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 5;
    touch-action: none;
}
#joystick-knob {
    width: 50px;
    height: 50px;
    background: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 15px var(--primary);
    pointer-events: none;
    transition: transform 0.05s linear;
}
@media (pointer: coarse) {
    #joystick-container { display: flex; }
}