:root {
    /* --- NEON PALETTE --- */
    --bg-dark: #130f26;      
    --bg-panel: #241b42;     
    --primary: #d946ef;      /* Neon Pink */
    --secondary: #06b6d4;    /* Neon Cyan */
    --accent: #facc15;       /* Bright Gold */
    --danger: #ff3366;       /* Neon Red */
    --text-main: #e2e8f0;    /* Off-white text */
    --text-dim: #94a3b8;     
    
    --shadow-glow: 0 0 15px rgba(217, 70, 239, 0.4);
}

html {
    background-color: #130f26; /* Matches --bg-dark variable */
    height: 100%; /* Ensures the page fills the window */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'VT323', monospace; 
    background-color: transparent;
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
    font-size: 1.2rem; 
	position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;     /* Anchors to right */
    bottom: 0;    /* Anchors to bottom instead of using explicit height */
    z-index: -1;
    
    background: url('https://raw.githubusercontent.com/yunadata/yunadata.github.io/refs/heads/main/crystal-guard-bg.webp') no-repeat center center;
    background-size: cover;
    
    transform: translateZ(0);
}

/* --- Navigation --- */
nav {
    padding: 1rem 2rem;
    background: rgba(19, 15, 38, 0.5);
    border-bottom: 2px solid var(--primary);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 0 20px rgba(217, 70, 239, 0.2);
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo { 
    font-family: 'Press Start 2P', cursive;
    font-size: 1rem; 
    color: var(--secondary);
    text-shadow: 2px 2px 0px #000;
    cursor: pointer; 
}
.blink { animation: blinker 1s linear infinite; }
@keyframes blinker { 50% { opacity: 0; } }

.btn-small {
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    color: var(--bg-dark);
    padding: 5px 15px;
    background: var(--secondary);
    text-decoration: none;
    text-transform: uppercase;
    border: 2px solid #fff;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.5);
    transition: 0.1s;
}
.btn-small:hover { 
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0px rgba(0,0,0,0.5);
}

/* --- Game Layout --- */
main {
    display: flex;
    justify-content: center;
    padding: 2rem;
    min-height: calc(100vh - 100px);
}

#game-wrapper {
    display: flex;
    gap: 0; 
    border: 4px solid #45326e;
    background: var(--bg-panel);
    border-radius: 4px;
    flex-wrap: wrap; 
    justify-content: center;
    align-items: stretch; /* Prevents black bar on side panel expand */
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    max-width: 1150px;
}

/* --- Canvas Area --- */
.canvas-container {
    position: relative;
    border-right: 4px solid #45326e;
    
    /* FIX FOR LAPTOP BLACK BARS: Match background to the panel purple */
    /* This blends the extra space with the UI frame */
    background: var(--bg-panel); 
    
    display: flex; 
    justify-content: center;
    align-items: center;
}

canvas {
    display: block;
    max-width: 100%;
    height: auto;
    background-color: #000; /* Ensure the game area itself stays black */
    image-rendering: pixelated; 
}

/* --- UI Sidebar --- */
#ui-sidebar {
    width: 300px;
    background: var(--bg-panel);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    color: var(--text-main);
}

#ui-sidebar h2 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    text-align: center;
    color: var(--accent);
    margin-bottom: 10px;
    text-shadow: 2px 2px 0 #000;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-box {
    background: rgba(0,0,0,0.3);
    padding: 10px;
    border: 1px solid #45326e;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 1.1rem;
}
.neon-text { color: var(--secondary); text-shadow: 0 0 5px var(--secondary); }
.gold-text { color: var(--accent); }
.life-text { color: var(--danger); }

.section-title {
    font-size: 1.2rem;
    text-align: center;
    margin: 10px 0 5px;
    color: var(--text-dim);
    letter-spacing: 2px;
}

.tower-select {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tower-btn {
    background: #1a152e;
    border: 2px solid #45326e;
    padding: 10px;
    cursor: pointer;
    text-align: center;
    transition: 0.2s;
    position: relative;
    overflow: hidden;
    /* Added this line to force the button to use the body's VT323 font */
    font-family: inherit; 
}

.tower-btn:hover { 
    border-color: var(--text-main); 
    background: #2a2245;
}
.tower-btn.active { 
    border-color: var(--primary); 
    box-shadow: inset 0 0 15px rgba(217, 70, 239, 0.3);
}

.t-name { font-weight: bold; font-size: 1.1rem; color: #fff; }
.t-cost { color: var(--accent); font-size: 1rem; }
.t-info { font-size: 0.9rem; color: var(--text-dim); }

#upgrade-panel {
    margin-top: auto;
    border-top: 2px dashed #45326e;
    padding-top: 15px;
    visibility: hidden;
}

/* --- Game Buttons --- */
.btn-game {
    width: 100%;
    padding: 15px;
    border: none;
    cursor: pointer;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    margin-top: 10px;
    text-transform: uppercase;
    color: white;
    border: 3px solid rgba(0,0,0,0.2);
    box-shadow: inset 0 -4px 0 rgba(0,0,0,0.3);
    transition: 0.1s;
}

.btn-game:active {
    transform: translateY(2px);
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.3);
}

.btn-game.start {
    background: var(--primary);
    box-shadow: 0 0 20px var(--primary);
    border: 2px solid #fff;
    font-size: 1.2rem;
}
.btn-game.start:hover { background: #e879f9; }

.btn-game.upgrade { background: var(--secondary); color: #000; }
.btn-game.sell { background: var(--danger); color: #fff; }
.btn-game.action { background: var(--accent); color: #000; max-width: 200px; }

/* --- Overlay --- */
#overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(19, 15, 38, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    color: white;
    text-align: center;
    padding: 20px;
}
#overlay h1 { 
    font-family: 'Press Start 2P'; 
    font-size: 2.5rem; 
    margin-bottom: 20px; 
    color: var(--primary);
    text-shadow: 4px 4px 0 #000;
    line-height: 1.5;
}
#overlay p { color: var(--text-dim); max-width: 400px; margin-bottom: 30px; font-size: 1.3rem; }

.hidden { display: none !important; }

/* --- Leaderboard --- */
#leaderboard-display {
    background: rgba(0,0,0,0.5);
    padding: 15px;
    border: 2px solid #45326e;
    margin-bottom: 20px;
    width: 350px; 
}

#leaderboard-list {
    max-height: 200px; 
    overflow-y: auto;  
    padding-right: 5px;
}

#leaderboard-list::-webkit-scrollbar { width: 8px; }
#leaderboard-list::-webkit-scrollbar-track { background: #1a152e; }
#leaderboard-list::-webkit-scrollbar-thumb { 
    background: var(--secondary); 
    border-radius: 4px; 
    border: 2px solid #1a152e;
}
#leaderboard-list::-webkit-scrollbar-thumb:hover { background: #fff; }

.score-entry {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px dashed #45326e;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
}

#player-name {
    padding: 10px;
    background: #000;
    border: 2px solid var(--secondary);
    color: var(--secondary);
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 10px;
    width: 200px;
    outline: none;
}

.final-score-text { font-size: 2rem; color: var(--accent) !important; font-family: 'VT323'; margin-bottom: 10px; }

/* --- How To Play Section --- */
#how-to-play {
    width: 100%;
    max-width: 1150px;
    background: rgba(36, 27, 66, 0.8);
    border: 4px solid #45326e;
    padding: 30px;
    text-align: center;
    margin-top: 20px;
}

#how-to-play h2 {
    font-family: 'Press Start 2P';
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: var(--secondary);
}

.instructions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.instruction-card {
    background: #1a152e;
    padding: 20px;
    border: 2px solid #45326e;
    text-align: center;
}

.instruction-card .icon {
    font-size: 2rem;
    margin-bottom: 15px;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary);
}

.instruction-card h3 {
    font-family: 'Press Start 2P';
    font-size: 0.8rem;
    margin-bottom: 10px;
    color: var(--text-main);
}

.instruction-card p { font-size: 1.1rem; color: var(--text-dim); }

footer {
    text-align: center;
    padding: 20px;
    font-size: 1rem;
    color: var(--text-main);
    margin-top: 20px;
}
footer a:hover { color: var(--primary) !important; }

/* --- COOKIE BANNER RESTYLING --- */
#simple-cookie-banner {
    background: #241b42 !important; 
    color: #e2e8f0 !important; 
    font-family: 'VT323', monospace !important;
    font-size: 1.2rem !important;
    border: 3px solid #45326e !important; 
    border-top: 4px solid var(--primary) !important; 
    border-radius: 4px !important; 
    backdrop-filter: none !important; 
    box-shadow: 0 0 25px rgba(0,0,0,0.8) !important;
    padding: 15px !important;
    z-index: 99999 !important;
}

#simple-cookie-banner strong {
    font-family: 'Press Start 2P', cursive !important;
    font-size: 0.9rem !important;
    color: var(--primary) !important;
    background: none !important;
    -webkit-text-fill-color: var(--primary) !important;
    text-shadow: 2px 2px 0px #000 !important;
    display: block !important;
    margin-bottom: 8px !important;
}

#simple-cookie-banner div, 
#simple-cookie-banner p {
    color: #e2e8f0 !important;
}

#simple-cookie-banner a {
    color: var(--secondary) !important;
    text-decoration: underline !important;
    font-weight: normal !important;
}
#simple-cookie-banner a:hover {
    color: #fff !important;
    text-shadow: 0 0 5px var(--secondary) !important;
}

#simple-cookie-banner .button-container {
    margin-top: 10px !important;
}

#simple-cookie-banner button {
    font-family: 'Press Start 2P', cursive !important;
    font-size: 0.7rem !important;
    text-transform: uppercase !important;
    border-radius: 0px !important;
    padding: 12px 20px !important;
    cursor: pointer !important;
    transition: 0.1s !important;
    box-shadow: 4px 4px 0px rgba(0,0,0,0.5) !important;
}

#btn-accept {
    background: var(--secondary) !important;
    color: #000 !important;
    border: 2px solid #fff !important;
}
#btn-accept:hover {
    transform: translate(2px, 2px) !important;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.5) !important;
}

#btn-deny {
    background: transparent !important;
    color: #fff !important;
    border: 2px solid var(--danger) !important;
}
#btn-deny:hover {
    background: var(--danger) !important;
    color: #fff !important;
    transform: translate(2px, 2px) !important;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.5) !important;
}

#btn-reopen-settings {
    background: #241b42 !important;
    border: 2px solid var(--primary) !important;
    border-radius: 4px !important; 
    color: var(--primary) !important;
    box-shadow: 0 0 10px rgba(0,0,0,0.5) !important;
}
#btn-reopen-settings:hover {
    background: var(--primary) !important;
    color: #000 !important;
}

/* --- MOBILE SPECIFIC FIXES (TABLET & PHONE) --- */
@media (max-width: 900px) {
	
    #game-wrapper { 
        flex-direction: column; 
        align-items: center; 
        border: none; 
        background: transparent; 
        box-shadow: none; 
    }
    .canvas-container { 
        border-right: none; 
        border-bottom: 4px solid #45326e; 
        border-radius: 4px; 
        width: 100%;
    }
    #ui-sidebar { 
        width: 100%; 
        max-width: 800px; 
        border: 4px solid #45326e; 
        border-radius: 4px; 
    }
    
    /* Fullscreen Overlay for Game Over */
    #overlay.mode-game-over {
        position: fixed !important; 
        top: 0 !important; 
        left: 0 !important; 
        right: 0 !important; 
        bottom: 0 !important;
        width: 100vw !important; 
        height: 100vh !important;
        background: rgba(19, 15, 38, 0.98) !important; 
        z-index: 99999 !important;
        overflow-y: auto !important; 
        justify-content: flex-start !important;
        padding-top: 50px !important;
    }
}

/* --- FIX FOR SMALL PHONES (iPhone/Smartphone Scaling) --- */
/* This specific query targets phones to shrink the title/buttons so they fit */
@media (max-width: 600px) {
    #overlay h1 {
        font-size: 1.8rem; /* Reduce title size */
        margin-bottom: 10px;
    }
    #overlay p {
        font-size: 1rem; /* Reduce intro text size */
        margin-bottom: 20px;
    }
    #overlay .btn-game.start {
        padding: 10px; /* Make the button smaller */
        font-size: 0.9rem;
    }
    #overlay {
        padding: 10px;
    }
}
