:root {
    --primary: #4facfe;
    --primary-glow: rgba(79, 172, 254, 0.45);
    --secondary: #00f2fe;
    --secondary-glow: rgba(0, 242, 254, 0.45);
    --neon-pink: #ff0844;
    --neon-pink-glow: rgba(255, 8, 68, 0.5);
    --glass-bg: rgba(10, 10, 25, 0.72);
    --gold: #ffd700;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    font-family: 'Outfit', sans-serif;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #020205;
    touch-action: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#trail-canvas {
    z-index: 10;
    pointer-events: auto; /* Handle touch interaction overlay */
}

/* Flash and UI Edge Indicators */
#flash-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 15;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s ease-out;
}

#border-flash {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 16;
    pointer-events: none;
    border: 0px solid transparent;
    transition: border 0.2s ease-out;
}

#floating-text-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 12;
    pointer-events: none;
}

.floating-score-text {
    position: absolute;
    font-weight: 900;
    font-size: 1.8rem;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8), 0 0 5px currentColor;
    transform: translateY(0) scale(1);
    opacity: 1;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.6s ease;
}

#toast-container {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 500;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.achievement-toast {
    background: rgba(10, 10, 20, 0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1.5px solid var(--gold);
    border-radius: 16px;
    padding: 14px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 30px rgba(255, 215, 0, 0.2);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.5s ease;
    max-width: 320px;
}

.achievement-toast.active {
    transform: translateX(0);
    opacity: 1;
}

.toast-trophy-icon {
    color: var(--gold);
    font-size: 1.8rem;
    animation: pulse-glow 1.5s infinite alternate;
}

.toast-text h4 {
    font-size: 0.8rem;
    color: var(--gold);
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.toast-text p {
    font-size: 0.95rem;
    color: #fff;
    font-weight: 500;
}

/* HUD System Styles */
#game-hud {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    padding: 24px;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#game-hud.active {
    pointer-events: auto;
    opacity: 1;
}

.hud-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hud-item {
    background: rgba(15, 15, 30, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 20px;
    border-radius: 14px;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.hud-lives {
    display: flex;
    gap: 6px;
    font-size: 1.4rem;
}

.hud-lives i {
    color: #ff334b;
    filter: drop-shadow(0 0 5px rgba(255, 51, 75, 0.6));
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.hud-score {
    font-size: 2.8rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

.hud-combo-alert {
    background: linear-gradient(135deg, var(--neon-pink) 0%, #ff6a00 100%);
    padding: 4px 14px;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
    transform: scale(0);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 20px var(--neon-pink-glow);
}

.hud-combo-alert.active {
    transform: scale(1);
}

.hud-timer {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffcc00;
}

.icon-gold {
    color: var(--gold);
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.5));
}

.btn-pause {
    background: rgba(15, 15, 30, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.25s ease;
}

.btn-pause:hover {
    background: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
    border-color: transparent;
}

/* Boss HUD Overlay */
#boss-hud {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%) scale(0.8);
    z-index: 21;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#boss-hud.active {
    transform: translateX(-50%) scale(1);
    opacity: 1;
}

.boss-panel {
    background: rgba(25, 5, 5, 0.85);
    border: 1.5px solid #ff1133;
    border-radius: 16px;
    padding: 12px 18px;
    box-shadow: 0 0 25px rgba(255, 17, 51, 0.35);
    text-align: center;
}

.boss-name {
    color: #ff334b;
    font-weight: 900;
    font-size: 1rem;
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.boss-hp-bar {
    width: 100%;
    height: 12px;
    background: #200;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 17, 51, 0.3);
}

.boss-hp-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff1133, #ff6600);
    box-shadow: 0 0 10px #ff1133;
    transition: width 0.15s ease-out;
}

/* Screen Panel Overlays */
.screen-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, rgba(10, 10, 25, 0.4) 0%, rgba(2, 2, 5, 0.96) 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

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

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border-radius: 28px;
    padding: 36px;
    width: 90%;
    max-width: 480px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh;
    overflow-y: auto;
}

.glass-panel::-webkit-scrollbar {
    width: 6px;
}
.glass-panel::-webkit-scrollbar-track {
    background: transparent;
}
.glass-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.screen-overlay.active .glass-panel {
    transform: scale(1);
}

.cinematic-title {
    font-size: 3.2rem;
    font-weight: 900;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 30%, #c0c0d5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.cinematic-subtitle {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 4px;
    margin-bottom: 30px;
    text-transform: uppercase;
}

.menu-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Buttons */
.btn-premium {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow: 0 4px 18px var(--primary-glow);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 14px;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 14px 28px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.btn-premium:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px var(--secondary-glow);
}

.btn-premium:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-premium-outline {
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    border-radius: 14px;
    font-weight: 700;
    font-size: 1rem;
    padding: 12px 24px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-premium-outline:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.panel-heading {
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Tabs */
.tab-bar {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #a0a0ba;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.25s ease;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Lists and Cards */
.items-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.shop-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    transition: all 0.25s ease;
}

.shop-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
}

.shop-card-info h3 {
    font-size: 1.1rem;
    color: #fff;
    margin-bottom: 4px;
}

.shop-card-info p {
    font-size: 0.85rem;
    color: #a0a0ba;
}

.color-swatch {
    width: 24px;
    height: 6px;
    border-radius: 3px;
    margin-top: 6px;
}

.shop-btn {
    padding: 8px 16px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.buy-btn {
    background: var(--gold);
    border: none;
    color: #000;
}

.buy-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

.equip-btn {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}

.equip-btn:hover {
    background: var(--primary);
    color: #fff;
}

.equipped-badge {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    cursor: default;
}

/* Achievement Item Design */
.achievement-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
    margin-bottom: 10px;
}

.achievement-icon-container {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.3rem;
    color: #a0a0ba;
}

.achievement-item.unlocked .achievement-icon-container {
    background: rgba(255, 215, 0, 0.15);
    color: var(--gold);
    animation: pulse-glow 2s infinite alternate;
}

.achievement-details h4 {
    font-size: 1.05rem;
    color: #fff;
}

.achievement-details p {
    font-size: 0.85rem;
    color: #a0a0ba;
}

.achievement-item.unlocked {
    border-color: rgba(255, 215, 0, 0.25);
}

/* Profiles and Stats Grid */
.profile-xp-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 18px;
    margin-bottom: 24px;
}

.profile-progress-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 10px;
}

.profile-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    box-shadow: 0 0 10px var(--primary-glow);
    transition: width 0.5s ease-out;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 14px;
    text-align: center;
}

.stat-card h5 {
    font-size: 0.8rem;
    color: #a0a0ba;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-card p {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
}

/* Settings Controls */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 28px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 14px 18px;
    border-radius: 16px;
}

.setting-row span {
    color: #fff;
    font-weight: 600;
}

/* Toggles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Daily Targets Item Styling */
.challenge-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    margin-bottom: 12px;
}

.challenge-info {
    flex: 1;
}

.challenge-info h4 {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 6px;
}

.challenge-bar-container {
    width: 85%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 6px;
}

.challenge-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff8c00, #ff0080);
    border-radius: 3px;
}

.challenge-status {
    font-size: 0.75rem;
    color: #a0a0ba;
    display: inline-block;
    margin-top: 4px;
}

.challenge-reward {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 70px;
}

.challenge-reward span {
    font-weight: 700;
    color: #fff;
    font-size: 0.9rem;
}

.challenge-done-icon {
    color: #00ff66;
    font-size: 1.2rem;
}

.challenge-pending-icon {
    color: #a0a0ba;
    font-size: 1.1rem;
}

/* Fallback Screens */
#fallback-screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 999;
    display: none;
    justify-content: center;
    align-items: center;
    background: #020205;
}

#fallback-screen.active {
    display: flex;
}

@keyframes pulse-glow {
    from {
        filter: drop-shadow(0 0 2px currentColor);
    }
    to {
        filter: drop-shadow(0 0 8px currentColor);
    }
}