/* ==========================================================================
   CHRONO RIFT: CYBERPUNK SYNTHWAVE STYLESHEET
   ========================================================================== */

:root {
    --bg-dark: #070312;
    --panel-bg: rgba(13, 8, 28, 0.85);
    --panel-border: rgba(0, 240, 255, 0.4);
    --neon-cyan: #00f0ff;
    --neon-pink: #ff0077;
    --neon-purple: #a855f7;
    --neon-green: #00ffaa;
    --neon-yellow: #ffdd00;
    --neon-orange: #ff6600;
    --font-mono: 'Courier New', 'Consolas', monospace;
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    font-family: var(--font-mono);
    color: #ffffff;
    touch-action: none;
    -webkit-touch-callout: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Canvas Container */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    cursor: crosshair;
    touch-action: none;
}

/* CRT Scanline Filter Overlay */
.crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    background-size: 100% 4px, 6px 100%;
    z-index: 10;
}

/* Common Cyberpunk Glassmorphism Panel */
.cyber-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--panel-border);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.2), inset 0 0 15px rgba(0, 240, 255, 0.08);
    border-radius: 8px;
    position: relative;
}

/* Buttons */
.cyber-btn {
    background: rgba(0, 240, 255, 0.1);
    color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan);
    padding: 12px 24px;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 2px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-shadow: 0 0 8px var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cyber-btn:hover:not(:disabled) {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 25px var(--neon-cyan);
    transform: translateY(-2px);
}

.cyber-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.cyber-btn.pink {
    color: var(--neon-pink);
    border-color: var(--neon-pink);
    background: rgba(255, 0, 119, 0.1);
    text-shadow: 0 0 8px var(--neon-pink);
    box-shadow: 0 0 10px rgba(255, 0, 119, 0.15);
}

.cyber-btn.pink:hover:not(:disabled) {
    background: var(--neon-pink);
    color: #fff;
    box-shadow: 0 0 25px var(--neon-pink);
}

.cyber-btn.disabled, .cyber-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: #666;
    color: #888;
    box-shadow: none;
    text-shadow: none;
}

/* ==========================================================================
   MAIN MENU
   ========================================================================== */
#mainMenu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    background: radial-gradient(circle at center, rgba(168, 85, 247, 0.12) 0%, rgba(7, 3, 18, 0.95) 75%);
}

.title-container {
    text-align: center;
    margin-bottom: 30px;
}

.game-title {
    font-size: 54px;
    font-weight: 900;
    letter-spacing: 6px;
    color: #ffffff;
    text-shadow: 0 0 15px var(--neon-cyan), 0 0 35px var(--neon-purple);
    margin-bottom: 6px;
}

.game-subtitle {
    font-size: 16px;
    letter-spacing: 4px;
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink);
}

.menu-stats-bar {
    display: flex;
    gap: 25px;
    margin-bottom: 30px;
    padding: 10px 25px;
}

.stat-chip {
    font-size: 14px;
    color: #bbb;
}
.stat-chip span {
    font-weight: bold;
    color: var(--neon-cyan);
    margin-left: 6px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 320px;
}

.menu-buttons .cyber-btn {
    width: 100%;
}

.controls-hint {
    margin-top: 35px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 1px;
    text-align: center;
    line-height: 1.6;
}

/* ==========================================================================
   HEADS-UP DISPLAY (HUD)
   ========================================================================== */
#hudOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
    display: none;
}

/* Top HUD bar */
.top-hud {
    position: absolute;
    top: 15px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 320px;
    pointer-events: auto;
}

.hud-stat-group {
    background: rgba(10, 5, 20, 0.75);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 4px;
    padding: 8px 12px;
}

.hud-bar-wrapper {
    position: relative;
    width: 100%;
    height: 14px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.15s ease-out;
}

#hudHpBar {
    background: linear-gradient(90deg, #ff0055, #00ffaa);
    box-shadow: 0 0 10px #00ffaa;
}

#hudChronoBar {
    background: linear-gradient(90deg, #6b21a8, #c084fc);
    box-shadow: 0 0 10px #c084fc;
}

#hudXpBar {
    background: linear-gradient(90deg, #0077ff, #00f0ff);
    box-shadow: 0 0 10px #00f0ff;
}

.hud-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1px;
    color: #eee;
}

/* Top Right Score & Wave */
.top-right-hud {
    position: absolute;
    top: 15px;
    right: 200px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    background: rgba(10, 5, 20, 0.75);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 4px;
    padding: 8px 16px;
}

#hudScoreText {
    font-size: 20px;
    font-weight: bold;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
}

#hudWaveText {
    font-size: 13px;
    color: var(--neon-pink);
    letter-spacing: 1px;
}

#hudComboText {
    font-size: 18px;
    font-weight: 900;
    color: var(--neon-yellow);
    text-shadow: 0 0 12px var(--neon-yellow);
    animation: comboPulse 0.4s infinite alternate;
}

@keyframes comboPulse {
    from { transform: scale(1.0); }
    to { transform: scale(1.15); }
}

/* Bottom Weapon Slots */
.bottom-hud {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

.weapon-slot {
    width: 54px;
    height: 54px;
    background: rgba(10, 5, 20, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.weapon-slot.active {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 15px var(--neon-cyan);
    transform: translateY(-4px);
}

.wep-key {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 10px;
    color: #888;
}

.wep-icon {
    font-size: 24px;
}

/* Mobile Virtual Buttons */
.mobile-controls {
    position: absolute;
    bottom: 25px;
    right: 25px;
    display: none;
    flex-direction: column;
    gap: 16px;
    pointer-events: auto;
    z-index: 25;
}

@media (max-width: 1024px), (pointer: coarse) {
    .mobile-controls {
        display: flex;
    }
}

.touch-action-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(0, 240, 255, 0.25);
    border: 2px solid var(--neon-cyan);
    color: #fff;
    font-weight: 900;
    font-size: 13px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--neon-cyan);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    touch-action: none;
}

.touch-action-btn:active {
    background: var(--neon-cyan);
    color: #000;
    transform: scale(0.92);
}

/* ==========================================================================
   MODALS (Level Up, Shop, Pause, Game Over, Achievements, Settings)
   ========================================================================== */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 2, 12, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.modal-content {
    max-width: 850px;
    width: 90%;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(0, 240, 255, 0.3);
    padding-bottom: 12px;
}

.modal-title {
    font-size: 26px;
    font-weight: bold;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
    letter-spacing: 2px;
}

/* Level Up Upgrade Cards */
.cards-container {
    display: flex;
    gap: 20px;
    width: 100%;
    justify-content: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.upgrade-card {
    flex: 1;
    min-width: 220px;
    max-width: 260px;
    background: rgba(18, 10, 38, 0.9);
    border: 2px solid #555;
    border-radius: 8px;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
    position: relative;
    overflow: hidden;
}

.upgrade-card:hover {
    transform: translateY(-8px) scale(1.03);
}

.upgrade-card.rarity-common {
    border-color: #888;
}
.upgrade-card.rarity-common:hover {
    border-color: #ffffff;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

.upgrade-card.rarity-rare {
    border-color: var(--neon-cyan);
}
.upgrade-card.rarity-rare:hover {
    box-shadow: 0 0 25px var(--neon-cyan);
}

.upgrade-card.rarity-epic {
    border-color: var(--neon-purple);
}
.upgrade-card.rarity-epic:hover {
    box-shadow: 0 0 30px var(--neon-purple);
}

.upgrade-card.rarity-legendary {
    border-color: var(--neon-yellow);
}
.upgrade-card.rarity-legendary:hover {
    box-shadow: 0 0 35px var(--neon-yellow);
}

.card-icon {
    font-size: 42px;
    margin-bottom: 12px;
}

.card-rarity {
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 6px;
    color: #aaa;
}
.rarity-rare .card-rarity { color: var(--neon-cyan); }
.rarity-epic .card-rarity { color: var(--neon-purple); }
.rarity-legendary .card-rarity { color: var(--neon-yellow); }

.card-name {
    font-size: 17px;
    font-weight: bold;
    margin-bottom: 12px;
    color: #fff;
}

.card-desc {
    font-size: 13px;
    color: #bbb;
    line-height: 1.5;
}

/* Meta Shop Grid */
.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    width: 100%;
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 6px;
}

.shop-card {
    background: rgba(20, 12, 40, 0.85);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 6px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shop-icon {
    font-size: 28px;
}

.shop-title {
    font-weight: bold;
    font-size: 15px;
    color: var(--neon-cyan);
}

.shop-desc {
    font-size: 12px;
    color: #aaa;
    line-height: 1.4;
}

.shop-level {
    font-size: 12px;
    color: var(--neon-yellow);
    font-weight: bold;
}

.shop-buy-btn {
    margin-top: 6px;
    padding: 8px;
    font-size: 13px;
}

/* Achievements List */
.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-height: 55vh;
    overflow-y: auto;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(20, 12, 40, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 12px 16px;
}

.achievement-item.unlocked {
    border-color: var(--neon-green);
    box-shadow: 0 0 10px rgba(0, 255, 170, 0.15);
}

.ach-badge {
    font-size: 32px;
}

.ach-details {
    flex: 1;
}

.ach-header {
    font-weight: bold;
    font-size: 15px;
    color: #fff;
}
.achievement-item.unlocked .ach-header {
    color: var(--neon-green);
}

.ach-desc {
    font-size: 12px;
    color: #aaa;
}

/* Achievement Popup Toast */
.achievement-toast {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: rgba(10, 5, 25, 0.95);
    border: 2px solid var(--neon-green);
    box-shadow: 0 0 20px var(--neon-green);
    border-radius: 8px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 100;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.35s ease;
}

.achievement-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.achievement-toast .ach-title {
    font-size: 11px;
    color: var(--neon-green);
    font-weight: bold;
    letter-spacing: 2px;
}

.achievement-toast .ach-name {
    font-size: 13px;
    color: #fff;
}

/* Settings Sliders */
.settings-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin: 20px 0;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.cyber-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 200px;
    height: 8px;
    background: rgba(0, 240, 255, 0.2);
    border-radius: 4px;
    outline: none;
    border: 1px solid var(--neon-cyan);
}

.cyber-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--neon-cyan);
    box-shadow: 0 0 10px var(--neon-cyan);
    cursor: pointer;
}

/* Cyber Select & Textarea */
.cyber-select {
    background: rgba(10, 5, 25, 0.9);
    color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan);
    border-radius: 4px;
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
}

.cyber-textarea {
    width: 100%;
    height: 65px;
    background: rgba(10, 5, 25, 0.9);
    border: 1px solid rgba(0, 240, 255, 0.3);
    border-radius: 4px;
    color: #fff;
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 8px;
    resize: none;
    outline: none;
}
.cyber-textarea:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

/* Game Over Stats Table */
.stats-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 30px;
    margin: 25px 0;
    width: 100%;
    max-width: 400px;
}

.stats-summary .stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #aaa;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
    padding-bottom: 4px;
}

.stats-summary .stat-item span:last-child {
    font-weight: bold;
    color: var(--neon-cyan);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .game-title { font-size: 36px; }
    .top-hud { width: 220px; }
    .top-right-hud { right: 100px; }
    .mobile-controls { display: flex; }
    .upgrade-card { min-width: 100%; }
}
