/* CSS Variables for Mobile Optimization */
:root {
  /* Base measurements */
  --vh: 1vh; /* Dynamic viewport height */
  --vw: 1vw; /* Dynamic viewport width */
  
  /* Safe areas for notched devices */
  --safe-area-inset-top: env(safe-area-inset-top, 0px);
  --safe-area-inset-right: env(safe-area-inset-right, 0px);
  --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-inset-left: env(safe-area-inset-left, 0px);
  
  /* Font scaling (set by FontScalingSystem) */
  --font-scale: 1.0;
  --base-font-size: 16px;
  --heading-font-size: 24px;
  --small-font-size: 14px;
  --button-font-size: 16px;
  --caption-font-size: 12px;
  --large-font-size: 20px;
  --xlarge-font-size: 24px;
  
  /* Touch targets */
  --min-touch-target: 44px;
  --adaptive-touch-padding: 0px;
  
  /* Animations and motion */
  --animation-duration: 300ms;
  --transition-duration: 200ms;
  --shake-intensity: 1.0;
  
  /* =================================================================
     CENTRALIZED COLOR SYSTEM
     ================================================================= */
  
  /* Primary Brand Colors */
  --color-primary: #FFD700;           /* Gold - Primary brand color */
  --color-primary-light: #FFDF40;     /* Lighter gold variant */
  --color-primary-dark: #B8860B;      /* Darker gold variant */
  
  /* Secondary Brand Colors */
  --color-secondary: #4CAF50;         /* Green - Player/success color */
  --color-secondary-light: #66BB6A;   /* Light green */
  --color-secondary-dark: #388E3C;    /* Dark green */
  
  /* Background Colors */
  --color-bg-primary: #1a1a2e;        /* Main dark background */
  --color-bg-secondary: #16213e;      /* Secondary dark background */
  --color-bg-tertiary: #0f3460;       /* Tertiary background */
  --color-bg-modal: #2a2a2a;          /* Modal backgrounds */
  --color-bg-overlay: rgba(0, 0, 0, 0.8); /* Dark overlay */
  --color-bg-card: rgba(255, 255, 255, 0.1); /* Card backgrounds */
  
  /* Text Colors */
  --color-text-primary: #ffffff;      /* Primary text (white) */
  --color-text-secondary: #cccccc;    /* Secondary text (light gray) */
  --color-text-tertiary: #aaaaaa;     /* Tertiary text (medium gray) */
  --color-text-muted: #888888;        /* Muted text (dark gray) */
  --color-text-dark: #333333;         /* Dark text for light backgrounds */
  
  /* Status Colors */
  --color-success: #4CAF50;           /* Success states */
  --color-success-light: #66BB6A;     /* Light success */
  --color-warning: #FF9800;           /* Warning states */
  --color-warning-light: #FFB74D;     /* Light warning */
  --color-error: #ff6b6b;             /* Error states */
  --color-error-light: #FF8A80;       /* Light error */
  --color-error-dark: #dc3545;        /* Dark error */
  --color-info: #2196F3;              /* Info states */
  --color-info-light: #64B5F6;        /* Light info */
  
  /* Game Element Colors */
  --color-player: #4CAF50;            /* Player color */
  --color-bot-a: #FF5722;             /* Bot A color */
  --color-bot-b: #2196F3;             /* Bot B color */
  --color-bot-c: #FF9800;             /* Bot C color */
  
  /* Power-up Colors */
  --color-powerup-speed: #FFD700;     /* Speed power-up */
  --color-powerup-magnet: #2196F3;    /* Magnet power-up */
  --color-powerup-shield: #4CAF50;    /* Shield power-up */
  --color-powerup-multiplier: #FF9800; /* Score multiplier */
  --color-powerup-spawn: #9C27B0;     /* Spawn boost */
  
  /* Border Colors */
  --color-border-primary: rgba(255, 255, 255, 0.2); /* Primary borders */
  --color-border-secondary: rgba(255, 255, 255, 0.1); /* Secondary borders */
  --color-border-focus: #007AFF;      /* Focus borders */
  --color-border-error: #ff6b6b;      /* Error borders */
  --color-border-success: #4CAF50;    /* Success borders */
  
  /* Social Platform Colors */
  --color-social-twitter: #1DA1F2;    /* Twitter blue */
  --color-social-discord: #5865F2;    /* Discord purple */
  --color-social-facebook: #1877F2;   /* Facebook blue */
  --color-social-reddit: #FF4500;     /* Reddit orange */
  --color-social-generic: #6B7280;    /* Generic social */
  
  /* Theme Variants (for theme switching) */
  --color-theme-neon-bg: #0a0a0a;     /* Neon theme background */
  --color-theme-neon-player: #00ffff; /* Neon theme player */
  --color-theme-gold-bg: #2a1810;     /* Gold theme background */
  --color-theme-ice-bg: #0a1628;      /* Ice theme background */
  --color-theme-ice-player: #60a5fa;  /* Ice theme player */
  --color-theme-fire-bg: #3a0a0a;     /* Fire theme background */
  --color-theme-fire-player: #ff4444; /* Fire theme player */
  
  /* Opacity Variants (for consistency) */
  --opacity-light: 0.1;               /* Light transparency */
  --opacity-medium: 0.3;              /* Medium transparency */
  --opacity-heavy: 0.6;               /* Heavy transparency */
  --opacity-overlay: 0.8;             /* Overlay transparency */
  
  /* Colors for accessibility */
  --focus-color: var(--color-border-focus);
  --focus-outline-width: 2px;
  --high-contrast-ratio: 1.0;
  
  /* =================================================================
     CENTRALIZED FONT SYSTEM
     ================================================================= */
  
  /* Font Families */
  --font-family-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-family-secondary: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --font-family-monospace: 'Courier New', monospace;
  --font-family-display: var(--font-family-primary); /* For headings */
  --font-family-body: var(--font-family-primary);    /* For body text */
  --font-family-ui: var(--font-family-primary);      /* For UI elements */
  --font-family-code: var(--font-family-monospace);  /* For code/technical text */
  --font-family-canvas: Arial, sans-serif;           /* For canvas text rendering */
  
  /* Font Weights */
  --font-weight-light: 300;
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-black: 900;
  
  /* Line Heights */
  --line-height-tight: 1.1;
  --line-height-normal: 1.4;
  --line-height-relaxed: 1.6;
  --line-height-loose: 1.8;
}

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

body {
    font-family: var(--font-family-body);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    overflow: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    margin: 0;
    padding: 0;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    width: 100vw;
    width: calc(var(--vw, 1vw) * 100);
    font-size: var(--base-font-size, 16px);
    
    /* Safe area support for notched devices */
    padding-top: var(--safe-area-inset-top);
    padding-right: var(--safe-area-inset-right);
    padding-bottom: var(--safe-area-inset-bottom);
    padding-left: var(--safe-area-inset-left);
}

#gameContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
}

#gameCanvas {
    display: block !important;
    background: #2a2a2a;
    cursor: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    z-index: 1;
}

.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    text-align: center;
    box-sizing: border-box;
    padding: 20px;
    margin: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

/* Force end screen display override */
#endScreen.screen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.9) !important;
    z-index: 10000 !important;
    visibility: visible !important;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Force display when JavaScript sets it */
#endScreen.screen[style*="display: flex"],
#endScreen.screen[style*="display:flex"] {
    display: flex !important;
}


/* Show end screen when active - Force override all other styles */
#endScreen.screen.show,
#endScreen.screen[style*="display: flex"],
#endScreen[style*="display: flex"] {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 10000 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    justify-content: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
}

/* Allow body scroll when end screen is shown - fallback for older browsers */
body.end-screen-active {
    overflow: auto !important;
}

/* Allow body scroll when end screen is shown - modern browsers */
body:has(#endScreen[style*="display: flex"]) {
    overflow: auto !important;
}

/* Ensure end screen content is visible */
#endScreen .start-content {
    z-index: 10001 !important;
    position: relative !important;
}

.start-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

.start-bg-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, transparent 0%, rgba(26, 26, 46, 0.8) 100%);
    z-index: 1;
    pointer-events: none;
}

.start-content {
    position: relative;
    z-index: 10;
    padding: 20px;
    max-width: 1200px;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Mobile-First Layout */
.mobile-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    max-height: 100vh;
    height: 100vh;
    padding: max(15px, env(safe-area-inset-top)) 15px max(15px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    gap: clamp(8px, 2vh, 15px);
    overflow-y: auto;
    overflow-x: hidden;
}

.desktop-layout {
    display: none;
}

.game-title,
.game-title.compact {
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;

  /* Gradient text fix */
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;

  /* Rendering improvements */
  -webkit-text-fill-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;

  /* Avoid fractional scaling blur */
  font-size: clamp(1.8rem, 3.5vw, 2.2rem);
  transform: translateZ(0); /* Force GPU crispness */

  /* Subtle shadow */
  text-shadow: 0 0 8px rgba(102, 126, 234, 0.25);
}

/* Title favicon styling */
.title-favicon {
  display: inline-block;
  height: 1em;
  width: auto;
  vertical-align: middle;
  margin: 0 0.2em;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s ease;
}

.title-favicon:hover {
  transform: scale(1.1) rotate(5deg);
}

.game-subtitle {
    font-size: 1.2rem;
    color: #aaa;
    margin-bottom: 30px;
    text-align: center;
}

/* Mobile subtitle adjustments */
@media (max-width: 767px) {
    .game-subtitle {
        font-size: clamp(0.9rem, 3vw, 1.1rem);
        margin-bottom: 20px;
    }
}

/* Height-based responsive breakpoints for compact screens */
@media (max-height: 600px) {
    .mobile-layout {
        gap: clamp(4px, 1vh, 8px);
        padding: max(8px, env(safe-area-inset-top)) 15px max(8px, env(safe-area-inset-bottom));
    }
    
    .game-title.compact {
        font-size: clamp(1.3rem, 3vw, 1.6rem);
        margin: clamp(5px, 1vh, 10px) 0;
        line-height: 1.1;
    }
    
    .game-subtitle {
        font-size: clamp(0.75rem, 2.5vw, 0.9rem);
        margin-bottom: clamp(8px, 1.5vh, 15px);
    }
    
    .title-favicon {
        height: 0.8em;
        margin: 0 0.15em;
    }
}

@media (max-height: 500px) {
    .mobile-layout {
        gap: clamp(2px, 0.5vh, 5px);
        padding: max(5px, env(safe-area-inset-top)) 10px max(5px, env(safe-area-inset-bottom));
        justify-content: space-between;
    }
    
    .game-title.compact {
        font-size: clamp(1.1rem, 2.8vw, 1.3rem);
        margin: clamp(2px, 0.5vh, 5px) 0;
        line-height: 1;
    }
    
    .game-subtitle {
        font-size: clamp(0.65rem, 2vw, 0.75rem);
        margin-bottom: clamp(3px, 0.5vh, 8px);
    }
    
    .title-favicon {
        height: 0.7em;
        margin: 0 0.1em;
    }
    
    .play-btn {
        min-height: 35px;
        font-size: clamp(12px, 2.5vw, 14px);
        padding: clamp(6px, 1vh, 8px) clamp(12px, 3vw, 16px);
    }
    
    .settings-btn {
        min-height: 30px;
        font-size: clamp(11px, 2.5vw, 13px);
        padding: clamp(4px, 0.8vh, 6px) clamp(8px, 2vw, 12px);
    }
}

/* Combined width+height breakpoints for landscape phones and ultra-compact screens */
@media (max-width: 640px) and (max-height: 400px) {
    .mobile-layout {
        gap: clamp(2px, 0.5vh, 4px);
        padding: max(5px, env(safe-area-inset-top)) 8px max(5px, env(safe-area-inset-bottom));
        justify-content: space-between;
    }
    
    .game-title.compact {
        font-size: clamp(1rem, 2.5vw, 1.1rem);
        margin: 2px 0;
        line-height: 0.9;
    }
    
    .game-subtitle {
        font-size: clamp(0.6rem, 1.8vw, 0.7rem);
        margin-bottom: 2px;
    }
    
    .title-favicon {
        height: 0.6em;
        margin: 0 0.08em;
    }
    
    .main-actions {
        gap: clamp(3px, 0.8vh, 6px);
    }
    
    .mobile-actions {
        gap: clamp(2px, 0.5vh, 4px);
    }
    
    .quick-stats {
        gap: clamp(5px, 1vh, 8px);
        margin: clamp(3px, 0.8vh, 6px) 0;
    }
    
    .play-btn {
        min-height: 28px;
        font-size: clamp(10px, 2vw, 12px);
        padding: clamp(4px, 0.5vh, 6px) clamp(8px, 2vw, 12px);
    }
    
    .settings-btn {
        min-height: 24px;
        font-size: clamp(9px, 2vw, 11px);
        padding: clamp(2px, 0.4vh, 4px) clamp(6px, 1.5vw, 8px);
    }
    
    .start-footer {
        margin-top: clamp(3px, 0.8vh, 6px);
        padding: clamp(3px, 0.8vh, 6px) 0;
        font-size: 11px;
    }
}

/* Ultra-small devices (iPhone SE, older Android) */
@media (max-width: 360px) and (max-height: 640px) {
    .mobile-layout {
        gap: clamp(3px, 0.8vh, 6px);
    }
    
    .game-title.compact {
        font-size: clamp(1.2rem, 3vw, 1.4rem);
        margin: clamp(3px, 0.8vh, 6px) 0;
    }
    
    .game-subtitle {
        font-size: clamp(0.7rem, 2.2vw, 0.8rem);
        margin-bottom: clamp(4px, 1vh, 8px);
    }
    
    .name-input-mobile {
        font-size: clamp(12px, 2.5vw, 14px);
        padding: clamp(6px, 1.5vh, 10px) clamp(8px, 2vw, 12px);
        margin: clamp(4px, 1vh, 8px) 0;
    }
    
    .quick-stat {
        font-size: clamp(11px, 2.5vw, 13px);
        padding: clamp(4px, 1vh, 8px);
    }
}

.title-letters {
    display: inline-block;
}

.letter {
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

.letter:nth-child(1) { animation-delay: 0.1s; }
.letter:nth-child(2) { animation-delay: 0.2s; }
.letter:nth-child(3) { animation-delay: 0.3s; }
.letter:nth-child(4) { animation-delay: 0.4s; }
.letter:nth-child(5) { animation-delay: 0.5s; }

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

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

.main-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin: 20px 0;
    width: 100%;
    max-width: 280px;
}

.play-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    color: white;
    padding: clamp(14px, 4vw, 18px) clamp(25px, 8vw, 35px);
    border-radius: clamp(25px, 7vw, 30px);
    cursor: pointer;
    font-size: clamp(1.1rem, 3.5vw, 1.3rem);
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    min-width: clamp(200px, 65vw, 280px);
    min-height: 48px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.3px;
    max-width: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.play-btn:active {
    transform: translateY(0);
}

.play-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.play-btn:hover::before {
    left: 100%;
}

.play-btn.primary {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
    font-size: clamp(1.1rem, 3.5vw, 1.3rem);
    min-height: 52px;
}

.play-btn.primary:hover {
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
}

.play-btn.secondary {
    background: linear-gradient(135deg, #FFB74D, #FF9800);
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.2);
    min-height: 46px;
    font-size: clamp(1rem, 3vw, 1.15rem);
}

.play-btn.secondary:hover {
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.6);
}

.play-btn.large {
    font-size: 1.4rem;
    padding: 20px 40px;
    min-width: 200px;
}

.play-btn.small {
    font-size: 1rem;
    padding: 12px 24px;
    min-width: 120px;
}

.btn-text {
    display: block;
    font-weight: bold;
}

.btn-subtext {
    display: block;
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 5px;
}

.multi-btns {
    display: flex;
    gap: 16px;
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
}

.name-input-mobile,
.name-input-desktop {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 5px;
    color: white;
    padding: 12px;
    font-size: 16px;
    text-align: center;
    transition: border-color 0.3s ease;
}

.name-input-mobile:focus,
.name-input-desktop:focus {
    outline: none;
    border-color: #667eea;
}

.name-input-mobile {
    width: clamp(220px, 75vw, 280px);
    margin: 16px 0;
    padding: clamp(16px, 4vw, 18px);
    font-size: clamp(16px, 3.5vw, 18px);
    border-radius: clamp(22px, 6vw, 25px);
    min-height: 48px;
    transition: all 0.3s ease;
}

.name-input-desktop {
    width: 250px;
    padding: 15px;
}

.quick-stats {
    display: flex;
    gap: clamp(25px, 10vw, 45px);
    margin: clamp(15px, 4vh, 25px) 0;
    padding: clamp(15px, 4vw, 20px);
    background: rgba(255, 255, 255, 0.08);
    border-radius: clamp(18px, 5vw, 22px);
    backdrop-filter: blur(10px);
    flex-wrap: wrap;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.quick-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-value {
    font-size: clamp(1.6rem, 4.5vw, 2rem);
    font-weight: bold;
    color: #FFD700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    animation: glow 2s ease-in-out infinite alternate;
    font-family: 'Courier New', monospace;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-icon {
    font-size: 1.2rem;
    margin-bottom: 2px;
}

@keyframes glow {
    from {
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }
    to {
        text-shadow: 0 0 20px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.6);
    }
}

.stat-label {
    font-size: clamp(0.85rem, 3vw, 1rem);
    color: #ccc;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.settings-btn {
    background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: clamp(12px, 3vh, 16px) clamp(20px, 5vw, 25px);
    border-radius: clamp(22px, 6vw, 25px);
    cursor: pointer;
    font-size: clamp(14px, 3.5vw, 16px);
    margin: 8px 0;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    backdrop-filter: blur(5px);
    min-height: 44px;
    min-width: clamp(200px, 70vw, 260px);
}

.settings-btn:hover {
    background: rgba(255,255,255,0.2);
}

.mobile-actions {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 2vh, 12px);
    align-items: center;
    margin: clamp(15px, 4vh, 25px) 0;
    width: 100%;
    max-width: clamp(250px, 85vw, 300px);
}

.mobile-actions .settings-btn {
    width: 100%;
    max-width: clamp(220px, 75vw, 260px);
    padding: clamp(10px, 2.5vh, 14px) clamp(15px, 4vw, 20px);
    margin: clamp(4px, 1vh, 6px) 0;
    font-size: clamp(13px, 3.5vw, 15px);
    text-align: center;
    border-radius: clamp(20px, 5vw, 22px);
    background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.08));
    border: 1px solid rgba(255,255,255,0.3);
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-weight: 500;
    line-height: 1.3;
}

.mobile-actions .settings-btn:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.2), rgba(255,255,255,0.1));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.mobile-actions .settings-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Enhanced social bar for desktop */
.social-bar {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 30px 0;
    flex-wrap: wrap;
}

.social-btn.compact {
    font-size: 24px;
    padding: 15px;
    min-width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.08));
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    backdrop-filter: blur(5px);
}

.social-btn.compact:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.2), rgba(255,255,255,0.1));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.stat-card {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .stat-value {
    font-size: 2rem;
    color: #FFD700;
}

.stat-card .stat-label {
    font-size: clamp(0.85rem, 3vw, 1rem);
    color: #ccc;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.social-bar {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 20px 0;
}

.social-btn.compact {
    font-size: 20px;
    padding: 10px;
    min-width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    cursor: pointer;
    transition: background 0.3s ease;
}

.social-btn.compact:hover {
    background: rgba(255,255,255,0.2);
}

/* Footer links styling */
.start-footer {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    padding: 15px 20px;
    width: 100%;
    font-size: 14px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.footer-link {
    color: rgba(255, 255, 255, 0.7) !important;
    text-decoration: none;
    font-size: 14px !important;
    font-weight: normal;
    transition: color 0.3s ease;
}

.footer-link:hover {
    color: rgba(255, 255, 255, 1) !important;
    text-decoration: underline;
}

.footer-separator {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: normal;
}

.settings-compact {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.setting-row-compact {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
    font-size: 0.9rem;
}

.setting-row-compact label {
    color: #aaa;
}

.setting-row-compact select,
.setting-row-compact input[type="range"] {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 3px;
    color: white;
    padding: 5px;
}

.volume-controls-compact {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.volume-controls-compact label {
    color: #aaa;
    font-size: 0.8rem;
}

/* Desktop Layout */
@media (min-width: 768px) {
    .mobile-layout {
        display: none;
    }
    
    .desktop-layout {
        display: flex;
        flex-direction: column;
        width: 100%;
        max-width: 1200px;
        height: 100vh;
        padding: 40px;
        box-sizing: border-box;
    }
    
    .desktop-header {
        text-align: center;
        margin-bottom: 40px;
    }
    
    .game-title {
        font-size: 3.5rem;
        margin-bottom: 10px;
    }
    
    .desktop-main {
        display: grid;
        grid-template-columns: 1fr 2fr 1fr;
        gap: 40px;
        align-items: start;
        flex: 1;
    }
    
    .left-column {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    
    .center-column {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .right-column {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }
    
    .main-actions-desktop {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    
    .multi-btns-desktop {
        display: flex;
        gap: 15px;
    }
    
    .name-input-desktop {
        width: 250px;
        padding: 15px;
        font-size: 16px;
    }
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95), rgba(22, 33, 62, 0.95));
    margin: 10vh auto;
    padding: 20px;
    border-radius: 25px;
    width: 90%;
    max-width: 500px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 
        0 25px 60px rgba(0,0,0,0.6),
        0 0 100px rgba(102, 126, 234, 0.1),
        inset 0 1px 0 rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    backdrop-filter: blur(25px);
    animation: modalSlideIn 0.4s ease-out;
    position: relative;
    z-index: 2001;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

.modal-content::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.03) 0%, transparent 70%);
    animation: modalGlow 3s ease-in-out infinite alternate;
}

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

@keyframes modalGlow {
    from {
        opacity: 0.3;
    }
    to {
        opacity: 0.6;
    }
}

/* Modal structure for proper scrolling */
.modal-header {
    margin-bottom: 20px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 2003;
}

/* Simple scroll container */
.achievements-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 2002;
    pointer-events: auto;
}

/* Scrollbar styling for new container */
.achievements-scroll-container::-webkit-scrollbar {
    width: 12px !important;
    -webkit-appearance: none !important;
    z-index: 2003 !important;
}

.achievements-scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.2) !important;
    border-radius: 6px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.achievements-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.6) !important;
    border-radius: 6px !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    min-height: 20px !important;
}

.achievements-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.8) !important;
}

.achievements-scroll-container::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.9) !important;
}

/* Desktop/Web view specific fixes */
@media (min-width: 768px) {
    .modal-content {
        height: 80vh;
        margin: 10vh auto;
    }
    
    .achievements-scroll-container {
        /* Ensure scrollbar is always visible on desktop */
        scrollbar-width: auto;
        overflow-y: scroll;
    }
    
    .achievements-scroll-container::-webkit-scrollbar {
        width: 14px !important;
        display: block !important;
    }
    
    .achievements-scroll-container::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.7) !important;
        cursor: pointer;
    }
    
    .achievements-scroll-container::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.9) !important;
    }
}

/* Scroll indicator animation */
@keyframes pulse {
    0% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.7; transform: scale(1); }
}

/* Additional scroll containers matching achievements pattern */
.challenges-scroll-container,
.reset-scroll-container,
.share-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 2002;
    pointer-events: auto;
}

/* Scrollbar styling for additional containers */
.challenges-scroll-container::-webkit-scrollbar,
.reset-scroll-container::-webkit-scrollbar,
.share-scroll-container::-webkit-scrollbar {
    width: 12px !important;
    -webkit-appearance: none !important;
    z-index: 2003 !important;
}

.challenges-scroll-container::-webkit-scrollbar-track,
.reset-scroll-container::-webkit-scrollbar-track,
.share-scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.2) !important;
    border-radius: 6px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.challenges-scroll-container::-webkit-scrollbar-thumb,
.reset-scroll-container::-webkit-scrollbar-thumb,
.share-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.6) !important;
    border-radius: 6px !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    min-height: 20px !important;
}

.challenges-scroll-container::-webkit-scrollbar-thumb:hover,
.reset-scroll-container::-webkit-scrollbar-thumb:hover,
.share-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.8) !important;
}

.challenges-scroll-container::-webkit-scrollbar-thumb:active,
.reset-scroll-container::-webkit-scrollbar-thumb:active,
.share-scroll-container::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.9) !important;
}

/* Desktop/Web view specific fixes for additional containers */
@media (min-width: 768px) {
    .challenges-scroll-container,
    .reset-scroll-container,
    .share-scroll-container {
        /* Ensure scrollbar is always visible on desktop */
        scrollbar-width: auto;
        overflow-y: scroll;
    }
    
    .challenges-scroll-container::-webkit-scrollbar,
    .reset-scroll-container::-webkit-scrollbar,
    .share-scroll-container::-webkit-scrollbar {
        width: 14px !important;
        display: block !important;
    }
    
    .challenges-scroll-container::-webkit-scrollbar-thumb,
    .reset-scroll-container::-webkit-scrollbar-thumb,
    .share-scroll-container::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.7) !important;
        cursor: pointer;
    }
    
    .challenges-scroll-container::-webkit-scrollbar-thumb:hover,
    .reset-scroll-container::-webkit-scrollbar-thumb:hover,
    .share-scroll-container::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.9) !important;
    }
}

.achievement-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.achievement-item.unlocked {
    background: rgba(46, 204, 113, 0.1);
    border-color: rgba(46, 204, 113, 0.3);
}

.achievement-item.locked {
    opacity: 0.6;
}

.achievement-icon {
    font-size: 2em;
    margin-right: 12px;
    min-width: 50px;
    text-align: center;
}

.achievement-info {
    flex-grow: 1;
}

.achievement-name {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 5px;
    color: #fff;
}

.achievement-description {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
}

.achievement-progress {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2ecc71, #27ae60);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    right: 0;
    top: -20px;
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.7);
}

.achievement-checkmark {
    font-size: 1.5em;
    margin-left: 15px;
}

.close-btn {
    color: rgba(255,255,255,0.7);
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 10;
}

.close-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.2);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(255,255,255,0.1);
}

.close {
    color: rgba(255,255,255,0.7);
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 10;
}

.close:hover {
    color: #fff;
    background: rgba(255,255,255,0.2);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(255,255,255,0.1);
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.volume-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Comprehensive Mobile Responsive Breakpoints */
@media (max-width: 480px) {
    .mobile-layout {
        padding: max(10px, env(safe-area-inset-top)) 15px max(10px, env(safe-area-inset-bottom));
        gap: clamp(6px, 1.5vh, 10px);
    }
    
    .game-title.compact {
        font-size: clamp(1.4rem, 4vw, 1.7rem);
        margin: clamp(5px, 1vh, 10px) 0;
    }
    
    .main-actions {
        gap: clamp(8px, 2vh, 12px);
    }
    
    .mobile-actions {
        gap: clamp(6px, 1.5vh, 10px);
    }
    
    .quick-stats {
        gap: clamp(10px, 3vh, 15px);
        margin: clamp(8px, 2vh, 12px) 0;
    }
    
    /* Improve general mobile readability */
    .play-btn {
        min-height: 45px;
        font-size: clamp(14px, 3.5vw, 16px);
        padding: clamp(8px, 2.5vh, 12px) clamp(16px, 5vw, 22px);
        min-width: clamp(140px, 45vw, 180px);
        touch-action: manipulation;
    }
    
    /* Achievement modal mobile optimization */
    .modal-content {
        height: 80vh;
        margin: 10vh auto;
        padding: 15px;
    }
    
    .achievements-scroll-container {
        padding-right: 5px;
    }
    
    .achievement-item {
        margin-bottom: 8px;
    }
    
    .achievement-item {
        padding: 12px;
        flex-direction: column;
        text-align: center;
        align-items: center;
    }
    
    .achievement-icon {
        font-size: 2em;
        margin-right: 0;
        margin-bottom: 10px;
        min-width: auto;
    }
    
    .achievement-info {
        text-align: center;
    }
    
    .achievement-name {
        font-size: 1em;
        margin-bottom: 8px;
    }
    
    .achievement-description {
        font-size: 0.85em;
        line-height: 1.3;
    }
    
    .achievement-checkmark {
        margin-left: 0;
        margin-top: 10px;
    }

    /* Ensure text is always readable on mobile */
    body, .modal-content {
        font-size: 16px;
        line-height: 1.4;
    }
    
    /* Mobile leaderboard improvements */
    .leaderboard-item {
        padding: 12px 15px;
        margin: 8px 0;
        font-size: 1rem;
    }
    
    .leaderboard-name {
        font-size: 1.1rem;
        font-weight: bold;
    }
    
    .leaderboard-stats {
        font-size: 1rem;
        margin-top: 4px;
    }
    
    .multi-btns {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .multi-btns .play-btn {
        min-width: clamp(140px, 45vw, 180px);
    }
    
    .quick-stats {
        gap: clamp(15px, 6vw, 25px);
    }
    
    .modal-content {
        margin: 10% auto;
        padding: clamp(20px, 4vh, 35px);
        border-radius: 20px;
        width: 95%;
        max-width: 400px;
    }
    
    .close {
        top: 15px;
        right: 20px;
        font-size: 28px;
        width: 35px;
        height: 35px;
    }
    
    .stat-value {
        font-size: clamp(1.2rem, 3.5vw, 1.6rem);
    }
    
    .mobile-actions {
        gap: clamp(6px, 1.5vh, 10px);
        margin: clamp(12px, 3vh, 20px) 0;
    }
    
    .mobile-actions .settings-btn {
        font-size: clamp(12px, 3.5vw, 14px);
        padding: clamp(8px, 2vh, 12px) clamp(12px, 3vw, 16px);
    }
    
    /* Mobile footer adjustments */
    .start-footer {
        margin-top: 20px;
        padding: 15px 0;
        flex-direction: row;
        gap: 15px;
    }
    
    .footer-link {
        font-size: 13px;
        padding: 8px 15px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
        cursor: pointer;
    }
    
    .footer-separator {
        display: inline;
    }
}

@media (max-width: 375px) {
    .mobile-layout {
        padding: max(8px, env(safe-area-inset-top)) 12px max(8px, env(safe-area-inset-bottom));
    }
    
    .game-title.compact {
        font-size: 1.4rem;
    }
    
    .play-btn {
        font-size: 13px;
        padding: 8px 16px;
        min-width: 130px;
    }
    
    .name-input-mobile {
        width: clamp(180px, 65vw, 220px);
        font-size: 14px;
    }
}

@media (max-width: 320px) {
    .mobile-layout {
        padding: max(5px, env(safe-area-inset-top)) 10px max(5px, env(safe-area-inset-bottom));
        gap: 8px;
    }
    
    .game-title.compact {
        font-size: 1.3rem;
        margin: 8px 0;
    }
    
    .play-btn {
        font-size: 12px;
        padding: 6px 14px;
        min-width: 120px;
    }
    
    .quick-stats {
        gap: 12px;
        padding: 8px;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
}

@media (max-height: 600px) {
    .mobile-layout {
        gap: 8px;
    }
    
    .game-title.compact {
        font-size: clamp(1.4rem, 4vh, 1.7rem);
        margin: 8px 0;
    }
    
    .play-btn {
        font-size: clamp(12px, 2.5vh, 14px);
        padding: clamp(6px, 2vh, 10px) clamp(12px, 4vw, 18px);
    }
    
    .mobile-actions {
        gap: clamp(4px, 1vh, 8px);
        margin: clamp(8px, 2vh, 15px) 0;
    }
}

/* Ensure desktop buttons are always visible */
@media (min-width: 768px) {
    .desktop-layout {
        display: flex !important;
        visibility: visible !important;
    }
    
    .mobile-layout {
        display: none !important;
    }
}

/* Fallback for very small screens */
@media (max-width: 280px) {
    .mobile-layout {
        padding: 5px;
    }
    
    .game-title.compact {
        font-size: 1.2rem;
    }
    
    .play-btn {
        font-size: 11px;
        min-width: 110px;
    }
}

@media (min-width: 1200px) {
    .desktop-main {
        grid-template-columns: 1fr 1.5fr 1fr;
    }
}

/* Victory Screen Enhanced Styles */
.victory-header {
    text-align: center;
    margin-bottom: 30px;
    position: relative;
    z-index: 15;
}

.trophy-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: trophyBounce 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.6));
}

@keyframes trophyBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-10px) scale(1.1); }
}

.victory-title {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.control-hints {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-hints.show {
    opacity: 1;
}

.control-hints.mobile {
    display: none;
}

@media (max-width: 768px) {
    .control-hints {
        display: none;
    }
}

@media (min-width: 769px) {
    .control-hints {
        display: block;
    }
}

.victory-stats {
    margin: 30px 0;
    text-align: center;
}

.victory-score-display {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 20px;
    padding: 30px;
    backdrop-filter: blur(10px);
    max-width: 400px;
    margin: 0 auto;
}

.score-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 1.3rem;
    margin-bottom: 15px;
}

.score-text strong, .tile-text strong {
    color: #FFD700;
    font-weight: bold;
    font-size: 1.5rem;
}

.personal-best-badge {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
}

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

.leaderboard-enhanced {
    margin: 30px 0;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    margin: 8px 0;
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.leaderboard-row.player-highlight {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 165, 0, 0.1));
    border: 1px solid rgba(255, 215, 0, 0.4);
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.3);
    transform: scale(1.02);
}

.leaderboard-row.player-highlight::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.1), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.leaderboard-rank {
    font-size: 1.2rem;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.leaderboard-name {
    flex: 1;
    margin: 0 15px;
    font-weight: 500;
}

.leaderboard-stats {
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
    color: #ccc;
}

.victory-actions {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    margin-top: 40px;
}

.victory-primary {
    font-size: 1.4rem;
    padding: 20px 40px;
    min-width: 250px;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.3);
    animation: victoryPulse 3s ease-in-out infinite;
}

@keyframes victoryPulse {
    0%, 100% { box-shadow: 0 8px 25px rgba(76, 175, 80, 0.3); }
    50% { box-shadow: 0 8px 35px rgba(76, 175, 80, 0.6); }
}

.victory-secondary-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.victory-secondary {
    min-width: 120px;
    padding: 15px 25px;
    font-size: 1.1rem;
}

.performance-feedback {
    font-size: 1.1rem;
    color: #4CAF50;
    margin-top: 10px;
    animation: fadeInUp 1s ease-out;
}

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

/* Confetti Animation */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #FFD700;
    animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #endScreen .start-content {
        min-height: auto;
        justify-content: flex-start;
        padding: 15px 20px 40px;
        margin-top: 20px;
    }
    
    .victory-header {
        margin-bottom: 20px;
    }
    
    .victory-title {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }
    
    .trophy-icon {
        font-size: 2.5rem;
        margin-bottom: 10px;
    }
    
    .victory-score-display {
        margin: 15px 10px;
        padding: 15px;
    }
    
    .score-breakdown {
        font-size: 1.1rem;
        gap: 8px;
    }
    
    .victory-stats {
        margin: 20px 0;
    }
    
    .victory-actions {
        margin-top: 20px;
        gap: 15px;
        padding: 0 10px;
    }
    
    .victory-primary {
        font-size: 1.2rem;
        padding: 14px 30px;
        min-width: 280px;
        max-width: 90%;
        min-height: 50px;
    }
    
    .victory-secondary-actions {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0 5px;
        max-width: 100%;
    }
    
    .victory-secondary {
        width: auto;
        min-width: 130px;
        min-height: 48px;
        padding: 12px 18px;
        font-size: 1rem;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        flex: 0 0 auto;
        max-width: calc(50% - 6px);
    }
    
    .leaderboard-enhanced {
        margin: 15px 0;
    }
    
    .leaderboard-row {
        padding: 12px 10px;
        margin: 6px 0;
        border-radius: 10px;
    }
    
    .leaderboard-rank {
        font-size: 1.1rem;
        min-width: 35px;
    }
    
    .leaderboard-name {
        font-size: 1rem;
        margin: 0 15px;
    }
    
    .leaderboard-stats {
        font-size: 0.9rem;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    #endScreen .start-content {
        margin-top: 10px;
        padding: 10px 20px 40px;
    }
    
    .victory-header {
        margin-bottom: 15px;
    }
    
    .victory-title {
        font-size: 1.6rem;
        margin-bottom: 5px;
    }
    
    .trophy-icon {
        font-size: 2rem;
        margin-bottom: 8px;
    }
    
    .victory-score-display {
        margin: 10px 5px;
        padding: 12px;
        border-radius: 12px;
    }
    
    .score-breakdown {
        font-size: 1rem;
        gap: 6px;
    }
    
    .score-text strong, .tile-text strong {
        font-size: 1.2rem;
    }
    
    .victory-stats {
        margin: 15px 0;
    }
    
    .victory-actions {
        margin-top: 15px;
        gap: 14px;
        padding: 0 15px;
    }
    
    .victory-primary {
        font-size: 1.1rem;
        padding: 12px 25px;
        min-width: 260px;
        max-width: 95%;
        min-height: 48px;
    }
    
    .victory-secondary-actions {
        gap: 12px;
        justify-content: center;
        flex-wrap: wrap;
        max-width: 100%;
    }
    
    .victory-secondary {
        min-width: 120px;
        min-height: 44px;
        font-size: 0.95rem;
        padding: 12px 16px;
        white-space: nowrap;
        flex: 0 0 auto;
        max-width: calc(50% - 6px);
    }
    
    .leaderboard-enhanced {
        margin: 12px 0;
    }
    
    .leaderboard-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 8px;
        margin: 4px 0;
    }
    
    .leaderboard-rank {
        align-self: flex-start;
        font-size: 1rem;
    }
    
    .leaderboard-name {
        font-size: 0.95rem;
        font-weight: 600;
        margin: 0;
        width: 100%;
    }
    
    .leaderboard-stats {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
        font-size: 0.85rem;
        gap: 10px;
        margin-top: 4px;
    }
    
    .personal-best-badge {
        font-size: 0.8rem;
        padding: 4px 8px;
        margin-top: 6px;
    }
}

/* Mobile Touch Enhancements */
@media (max-width: 768px) and (pointer: coarse) {
    /* Increase touch target sizes */
    .victory-primary {
        min-height: 60px;
        touch-action: manipulation;
    }
    
    .victory-secondary {
        min-height: 54px;
        touch-action: manipulation;
    }
    
    .leaderboard-row {
        touch-action: manipulation;
        user-select: none;
    }
    
    /* Add visual feedback for touch */
    .play-btn:active {
        transform: scale(0.96);
        transition: transform 0.1s ease;
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    /* Better spacing between interactive elements */
    .victory-actions {
        padding: 0 15px;
    }
    
    .victory-secondary-actions {
        gap: 25px;
    }
    
    /* Improve text contrast and readability */
    .score-text, .tile-text {
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    }
    
    .leaderboard-name {
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }
}

/* Virtual Joystick Styles */
#virtualJoystick {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 120px;
    height: 120px;
    z-index: 9999;
    pointer-events: auto;
    opacity: 0.8;
    touch-action: none;
    visibility: hidden; /* Hidden by default - managed by InputSystem */
    display: none; /* Hidden by default - managed by InputSystem */
}

/* Hide joystick class - can be used by InputSystem */
#virtualJoystick.hidden {
    display: none !important;
    visibility: hidden !important;
}

.joystick-base {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
    border: 3px solid rgba(255, 255, 255, 0.6);
    position: relative;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.joystick-stick {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.9), rgba(255, 165, 0, 0.7));
    border: 2px solid rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    touch-action: none;
}

.joystick-stick.active {
    transform: translate(-50%, -50%) scale(1.1);
    background: radial-gradient(circle, rgba(255, 215, 0, 1), rgba(255, 165, 0, 0.9));
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.5);
    animation: joystick-pulse 1.5s ease-in-out infinite alternate;
}

/* Enhanced joystick animations */
@keyframes joystick-pulse {
    0% { 
        box-shadow: 0 4px 15px rgba(255, 215, 0, 0.5);
    }
    100% { 
        box-shadow: 0 6px 20px rgba(255, 215, 0, 0.8);
    }
}

@keyframes joystick-ripple {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.6;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.4);
        opacity: 0;
    }
}

/* Joystick feedback elements */
.joystick-ripple {
    animation: joystick-ripple 0.6s ease-out;
}

.joystick-indicator {
    background: conic-gradient(
        from 0deg,
        rgba(255, 215, 0, 0.3) 0deg,
        transparent 45deg,
        rgba(255, 215, 0, 0.3) 90deg,
        transparent 135deg,
        rgba(255, 215, 0, 0.3) 180deg,
        transparent 225deg,
        rgba(255, 215, 0, 0.3) 270deg,
        transparent 315deg,
        rgba(255, 215, 0, 0.3) 360deg
    );
    border: none !important;
}

/* Enhanced joystick base with better feedback */
.joystick-base {
    position: relative;
    overflow: visible;
}

.joystick-base::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#virtualJoystick:active .joystick-base::before,
#virtualJoystick.active .joystick-base::before {
    opacity: 1;
}

/* Improved mobile responsiveness for joystick */
@media (max-width: 480px) and (orientation: portrait) {
    #virtualJoystick {
        bottom: max(20px, env(safe-area-inset-bottom));
        left: max(20px, env(safe-area-inset-left));
        width: clamp(90px, 15vw, 110px);
        height: clamp(90px, 15vw, 110px);
    }
    
    .joystick-stick {
        width: clamp(35px, 8vw, 45px) !important;
        height: clamp(35px, 8vw, 45px) !important;
    }
}

@media (max-width: 480px) and (orientation: landscape) {
    #virtualJoystick {
        bottom: max(15px, env(safe-area-inset-bottom));
        left: max(15px, env(safe-area-inset-left));
        width: 85px;
        height: 85px;
    }
    
    .joystick-stick {
        width: 35px !important;
        height: 35px !important;
    }
}

@media (max-width: 480px) {
    #virtualJoystick {
        bottom: 20px;
        left: 20px;
        width: 100px;
        height: 100px;
    }
    
    .joystick-stick {
        width: 40px;
        height: 40px;
    }
}

/* Enhanced animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* UI Scaling Support for Accessibility */
:root {
    --ui-scale: 1;
    --base-font-size: 16px;
}

/* Scale-aware UI elements */
.scalable-ui {
    transform: scale(var(--ui-scale));
    transform-origin: center;
}

.scalable-text {
    font-size: calc(var(--base-font-size) * var(--ui-scale));
}

/* Context Menu Styles */
.game-context-menu {
    background: rgba(0, 0, 0, 0.95);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: contextMenuAppear 0.2s ease-out;
}

.context-menu-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: none;
    border: none;
    color: white;
    font-size: 14px;
    text-align: left;
    border-radius: 8px;
    margin: 2px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.context-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(4px);
}

.context-menu-item:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.98);
}

@keyframes contextMenuAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -100%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -100%) scale(1);
    }
}

/* Gesture Feedback Styles */
.gesture-feedback {
    position: absolute;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gesture-feedback.active {
    opacity: 1;
}

.pinch-indicator {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(255, 215, 0, 0.8);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.2), transparent);
    animation: pinchPulse 0.5s ease-in-out;
}

@keyframes pinchPulse {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 0.8; }
}

.swipe-indicator {
    width: 4px;
    height: 40px;
    background: linear-gradient(to bottom, 
        rgba(255, 215, 0, 0.8), 
        rgba(255, 215, 0, 0.2)
    );
    border-radius: 2px;
    animation: swipeTrail 0.3s ease-out;
}

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

/* Enhanced Touch Target Sizing */
.touch-target {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Improved button responsiveness on mobile */
@media (pointer: coarse) {
    button, .btn, .touch-target {
        min-width: 48px;
        min-height: 48px;
        padding: 12px 16px;
    }
    
    /* Larger tap areas for small elements */
    .small-element::before {
        content: '';
        position: absolute;
        top: -12px;
        left: -12px;
        right: -12px;
        bottom: -12px;
        pointer-events: auto;
    }
}

/* Visual feedback for gesture interactions */
.gesture-ripple {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.6), transparent);
    pointer-events: none;
    animation: gestureRipple 0.6s ease-out;
}

@keyframes gestureRipple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* Help overlay improvements */
.help-section {
    line-height: 1.6;
    padding: 10px 0;
}

.help-section p {
    margin: 8px 0;
    font-size: 14px;
}

.help-section strong {
    color: #FFD700;
    font-weight: 600;
}

/* Adaptive Touch Target Styles */
.adaptive-touch-target {
    position: relative;
    padding: calc(var(--adaptive-touch-padding, 0px));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: calc(4px + var(--adaptive-touch-padding, 0px));
}

.adaptive-touch-target::before {
    content: '';
    position: absolute;
    top: calc(-1 * var(--adaptive-touch-padding, 0px));
    left: calc(-1 * var(--adaptive-touch-padding, 0px));
    right: calc(-1 * var(--adaptive-touch-padding, 0px));
    bottom: calc(-1 * var(--adaptive-touch-padding, 0px));
    background: rgba(255, 215, 0, 0.1);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: -1;
}

.adaptive-touch-target:hover::before,
.adaptive-touch-target:focus::before {
    opacity: 1;
}

/* Adaptation feedback animation */
@keyframes adaptationFeedback {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(0);
    }
    50% {
        opacity: 1;
        transform: scale(1) translateY(-10px);
    }
    100% {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
}

.adaptation-feedback {
    animation: adaptationFeedback 1s ease-out forwards;
}

/* Enhanced touch targets for different device capabilities */
@media (pointer: coarse) and (max-width: 480px) {
    /* Extra small screens need larger targets */
    .adaptive-touch-target {
        min-width: 48px;
        min-height: 48px;
    }
}

@media (pointer: coarse) and (min-width: 481px) {
    /* Regular mobile devices */
    .adaptive-touch-target {
        min-width: 44px;
        min-height: 44px;
    }
}

@media (pointer: coarse) and (orientation: landscape) {
    /* Landscape mode - slightly smaller targets for thumb reach */
    .adaptive-touch-target {
        min-width: 42px;
        min-height: 42px;
    }
}

/* High DPI displays need proportionally larger targets */
@media (min-resolution: 2dppx) {
    .adaptive-touch-target {
        min-width: calc(44px * 1.2);
        min-height: calc(44px * 1.2);
    }
}

@media (min-resolution: 3dppx) {
    .adaptive-touch-target {
        min-width: calc(44px * 1.4);
        min-height: calc(44px * 1.4);
    }
}

/* Accessibility enhancements for motor impairments */
@media (prefers-reduced-motion: no-preference) {
    .adaptive-touch-target {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .adaptive-touch-target {
        transition: none;
    }
}

/* Enhanced focus indicators for adaptive targets */
.adaptive-touch-target:focus {
    outline: 3px solid rgba(255, 215, 0, 0.8);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(255, 215, 0, 0.2);
}

/* Success feedback for adapted targets */
.adaptive-touch-target.adaptation-success {
    animation: adaptationSuccess 0.5s ease-out;
}

@keyframes adaptationSuccess {
    0% { background-color: rgba(76, 175, 80, 0.2); }
    100% { background-color: transparent; }
}

/* Miss feedback for targets that need adaptation */
.adaptive-touch-target.adaptation-miss {
    animation: adaptationMiss 0.3s ease-out;
}

@keyframes adaptationMiss {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* Orientation-Specific Layouts */
:root {
    --orientation-padding-horizontal: 4vw;
    --orientation-padding-vertical: 3vh;
    --orientation-font-scale: 1;
    --orientation-button-height: 48px;
}

/* Landscape Mode Optimizations */
.orientation-landscape {
    --orientation-padding-horizontal: 5vh;
    --orientation-padding-vertical: 2vh;
    --orientation-font-scale: 0.9;
    --orientation-button-height: 40px;
}

/* Portrait Mode Optimizations */
.orientation-portrait {
    --orientation-padding-horizontal: 4vw;
    --orientation-padding-vertical: 3vh;
    --orientation-font-scale: 1;
    --orientation-button-height: 48px;
}

/* Landscape-specific screen layouts */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .screen {
        padding: var(--orientation-padding-vertical) var(--orientation-padding-horizontal);
    }
    
    .start-content {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        max-width: 90vw;
        gap: 30px;
    }
    
    .start-content .left-section,
    .start-content .right-section {
        flex: 1;
        max-width: 45%;
    }
    
    /* Compact buttons in landscape */
    .victory-primary,
    .victory-secondary,
    button,
    .btn {
        height: var(--orientation-button-height);
        font-size: calc(14px * var(--orientation-font-scale));
        padding: 8px 16px;
    }
    
    /* Smaller headings in landscape */
    h1 {
        font-size: calc(2rem * var(--orientation-font-scale));
        margin-bottom: 15px;
    }
    
    h2 {
        font-size: calc(1.5rem * var(--orientation-font-scale));
        margin-bottom: 12px;
    }
    
    /* Compact HUD elements */
    .timer-display,
    .score-display {
        font-size: calc(1.2rem * var(--orientation-font-scale));
        padding: 6px 12px;
    }
    
    /* Landscape joystick positioning */
    #virtualJoystick {
        width: 100px !important;
        height: 100px !important;
    }
    
    .joystick-stick {
        width: 40px !important;
        height: 40px !important;
    }
    
    /* Modal adjustments for landscape */
    .modal-content {
        width: min(90vw, 600px);
        height: min(75vh, 400px);
        max-height: 75vh;
        display: flex;
        flex-direction: row;
        gap: 20px;
    }
    
    .modal-body {
        overflow-y: auto;
        padding-right: 10px;
    }
    
    /* End screen landscape layout */
    #endScreen .start-content {
        min-height: auto;
        justify-content: center;
        align-items: center;
        padding: 20px;
        gap: 20px;
    }
    
    .victory-section {
        flex-direction: row;
        gap: 20px;
    }
    
    .victory-text,
    .victory-stats {
        flex: 1;
    }
    
    .victory-buttons {
        flex-direction: row;
        gap: 15px;
        justify-content: center;
    }
}

/* Portrait-specific optimizations */
@media screen and (orientation: portrait) {
    .start-content {
        flex-direction: column;
        justify-content: flex-start;
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    /* Larger touch targets in portrait */
    .victory-primary,
    .victory-secondary,
    button,
    .btn {
        min-height: var(--orientation-button-height);
        font-size: calc(16px * var(--orientation-font-scale));
    }
    
    /* Standard joystick positioning in portrait */
    #virtualJoystick {
        width: 120px !important;
        height: 120px !important;
        bottom: max(30px, env(safe-area-inset-bottom));
        left: max(30px, env(safe-area-inset-left));
    }
}

/* Device-specific landscape optimizations */
@media screen and (orientation: landscape) and (max-height: 400px) {
    /* Very short landscape screens (phones) */
    .start-content {
        gap: 15px;
        padding: 10px 20px;
    }
    
    .victory-primary,
    .victory-secondary {
        height: 36px;
        font-size: 13px;
        padding: 6px 12px;
    }
    
    h1 {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }
    
    .timer-display,
    .score-display {
        font-size: 1rem;
        padding: 4px 8px;
    }
}

@media screen and (orientation: landscape) and (min-height: 500px) {
    /* Taller landscape screens (tablets) */
    .start-content {
        max-width: 80vw;
        gap: 40px;
    }
    
    .modal-content {
        max-width: 70vw;
        height: auto;
        max-height: 80vh;
    }
}

/* Handedness-aware joystick positioning */
.handedness-left #virtualJoystick {
    left: auto !important;
    right: max(20px, env(safe-area-inset-right)) !important;
}

.handedness-right #virtualJoystick {
    right: auto !important;
    left: max(20px, env(safe-area-inset-left)) !important;
}

/* Safe area aware positioning */
@supports (padding: env(safe-area-inset-top)) {
    .orientation-landscape .timer-display {
        top: max(20px, env(safe-area-inset-top));
        left: max(20px, env(safe-area-inset-left));
    }
    
    .orientation-landscape .score-display {
        top: max(20px, env(safe-area-inset-top));
        right: max(20px, env(safe-area-inset-right));
    }
    
    .orientation-portrait .screen {
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
}

/* Smooth transitions for orientation changes */
@media (prefers-reduced-motion: no-preference) {
    .timer-display,
    .score-display,
    #virtualJoystick,
    .modal-content,
    .start-content {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .orientation-landscape,
    .orientation-portrait {
        transition: padding 0.3s ease, font-size 0.3s ease;
    }
}

/* Prevent layout shifts during orientation changes */
.screen * {
    box-sizing: border-box;
}

.start-content {
    contain: layout style;
}

/* Optimize scrollable areas for different orientations */
.scrollable {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.orientation-landscape .scrollable {
    max-height: 70vh;
    padding-right: 8px;
}

.orientation-portrait .scrollable {
    max-height: 80vh;
}

.scrollable::-webkit-scrollbar {
    width: 4px;
}

.scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.scrollable::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Enhanced Safe Area Handling */
:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
}

/* Base safe area aware positioning */
.has-safe-areas {
    --safe-padding-top: max(20px, var(--safe-area-top));
    --safe-padding-right: max(20px, var(--safe-area-right));
    --safe-padding-bottom: max(20px, var(--safe-area-bottom));
    --safe-padding-left: max(20px, var(--safe-area-left));
}

/* Notch-specific adjustments */
.has-notch {
    --notch-height: var(--safe-area-top);
}

.has-notch .screen {
    padding-top: max(40px, calc(var(--safe-area-top) + 20px)) !important;
}

.has-notch .timer-display,
.has-notch .score-display {
    top: max(30px, calc(var(--safe-area-top) + 10px)) !important;
}

/* Home indicator adjustments */
.has-home-indicator {
    --home-indicator-height: var(--safe-area-bottom);
}

.has-home-indicator #virtualJoystick {
    bottom: max(40px, calc(var(--safe-area-bottom) + 30px)) !important;
}

.has-home-indicator .screen {
    padding-bottom: max(30px, calc(var(--safe-area-bottom) + 20px)) !important;
}

/* Landscape safe areas */
@media screen and (orientation: landscape) {
    .has-safe-areas.orientation-landscape .screen {
        padding-left: max(20px, var(--safe-area-left)) !important;
        padding-right: max(20px, var(--safe-area-right)) !important;
    }
    
    .has-safe-areas.orientation-landscape .timer-display {
        left: max(30px, calc(var(--safe-area-left) + 20px)) !important;
    }
    
    .has-safe-areas.orientation-landscape .score-display {
        right: max(30px, calc(var(--safe-area-right) + 20px)) !important;
    }
    
    .has-safe-areas.orientation-landscape #virtualJoystick {
        left: max(30px, calc(var(--safe-area-left) + 20px)) !important;
        bottom: max(30px, calc(var(--safe-area-bottom) + 20px)) !important;
    }
}

/* Safe area aware modals */
.has-safe-areas .modal-content {
    margin-top: max(10vh, var(--safe-area-top));
    margin-bottom: max(10vh, var(--safe-area-bottom));
    padding-left: max(20px, var(--safe-area-left));
    padding-right: max(20px, var(--safe-area-right));
}

/* Safe area aware notifications */
.has-safe-areas .notification-container {
    top: max(20px, calc(var(--safe-area-top) + 10px)) !important;
    right: max(20px, var(--safe-area-right)) !important;
    left: max(20px, var(--safe-area-left)) !important;
}

/* End screen safe area handling */
.has-safe-areas #endScreen .start-content {
    padding-top: max(30px, calc(var(--safe-area-top) + 20px)) !important;
    padding-bottom: max(40px, calc(var(--safe-area-bottom) + 30px)) !important;
    padding-left: max(20px, var(--safe-area-left)) !important;
    padding-right: max(20px, var(--safe-area-right)) !important;
}

/* Mobile safe area for end screen */
@media (max-width: 768px) {
    .has-safe-areas #endScreen .start-content {
        padding-bottom: max(50px, calc(var(--safe-area-bottom) + 40px)) !important;
    }
}

@media (max-width: 480px) {
    .has-safe-areas #endScreen .start-content {
        padding-bottom: max(60px, calc(var(--safe-area-bottom) + 50px)) !important;
        padding-left: max(20px, calc(var(--safe-area-left) + 10px)) !important;
        padding-right: max(20px, calc(var(--safe-area-right) + 10px)) !important;
    }
}

/* Game HUD safe area adjustments */
.has-safe-areas #hud {
    padding-top: var(--safe-area-top);
    padding-left: var(--safe-area-left);
    padding-right: var(--safe-area-right);
    padding-bottom: var(--safe-area-bottom);
}

/* iPhone X+ specific optimizations */
@media screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) {
    /* iPhone X, XS, 11 Pro */
    .screen {
        padding-top: max(44px, var(--safe-area-top)) !important;
        padding-bottom: max(34px, var(--safe-area-bottom)) !important;
    }
}

@media screen and (device-width: 414px) and (device-height: 896px) {
    /* iPhone XR, 11, XS Max, 11 Pro Max */
    .screen {
        padding-top: max(44px, var(--safe-area-top)) !important;
        padding-bottom: max(34px, var(--safe-area-bottom)) !important;
    }
}

@media screen and (device-width: 390px) and (device-height: 844px) {
    /* iPhone 12, 12 Pro */
    .screen {
        padding-top: max(47px, var(--safe-area-top)) !important;
        padding-bottom: max(34px, var(--safe-area-bottom)) !important;
    }
}

@media screen and (device-width: 428px) and (device-height: 926px) {
    /* iPhone 12 Pro Max */
    .screen {
        padding-top: max(47px, var(--safe-area-top)) !important;
        padding-bottom: max(34px, var(--safe-area-bottom)) !important;
    }
}

/* Android punch-hole and notch handling */
@media screen and (min-aspect-ratio: 19/9) {
    /* Likely has notch or punch hole */
    .screen {
        padding-top: max(30px, var(--safe-area-top)) !important;
    }
    
    .timer-display {
        top: max(40px, calc(var(--safe-area-top) + 20px)) !important;
    }
}

/* Dynamic safe area animations */
@media (prefers-reduced-motion: no-preference) {
    .screen,
    .timer-display,
    .score-display,
    #virtualJoystick,
    .modal-content {
        transition: padding 0.3s ease, margin 0.3s ease, top 0.3s ease, bottom 0.3s ease, left 0.3s ease, right 0.3s ease;
    }
}

/* Safe area debugging (development only) */
.debug-safe-areas::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--safe-area-top);
    background: rgba(255, 0, 0, 0.3);
    pointer-events: none;
    z-index: 10000;
}

.debug-safe-areas::after {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--safe-area-bottom);
    background: rgba(0, 255, 0, 0.3);
    pointer-events: none;
    z-index: 10000;
}
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

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

.play-btn:hover {
    animation: pulse 0.6s ease-in-out;
}

.play-btn:active,
.settings-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

.play-btn:disabled,
.settings-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.play-btn:disabled:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

/* Enhanced HUD styles for better readability */
.timer-display {
    position: fixed !important;
    top: 20px !important;
    left: 20px !important;
    transform: none !important;
    font-size: clamp(1.5rem, 3vw, 2.5rem) !important;
    font-weight: bold !important;
    color: #FFD700 !important;
    background: rgba(0, 0, 0, 0.8) !important;
    padding: clamp(8px, 2vw, 15px) clamp(15px, 4vw, 25px) !important;
    border-radius: 25px !important;
    z-index: 10000 !important;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5) !important;
    border: 2px solid rgba(255, 215, 0, 0.3) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    backdrop-filter: blur(5px) !important;
    text-align: center !important;
    min-width: 80px !important;
}

.player-stats, .bot-stats {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    padding: clamp(10px, 2vw, 20px);
    border-radius: 15px;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    font-family: 'Courier New', monospace;
}

.bot-stats {
    top: 80px;
    right: 20px;
}

.stat-item, .bot-item {
    display: flex;
    align-items: center;
    margin: clamp(3px, 1vw, 8px) 0;
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    color: white;
    font-weight: 500;
    line-height: 1.2;
}

.stat-value, .bot-value {
    margin-left: clamp(3px, 1vw, 8px);
    font-weight: bold;
    color: #FFD700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    font-family: 'Courier New', monospace;
}

.stat-icon, .bot-icon {
    font-size: clamp(1rem, 3vw, 1.4rem);
    margin-right: clamp(3px, 1vw, 8px);
    text-shadow: 0 0 5px currentColor;
    min-width: 20px;
    text-align: center;
}

#hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

/* Mobile-specific HUD adjustments */
@media (max-width: 768px) {
    .timer-display {
        top: 15px !important;
        left: 15px !important;
        transform: none !important;
        font-size: clamp(1.2rem, 3.5vw, 1.8rem);
        padding: clamp(6px, 2vw, 12px) clamp(12px, 4vw, 20px);
    }
    
    .player-stats, .bot-stats {
        top: 15px;
        right: 15px;
        padding: clamp(8px, 2vw, 15px);
        max-width: 120px;
    }
    
    .bot-stats {
        top: 75px;
        right: 15px;
    }
    
    .stat-item, .bot-item {
        font-size: clamp(0.8rem, 2.5vw, 1rem);
        margin: 2px 0;
    }
    
    .stat-icon, .bot-icon {
        font-size: clamp(0.9rem, 3vw, 1.2rem);
        margin-right: 4px;
    }
}

@media (max-width: 480px) {
    .timer-display {
        top: 10px !important;
        left: 10px !important;
        transform: none !important;
        font-size: clamp(1rem, 4vw, 1.5rem);
        padding: clamp(5px, 2vw, 10px) clamp(10px, 4vw, 15px);
    }
    
    .player-stats, .bot-stats {
        top: 10px;
        right: 10px;
        padding: clamp(6px, 2vw, 12px);
        max-width: 100px;
    }
    
    .bot-stats {
        top: 65px;
        right: 10px;
    }
    
    .stat-item, .bot-item {
        font-size: clamp(0.75rem, 3vw, 0.9rem);
        margin: 1px 0;
    }
}

@media (max-width: 375px) {
    .timer-display {
        top: 8px !important;
        left: 8px !important;
        transform: none !important;
        font-size: clamp(0.9rem, 4.5vw, 1.3rem);
    }
    
    .player-stats, .bot-stats {
        top: 8px;
        right: 8px;
        max-width: 90px;
    }
    
    .bot-stats {
        top: 55px;
        right: 8px;
    }
}

/* Input validation styles */
.name-input-mobile:invalid {
    border-color: #ff6b6b;
}

.name-input-mobile:focus:invalid {
    border-color: #ff4757;
    animation: shake 0.3s ease-in-out;
}

/* Enhanced touch feedback and haptic responses */
@media (hover: none) {
    .play-btn:active,
    .settings-btn:active,
    .social-btn.compact:active {
        transform: scale(0.95);
        box-shadow: 0 1px 5px rgba(0, 0, 0, 0.3);
    }
    
    .play-btn:disabled:active {
        transform: none;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
    }
}

/* Icon explanations and tooltips */
.tooltip-container {
    position: relative;
    display: inline-block;
}

.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.9) transparent transparent transparent;
}

.tooltip-container:hover .tooltip {
    opacity: 1;
}

.tooltip-container:focus .tooltip {
    opacity: 1;
}

/* Mobile-friendly tooltip positioning */
@media (max-width: 768px) {
    .tooltip {
        font-size: 11px;
        padding: 6px 10px;
        bottom: 120%;
        max-width: 200px;
        white-space: normal;
        text-align: center;
    }
}

/* Icon legend for accessibility */
.icon-legend {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    border-radius: 8px;
    font-size: 11px;
    color: #ccc;
    z-index: 1000;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 200px;
    display: none;
}

.icon-legend.show {
    display: block;
}

.icon-legend-item {
    display: flex;
    align-items: center;
    margin: 4px 0;
    gap: 8px;
}

.icon-legend-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

/* Quick help overlay */
.quick-help {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px;
    border-radius: 15px;
    max-width: 300px;
    z-index: 2000;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: none;
}

.quick-help.show {
    display: block;
    animation: fadeInUp 0.3s ease-out;
}

.quick-help h4 {
    color: #FFD700;
    margin-bottom: 10px;
    font-size: 16px;
}

.quick-help p {
    margin: 5px 0;
    font-size: 13px;
    line-height: 1.4;
}

.quick-help button {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 15px;
    font-size: 12px;
    margin-top: 10px;
    cursor: pointer;
}

/* Control hints */
.control-hints {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 12px;
    z-index: 100;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 250px;
}

.control-hints.show {
    display: block;
    animation: slideInLeft 0.3s ease-out;
}

/* Victory Screen Styles */
.victory-header {
    text-align: center;
    margin-bottom: 15px;
}

.trophy-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.victory-title {
    margin: 10px 0;
    font-size: 2rem;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

.performance-feedback {
    font-size: 1rem;
    color: #4CAF50;
    margin-bottom: 10px;
    font-weight: 500;
}

.victory-stats {
    margin: 15px 0;
    text-align: center;
}

.victory-score-display {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 15px;
}

.score-breakdown .score-text {
    display: block;
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: #FFD700;
}

.score-breakdown .tile-text {
    display: block;
    font-size: 1rem;
    color: #4CAF50;
}

.personal-best-badge {
    margin-top: 10px;
    font-size: 0.9rem;
    padding: 5px 15px;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    border-radius: 20px;
    color: #000;
    font-weight: bold;
    display: inline-block;
}

.victory-actions {
    text-align: center;
    margin-top: 20px;
}

.victory-primary {
    margin-bottom: 15px;
    min-height: 50px;
    font-size: 1.1rem;
}

.victory-secondary-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.victory-secondary {
    flex: 1;
    min-width: 120px;
    max-width: 150px;
    min-height: 45px;
}

/* Mobile End Screen - Ultra Compact to fit all content */
@media (max-width: 480px) and (max-height: 800px) {
    .victory-header {
        margin-bottom: 5px;
    }
    
    .trophy-icon {
        font-size: 1.5rem;
        margin-bottom: 3px;
    }
    
    .victory-title {
        font-size: 1.2rem;
        margin: 3px 0;
        line-height: 1.1;
    }
    
    .performance-feedback {
        font-size: 0.8rem;
        margin-bottom: 5px;
        line-height: 1.2;
    }
    
    .victory-stats {
        margin: 8px 0;
    }
    
    .victory-score-display {
        padding: 8px;
        margin-bottom: 8px;
        max-width: 95%;
    }
    
    .score-breakdown .score-text {
        font-size: 1rem;
        margin-bottom: 3px;
        line-height: 1.2;
    }
    
    .score-breakdown .tile-text {
        font-size: 0.8rem;
        line-height: 1.2;
    }
    
    .personal-best-badge {
        font-size: 0.7rem;
        padding: 3px 8px;
        margin-top: 5px;
    }
    
    .victory-actions {
        margin-top: 10px;
    }
    
    .victory-primary {
        margin-bottom: 8px;
        min-height: 35px;
        font-size: 0.9rem;
        padding: 8px 15px;
        width: 90%;
    }
    
    .victory-secondary-actions {
        gap: 8px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0 10px;
    }
    
    .victory-secondary {
        min-width: 100px;
        max-width: 140px;
        min-height: 32px;
        font-size: 0.75rem;
        padding: 6px 12px;
        white-space: nowrap;
    }
    
    /* Compact finalScores for mobile */
    #finalScores {
        margin: 8px 0;
        font-size: 0.8rem;
        gap: 3px;
        max-width: 95%;
        margin-left: auto;
        margin-right: auto;
    }
    
    #finalScores div {
        margin: 2px 0;
        padding: 6px 10px;
        min-width: 120px;
        font-size: 0.8rem;
        line-height: 1.2;
    }
    
    /* Compact modal for mobile */
    .modal-content {
        width: 95%;
        max-width: 350px;
        max-height: 90vh;
        margin: 2% auto;
        padding: 15px;
        overflow-y: auto;
    }
}

/* Extra small phones - Ultra compact */
@media (max-width: 375px) and (max-height: 700px) {
    .victory-header {
        margin-bottom: 3px;
    }
    
    .trophy-icon {
        font-size: 1.2rem;
        margin-bottom: 2px;
    }
    
    .victory-title {
        font-size: 1rem;
        margin: 2px 0;
        line-height: 1.1;
    }
    
    .victory-score-display {
        padding: 6px;
        margin-bottom: 6px;
        max-width: 98%;
    }
    
    .score-breakdown .score-text {
        font-size: 0.9rem;
        margin-bottom: 2px;
        line-height: 1.1;
    }
    
    .score-breakdown .tile-text {
        font-size: 0.7rem;
        line-height: 1.1;
    }
    
    .victory-primary {
        min-height: 30px;
        font-size: 0.8rem;
        width: 90%;
        padding: 6px 12px;
        margin-bottom: 5px;
    }
    
    .victory-secondary {
        min-width: 70px;
        max-width: 100px;
        min-height: 25px;
        font-size: 0.65rem;
        padding: 4px 8px;
    }
    
    #finalScores {
        font-size: 0.7rem;
        margin: 5px 0;
        gap: 2px;
    }
    
    #finalScores div {
        padding: 4px 8px;
        min-width: 100px;
        font-size: 0.7rem;
        margin: 1px 0;
    }
    
    .performance-feedback {
        font-size: 0.7rem;
        margin-bottom: 3px;
    }
    
    .victory-actions {
        margin-top: 8px;
    }
    
    .modal-content {
        padding: 10px;
        max-height: 95vh;
        margin: 1% auto;
    }
}

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

/* Responsive adjustments for tooltips */
@media (max-width: 480px) {
    .icon-legend {
        bottom: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
        font-size: 10px;
    }
    
    .quick-help {
        max-width: 90vw;
        margin: 0 10px;
    }
    
    .control-hints {
        top: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
        font-size: 11px;
    }
}

/* Enhanced button states */
.play-btn:disabled,
.settings-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.play-btn:disabled:hover {
    transform: none;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

/* Settings Modal Form Controls */
.settings-grid select,
.settings-grid input[type="range"] {
    background: rgba(255,255,255,0.1) !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    border-radius: 8px !important;
    color: white !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    outline: none !important;
    min-width: 200px;
}

.settings-grid select:focus,
.settings-grid input[type="range"]:focus {
    outline: none !important;
    border-color: #667eea !important;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.3) !important;
}

.settings-grid select option {
    background: #2a2a2a !important;
    color: white !important;
    padding: 8px !important;
}

/* Range slider styling */
.settings-grid input[type="range"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    height: 6px !important;
    background: rgba(255,255,255,0.2) !important;
    border-radius: 3px !important;
    cursor: pointer !important;
}

.settings-grid input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 18px !important;
    height: 18px !important;
    background: #667eea !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    border: 2px solid white !important;
}

.settings-grid input[type="range"]::-moz-range-thumb {
    width: 18px !important;
    height: 18px !important;
    background: #667eea !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    border: 2px solid white !important;
}

/* Remove all default browser focus outlines for form elements */
select, input, button, textarea {
    outline: none !important;
}

/* Remove dotted focus lines on selects */
select:focus {
    outline: none !important;
    border-color: #667eea !important;
}

/* Ensure volume controls are properly styled */
.volume-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}

.volume-controls label {
    color: #ccc;
    font-size: 14px;
    margin-bottom: 5px;
    display: block;
}

/* Ensure modal buttons are always clickable */
.modal-content .play-btn {
    z-index: 1;
    position: relative;
}

/* Ensure modal has proper z-index */
.modal {
    z-index: 2000 !important;
}

.modal-content {
    z-index: 2001 !important;
    position: relative;
}

/* Force all modal elements to be interactive */
.modal-content * {
    pointer-events: auto !important;
}

.modal-content .play-btn {
    user-select: none !important;
    -webkit-user-select: none !important;
}

/* Ensure form elements are interactive */
.modal-content select,
.modal-content input,
.modal-content button,
.modal-content label {
    pointer-events: auto !important;
    position: relative !important;
    z-index: 10 !important;
}

/* Ensure settings grid elements are clickable */
.settings-grid,
.settings-grid * {
    pointer-events: auto !important;
}

/* Disable canvas interaction when modal is open */
body:has(.modal[style*="display: block"]) #gameCanvas {
    pointer-events: none !important;
}

/* Alternative for browsers that don't support :has() */
.modal-open #gameCanvas {
    pointer-events: none !important;
}

/* Touch feedback indicators */
.touch-feedback {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 215, 0, 0.6) 0%, rgba(255, 215, 0, 0) 70%);
    transform: scale(0);
    animation: touchRipple 0.6s ease-out;
}

@keyframes touchRipple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Enhanced button states */
.play-btn.touch-active,
.settings-btn.touch-active,
.social-btn.compact.touch-active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* Visual feedback for interactions */
.button-press-animation {
    animation: buttonPress 0.2s ease-out;
}

@keyframes buttonPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.92); }
    100% { transform: scale(1); }
}

/* Haptic feedback visual indicator */
.haptic-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #FFD700;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10000;
}

.haptic-indicator.show {
    opacity: 1;
}

/* Daily Challenges Styles */
.challenges-header {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.challenge-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
}

.challenge-stats .stat-item {
    text-align: center;
    flex: 1;
}

.challenge-stats .stat-icon {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.challenge-stats .stat-value {
    display: block;
    font-size: 1.2rem;
    font-weight: bold;
    color: #FFD700;
}

.challenge-stats .stat-label {
    display: block;
    font-size: 0.8rem;
    color: #ccc;
    margin-top: 2px;
}

.reset-timer {
    text-align: center;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.challenges-list {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.loading-challenges {
    text-align: center;
    padding: 40px 20px;
    color: #ccc;
}

.loading-challenges .loading-spinner {
    font-size: 2rem;
    animation: spin 2s linear infinite;
    margin-bottom: 10px;
}

.challenge-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.challenge-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 215, 0, 0.3);
}

.challenge-item.completed {
    background: rgba(76, 175, 80, 0.1);
    border-color: #4CAF50;
}

.challenge-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.challenge-icon {
    font-size: 1.5rem;
    margin-right: 12px;
}

.challenge-info {
    flex: 1;
}

.challenge-name {
    font-size: 1rem;
    font-weight: bold;
    color: #FFD700;
    margin-bottom: 4px;
}

.challenge-description {
    font-size: 0.9rem;
    color: #ccc;
    line-height: 1.3;
}

.challenge-difficulty {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: bold;
    margin-left: auto;
}

.challenge-difficulty.easy {
    background: #4CAF50;
    color: white;
}

.challenge-difficulty.medium {
    background: #FF9800;
    color: white;
}

.challenge-difficulty.hard {
    background: #F44336;
    color: white;
}

.challenge-difficulty.expert {
    background: #9C27B0;
    color: white;
}

.challenge-progress {
    margin-top: 12px;
}

.progress-bar {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #FFD700, #FFA500);
    border-radius: 6px;
    transition: width 0.3s ease;
}

.challenge-progress.completed .progress-fill {
    background: linear-gradient(90deg, #4CAF50, #45a049);
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #ccc;
}

.challenge-reward {
    text-align: right;
    font-size: 0.7rem;
    color: #FFD700;
    font-weight: bold;
}

.challenge-completed-badge {
    display: inline-flex;
    align-items: center;
    background: #4CAF50;
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: bold;
    margin-left: auto;
}

.challenge-completed-badge::before {
    content: "✓";
    margin-right: 4px;
}

/* Mobile responsiveness for challenges */
@media (max-width: 480px) {
    .challenges-header {
        padding: 15px;
    }
    
    .challenge-stats {
        flex-direction: row;
        gap: 10px;
    }
    
    .challenge-stats .stat-item {
        min-width: 0;
    }
    
    .challenge-stats .stat-icon {
        font-size: 1.2rem;
    }
    
    .challenge-stats .stat-value {
        font-size: 1rem;
    }
    
    .challenge-stats .stat-label {
        font-size: 0.7rem;
    }
    
    .challenge-item {
        padding: 12px;
    }
    
    .challenge-header {
        flex-wrap: wrap;
    }
    
    .challenge-difficulty {
        margin-left: 0;
        margin-top: 4px;
    }
}

/* Compact challenges for very small screens */
@media (max-width: 375px) {
    .challenge-stats {
        flex-direction: column;
        gap: 8px;
    }
    
    .challenge-stats .stat-item {
        display: flex;
        align-items: center;
        text-align: left;
        gap: 8px;
    }
    
    .challenge-stats .stat-icon {
        font-size: 1rem;
        margin-bottom: 0;
    }
}

/* Achievement Notification Styles */
.achievement-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    padding: 15px 20px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(255, 215, 0, 0.3);
    z-index: 10000;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s ease-in-out;
    max-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.achievement-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.achievement-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.achievement-content {
    flex: 1;
}

.achievement-title {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.achievement-name {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.achievement-desc {
    font-size: 0.85rem;
    opacity: 0.8;
    line-height: 1.2;
}

/* Unlock Notification Styles */
.unlock-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: linear-gradient(135deg, #9C27B0, #673AB7);
    color: white;
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(156, 39, 176, 0.4);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease-in-out;
    display: flex;
    align-items: center;
    gap: 10px;
}

.unlock-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.unlock-icon {
    font-size: 1.5rem;
    animation: sparkle 1s ease-in-out infinite alternate;
}

@keyframes sparkle {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.5); }
}

.unlock-content {
    text-align: center;
}

.unlock-title {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.unlock-name {
    font-size: 1rem;
    font-weight: bold;
    color: #FFD700;
}

/* Mobile responsive notifications */
@media (max-width: 768px) {
    .achievement-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: calc(100vw - 20px);
        transform: translateY(-100%);
    }
    
    .achievement-notification.show {
        transform: translateY(0);
    }
    
    .unlock-notification {
        left: 10px;
        right: 10px;
        transform: translateY(-100%);
    }
    
    .unlock-notification.show {
        transform: translateY(0);
    }
}

/* Additional Daily Challenge Styles */
.challenge-date {
    text-align: center;
    font-size: 1.1rem;
    color: #FFD700;
    font-weight: bold;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.challenge-checkmark {
    font-size: 1.5rem;
    color: #4CAF50;
    margin-left: 10px;
    flex-shrink: 0;
}

.challenges-scroll-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    -webkit-overflow-scrolling: touch;
    position: relative;
    z-index: 2002;
}

/* Challenges scroll container custom scrollbar */
.challenges-scroll-container::-webkit-scrollbar {
    width: 12px !important;
    -webkit-appearance: none !important;
    z-index: 2003 !important;
}

.challenges-scroll-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.2) !important;
    border-radius: 6px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.challenges-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.6) !important;
    border-radius: 6px !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    min-height: 20px !important;
}

.challenges-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.8) !important;
}

.challenges-scroll-container::-webkit-scrollbar-thumb:active {
    background: rgba(255, 255, 255, 0.9) !important;
}

/* Desktop/Web view specific fixes for challenges */
@media (min-width: 768px) {
    .challenges-scroll-container {
        /* Ensure scrollbar is always visible on desktop */
        scrollbar-width: auto;
        overflow-y: scroll;
    }
    
    .challenges-scroll-container::-webkit-scrollbar {
        width: 14px !important;
        display: block !important;
    }
    
    .challenges-scroll-container::-webkit-scrollbar-thumb {
        background: rgba(255, 255, 255, 0.7) !important;
        cursor: pointer;
    }
    
    .challenges-scroll-container::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 255, 255, 0.9) !important;
    }
}

/* Modal Close Button Styling */
.modal-close, .close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    z-index: 1000;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover,
.modal-close:focus,
.close-btn:hover,
.close-btn:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.modal-close:active,
.close-btn:active {
    transform: scale(0.95);
}

/* Override progress bar for challenges */
.challenge-item .progress-bar {
    background: linear-gradient(90deg, #4CAF50, #45a049);
    height: 100%;
    border-radius: 8px;
    transition: width 0.3s ease;
}

.challenge-item .challenge-progress {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    height: 20px;
    position: relative;
    margin: 8px 0;
    overflow: hidden;
}

.challenge-item .progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    z-index: 1;
}

/* Modal header improvements for challenges */
.modal-header h2 {
    margin: 0;
    color: #FFD700;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Share Modal Styles */
.share-content {
    text-align: center;
    padding: 20px 0;
}

.share-content p {
    margin-bottom: 15px;
    color: #ccc;
    font-size: 1rem;
}

.share-content textarea {
    width: 100%;
    height: 150px;
    margin: 10px 0;
    padding: 15px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    border: 2px solid #444;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    resize: vertical;
    box-sizing: border-box;
}

.share-content textarea:focus {
    outline: none;
    border-color: #FFD700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.share-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.share-buttons .play-btn {
    min-width: 140px;
    padding: 12px 20px;
    font-size: 0.9rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.share-buttons .play-btn.primary {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
}

.share-buttons .play-btn.primary:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.share-buttons .play-btn.secondary {
    background: linear-gradient(135deg, #6c757d, #5a6268);
    color: white;
}

.share-buttons .play-btn.secondary:hover {
    background: linear-gradient(135deg, #5a6268, #495057);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.4);
}

/* Mobile responsive for share modal */
@media (max-width: 768px) {
    .share-content textarea {
        height: 120px;
        font-size: 13px;
        padding: 10px;
    }
    
    .share-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .share-buttons .play-btn {
        width: 100%;
        max-width: 250px;
        margin: 5px 0;
    }
}

/* =================================================================
   MOBILE UI OPTIMIZATION STYLES
   ================================================================= */

/* Enhanced Virtual Joystick */
.virtual-joystick {
  position: fixed;
  bottom: calc(20px + var(--safe-area-inset-bottom));
  left: calc(20px + var(--safe-area-inset-left));
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  touch-action: none;
  transition: all var(--transition-duration) ease;
}

.joystick-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  transform: translate(-50%, -50%);
  transition: all 100ms ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.joystick-feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid transparent;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: all 200ms ease;
}

.joystick-active .joystick-feedback {
  border-color: var(--focus-color);
  animation: joystickPulse 1s infinite;
}

@keyframes joystickPulse {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.2; transform: translate(-50%, -50%) scale(1.1); }
}

/* Adaptive Touch Targets */
.adaptive-touch-target {
  padding: var(--adaptive-touch-padding);
  min-width: var(--min-touch-target);
  min-height: var(--min-touch-target);
  position: relative;
}

.adaptive-touch-target::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--min-touch-target);
  height: var(--min-touch-target);
  transform: translate(-50%, -50%);
  pointer-events: none;
  border-radius: 4px;
  border: 1px dashed transparent;
  transition: border-color var(--transition-duration) ease;
}

.touch-assist .adaptive-touch-target::after {
  border-color: rgba(0, 122, 255, 0.3);
}

/* Gesture Feedback */
@keyframes adaptationFeedback {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(1.5) translateY(-20px); }
}

.adaptation-feedback {
  animation: adaptationFeedback 1s ease-out forwards;
}

/* Enhanced Focus Indicators */
.enhanced-focus *:focus {
  outline: var(--focus-outline-width) solid var(--focus-color) !important;
  outline-offset: 2px;
  border-radius: 4px;
}

.enhanced-focus button:focus,
.enhanced-focus .btn:focus {
  box-shadow: 0 0 0 var(--focus-outline-width) var(--focus-color),
              0 4px 12px rgba(0, 122, 255, 0.3);
}

/* High Contrast Mode */
.high-contrast {
  filter: contrast(1.5) saturate(0.8);
}

.high-contrast * {
  text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8) !important;
}

.high-contrast button,
.high-contrast .btn {
  border: 2px solid currentColor !important;
  background: rgba(0, 0, 0, 0.9) !important;
  color: white !important;
}

/* Large Text Support */
.large-text {
  font-size: calc(var(--base-font-size) * 1.25) !important;
}

.large-text h1, .large-text h2, .large-text h3 {
  font-size: calc(var(--heading-font-size) * 1.25) !important;
}

.large-text button, .large-text .btn {
  font-size: calc(var(--button-font-size) * 1.25) !important;
  padding: 12px 20px !important;
}

/* Reduced Motion */
.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* No Parallax */
.no-parallax * {
  transform: none !important;
}

/* Simplified UI */
.simplified-ui .advanced-controls,
.simplified-ui .secondary-ui {
  display: none !important;
}

.simplified-ui button,
.simplified-ui .btn {
  font-size: calc(var(--button-font-size) * 1.1) !important;
  padding: 16px 24px !important;
  margin: 8px !important;
}

/* Focus Mode */
.focus-mode * {
  transition: opacity var(--transition-duration) ease;
}

.focus-mode .non-essential {
  opacity: 0.3;
}

.focus-mode .essential {
  opacity: 1;
  position: relative;
  z-index: 10;
}

/* Reading Guide */
.reading-guide {
  background: linear-gradient(90deg, transparent, var(--focus-color), transparent);
  height: 3px !important;
  box-shadow: 0 0 10px rgba(0, 122, 255, 0.5);
}

/* Skip Navigation */
.skip-navigation {
  position: fixed;
  top: calc(-100px - var(--safe-area-inset-top));
  left: var(--safe-area-inset-left);
  z-index: 9999;
  transition: top var(--transition-duration) ease;
}

.skip-navigation:focus-within {
  top: var(--safe-area-inset-top);
}

.skip-link {
  display: inline-block;
  padding: 8px 16px;
  background: var(--focus-color);
  color: white;
  text-decoration: none;
  border-radius: 0 0 4px 4px;
  font-weight: bold;
  margin-right: 4px;
}

.skip-link:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Dwell Click Feedback */
@keyframes dwellFeedback {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(0.8) translateY(-30px); }
}

/* Screen Reader Only Content */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Reduced Transparency */
.no-transparency * {
  background-color: rgba(0, 0, 0, 0.9) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Landscape Orientation Optimizations */
@media screen and (orientation: landscape) and (max-height: 500px) {
  .virtual-joystick {
    width: 100px;
    height: 100px;
    bottom: calc(10px + var(--safe-area-inset-bottom));
    left: calc(10px + var(--safe-area-inset-left));
  }
  
  .joystick-inner {
    width: 35px;
    height: 35px;
  }
  
  .score-display {
    top: calc(10px + var(--safe-area-inset-top));
    right: calc(10px + var(--safe-area-inset-right));
    font-size: 16px;
    padding: 8px 12px;
  }
  
  /* Adjust UI for landscape phones */
  .landscape-compact {
    font-size: 14px;
  }
  
  .landscape-compact button,
  .landscape-compact .btn {
    padding: 8px 12px;
    font-size: 14px;
  }
}

/* Portrait Orientation Optimizations */
@media screen and (orientation: portrait) {
  .virtual-joystick {
    bottom: calc(80px + var(--safe-area-inset-bottom));
  }
  
  /* Larger touch targets in portrait */
  .adaptive-touch-target {
    min-width: calc(var(--min-touch-target) * 1.1);
    min-height: calc(var(--min-touch-target) * 1.1);
  }
}

/* Device-Specific Optimizations */

/* iPhone X and newer with notch */
@supports (padding: max(0px)) {
  .notch-aware {
    padding-top: max(var(--safe-area-inset-top), 20px);
    padding-bottom: max(var(--safe-area-inset-bottom), 20px);
    padding-left: max(var(--safe-area-inset-left), 20px);
    padding-right: max(var(--safe-area-inset-right), 20px);
  }
}

/* Android with display cutouts */
@media screen and (display-mode: standalone) {
  body {
    padding-top: calc(var(--safe-area-inset-top) + env(titlebar-area-height, 0px));
  }
}

/* Small screens (phones) */
@media screen and (max-width: 480px) {
  :root {
    --base-font-size: 14px;
    --button-font-size: 16px;
    --min-touch-target: 48px;
  }
  
  .virtual-joystick {
    width: 110px;
    height: 110px;
  }
  
  .score-display {
    font-size: 16px;
  }
}

/* Medium screens (small tablets) */
@media screen and (min-width: 481px) and (max-width: 768px) {
  :root {
    --base-font-size: 16px;
    --min-touch-target: 50px;
  }
}

/* Large screens (tablets and desktops) */
@media screen and (min-width: 769px) {
  :root {
    --base-font-size: 16px;
    --min-touch-target: 44px;
  }
  
  .virtual-joystick {
    display: none; /* Hide on desktop */
  }
}

/* High DPI displays */
@media screen and (min-resolution: 2dppx) {
  .crisp-edges {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
  }
}

/* Prefer reduced motion users */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .virtual-joystick {
    transition: none;
  }
}

/* High contrast preference */
@media (prefers-contrast: high) {
  :root {
    --focus-outline-width: 3px;
  }
  
  * {
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
  }
  
  button, .btn {
    border: 2px solid currentColor;
  }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
  /* Already using dark theme, but could add variations */
  .auto-theme {
    background: #000;
    color: #fff;
  }
}

/* Pointer device optimizations */
@media (pointer: coarse) {
  /* Touch devices - larger targets */
  button, .btn, input, select, textarea {
    min-height: var(--min-touch-target);
    padding: 12px 16px;
  }
}

@media (pointer: fine) {
  /* Mouse devices - smaller targets OK */
  button, .btn {
    min-height: 36px;
    padding: 8px 12px;
  }
}

/* Hover capability */
@media (hover: hover) {
  /* Devices that can hover */
  .hover-effects:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
}

@media (hover: none) {
  /* Devices without hover (touch) */
  .hover-effects:active {
    transform: scale(0.98);
  }
}

/* Modern End Screen Styles */
.modern-end-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #0f1419 0%, #1a1f2e 50%, #0f1419 100%);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 10000;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 0;
}

.end-screen-content {
    max-width: 400px;
    width: 90%;
    text-align: center;
    padding: 20px;
    margin: auto 0;
    min-height: fit-content;
}

/* Trophy Animation */
.trophy-container {
    margin-bottom: 20px;
}

.animated-trophy {
    font-size: 4rem;
    display: inline-block;
    animation: trophyFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.8));
}

@keyframes trophyFloat {
    0%, 100% { 
        transform: translateY(0) rotate(0deg) scale(1); 
    }
    33% { 
        transform: translateY(-8px) rotate(2deg) scale(1.05); 
    }
    66% { 
        transform: translateY(-4px) rotate(-1deg) scale(1.02); 
    }
}

/* Title */
.end-title {
    color: #FFD700;
    font-size: 2rem;
    margin-bottom: 30px;
    font-weight: 600;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

/* Glass Card Effect */
.glass-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin: 15px 0;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    animation: cardGlow 2s ease-in-out infinite alternate;
}

@keyframes cardGlow {
    0% { 
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
    100% { 
        box-shadow: 
            0 12px 40px rgba(0, 0, 0, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.3),
            0 0 20px rgba(255, 215, 0, 0.1);
    }
}

.main-score-card {
    margin-bottom: 25px;
}

.score-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.main-score {
    color: #ffffff;
    font-size: 1.3rem;
    font-weight: 600;
}

.sub-score {
    color: #cccccc;
    font-size: 1rem;
    opacity: 0.9;
}

/* Leaderboard Section */
.leaderboard-section {
    margin: 25px 0;
}

/* Individual Player Cards */
.individual-player-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 20px 24px;
    margin: 12px 0;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    animation: cardSlideIn 0.6s ease-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 80px;
}

.individual-player-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 50%, transparent 100%);
    pointer-events: none;
    z-index: 1;
}

.individual-player-card:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 16px 48px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
}

.individual-player-card.player-highlight-card {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 
        0 8px 32px rgba(255, 215, 0, 0.15),
        inset 0 1px 0 rgba(255, 215, 0, 0.15);
}

.individual-player-card.player-highlight-card::before {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12) 0%, rgba(255, 215, 0, 0.04) 50%, transparent 100%);
}

.individual-player-card.player-highlight-card:hover {
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 
        0 16px 48px rgba(255, 215, 0, 0.25),
        inset 0 1px 0 rgba(255, 215, 0, 0.25);
}

/* Player card layout */
.player-card-layout {
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 2;
}

.rank-section {
    flex-shrink: 0;
}

.rank-medal-individual {
    font-size: 1.8rem;
    width: 55px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    font-weight: bold;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.player-info-section {
    flex: 1;
    min-width: 0;
}

.player-name-individual {
    color: #ffffff;
    font-weight: 600;
    font-size: 1.2rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
}

.player-stats-section {
    display: flex;
    gap: 30px;
    align-items: center;
    flex-shrink: 0;
}

.tile-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    backdrop-filter: blur(8px);
    min-width: 60px;
}

.stat-label-individual {
    color: #aaaaaa;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-value-individual {
    color: #FFD700;
    font-weight: 600;
    font-size: 1.1rem;
}

.score-stat {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    backdrop-filter: blur(8px);
    min-width: 70px;
    text-align: center;
}

.stat-value-score-individual {
    color: #FFD700;
    font-weight: 700;
    font-size: 1.4rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
}

/* Mobile Responsive Styles for Individual Cards */
@media (max-width: 480px) {
    .individual-player-card {
        padding: 16px 20px;
        margin: 10px 0;
        min-height: 70px;
        border-radius: 12px;
    }
    
    .player-card-layout {
        gap: 16px;
    }
    
    .rank-medal-individual {
        font-size: 1.5rem;
        width: 45px;
        height: 45px;
        border-radius: 10px;
    }
    
    .player-name-individual {
        font-size: 1.1rem;
    }
    
    .player-stats-section {
        gap: 20px;
    }
    
    .tile-stat, .score-stat {
        padding: 6px 12px;
        min-width: 50px;
        border-radius: 8px;
    }
    
    .stat-label-individual {
        font-size: 0.7rem;
    }
    
    .stat-value-individual {
        font-size: 1rem;
    }
    
    .stat-value-score-individual {
        font-size: 1.2rem;
    }
}

@media (max-width: 360px) {
    .individual-player-card {
        padding: 14px 16px;
    }
    
    .player-card-layout {
        gap: 12px;
    }
    
    .rank-medal-individual {
        font-size: 1.3rem;
        width: 40px;
        height: 40px;
    }
    
    .player-name-individual {
        font-size: 1rem;
    }
    
    .player-stats-section {
        gap: 15px;
    }
    
    .tile-stat, .score-stat {
        padding: 4px 8px;
        min-width: 45px;
    }
    
    .stat-value-score-individual {
        font-size: 1.1rem;
    }
}

/* Unified Leaderboard Card */
.leaderboard-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 0;
    margin: 20px 0;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    animation: cardSlideIn 0.6s ease-out;
    transition: all 0.3s ease;
}

.leaderboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 50%, transparent 100%);
    pointer-events: none;
    z-index: 1;
}

.leaderboard-card-content {
    position: relative;
    z-index: 2;
}

/* Player Rows within the unified card */
.player-row {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    position: relative;
}

.player-row:last-child {
    border-bottom: none;
}

.player-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.player-row.player-highlight-row {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.1);
}

.player-row.player-highlight-row:hover {
    background: rgba(255, 215, 0, 0.15);
}

/* Row elements */
.rank-medal-small {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    flex-shrink: 0;
    margin-right: 15px;
}

.player-info-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.player-icon-small {
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    flex-shrink: 0;
}

.player-name-row {
    color: #ffffff;
    font-weight: 500;
    font-size: 1rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-stats-row {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-shrink: 0;
}

.stat-item-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    min-width: 50px;
}

.stat-label-small {
    color: #aaaaaa;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    line-height: 1;
}

.stat-value-small {
    color: #FFD700;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1;
}

.stat-value-score {
    color: #FFD700;
    font-weight: 600;
    font-size: 1rem;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    min-width: 50px;
    text-align: center;
}

/* Row slide-in animation */
@keyframes rowSlideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Individual Player Cards (keep for backward compatibility) */
.player-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 20px;
    margin: 10px 0;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    animation: cardSlideIn 0.6s ease-out;
    transition: all 0.3s ease;
}

.player-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 50%, transparent 100%);
    pointer-events: none;
    z-index: 1;
}

.player-card:hover {
    transform: translateY(-4px);
    box-shadow: 
        0 16px 48px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.12);
}

.player-card.player-highlight {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.2);
    box-shadow: 
        0 8px 32px rgba(255, 215, 0, 0.15),
        inset 0 1px 0 rgba(255, 215, 0, 0.15);
}

.player-card.player-highlight::before {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12) 0%, rgba(255, 215, 0, 0.04) 50%, transparent 100%);
}

.player-card.player-highlight:hover {
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 
        0 16px 48px rgba(255, 215, 0, 0.25),
        inset 0 1px 0 rgba(255, 215, 0, 0.25);
}

.player-card-content {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    z-index: 2;
}

.rank-medal {
    font-size: 1.8rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

.player-info-card {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.player-info-card .player-icon {
    font-size: 1.3rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    backdrop-filter: blur(8px);
}

.player-info-card .player-name {
    color: #ffffff;
    font-weight: 500;
    font-size: 1rem;
}

.player-stats-card {
    display: flex;
    gap: 20px;
    align-items: center;
}

.stat-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    min-width: 50px;
}

.stat-group .stat-label {
    color: #aaaaaa;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-group .stat-value {
    color: #FFD700;
    font-weight: 600;
    font-size: 0.9rem;
}

.leaderboard-item {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px 20px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: cardSlideIn 0.5s ease-out;
    transition: all 0.3s ease;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.leaderboard-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 50%, transparent 100%);
    pointer-events: none;
}

.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-3px);
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.leaderboard-item.player-row {
    background: rgba(255, 215, 0, 0.12);
    border: 1px solid rgba(255, 215, 0, 0.25);
    box-shadow: 
        0 8px 32px rgba(255, 215, 0, 0.15),
        inset 0 1px 0 rgba(255, 215, 0, 0.2);
}

.leaderboard-item.player-row::before {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.08) 50%, transparent 100%);
}

.leaderboard-item.player-row:hover {
    background: rgba(255, 215, 0, 0.18);
    box-shadow: 
        0 12px 40px rgba(255, 215, 0, 0.25),
        inset 0 1px 0 rgba(255, 215, 0, 0.3);
}

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

.player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.player-icon {
    font-size: 1.4rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-name {
    color: #ffffff;
    font-weight: 500;
    font-size: 1rem;
}

.player-stats {
    display: flex;
    align-items: center;
    gap: 20px;
    color: #cccccc;
    font-size: 0.9rem;
    font-weight: 400;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.stat-label {
    color: #888888;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-weight: 600;
    color: #FFD700;
    font-size: 0.95rem;
}

/* Rank indicators */
.leaderboard-item .rank-indicator {
    position: absolute;
    left: -1px;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 2px 0 0 2px;
}

.leaderboard-item:nth-child(1) .rank-indicator {
    background: linear-gradient(180deg, #FFD700, #FFA500);
}

.leaderboard-item:nth-child(2) .rank-indicator {
    background: linear-gradient(180deg, #C0C0C0, #A0A0A0);
}

.leaderboard-item:nth-child(3) .rank-indicator {
    background: linear-gradient(180deg, #CD7F32, #A0522D);
}

/* Action Buttons */
.action-buttons {
    margin-top: 30px;
}

.modern-btn {
    border: none;
    border-radius: 12px;
    padding: 15px 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.modern-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.modern-btn:hover::before {
    left: 100%;
}

.primary-btn {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    margin-bottom: 20px;
    width: 100%;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.6);
}

.secondary-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.secondary-btn {
    background: rgba(255, 165, 0, 0.9);
    color: white;
    flex: 1;
    box-shadow: 0 4px 15px rgba(255, 165, 0, 0.3);
}

.secondary-btn:hover {
    background: rgba(255, 165, 0, 1);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 165, 0, 0.5);
}

.btn-text {
    display: block;
    font-size: 1rem;
    font-weight: 600;
}

.btn-subtext {
    display: block;
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 2px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .modern-end-screen {
        padding: 10px 0;
        align-items: flex-start;
    }
    
    .end-screen-content {
        width: 95%;
        padding: 15px;
        margin: 10px 0;
    }
    
    .animated-trophy {
        font-size: 3rem;
    }
    
    .end-title {
        font-size: 1.6rem;
        margin-bottom: 20px;
    }
    
    .glass-card {
        padding: 15px;
        margin: 12px 0;
    }
    
    .main-score {
        font-size: 1.1rem;
    }
    
    .leaderboard-item {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    /* Unified leaderboard card mobile styling */
    .leaderboard-card {
        margin: 15px 0;
    }
    
    .player-row {
        padding: 12px 15px;
    }
    
    .rank-medal-small {
        font-size: 1.2rem;
        width: 32px;
        height: 32px;
        margin-right: 12px;
    }
    
    .player-icon-small {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }
    
    .player-name-row {
        font-size: 0.9rem;
    }
    
    .player-stats-row {
        gap: 12px;
    }
    
    .stat-item-row {
        padding: 4px 8px;
        min-width: 40px;
    }
    
    .stat-label-small {
        font-size: 0.65rem;
    }
    
    .stat-value-small {
        font-size: 0.8rem;
    }
    
    .stat-value-score {
        font-size: 0.85rem;
        padding: 4px 8px;
        min-width: 40px;
    }
    
    /* Player cards mobile styling (backward compatibility) */
    .player-card {
        padding: 15px;
        margin: 8px 0;
    }
    
    .player-card-content {
        gap: 10px;
    }
    
    .rank-medal {
        font-size: 1.4rem;
        width: 32px;
        height: 32px;
    }
    
    .player-info-card .player-icon {
        width: 28px;
        height: 28px;
        font-size: 1.1rem;
    }
    
    .player-info-card .player-name {
        font-size: 0.9rem;
    }
    
    .player-stats-card {
        gap: 12px;
    }
    
    .stat-group {
        padding: 6px 10px;
        min-width: 45px;
    }
    
    .stat-group .stat-label {
        font-size: 0.65rem;
    }
    
    .stat-group .stat-value {
        font-size: 0.85rem;
    }
    
    .modern-btn {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    
    .secondary-buttons {
        flex-direction: column;
        gap: 8px;
    }
}

/* Extra small phones (iPhone SE, small Android phones) */
@media (max-height: 667px) and (max-width: 480px) {
    .modern-end-screen {
        padding: 5px 0;
    }
    
    .end-screen-content {
        padding: 10px;
        margin: 5px 0;
    }
    
    .animated-trophy {
        font-size: 2.5rem;
    }
    
    .end-title {
        font-size: 1.4rem;
        margin-bottom: 15px;
    }
    
    .glass-card {
        padding: 12px;
        margin: 8px 0;
    }
    
    .trophy-container {
        margin-bottom: 15px;
    }
    
    .main-score-card {
        margin-bottom: 18px;
    }
    
    .leaderboard-section {
        margin: 18px 0;
    }
    
    .individual-player-card {
        padding: 15px 18px;
        margin: 8px 0;
        min-height: 65px;
    }
    
    .action-buttons {
        margin-top: 15px;
    }
    
    .modern-btn {
        padding: 10px 16px;
        font-size: 0.85rem;
    }
}

/* Very small phones (height < 600px) */
@media (max-height: 600px) and (max-width: 480px) {
    .animated-trophy {
        font-size: 1.8rem;
    }
    
    .end-title {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }
    
    .glass-card {
        padding: 8px;
        margin: 4px 0;
    }
    
    .individual-player-card {
        padding: 8px 12px;
        margin: 3px 0;
        min-height: 45px;
    }
    
    .trophy-container {
        margin-bottom: 8px;
    }
    
    .main-score-card {
        margin-bottom: 10px;
    }
    
    .leaderboard-section {
        margin: 10px 0;
    }
    
    .rank-medal-individual {
        font-size: 1.2rem;
        width: 35px;
        height: 35px;
    }
    
    .player-card-layout {
        gap: 12px;
    }
    
    .player-name-individual {
        font-size: 0.8rem;
    }
    
    .tile-value-individual {
        font-size: 0.75rem;
        padding: 2px 6px;
    }
    
    .action-buttons {
        margin-top: 10px;
    }
    
    .modern-btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    .btn-subtext {
        font-size: 0.7rem;
        margin-top: 1px;
    }
}

/* Extremely small phones (height < 568px - iPhone SE first gen) */
@media (max-height: 568px) and (max-width: 480px) {
    .modern-end-screen {
        padding: 2px 0;
    }
    
    .end-screen-content {
        padding: 8px;
        margin: 2px 0;
    }
    
    .animated-trophy {
        font-size: 1.5rem;
    }
    
    .end-title {
        font-size: 1rem;
        margin-bottom: 6px;
    }
    
    .glass-card {
        padding: 6px;
        margin: 2px 0;
    }
    
    .individual-player-card {
        padding: 6px 10px;
        margin: 2px 0;
        min-height: 38px;
    }
    
    .trophy-container {
        margin-bottom: 6px;
    }
    
    .main-score-card {
        margin-bottom: 8px;
    }
    
    .leaderboard-section {
        margin: 8px 0;
    }
    
    .rank-medal-individual {
        font-size: 1rem;
        width: 30px;
        height: 30px;
    }
    
    .player-card-layout {
        gap: 10px;
    }
    
    .player-name-individual {
        font-size: 0.75rem;
    }
    
    .tile-value-individual {
        font-size: 0.7rem;
        padding: 1px 5px;
    }
    
    .action-buttons {
        margin-top: 8px;
    }
    
    .modern-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    .btn-subtext {
        font-size: 0.65rem;
        margin-top: 0;
    }
    
    .main-score {
        font-size: 1rem;
    }
    
    .sub-score {
        font-size: 0.85rem;
    }
}

