:root {
    --bg-color: #0a0514;
    --primary: #bc13fe;
    --secondary: #00f3ff;
    --accent: #ff007c;
    --text-main: #ffffff;
    --text-dim: #a9a2c2;
    --glass-bg: rgba(20, 10, 40, 0.6);
    --glass-border: rgba(188, 19, 254, 0.3);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

* {
    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-color);
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    touch-action: none; /* Prevent default touch actions like pull-to-refresh */
}

/* Game Canvas */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
}

/* UI Layer */
#uiLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through to canvas when not on UI */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    pointer-events: auto;
}

.glass-heavy {
    background: rgba(15, 8, 30, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(0, 243, 255, 0.4);
    box-shadow: 0 0 40px rgba(0, 243, 255, 0.1), inset 0 0 20px rgba(188, 19, 254, 0.2);
}

.panel {
    border-radius: 16px;
    padding: 10px 15px;
}

/* Typography & Glow */
.neon-text {
    color: #fff;
    text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 20px var(--secondary), 0 0 40px var(--secondary);
}

.title-glow {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 5px;
    text-align: center;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(0, 243, 255, 0.5);
}

/* HUD (Top Left) */
#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 200px;
}

.stat-box {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.stat-icon {
    font-size: 1.5rem;
    width: 30px;
    text-align: center;
    filter: drop-shadow(0 0 8px rgba(255,255,255,0.5));
}

.stat-value {
    font-weight: 600;
    font-size: 1.1rem;
    width: 80px;
}

.stat-bar-bg {
    flex-grow: 1;
    height: 8px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

.stat-bar-fill {
    height: 100%;
    width: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.energy-fill {
    background: linear-gradient(90deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    box-shadow: 0 0 10px #ff9a9e;
}

.xp-fill {
    background: linear-gradient(90deg, #00c6ff 0%, #0072ff 100%);
    box-shadow: 0 0 10px #00c6ff;
    width: 0%;
}

/* Time HUD (Top Right) */
#timeHud {
    position: absolute;
    top: 20px;
    right: 20px;
    text-align: center;
    min-width: 120px;
}

#dayDisplay {
    font-size: 0.9rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#timeDisplay {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--secondary);
    text-shadow: 0 0 10px rgba(0,243,255,0.5);
}

/* Right Side Menu Buttons */
#menuButtons {
    position: absolute;
    top: 100px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: auto;
}

.circle-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.circle-btn:hover {
    transform: scale(1.1);
    border-color: var(--secondary);
    box-shadow: 0 0 15px rgba(0,243,255,0.4);
}

.circle-btn:active {
    transform: scale(0.95);
}

/* Toolbar (Bottom Center) */
#toolbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    padding: 10px;
    border-radius: 20px;
}

.tool-slot {
    width: 70px;
    height: 80px;
    border-radius: 12px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.tool-slot:hover:not(.locked) {
    background: rgba(255,255,255,0.1);
    transform: translateY(-5px);
}

.tool-slot.active {
    background: rgba(188, 19, 254, 0.3);
    border-color: var(--secondary);
    box-shadow: 0 0 15px rgba(0,243,255,0.4), inset 0 0 10px rgba(188, 19, 254, 0.5);
    transform: translateY(-10px);
}

.tool-icon {
    font-size: 1.8rem;
    margin-bottom: 5px;
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.3));
}

.tool-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
}

.tool-cost {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--bg-color);
    border: 1px solid var(--secondary);
    border-radius: 10px;
    font-size: 0.6rem;
    padding: 2px 5px;
    color: var(--secondary);
    font-weight: 800;
}

.tool-slot.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(100%);
}

/* Modals */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

.modal-content {
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    max-width: 90%;
    width: 500px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-content.wide-panel {
    width: 700px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--accent);
}

/* Intro Screen specific */
.intro-thumbnail {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 16px;
    margin-bottom: 20px;
    border: 2px solid var(--primary);
    box-shadow: 0 0 20px rgba(188, 19, 254, 0.4);
}

.subtitle {
    color: var(--text-dim);
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.tutorial-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 30px;
}

.tut-item {
    background: rgba(0,0,0,0.3);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.tut-icon {
    font-size: 2rem;
    background: rgba(255,255,255,0.1);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    border: none;
    padding: 15px 40px;
    border-radius: 30px;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 2px;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3), 0 0 15px rgba(0,243,255,0.4);
    transition: all 0.2s;
    text-transform: uppercase;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 25px rgba(0,0,0,0.4), 0 0 25px rgba(0,243,255,0.6);
}

.btn-primary:active {
    transform: translateY(1px);
}

/* Upgrades */
.upgrade-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

.upgrade-list::-webkit-scrollbar {
    width: 8px;
}
.upgrade-list::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
}
.upgrade-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

.upgrade-item {
    display: flex;
    align-items: center;
    padding: 15px;
    gap: 15px;
    text-align: left;
}

.upg-icon {
    font-size: 2.5rem;
    background: rgba(0,0,0,0.4);
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--glass-border);
}

.upg-info {
    flex-grow: 1;
}

.upg-info h3 {
    color: var(--secondary);
    margin-bottom: 5px;
}

.upg-info p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.btn-buy {
    background: rgba(188, 19, 254, 0.2);
    border: 1px solid var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.btn-buy:hover {
    background: var(--primary);
    box-shadow: 0 0 15px rgba(188, 19, 254, 0.6);
}

.btn-buy.purchased {
    background: rgba(0,255,0,0.2);
    border-color: #00ff00;
    color: #00ff00;
    cursor: default;
    box-shadow: none;
}

/* Notifications */
.notification {
    position: absolute;
    pointer-events: none;
    color: white;
    font-weight: 800;
    font-size: 1.2rem;
    text-shadow: 0 0 5px black, 0 0 10px var(--secondary);
    animation: floatUp 1.5s forwards ease-out;
    z-index: 50;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-50px) scale(1.2); opacity: 0; }
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .title-glow { font-size: 2rem; }
    .subtitle { font-size: 1rem; }
    .tutorial-grid { gap: 10px; }
    .tut-item { padding: 10px; }
    
    #toolbar {
        width: 95%;
        overflow-x: auto;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
    }
    
    .tool-slot {
        min-width: 65px;
        height: 75px;
    }

    #hud { top: 10px; left: 10px; min-width: 150px; transform: scale(0.9); transform-origin: top left; }
    #timeHud { top: 10px; right: 10px; transform: scale(0.9); transform-origin: top right; }
    #menuButtons { top: 80px; right: 10px; transform: scale(0.9); transform-origin: top right; }
    
    .modal-content { padding: 20px; }
    .modal-content.wide-panel { width: 95%; }
}
