
@font-face {
    font-family: 'NXBaskerville';
    src: url('/fonts/WorcesterRegular.otf') format('truetype');
    font-weight: normal;
    font-style: normal;
}


:root {
    /* Typography */
    --font-primary: 'NXBaskerville', serif;
    --font-secondary: 'NXBaskerville', serif;
    
    /* Color Scheme */
    --primary-color: #2d1f2e;
    --primary-light: #9f7aea;
    --primary-dark: #1a121b;
    --accent-color: #849d14;
    --accent-light: #849d14;
    --background-color: #0a0d12;
    --surface-color: #2e272f;
    --text-color: #ffffff;
    --text-secondary: #cbd5e0;
    --success-color: #849d14;
    --warning-color: #f39c12;
    --error-color: #e74c3c;
    --color-background: #0a0d12;
    --color-text: #ffffff;
    --color-text-dark: #cbd5e0;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    
    /* Border Radius */
    --border-radius-sm: 6px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 3rem;
    --spacing-xl: 6rem;
    
    /* Transitions */
    --transition-fast: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Chess-specific colors */
    --color-white-square: #f0d9b5;
    --color-black-square: #b58863;
    --color-white-piece: #ffffff;
    --color-black-piece: #000000;
    --color-selected: rgba(159, 122, 234, 0.4);
    --color-legal-move: rgb(2, 186, 2);
    --color-check: rgba(255, 0, 0, 0.5);
    
    /* Game layout variables */
    --panel-width: 300px;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Allow text selection only in specific elements */
.chatinput input,
.game-id-box input,
input[type="text"],
input[type="password"],
input[type="email"],
textarea {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* Body Styles */
body {
    font-family: 'NXBaskerville', serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(74, 144, 226, 0.05) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(231, 76, 60, 0.05) 0%, transparent 20%);
}

/* Header Styles */
.header {
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, rgb(42, 41, 43), rgba(42, 41, 43)) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    -webkit-backdrop-filter: blur(10px);
    transform: translateZ(0);
    will-change: transform;
    padding: 10px 20px;
    box-sizing: border-box;
    height: 70px;
    overflow: visible;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    transition: background-color var(--transition-normal);
    background: transparent !important; /* Transparent header by default */
    box-shadow: none !important;        /* No shadow by default */
    transition: background 0.3s, box-shadow 0.3s;
    border: none;
}

/* Mobile header styling for non-authenticated users */
@media (max-width: 768px) {
    body:not(.authenticated) .header {
        background: #282825 !important; /* Override transparent background with black for non-authenticated users on mobile */
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important; /* Add shadow for non-authenticated users on mobile */
    }
}

/* Logo Styles */
.logo-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    height: 100%;
    width: 200px;
    transition: width var(--transition-normal);
}

.logo-img {
    height: 100%;
    width: auto;
    max-height: 50px; /* Set a maximum height for the logo */
    transition: all var(--transition-normal);
    object-fit: contain;
}

/* Auth Section */
.header-auth {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    height: 100%;
}


.header-auth > div {
    display: flex;
    align-items: center;
    gap: 8px; /* Add a small gap between buttons */
    height: 100%;
}

/* Ensure header nav links for non-authenticated users always use Neucha font */
.header-auth {
    font-family:  'NXBaskerville', serif !important; /* Use Neucha, fallback to cursive */
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* Main Content Layout */
.main-content {
    min-height: 100vh;
    padding-top: 70px;
    overflow-y: auto;
    scroll-behavior: auto;
    position: relative;
    z-index: 2;
    scroll-snap-type: none;
}

/* Hero Section */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.55)), url('/images/bnwthess.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    padding: var(--spacing-xl);
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}
.hero-content {
    max-width: 900px;
    position: relative;
    z-index: 2;
}

.hero-content h1 {
    font-size: 4.5rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-color);
    text-shadow: none;
    animation: fadeInUp 1s ease-out;
}

.hero-content p {
    font-size: 1.4rem;
    margin-bottom: var(--spacing-lg);
    color: var(--text-secondary);
    animation: fadeInUp 1s ease-out 0.2s backwards;
}

/* ================= FOOTER (RESPONSIVE) ================= */
.site-footer {
  background: rgb(35, 35, 35); /* Footer background */
  padding: 6vw 3vw; /* Responsive padding */
  color: var(--text-secondary); /* Footer text color */
  position: relative; /* For stacking */
  overflow: hidden; /* Hide overflow */
}

.site-footer::before {
  position: absolute; /* Absolute positioning */
  top: 0; left: 0; right: 0;
  height: 0.1em; /* Responsive height */
  background: linear-gradient(90deg, transparent, var(--primary-light), transparent); /* Gradient line */
}

.footer-content {
  display: grid; /* Use grid for layout */
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); /* Responsive columns */
  gap: 3vw; /* Responsive gap */
  max-width: 1200px; /* Max width for large screens */
  margin: 0 auto; /* Center horizontally */
  position: relative; /* For stacking */
  z-index: 1; /* Above background */
  text-align: center; /* Center all content */
}

.footer-section h3 {
  color: var(--text-color); /* Section title color */
  margin-bottom: 2vw; /* Responsive margin */
}

.footer-section ul {
  list-style: none; /* Remove bullets */
}

.footer-section ul li {
  margin-bottom: 1vw; /* Responsive margin */
}

.footer-link {
  color: var(--text-secondary); /* Footer link color */
  text-decoration: none; /* Remove underline */
  transition: color 0.3s ease; /* Smooth color transition */
  font-size: 0.9rem; /* Slightly smaller font */
}

.footer-link:hover {
  color: var(--primary-light); /* Highlight on hover */
  text-decoration: underline; /* Add underline on hover */
}

.social-links {
  display: flex; /* Flexbox for layout */
  gap: 2vw; /* Responsive gap */
  margin-top: 2vw; /* Responsive margin */
  justify-content: center; /* Center horizontally */
  align-items: center; /* Center vertically */
}

.social-link {
  color: var(--text-secondary); /* Social icon color */
  font-size: 2vw; /* Responsive icon size */
  transition: all 0.4s; /* Smooth transition */
  display: inline-flex; /* Inline flex for icons */
  align-items: center; /* Center vertically */
  justify-content: center; /* Center horizontally */
  width: 3em; /* Responsive width */
  height: 3em; /* Responsive height */
  border-radius: 50%; /* Circular icons */
  background: rgba(255, 255, 255, 0.05); /* Subtle background */
}

.social-link:hover {
  color: var(--primary-light); /* Highlight on hover */
  background: rgba(74, 144, 226, 0.1); /* Subtle background on hover */
  transform: translateY(-0.3em); /* Lift on hover */
}

.footer-bottom {
  text-align: center; /* Center text */
  margin-top: 4vw; /* Responsive margin */
  padding-top: 2vw; /* Responsive padding */
  border-top: 0.1em solid #d9cbbc; /* Subtle border */
  font-size: 1em; /* Responsive font size */
}

/* Buttons - Base styles */
.btn {
    /* Base button styling */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    font-weight: 600;
    transition: all var(--transition-normal);
    cursor: pointer;
    border: none;
    font-size: 1rem;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    text-transform: uppercase;
    border-radius: .15rem;
    width: 200px;
    padding: .150rem .75rem;
    margin: 30px auto;
    font-family: 'PT Sans', sans-serif;
    letter-spacing: 2px;
}

/* Hover effect for all buttons */
.btn:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Shine effect for all buttons */
.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transform: translateX(-100%);
    transition: transform 0.8s ease;
}

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

.btn-home {
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'NXBaskerville', serif;
    border-radius: var(--border-radius-md);
    transition: all var(--transition-normal);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 36px;
    text-decoration: none;
    z-index: 10;
    border-top-left-radius: var(--border-radius-md);
    border-bottom-left-radius: var(--border-radius-md);
}

.btn-home:hover {
    transform: translateY(-1px);
    transform: scale(0.95);
    box-shadow: 0 2px 10px rgba(138, 43, 226, 0.3);
}

/* Copy and Join buttons */
.copy-btn, .join-btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--border-radius-sm);
    background: var(--success-color);
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
}

.copy-btn:hover, .join-btn:hover {
    background: var(--primary-dark);
}

/* Sign in/out buttons */
.btn-sign-in, .btn-sign-out, .btn-home {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-md);
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    height: 40px;
    white-space: nowrap;
    transition: all var(--transition-normal);
}

.btn-sign-out {
    border-top-right-radius: var(--border-radius-md);
    border-bottom-right-radius: var(--border-radius-md);
    border-left: none;
}

.btn-sign-in:hover, .btn-sign-out:hover, .btn-home:hover {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

/* Fix for sign-out button hover */
.btn-sign-out:hover {
    border-left: none;  /* Ensure left border stays removed on hover */
    border-top: 1px solid rgba(255, 255, 255, 0.2);  /* Match other borders */
    border-right: 1px solid rgba(255, 255, 255, 0.2);  /* Match other borders */
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);  /* Match other borders */
}

/* Yes/No buttons */
.btn-yes {
    background: var(--error-color);
    color: white;
}

.btn-yes:hover {
    background: var(--error-dark);
}

.btn-no {
    background: var(--primary-color);
    color: var(--text-color);
}

.btn-no:hover {
    background: var(--primary-dark);
}

/* Close Button */
.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 15px;
    top: 50%;
}

.close-btn:hover {
    color: var(--text-color);
    transform: rotate(90deg);
}

/* Notification styles */
.notification {
    /* Position */
    position: fixed;
    top: 5px;
    right: 20px;
    z-index: 10000;

    /* Layout */
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    
    /* Appearance */
    background: rgba(26, 31, 38, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(8px);
    
    /* Text */
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    
    /* Animation */
    animation: slideIn 0.3s ease-out forwards;
}

/* Notification types */
.notification.success {
    border-left: 4px solid #4CAF50;
}

.notification.error {
    border-left: 4px solid #f44336;
}

.notification.info {
    border-left: 4px solid #2196F3;
}

/* Icon styles */
.notification i {
    font-size: 1.2em;
}

.notification.success i {
    color: #4CAF50;
}

.notification.error i {
    color: #f44336;
}

.notification.info i {
    color: #2196F3;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
} 

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 10px;
    }
    
    .logo-container {
        width: 150px;
    }
    
    .logo-img {
        max-height: 40px;
    }
    
    .header-auth {
        gap: var(--spacing-sm);
    }
    
    .header-auth > div {
        gap: 3px; /* Slightly smaller gap on tablets */
    }
    
    .btn-sign-in, .btn-sign-out, .btn-home {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 8px;
    }
    
    .logo-container {
        width: 120px;
    }
    
    .logo-img {
        max-height: 35px;
    }
    
    .header-auth {
        gap: var(--spacing-xs);
    }
    
    .header-auth > div {
        gap: 2px; /* Even smaller gap on mobile */
    }
    
    .btn-sign-in, .btn-sign-out, .btn-home {
        padding: 0.3rem 0.6rem;
        font-size: 0.85rem;
    }
}

/* Audio Player Styles */
.music-player {
    position: fixed;      /* Changed from relative to fixed */
    bottom: 5px;         /* Updated to match the fragment position */
    right: 20px;         /* Position from right */
    width: 45px;         /* Keep the same width */
    height: 22px;        /* Keep the same height */
    background: #ff4444; /* Red background when muted */
    border-radius: 11px; /* Keep the same border radius */
    cursor: pointer;     /* Keep pointer cursor */
    transition: all 0.3s ease;  /* Keep smooth transitions */
    display: flex;       /* Keep flex container */
    align-items: center; /* Keep vertical centering */
    border: none;        /* Keep no border */
    padding: 0;          /* Keep no padding */
    margin: 0;           /* Remove margin since it's fixed positioned */
    z-index: 1000;       /* Ensure it stays on top */
}

.music-player::before {
    content: '';         /* Empty content */
    position: absolute;  /* Position absolutely */
    left: 2px;          /* Adjusted from 3px */
    width: 18px;        /* Reduced from 24px */
    height: 18px;       /* Reduced from 24px */
    background: white;   /* White circle */
    border-radius: 50%;  /* Make it circular */
    transition: all 0.3s ease;  /* Smooth transitions */
}

.music-player.unmuted {
    background: #4CAF50; /* Green background when unmuted */
}

.music-player.unmuted::before {
    left: calc(100% - 20px); /* Adjusted from 27px */
}

/* Remove old icon styles */
.music-player i {
    display: none;      /* Hide the icon */
}

.music-credits {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: rgba(26, 22, 37, 0.95);  /* Dark purple background */
    color: white;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 0.85em;
    max-width: 300px;
    display: none;
    z-index: 1000;
    border-left: 4px solid #fafafa;  /* Purple accent border */
    box-shadow: 0 2px 10px rgba(107, 70, 193, 0.3);  /* Purple shadow */
    cursor: default;  /* Changed from pointer to default */
    transition: all 0.3s ease;  /* Smooth transition for hover effect */
}

.music-credits:hover {
    transform: none;  /* Remove hover effect */
}

.music-credits.show {
    display: block;
}

.music-credits .close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    color: #9f7aea;  /* Light purple close button */
    cursor: pointer;
    font-size: 1.2em;
    padding: 0;
}

.music-credits .close-btn:hover {
    color: #ffffff;  /* Darker purple on hover */
}

.music-credits .title {
    font-weight: bold;
    color: #ffffff;  /* Light purple title */
    font-size: 1.1em;
}

.music-credits .license {
    font-size: 0.9em;
    color: #fefeff;  /* Light purple license text */
    margin-top: 8px;
    border-top: 1px solid rgba(107, 70, 193, 0.3);  /* Purple separator */
    padding-top: 8px;
}

/* Add tooltip styles */
.music-player::after {
    content: attr(data-tooltip) !important;  /* Force use data-tooltip attribute for text */
    position: absolute;       /* Position absolutely */
    bottom: 100%;            /* Position above the toggle */
    left: 50%;               /* Center horizontally */
    transform: translateX(-50%);  /* Center the tooltip */
    padding: 5px 10px;       /* Add padding */
    background: rgba(0, 0, 0, 0.8);  /* Dark background */
    color: white;            /* White text */
    font-size: 12px;         /* Small font size */
    border-radius: 4px;      /* Rounded corners */
    white-space: nowrap;     /* Keep text in one line */
    opacity: 0;              /* Start invisible */
    visibility: hidden;      /* Hide by default */
    transition: all 0.3s ease;  /* Smooth transition */
    pointer-events: none;    /* Prevent tooltip from interfering with clicks */
}

.music-player:hover::after {
    opacity: 1;              /* Show on hover */
    visibility: visible;     /* Make visible on hover */
    bottom: calc(100% + 5px);  /* Add some space between toggle and tooltip */
}

/* Responsive design for modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: var(--spacing-sm);
    }
    
    .color-selection {
        flex-direction: column;
    }
    
    .color-option {
        flex: none;
        width: 100%;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn-cancel, .btn-create {
        width: 100%;
    }
}

/* Game Creation Popup Styles */
.game-creation-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: linear-gradient(135deg, rgb(30, 29, 31), rgba(30, 29, 31));
    border: 1px solid rgba(107, 70, 193, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 500px;
    width: 90vw;
    max-height: 80vh;
    overflow: visible !important; /* Allow dropdowns to extend beyond popup */
}

.game-creation-popup.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.game-creation-popup .popup-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.game-creation-popup .popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px 24px;
    border-bottom: 1px solid rgba(107, 70, 193, 0.1);
    background: linear-gradient(135deg, rgba(42, 41, 43, 0.8), rgba(42, 41, 43, 0.6));
}

.game-creation-popup .popup-header h3 {
    color: #ffffff;
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.game-creation-popup .popup-body {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: visible; /* Allow dropdowns to extend beyond the body */
}

.game-creation-popup .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: visible; /* Allow dropdowns to extend beyond form group */
}

.game-creation-popup .form-group label {
    display: block;
    color: #ffffff;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 1rem;
}

.game-creation-popup select,
.game-creation-popup input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(42, 41, 43, 0.8);
    border: 1px solid rgba(107, 70, 193, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

/* Custom Dropdown Styles */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.dropdown-trigger {
    width: 100%;
    padding: 12px 16px;
    background: rgba(42, 41, 43, 0.8);
    border: 1px solid rgba(107, 70, 193, 0.3);
    border-radius: 8px;
    color: #ffffff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.3s ease;
}

.dropdown-trigger:hover {
    border-color: #dbcdbe;
}

.dropdown-trigger.active {
    border-color: #dbcdbe;;
    box-shadow: 0 0 0 2px rgba(107, 70, 193, 0.1);
}

.dropdown-trigger:focus {
    outline: none;
    border-color: #dbcdbe;
    box-shadow: 0 0 0 2px rgba(107, 70, 193, 0.1);
}

.dropdown-trigger i {
    transition: transform 0.3s ease;
}

.dropdown-trigger.active i {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%; /* Always appear below the trigger */
    left: 0;
    right: 0;
    background: rgba(42, 41, 43, 0.95);
    border: 1px solid rgba(107, 70, 193, 0.3);
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-top: 4px;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-group {
    border-bottom: 1px solid rgba(107, 70, 193, 0.1);
}

.dropdown-group:last-child {
    border-bottom: none;
}

.dropdown-group-label {
    padding: 8px 16px;
    background: rgba(42, 41, 43, 0.9);
    color: #a3a3a3;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown-option {
    padding: 10px 16px;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-left: 3px solid transparent;
}

.dropdown-option:hover {
    background: rgba(107, 70, 193, 1);
    border-left-color: rgba(107, 70, 193, 0.5);
}

.dropdown-option.selected {
    background: rgba(107, 70, 193, 1);
    border-left-color: rgba(107, 70, 193, 0.8);
}

/* Ensure dropdown appears downwards */
.game-creation-popup select {
    /* Force dropdown to open downwards */
    direction: ltr; /* Left-to-right direction */
    writing-mode: horizontal-tb; /* Horizontal top-to-bottom writing mode */
    transform-origin: top left; /* Set transform origin to top-left */
    position: relative; /* Ensure proper positioning context */
    /* Force dropdown to open downwards */
    size: auto; /* Allow natural size */
    max-height: none; /* Remove height restrictions */
}

/* Force the dropdown list to appear below the select */
.game-creation-popup select:focus {
    /* Ensure dropdown opens downwards when focused */
    transform: none; /* Remove any transforms that might affect positioning */
}

/* Additional styles to ensure proper dropdown behavior */
.game-creation-popup select option {
    background: rgba(42, 41, 43, 0.95);
    color: #ffffff;
    padding: 8px 12px;
}

.game-creation-popup select optgroup {
    background: rgba(42, 41, 43, 0.9);
    color: #a3a3a3;
    font-weight: 600;
    padding: 8px 12px;
}

.game-creation-popup select:focus,
.game-creation-popup input:focus {
    outline: none;
    border-color: #dbcdbe;;
    box-shadow: 0 0 0 2px rgba(107, 70, 193, 0.1);
}

.game-creation-popup .color-selection {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.game-creation-popup .color-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.game-creation-popup .color-option:hover {
    background: rgba(107, 70, 193, 0.1);
}

.game-creation-popup .color-option input[type="radio"] {
    display: none;
}

.game-creation-popup .color-option input[type="radio"]:checked + .color-box {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px #d9cbbc;
}

.game-creation-popup .color-box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.2s ease;
}

.game-creation-popup .color-box.white-piece {
    background: #f0d9b5;
    color: #b58863;
}

.game-creation-popup .color-box.black-piece {
    background: #b58863;
    color: #f0d9b5;
}

.game-creation-popup .color-box.random-piece {
    background: linear-gradient(45deg, #f0d9b5, #b58863);
    color: #ffffff;
}

.game-creation-popup .create-button-container {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(107, 70, 193, 0.1);
}

.game-creation-popup .btn-create {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #6b46c1, #553c9a);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Username modal specific button styles */
#username-modal .btn-cancel {
    background: linear-gradient(135deg, #991616, #991616);
    color: white;
}

#username-modal .btn-create {
    background: #1b6b05;
    color: white;
    border: 2px solid #2fa70d;
}

.game-creation-popup .btn-create:hover {
    background: linear-gradient(135deg, #553c9a, #44337a);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 70, 193, 0.3);
}

.game-creation-popup .btn-create:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.game-creation-popup .btn-create:disabled:hover {
    background: #666;
    transform: none;
    box-shadow: none;
}

/* Mobile Keyboard Handling Fixes */
@media (max-width: 768px) {
    /* Prevent body scroll when popups are open */
    body.popup-open {
        position: fixed;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
    
    /* Use dynamic viewport height for better keyboard handling */
    .game-creation-popup {
        /* Fix centering and sizing for mobile */
        width: 95vw;
        max-width: 95vw; /* Ensure it doesn't exceed viewport width */
        max-height: 85dvh; /* Use dynamic viewport height for better mobile keyboard handling */
        margin: 0; /* Remove margin that was causing centering issues */
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0.95); /* Slightly smaller scale for mobile */
        border-radius: 12px; /* Smaller border radius for mobile */
        overflow: hidden; /* Prevent content from spilling out */
        position: fixed;
    }
    
    .game-creation-popup.show {
        transform: translate(-50%, -50%) scale(1);
    }
    
    .game-creation-popup .popup-content {
        /* Ensure proper height management */
        height: 100%;
        max-height: 85dvh;
        display: flex;
        flex-direction: column;
    }
    
    .game-creation-popup .popup-header {
        /* Reduce header padding for mobile */
        padding: 16px 20px 12px 20px;
        flex-shrink: 0; /* Prevent header from shrinking */
    }
    
    .game-creation-popup .popup-header h3 {
        font-size: 1.2rem; /* Smaller font size for mobile */
    }
    
    .game-creation-popup .popup-body {
        /* Make body scrollable and properly sized */
        padding: 16px 20px;
        gap: 12px; /* Reduce gap between form elements */
        flex: 1;
        overflow-y: auto; /* Enable scrolling within the popup body */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    .game-creation-popup .form-group {
        gap: 6px; /* Reduce gap between label and input */
    }
    
    .game-creation-popup .form-group label {
        font-size: 0.9rem; /* Smaller label font size */
        margin-bottom: 6px;
    }
    
    .game-creation-popup select,
    .game-creation-popup input {
        padding: 10px 14px; /* Reduce padding for mobile */
        font-size: 0.9rem; /* Smaller font size */
    }
    
    /* Fix dropdown positioning and scrolling on mobile */
    .custom-dropdown {
        position: relative;
    }
    
    .dropdown-menu {
        /* Ensure dropdown is properly positioned and scrollable */
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: 200px; /* Limit dropdown height */
        overflow-y: auto; /* Enable scrolling */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        z-index: 10001; /* Ensure it appears above other elements */
        border-radius: 8px;
        margin-top: 4px;
    }
    
    .dropdown-option {
        padding: 10px 14px; /* Increase touch target size */
        font-size: 0.9rem;
    }
    
    .dropdown-group-label {
        padding: 8px 14px;
        font-size: 0.85rem;
    }
    
    .game-creation-popup .color-selection {
        gap: 8px; /* Reduce gap between color options */
        flex-wrap: wrap; /* Allow wrapping on very small screens */
    }
    
    .game-creation-popup .color-option {
        padding: 6px 10px; /* Reduce padding */
        font-size: 0.9rem;
    }
    
    .game-creation-popup .color-box {
        width: 20px; /* Slightly smaller color boxes */
        height: 20px;
        font-size: 1rem;
    }
    
    .game-creation-popup .create-button-container {
        /* Ensure button container stays at bottom */
        margin-top: auto;
        padding-top: 16px;
        flex-shrink: 0; /* Prevent button container from shrinking */
    }
    
    .game-creation-popup .btn-create {
        padding: 12px 18px; /* Reduce padding */
        font-size: 0.95rem;
        min-height: 44px; /* Ensure minimum touch target size */
    }
    
    /* Fix search results positioning on mobile */
    .search-results {
        max-height: 150px; /* Limit search results height */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .search-result-item {
        padding: 10px 14px; /* Increase touch target size */
        font-size: 0.9rem;
    }
    
    /* Adjust for very small viewport heights (when keyboard is open) */
    @media (max-height: 500px) {
        .game-creation-popup {
            max-height: 90dvh;
            top: 5dvh;
            transform: translate(-50%, 0) scale(0.95);
        }
        
        .game-creation-popup.show {
            transform: translate(-50%, 0) scale(1);
        }
        
        .game-creation-popup .popup-body {
            max-height: 70dvh;
            padding: 12px 16px;
            gap: 8px;
        }
        
        .game-creation-popup .popup-header {
            padding: 8px 16px 6px 16px;
        }
        
        .game-creation-popup .popup-header h3 {
            font-size: 1rem;
        }
    }
    
    /* Keyboard-specific adjustments */
    @media (max-height: 400px) {
        .game-creation-popup {
            max-height: 95dvh;
            top: 2.5dvh;
            transform: translate(-50%, 0) scale(0.9);
        }
        
        .game-creation-popup.show {
            transform: translate(-50%, 0) scale(1);
        }
        
        .game-creation-popup .popup-body {
            max-height: 80dvh;
            padding: 8px 12px;
            gap: 6px;
        }
        
        .game-creation-popup .popup-header {
            padding: 6px 12px 4px 12px;
        }
        
        .game-creation-popup .popup-header h3 {
            font-size: 0.9rem;
        }
        
        .game-creation-popup .form-group label {
            font-size: 0.8rem;
            margin-bottom: 4px;
        }
        
        .game-creation-popup select,
        .game-creation-popup input {
            padding: 8px 10px;
            font-size: 0.8rem;
        }
    }
}

/* Additional fixes for very small screens */
@media (max-width: 480px) {
    .game-creation-popup {
        width: 98vw; /* Use almost full width on very small screens */
        max-height: 80vh; /* Further reduce height */
        border-radius: 8px;
    }
    
    .game-creation-popup .popup-header {
        padding: 12px 16px 8px 16px;
    }
    
    .game-creation-popup .popup-header h3 {
        font-size: 1.1rem;
    }
    
    .game-creation-popup .popup-body {
        padding: 12px 16px;
        gap: 10px;
    }
    
    .game-creation-popup .form-group label {
        font-size: 0.85rem;
    }
    
    .game-creation-popup select,
    .game-creation-popup input {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .dropdown-option {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .game-creation-popup .color-selection {
        gap: 6px;
    }
    
    .game-creation-popup .color-option {
        padding: 4px 8px;
        font-size: 0.85rem;
    }
    
    .game-creation-popup .btn-create {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}

/* Fix for landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .game-creation-popup {
        max-height: 75vh; /* Reduce height further in landscape */
    }
    
    .game-creation-popup .popup-body {
        max-height: 60vh; /* Limit body height in landscape */
    }
}

/* Add invitation system styles at the end of the file */

/* Search container styles */
.search-container {
    position: relative;
    width: 100%;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2c2c2e;
    border: 1px solid #d9cbbc;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.search-result-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(107, 70, 193, 0.1);
    transition: background-color 0.2s ease;
}

.search-result-item:hover,
.search-result-item.selected {
    background-color: rgba(107, 70, 193, 0.2);
}

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

.search-result-item .username {
    color: #ffffff;
    font-weight: 500;
}

.no-results,
.search-error {
    padding: 12px 16px;
    color: #888;
    text-align: center;
    font-style: italic;
}

/* Invitations section styles */
.invitations-section {
    margin-bottom: 20px;
}

.invitations-section h3 {
    color: #ffffff;
    margin-bottom: 15px;
    font-size: 1.1rem;
    font-weight: 600;
}

.invitations-container {
    max-height: 300px;
    overflow-y: auto;
}

.invitation-item {
    background: linear-gradient(135deg, rgba(42, 41, 43, 0.8), rgba(42, 41, 43, 0.6));
    border: 1px solid rgba(107, 70, 193, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.invitation-item:hover {
    border-color: rgba(107, 70, 193, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 70, 193, 0.1);
}

.invitation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.inviter-name {
    color: #ffd700;
    font-weight: 600;
    font-size: 1.1rem;
}

.invitation-time {
    background: rgba(107, 70, 193, 0.3);
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.invitation-details {
    margin-bottom: 12px;
    color: #cccccc;
    font-size: 0.95rem;
}

.invitation-text {
    color: #cccccc;
}

.invitation-color {
    color: #ffd700;
    font-weight: 500;
}

.invitation-actions {
    display: flex;
    gap: 8px;
}

.btn-accept,
.btn-decline {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

.btn-accept:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40);
    transform: translateY(-1px);
}

.btn-decline {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
}

.btn-decline:hover {
    background: linear-gradient(135deg, #d32f2f, #b71c1c);
    transform: translateY(-1px);
}

/* Divider styles */
.divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(107, 70, 193, 0.3);
}

.divider span {
    background: #1e1d1f;
    padding: 0 16px;
    color: #888;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Loading and error states */
.loading,
.no-invitations,
.error {
    text-align: center;
    padding: 20px;
    color: #888;
    font-style: italic;
}

.loading {
    color: #ffd700;
}

.error {
    color: #f44336;
}

/* Success popup styles */
.success-popup {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    z-index: 10000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    max-width: 300px;
}

.success-popup.show {
    transform: translateX(0);
}

.success-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.success-content i {
    font-size: 1.2rem;
    color: #ffffff;
}

.success-content p {
    margin: 0;
    flex: 1;
    font-weight: 500;
}

.success-content button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.2s ease;
}

.success-content button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Update error popup styles to match success popup */
.error-popup {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
    z-index: 10000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    max-width: 300px;
}

.error-popup.show {
    transform: translateX(0);
}

.error-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.error-content i {
    font-size: 1.2rem;
    color: #ffffff;
}

.error-content p {
    margin: 0;
    flex: 1;
    font-weight: 500;
}

.error-content button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background-color 0.2s ease;
}

.error-content button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .header .logo {
        font-family: 'NXBaskerville', serif !important;
        font-size: 2.2rem;
        font-weight: 400;
        letter-spacing: 0.02em;
        color: #fff !important;
        text-shadow: 0 1px 4px rgba(0,0,0,0.18);
    }
    
    .invitation-actions {
        flex-direction: column;
    }
    
    .success-popup,
    .error-popup {
        left: 20px;
        right: 20px;
        max-width: none;
        transform: translateY(-100px);
    }
    
    .success-popup.show,
    .error-popup.show {
        transform: translateY(0);
    }
}

/* Additional mobile-specific dropdown improvements */
@media (max-width: 768px) {
    /* Ensure dropdown trigger has proper touch target size */
    .dropdown-trigger {
        min-height: 44px; /* Minimum touch target size */
        padding: 12px 16px;
        font-size: 0.9rem;
    }
    
    /* Improve dropdown menu positioning and scrolling */
    .dropdown-menu {
        /* Ensure proper positioning relative to trigger */
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: 200px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        z-index: 10001;
        border-radius: 8px;
        margin-top: 4px;
        /* Add backdrop blur for better visibility */
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    
    /* Ensure dropdown options are properly sized for touch */
    .dropdown-option {
        min-height: 44px; /* Minimum touch target size */
        padding: 12px 16px;
        font-size: 0.9rem;
        display: flex;
        align-items: center;
    }
    
    /* Improve dropdown group labels */
    .dropdown-group-label {
        padding: 10px 16px 6px 16px;
        font-size: 0.85rem;
        font-weight: 600;
        color: #a3a3a3;
        background: rgba(42, 41, 43, 0.8);
        border-bottom: 1px solid rgba(107, 70, 193, 0.2);
    }
    
    /* Ensure dropdown groups are properly spaced */
    .dropdown-group {
        margin-bottom: 4px;
    }
    
    .dropdown-group:last-child {
        margin-bottom: 0;
    }
    
    /* Improve search results on mobile */
    .search-results {
        max-height: 150px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
        margin-top: 4px;
    }
    
    .search-result-item {
        min-height: 44px; /* Minimum touch target size */
        padding: 12px 16px;
        font-size: 0.9rem;
        display: flex;
        align-items: center;
    }
}

/* Additional fixes for very small screens */
@media (max-width: 480px) {
    .dropdown-trigger {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .dropdown-option {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .dropdown-group-label {
        padding: 8px 14px 4px 14px;
        font-size: 0.8rem;
    }
    
    .search-result-item {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
}

/* Ensure skgweb logo displays properly */
.skgweb-logo {
    width: auto !important;
    height: 60px !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: initial !important;
    display: block !important;
    margin-top: 20px !important;
    align-self: flex-start !important;
}

/* Mobile-specific spacing for skgweb logo */
@media (max-width: 768px) {
    .skgweb-logo {
        margin-bottom: 1.5rem !important; /* Add bottom margin for proper gap on mobile */
    }
}

@media (max-width: 600px) {
    .skgweb-logo {
        margin-bottom: 2rem !important; /* Increase bottom margin for very small screens */
    }
}

@media (max-width: 480px) {
    .skgweb-logo {
        margin-bottom: 2.5rem !important; /* Maximum bottom margin for extra small screens */
    }
}

.header .logo,
.header .menu-btn {
    font-family: 'NXBaskerville', serif !important;
    font-size: 2.2rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: #fff !important;
    text-shadow: 0 1px 4px rgba(0,0,0,0.18);
    transition: color 0.3s ease; /* Smooth transition for color changes */
}

/* Black header text when first section is not visible - Desktop and Light Mode only */
@media (min-width: 769px) {
    [data-theme="light"] .header.first-section-hidden .logo {
        color: #000 !important; /* Black text when first section is not visible in light mode */
        text-shadow: none; /* Remove text shadow for better black text visibility */
    }

    /* Black burger menu icon when first section is not visible - Desktop and Light Mode only */
    [data-theme="light"] .header.first-section-hidden .menu-btn {
        color: #000 !important; /* Black burger menu icon when first section is not visible in light mode */
    }
}

.close-btn {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    color: inherit !important;
    font-size: 2rem;      /* Adjust as needed for your design */
    font-weight: normal;  /* Or bold if you want a heavier X */
    padding: 0.2em 0.5em; /* Minimal padding for click area */
    margin: 0;
    border-radius: 0 !important;
    cursor: pointer;
    outline: none;
    transition: none;
    line-height: 1;
}

.close-btn:focus,
.close-btn:hover {
    background: none !important;
    color: inherit !important;
    box-shadow: none !important;
}
