:root {
    --blue-team: #007bff;
    --red-team: #ff4d4d;
    --gold-color: #ffd700;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.9);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: 'Inter', sans-serif;
    color: white;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #2c3e50;
}

.hidden { display: none !important; }

/* Selection Screen */
#selection-screen {
    position: absolute; inset: 0; background: rgba(15, 23, 42, 0.95);
    z-index: 1000; display: flex; flex-direction: column; 
    justify-content: center; align-items: center; padding: 20px;
}
#selection-screen h1 { font-size: 2.2rem; margin-bottom: 30px; font-weight: 900; }
.hero-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; width: 100%; max-width: 440px; }
.hero-card { background: var(--card-bg); border: 2px solid rgba(255,255,255,0.1); border-radius: 15px; padding: 20px 10px; text-align: center; cursor: pointer; transition: 0.2s; }
.hero-card:active { transform: scale(0.95); }
.hero-emoji { font-size: 3rem; margin-bottom: 8px; }
.hero-card h3 { color: var(--blue-team); margin-bottom: 5px; font-weight: 900; font-size: 1rem; }
.hero-card p { font-size: 0.75rem; opacity: 0.8; line-height: 1.2; }

/* HUD Top Bar */
#top-bar {
    position: absolute; top: 2vh; left: 50%; transform: translateX(-50%);
    display: flex; align-items: center; gap: 3vmin;
    background: rgba(0,0,0,0.85); padding: 1.2vmin 4vmin;
    border-radius: 6vmin; border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(5px); z-index: 200; pointer-events: none;
    white-space: nowrap;
}

.stat-box { font-weight: 900; font-size: 3.5vmin; min-width: 12vmin; text-align: center; }
.gold { color: var(--gold-color); border-left: 1px solid rgba(255,255,255,0.2); padding-left: 3vmin; }
#timer { font-size: 4vmin; font-family: monospace; font-weight: 900; border-left: 1px solid rgba(255,255,255,0.2); padding-left: 3vmin; }

/* Joystick */
#joystick-region { position: absolute; bottom: 0; left: 0; width: 50%; height: 60%; pointer-events: auto; }
#joystick-base { 
    position: fixed; /* Fixed to ignore parent offsets */
    width: 35vmin; height: 35vmin; min-width: 120px; min-height: 120px; 
    background: rgba(255,255,255,0.05); border: 2px solid rgba(255,255,255,0.2); 
    border-radius: 50%; display: none; backdrop-filter: blur(4px); 
    z-index: 500;
}
#joystick-handle { position: absolute; top: 50%; left: 50%; width: 15vmin; height: 15vmin; min-width: 50px; min-height: 50px; background: rgba(255,255,255,0.4); border-radius: 50%; transform: translate(-50%, -50%); }

/* Actions */
#action-region { 
    position: absolute; bottom: 12vh; right: 5vw; 
    width: 55vmin; height: 55vmin; 
    pointer-events: none;
}
.action-btn { 
    position: absolute; display: flex; justify-content: center; align-items: center; 
    border-radius: 50%; border: 3px solid #fff; color: white; cursor: pointer; 
    overflow: hidden; box-shadow: 0 5px 15px rgba(0,0,0,0.5); transition: transform 0.1s;
    background-size: cover; background-position: center; pointer-events: auto;
}
.action-btn:active { transform: scale(0.9); }

.attack { bottom: 0; right: 0; width: 26vmin; height: 26vmin; z-index: 10; min-width: 90px; min-height: 90px; }
.skill { bottom: 28vmin; right: 2vmin; width: 18vmin; height: 18vmin; z-index: 11; min-width: 65px; min-height: 65px; }
.recall { bottom: 6vmin; right: 30vmin; width: 12vmin; height: 12vmin; background: #34495e; font-size: 1.5rem; z-index: 12; min-width: 45px; min-height: 45px; }

.btn-label { display: none; }
.cooldown-overlay { position: absolute; bottom: 0; left: 0; width: 100%; height: 0%; background: rgba(0,0,0,0.7); }
.ammo-dots { position: absolute; bottom: 8%; display: flex; gap: 1.5vmin; }
.charge { width: 2vmin; height: 2vmin; min-width: 6px; min-height: 6px; border-radius: 50%; background: rgba(255,255,255,0.2); }
.charge.active { background: #00ff00; box-shadow: 0 0 1.5vmin #00ff00; }

/* Recall Overlay */
#recall-overlay {
    position: absolute; bottom: 30vh; left: 50%;
    transform: translateX(-50%); text-align: center;
    pointer-events: none; z-index: 500;
}
.recall-bar-bg {
    width: 50vw; height: 3vmin; min-width: 150px; min-height: 12px;
    background: rgba(0,0,0,0.5); border: 2px solid white;
    border-radius: 1vmin; overflow: hidden; margin-bottom: 5px;
}
#recall-bar-fill {
    width: 0%; height: 100%; background: #007bff;
    transition: width 0.1s linear;
}
#recall-overlay p { font-weight: 700; font-size: 4vmin; text-shadow: 0 2px 4px black; }

/* Death Overlay */
#death-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.75); display: flex;
    justify-content: center; align-items: center; z-index: 3000;
}
#death-content { text-align: center; color: #ff4d4d; }
#death-content h1 { font-size: 10vmin; font-weight: 900; margin-bottom: 2vh; text-shadow: 0 0 3vmin rgba(255,0,0,0.5); }
#death-content p { font-size: 5vmin; color: white; font-weight: 700; }

/* Message Overlay */
#msg-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 4000; display: flex; justify-content: center; align-items: center; }
#msg-box { background: #1e293b; padding: 40px; border-radius: 20px; text-align: center; border: 2px solid var(--blue-team); }
#msg-box h1 { font-size: 8vmin; margin-bottom: 20px; }
#msg-box button { background: var(--blue-team); border: none; padding: 15px 40px; border-radius: 10px; color: white; font-weight: 700; cursor: pointer; font-size: 4vmin; }

@media (max-width: 600px) {
    #selection-screen h1 { font-size: 1.8rem; }
    .hero-list { grid-template-columns: repeat(2, 1fr); }
}
