/* Gateway Styles - Cribbage Themed */

/* Color Palette */
:root {
    --primary-color: #2c5234;    /* Deep forest green */
    --secondary-color: #8B4513;  /* Saddle brown (wood) */
    --accent-color: #ffd700;     /* Gold */
    --text-color: #2c2c2c;      /* Dark gray */
    --light-text: #666;         /* Light gray */
    --background: #f8f9fa;      /* Light background */
    --white: #ffffff;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    
    /* Card colors */
    --club-spade: #2c2c2c;      /* Black suits */
    --heart-diamond: #dc3545;   /* Red suits */
    
    /* Board colors */
    --board-wood: #8B4513;
    --board-dark: #654321;
    --board-hole: #2c1810;
    
    /* Shadows and borders */
    --shadow-light: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 8px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 8px 16px rgba(0, 0, 0, 0.2);
    --border-radius: 8px;
    --border-radius-large: 12px;
}

/* Prevent horizontal overflow globally so fixed elements stay in viewport */
/* overflow-x only on body (not html) so position:sticky works on desktop */
html {
    max-width: 100%;
}
body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Desktop nav centering: keep menu centered whenever we're not in mobile mode */
html:not(.mobile-device) .nav-brand {
    display: none;
}

html:not(.mobile-device) .nav-container {
    justify-content: center;
    padding-top: 7px;
    padding-bottom: 7px;
}

html:not(.mobile-device) .nav-menu {
    flex: 1 1 auto;
}

html:not(.mobile-device) .nav-links {
    flex: 1 1 auto;
    justify-content: center;
}

@media (max-height: 820px) {
    .hero-section {
        padding: 50px 0;
    }

    .hero-title {
        font-size: 3rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
        margin-bottom: 20px;
    }

    .modal {
        align-items: flex-start;
        padding-top: 40px;
        padding-bottom: 40px;
    }

    .modal-content {
        max-height: calc(100vh - 80px);
    }

    .modal-header {
        padding: 16px 24px 16px;
    }

    .auth-form {
        padding: 24px;
    }
}

@media (max-height: 700px) {
    .hero-section {
        padding: 32px 0;
    }

    .hero-title {
        font-size: 2.4rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .hero-buttons {
        gap: 12px;
    }
}

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

html,
body {
    -webkit-text-size-adjust: 100%;
}

/* Prevent iOS auto-zoom on input focus - minimum 16px font-size required */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background);
}

/* Orientation lock overlay for mobile devices (applies to gateway only) */
.orientation-lock-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background: #000000;
    color: #ffffff;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.orientation-lock-overlay.visible {
    display: flex;
}

.orientation-lock-overlay-content {
    max-width: 420px;
    margin: 0 auto;
}

.orientation-lock-title {
    font-size: 1.6rem;
    margin-bottom: 12px;
}

.orientation-lock-message {
    font-size: 1rem;
    opacity: 0.9;
}

.orientation-lock-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

/* PWA Standalone Mode - Black Safe Areas */
@media (display-mode: standalone) {
    /* iOS keyboard handling for PWA mode */
    html {
        position: fixed;
        width: 100%;
        height: 100%;
        overflow: hidden;
        background-color: #000000;
    }

    body {
        position: relative;
        width: 100%;
        height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        /* No background on body - let html background show through */
        background-color: transparent;
        padding-top: env(safe-area-inset-top);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
    }

    /* Fixed black bar for top safe area */
    body::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: env(safe-area-inset-top);
        background-color: #000000;
        z-index: 10000;
        pointer-events: none;
    }

    /* Add white background to content wrapper instead of body */
    .hero-section,
    .main-nav,
    .main-content,
    .main-footer {
        background-color: var(--white);
    }

    /* Override hero gradient */
    .hero-section {
        background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    }

    /* Override footer */
    .main-footer {
        background-color: var(--primary-color);
    }

    /* Reset the hero section padding since body now handles it */
    .hero-section {
        padding-top: 55px;
    }

    /* Remove duplicate nav styling - handled below */

    /* Ensure modals account for safe area */
    .modal {
        padding-top: calc(20px + env(safe-area-inset-top));
    }
}

/* iPad landscape: no bottom safe-area padding (no home indicator in landscape) */
@media (display-mode: standalone) and (orientation: landscape) {
    html.ipad-device body {
        padding-bottom: 0;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

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

/* Button Styles */
.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    min-width: 120px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
    border: 1px solid #000000;
}

.btn-primary:hover:not(:disabled) {
    background-color: #1a3d20;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--white);
    border: 1px solid #000000;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #5d2e09;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: var(--white);
}

.btn-admin {
    background-color: #6f42c1;
    color: var(--white);
    border: 2px solid #5a2d91;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-admin:hover:not(:disabled) {
    background-color: #5a2d91;
    border-color: #4c1f7a;
    color: var(--white);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn-admin:active {
    background-color: #4c1f7a;
    transform: translateY(1px);
    box-shadow: var(--shadow-light);
}

.btn-full {
    width: 100%;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--white);
    padding: 55px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="%23ffffff" fill-opacity="0.05"><path d="M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z"/></g></g></svg>') repeat;
    opacity: 0.1;
}

.hero-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Hide the now-empty hero image container so text block centers correctly */
.hero-image {
    display: none;
}

.hero-image .cribbage-logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
}

.hero-title-line {
    display: inline-block;
    white-space: nowrap;
    max-width: 100%;
}

.hero-subtitle {
    font-size: 1.3rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

.hero-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.hero-desktop-game-btn {
    min-width: 140px;
}


html.mobile-device .hero-desktop-game-btn {
    display: none;
}

/* Mobile-only hero buttons - hidden by default */
.hero-buttons-mobile {
    display: none;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 0;
}

/* Pure-CSS small-screen hero scaling (no mobile-device class required) */
@media (max-width: 600px) {
    .hero-title {
        font-size: 2.2rem;
    }
    .hero-subtitle {
        font-size: 1rem;
    }
    .hero-content {
        flex-direction: column;
        padding: 0 16px;
        text-align: center;
    }
    .hero-section {
        padding: 40px 0;
    }
    .hero-text {
        min-width: 0;
        width: 100%;
    }
    .hero-buttons {
        flex-wrap: wrap;
        gap: 10px;
    }
}

/* Navigation */
.main-nav {
    background-color: var(--white);
    box-shadow: var(--shadow-light);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Override for standalone mode - ensure nav sticks right below safe area */
@media (display-mode: standalone) {
    .main-nav {
        position: sticky;
        top: 0 !important;
        z-index: 100;
    }
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 30px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 101;
}

.nav-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Mobile menu toggle */
.nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 5px;
    z-index: 101;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background-color: var(--primary-color);
    margin: 3px 0;
    transition: 0.3s;
    border-radius: 2px;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

.nav-links {
    display: flex;
    gap: 30px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
    background-color: var(--primary-color);
    color: var(--white);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-welcome {
    white-space: nowrap;
    color: var(--primary-color);
    font-weight: 500;
}

/* Responsive Navigation */
@media (max-width: 1024px) {
    .nav-links {
        gap: 20px;
    }
    
    .nav-user {
        gap: 10px;
    }
    
    .nav-user .btn {
        padding: 8px 12px;
        font-size: 14px;
        min-width: 80px;
    }
}

@media (max-width: 768px),
       (orientation: landscape) and (max-height: 500px) {
    html.mobile-device .nav-toggle {
        display: flex;
    }
    
    html.mobile-device .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--white);
        box-shadow: var(--shadow-medium);
        flex-direction: column;
        padding: 20px;
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        gap: 0;
    }
    
    html.mobile-device .nav-menu.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    html.mobile-device .nav-user {
        order: 1;
        gap: 10px;
        padding-top: 0;
        padding-bottom: 10px; /* reduced: less space above separator line */
        flex-direction: column;
        border-bottom: 1px solid #e9ecef;
        margin-bottom: 0;
    }

    html.mobile-device .nav-links {
        order: 2;
        gap: 10px;
        flex-direction: column;
        margin-top: 15px; /* restore original space below separator */
    }
    
    html.mobile-device .nav-link {
        padding: 12px 16px;
        text-align: center;
        border: 1px solid #e9ecef;
        margin-bottom: 5px;
    }
    
    html.mobile-device .nav-user .btn {
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
    }
    
    html.mobile-device .user-welcome {
        text-align: center;
        padding: 10px;
        background-color: var(--background);
        border-radius: var(--border-radius);
        margin-bottom: 15px;
    }
}

@media (max-width: 480px) {
    html.mobile-device .nav-container {
        padding: 8px 15px;
    }
    
    html.mobile-device .nav-title {
        font-size: 1.3rem;
    }
}

/* Main Content */
.main-content {
    padding: 0px 0;
}

.section-title {
    font-size: 2.5rem;
    text-align: center;
    margin-top: 50px;
    margin-bottom: 20px;
    color: var(--primary-color);
    font-weight: 700;
}

/* Play Section */
.play-section {
    background-color: var(--white);
    margin-bottom: 20px;
    padding: 1px 0;
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-light);
    scroll-margin-top: 60px;
}

.play-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 40px;
    max-width: 800px;
    margin: 0 auto;
}

.play-card {
    background-color: var(--background);
    padding: 40px;
    border-radius: var(--border-radius-large);
    text-align: center;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.play-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-medium);
    border-color: var(--primary-color);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.play-card h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.play-card p {
    color: var(--light-text);
    margin-bottom: 25px;
}

.join-input-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.join-input-group input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 16px;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 2px;
}

.join-input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Guide Section */
.guide-section {
    background-color: var(--background);
    padding: 0px 0;
    margin-bottom: 20px;
    scroll-margin-top: 60px;
}

.guide-content {
    max-width: 1000px;
    margin: 0 auto;
}

.guide-overview {
    text-align: center;
    margin-bottom: 20px;
    padding: 30px;
    background-color: var(--white);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-light);
}

.guide-overview h3 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.guide-overview p {
    font-size: 1.1rem;
    color: var(--light-text);
    line-height: 1.8;
}

.guide-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px;
    margin-bottom: 20px;
}

.guide-card {
    background-color: var(--white);
    border-radius: var(--border-radius-large);
    padding: 30px;
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
}

.guide-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
}

.guide-card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.guide-icon {
    font-size: 2rem;
    background-color: var(--primary-color);
    color: var(--white);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guide-card h4 {
    color: var(--primary-color);
    font-size: 1.3rem;
}

.guide-card ul {
    list-style: none;
    padding: 0;
}

.guide-card li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    color: var(--text-color);
}

.guide-card li:last-child {
    border-bottom: none;
}

.guide-card strong {
    color: var(--primary-color);
}

/* Cribbage Board Info */
.cribbage-board-info {
    /* background-color: var(--white); */ /* Removed to allow PNG transparency to show through */
    border-radius: var(--border-radius-large);
    padding: 20px;
    box-shadow: var(--shadow-light);
}

.cribbage-board-info h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 1.8rem;
}

.board-description {
    display: flex;
    align-items: center;
    gap: 30px;
    flex-wrap: wrap;
}

.board-image {
    flex: 0 0 auto;
    background: transparent;
    /* Ensure no background bleeding through */
}

.board-image img {
    background-color: transparent !important;
    background: none !important;
    /* Ensure proper PNG transparency rendering */
    image-rendering: auto;
    /* Remove any potential border or outline */
    border: none;
    outline: none;
}

.mini-board {
    width: 300px;
    height: 100px;
    background: transparent !important;
    /* Removed border-radius and box-shadow to preserve PNG transparency */
    /* Additional transparency properties */
    image-rendering: auto;
    object-fit: contain;
    /* Ensure no borders or outlines */
    border: none !important;
    outline: none !important;
    /* Remove any potential margin/padding that could show white */
    margin: 0;
    padding: 0;
    /* Try to remove white background if it exists in the PNG */
    mix-blend-mode: multiply;
    filter: contrast(1.1) brightness(1.05);
}

.board-description p {
    flex: 1;
    font-size: 1.1rem;
    color: var(--light-text);
    line-height: 1.8;
    min-width: 220px;
}

/* Stats Section */
.stats-section {
    background-color: var(--background);
    padding: 20px 0 40px;
    margin-bottom: 20px;
    border-radius: var(--border-radius-large);
    scroll-margin-top: 60px;
}

/* Stats Dashboard Container */
.stats-dashboard {
    max-width: 900px;
    margin: 0 auto 40px;
}

/* Player Profile Card */
.player-profile-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a3d20 100%);
    border-radius: var(--border-radius-large);
    padding: 30px;
    color: var(--white);
    margin-bottom: 30px;
    box-shadow: var(--shadow-heavy);
    position: relative;
    overflow: hidden;
}

.player-profile-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.player-profile-card::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 50%;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    position: relative;
    z-index: 1;
}

.profile-avatar {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    color: var(--white);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    font-family: inherit;
}

button.profile-avatar:hover,
button.profile-avatar:focus-visible {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    outline: none;
}

.profile-avatar-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
}

.profile-avatar .avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-avatar .avatar-emoji {
    font-size: 2.4rem;
    line-height: 1;
}

.profile-avatar .avatar-monogram {
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--white);
}

.avatar-icon {
    font-size: 2rem;
    color: var(--white);
}

/* Smaller avatar variant used in the top-right nav */
.profile-avatar--nav {
    width: 38px;
    height: 38px;
    border-width: 2px;
    background: var(--primary-color, #1976d2);
    flex-shrink: 0;
}

.profile-avatar--nav .avatar-emoji {
    font-size: 1.2rem;
}

.profile-avatar--nav .avatar-monogram {
    font-size: 1rem;
}

.profile-avatar--nav .avatar-icon {
    font-size: 1rem;
}

/* Mobile nav avatar — fixed size in both portrait and landscape */
html.mobile-device .profile-avatar--nav {
    width: 46px;
    height: 46px;
}

html.mobile-device .profile-avatar--nav .avatar-emoji {
    font-size: 1.4rem;
}

html.mobile-device .profile-avatar--nav .avatar-monogram {
    font-size: 1.1rem;
}

html.mobile-device .profile-avatar--nav .avatar-icon {
    font-size: 1.1rem;
}


/* Dim and disable the avatar button while a profile/avatar modal is open */
.nav-avatar-wrapper.modal-active {
    pointer-events: none;
    opacity: 0.3;
    filter: blur(2px);
    transition: opacity 0.2s ease, filter 0.2s ease;
}

/* Avatar dropdown menu — fixed to top-right of viewport */
.nav-avatar-wrapper {
    position: fixed;
    top: calc(14px + env(safe-area-inset-top));
    right: calc(16px + env(safe-area-inset-right));
    z-index: 3000;
}

html:not(.mobile-device) .nav-avatar-wrapper {
    top: 9px;
}

html.mobile-device .nav-avatar-wrapper {
    top: calc(4px + env(safe-area-inset-top));
}

.nav-avatar-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--white, #fff);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    z-index: 2000;
    overflow: hidden;
    padding: 4px 0;
}

.nav-avatar-menu-item {
    display: block;
    width: 100%;
    padding: 11px 18px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    color: #333;
    text-decoration: none;
    transition: background 0.12s ease;
    box-sizing: border-box;
}

.nav-avatar-menu-item:hover,
.nav-avatar-menu-item:focus-visible {
    background: #f4f6f9;
    outline: none;
}

.nav-avatar-menu-item--danger {
    color: #e53935;
}

#nav-admin-link {
    background-color: #7c3aed;
    color: #ffffff;
}

#nav-admin-link:hover,
#nav-admin-link:focus-visible {
    background-color: #6d28d9;
}


/* Profile modal avatar editor */
.profile-avatar-editor {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.profile-avatar-ring {
    display: inline-flex;
    border-radius: 50%;
    padding: 3px;
    background: #000;
    flex-shrink: 0;
}

.profile-avatar-preview {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: none;
    color: #333;
}

.profile-avatar-preview .avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-avatar-preview .avatar-emoji {
    font-size: 3rem;
    line-height: 1;
}

.profile-avatar-preview .avatar-monogram {
    font-size: 2.6rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
}

.profile-avatar-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    flex: 1;
}

.profile-avatar-hint {
    font-size: 0.75rem;
    color: #777;
    margin: 0;
}

.profile-avatar-section-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #777;
    margin: 16px 0 6px;
    font-weight: 600;
}

.profile-avatar-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.preset-avatar {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid transparent;
    background: rgba(0, 0, 0, 0.05);
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease;
    padding: 0;
}

.preset-avatar:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.05);
}

.preset-avatar.selected {
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.18);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.profile-info {
    flex: 1;
}

.profile-username {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 8px 0;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.profile-rank {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rank-badge {
    background: var(--accent-color);
    color: var(--text-color);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
}

.rank-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.profile-stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    position: relative;
    z-index: 1;
}

.summary-stat {
    text-align: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    backdrop-filter: blur(10px);
}

.summary-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.summary-label {
    font-size: 0.85rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stats Detail Grid */
.stats-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}

.stats-detail-card {
    background: var(--white);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-light);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
}

.stats-detail-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-heavy);
}

.detail-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
}

.multiplayer-card .detail-card-header {
    background: linear-gradient(90deg, rgba(44, 82, 52, 0.08) 0%, transparent 100%);
}

.computer-card .detail-card-header {
    background: linear-gradient(90deg, rgba(23, 162, 184, 0.08) 0%, transparent 100%);
}

.detail-icon {
    font-size: 1.8rem;
}

.detail-card-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-color);
    font-weight: 600;
}

.detail-card-body {
    padding: 20px;
}

.detail-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.detail-stat {
    text-align: center;
    padding: 15px;
    background: var(--background);
    border-radius: var(--border-radius);
}

.detail-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.multiplayer-card .detail-value {
    color: var(--primary-color);
}

.computer-card .detail-value {
    color: var(--info);
}

.detail-label {
    font-size: 0.85rem;
    color: var(--light-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.win-rate-display {
    background: var(--background);
    border-radius: var(--border-radius);
    padding: 15px;
}

.win-rate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.win-rate-header span:first-child {
    color: var(--light-text);
    font-weight: 500;
}

.win-rate-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.multiplayer-card .win-rate-value {
    color: var(--primary-color);
}

.computer-card .win-rate-value {
    color: var(--info);
}

.progress-bar-container {
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease-out;
}

.multiplayer-progress {
    background: linear-gradient(90deg, var(--primary-color) 0%, #4a7c59 100%);
}

.computer-progress {
    background: linear-gradient(90deg, var(--info) 0%, #5bc0de 100%);
}

.detail-card-footer {
    padding: 12px 20px;
    background: var(--background);
    border-top: 1px solid #e9ecef;
}

.footer-note {
    font-size: 0.8rem;
    color: var(--light-text);
    font-style: italic;
}

/* Leaderboard Styles - Redesigned */
.leaderboard-section {
    max-width: 650px;
    margin: 0 auto;
    padding: 0 20px;
}

.leaderboard-header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.leaderboard-trophy {
    font-size: 2.2rem;
}

.leaderboard-title {
    color: var(--primary-color);
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
}

.leaderboard-subtitle {
    text-align: center;
    color: var(--light-text);
    font-size: 0.95rem;
    margin: 0 0 25px;
}

.leaderboard-container {
    background-color: var(--white);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-medium);
    overflow: hidden;
    border: none;
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 70px 1fr 80px 90px;
    gap: 15px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a3d20 100%);
    color: var(--white);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.leaderboard-list {
    min-height: auto;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 70px 1fr 80px 90px;
    gap: 15px;
    padding: 14px 20px;
    border-bottom: 1px solid #f0f0f0;
    transition: all 0.2s ease;
    align-items: center;
}

.leaderboard-item:hover {
    background-color: #f8f9fa;
}

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

.leaderboard-item.current-user {
    background: linear-gradient(90deg, rgba(44, 82, 52, 0.1) 0%, rgba(44, 82, 52, 0.05) 100%);
    border-left: 4px solid var(--primary-color);
}

.leaderboard-item.current-user:hover {
    background: linear-gradient(90deg, rgba(44, 82, 52, 0.15) 0%, rgba(44, 82, 52, 0.08) 100%);
}

.leaderboard-rank {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: var(--light-text);
}

.leaderboard-rank.rank-1 {
    color: #FFD700;
    font-size: 1.5rem;
}

.leaderboard-rank.rank-2 {
    color: #C0C0C0;
    font-size: 1.4rem;
}

.leaderboard-rank.rank-3 {
    color: #CD7F32;
    font-size: 1.3rem;
}

.rank-medal {
    font-size: 1.5rem;
}

.leaderboard-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.leaderboard-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--white);
    background-color: #ccc;
    border: 2px solid var(--primary-color);
}

.leaderboard-avatar .avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.leaderboard-avatar .avatar-emoji {
    font-size: 1rem;
    line-height: 1;
}

.leaderboard-avatar .avatar-monogram {
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

.leaderboard-avatar .avatar-icon {
    font-size: 0.75rem;
    line-height: 1;
}

.leaderboard-name.placeholder {
    color: #ccc;
    font-style: italic;
    font-weight: 400;
}

.leaderboard-wins {
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    font-size: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.rank-header {
    text-align: center;
}

.name-header {
    padding-left: 36px;
}

.wins-header,
.rate-header {
    text-align: center;
}

.leaderboard-rate {
    font-weight: 600;
    color: var(--light-text);
    text-align: center;
    font-size: 0.95rem;
}

/* Responsive for Stats Dashboard */
@media (max-width: 768px) {
    .profile-stats-summary {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .summary-stat {
        padding: 12px 8px;
    }
    
    .summary-value {
        font-size: 1.5rem;
    }
    
    .summary-label {
        font-size: 0.75rem;
    }
    
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-rank {
        justify-content: center;
    }
    
    .stats-detail-grid {
        grid-template-columns: 1fr;
    }
    
    .leaderboard-header,
    .leaderboard-item {
        grid-template-columns: 50px 1fr 60px 70px;
        gap: 10px;
        padding: 12px 15px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .player-profile-card {
        padding: 20px;
    }
    
    .profile-avatar {
        width: 55px;
        height: 55px;
    }
    
    .avatar-icon {
        font-size: 1.5rem;
    }
    
    .profile-username {
        font-size: 1.3rem;
    }
    
    .detail-stats-row {
        gap: 10px;
    }
    
    .detail-value {
        font-size: 1.6rem;
    }
    
    .leaderboard-header,
    .leaderboard-item {
        grid-template-columns: 40px 1fr 50px 60px;
        gap: 8px;
        padding: 10px 12px;
    }
    
    .rank-medal {
        font-size: 1.2rem;
    }
    
    .leaderboard-name {
        font-size: 0.9rem;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--white);
    border-radius: var(--border-radius-large);
    box-shadow: var(--shadow-heavy);
    width: 100%;
    max-width: 500px;
    position: relative;
    z-index: 1001;
    animation: modalSlideIn 0.3s ease;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

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

.modal-header {
    padding: 20px 30px 20px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--white);
}

#auth-modal .modal-header {
    position: sticky;
    top: 0;
    z-index: 5;
}

.modal-header h3 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--light-text);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background-color: var(--background);
    color: var(--text-color);
}

/* Admin Panel Modal */
#admin-panel-modal .modal-content {
    max-width: 1300px;
    width: 92%;
    height: 88vh;
    max-height: 88vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
}

#admin-panel-modal .modal-header {
    background: linear-gradient(135deg, #4c1d95 0%, #5b21b6 100%);
    border-bottom: none;
    padding: 12px 20px;
    flex-shrink: 0;
    position: relative;
}

#admin-panel-modal .modal-header h3 {
    color: #ffffff;
    font-size: 1.1rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

#admin-panel-modal .modal-close {
    color: rgba(255, 255, 255, 0.9);
}

#admin-panel-modal .modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.admin-panel-iframe {
    display: block;
    width: 100%;
    flex: 1;
    border: none;
    min-height: 0;
}

/* Form Styles */
.auth-form {
    padding: 30px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(44, 82, 52, 0.1);
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Google Auth Styles */
.auth-divider {
    text-align: center;
    position: relative;
    margin: 30px 0;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: #e9ecef;
}

.auth-divider span {
    background-color: var(--white);
    padding: 0 15px;
    color: var(--light-text);
    font-size: 14px;
    font-weight: 500;
}

.google-auth-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 20px;
}

.google-signin-button {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

/* Override Google button styles to match our theme */
.google-signin-button iframe {
    border-radius: var(--border-radius) !important;
}

/* Footer */
.main-footer {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 20px 0 30px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-section h4 {
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.footer-section p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 10px;
}

.footer-section a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: var(--white);
}

.footer-bottom {
    text-align: center;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.6);
}

/* Responsive Design */
@media (max-width: 768px) {
    html.mobile-device .hero-content {
        flex-direction: column;
        text-align: center;
        gap: 30px;
    }
    
    html.mobile-device .hero-title {
        font-size: 2.5rem;
    }
    
    html.mobile-device .hero-text {
        display: flex;
        flex-direction: column;
    }
    
    html.mobile-device .hero-buttons {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        order: 2;
    }
    
    html.mobile-device .hero-buttons .btn {
        padding: 10px 20px;
        font-size: 14px;
        min-width: auto;
    }
    
    /* Make Learn to Play a text link style on mobile when other buttons visible */
    html.mobile-device .hero-buttons .btn-secondary {
        background: transparent;
        border: none;
        text-decoration: underline;
        padding: 8px 12px;
        font-size: 13px;
        opacity: 0.9;
    }
    
    html.mobile-device .hero-text {
        display: flex;
        flex-direction: column;
    }
    
    html.mobile-device .hero-buttons-mobile {
        display: flex;
        order: 1;
        margin-bottom: 12px;
    }
    
    html.mobile-device .hero-buttons-mobile .btn {
        padding: 12px 24px;
        font-size: 15px;
    }
    
    html.mobile-device .hero-learn-link {
        order: 3;
        margin-top: 8px;
        align-self: center;
    }
    
    html.mobile-device .nav-container {
        flex-direction: column;
        gap: 0;
    }

    html.mobile-device .nav-links {
        gap: 15px;
        flex-wrap: wrap;
        justify-content: center;
    }

    html.mobile-device .board-description {
        flex-direction: column;
        text-align: center;
    }
    
    html.mobile-device .join-input-group {
        flex-direction: column;
    }
    
    html.mobile-device .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    html.mobile-device .guide-sections {
        grid-template-columns: 1fr;
    }
}

/* Mobile landscape mode - mirror portrait hero layout */
@media (orientation: landscape) and (max-height: 500px) {
    html.mobile-device .hero-content {
        flex-direction: column;
        text-align: center;
        gap: 30px;
        align-items: center;
        justify-content: center;
    }

    html.mobile-device .hero-title {
        font-size: 2.5rem;
    }

    html.mobile-device .hero-text {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    html.mobile-device .nav-container {
        padding: 8px 15px;
        justify-content: center;
    }

    html.mobile-device .hero-buttons {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 12px;
        order: 2;
    }

    html.mobile-device .hero-buttons .btn {
        padding: 10px 20px;
        font-size: 14px;
        min-width: auto;
    }
    
    html.mobile-device .hero-buttons-mobile {
        display: flex;
        order: 1;
        margin-bottom: 12px;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    html.mobile-device .hero-buttons-mobile .btn {
        padding: 12px 24px;
        font-size: 15px;
    }

    html.mobile-device #admin-panel-modal {
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
        align-items: flex-start;
    }

    html.mobile-device #admin-panel-modal .modal-content {
        width: 100%;
        margin: 0;
        max-width: none;
        height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        max-height: none;
        border-radius: 0;
    }

}

@media (max-width: 480px) {
    html.mobile-device .hero-title {
        font-size: 2rem;
    }
    
    html.mobile-device .section-title {
        font-size: 2rem;
    }
    
    html.mobile-device .play-options {
        grid-template-columns: 1fr;
    }
    
    html.mobile-device .stats-grid {
        grid-template-columns: 1fr;
    }
    
    html.mobile-device .modal-content {
        margin: 10px;
    }
    
    html.mobile-device .modal-header,
    html.mobile-device .auth-form {
        padding: 20px;
    }

    html.mobile-device #admin-panel-modal {
        padding: max(env(safe-area-inset-top), 10px) 8px max(env(safe-area-inset-bottom), 8px);
        align-items: flex-start;
    }

    html.mobile-device #admin-panel-modal .modal-content {
        width: 100%;
        margin: 0;
        max-width: none;
        height: calc(100vh - max(env(safe-area-inset-top), 10px) - max(env(safe-area-inset-bottom), 8px));
        max-height: none;
    }

    html.mobile-device .leaderboard-title {
        font-size: 1.5rem;
    }
    
    html.mobile-device .leaderboard-section {
        padding: 0 5px;
    }

    html.mobile-device .leaderboard-header,
    html.mobile-device .leaderboard-item {
        grid-template-columns: 44px 1fr 70px 70px;
        gap: 8px;
        padding: 12px 12px;
        font-size: 0.9rem;
    }
    
    .leaderboard-rank {
        font-size: 1rem;
    }
    
    html.mobile-device .leaderboard-name {
        font-size: 1rem;
    }
    
    html.mobile-device .profile-modal {
        width: 95%;
        max-width: none;
    }
    
    html.mobile-device .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    html.mobile-device .form-actions .btn {
        width: 100%;
        min-width: auto;
    }
}

/* Game List Modal Styles */
.game-list-modal {
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.game-list-modal .modal-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

#game-list-modal .modal-body {
    padding: 0 20px 20px;
    overflow-y: auto;
    flex: 1;
}

.game-code-section {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.game-code-section h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.1em;
}

.game-code-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.game-code-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px; /* Minimum 16px prevents iOS auto-zoom on focus */
    text-transform: uppercase;
}

.game-code-form button {
    padding: 8px 16px;
    font-size: 14px;
    white-space: nowrap;
}

.game-list-section {
    margin-top: 20px;
}

.game-list-section h4 {
    margin: 0 0 15px 20px; /* Add left margin to align with .game-code-section h4 */
    color: #333;
    font-size: 1.1em;
}

.game-list {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: visible;
    position: relative;
}

.game-list-header {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr;
    padding: 12px;
    background-color: #f8f9fa;
    font-weight: bold;
    border-bottom: 1px solid #eee;
    gap: 10px;
}

.game-list-item {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr 1fr;
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s ease;
}

.game-list-item:hover {
    background-color: #f9f9f9;
}

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

.game-code {
    font-weight: bold;
    color: #333;
}

.game-players {
    position: relative;
    font-size: 0.9em;
    color: #444;
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-player-preview {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-list-extra {
    margin-left: 4px;
    color: #888;
    font-size: 0.85em;
}

.player-list-info-button {
    border: none;
    background: transparent;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    transition: transform 0.15s ease, color 0.2s ease, background 0.2s ease;
}

.player-list-info-button:hover,
.player-list-info-button:focus-visible {
    color: #145c3d;
    background: rgba(44, 82, 52, 0.08);
    outline: none;
    transform: translateY(-1px);
}

.player-list-popover {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(0, -50%);
    z-index: 2000;
    min-width: 240px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.08);
    animation: popover-fade 180ms ease forwards;
}

.player-list-popover::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -7px;
    transform: translateY(-50%) rotate(45deg);
    width: 14px;
    height: 14px;
    background: #fff;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.player-list-popover-header {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.player-list-popover-header button {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    color: #999;
    padding: 0 4px;
}

.player-list-popover-header button:hover {
    color: #555;
}

.player-list-popover-body {
    list-style: none;
    margin: 0;
    padding: 10px 14px;
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.9em;
}

.player-list-popover-body li {
    display: flex;
    gap: 6px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.player-list-popover-body li:last-child {
    border-bottom: none;
}

.player-index {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 18px;
}

.player-name-entry {
    flex: 1;
    color: #333;
}

.player-list-popover-footer {
    padding: 10px 14px;
    font-size: 0.85em;
    color: #666;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

@keyframes popover-fade {
    from {
        opacity: 0;
        transform: translate(-6px, -50%);
    }
    to {
        opacity: 1;
        transform: translate(0, -50%);
    }
}

.game-count {
    color: #666;
}

.game-join-btn {
    padding: 6px 12px;
    font-size: 0.85em;
    border-radius: 4px;
    border: 1px solid #000000;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.game-join-btn:not(.disabled) {
    background-color: #28a745;
    color: white;
}

.game-join-btn:not(.disabled):hover {
    background-color: #218838;
}

.game-join-btn.disabled {
    background-color: #6c757d;
    color: white;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Re-join button styles */
.game-join-btn.rejoin-btn {
    position: relative;
    background-color: #ff8c00;
    color: white;
    font-weight: bold;
    cursor: pointer;
    opacity: 1;
    animation: pulse-rejoin 2s infinite;
}

.game-join-btn.rejoin-btn:hover {
    background-color: #e67e00;
    transform: scale(1.05);
}

@keyframes pulse-rejoin {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 140, 0, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(255, 140, 0, 0);
    }
}

/* Timer overlay on the rejoin button */
.rejoin-timer-overlay {
    display: block;
    font-size: 0.7em;
    font-family: 'Courier New', monospace;
    opacity: 0.9;
    line-height: 1;
    margin-top: 1px;
}

/* Game list item highlight for rejoin */
.game-list-item.can-rejoin {
    background-color: rgba(255, 140, 0, 0.1);
    border-left: 3px solid #ff8c00;
}

.game-list-item.can-rejoin:hover {
    background-color: rgba(255, 140, 0, 0.15);
}

.no-games-message {
    text-align: center;
    color: #666;
    padding: 30px 20px;
    font-style: italic;
}

.loading-message {
    text-align: center;
    color: #666;
    padding: 30px 20px;
    font-size: 1.1em;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(44, 82, 52, 0.5);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}
.loading-overlay.hidden {
    display: none;
}
.loading-spinner {
    border: 6px solid #f3f3f3;
    border-top: 6px solid var(--primary-color);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
    margin-bottom: 24px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
#loading-message.loading-message {
    color: #fff;
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Mobile responsive adjustments for game list modal */
@media (max-width: 768px) {
    .game-list-modal {
        width: 95%;
        max-height: 85vh;
    }
    
    .game-code-form {
        flex-direction: column;
        gap: 8px;
    }
    
    .game-code-form input,
    .game-code-form button {
        width: 100%;
    }
    
    .game-list-header,
    .game-list-item {
        grid-template-columns: 1fr 1.5fr 0.8fr 0.8fr;
        gap: 8px;
        padding: 10px;
    }
    
    .game-players {
        font-size: 0.8em;
    }
    
    .game-join-btn {
        padding: 5px 8px;
        font-size: 0.8em;
    }
}

/* Profile Modal Styles */
.profile-modal {
    max-width: 500px;
    width: 90%;
}

#profile-modal .modal-body,
#avatar-modal .modal-body {
    padding: 0 20px 20px;
}

.form-note {
    margin-top: 8px;
    padding: 10px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    color: var(--light-text);
    line-height: 1.4;
}

.form-note strong {
    color: var(--text-color);
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.form-actions .btn {
    min-width: 120px;
}

/* Create Game Modal Styles */
#create-game-modal .modal-body {
    padding: 0 40px 20px;
}

.game-type-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 20px;
    align-items: stretch; /* Make cards equal height */
}

.game-type-card {
    background: var(--white);
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius-large);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Push button to bottom */
    outline: none;
}

@media (hover: hover) and (pointer: fine) {
    .game-type-card:hover {
        border-color: var(--primary-color);
        box-shadow: var(--shadow-medium);
        transform: translateY(-2px);
    }
}

.game-type-card:focus-visible {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-medium);
}

.game-type-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
}

.game-type-card h4 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 1.3rem;
}

.game-type-card p {
    color: var(--light-text);
    margin-bottom: 0;
    line-height: 1.5;
    flex-grow: 1; /* Allow text to take available space */
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-type-card .btn {
    pointer-events: none; /* Prevent double-click issues */
    margin-top: 20px; /* Add space above button */
}

.local-game-options {
    text-align: center;
    padding: 20px 0;
}

.local-game-options h4 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.computer-player-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.computer-count-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.computer-count-btn:hover {
    background-color: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

/* Mobile responsive adjustments for create game modal */
@media (max-width: 768px) {
    .game-type-options {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .game-type-card {
        padding: 20px;
    }
    
    .game-type-icon {
        font-size: 2.5rem;
        margin-bottom: 12px;
    }
    
    .game-type-card h4 {
        font-size: 1.2rem;
    }
    
    .computer-player-options {
        max-width: 100%;
    }
}

/* Login Note Styling */
.login-note {
    text-align: center;
    margin: 20px auto 0 auto;
    margin-bottom: 20px;
    padding: 12px 20px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    color: var(--light-text);
    max-width: 800px;
    /* Match the width of play-options container */
}

.login-note small {
    font-size: 0.9rem;
    font-style: italic;
}

/* Mobile landscape mode - Compact Create Game modal to fit on screen */
@media (max-height: 500px) and (orientation: landscape) {
    #create-game-modal .modal-content {
        max-height: calc(100vh - 20px);
        max-width: 650px;
    }
    
    #create-game-modal .modal-header {
        padding: 14px 24px;
    }
    
    #create-game-modal .modal-header h3 {
        font-size: 1.25rem;
    }
    
    #create-game-modal .modal-body {
        padding: 0 24px 20px;
    }
    
    .game-type-options {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
        margin-bottom: 14px;
    }
    
    .game-type-card {
        padding: 16px 14px;
    }
    
    .game-type-icon {
        font-size: 2.1rem;
        margin-bottom: 10px;
    }
    
    .game-type-card h4 {
        font-size: 1.15rem;
        margin-bottom: 10px;
    }
    
    .game-type-card p {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    .game-type-card .btn {
        padding: 10px 14px;
        font-size: 0.9rem;
        margin-top: 14px;
        min-width: auto;
    }
    
    /* Local game options in landscape */
    .local-game-options {
        padding: 14px 0;
    }
    
    .local-game-options h4 {
        font-size: 1.1rem;
        margin-bottom: 16px;
    }
    
    .computer-player-options {
        gap: 12px;
        margin-bottom: 16px;
    }
    
    .computer-count-btn {
        padding: 12px 18px;
        font-size: 1rem;
    }
    
    /* Join Game modal in landscape */
    #game-list-modal .modal-content {
        max-height: calc(100vh - 20px);
        max-width: 600px;
    }
    
    #game-list-modal .modal-header {
        padding: 12px 20px;
    }
    
    #game-list-modal .modal-header h3 {
        font-size: 1.2rem;
    }
    
    #game-list-modal .modal-body {
        padding: 0 16px 16px;
    }
    
    .game-code-section {
        margin-bottom: 16px;
        padding: 14px;
    }
    
    .game-code-section h4 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    
    .game-code-form input {
        padding: 8px 10px;
    }
    
    .game-code-form button {
        padding: 8px 14px;
    }
    
    .game-list-section {
        margin-top: 12px;
    }
    
    .game-list-section h4 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    
    .no-games-message {
        padding: 14px;
        font-size: 0.9rem;
    }
    
    .game-list-header,
    .game-list-item {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
}


