:root {
    --bg-dark: #121212;
    --neon-cyan: #00f7ff;
    --neon-pink: #ff00ff;
    --glow-cyan: 0 0 10px rgba(0, 247, 255, 0.5), 0 0 20px rgba(0, 247, 255, 0.3);
    --glow-pink: 0 0 10px rgba(255, 0, 255, 0.5), 0 0 20px rgba(255, 0, 255, 0.3);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
}

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

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

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: block;
    background: radial-gradient(circle, #1a1a1a 0%, #0d0d0d 100%);
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Common Overlay Styles */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    transition: opacity 0.4s ease, visibility 0.4s ease;
    pointer-events: auto;
}

.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.active {
    opacity: 1;
    visibility: visible;
}

/* Typography */
.game-title {
    font-size: 5rem;
    font-weight: 900;
    line-height: 0.9;
    text-align: center;
    margin-bottom: 0.5rem;
    letter-spacing: -2px;
}

.game-title span {
    color: var(--neon-cyan);
    text-shadow: var(--glow-cyan);
}

.subtitle {
    font-size: 1.2rem;
    letter-spacing: 0.5rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 3rem;
}

/* Buttons */
.primary-btn, .secondary-btn, .action-btn, .buy-btn {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
}

.primary-btn {
    padding: 1.2rem 3rem;
    background: white;
    color: black;
    border-radius: 100px;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.primary-btn:hover, .primary-btn:active {
    transform: scale(1.05);
    background: var(--neon-cyan);
    box-shadow: var(--glow-cyan);
}

.secondary-btn {
    padding: 0.8rem 2rem;
    background: transparent;
    color: white;
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    font-size: 0.9rem;
    backdrop-filter: blur(5px);
}

.secondary-btn:hover, .secondary-btn:active {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.stats-panel {
    width: 40%;
}

.stat-item {
    margin-bottom: 0.5rem;
}

.label {
    font-size: 0.6rem;
    font-weight: 700;
    opacity: 0.6;
    display: block;
    margin-bottom: 2px;
}

.bar-container {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.bar {
    height: 100%;
    width: 100%;
    transition: width 0.3s ease-out;
}

.health { background: var(--neon-cyan); box-shadow: var(--glow-cyan); }

.score-panel {
    text-align: right;
}

#currency-display {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--neon-cyan);
    text-shadow: var(--glow-cyan);
}

#wave-display {
    font-size: 0.7rem;
    font-weight: 700;
    opacity: 0.6;
}

/* Shop Menu */
#shop-menu h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--neon-pink);
    text-shadow: var(--glow-pink);
}

.shop-items {
    width: 90%;
    max-width: 400px;
    margin-bottom: 2rem;
}

.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
}

.item-info {
    display: flex;
    flex-direction: column;
}

.item-name {
    font-weight: 700;
    font-size: 1.1rem;
}

.item-level {
    font-size: 0.7rem;
    opacity: 0.5;
}

.buy-btn {
    background: var(--neon-cyan);
    color: black;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 900;
}

.buy-btn:active {
    transform: scale(0.9);
}

.buy-btn:disabled {
    background: #333;
    color: #666;
    opacity: 0.5;
    pointer-events: none;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 180px;
    padding: 0 2rem 2rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
}

#joystick-container {
    width: 160px;
    height: 160px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    border: 1px solid var(--glass-border);
}

#joystick-base {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    position: relative;
    backdrop-filter: blur(5px);
}

#joystick-stick {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px rgba(255,255,255,0.5);
}

#action-buttons {
    display: flex;
    gap: 1.5rem;
    pointer-events: auto;
}

.action-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 2.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(5px);
    color: white;
}

.action-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.2);
}

.action-btn.special {
    background: var(--neon-pink);
    border: none;
    box-shadow: var(--glow-pink);
}

/* Story Victory Overlay */
.victory-title {
    font-size: 5rem;
    color: var(--neon-cyan);
    text-shadow: var(--glow-cyan);
    margin-bottom: 0.5rem;
}

.matcha-icon {
    font-size: 6rem;
    margin: 1.5rem 0;
    filter: drop-shadow(0 0 20px rgba(0, 255, 0, 0.5));
}

.end-credits {
    text-align: center;
    animation: fadeIn 2s ease-out;
}

.ending-msg {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.ending-sub {
    font-size: 1.1rem;
    opacity: 0.7;
    margin-bottom: 2rem;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Desktop Responsiveness */
@media (min-width: 1024px) {
    #mobile-controls {
        display: none !important;
    }
}

@media (max-width: 600px) {
    .game-title { font-size: 3.5rem; }
    .death-title { font-size: 3rem; }
}

/* Animations */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.animate-shake {
    animation: shake 0.5s;
    animation-iteration-count: infinite;
}
