:root {
    --primary-color: #4ADE80;
    /* Green matching Tailwind primary */
    --secondary-color: #bc13fe;
    /* Neon Purple */
    --bg-dark: #050510;
    --glass-bg: rgba(10, 10, 25, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --font-main: 'Noto Sans TC', sans-serif;
    --font-tech: 'ZCOOL KuaiLe', cursive;

    /* New Liquid Theme Vars */
    --liquid-bg: rgba(255, 255, 255, 0.45);
    --liquid-border: rgba(255, 255, 255, 0.8);
    --liquid-shadow: inset 0 8px 15px rgba(255, 255, 255, 0.9), 0 10px 40px rgba(0, 0, 0, 0.04);
    --iridescent: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.4) 45%, rgba(255, 255, 255, 0.8) 50%, rgba(255, 255, 255, 0.4) 55%, transparent 70%);
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100%;
    /* Changed from 100vh for iOS safari fix */
    height: -webkit-fill-available;
    overflow: hidden !important;
    background-color: var(--bg-dark);
    font-family: var(--font-main);
    color: var(--text-main);
    touch-action: none;
    -webkit-font-smoothing: antialiased;

    /* Safe Area Support */
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
}

#game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #1a1a2e 0%, #000000 100%);
}

#game-container {
    width: 100%;
    height: 100%;
    touch-action: none;
}

#joystick-zone {
    touch-action: none;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.hidden {
    display: none !important;
}

/* Material Symbols Utilities */
.fill-1 {
    font-variation-settings: 'FILL' 1, 'wght' 700, 'GRAD' 0, 'opsz' 48;
}

.weight-bold {
    font-weight: bold;
}

/* New HUD Styles */
.liquid-glass {
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.2);
}

.liquid-glass-hud {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.2);
}

.hp-liquid {
    background: linear-gradient(90deg, #ff4d4d, #f9cb28);
    position: relative;
    overflow: hidden;
    transition: width 0.2s ease-out;
}

.hp-liquid::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.25) 50%,
            rgba(255, 255, 255, 0) 100%);
    animation: flow 3s infinite linear;
}

@keyframes flow {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(100%);
    }
}

/* Base HUD container - allows Tailwind to control layout */
#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 100;
}

/* Top Bar: Level & Timer & Pause */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    width: 100%;
}







/* Bars */
#xp-bar-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 6px;
    background: #111;
    z-index: 1001;
}



#health-bar-container {
    width: 300px;
    height: 12px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 5px;
    position: relative;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

/* HUD bar overrides removed to let Tailwind handle it */

/* Overlays (Pause, Level Up, Game Over) */
#pause-screen,
#game-over-screen {
    z-index: 1000;
}

/* Use specific ID selectors for heads in overlays to override reset */
#pause-screen h1,
#game-over-screen h1 {
    margin: 0;
    font-family: var(--font-tech);
    text-transform: uppercase;
    letter-spacing: 2px;
}

#pause-screen h1,
#game-over-screen h1 {
    font-size: 2.5em;
    background: linear-gradient(45deg, #fff, var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(0, 243, 255, 0.3);
}



/* Base buttons for old overlays */
#pause-screen button,
#game-over-screen button {
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-family: var(--font-main);
    font-weight: 700;
    padding: 12px 30px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#pause-screen button:hover,
#game-over-screen button:hover {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 20px var(--primary-color);
}

/* Upgrade Cards */
#upgrade-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

.upgrade-card {
    flex: 1;
    min-width: 250px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.upgrade-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.upgrade-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
}

.upgrade-card:hover::before {
    transform: translateX(100%);
}

.upgrade-title {
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1.2em;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.upgrade-desc {
    font-size: 0.9em;
    color: #aaa;
    line-height: 1.5;
}

/* Slots (Pause Menu) */
#equipment-slots {
    width: 100%;
    padding: 5px 0;
}

.slot-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.slot {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@media (min-width: 768px) {
    .slot {
        width: 60px;
        height: 60px;
        font-size: 28px;
        border-width: 2px;
    }
}

.slot.active {
    border-color: #FFD700;
    background: rgba(255, 215, 0, 0.05);
    cursor: pointer;
}

.slot.active:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.slot.breakthrough {
    border-color: #FF4500;
    box-shadow: 0 0 15px rgba(255, 69, 0, 0.4);
    animation: glow-pulse-gold 2s infinite;
}

@keyframes glow-pulse-gold {

    0%,
    100% {
        box-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    }
}

.slot-lvl {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: #FFD700;
    border: 1px solid #000;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 4px;
    font-family: var(--font-tech);
    color: #000;
    font-weight: bold;
}



#pause-slot-description {
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
    text-align: left;
    margin-top: 15px;
    margin-top: 5px;
    width: 100%;
    display: flex;
    gap: 15px;
}

#pause-slot-name {
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 5px;
}

@keyframes glow-pulse {

    0%,
    100% {
        box-shadow: 0 0 5px var(--secondary-color);
    }

    50% {
        box-shadow: 0 0 20px var(--secondary-color);
    }
}

/* === LIQUID GLASS THEME CSS (Custom Animations only, others via Tailwind) === */



.blob {
    position: absolute;
    background: linear-gradient(135deg, rgba(255, 128, 171, 0.2) 0%, rgba(128, 203, 196, 0.2) 100%);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    pointer-events: none;
}

.glossy-button {
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background-clip: padding-box;
}

.glossy-button::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 5%;
    width: 90%;
    height: 45%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-radius: 20px;
    pointer-events: none;
    z-index: 1;
}

.glossy-button .sweep-light {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    pointer-events: none;
    z-index: 2;
}

.glossy-button:hover .sweep-light,
.glossy-button:focus .sweep-light {
    animation: sweep 1.2s ease-in-out infinite;
}

.glossy-button:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.08);
}

.bubble-title {
    text-shadow: 0 4px 15px rgba(255, 128, 171, 0.35);
    filter: drop-shadow(0 2px 4px rgba(255, 255, 255, 0.8));
}

.refraction-edge {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 0 25px rgba(255, 255, 255, 0.6), inset 8px 8px 12px rgba(255, 255, 255, 0.4);
    opacity: 0.9;
    z-index: 1;
}

.refraction-highlight {
    position: absolute;
    width: 40%;
    height: 40%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
    filter: blur(10px);
    opacity: 0.5;
    pointer-events: none;
    animation: float 6s ease-in-out infinite alternate;
}

/* === Balanced Scaling for Short Screens (Mobile Landscape Fix) === */
@media (max-height: 500px) and (orientation: landscape) {
    .liquid-glass {
        padding: 1.5rem 2.5rem !important;
        border-radius: 2.5rem !important;
    }

    .bubble-title {
        font-size: 2.35rem !important;
        margin-bottom: 0.5rem !important;
        line-height: 1.1 !important;
    }

    .bubble-title span {
        font-size: 1.9rem !important;
    }

    #start-btn-html {
        padding-top: 0.9rem !important;
        padding-bottom: 0.9rem !important;
        max-width: 300px !important;
        border-radius: 1.75rem !important;
    }

    #start-btn-html span {
        font-size: 1.35rem !important;
    }

    .menu-description {
        display: block !important;
        font-size: 13px !important;
        line-height: 1.4 !important;
        margin-top: 0.25rem !important;
        margin-bottom: 0.75rem !important;
        opacity: 0.9;
        max-width: 450px;
    }

    .menu-card {
        padding: 1.75rem !important;
        max-height: 98vh;
        width: auto !important;
        min-width: 320px;
    }

    /* Shrink Fullscreen Button on Short Screens */
    #fullscreen-btn-html {
        padding: 0.35rem 0.75rem !important;
        font-size: 11px !important;
        gap: 0.25rem !important;
    }

    #fullscreen-btn-html span.material-symbols-outlined {
        font-size: 16px !important;
    }

    /* Reduce container padding on short screens */
    .fullscreen-container {
        padding-top: 0.75rem !important;
        padding-right: 1rem !important;
    }

    /* Global HUD Scaling for Mobile Landscape (Ultra-Compact) */
    #hud>div.absolute {
        --scale-factor: clamp(0.55, calc(var(--vh, 1vh) * 100 / 500), 0.7);
        transform: scale(var(--scale-factor));
        transform-origin: top left;
        width: calc(100% / var(--scale-factor)) !important;
        left: 0 !important;
        padding-top: max(0.25rem, env(safe-area-inset-top)) !important;
        padding-left: max(0.5rem, env(safe-area-inset-left)) !important;
    }

    .hud-right-container {
        transform-origin: top right;
        padding-right: max(1.2rem, env(safe-area-inset-right)) !important;
    }
}

/* The modern Liquid Glass system handles mobile responsiveness via Tailwind classes in index.html. Legacy overrides removed for consistency. */

/* === Ratio-Specific Layout Adjustments === */

/* Square Ratios (iPads, Foldables) - Prevent HUD clash */
html[data-screen-ratio="square"] .menu-card {
    max-width: 85vw !important;
}

html[data-screen-ratio="square"] #hud div.flex-1.flex.justify-start {
    max-width: 120px;
    /* Narrower status on square screens */
}

/* Wide/Ultra-Wide Ratios - Push elements to edges */
html[data-screen-ratio="ultra-wide"] #hud>div.absolute {
    padding-left: max(2rem, env(safe-area-inset-left)) !important;
}

html[data-screen-ratio="ultra-wide"] .hud-right-container {
    padding-right: max(2rem, env(safe-area-inset-right)) !important;
}

/* Landscape menu centering fix for different ratios */
@media (orientation: landscape) {

    html[data-screen-ratio="wide"] .menu-card,
    html[data-screen-ratio="ultra-wide"] .menu-card {
        max-width: 550px;
    }

    html[data-screen-ratio="square"] .menu-card {
        max-width: 60vw;
    }
}

/* Standard Ratios (16:9) - Balanced defaults */
html[data-screen-ratio="standard"] .menu-card {
    max-width: 400px;
}

/* Wide Ratios (19.5:9, 20:9) - Spread HUD elements */
html[data-screen-ratio="wide"] #hud>div.absolute {
    padding-left: max(1.5rem, env(safe-area-inset-left)) !important;
}

html[data-screen-ratio="wide"] .hud-right-container {
    padding-right: max(1.5rem, env(safe-area-inset-right)) !important;
}

/* Square Ratios - Compact timer and buttons */
html[data-screen-ratio="square"] #hud div.flex-none {
    transform: scale(0.85);
}

html[data-screen-ratio="square"] .hud-right-container button {
    width: 1.75rem !important;
    height: 1.75rem !important;
}

/* Portrait mode overrides for square devices */
@media (orientation: portrait) {
    html[data-screen-ratio="square"] .menu-card {
        max-width: 90vw !important;
        padding: 2rem !important;
    }

    html[data-screen-ratio="square"] #hud div.flex-1.flex.justify-start {
        max-width: 200px !important;
    }
}