nav{
  position:fixed;
  top:0;
  width:100%;
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:18px 6%;
  background:rgba(5,10,20,0.9);
  backdrop-filter:blur(10px);
  z-index:1000;
  border-bottom:1px solid rgba(255,255,255,0.08);
  gap:20px;
}

.logo{
  color:#facc15;
  font-size:1.3rem;
  font-weight:700;
  white-space:nowrap;
}

.nav-right{
  display:flex;
  align-items:center;
  gap:25px;
}

nav ul{
  display:flex;
  gap:24px;
  list-style:none;
}

nav a{
  color:white;
  text-decoration:none;
  transition:0.3s;
  font-weight:500;
}

nav a:hover{
  color:#facc15;
}

.nav-toggle {
    display: none;
}

/* ----- dropdown menus: "My chess" (members) and "Admin" ----- */
.nav-dd{ position:relative; }
.nav-dd-btn{
  display:inline-flex; align-items:center; gap:6px;
  background:none; border:1px solid rgba(255,255,255,0.14); border-radius:999px;
  color:white; font:inherit; font-weight:500; padding:7px 14px; cursor:pointer; white-space:nowrap;
  transition:border-color .2s, color .2s;
}
.nav-dd-btn:hover, .nav-dd.open .nav-dd-btn, .nav-dd.current .nav-dd-btn{ border-color:#facc15; color:#facc15; }
.nav-dd-caret{ font-size:.75em; transition:transform .2s; }
.nav-dd.open .nav-dd-caret{ transform:rotate(180deg); }
.nav-dd-menu{
  display:none; position:absolute; right:0; top:calc(100% + 10px); min-width:250px; padding:6px;
  background:#111827; border:1px solid rgba(255,255,255,0.12); border-radius:12px;
  box-shadow:0 12px 30px rgba(0,0,0,.45); z-index:1100;
}
.nav-dd-menu::before{ content:""; position:absolute; left:0; right:0; top:-12px; height:12px; }   /* hover bridge */
.nav-dd.open .nav-dd-menu{ display:block; }
@media (hover:hover) and (min-width:1025px){ .nav-dd:hover .nav-dd-menu{ display:block; } }
.nav-dd-menu a{ display:block; padding:9px 12px; border-radius:8px; white-space:nowrap; font-size:.95rem; }
.nav-dd-menu a:hover{ background:rgba(255,255,255,0.06); }
.nav-dd-menu a[hidden]{ display:none; }
.nav-dd-menu a.active{ color:#facc15; background:rgba(250,204,21,0.08); }
.nav-dd-sep{ height:1px; margin:6px 10px; background:rgba(255,255,255,0.12); }   /* divider between groups of menu items */

.language-switcher{
  display:flex;
  align-items:center;
  gap:10px;
}
/* A3Chess logo + tagline */
.logo-link{ display:flex; align-items:center; gap:11px; text-decoration:none; }
.logo-mark{ width:34px; height:34px; flex-shrink:0; }
.logo-text{ display:flex; flex-direction:column; line-height:1.15; }
.logo-link .logo{ color:#e8ecf3; letter-spacing:-.01em; }
.logo-link .logo b{ color:#facc15; font-weight:700; }
.logo-tag{ font-size:.72rem; font-weight:500; color:#94a3b8; letter-spacing:.02em; white-space:nowrap; }
.logo-link:hover .logo-tag{ color:#cbd5e1; }
/* main menus: plain text like links; only Admin keeps the pill */
.nav-dd.plain .nav-dd-btn{ border-color:transparent; padding:7px 4px; }
.nav-dd.plain .nav-dd-btn:hover, .nav-dd.plain.open .nav-dd-btn{ border-color:transparent; }
.auth-buttons{ display:flex; align-items:center; gap:12px; white-space:nowrap; }
.login-top{ display:none; }   /* phones/tablets only, see the media query below */
.user-dd:has(.user-greeting:empty){ display:none; }   /* logged out: no name, no menu */
@media (min-width:1025px) and (max-width:1200px){
  nav{ padding-left:3%; padding-right:3%; }
  .nav-right, nav ul{ gap:14px; }
}
/* ===== PHONES + TABLETS (up to 1024px): compact header, hamburger, slide-out menu (moved from mobile.css so that every page has it) ===== */
@media (max-width: 1024px) {

    /* ----- NAVIGATION ----- */
    nav {
        flex-direction: row !important;        /* Keep items in a row */
        padding: 8px 12px !important;          /* Compact header */
        min-height: 56px;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 9999;
        background: rgba(5, 10, 20, 0.95);
        backdrop-filter: blur(10px);
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
        transition: transform 0.3s ease;
    }

    /* Hide header on scroll down */
    #header.header-hidden {
        transform: translateY(-110%);
    }

    /* ----- LEFT SIDE (logo + hamburger) ----- */
    .nav-left {
        display: flex;
        align-items: center;
        gap: 10px;
        z-index: 10000;          /* Ensure it's above overlay */
        flex-shrink: 0;
    }

    .logo {
        display: block !important;    /* Always show logo */
        font-size: 1rem !important;
        white-space: nowrap;
        color: #e8ecf3;
        font-weight: 700;
    }
    .logo-mark { width: 28px; height: 28px; }
    .logo-link { gap: 9px; }

    /* ----- HAMBURGER BUTTON ----- */
    .nav-toggle {
        display: block !important;
        background: none;
        border: none;
        color: white;
        font-size: 28px;
        cursor: pointer;
        padding: 12px 14px;          /* Large tap target */
        min-width: 48px;
        min-height: 48px;
        touch-action: manipulation;
        z-index: 99999 !important;  /* Highest possible */
         position: relative;
        pointer-events: auto !important;
        -webkit-tap-highlight-color: transparent; /* Remove tap highlight */
        position: relative;
        margin: -8px 0;
        line-height: 1;
        pointer-events: auto !important;
        touch-action: manipulation;   /* prevents 300ms delay & double-tap zoom */

    }

    .nav-toggle:active {
        opacity: 0.6;
    }

    /* ----- LOGIN ICON in the top bar (logged out only; auth.js removes [hidden]) ----- */
    .login-top:not([hidden]) {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        margin-left: auto;
        border: 2px solid #facc15;
        border-radius: 50%;
        color: #facc15;
        background: rgba(250, 204, 21, 0.08);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    .login-top svg { width: 22px; height: 22px; }
    .login-top:hover, .login-top:active { color: #111827; background: #facc15; }
    /* logged in: filled circle with your initial */
    .user-top {
        font: 700 1.05rem 'Poppins', sans-serif;
        color: #111827;
        background: #facc15;
        cursor: pointer;
        padding: 0;
        box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.2);
    }
    .user-top:hover, .user-top:active { background: #fde047; }
    /* its small menu, just below the icon (nav is the containing block: it is fixed) */
    .user-top-menu:not([hidden]) {
        position: absolute;
        top: calc(100% + 6px);
        right: 12px;
        min-width: 210px;
        display: flex;
        flex-direction: column;
        padding: 6px;
        background: #111827;
        border: 1px solid rgba(250, 204, 21, 0.25);
        border-radius: 12px;
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
        z-index: 3000;
    }
    .user-top-menu a {
        padding: 12px 14px;
        border-radius: 8px;
        color: #e8ecf3;
        font-size: 0.95rem;
        white-space: nowrap;
    }
    .user-top-menu a:hover, .user-top-menu a:active { background: rgba(250, 204, 21, 0.1); color: #facc15; }

    /* ----- RIGHT SIDE (menu) ----- */
    .nav-right {
        position: fixed;
        top: 0;
        right: -300px;              /* Start off-screen to the right */
        width: 280px;
        height: 100vh;
        background: #111827;
        padding: 80px 24px 30px;
        transition: right 0.3s ease;
        z-index: 2000;
        display: flex;
        flex-direction: column;
        gap: 20px;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;  /* scrolling the menu never scrolls/pans the page behind it */
        touch-action: pan-y;           /* sideways swipes don't pan the page */
        -webkit-overflow-scrolling: touch;
        box-shadow: -4px 0 20px rgba(0,0,0,0.5);
        border-left: 1px solid rgba(255,255,255,0.08);
    }

    .nav-right.open {
        right: 0;
    }

    /* Menu links */
    .nav-right ul {
        display: flex !important;      /* Override display:none from earlier */
        flex-direction: column;
        gap: 16px;
        margin: 0;
        padding: 0;
        list-style: none;
        width: 100%;
    }

    .nav-right ul li {
        width: 100%;
        border-bottom: 1px solid rgba(255,255,255,0.06);
        padding-bottom: 6px;
    }

    .nav-right ul li a {
        color: white;
        font-size: 1.2rem;
        font-weight: 500;
        padding: 12px 0;
        display: block;
        text-decoration: none;
        touch-action: manipulation;
        transition: color 0.2s;
    }

    .nav-right ul li a:hover {
        color: #facc15;
    }

    /* Language switcher */
    .language-switcher {
        display: flex;
        gap: 12px;
        margin-top: 10px;
        justify-content: flex-start;
    }

    .lang-btn {
        background: rgba(255,255,255,0.08);
        border: 1px solid rgba(255,255,255,0.12);
        color: white;
        padding: 8px 16px;
        border-radius: 8px;
        font-size: 0.9rem;
        cursor: pointer;
        touch-action: manipulation;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .lang-btn:active {
        background: rgba(255,255,255,0.2);
    }

    /* Auth buttons */
    .auth-buttons {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 10px;
        width: 100%;
    }

    .auth-btn {
        width: 100%;
        text-align: center;
        padding: 12px 16px;
        font-size: 1rem;
        border-radius: 10px;
        touch-action: manipulation;
        box-sizing: border-box;
    }

    #dashboardBtn {
        width: 100%;
        text-align: center;
        padding: 12px 16px;
        font-size: 1rem;
        border-radius: 10px;
        touch-action: manipulation;
        box-sizing: border-box;
    }

    /* dropdown menus: shown open as groups in the slide-out menu */
    .nav-dd { width: 100%; }
    .nav-dd-btn { border: 0; padding: 0 0 4px; cursor: default; color: #9aa4b2 !important; font-size: .8rem;
        text-transform: uppercase; letter-spacing: .08em; }
    .nav-dd-caret { display: none; }
    .nav-dd-menu { display: block; position: static; min-width: 0; padding: 0; background: none; border: 0; box-shadow: none; }
    .nav-dd-menu a { font-size: 1.05rem; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.06); border-radius: 0; white-space: normal; }
    .nav-dd-sep { height: 2px; margin: 8px 0; background: rgba(250,204,21,0.3); }

    /* Hide desktop-only elements if any */
    .nav-right .desktop-only {
        display: none;
    }

    /* ----- OVERLAY ----- */
    #menuOverlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
        z-index: 1500;
        touch-action: manipulation;
    }

    #menuOverlay.show {
        opacity: 1;
        visibility: visible;
    }

}
