/* Optimized CSS - Mobile Enhanced with Dynamic Theme Support */

/* CSS Variables */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --danger-gradient: linear-gradient(135deg, #ff4757 0%, #c44569 100%);
    --success-gradient: linear-gradient(135deg, #2ed573 0%, #1e90ff 100%);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --shadow-glow: 0 8px 32px rgba(31, 38, 135, 0.37);
    --shadow-hover: 0 15px 35px rgba(31, 38, 135, 0.5);
    --explode-bg: linear-gradient(135deg, #ff4757 0%, #c44569 50%, #2c2c54 100%);
    --accent-color: #4facfe;
    --warning-color: #ffa500;
    --success-color: #00ff88;
    --dynamic-bg-color: #0c0c0c;
    --dynamic-bg-gradient: linear-gradient(135deg, #0c0c0c 0%, #1a1a2e 25%, #16213e 50%, #0f3460 100%);
    --safe-area-top: 0px;
    --safe-area-bottom: 0px;
    --safe-area-left: 0px;
    --safe-area-right: 0px;
}

/* Theme Variants */
[data-theme="light"] {
    --glass-bg: rgba(255, 255, 255, 0.25);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-primary: #1a1a2e;
    --text-secondary: rgba(26, 26, 46, 0.8);
    --shadow-glow: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 15px 35px rgba(0, 0, 0, 0.2);
    --accent-color: #3e7eff;
    --dynamic-bg-color: #667eea;
    --dynamic-bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    height: -webkit-fill-available;
    background: var(--dynamic-bg-gradient) !important;
    background-color: var(--dynamic-bg-color) !important;
    background-attachment: scroll !important;
    background-size: cover !important;
    background-repeat: no-repeat !important;
}

body {
    background: var(--dynamic-bg-gradient) !important;
    background-color: var(--dynamic-bg-color) !important;
    background-attachment: scroll !important;
    background-size: cover !important;
    background-repeat: no-repeat !important;
    font-family: 'Poppins', sans-serif;
    overflow-x: hidden;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -webkit-overflow-scrolling: touch;
    transition: background 0.3s ease;
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Desktop Fallback */
@media (min-width: 1024px) {
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--dynamic-bg-gradient) !important;
        z-index: -3;
        pointer-events: none;
        transition: all 0.5s ease;
    }
    body { background: none !important; }
}

/* iOS Safari Fixes */
@supports (-webkit-touch-callout: none) {
    html, body {
        background: var(--dynamic-bg-gradient) !important;
        background-color: var(--dynamic-bg-color) !important;
        background-attachment: scroll !important;
        background-size: 100% 100% !important;
        background-repeat: no-repeat !important;
        min-height: 100vh !important;
        min-height: -webkit-fill-available !important;
    }
}

/* Boom Game States */
body.boom-game {
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.8s ease;
}

body.boom-game::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 200, 255, 0.2) 0%, transparent 50%);
    z-index: -2;
    animation: backgroundShift 20s ease infinite;
}

body.exploded {
    background: var(--explode-bg) !important;
    background-color: #ff4757 !important;
    animation: explosionShake 0.5s ease-out;
}

body.exploded::before {
    background: linear-gradient(135deg, #ff4757 0%, #c44569 50%, #2c2c54 100%) !important;
}

body.exploded::after {
    display: none;
}

/* Keyframes */
@keyframes explosionShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px) rotate(-1deg); }
    75% { transform: translateX(10px) rotate(1deg); }
}

@keyframes backgroundShift {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.1); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

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

@keyframes slideInFromTop1 {
    from { opacity: 0; transform: translateY(-100px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes float {
    0%, 100% { transform: translateY(100vh) rotate(0deg); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateY(-100px) rotate(360deg); }
}

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

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

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    transition: opacity 0.3s ease;
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
}

.particles.disabled {
    opacity: 0;
    pointer-events: none;
}

.particle {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    animation: float 6s ease-in-out infinite;
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
    will-change: transform;
}

.particle:nth-child(1) { width: 4px; height: 4px; left: 10%; animation-delay: 0s; }
.particle:nth-child(2) { width: 6px; height: 6px; left: 20%; animation-delay: 1s; }
.particle:nth-child(3) { width: 3px; height: 3px; left: 30%; animation-delay: 2s; }
.particle:nth-child(4) { width: 5px; height: 5px; left: 40%; animation-delay: 0.5s; }
.particle:nth-child(5) { width: 4px; height: 4px; left: 50%; animation-delay: 1.5s; }
.particle:nth-child(6) { width: 6px; height: 6px; left: 60%; animation-delay: 3s; }
.particle:nth-child(7) { width: 3px; height: 3px; left: 70%; animation-delay: 2.5s; }
.particle:nth-child(8) { width: 5px; height: 5px; left: 80%; animation-delay: 4s; }
.particle:nth-child(9) { width: 4px; height: 4px; left: 90%; animation-delay: 0.8s; }

/* Light Theme Particles */
[data-theme="light"] .particle {
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

/* Reduced Animations */
.reduced-animations * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

.reduced-animations .particle {
    display: none !important;
}

/* Age Modal */
.age-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalFade 0.5s ease-out;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: rgba(26, 26, 46, 0.85);
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    padding: 50px 40px;
    text-align: center;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlide 0.8s ease-out;
    color: var(--text-primary);
    position: relative;
    margin: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content h2 {
    font-family: 'Orbitron', monospace;
    font-size: 2.2rem;
    margin-bottom: 25px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    -webkit-text-size-adjust: none;
}

.modal-content p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 30px;
    color: var(--text-secondary);
}

.modal-buttons {
    display: flex;
    gap: 20px;
    margin-top: 30px;
}

.modal-btn {
    flex: 1;
    padding: 18px 30px;
    border: none;
    border-radius: 15px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    text-transform: uppercase;
    letter-spacing: 1px;
    -webkit-tap-highlight-color: transparent;
}

.accept-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.decline-btn {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(250, 112, 154, 0.3);
}

/* Header */
header {
    position: relative;
    z-index: 100;
    text-align: center;
    padding: 40px 20px;
    padding-top: max(40px, calc(var(--safe-area-top, 0px) + 20px));
}

.main-title, #maintitle1 {
    font-family: 'Orbitron', monospace;
    font-size: clamp(3rem, 8vw, 8rem);
    font-weight: 900;
    text-align: center;
    margin: 0 0 30px 0;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24, #f0932b, #eb4d4b, #6c5ce7);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 8s ease infinite, titlePulse 2s ease-in-out infinite alternate;
    cursor: pointer;
    transition: all 0.3s ease;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    -webkit-text-size-adjust: none;
}

#maintitle1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    animation: gradientShift 8s ease infinite, slideInFromTop1 1s forwards;
}

/* Theme Toggle */
.theme-toggle-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0 40px 0;
    gap: 15px;
}

.theme-toggle {
    position: relative;
    width: 80px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--glass-border);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-glow);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.theme-toggle.active {
    background: linear-gradient(135deg, #ffa500 0%, #ff6b35 100%);
    border-color: #ffa500;
    box-shadow: 0 0 20px rgba(255, 165, 0, 0.4);
}

.theme-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
}

.theme-toggle.active .theme-slider {
    transform: translateX(40px);
    -webkit-transform: translateX(40px) translate3d(0,0,0);
}

.theme-icon {
    transition: all 0.3s ease;
}

.theme-label {
    font-family: 'Orbitron', monospace;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Settings Icon */
.settings-icon {
    position: fixed;
    top: max(30px, calc(var(--safe-area-top, 0px) + 10px));
    left: max(30px, var(--safe-area-left, 30px));
    width: 65px;
    height: 65px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 200;
    box-shadow: var(--shadow-glow);
    font-size: 1.8rem;
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Settings Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    -webkit-backdrop-filter: blur(30px);
    backdrop-filter: blur(30px);
    z-index: 500;
    transition: left 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: max(0px, var(--safe-area-top, 0px));
    padding-bottom: max(0px, var(--safe-area-bottom, 0px));
    padding-left: max(0px, var(--safe-area-left, 0px));
    padding-right: max(0px, var(--safe-area-right, 0px));
}

.sidebar.open {
    left: 0;
}

.sidebar-content {
    text-align: center;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 2px solid var(--glass-border);
    border-radius: 30px;
    padding: 60px 50px;
    box-shadow: var(--shadow-glow);
    max-width: 500px;
    width: 90%;
    margin: 20px;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    color: var(--text-primary);
}

.sidebar-title {
    font-family: 'Orbitron', monospace;
    font-size: 3rem;
    margin-bottom: 40px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    -webkit-text-size-adjust: none;
}

.close-btn {
    position: absolute;
    top: max(30px, calc(var(--safe-area-top, 0px) + 10px));
    right: max(30px, calc(var(--safe-area-right, 0px) + 10px));
    background: none;
    border: none;
    color: #ff4757;
    font-size: 3.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    -webkit-tap-highlight-color: transparent;
    z-index: 501;
}

/* Settings Options */
.settings-option {
    margin: 30px 0;
    padding: 25px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    transition: all 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.settings-option h3 {
    font-family: 'Orbitron', monospace;
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    -webkit-text-size-adjust: none;
}

.settings-option p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Toggle Switches */
.toggle-switch {
    position: relative;
    width: 70px;
    height: 35px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--glass-border);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.toggle-switch.active {
    background: var(--success-gradient);
    border-color: var(--success-color);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 27px;
    height: 27px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
}

.toggle-switch.active .toggle-slider {
    transform: translateX(35px);
    -webkit-transform: translateX(35px) translate3d(0,0,0);
}

/* Player Input */
.player-input {
    max-width: 600px;
    margin: 0px auto;
    padding: 50px 40px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 2px solid var(--glass-border);
    border-radius: 30px;
    box-shadow: var(--shadow-glow);
    text-align: center;
    animation: slideUp 0.8s ease-out;
    color: var(--text-primary);
}

.player-input h2 {
    font-family: 'Orbitron', monospace;
    font-size: 2rem;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.player-input input {
    width: 100%;
    max-width: 300px;
    padding: 20px;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 25px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    font-family: 'Orbitron', monospace;
    font-weight: 600;
    font-size: 16px !important;
    -webkit-appearance: none;
    -webkit-border-radius: 15px;
}

.player-input input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 25px rgba(79, 172, 254, 0.4);
    transform: scale(1.02);
}

.player-input input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.start-btn {
    padding: 18px 45px;
    font-size: 1.3rem;
    font-weight: 700;
    background: var(--success-gradient);
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: var(--shadow-glow);
    font-family: 'Orbitron', monospace;
    text-transform: uppercase;
    letter-spacing: 1px;
    -webkit-tap-highlight-color: transparent;
}

/* Game Cards */
.games-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 40px;
    max-width: 1200px;
    margin: 0px auto;
    padding: 0 20px;
}

.game-card {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 2px solid var(--glass-border);
    border-radius: 30px;
    padding: 50px 35px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: var(--shadow-glow);
    position: relative;
    overflow: hidden;
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s;
}

.game-card:nth-child(1) { animation-delay: 0.1s; border-left: 4px solid #4facfe; }
.game-card:nth-child(2) { animation-delay: 0.2s; border-left: 4px solid #f093fb; }
.game-card:nth-child(3) { animation-delay: 0.3s; border-left: 4px solid #fa709a; }
.game-card:nth-child(4) { animation-delay: 0.4s; border-left: 4px solid #fee140; }

.game-emoji {
    font-size: 4.5rem;
    margin-bottom: 25px;
    display: block;
    animation: bounce 2s ease-in-out infinite;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.3));
}

.game-card:nth-child(1) .game-emoji { animation-delay: 0s; }
.game-card:nth-child(2) .game-emoji { animation-delay: 0.5s; }
.game-card:nth-child(3) .game-emoji { animation-delay: 1s; }
.game-card:nth-child(4) .game-emoji { animation-delay: 1.5s; }

.game-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 15px;
    font-family: 'Orbitron', monospace;
}

.game-description {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

/* Footer */
.footer {
    margin-top: 120px;
    padding: 50px 40px;
    text-align: center;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-top: 2px solid var(--glass-border);
    color: var(--text-primary);
    padding-bottom: max(50px, calc(var(--safe-area-bottom, 0px) + 30px));
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 50px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    padding: 15px 25px;
    border-radius: 15px;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.footer-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(79, 172, 254, 0.1), transparent);
    transition: left 0.6s;
}

.online-count {
    font-size: 1.4rem;
    color: #4facfe;
    font-weight: 700;
    margin-top: 25px;
    font-family: 'Orbitron', monospace;
    text-shadow: 0 2px 10px rgba(79, 172, 254, 0.3);
}

/* Name Inputs */
.name-inputs {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 30px 0;
    max-height: 400px;
    overflow-y: auto;
    padding: 25px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    -webkit-overflow-scrolling: touch;
}

.name-input {
    padding: 18px 20px;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    color: var(--text-primary);
    text-align: center;
    transition: all 0.3s ease;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    font-size: 16px !important;
    -webkit-appearance: none;
    -webkit-border-radius: 15px;
}

.name-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 20px rgba(79, 172, 254, 0.3);
    transform: scale(1.02);
}

.name-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Notification System */
.notification {
    position: fixed;
    top: max(20px, calc(var(--safe-area-top, 0px) + 5px));
    right: max(20px, var(--safe-area-right, 20px));
    padding: 20px 30px;
    border-radius: 15px;
    color: white;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
    z-index: 9999;
    transform: translateX(400px);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-glow);
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 380px;
    min-width: 300px;
}

.notification.show {
    transform: translateX(0);
}

.notification-error {
    background: linear-gradient(135deg, rgba(255, 71, 87, 0.9), rgba(196, 69, 105, 0.9));
    border-left: 4px solid #ff4757;
}

.notification-success {
    background: linear-gradient(135deg, rgba(79, 172, 254, 0.9), rgba(0, 242, 254, 0.9));
    border-left: 4px solid #4facfe;
}

.notification-info {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9), rgba(118, 75, 162, 0.9));
    border-left: 4px solid #667eea;
}

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

.notification-text {
    flex: 1;
    line-height: 1.4;
}

/* Hidden Class */
.hidden {
    display: none !important;
}

/* Backdrop Filter Fallback */
@supports not (backdrop-filter: blur(20px)) {
    .age-modal {
        background: rgba(0, 0, 0, 0.9) !important;
    }
    
    .modal-content, .sidebar-content, .settings-icon, .player-input, .game-card {
        background: rgba(26, 26, 46, 0.95) !important;
        border: 2px solid rgba(255, 255, 255, 0.2);
    }
    
    [data-theme="light"] .modal-content,
    [data-theme="light"] .sidebar-content,
    [data-theme="light"] .settings-icon,
    [data-theme="light"] .player-input,
    [data-theme="light"] .game-card {
        background: rgba(230, 230, 250, 0.95) !important;
        border: 2px solid rgba(0, 0, 0, 0.2);
    }
}

/* Light Theme Input Styling */
[data-theme="light"] .player-input input,
[data-theme="light"] .name-input {
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.6);
    color: var(--text-primary);
}

/* Light Theme Overrides */
[data-theme="light"] .main-title,
[data-theme="light"] #maintitle1 {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

[data-theme="light"] .game-card,
[data-theme="light"] .player-input,
[data-theme="light"] .modal-content,
[data-theme="light"] .sidebar-content,
[data-theme="light"] .footer {
    color: var(--text-primary) !important;
}

[data-theme="light"] input {
    color: var(--text-primary) !important;
}

[data-theme="light"] .particle {
    background: rgba(255, 255, 255, 0.4) !important;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4) !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    /* iOS Safari Touch Fixes - Complete Implementation */
    .game-card, .start-btn, .modal-btn, button, .settings-icon, .theme-toggle, .toggle-switch, .close-btn, .footer-link {
        -webkit-transform: none !important;
        transform: none !important;
        -webkit-transition: opacity 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease !important;
        transition: opacity 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease !important;
    }
    
    .game-card:active {
        opacity: 0.85 !important;
        background-color: rgba(79, 172, 254, 0.15) !important;
        -webkit-transform: none !important;
        transform: none !important;
        box-shadow: 0 4px 20px rgba(79, 172, 254, 0.3) !important;
    }
    
    .start-btn:active, button:active, .modal-btn:active {
        opacity: 0.85 !important;
        -webkit-transform: none !important;
        transform: none !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important;
    }
    
    .settings-icon:active, .theme-toggle:active, .toggle-switch:active {
        opacity: 0.85 !important;
        -webkit-transform: none !important;
        transform: none !important;
        background-color: rgba(79, 172, 254, 0.1) !important;
    }
    
    .close-btn:active, .footer-link:active {
        opacity: 0.85 !important;
        -webkit-transform: none !important;
        transform: none !important;
    }
    
    * {
        -webkit-transform-style: flat !important;
        transform-style: flat !important;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    input, textarea {
        -webkit-user-select: text;
        -webkit-touch-callout: default;
    }

/* Small Screens */
@media (max-width: 480px) {
    .sidebar-content {
        padding: 40px 20px;
        margin: 10px;
        max-height: 85vh;
        border-radius: 20px;
    }
    
    .sidebar-title {
        font-size: 2rem;
        margin-bottom: 30px;
    }
    
    .close-btn {
        top: max(15px, calc(var(--safe-area-top, 0px) + 5px));
        right: max(15px, calc(var(--safe-area-right, 0px) + 5px));
        font-size: 2rem;
        width: 40px;
        height: 40px;
    }
    
    .settings-option {
        padding: 20px 15px;
        margin: 20px 0;
        border-radius: 15px;
    }
    
    .settings-option h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
        flex-direction: column;
        gap: 8px;
    }
    
    .settings-option p {
        font-size: 0.85rem;
        margin-bottom: 15px;
    }
    
    .toggle-switch {
        width: 60px;
        height: 30px;
        border-width: 1px;
    }
    
    .toggle-slider {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
        top: 1px;
        left: 1px;
    }
    
    .toggle-switch.active .toggle-slider {
        transform: translateX(30px);
        -webkit-transform: translateX(30px) translate3d(0,0,0);
    }
    
    .main-title, #maintitle1 {
        font-size: 3rem;
    }
    
    .theme-toggle {
        width: 60px;
        height: 30px;
    }
    
    .theme-slider {
        width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }
    
    .theme-toggle.active .theme-slider {
        transform: translateX(30px);
    }
    
    .game-card {
        padding: 35px 20px;
    }
    
    .game-emoji {
        font-size: 3.5rem;
    }
    
    .notification {
        padding: 12px 15px;
        max-width: 280px;
        min-width: 220px;
        font-size: 0.9rem;
        top: max(10px, calc(var(--safe-area-top, 0px) + 5px));
        right: max(10px, var(--safe-area-right, 10px));
        border-radius: 12px;
    }
    
    .settings-icon {
        top: max(15px, calc(var(--safe-area-top, 0px) + 5px));
        left: max(15px, var(--safe-area-left, 15px));
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
    
    .player-input {
        margin: 15px 10px;
        padding: 30px 20px;
        border-radius: 20px;
    }
    
    .player-input h2 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
    
    .player-input input {
        padding: 15px;
        font-size: 16px !important;
        border-radius: 12px;
        max-width: 250px;
    }
    
    .start-btn {
        padding: 15px 35px;
        font-size: 1.1rem;
        border-radius: 15px;
    }
    
    .footer {
        margin-top: 80px;
        padding: 30px 20px;
        padding-bottom: max(30px, calc(var(--safe-area-bottom, 0px) + 20px));
    }
    
    .footer-links {
        gap: 15px;
    }
    
    .footer-link {
        padding: 12px 20px;
        font-size: 0.9rem;
        border-radius: 12px;
    }
    
    .online-count {
        font-size: 1.2rem;
        margin-top: 20px;
    }
}

/* Mobile Age Modal */
@media (max-width: 768px) {
    .age-modal {
        padding: 15px;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
    
    .modal-content {
        padding: 40px 25px;
        max-width: 90%;
        width: 100%;
        max-height: 85vh;
        margin: 0;
        align-self: center;
        justify-self: center;
    }
    
    .modal-btn {
        width: 100%;
        padding: 18px 20px;
        font-size: 1rem;
    }
}

/* Desktop Hover Effects */
@media (hover: hover) and (pointer: fine) {
    .modal-btn:hover, .start-btn:hover, .settings-icon:hover, .footer-link:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-hover);
    }
    
    .game-card:hover::before {
        left: 100%;
    }
    
    .game-card:hover {
        transform: translateY(-15px) scale(1.03);
        box-shadow: var(--shadow-hover);
        border-color: var(--accent-color);
    }
    
    .main-title:hover, #maintitle1:hover {
        transform: scale(1.05);
        filter: drop-shadow(0 8px 25px rgba(255, 255, 255, 0.4));
    }
    
    [data-theme="light"] .main-title:hover,
    [data-theme="light"] #maintitle1:hover {
        filter: drop-shadow(0 8px 25px rgba(0, 0, 0, 0.4));
    }
    
    .settings-icon:hover {
        transform: rotate(180deg) scale(1.1);
        border-color: var(--accent-color);
    }
    
    .close-btn:hover, .close-btn:active {
        transform: rotate(90deg) scale(1.2);
        background: rgba(255, 71, 87, 0.1);
    }
    
    .settings-option:hover, .settings-option:active {
        background: rgba(255, 255, 255, 0.1);
        transform: translateY(-2px);
    }
    
    .footer-link:hover {
        color: var(--text-primary);
        background: rgba(79, 172, 254, 0.1);
        border: 1px solid rgba(79, 172, 254, 0.3);
    }
    
    .footer-link:hover::before {
        left: 100%;
    }
}

/* Touch States */
@media (hover: none) and (pointer: coarse) {
    .game-card:active, .settings-icon:active, .start-btn:active {
        opacity: 0.8;
        transition: opacity 0.1s ease;
    }
}

/* Loading States */
.loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid transparent;
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Error/Success States */
.error {
    border-color: #ff4757 !important;
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.3) !important;
}

.error input {
    border-color: #ff4757 !important;
    box-shadow: 0 0 15px rgba(255, 71, 87, 0.2) !important;
}

.success {
    border-color: #2ed573 !important;
    box-shadow: 0 0 20px rgba(46, 213, 115, 0.3) !important;
}

/* Focus States */
button:focus, input:focus, .game-card:focus, .settings-icon:focus, .toggle-switch:focus {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

/* Landscape Mode */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .main-title, #maintitle1 {
        font-size: 2.5rem;
        margin-bottom: 15px;
    }
    
    .theme-toggle-container {
        margin: 10px 0 20px 0;
    }
    
    .player-input {
        padding: 30px 25px;
        margin: 15px;
    }
    
    .game-card {
        padding: 30px 20px;
    }
    
    .modal-content, .sidebar-content {
        padding: 30px 25px;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Ultra-wide Screens */
@media (min-width: 1920px) {
    .games-container {
        grid-template-columns: repeat(4, 1fr);
        max-width: 1600px;
    }
    
    .main-title, #maintitle1 {
        font-size: 10rem;
    }
    
    .game-card {
        padding: 60px 40px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .particle {
        display: none !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --glass-bg: rgba(0, 0, 0, 0.9);
        --glass-border: rgba(255, 255, 255, 0.8);
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
    }
    
    [data-theme="light"] {
        --glass-bg: rgba(255, 255, 255, 0.9);
        --glass-border: rgba(0, 0, 0, 0.8);
        --text-primary: #000000;
        --text-secondary: #333333;
    }
}

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

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 4px;
    transition: background 0.3s ease;
}

[data-theme="light"] ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) rgba(255, 255, 255, 0.1);
}

[data-theme="light"] * {
    scrollbar-color: var(--accent-color) rgba(0, 0, 0, 0.1);
}

/* Selection Styling */
::selection {
    background: var(--accent-color);
    color: white;
}

/* Placeholder Styling */
::placeholder, ::-webkit-input-placeholder, ::-moz-placeholder, :-ms-input-placeholder, :-moz-placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* iOS Safari Final Fixes */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-user-select: none;
        -webkit-touch-callout: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    input, textarea {
        -webkit-user-select: text;
        -webkit-touch-callout: default;
    }
    
    @media screen and (-webkit-min-device-pixel-ratio: 0) {
        select, textarea, input[type="text"], input[type="password"], 
        input[type="datetime"], input[type="datetime-local"], 
        input[type="date"], input[type="month"], input[type="time"], 
        input[type="week"], input[type="number"], input[type="email"], 
        input[type="url"], input[type="search"], input[type="tel"], 
        input[type="color"] {
            font-size: 16px !important;
        }
    }
}
}