:root {
    --primary-color: #4F46E5;
    --primary-light: #6366F1;
    --secondary-color: #F3F4F6;
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --background-color: #FFFFFF;
    --card-background: #F9FAFB;
    --border-color: #E5E7EB;
    --success-color: #10B981;
    --error-color: #EF4444;
    --warning-color: #F59E0B;
    --just-bgcolor: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
}

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

/* Prevent mobile UI stretching globally */
html, body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* Prevent elastic scrolling on all elements */
* {
    overscroll-behavior: none;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--just-bgcolor);
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: var(--text-primary);
    min-height: 100vh;
    max-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    padding-top: 4rem;
    padding-bottom: 5rem;
    /* Prevent mobile UI stretching */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* Navbar Styles */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4rem;
    background-color: var(--background-color);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 50;
}

.navbar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-left: 1rem;
}

/* Card Styles */
.glass-effect {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
}

/* Button Styles */
.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

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

.btn-primary:hover {
    background-color: var(--primary-light);
}

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

.btn-secondary:hover {
    background-color: #E5E7EB;
}

/* Form Elements */
input,
select,
textarea {
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    max-width: 24rem;
    margin: 0 auto;
    width: 100%;
}

.cell {
    aspect-ratio: 1;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 0;
    /* Prevents overflow */
    padding: 0.5rem;
}

.cell:hover {
    background-color: var(--secondary-color);
}

/* Responsive Design */
@media (max-width: 640px) {
    body {
        padding: 1rem;
        padding-top: 4rem;
        /* Enhanced mobile scroll control */
        height: 100vh;
        max-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: none;
        -webkit-overflow-scrolling: touch;
        /* Prevent elastic scrolling on iOS */
        position: fixed;
        width: 100%;
        top: 0;
        left: 0;
    }

    /* Ensure main content doesn't stretch */
    html {
        height: 100%;
        overflow: hidden;
    }

    .game-board {
        max-width: 100%;
        gap: 0.25rem;
    }

    .cell {
        font-size: clamp(1.25rem, 3vw, 1.75rem);
        padding: 0.25rem;
    }
}

@media (max-width: 360px) {
    .cell {
        font-size: clamp(1rem, 2.5vw, 1.5rem);
        padding: 0.125rem;
    }
}

@media (min-width: 1024px) {
    .game-board {
        max-width: 32rem;
    }

    .cell {
        font-size: clamp(2rem, 3vw, 2.5rem);
    }
}

/* Utility Classes */
.text-primary {
    color: var(--text-primary);
}

.text-secondary {
    color: var(--text-secondary);
}

.bg-primary {
    background-color: var(--primary-color);
}

.bg-secondary {
    background-color: var(--secondary-color);
}

.border-primary {
    border-color: var(--primary-color);
}

/* Remove dark mode toggle styles */
.theme-toggle {
    display: none;
}

/* Status Messages */
.status-message {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.status-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.status-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.status-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

/* Section Transitions */
#authSection,
#gameModesSection,
#onlinePlayersSection,
#gameSection,
#userAccountSection,
#contactSection {
    position: relative;
    width: 100%;
    height: auto;
}

#authSection.hidden,
#gameModesSection.hidden,
#onlinePlayersSection.hidden,
#gameSection.hidden,
#userAccountSection.hidden,
#contactSection.hidden {
    display: none;
}

/* Mobile Bottom Navbar */
.mobile-navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    z-index: 50;
    transition: all 0.3s ease;
}

.mobile-navbar .nav-item {
    transition: all 0.2s ease;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.mobile-navbar .nav-item.active {
    color: var(--primary-color);
}

.mobile-navbar .nav-item.active svg {
    stroke: var(--primary-color);
}

.mobile-navbar .nav-item svg {
    width: 1.5rem;
    height: 1.5rem;
    margin-bottom: 0.25rem;
}

.mobile-navbar .nav-item span {
    font-size: 0.75rem;
    line-height: 1;
}

/* Responsive Improvements */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .glass-effect {
        padding: 1rem;
    }

    .btn {
        padding: 0.75rem 1rem;
    }
}

/* Chat Styles */
.chat-container {
    max-width: 100%;
    margin: 0 auto;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: #f9fafb;
    border-radius: 0.5rem;
    min-height: 8rem;
    max-height: 12rem;
    overflow-y: auto;
}

.chat-message {
    max-width: 80%;
    padding: 0.5rem;
    border-radius: 0.5rem;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.sent {
    align-self: flex-end;
    background-color: #e0e7ff;
    margin-left: auto;
    border-bottom-right-radius: 0;
}

.chat-message.received {
    align-self: flex-start;
    background-color: #f3f4f6;
    border-bottom-left-radius: 0;
}

.chat-message.new-message {
    animation: newMessage 0.5s ease;
}

@keyframes newMessage {
    0% {
        transform: scale(0.95);
        background-color: #e5e7eb;
    }

    50% {
        transform: scale(1.02);
        background-color: #f3f4f6;
    }

    100% {
        transform: scale(1);
        background-color: #f3f4f6;
    }
}

.message-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: #4f46e5;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    z-index: 1000;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.message-notification:hover {
    background-color: #4338ca;
    transform: translateY(-2px);
}

.message-notification:active {
    transform: translateY(0);
}

.message-notification svg {
    animation: bellRing 0.5s ease;
}

@keyframes bellRing {
    0% {
        transform: rotate(0);
    }

    25% {
        transform: rotate(15deg);
    }

    50% {
        transform: rotate(-15deg);
    }

    75% {
        transform: rotate(15deg);
    }

    100% {
        transform: rotate(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.chat-input-container {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.chat-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #4f46e5;
}

.chat-send-button {
    padding: 0.5rem 1rem;
    background-color: #4f46e5;
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-send-button:hover {
    background-color: #4338ca;
}

/* Scrollbar styles for chat messages */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Section transitions */
.section-transition {
    /* Remove transitions */
}

.fade-in {
    /* Remove animation */
}

.fade-out {
    /* Remove animation */
}

/* Improve scrolling behavior */
html {
    /* Removed smooth scrolling to prevent animation during section navigation */
}

/* Fix mobile navigation menu */
@media (max-width: 900px) {
    .nav-menu {
        transform: translateX(-100%);
    }

    .nav-menu.active {
        transform: translateX(0);
    }
}


/* Custom CSS for Online Players title - smaller on screens less than 370px */
@media (max-width: 370px) {
    .online-players-title {
        font-size: 1.25rem !important;
        /* text-xl equivalent */
    }
}

@media (max-width: 390px) {
    .online-players-title {
        font-size: 1.5rem !important;
        /* text-xl equivalent */
    }
}

/* Verified account icon */
.verified-icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 16px;
    height: 16px;
    background-color: #1d9bf0;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    margin-left: 4px;
    vertical-align: middle;
    cursor: pointer;
    position: relative;
    line-height: 1;
    transform: translateY(-1px);
}

/* Tooltip for verified icon */
.verified-icon-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.verified-icon-tooltip .tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: rgba(0, 0, 0, 0.9);
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 12px;
    position: fixed;
    z-index: 1000;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 14px;
    font-weight: normal;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: tooltipFadeIn 0.3s ease, tooltipFadeOut 0.3s ease 5s forwards;
}

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

.verified-icon-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

@keyframes tooltipFadeOut {
    from {
        opacity: 1;
        transform: translate(-50%, -50%);
    }

    to {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
}

#authInstallButton {

    width: 300px;

}

/* Hide navbars when auth section is visible */
body:has(#authSection:not(.hidden)) .header,
body:has(#authSection:not(.hidden)) .mobile-navbar,
body:has(#authSection:not(.hidden)) #gameModesSection,
body:has(#gameSection:not(.hidden)) .header,
body:has(#usernameSetupSection:not(.hidden)) .header,
body:has(#gameSection:not(.hidden)) #navbarToggleBtn,
body:has(#usernameSetupSection:not(.hidden)) .mobile-navbar {
    display: none !important;
}

body:has(#usernameSetupSection:not(.hidden)) .mobile-navbar,
body:has(#usernameSetupSection:not(.hidden)) #gameModesSection,
body:has(#usernameSetupSection:not(.hidden)) #gameSection,
body:has(#usernameSetupSection:not(.hidden)) #navbarToggleBtn,
body:has(#usernameSetupSection:not(.hidden)) #userAccountSection,
body:has(#usernameSetupSection:not(.hidden)) #authSection {
    display: none !important;
}

body:has(#gameModesSection:not(.hidden)) #userAccountSection {
    display: none !important;
}

body:has(#gameSection:not(.hidden)) #userAccountSection {
    display: none !important;
}

body:has(#gameSection:not(.hidden)) #gameModesSection {
    display: none !important;
}

body:has(#gameModesSection:not(.hidden)) #gameSection {
    display: none !important;
}

body:has(#onlinePlayersSection:not(.hidden)) #userAccountSection {
    display: none !important;
}

body:has(#onlinePlayersSection:not(.hidden)) #gameSection {
    display: none !important;
}

body:has(#onlinePlayersSection:not(.hidden)) #gameModesSection {
    display: none !important;
}




/* body:has(#gameModesSection:not(.hidden)) #authSection {
    display: none !important;
} */


/* History Modal Animation */
@keyframes fadeInUpModal {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.98);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-content.animate-fade-in-up {
    animation: fadeInUpModal 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Profile Refresh Button Styles */
.profile-refresh-btn {
    position: static;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 8px;
}

.profile-refresh-btn:hover {
    transform: scale(1.1);
}

.profile-refresh-btn:active {
    transform: scale(0.95);
}

.profile-refresh-btn .refresh-icon {
    transition: transform 0.3s ease;
}

.profile-refresh-btn:hover .refresh-icon {
    transform: rotate(180deg);
}

/* Responsive adjustments for profile refresh button */
@media (max-width: 640px) {
    .profile-refresh-btn {
        width: 28px;
        height: 28px;
        margin-left: 6px;
    }

    .profile-refresh-btn svg {
        width: 14px;
        height: 14px;
    }
}