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

:root {
    --primary-color: #00ADB5;
    --secondary-color: #393E46;
    --dark-color: #222831;
    --light-color: #EEEEEE;
    --accent-color: #00ADB5;
    --text-dark: #222831;
    --text-light: #EEEEEE;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--light-color);
    overflow-x: hidden;
    max-width: 100vw;
}

/* Viewport and overflow prevention */
html, body {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
}

/* Ensure all elements respect viewport boundaries */
* {
    max-width: 100vw;
    box-sizing: border-box;
}

/* Prevent horizontal scroll on all devices */
@media screen and (max-width: 100vw) {
    html, body, .container, .header, .footer, .navbar, 
    .nav-container, .nav-menu, .hero-section, .features-section, 
    .games-section, .benefits-section, .testimonials-section, 
    .stats-section, .cta-section, .games-grid, .features-grid, 
    .benefits-grid, .testimonials-grid, .stats-grid {
        overflow-x: hidden;
        max-width: 100vw;
        width: 100%;
    }
}

/* Ensure images and media don't overflow */
img, video, iframe, embed, object {
    max-width: 100%;
    height: auto;
    overflow: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
    color: var(--dark-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
}

h2 {
    font-size: 2.5rem;
}

h3 {
    font-size: 1.8rem;
}

p {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    overflow-x: hidden;
}

/* Header and Navigation */
.header {
    background-color: var(--dark-color);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.navbar {
    padding: 1rem 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.nav-logo {
    display: flex;
    align-items: center;
}

.nav-logo img {
    height: 50px;
    width: auto;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
    margin-left: auto;
}

.nav-link {
    color: var(--light-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
}

.nav-link:hover {
    color: var(--primary-color);
    background-color: rgba(0, 173, 181, 0.1);
}

.nav-buttons {
    display: flex;
    gap: 1rem;
}

.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: 600;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    text-align: center;
    font-size: 1rem;
}

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

.btn-primary:hover {
    background-color: #0099a3;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 173, 181, 0.3);
}

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

.btn-secondary:hover {
    background-color: var(--primary-color);
    color: var(--light-color);
    transform: translateY(-2px);
}

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

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

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

.btn-register:hover {
    background-color: #0099a3;
    transform: translateY(-2px);
}

.btn-login-large, .btn-register-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    margin-top: 1rem;
}

.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 4px;
    padding: 0.5rem;
    z-index: 1001;
}

.hamburger span {
    width: 25px;
    height: 3px;
    background-color: var(--light-color);
    transition: var(--transition);
    border-radius: 2px;
}

/* Hamburger animation when active */
.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

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

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

/* Main Content */
main {
    margin-top: 80px;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--dark-color) 0%, var(--secondary-color) 100%);
    color: var(--light-color);
    padding: 6rem 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.hero-content h1 {
    color: var(--light-color);
    margin-bottom: 1.5rem;
}

.hero-subtitle {
    font-size: 1.3rem;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 1rem;
}

.hero-description {
    font-size: 1.1rem;
    color: #cccccc;
    margin-bottom: 2rem;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

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

.hero-image img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

/* Features Section */
.features-section {
    padding: 5rem 0;
    background-color: var(--light-color);
}

.features-section h2 {
    text-align: center;
    margin-bottom: 3rem;
    color: var(--dark-color);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature-card {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.feature-icon {
    margin-bottom: 1rem;
    font-size: 3rem;
    color: var(--accent-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 80px;
}

.feature-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Login and Register Sections */
.login-section, .register-section {
    padding: 5rem 0;
    background-color: white;
}

.login-section:nth-child(even), .register-section:nth-child(even) {
    background-color: var(--light-color);
}

.login-content, .register-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.login-content h2, .register-content h2 {
    color: var(--dark-color);
    margin-bottom: 1.5rem;
}

.login-content p, .register-content p {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

/* About Section */
.about-section {
    padding: 3rem 0;
    background-color: var(--light-color);
}

.about-section .container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.about-content h2 {
    color: var(--dark-color);
    margin-bottom: 1.5rem;
}

.about-content p {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.about-image {
    display: flex;
    justify-content: center;
    align-items: center;
}

.about-image img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

/* Responsive design for about section */
@media (max-width: 768px) {
    .about-section .container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .about-image {
        order: -1; /* Move image above text on mobile */
    }
}

/* Games Section */
.games-section {
    padding: 5rem 0;
    background-color: white;
}

.games-section h2 {
    text-align: center;
    margin-bottom: 3rem;
    color: var(--dark-color);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.game-card {
    background-color: var(--light-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.game-icon {
    width: 100%;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: var(--light-color);
    font-size: 4rem;
}

.game-card h3 {
    padding: 1.5rem 1.5rem 0.5rem;
    color: var(--primary-color);
}

.game-card p {
    padding: 0 1.5rem 1.5rem;
    color: var(--secondary-color);
}

/* Benefits Section */
.benefits-section {
    padding: 5rem 0;
    background-color: var(--light-color);
}

.benefits-section h2 {
    text-align: center;
    margin-bottom: 3rem;
    color: var(--dark-color);
}

.benefits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.benefit-item {
    background-color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.benefit-item h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.benefit-item p {
    color: var(--secondary-color);
}

/* Testimonials Section */
.testimonials-section {
    padding: 5rem 0;
    background-color: white;
}

.testimonials-section h2 {
    text-align: center;
    margin-bottom: 3rem;
    color: var(--dark-color);
}

.testimonials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.testimonial-card {
    background-color: var(--light-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
    position: relative;
}

.testimonial-card p {
    font-style: italic;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.testimonial-author {
    color: var(--primary-color);
    font-weight: 600;
}

/* Stats Section */
.stats-section {
    padding: 5rem 0;
    background: linear-gradient(135deg, var(--dark-color) 0%, var(--secondary-color) 100%);
    color: var(--light-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    text-align: center;
}

.stat-item h3 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-item p {
    color: var(--light-color);
    font-size: 1.2rem;
    font-weight: 600;
}

/* CTA Section */
.cta-section {
    padding: 5rem 0;
    background-color: var(--light-color);
    text-align: center;
}

.cta-section h2 {
    color: var(--dark-color);
    margin-bottom: 1.5rem;
}

.cta-section p {
    color: var(--secondary-color);
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Footer */
.footer {
    background-color: var(--dark-color);
    color: var(--light-color);
    padding: 3rem 0 1rem;
}

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

.footer-section h3, .footer-section h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.footer-section p {
    color: #cccccc;
}

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

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: #cccccc;
    text-decoration: none;
    transition: var(--transition);
}

.footer-section ul li a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--secondary-color);
    color: #cccccc;
}

/* Responsive Design */
@media (max-width: 768px) {
    .hamburger {
        display: flex;
        z-index: 1001;
        position: relative;
    }
    
    /* Ensure header layout is maintained on mobile */
    .header {
        width: 100%;
        position: relative;
    }
    
    .navbar {
        width: 100%;
        max-width: 100%;
        padding: 1rem 1rem;
        position: relative;
    }
    
    .nav-container {
        width: 100%;
        max-width: 100%;
        justify-content: space-between;
        position: relative;
    }
    
    .nav-menu {
        display: none;
        position: fixed;
        top: 80px; /* Height of header */
        left: 0;
        width: 100%;
        height: calc(100vh - 80px);
        background-color: var(--dark-color);
        flex-direction: column;
        padding: 2rem 0;
        box-shadow: var(--shadow);
        overflow-x: hidden;
        overflow-y: auto;
        margin-left: 0; /* Reset margin for mobile dropdown */
        z-index: 1000;
    }
    
    .nav-menu.active {
        display: flex;
    }
    
    .nav-menu li {
        width: 100%;
        text-align: center;
        margin: 0;
        padding: 0;
    }
    
    .nav-menu .nav-link {
        display: block;
        padding: 1rem 2rem;
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .nav-buttons {
        display: none;
    }
    
    .nav-menu .nav-buttons {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        margin-top: 2rem;
        padding: 0 2rem;
        list-style: none;
        overflow-x: hidden;
        width: 100%;
    }
    
    .nav-menu .nav-buttons .btn {
        width: 100%;
        text-align: center;
        padding: 1rem;
        margin: 0;
        max-width: 100%;
    }
    
    .hero-content {
        text-align: center;
        margin-bottom: 2rem;
        overflow-x: hidden;
    }
    
    .hero-buttons {
        justify-content: center;
        overflow-x: hidden;
        flex-wrap: wrap;
    }
    
    .about-content {
        grid-template-columns: 1fr;
        text-align: center;
        overflow-x: hidden;
    }
    
    .cta-buttons {
        flex-direction: column;
        align-items: center;
        overflow-x: hidden;
    }
    
    h1 {
        font-size: 2.5rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    h2 {
        font-size: 2rem;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .container {
        padding: 0 1rem;
        overflow-x: hidden;
        max-width: 100%;
    }
    
    /* Prevent horizontal scroll on mobile */
    .features-grid, .games-grid, .benefits-grid, .testimonials-grid, .stats-grid {
        overflow-x: hidden;
        max-width: 100%;
        grid-template-columns: 1fr;
    }
    
    .game-card, .feature-card, .benefit-item, .testimonial-card, .stat-item {
        overflow-x: hidden;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}

@media (max-width: 480px) {
    .hero-section {
        padding: 4rem 0;
        overflow-x: hidden;
    }
    
    .features-grid, .games-grid, .benefits-grid, .testimonials-grid, .stats-grid {
        grid-template-columns: 1fr;
        overflow-x: hidden;
        max-width: 100%;
        gap: 1rem;
    }
    
    .hero-buttons {
        flex-direction: column;
        align-items: center;
        overflow-x: hidden;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
        overflow-x: hidden;
    }
    
    .container {
        padding: 0 0.5rem;
        overflow-x: hidden;
        max-width: 100%;
    }
    
    /* Ensure all text elements don't overflow */
    h1, h2, h3, h4, h5, h6, p, span, a {
        word-wrap: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }
    
    /* Prevent game cards from overflowing */
    .game-card {
        margin: 0;
        padding: 0;
        overflow-x: hidden;
        max-width: 100%;
    }
    
    .game-card-content {
        padding: 1rem;
        overflow-x: hidden;
        max-width: 100%;
    }
    
    /* Ensure navigation doesn't overflow */
    .navbar {
        padding: 1rem 1rem;
        overflow-x: hidden;
        max-width: 100%;
        width: 100%;
    }
    
    .nav-container {
        overflow-x: hidden;
        max-width: 100%;
        width: 100%;
        justify-content: space-between;
    }
    
    /* Ensure header layout is maintained on extra small devices */
    .header {
        width: 100%;
    }
    
    .nav-logo {
        display: flex;
        align-items: center;
    }
    
    .hamburger {
        margin-left: auto;
    }
}

/* Additional mobile overflow prevention */
@media (max-width: 768px) {
    /* Prevent table overflow */
    table {
        max-width: 100%;
        overflow-x: auto;
        display: block;
    }
    
    /* Ensure forms don't overflow */
    form, input, textarea, select {
        max-width: 100%;
        overflow-x: hidden;
    }
    
    /* Prevent any absolute positioned elements from overflowing */
    .header, .footer, .nav-menu, .hero-section, .features-section, 
    .games-section, .benefits-section, .testimonials-section, 
    .stats-section, .cta-section {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    /* Ensure grid items don't overflow */
    .grid-item, .card, .section {
        overflow-x: hidden;
        max-width: 100%;
    }
    
    /* Handle long words and URLs */
    * {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Ensure buttons and links don't overflow */
    .btn, a, button {
        max-width: 100%;
        overflow-x: hidden;
        white-space: normal;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    /* Force single column layout */
    .grid, .flex {
        flex-direction: column;
        flex-wrap: wrap;
    }
    
    /* Ensure all containers respect viewport */
    .container, .section, .card, .grid-item {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Prevent any element from exceeding viewport width */
    * {
        max-width: 100vw;
        box-sizing: border-box;
    }
}

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

/* Focus styles for accessibility */
a:focus, button:focus, input:focus, textarea:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #00ffff;
        --secondary-color: #000000;
        --dark-color: #000000;
        --light-color: #ffffff;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: var(--light-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
}

.back-to-top.show {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 173, 181, 0.4);
}

.back-to-top:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .header, .footer, .btn, .back-to-top {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    main {
        margin-top: 0;
    }
}

/* Game-specific overflow prevention */
.game-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: hidden;
    max-width: 100%;
}

.game-feature {
    background-color: var(--primary-color);
    color: var(--light-color);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.game-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    overflow-x: hidden;
    max-width: 100%;
}

.game-actions .btn {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Mobile-specific game card adjustments */
@media (max-width: 768px) {
    .game-features {
        justify-content: center;
        gap: 0.25rem;
    }
    
    .game-feature {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
        max-width: 100%;
    }
    
    .game-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .game-actions .btn {
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .game-features {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
    }
    
    .game-feature {
        width: 100%;
        text-align: center;
        max-width: 100%;
    }
    
    .game-actions .btn {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }
}

/* Prevent body scroll when mobile menu is open */
body.menu-open {
    overflow: hidden;
}

/* Mobile menu item spacing and styling */
@media (max-width: 768px) {
    .nav-menu li:not(.nav-buttons) {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .nav-menu li:last-child {
        border-bottom: none;
    }
    
    .nav-menu .nav-link:hover {
        background-color: rgba(0, 173, 181, 0.1);
        color: var(--primary-color);
    }
    
    /* Ensure proper spacing for menu items */
    .nav-menu > li {
        margin: 0;
        padding: 0;
    }
    
    .nav-menu .nav-link {
        font-size: 1.1rem;
        font-weight: 500;
        transition: var(--transition);
    }
}
