:root {
    --bg-color: #0b0b1a;
    --primary: #00ffff;
    --primary-glow: rgba(0, 255, 255, 0.4);
    --secondary: #ff00ff;
    --boss-color: #ff3366;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --header-h: 56px;
    --strip-h: 30px;
    --bottom-h: 90px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #000;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ==================== 0. GAME ROOT (Reliable Full Screen) ==================== */
.game-root {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0a0a0f;
    padding-top: env(safe-area-inset-top);
}

/* ==================== 1. HUD ROW ==================== */
.header {
    height: var(--header-h);
    width: 100%;
    background: rgba(0, 0, 0, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: 0 16px;
    z-index: 1000;
    flex-shrink: 0;
}

.nav-left { display: flex; align-items: center; min-width: 100px; }
.home-btn {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}
.home-btn:hover { color: #fff; border-color: var(--primary); }

.header-center { display: flex; justify-content: center; align-items: center; }
.score-pills { display: flex; gap: 8px; }

.score-pill {
    background: rgba(0, 255, 255, 0.08);
    border: 1px solid rgba(0, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 72px;
}

.pill-label {
    font-size: 7px;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.pill-value {
    font-size: 0.9rem;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}
.score-pill:first-child .pill-value { color: var(--primary); }
.score-pill:last-child .pill-value { color: var(--secondary); }

.header-right { display: flex; gap: 8px; justify-content: flex-end; min-width: 100px; }

.icon-btn {
    width: 44px; /* Minimum iOS touch target */
    height: 44px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}
.icon-btn:hover { border-color: var(--primary); background: rgba(255, 255, 255, 0.1); }

/* ==================== 2. HEALTH STRIPS ==================== */
.health-strip {
    height: var(--strip-h);
    background: rgba(5, 5, 15, 0.9);
    border-bottom: 1px solid rgba(0, 229, 200, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 16px;
    z-index: 900;
    flex-shrink: 0;
}

.health-strip.hidden { display: none !important; }

.strip-label {
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-secondary);
    min-width: 45px;
}
.boss-text { color: var(--boss-color); min-width: 55px; }

.strip-bar-container {
    width: 120px;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.strip-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00e5c8, #00b4a0);
    transition: width 0.3s ease;
}

.boss-fill {
    background: linear-gradient(90deg, #ff3366, #ff0000);
}

.strip-val {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
}

/* ==================== 3. GAME AREA ==================== */
#gameWrapper {
    flex: 1;
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #000;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    background: linear-gradient(180deg, #120e2b 0%, #000 100%);
    padding-bottom: var(--bottom-h);
}

.combo-pill {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: var(--secondary);
    text-shadow: 0 0 8px var(--secondary);
    z-index: 800;
    pointer-events: none;
}
.combo-pill.hidden { display: none; }

/* ==================== 4. BOTTOM CONTROLS (Fixed Bottom Bar) ==================== */
.bottom-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-h);
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 24px;
    padding-right: 24px;
    z-index: 1200;
    pointer-events: none;
}
.bottom-controls.hidden { display: none !important; }

.dpad-left { display: flex; gap: 12px; pointer-events: auto; }
.dpad-right { pointer-events: auto; }

.m-btn {
    width: 54px;
    height: 54px;
    min-width: 54px;
    min-height: 54px;
    border-radius: 50%;
    background: rgba(0, 229, 200, 0.1);
    border: 2px solid rgba(0, 229, 200, 0.35);
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.1s ease;
}
.m-btn:active { background: rgba(0, 229, 200, 0.3); transform: scale(0.93); }

.attack-btn {
    width: 66px;
    height: 66px;
    min-width: 66px;
    min-height: 66px;
    background: rgba(255, 0, 102, 0.15);
    border: 2px solid rgba(255, 0, 102, 0.5);
    color: #ff3366;
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    box-shadow: 0 0 16px rgba(255, 0, 102, 0.2);
}
.attack-btn:active { background: rgba(255, 0, 102, 0.4); transform: scale(0.9); }

/* ==================== MENUS & OVERLAYS ==================== */
.menu-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 5, 10, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    padding: 24px;
    padding-bottom: env(safe-area-inset-bottom);
}
.menu-overlay.hidden { display: none !important; }

.logo-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.2rem;
    color: var(--primary);
    text-align: center;
    line-height: 1.2;
    margin-bottom: 20px;
    text-shadow: 0 0 20px var(--primary-glow);
}

.btn {
    width: 220px;
    padding: 14px;
    margin: 8px;
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
    text-transform: uppercase;
}

.primary-btn {
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 20px var(--primary-glow);
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--secondary);
    color: var(--secondary);
}

.controls-hint {
    font-size: 10px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.6;
}

/* ==================== MOBILE ADJUSTMENTS ==================== */
@media (max-width: 600px) {
    .header { padding: 0 12px; }
    .nav-left, .header-right { min-width: 70px; }
    .home-btn { padding: 6px 10px; font-size: 0; }
    .home-btn::after { content: '← Hub'; font-size: 0.75rem; }
    
    .score-pill { padding: 4px 10px; min-width: 60px; }
    .pill-label { font-size: 6px; }
    .pill-value { font-size: 0.8rem; }
    
    .logo-title { font-size: 1.8rem; }
}

/* Shake Effect */
.shake { animation: shake 0.2s linear infinite; }
@keyframes shake {
    0%, 100% { transform: translate(0,0); }
    25% { transform: translate(-4px, 4px); }
    75% { transform: translate(4px, -4px); }
}
