/* Base & Reset */
:root {
    --bg-dark: #0A0A1A; /* Very dark blue/black */
    --text-main: #f8fafc;
    --text-muted: #64748b;
    
    --primary: #FF006E; /* Neon Pink */
    --secondary: #8338EC; /* Cyber Purple */
    --accent: #00F5D4; /* Neon Teal */
    --warning: #FEE440; /* Yellow */
    --danger: #FF006E;
    
    --glass-bg: rgba(10, 10, 26, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --font-main: 'Inter', -apple-system, sans-serif;
    --border-radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-main);
    overflow: hidden;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-dark);
    overflow: hidden;
}

/* Parallax Backgrounds */
.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 200vw; /* Wider for scrolling */
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    background-repeat: repeat-x;
    background-size: auto 100%;
}

#bg-sky {
    background: linear-gradient(180deg, #050510 0%, #1a0b2e 100%);
    width: 100vw;
}

/* We'll draw the cityscape via canvas or complex gradients. 
   For purely CSS simple cityscape, we can use repeating linear gradients */
.cityscape {
    bottom: 0px;
    top: auto;
    height: 60vh;
    image-rendering: pixelated;
}

#bg-city-far {
    background-image: 
        linear-gradient(0deg, #1b0a3a 0%, #1b0a3a 40%, transparent 40%),
        repeating-linear-gradient(90deg, transparent 0px, transparent 100px, #1b0a3a 100px, #1b0a3a 150px),
        repeating-linear-gradient(90deg, transparent 0px, transparent 50px, #2a0b4a 50px, #2a0b4a 80px);
    background-size: 300px 100%, 300px 70%, 200px 50%;
    background-position: bottom left;
    background-repeat: repeat-x;
    opacity: 0.6;
    z-index: 1;
}

#bg-city-mid {
    background-image: 
        repeating-linear-gradient(90deg, transparent 0px, transparent 80px, #3a0ca3 80px, #3a0ca3 140px, transparent 140px, transparent 200px, #4a0ca3 200px, #4a0ca3 280px);
    background-size: 400px 60%;
    background-position: bottom left;
    background-repeat: repeat-x;
    opacity: 0.8;
    z-index: 2;
    /* Add neon window accents */
    box-shadow: inset 0 -20px 50px rgba(131, 56, 236, 0.4);
}

#bg-city-near {
    background-image: 
        repeating-linear-gradient(90deg, #0f0a1f 0px, #0f0a1f 120px, transparent 120px, transparent 160px, #150a2f 160px, #150a2f 260px);
    background-size: 500px 40%;
    background-position: bottom left;
    background-repeat: repeat-x;
    z-index: 3;
    border-bottom: 20px solid var(--primary); /* Glowing ground line */
    box-shadow: 0 -5px 15px rgba(255, 0, 110, 0.5);
}

canvas {
    display: block;
    z-index: 10;
    /* No shadow here, we want crisp edges blending with BG */
}

/* UI Layer */
#ui-layer {
    position: absolute;
    inset: 0;
    z-index: 20;
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: auto;
    transition: opacity 0.3s ease;
    padding: 2rem;
}

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

/* HUD elements */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.hud-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* Stat Bars */
.player-stats {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 300px;
    max-width: 40vw;
}

.stat-bar-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    font-weight: 900;
    font-style: italic;
    width: 30px;
    text-shadow: 0 0 5px rgba(255,255,255,0.5);
}

.stat-bar {
    flex-grow: 1;
    height: 14px;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.8);
}

.bar-fill {
    height: 100%;
    width: 100%;
    transform-origin: left;
    transition: transform 0.2s ease-out;
}

.health-bar .bar-fill {
    background: linear-gradient(90deg, #d90429, var(--primary));
    box-shadow: 0 0 10px var(--primary);
}

.energy-bar .bar-fill {
    background: linear-gradient(90deg, #0077b6, var(--accent));
    box-shadow: 0 0 10px var(--accent);
}

/* Score & Wave */
.score-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    text-align: right;
}

.score-container div {
    display: flex;
    flex-direction: column;
    background: rgba(10, 10, 26, 0.6);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--secondary);
    box-shadow: 0 0 10px rgba(131, 56, 236, 0.3);
    backdrop-filter: blur(4px);
}

.score-container .label {
    font-size: 0.6rem;
    color: var(--accent);
    letter-spacing: 2px;
}

.score-container .value {
    font-size: 1.5rem;
    font-weight: 900;
    font-style: italic;
    text-shadow: 0 0 5px rgba(255,255,255,0.8);
}

/* Combo UI */
#combo-container {
    position: absolute;
    top: 50%;
    right: 5%;
    transform: translateY(-50%);
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#combo-container.active {
    transform: translateY(-50%) scale(1.1);
}

#combo-count {
    font-size: 4rem;
    font-weight: 900;
    font-style: italic;
    color: var(--warning);
    line-height: 1;
    text-shadow: 2px 2px 0px var(--primary), -2px -2px 0px var(--secondary);
}

.combo-label {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 4px;
    margin-bottom: 5px;
    color: #fff;
}

.combo-timer-bar {
    width: 100px;
    height: 6px;
    background: rgba(0,0,0,0.5);
    border-radius: 3px;
    overflow: hidden;
}

#combo-timer-fill {
    height: 100%;
    width: 100%;
    background: var(--warning);
    transform-origin: right;
}

/* Boss UI */
#boss-ui {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-width: 80vw;
    text-align: center;
}

#boss-name {
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: 4px;
    color: var(--danger);
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px var(--danger);
}

.boss-health-bar {
    height: 20px;
    border: 2px solid var(--danger);
    background: rgba(0,0,0,0.8);
    border-radius: 0;
}

.boss-health-bar .bar-fill {
    background: var(--danger);
    box-shadow: 0 0 15px var(--danger);
}

/* Slow Mo Overlay Effect */
#slow-mo-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, transparent 30%, rgba(131, 56, 236, 0.4) 100%);
    box-shadow: inset 0 0 100px rgba(0, 245, 212, 0.2);
    pointer-events: none;
    z-index: 15;
    mix-blend-mode: color-dodge;
    transition: opacity 0.2s ease;
}

/* Typography & Glitch */
.title-container {
    text-align: center;
    margin-bottom: 1rem;
}

h1 {
    font-size: 6rem;
    font-weight: 900;
    letter-spacing: -0.05em;
    line-height: 0.9;
    color: #fff;
    font-style: italic;
    text-transform: uppercase;
}

h1.outline {
    color: transparent;
    -webkit-text-stroke: 2px var(--primary);
    text-shadow: 0 0 20px rgba(255, 0, 110, 0.4);
}

h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.subtitle {
    color: var(--accent);
    margin-bottom: 2rem;
    text-shadow: 0 0 10px rgba(0, 245, 212, 0.5);
}

.accent-text {
    color: var(--accent);
    font-weight: 700;
    text-shadow: 0 0 5px rgba(0, 245, 212, 0.5);
}

.txt-danger { color: var(--danger); -webkit-text-stroke: 0; }

.high-score-display, .currency-display {
    font-size: 1.2rem;
    margin-bottom: 3rem;
    background: rgba(0,0,0,0.5);
    padding: 0.5rem 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
}

/* Glitch Effect */
.glitch {
    position: relative;
    display: inline-block;
}
.glitch::before, .glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.8;
}
.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--secondary);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim 3s infinite linear alternate-reverse;
}
.glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--accent);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
}
@keyframes glitch-anim {
    0% { clip: rect(10px, 9999px, 86px, 0); }
    10% { clip: rect(38px, 9999px, 51px, 0); }
    20% { clip: rect(59px, 9999px, 63px, 0); }
    30% { clip: rect(66px, 9999px, 98px, 0); }
    40% { clip: rect(81px, 9999px, 45px, 0); }
    50% { clip: rect(32px, 9999px, 32px, 0); }
    60% { clip: rect(79px, 9999px, 58px, 0); }
    70% { clip: rect(82px, 9999px, 44px, 0); }
    80% { clip: rect(98px, 9999px, 20px, 0); }
    90% { clip: rect(21px, 9999px, 39px, 0); }
    100% { clip: rect(23px, 9999px, 20px, 0); }
}

/* Menus & Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 320px;
    margin-bottom: 2rem;
}

.btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 900;
    font-style: italic;
    letter-spacing: 2px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.btn::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 50%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transform: skewX(-20deg);
    transition: all 0.4s ease;
}

.btn:hover::after { left: 200%; }
.btn:active { transform: scale(0.95); }

.btn.primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.4);
}
.btn.primary:hover {
    background: #ff3388;
    box-shadow: 0 0 30px rgba(255, 0, 110, 0.6);
}

.btn.secondary {
    background: rgba(131, 56, 236, 0.2);
    color: var(--accent);
    border: 1px solid var(--secondary);
}
.btn.secondary:hover {
    background: rgba(131, 56, 236, 0.4);
    box-shadow: 0 0 15px rgba(131, 56, 236, 0.3);
}

/* Armory */
.sword-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    width: 100%;
    max-width: 800px;
    overflow-y: auto;
    max-height: 50vh;
    padding: 1rem;
}

.sword-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sword-card:hover {
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
}

.sword-card.equipped {
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(0, 245, 212, 0.2);
}

.sword-card.locked {
    opacity: 0.5;
    filter: grayscale(1);
}

.sword-color {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    margin: 10px 0;
    box-shadow: 0 0 10px currentColor;
}

/* Stats panel */
.stats-panel {
    background: rgba(0,0,0,0.6);
    border: 1px solid var(--secondary);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 400px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.stat-row:last-child { border-bottom: none; }
.stat-row.highlight { color: var(--warning); font-weight: bold; }

/* Control Info */
.controls-info {
    text-align: center;
    color: var(--text-muted);
}
.control-row { margin-bottom: 0.5rem; }
kbd {
    background: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-bottom-width: 2px;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 50;
}

.d-pad {
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
}

.d-pad-row {
    display: flex;
    gap: 8px;
}

.action-pad {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    pointer-events: auto;
    align-content: end;
}

.control-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(10, 10, 26, 0.6);
    border: 2px solid var(--secondary);
    color: #fff;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.1s;
    pointer-events: auto;
}

.control-btn.empty { background: transparent; border: none; pointer-events: none; }
.control-btn:active { transform: scale(0.9); background: rgba(131, 56, 236, 0.5); }

.action-btn {
    width: 55px;
    height: 55px;
    font-size: 1.2rem;
}

.light-atk { border-color: var(--accent); color: var(--accent); }
.heavy-atk { border-color: var(--primary); color: var(--primary); }
.special-atk { border-color: var(--warning); color: var(--warning); grid-column: span 2; justify-self: center;}
.dash-btn { border-color: #fff; grid-column: span 2; justify-self: center; width: 80px; height: 40px; border-radius: 20px;}


@media (pointer: fine) {
    #mobile-controls { display: none !important; }
}

@media (max-width: 768px) {
    h1 { font-size: 3.5rem; }
    h2 { font-size: 1.2rem; }
    .hud-top { padding: 0.5rem; }
    .player-stats { width: 150px; }
    .score-container .value { font-size: 1.2rem; }
    #combo-count { font-size: 2.5rem; }
    .sword-grid { grid-template-columns: repeat(2, 1fr); }
    .controls-info { display: none; }
}
