/**
 * Brawl Stars Mini App - Styles
 * A distinctive gaming aesthetic with neon accents
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
   /* 🔒 FIX: CSS Variables fallback for older browsers (IE11, etc.) */
   /* Note: Telegram Mini App doesn't support IE11, but fallback is good practice */
   :root {
    /* Primary Neon Colors - Brawl Stars inspired */
    --neon-cyan: #00f7ff;
    --neon-magenta: #ff2d92;
    --neon-lime: #39ff14;
    --neon-gold: #ffd700;
    --neon-purple: #bf00ff;
    --neon-blue: #2196f3;
    --neon-orange: #ff6b35;
    
    /* Background Colors - Deep space theme */
    --bg-void: #050510;
    --bg-deep: #0a0a1a;
    --bg-surface: #12122a;
    --bg-elevated: #1a1a3a;
    --bg-hover: #242450;
    
    /* Text Colors */
    --text-bright: #ffffff;
    --text-muted: #a0a0c0;
    --text-dim: #606080;
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-blue) 100%);
    --gradient-accent: linear-gradient(135deg, var(--neon-magenta) 0%, var(--neon-purple) 100%);
    --gradient-success: linear-gradient(135deg, var(--neon-lime) 0%, var(--neon-cyan) 100%);
    --gradient-gold: linear-gradient(135deg, var(--neon-gold) 0%, var(--neon-orange) 100%);
    
    /* Shadows */
    --glow-cyan: 0 0 20px rgba(0, 247, 255, 0.4);
    --glow-magenta: 0 0 20px rgba(255, 45, 146, 0.4);
    --glow-lime: 0 0 20px rgba(57, 255, 20, 0.4);
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    /* Typography with fallback fonts */
    --font-display: 'Orbitron', 'Rajdhani', 'Exo 2', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-body: 'Rajdhani', 'Exo 2', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', Courier, monospace;
}

/* 🔒 FIX: Fallback for browsers without CSS Variables support */
/* This ensures the app works even if CSS Variables fail */
@supports not (--css: variables) {
    :root {
        /* Fallback values - these will be used if CSS Variables don't work */
        --neon-cyan: #00f7ff;
        --neon-magenta: #ff2d92;
        --neon-lime: #39ff14;
        --bg-void: #050510;
        --bg-surface: #12122a;
        --text-bright: #ffffff;
        --space-md: 16px;
        --space-lg: 24px;
        --radius-md: 12px;
        --radius-lg: 16px;
        --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    }
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* Fallback: instant scroll for browsers without smooth scroll support */
    scroll-behavior: auto;
    /* Smooth scroll with fallback */
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
    /* 🔒 FIX: Constrain HTML to viewport height for Telegram Mini App */
    /* Use 100% instead of 100vh - 100vh can be taller than visible area in Telegram WebView */
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

/* Fallback for browsers without scroll-behavior support */
@supports not (scroll-behavior: smooth) {
    html {
        scroll-behavior: auto;
    }
}

body {
    font-family: var(--font-body);
    /* 🔒 FIX: Fallback font for WebViews that can't load Google Fonts */
    font-family: 'Rajdhani', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-weight: 500;
    background: var(--bg-void);
    background: #050510; /* Fallback for WebViews without CSS variable support */
    color: var(--text-bright);
    color: #ffffff; /* Fallback */
    /* 🔒 FIX: Use 100% + -webkit-fill-available for Telegram WebView compatibility */
    /* 100vh includes the Telegram toolbar space, causing content cut-off */
    height: 100%;
    height: -webkit-fill-available;
    max-height: 100%;
    max-height: -webkit-fill-available;
    overflow-x: hidden;
    overflow-y: auto;
    /* Enable smooth scrolling on iOS Safari */
    -webkit-overflow-scrolling: touch;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* 🔒 FIX: Allow text selection for better UX (removed user-select: none) */
    /* Text selection is now allowed for better accessibility */
    /* 🔒 FIX: RTL direction - set only for Hebrew content, not globally */
    direction: ltr; /* Default LTR for better cross-platform compatibility */
    /* Prevent body from expanding beyond viewport */
    position: relative;
}

/* RTL support for Hebrew content */
[dir="rtl"],
.rtl,
.hebrew {
    direction: rtl;
    text-align: right;
}

/* LTR support for English/numbers */
[dir="ltr"],
.ltr,
.english {
    direction: ltr;
    text-align: left;
}

/* ============================================
   BACKGROUND EFFECTS
   ============================================ */
body::before {
    content: '';
    position: fixed;
    /* 🔒 FIX: iOS Safari fixed positioning - use top/left/right/bottom instead of inset */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Fallback for browsers without inset support */
    inset: 0;
    background: 
        /* Animated gradient orbs */
        radial-gradient(ellipse 80% 50% at 20% 40%, rgba(0, 247, 255, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 60% 80% at 80% 60%, rgba(255, 45, 146, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 40% 40% at 50% 90%, rgba(57, 255, 20, 0.05) 0%, transparent 50%),
        /* Grid pattern */
        linear-gradient(rgba(0, 247, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 247, 255, 0.03) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 100% 100%, 50px 50px, 50px 50px;
    pointer-events: none;
    z-index: 0;
    animation: bgPulse 8s ease-in-out infinite alternate;
    /* 🔒 FIX: iOS Safari - prevent background from moving during scroll */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

@keyframes bgPulse {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* Scan line effect */
body::after {
    content: '';
    position: fixed;
    /* 🔒 FIX: iOS Safari fixed positioning - use top/left/right/bottom instead of inset */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Fallback for browsers without inset support */
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent 0,
        transparent 2px,
        rgba(0, 0, 0, 0.1) 2px,
        rgba(0, 0, 0, 0.1) 4px
    );
    pointer-events: none;
    z-index: 1000;
    opacity: 0.3;
    /* 🔒 FIX: iOS Safari - prevent background from moving during scroll */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3 {
    font-family: var(--font-display);
    /* 🔒 FIX: Fallback font for WebViews that can't load Google Fonts */
    font-family: 'Orbitron', 'Rajdhani', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.title {
    /* 🔒 FIX: Fallback for WebViews without clamp() support */
    font-size: 2rem;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 800;
    background: var(--gradient-primary);
    /* Fallback for browsers without gradient text support */
    color: var(--neon-cyan);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: relative;
    will-change: transform, opacity;
}

.title::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    background: var(--gradient-accent);
    /* Fallback for browsers without gradient text support */
    color: var(--neon-magenta);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0;
    animation: titleGlitch 3s ease-in-out infinite;
    will-change: transform, opacity;
}

@keyframes titleGlitch {
    0%, 90%, 100% { opacity: 0; transform: translate(0); }
    92% { opacity: 0.8; transform: translate(-2px, 1px); }
    94% { opacity: 0; }
    96% { opacity: 0.5; transform: translate(2px, -1px); }
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 600;
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
    max-width: 440px;
    margin: 0 auto;
    padding: var(--space-lg);
    position: relative;
    z-index: 1;
    /* 🔒 FIX: Prevent container from causing overflow */
    box-sizing: border-box;
    width: 100%;
}

/* Draft Recommendations Screen - Responsive container width */
#draft-recommendations-screen .container {
    max-width: 440px;
    width: 100%;
    margin: 0 auto;
    padding: var(--space-lg);
}

/* Desktop: Wider container for better card layout */
@media (min-width: 1025px) {
    #draft-recommendations-screen .container {
        max-width: 1200px !important;
        padding: var(--space-xl);
    }
    
    #draft-recommendations-screen .content {
        max-width: 100% !important;
        width: 100% !important;
    }
}

/* Tablet: Medium width */
@media (min-width: 769px) and (max-width: 1024px) {
    #draft-recommendations-screen .container {
        max-width: 800px !important;
        padding: var(--space-lg);
    }
    
    #draft-recommendations-screen .content {
        max-width: 100% !important;
        width: 100% !important;
    }
}

#draft-recommendations-screen .content {
    max-width: 100%;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: var(--space-2xl);
    padding: var(--space-lg) 0;
}

/* User status badge styling */
#user-status-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    word-break: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    direction: ltr;
    unicode-bidi: embed;
    max-width: 100%;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#user-status-badge span {
    display: inline-block;
    vertical-align: middle;
}

/* Player name display - handles any Unicode characters, emojis, stars, etc. */
#user-status-badge .player-name-display {
    max-width: 60%; /* Fallback for browsers without min() support */
    max-width: min(200px, 60%);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    unicode-bidi: embed;
    font-feature-settings: normal;
    /* Support for all languages and special characters */
    font-variant: normal;
    text-transform: none;
}

/* Player tag display - monospace for tags */
#user-status-badge .player-tag-display {
    max-width: 50%; /* Fallback for browsers without min() support */
    max-width: min(150px, 50%);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    unicode-bidi: embed;
    font-family: 'Courier New', Courier, monospace;
    font-feature-settings: normal;
}

/* Status display - always visible, no wrapping */
#user-status-badge .status-display {
    white-space: nowrap;
    flex-shrink: 0;
    font-weight: 600;
}

/* ============================================
   SCREENS
   ============================================ */
.screen {
    display: none;
    /* 🔒 FIX: Default opacity must be 1 so screens are always visible when active */
    /* Telegram WebView may not process opacity transition correctly */
    opacity: 1;
    transform: none;
    /* 🔒 FIX: Prevent screens from overflowing viewport */
    /* Use 100% instead of 100vh for Telegram WebView compatibility */
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.screen.active {
    /* 🔒 FIX: Use !important to ensure screens are visible even in iOS Telegram WebView */
    /* WKWebView can have CSS specificity issues that prevent screens from showing */
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    will-change: transform, opacity;
}

@keyframes screenEnter {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Smooth fade transitions for screen content */
.screen-content {
    animation: fadeInContent 0.4s ease-out;
}

@keyframes fadeInContent {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.screen-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.screen-header h2 {
    font-size: 1.5rem;
    background: var(--gradient-primary);
    /* Fallback for browsers without gradient text support */
    color: var(--neon-cyan);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    min-height: 56px;
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    /* 🔒 FIX: Keep user-select: none only for buttons (not for all text) */
    -webkit-user-select: none;
    user-select: none;
    /* 🔒 FIX: touch-action: manipulation prevents double-tap zoom and ensures click fires */
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 255, 255, 0.3);
    will-change: transform;
    transform: translateZ(0); /* Hardware acceleration */
}

.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.btn:hover::before {
    transform: translateX(100%);
}

.btn:active {
    transform: scale(0.96);
    transition: transform 0.1s ease;
}

/* Enhanced button hover effects */
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 247, 255, 0.3);
}

.btn:active:hover {
    transform: translateY(0) scale(0.96);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    /* 🔒 FIX: Better visual feedback for disabled buttons */
    filter: grayscale(0.5);
    box-shadow: none !important;
    transform: none !important;
}

/* Simplified connect button styles - removed excessive !important and z-index */
#connect-btn {
    /* Core interactive properties */
    position: relative;
    z-index: 10;
    pointer-events: auto;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0, 255, 255, 0.3);
    touch-action: manipulation;
    display: block;
    visibility: visible;
    opacity: 1;
    
    /* Additional properties for Telegram Desktop/iOS */
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    
    /* Hardware acceleration */
    will-change: transform;
    transform: translateZ(0);
    
    /* Button-specific styles */
    padding: 18px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    border-radius: 15px;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2), rgba(255, 0, 255, 0.2));
    border: 2px solid rgba(0, 255, 255, 0.5);
    color: #fff;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    
    /* Consistent rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-family: inherit;
}

#connect-btn:active {
    transform: scale(0.95) translateZ(0);
    opacity: 0.9;
}

#connect-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* macOS Telegram Desktop: Higher z-index for QtWebEngine stacking contexts */
@supports (-webkit-appearance: none) {
    /* Detect QtWebEngine (uses -webkit-appearance) */
    #connect-btn {
        z-index: 10000 !important; /* Increased for macOS QtWebEngine */
        position: relative !important;
        pointer-events: auto !important;
    }
    
    #connect-screen {
        z-index: 1000 !important; /* Increased for macOS QtWebEngine */
        position: relative !important;
        pointer-events: auto !important;
    }
    
    #connect-screen .container {
        z-index: 1001 !important;
        pointer-events: auto !important;
    }
    
    #connect-screen .connect-wrapper {
        z-index: 1002 !important;
        pointer-events: auto !important;
    }
}

/* Ensure connect screen doesn't block clicks */
#connect-screen {
    position: relative;
    z-index: 1;
    pointer-events: auto;
}

#connect-screen .container {
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

#connect-screen .connect-wrapper {
    position: relative;
    z-index: 3;
    pointer-events: auto;
}

/* Prevent overlays from blocking the connect button */
#connect-screen::before,
#connect-screen::after {
    pointer-events: none;
    z-index: 0;
}

/* Connect button class */
.connect-button-fixed {
    pointer-events: auto;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 255, 255, 0.3);
    position: relative;
    z-index: 10;
    -webkit-user-select: none;
    user-select: none;
    display: block;
    visibility: visible;
    opacity: 1;
}

.btn-icon {
    font-size: 1.2em;
    flex-shrink: 0;
}

.btn-text {
    flex: 1;
    text-align: center;
}

/* Primary Button */
.btn-primary {
    background: var(--gradient-primary);
    color: var(--bg-void);
    box-shadow: var(--glow-cyan), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
    box-shadow: 0 0 40px rgba(0, 247, 255, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Secondary Button */
.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-bright);
    border: 1px solid rgba(0, 247, 255, 0.25);
    box-shadow: 0 0 15px rgba(0, 247, 255, 0.1);
}

.btn-secondary:hover {
    border-color: var(--neon-cyan);
    box-shadow: var(--glow-cyan);
    background: var(--bg-hover);
}

/* Pro/Premium Button */
.btn-pro {
    background: var(--gradient-accent);
    color: var(--text-bright);
    box-shadow: var(--glow-magenta), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-pro:hover {
    box-shadow: 0 0 40px rgba(255, 45, 146, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Back Button */
.back-btn {
    background: transparent;
    border: 2px solid var(--neon-cyan);
    color: var(--neon-cyan);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.back-btn:hover {
    background: rgba(0, 247, 255, 0.15);
    box-shadow: var(--glow-cyan);
}

/* Neon Effect */
.neon-btn {
    position: relative;
}

.neon-btn::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    /* Fallback: linear gradient for browsers without conic-gradient support */
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta), var(--neon-lime), var(--neon-cyan));
    /* conic-gradient with fallback */
    background: conic-gradient(
        from 0deg,
        var(--neon-cyan),
        var(--neon-magenta),
        var(--neon-lime),
        var(--neon-cyan)
    );
    z-index: -1;
    opacity: 0;
    filter: blur(8px);
    transition: opacity 0.3s ease;
}

/* Fallback for browsers without conic-gradient support */
@supports not (background: conic-gradient(from 0deg, red, blue)) {
    .neon-btn::after {
        background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta), var(--neon-lime), var(--neon-cyan));
    }
}

.neon-btn:hover::after {
    opacity: 0.5;
    animation: neonRotate 2s linear infinite;
}

@keyframes neonRotate {
    to { transform: rotate(360deg); }
}

/* Button Grid */
.buttons-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* 🔒 FIX: Flexbox fallback for older Telegram WebView that doesn't support CSS Grid */
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    gap: var(--space-md);
}

.btn-row > * {
    flex: 1 1 calc(50% - 8px);
    min-width: 140px;
}

/* Upgrade to Grid for browsers that support it */
@supports (display: grid) {
    .btn-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
    .btn-row > * {
        flex: unset;
        min-width: unset;
    }
}

@media (max-width: 400px) {
    .btn-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   CARDS & CONTENT
   ============================================ */
.content {
    /* 🔒 FIX: Improved backdrop-filter fallback for Safari */
    /* Fallback background for browsers without backdrop-filter support */
    background: rgba(18, 18, 42, 0.98); /* Darker fallback for better contrast in Safari */
    border: 1px solid rgba(0, 247, 255, 0.15);
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    /* backdrop-filter with fallback */
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    /* Note: background is set above as fallback, browsers with backdrop-filter will use it */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    min-height: 200px;
    /* 🔒 FIX: Use 100% instead of 100vh for Telegram WebView */
    max-height: calc(100% - 200px);
    overflow-y: auto;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    animation: contentFadeIn 0.4s ease-out backwards;
    will-change: transform, opacity;
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(20px)) {
    .content {
        background: rgba(18, 18, 42, 0.98);
    }
}

@keyframes contentFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


.card {
    background: var(--bg-elevated);
    border: 1px solid rgba(0, 247, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: all 0.3s ease;
}

.card:hover {
    border-color: rgba(0, 247, 255, 0.3);
    box-shadow: var(--glow-cyan);
    transform: translateY(-2px);
}

.stat-card {
    background: linear-gradient(135deg, rgba(0, 247, 255, 0.08), rgba(255, 45, 146, 0.05));
    border: 1px solid rgba(0, 247, 255, 0.2);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--glow-cyan);
}

/* ============================================
   FORMS
   ============================================ */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-surface);
    border: 2px solid rgba(0, 247, 255, 0.2);
    border-radius: var(--radius-md);
    color: var(--text-bright);
    font-family: var(--font-body);
    /* 🔒 FIX: iOS Safari auto-zoom prevention - font-size must be >= 16px */
    /* Using min() to ensure at least 16px even if CSS variable is smaller */
    font-size: max(16px, var(--space-md, 16px));
    /* Fallback for browsers without max() support */
    font-size: 16px;
    transition: all 0.25s ease;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--neon-cyan);
    box-shadow: var(--glow-cyan);
    background: var(--bg-elevated);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-dim);
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-active {
    background: rgba(57, 255, 20, 0.15);
    color: var(--neon-lime);
    border: 1px solid rgba(57, 255, 20, 0.4);
}

.badge-pro {
    background: rgba(255, 45, 146, 0.15);
    color: var(--neon-magenta);
    border: 1px solid rgba(255, 45, 146, 0.4);
}

.badge-trial {
    background: rgba(255, 215, 0, 0.15);
    color: var(--neon-gold);
    border: 1px solid rgba(255, 215, 0, 0.4);
}

/* ============================================
   PROGRESS BARS
   ============================================ */
.progress-bar {
    height: 8px;
    background: var(--bg-surface);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    position: relative;
    transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

/* ============================================
   MODALS
   ============================================ */
#modal-overlay,
#input-modal-overlay {
    /* 🔒 FIX: Increased z-index to ensure modals appear above Telegram UI */
    /* Using 9999 instead of 99999 to avoid conflicts with Telegram UI (which uses 10000+) */
    z-index: 9999 !important;
    position: fixed;
    /* 🔒 FIX: iOS Safari fixed positioning - use top/left/right/bottom instead of inset */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    /* Fallback for browsers without inset support */
    inset: 0;
    /* Fallback background for browsers without backdrop-filter support */
    background: rgba(5, 5, 16, 0.98); /* Darker fallback for better contrast */
    /* backdrop-filter with fallback */
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    /* Fallback: darker background when backdrop-filter not supported */
    /* Note: background is set above, this is for browsers that support backdrop-filter */
    /* 🔒 FIX: iOS Safari - prevent modal from moving during scroll */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(8px)) {
    #modal-overlay,
    #input-modal-overlay {
        background: rgba(5, 5, 16, 0.98);
    }
}

#modal-content,
#input-modal-content {
    /* 🔒 FIX: Ensure modal content has high z-index and proper positioning */
    /* Using 10000 instead of 100000 to avoid conflicts with Telegram UI */
    position: relative;
    z-index: 10000 !important;
    background: var(--bg-elevated);
    border: 1px solid rgba(0, 247, 255, 0.3);
    box-shadow: var(--glow-cyan), 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: modalEnter 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalEnter {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ============================================
   LOADING STATES
   ============================================ */
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-hover);
    border-top-color: var(--neon-cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: var(--space-lg) auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-surface) 25%,
        var(--bg-elevated) 50%,
        var(--bg-surface) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ============================================
   SCROLLBAR
   ============================================ */
/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-void);
}

::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
}

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

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 247, 255, 0.5) var(--bg-void);
}

/* ============================================
   UTILITIES
   ============================================ */
.text-gradient {
    background: var(--gradient-primary);
    /* Fallback for browsers without gradient text support */
    color: var(--neon-cyan);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-glow {
    text-shadow: 0 0 20px rgba(0, 247, 255, 0.5);
}

.number-large {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 800;
    background: var(--gradient-gold);
    /* Fallback for browsers without gradient text support */
    color: var(--neon-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: var(--space-sm);
    animation: statusPulse 2s infinite;
}

.status-indicator.online {
    background: var(--neon-lime);
    box-shadow: var(--glow-lime);
}

.status-indicator.offline {
    background: #ff4444;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
    animation: none;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

/* Language Buttons */
.language-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.btn-language {
    width: 100%;
    padding: var(--space-lg);
    font-size: 1.1rem;
    background: var(--bg-elevated);
    color: var(--text-bright);
    border: 1px solid rgba(0, 247, 255, 0.25);
    box-shadow: 0 0 15px rgba(0, 247, 255, 0.1);
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn-language:hover {
    border-color: var(--neon-cyan);
    box-shadow: var(--glow-cyan);
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.btn-language:active {
    transform: translateY(0) scale(0.96);
}

/* Active language button indicator */
.btn-language[data-lang].active {
    border-color: var(--neon-cyan);
    box-shadow: var(--glow-cyan);
    background: rgba(0, 247, 255, 0.1);
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* Fallback for browsers without gap support */
    grid-column-gap: var(--space-md);
    grid-row-gap: var(--space-md);
    gap: var(--space-md);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    /* Fallback for browsers without gap support */
    grid-column-gap: var(--space-md);
    grid-row-gap: var(--space-md);
    gap: var(--space-md);
}

/* List Items */
.list-item {
    display: flex;
    align-items: center;
    padding: var(--space-md) 0;
    border-bottom: 1px solid rgba(0, 247, 255, 0.1);
    transition: all 0.2s ease;
}

.list-item:hover {
    background: rgba(0, 247, 255, 0.05);
    padding-left: var(--space-md);
    border-left: 3px solid var(--neon-cyan);
    margin-left: calc(-1 * var(--space-md));
}

.list-item:last-child {
    border-bottom: none;
}

/* ============================================
   TELEGRAM LOGIN CONTAINER & WIDGET (Safari Fix)
   ============================================ */
#telegram-login-container {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    -webkit-box-sizing: border-box !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    overflow: visible !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    padding: 0 !important;
    margin: 0 auto 20px !important;
    position: relative !important;
}

/* Telegram widget iframe and button - ensure proper sizing and centering */
#telegram-login-container iframe,
#telegram-login-container > script + iframe,
#telegram-login-container a[href*="telegram.org"],
#telegram-login-container > a {
    max-width: 100% !important;
    width: auto !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    -webkit-box-sizing: border-box !important;
    overflow: visible !important;
    display: block !important;
    margin: 0 auto !important;
    position: relative !important;
}

/* Telegram Login Widget fallback */
.telegram-login-fallback {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    word-wrap: break-word;
    -webkit-box-sizing: border-box;
}

.telegram-login-fallback a,
.telegram-login-fallback button {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-wrap: normal;
    display: block;
    margin: 0 auto;
}

/* Safari-specific fixes for widget and button overflow */
@supports (-webkit-appearance: none) {
    #telegram-login-container {
        -webkit-overflow-scrolling: touch;
        overflow-x: visible;
        overflow-y: visible;
    }
    
    #telegram-login-container iframe,
    #telegram-login-container > script + iframe,
    #telegram-login-container a[href*="telegram.org"] {
        -webkit-appearance: none;
        appearance: none;
        max-width: calc(100% - 20px) !important;
        margin: 0 auto !important;
    }
    
    .telegram-login-fallback {
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
    }
    
    .telegram-login-fallback a,
    .telegram-login-fallback button {
        -webkit-appearance: none;
        appearance: none;
        -webkit-tap-highlight-color: rgba(0, 255, 255, 0.3);
        touch-action: manipulation;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    :root {
        --space-lg: 16px;
        --space-xl: 24px;
    }
    
    .container {
        padding: var(--space-md);
    }
    
    .btn {
        padding: var(--space-sm) var(--space-md);
        min-height: 50px;
        font-size: 0.95rem;
    }
    
    .content {
        padding: var(--space-md);
    }
    
    /* Mobile Safari fixes for login screen */
    html {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
    
    body {
        height: auto !important;
        max-height: none !important;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .screen {
        max-height: none !important;
        overflow-y: visible !important;
    }
    
    #connect-screen {
        min-height: 100vh;
        min-height: -webkit-fill-available;
        overflow: visible !important;
        position: relative;
        max-height: none !important;
    }
    
    #connect-screen .container {
        min-height: 100vh;
        min-height: -webkit-fill-available;
        display: flex;
        flex-direction: column;
        overflow: visible;
    }
    
    #connect-screen .connect-wrapper {
        flex: 1;
        min-height: auto !important;
        max-height: none !important;
        justify-content: flex-start !important;
        padding-top: 20px !important;
        padding-bottom: 80px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        position: relative;
    }
    
    .connect-logo {
        margin-bottom: 25px !important;
        margin-top: 10px !important;
    }
    
    #connect-btn,
    #connect-google-btn {
        margin-bottom: 12px !important;
    }
    
    /* Ensure buttons are accessible and scrollable */
    #telegram-login-container {
        margin-bottom: 20px !important;
    }
}

/* ============================================
   FOCUS STATES (Accessibility)
   ============================================ */
*:focus-visible {
    outline: 2px solid var(--neon-cyan);
    outline-offset: 2px;
}

/* ============================================
   ANIMATIONS
   ============================================ */
/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   LOGO ANIMATIONS - GAMER STYLE
   ============================================ */
@keyframes hexRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes hexPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

@keyframes corePulse {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

@keyframes cornerPulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.3);
    }
}

@keyframes logoTextGlow {
    0%, 100% {
        text-shadow: 0 0 10px rgba(0, 247, 255, 0.8), 0 0 20px rgba(0, 247, 255, 0.4), 0 0 30px rgba(0, 247, 255, 0.2);
    }
    50% {
        text-shadow: 0 0 15px rgba(0, 247, 255, 1), 0 0 30px rgba(0, 247, 255, 0.6), 0 0 45px rgba(0, 247, 255, 0.3);
    }
}

@keyframes logoScan {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(200%);
    }
}

@keyframes underlineScan {
    0%, 100% {
        opacity: 0.3;
        transform: scaleX(0);
    }
    50% {
        opacity: 1;
        transform: scaleX(1);
    }
}

/* New animations for improved home screen logo */
@keyframes logoGlow {
    0%, 100% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

@keyframes lineExpand {
    0%, 100% {
        opacity: 0.3;
        transform: scaleX(0.5);
    }
    50% {
        opacity: 1;
        transform: scaleX(1);
    }
}

@keyframes dotPulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
        box-shadow: 0 0 10px rgba(0, 247, 255, 0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1.3);
        box-shadow: 0 0 20px rgba(0, 247, 255, 1), 0 0 30px rgba(0, 247, 255, 0.6);
    }
}

/* Premium Logo Styling - Clean, AI/Tech feel */
.premium-logo {
    /* Size: Larger for better visibility (300px) */
    max-width: 300px !important;
    width: auto !important;
    height: auto !important;
    max-height: 300px !important;
    
    /* No background, no container - sits directly on app background */
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    
    /* High quality image rendering */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: high-quality;
    image-rendering: auto;
    object-fit: contain;
    object-position: center;
    
    /* Premium soft cyan/teal glow - matches UI buttons */
    filter: 
        drop-shadow(0 0 8px rgba(0, 247, 255, 0.4))
        drop-shadow(0 0 16px rgba(0, 247, 255, 0.25))
        drop-shadow(0 0 24px rgba(0, 247, 255, 0.15))
        drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    
    /* Subtle depth - very soft drop shadow */
    box-shadow: none;
    
    /* No blend mode - keep original colors */
    mix-blend-mode: normal;
    
    /* Smooth transitions */
    transition: transform 0.3s ease, filter 0.3s ease;
    
    /* Prevent scaling artifacts */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
    /* High DPI support */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    
    /* Center alignment */
    display: block;
    margin: 0 auto;
}

/* Premium intro animation for login logo */
@keyframes premiumLogoIntro {
    0% {
        opacity: 0;
        transform: translateZ(0) scale(0.92) translateY(6px);
    }
    100% {
        opacity: 1;
        transform: translateZ(0) scale(1) translateY(0);
    }
}

/* Apply premium intro animation to login logo */
.login-logo {
    animation: premiumLogoIntro 700ms cubic-bezier(0.22, 1, 0.36, 1) 150ms backwards;
    /* backwards ensures initial state is applied before animation starts */
    /* animation-fill-mode: backwards ensures opacity: 0 before animation starts */
}

/* Hover effect - subtle scale */
.premium-logo:hover {
    transform: translateZ(0) scale(1.02);
    filter: 
        drop-shadow(0 0 10px rgba(0, 247, 255, 0.5))
        drop-shadow(0 0 20px rgba(0, 247, 255, 0.3))
        drop-shadow(0 0 30px rgba(0, 247, 255, 0.2))
        drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* Logo styling - ensure transparent background and high quality */
#main-logo,
#connect-main-logo {
    background: transparent !important;
    background-color: transparent !important;
    /* High quality image rendering - crisp and clear */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: high-quality;
    image-rendering: -moz-crisp-edges;
    image-rendering: pixelated;
    image-rendering: auto;
    /* Ensure image maintains aspect ratio and quality */
    object-fit: contain;
    object-position: center;
    /* Remove any white background that might appear */
    -webkit-background-clip: padding-box;
    background-clip: padding-box;
    /* Use CSS filter for glow effect - keep original colors */
    filter: drop-shadow(0 0 20px rgba(0, 247, 255, 0.5)) drop-shadow(0 0 40px rgba(0, 247, 255, 0.3));
    /* Ensure no blend mode that would darken the logo */
    mix-blend-mode: normal;
    /* Prevent image scaling artifacts */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* High DPI support */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
}

/* Ensure logo container doesn't add background */
#main-logo::before,
#connect-main-logo::before,
#main-logo::after,
#connect-main-logo::after {
    background: transparent !important;
    background-color: transparent !important;
}

/* Hide logo container background if exists */
#main-logo,
#connect-main-logo {
    background-image: none !important;
}

/* Note: If logo.png has white background, it needs to be edited in image editor */
/* CSS cannot perfectly remove white background - the PNG file itself must be transparent */

/* Staggered animations for content */
.content > * {
    animation: fadeInUp 0.4s ease-out backwards;
}

.content > *:nth-child(1) { animation-delay: 0.05s; }
.content > *:nth-child(2) { animation-delay: 0.1s; }
.content > *:nth-child(3) { animation-delay: 0.15s; }
.content > *:nth-child(4) { animation-delay: 0.2s; }
.content > *:nth-child(5) { animation-delay: 0.25s; }

/* ============================================
   NOTIFICATION ANIMATIONS
   ============================================ */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-30px) scale(0.9);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Notification styles */
.notification {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.notification:hover {
    transform: translateX(-50%) translateY(0) scale(1.02) !important;
    transition: transform 0.2s ease !important;
}

/* ============================================
   CONNECT SCREEN - SIMPLIFIED LOGIN BUTTONS
   ============================================ */
.connect-btn-main {
    width: 100%;
    max-width: 340px;
    padding: 18px 24px;
    font-size: 17px;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    position: relative;
    z-index: 10;
    -webkit-user-select: none;
    user-select: none;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    margin: 0 auto;
}

#connect-google-btn.connect-btn-main {
    background: linear-gradient(135deg, #4285f4, #34a853);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    box-shadow: 0 4px 15px rgba(66, 133, 244, 0.3);
}

#connect-btn.connect-btn-main {
    background: linear-gradient(135deg, rgba(0, 136, 204, 0.8), rgba(0, 180, 255, 0.6));
    border: 1px solid rgba(0, 180, 255, 0.4);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 136, 204, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

/* ============================================
   BOTTOM NAVIGATION BAR
   ============================================ */
#bottom-nav {
    -webkit-user-select: none;
    user-select: none;
}

.bottom-nav-item {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    outline: none;
}

.bottom-nav-item.active {
    color: #00f7ff !important;
    background: rgba(0, 247, 255, 0.1) !important;
}

.bottom-nav-item:active {
    transform: scale(0.92);
    transition: transform 0.1s;
}

/* Add padding to screens for bottom nav */
.screen:not(#connect-screen):not(#onboarding-screen) .container {
    padding-bottom: 80px;
}

/* ============================================
   ONBOARDING
   ============================================ */
.onboarding-step {
    animation: fadeInUp 0.4s ease-out;
}

/* ============================================
   PRO FEATURE BADGES
   ============================================ */
.pro-feature-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, #ff2d92, #bf00ff);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 1px;
    box-shadow: 0 2px 8px rgba(255, 45, 146, 0.5);
    z-index: 10;
    pointer-events: none;
    animation: proBadgePulse 2s ease-in-out infinite;
}

/* Pulse animation for Pro badges */
@keyframes proBadgePulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(255, 45, 146, 0.5); }
    50% { box-shadow: 0 2px 16px rgba(255, 45, 146, 0.8); }
}

/* Pro paywall modal */
#pro-paywall-modal > div {
    position: relative;
}

/* ============================================
   RETENTION & CONVERSION SYSTEM
   ============================================ */

/* Urgency Banner Animations */
@keyframes urgencyPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

@keyframes urgencyGlow {
    0%, 100% { box-shadow: 0 0 15px rgba(255, 45, 146, 0.3); }
    50% { box-shadow: 0 0 25px rgba(255, 45, 146, 0.6); }
}

@keyframes countdownPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes offerShine {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes urgencySlideIn {
    0% { transform: translateY(-20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

/* Retention Urgency Banner */
#retention-urgency-banner {
    animation: urgencySlideIn 0.5s ease;
}

#retention-urgency-banner.urgency-critical {
    animation: urgencyGlow 2s infinite, urgencySlideIn 0.5s ease;
}

#retention-urgency-banner.urgency-high {
    animation: urgencyPulse 3s infinite, urgencySlideIn 0.5s ease;
}

/* Special Offer Banner */
#special-offer-banner {
    animation: urgencySlideIn 0.5s ease 0.2s both;
}

.offer-discount-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 28px;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.offer-timer {
    font-family: 'Orbitron', monospace;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
}

/* Countdown Timer in Banner */
.retention-countdown {
    font-family: 'Orbitron', monospace;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 3px;
    animation: countdownPulse 2s infinite;
}

.retention-countdown.critical {
    color: #ff2d92;
    text-shadow: 0 0 20px rgba(255, 45, 146, 0.5);
}

.retention-countdown.high {
    color: #ff6600;
    text-shadow: 0 0 15px rgba(255, 102, 0, 0.4);
}

.retention-countdown.medium {
    color: #ffaa00;
}

/* What You'll Lose Section */
.lose-feature-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
}

.lose-feature-item .lose-icon {
    color: #ff4444;
    font-size: 14px;
    flex-shrink: 0;
}

/* Enhanced Upgrade Button Pulse */
.upgrade-btn-urgent {
    position: relative;
    overflow: hidden;
}

.upgrade-btn-urgent::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 70%
    );
    animation: offerShine 3s infinite;
}

/* Offer CTA Button */
.offer-cta-btn {
    background: linear-gradient(135deg, #ff2d92, #bf00ff) !important;
    border: none !important;
    color: white !important;
    font-weight: 700 !important;
    padding: 14px 24px !important;
    border-radius: 12px !important;
    font-size: 15px !important;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.offer-cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 45, 146, 0.4);
}

.offer-cta-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.15) 50%,
        transparent 70%
    );
    animation: offerShine 2.5s infinite;
}

/* ============================================
   RESPONSIVE - BOTTOM NAV
   ============================================ */
@media (max-width: 480px) {
    #bottom-nav {
        padding: 4px 0 6px 0;
        padding-bottom: env(safe-area-inset-bottom, 6px);
    }
    
    .bottom-nav-item {
        padding: 4px 8px !important;
        min-width: 48px !important;
    }
    
    .bottom-nav-item span:first-child {
        font-size: 20px !important;
    }
    
    .bottom-nav-item span:last-child {
        font-size: 9px !important;
    }
}

/* ============================================
   TELEGRAM WEBVIEW COMPATIBILITY FIXES
   Ensures the app renders correctly inside
   Telegram's built-in browser (WebView)
   ============================================ */

/* 🔒 FIX: Ensure screens are ALWAYS visible when active */
/* Telegram WebView may not trigger CSS transitions/animations correctly */
.screen.active {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

/* 🔒 FIX: Bottom padding for content when bottom nav is visible */
/* Prevents content from being hidden behind the bottom navigation bar */
.container {
    padding-bottom: 80px;
}

/* 🔒 FIX: Reduced motion for Telegram WebView performance */
/* Many animations can cause lag in Telegram's WebView engine */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}