/* Orbitron (Variable/Regular) */
@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/orbitron.woff2') format('woff2');
}

@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/orbitron.woff2') format('woff2');
}

@font-face {
  font-family: 'Orbitron';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('./fonts/orbitron.woff2') format('woff2');
}

/* Rajdhani 500 */
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./fonts/rajdhani-500-dev.woff2') format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./fonts/rajdhani-500-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('./fonts/rajdhani-500-lat.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Rajdhani 700 */
@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/rajdhani-700-dev.woff2') format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/rajdhani-700-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Rajdhani';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('./fonts/rajdhani-700-lat.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* =========================================
           CYBER-CORE CSS FRAMEWORK
           ========================================= */
        :root {
            --c-cyan: #00f3ff;
            --c-cyan-dim: rgba(0, 243, 255, 0.2);
            --c-pink: #ff0055;
            --c-pink-dim: rgba(255, 0, 85, 0.2);
            --c-gold: #ffcc00;
            --c-void: #050508;
            --c-panel: rgba(10, 12, 16, 0.85);
            --c-glass: rgba(255, 255, 255, 0.05);

            --f-head: 'Orbitron', sans-serif;
            --f-body: 'Rajdhani', sans-serif;

            --glow-cyan: 0 0 15px var(--c-cyan);
            --glow-pink: 0 0 15px var(--c-pink);
            --border-tech: 1px solid rgba(255, 255, 255, 0.1);
        }

        * {
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
        }

        body {
            margin: 0;
            overflow: hidden;
            background: var(--c-void);
            font-family: var(--f-body);
            color: white;
            user-select: none;
            touch-action: none;
        }

        #canvas-layer {
            position: fixed;
            top: 0;
            left: 0;
            z-index: 0;
        }

        /* SCANLINE OVERLAY */
        #crt-overlay {
            position: fixed;
            inset: 0;
            z-index: 5;
            pointer-events: none;
            background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 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%;
            opacity: 0.6;
        }

        /* =========================================
           UI LAYER SYSTEM
           ========================================= */
        #ui-layer {
            position: fixed;
            inset: 0;
            z-index: 10;
            display: flex;
            flex-direction: column;
            perspective: 1200px;
        }

        /* GENERAL UTILS */
        .hidden {
            display: none !important;
        }

        .fade-in {
            animation: fadeIn 0.5s forwards;
        }

        .fade-out {
            animation: fadeOut 0.3s forwards;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: scale(0.95);
            }

            to {
                opacity: 1;
                transform: scale(1);
            }
        }

        @keyframes fadeOut {
            from {
                opacity: 1;
                transform: scale(1);
            }

            to {
                opacity: 0;
                transform: scale(1.05);
            }
        }

        /* =========================================
           BUTTONS & INTERACTIVES
           ========================================= */
        .btn-cyber {
            position: relative;
            background: rgba(0, 0, 0, 0.6);
            border: 1px solid var(--c-cyan);
            color: var(--c-cyan);
            padding: 15px 40px;
            font-family: var(--f-head);
            font-weight: 900;
            font-size: 1.2rem;
            letter-spacing: 2px;
            text-transform: uppercase;
            cursor: pointer;
            transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
            overflow: hidden;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 220px;
            margin: 10px;
            box-shadow: 0 0 10px var(--c-cyan-dim);
        }

        /* Hover Fill Effect */
        .btn-cyber::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 0%;
            height: 100%;
            background: var(--c-cyan);
            z-index: -1;
            transition: width 0.3s ease;
        }

        .btn-cyber:hover::before {
            width: 100%;
        }

        .btn-cyber:hover {
            color: #000;
            box-shadow: 0 0 30px var(--c-cyan);
            text-shadow: none;
            border-color: white;
        }

        .btn-cyber:active {
            transform: scale(0.98);
        }

        /* Secondary Variant */
        .btn-cyber.secondary {
            border-color: #666;
            color: #aaa;
            box-shadow: none;
        }

        .btn-cyber.secondary::before {
            background: #ccc;
        }

        .btn-cyber.secondary:hover {
            color: #000;
            box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
        }

        /* Danger Variant */
        .btn-cyber.danger {
            border-color: var(--c-pink);
            color: var(--c-pink);
            box-shadow: 0 0 10px var(--c-pink-dim);
        }

        .btn-cyber.danger::before {
            background: var(--c-pink);
        }

        .btn-cyber.danger:hover {
            color: white;
            box-shadow: 0 0 30px var(--c-pink);
        }

        /* Back Button */
        .btn-back {
            position: absolute;
            bottom: 40px;
            left: 40px;
            background: transparent;
            border: 1px solid var(--c-pink);
            color: var(--c-pink);
            padding: 10px 30px;
            font-family: var(--f-head);
            cursor: pointer;
            transition: 0.3s;
            z-index: 100;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .btn-back:hover {
            background: var(--c-pink);
            color: white;
            box-shadow: var(--glow-pink);
            padding-left: 20px;
            padding-right: 40px;
        }

        /* =========================================
           SCREENS
           ========================================= */
        /* Custom Scrollbar */
        ::-webkit-scrollbar {
            width: 8px;
        }

        ::-webkit-scrollbar-track {
            background: #050508;
            border: 1px solid #333;
        }

        ::-webkit-scrollbar-thumb {
            background: var(--c-cyan);
            border-radius: 4px;
        }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--c-cyan-dim);
        }

        .touch-zone {
            position: absolute;
            bottom: 0;
            width: 50%;
            height: 150px;
            /* Shortened to avoid cutting player */
            z-index: 1000;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: all 0.2s;
            opacity: 0.8;
            /* Slightly visible for feedback */
            /* Glassmorphism for buttons */
            background: linear-gradient(to top, rgba(0, 243, 255, 0.2), rgba(0, 0, 0, 0));
            border-top: 1px solid rgba(0, 243, 255, 0.3);
            pointer-events: auto;
            /* Ensure it captures touches */
        }

        .screen-container {
            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);
            z-index: 10;
            transition: opacity 0.5s;
            opacity: 0;
            pointer-events: none;
            padding: 20px;
            box-sizing: border-box;
        }

        .screen-container.active {
            opacity: 1;
            pointer-events: auto;
        }

        /* HOME SCREEN */
        #home-screen {
            background: transparent;
            backdrop-filter: none;
            justify-content: flex-end;
            padding-bottom: 10vh;
        }

        .hero-title-container {
            text-align: center;
            margin-bottom: 40px;
            position: relative;
        }

        .hero-title {
            font-family: 'Orbitron', sans-serif;
            font-size: 5rem;
            color: transparent;
            -webkit-text-stroke: 2px var(--c-cyan);
            text-shadow: 0 0 30px var(--c-cyan);
            letter-spacing: 10px;
            margin-bottom: 10px;
            position: relative;
            z-index: 2;
        }

        .hero-tag {
            font-size: 1.2rem;
            letter-spacing: 12px;
            color: var(--c-pink);
            margin-top: 10px;
            font-weight: 700;
            text-transform: uppercase;
            text-shadow: 0 0 10px var(--c-pink);
        }

        /* HUD */
        #hud-layer {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.5s;
        }

        .hud-top-bar {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            display: flex;
            justify-content: space-between;
            padding: 20px 40px;
            background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
        }

        .hud-stat {
            display: flex;
            flex-direction: column;
            border-left: 2px solid var(--c-cyan);
            padding-left: 15px;
            background: linear-gradient(90deg, rgba(0, 243, 255, 0.1), transparent);
        }

        .hud-label {
            font-size: 0.8rem;
            color: #888;
            letter-spacing: 2px;
        }

        .hud-value {
            font-size: 2rem;
            font-family: var(--f-head);
            color: white;
            font-weight: bold;
        }

        .hud-value.gold {
            color: var(--c-gold);
            text-shadow: 0 0 10px var(--c-gold);
        }

        .powerup-deck {
            position: absolute;
            top: 120px;
            left: 40px;
            display: flex;
            gap: 15px;
        }

        .pu-slot {
            width: 50px;
            height: 50px;
            border: 1px solid #444;
            background: rgba(0, 0, 0, 0.5);
            display: flex;
            justify-content: center;
            align-items: center;
            opacity: 0.3;
            transition: 0.3s;
            color: #666;
        }

        .pu-slot svg {
            width: 24px;
            height: 24px;
        }

        .pu-slot.active {
            opacity: 1;
            animation: pulse 1s infinite;
        }

        #slot-shield.active {
            border-color: var(--c-cyan);
            box-shadow: 0 0 20px var(--c-cyan);
            color: var(--c-cyan);
        }

        #slot-magnet.active {
            border-color: #9900ff;
            box-shadow: 0 0 20px #9900ff;
            color: #9900ff;
        }

        /* SHOP SCREEN */
        #shop-screen {
            background: rgba(5, 5, 8, 0.95);
        }

        .shop-layout {
            display: grid;
            grid-template-columns: 350px 1fr;
            gap: 40px;
            width: 90vw;
            height: 80vh;
            max-width: 1200px;
        }

        .shop-sidebar {
            border-right: 1px solid #333;
            padding-right: 20px;
            display: flex;
            flex-direction: column;
            gap: 10px;
        }

        .shop-preview {
            position: relative;
            border: 1px solid var(--c-cyan);
            background: rgba(10, 12, 20, 0.95);
            height: 100%;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            box-shadow: 0 0 30px rgba(0, 243, 255, 0.1), inset 0 0 50px rgba(0, 0, 0, 0.5);
        }

        .shop-header {
            padding: 20px;
            border-bottom: 1px solid var(--c-cyan-dim);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .shop-tabs {
            display: flex;
            gap: 10px;
            padding: 20px;
        }

        .tab-btn {
            background: transparent;
            border: 1px solid #555;
            color: #888;
            padding: 10px 20px;
            cursor: pointer;
            font-family: var(--f-head);
            flex: 1;
            transition: 0.3s;
        }

        .tab-btn.active {
            border-color: var(--c-cyan);
            color: var(--c-cyan);
            background: var(--c-cyan-dim);
        }

        .shop-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
            gap: 15px;
            padding: 20px;
            overflow-y: auto;
        }

        .shop-item {
            background: rgba(20, 20, 35, 0.95);
            border: 1px solid #444;
            padding: 15px;
            cursor: pointer;
            transition: 0.2s;
            display: flex;
            flex-direction: column;
            align-items: center;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 243, 255, 0.03);
        }

        .shop-item:hover {
            background: rgba(0, 243, 255, 0.05);
            border-color: var(--c-cyan);
        }

        .shop-item.owned {
            border-color: #666;
        }

        .shop-item.equipped {
            border-color: var(--c-gold);
            box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.1);
        }

        .item-icon {
            font-size: 2rem;
            margin-bottom: 10px;
        }

        .item-price {
            color: var(--c-gold);
            font-weight: bold;
        }

        /* LEVEL SELECT */
        .level-matrix {
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            gap: 15px;
            padding: 20px;
            background: rgba(0, 0, 0, 0.5);
            border: 1px solid #333;
            max-height: 60vh;
            overflow-y: auto;
            width: 100%;
            max-width: 800px;
        }

        .lvl-cell {
            aspect-ratio: 1;
            border: 1px solid #444;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 1.5rem;
            color: #666;
            cursor: not-allowed;
            transition: 0.3s;
            background: rgba(0, 0, 0, 0.6);
            position: relative;
        }

        .lvl-cell.unlocked {
            color: white;
            border-color: var(--c-cyan-dim);
        }

        .lvl-cell.unlocked:hover {
            border-color: var(--c-cyan);
            background: var(--c-cyan-dim);
            transform: scale(1.05);
        }

        .lvl-cell.cleared {
            color: var(--c-gold);
            border-color: rgba(255, 215, 0, 0.3);
        }

        .lvl-cell.locked::after {
            content: '🔒';
            font-size: 1rem;
            position: absolute;
        }

        /* NOTIFICATIONS */
        #toast-container {
            position: absolute;
            bottom: 100px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            gap: 10px;
            pointer-events: none;
        }

        .toast {
            background: rgba(0, 0, 0, 0.8);
            border: 1px solid var(--c-cyan);
            color: var(--c-cyan);
            padding: 10px 30px;
            font-family: var(--f-head);
            text-transform: uppercase;
            animation: slideUp 0.3s ease-out;
            box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
        }

        @keyframes slideUp {
            from {
                transform: translateY(20px);
                opacity: 0;
            }

            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        /* MOBILE ADAPTATION */
        @media (max-width: 900px) {
            .hero-title {
                font-size: 4rem;
            }

            .shop-layout {
                grid-template-columns: 1fr;
                grid-template-rows: auto 1fr;
            }

            .shop-sidebar {
                border-right: none;
                border-bottom: 1px solid #333;
                padding-bottom: 20px;
            }

            .level-matrix {
                grid-template-columns: repeat(4, 1fr);
            }

            .btn-back {
                bottom: 20px;
                left: 20px;
                padding: 8px 20px;
            }

            .btn-cyber {
                padding: 12px 30px;
                font-size: 1rem;
                min-width: 180px;
            }
        }

        /* Portrait Mode - Phone Vertical */
        @media (max-aspect-ratio: 1/1) {
            .hero-title {
                margin-top: 0;
                /* Reset desktop margin */
                font-size: 3rem;
            }

            .hero-tag {
                font-size: 0.8rem;
            }

            .hud-top-bar {
                padding: 8px;
                gap: 3px;
            }

            .hud-stat {
                padding: 6px 8px;
            }

            .hud-label {
                font-size: 0.6rem;
                letter-spacing: 1px;
            }

            .hud-value {
                font-size: 1.2rem;
            }

            .powerup-deck {
                top: 80px;
                left: 10px;
                gap: 8px;
            }

            .pu-slot {
                width: 36px;
                height: 36px;
                font-size: 1rem;
            }

            .btn-cyber {
                padding: 12px 20px;
                font-size: 0.85rem;
                min-width: 140px;
                margin: 5px;
            }

            .level-matrix {
                grid-template-columns: repeat(4, 1fr);
                gap: 12px;
                padding: 10px;
                max-height: 60vh;
                overflow-y: auto;
            }

            .lvl-cell {
                width: 100%;
                aspect-ratio: 1;
                font-size: 1.2rem;
                display: flex;
                align-items: center;
                justify-content: center;
            }

            #home-screen {
                padding-bottom: 5vh;
            }

            /* Game over and win screen - smaller responsive text */
            #game-over-screen h1 {
                font-size: 2.2rem !important;
                word-break: break-word;
            }

            #win-screen h1 {
                font-size: 2.5rem !important;
            }

            /* Shop layout for mobile */
            .shop-layout {
                grid-template-columns: 1fr !important;
                grid-template-rows: auto 1fr;
                width: 95vw;
                height: 85vh;
                gap: 15px;
            }

            .shop-sidebar {
                border-right: none !important;
                border-bottom: 1px solid #333;
                padding-bottom: 10px;
                padding-right: 0;
            }

            .shop-preview {
                height: auto;
                min-height: 300px;
            }

            .shop-grid {
                grid-template-columns: repeat(2, 1fr) !important;
            }

            .btn-back {
                position: relative;
                bottom: auto;
                left: auto;
                margin-top: 10px;
            }
        }

        /* Extra small phones */
        @media (max-width: 400px) {
            .hero-title {
                font-size: 2.8rem;
            }

            .btn-cyber {
                padding: 12px 20px;
                font-size: 0.85rem;
                min-width: 140px;
            }

            .hud-value {
                font-size: 1.2rem;
            }

            .level-matrix {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        /* Touch-friendly tap areas */
        @media (pointer: coarse) {
            .btn-cyber {
                min-height: 48px;
            }

            .shop-item {
                min-height: 100px;
                padding: 20px;
            }

            .lvl-cell {
                min-width: 50px;
                min-height: 50px;
            }
        }

        /* Mobile Touch Button Zones */
        #touch-controls {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            height: 25vh;
            display: none;
            z-index: 15;
            pointer-events: none;
        }

        #touch-controls.visible {
            display: flex;
            pointer-events: auto;
        }

        .touch-zone {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            background: linear-gradient(to top, rgba(0, 243, 255, 0.15) 0%, transparent 100%);
            border-top: 1px solid rgba(0, 243, 255, 0.3);
            transition: all 0.15s ease;
            user-select: none;
            -webkit-user-select: none;
        }

        .touch-zone:first-child {
            border-right: 1px solid rgba(0, 243, 255, 0.2);
        }

        .touch-zone:last-child {
            border-left: 1px solid rgba(0, 243, 255, 0.2);
        }

        .touch-zone .zone-icon {
            font-size: 3rem;
            color: rgba(0, 243, 255, 0.5);
            text-shadow: 0 0 20px rgba(0, 243, 255, 0.3);
            transition: all 0.15s ease;
        }

        .touch-zone:active {
            background: linear-gradient(to top, rgba(0, 243, 255, 0.35) 0%, rgba(0, 243, 255, 0.1) 100%);
        }

        .touch-zone:active .zone-icon {
            color: rgba(0, 243, 255, 0.9);
            text-shadow: 0 0 30px var(--c-cyan);
            transform: scale(1.2);
        }

        .touch-zone.left .zone-icon::before {
            content: '◀';
        }

        .touch-zone.right .zone-icon::before {
            content: '▶';
        }

        /* Hide touch controls on desktop */
        @media (pointer: fine) {
            #touch-controls {
                display: none !important;
            }
        }

        /* Screen specific layouts */
        #home-screen {
            justify-content: flex-start;
            /* Align to top */
            padding-top: 15vh;
            /* Spacing from top */
        }
