/* Retro Pixelated Style */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    /* Prevent iOS text size adjustment */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: 'Press Start 2P', monospace;
    background: #1a1a2e;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.1) 2px, rgba(0,0,0,0.1) 4px);
    color: #00ff00;
    font-size: 10px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent text selection on buttons for better mobile UX */
    -webkit-tap-highlight-color: rgba(0, 255, 0, 0.2);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #0f0f1e;
    border: 4px solid #00ff00;
    box-shadow: 8px 8px 0px #00ff00;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #16213e;
    border: 3px solid #00ff00;
    margin-bottom: 20px;
    box-shadow: inset -2px -2px 0px #000, inset 2px 2px 0px #4a9eff;
}

.logo h1 {
    font-size: 24px;
    color: #ff00ff;
    text-shadow: 
        2px 2px 0px #000,
        4px 4px 0px #00ff00;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.logo-accent {
    color: #00ff00;
    text-shadow: 
        2px 2px 0px #000,
        4px 4px 0px #ff00ff;
}

.tagline {
    font-size: 8px;
    color: #ffff00;
    text-transform: uppercase;
}

.header-buttons {
    display: flex;
    gap: 10px;
}

/* Buttons */
.btn-header {
    padding: 12px 20px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    background: #333;
    color: #fff;
    border: 3px solid #00ff00;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 
        inset -2px -2px 0px #000,
        inset 2px 2px 0px #666;
    transition: all 0.1s;
}

.btn-header:hover {
    background: #444;
    transform: translate(1px, 1px);
    box-shadow: 
        inset -1px -1px 0px #000,
        inset 1px 1px 0px #666;
}

.btn-header:active {
    transform: translate(2px, 2px);
    box-shadow: inset 2px 2px 0px #000;
}

.btn-primary {
    background: #ff00ff;
    color: #fff;
    border-color: #ff00ff;
    box-shadow: 
        inset -2px -2px 0px #000,
        inset 2px 2px 0px #ff66ff;
}

.btn-primary:hover {
    background: #ff33ff;
}

.btn-play-small {
    padding: 8px 16px;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    background: #00ff00;
    color: #000;
    border: 2px solid #000;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 2px 2px 0px #000;
}

.btn-play-small:hover {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px #000;
}

.btn-play-small:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

/* Navigation */
.nav-menu {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.nav-link {
    padding: 10px 15px;
    background: #16213e;
    color: #00ff00;
    text-decoration: none;
    font-size: 8px;
    border: 2px solid #00ff00;
    text-transform: uppercase;
    box-shadow: 2px 2px 0px #000;
    transition: all 0.1s;
}

.nav-link:hover {
    background: #1a4d73;
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px #000;
}

.nav-link.active {
    background: #00ff00;
    color: #000;
    box-shadow: inset 2px 2px 0px #4aff4a;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    margin-bottom: 20px;
}

/* Sections */
section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 12px;
    color: #ffff00;
    margin-bottom: 15px;
    padding: 10px;
    background: #16213e;
    border: 2px solid #ffff00;
    text-transform: uppercase;
    box-shadow: 3px 3px 0px #000;
}

/* Featured Games */
.featured-games {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.game-card {
    background: #16213e;
    border: 3px solid #00ff00;
    box-shadow: 4px 4px 0px #000;
}

.game-card.featured {
    border-color: #ff00ff;
    box-shadow: 4px 4px 0px #ff00ff;
}

.game-thumbnail {
    width: 100%;
    height: 150px;
    background: #0a0a0a;
    border-bottom: 2px solid #00ff00;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: 
        repeating-linear-gradient(45deg, #1a1a2e 0px, #1a1a2e 10px, #0f0f1e 10px, #0f0f1e 20px);
}

.game-card.featured .game-thumbnail {
    border-bottom-color: #ff00ff;
}

.play-overlay {
    font-size: 10px;
    color: #00ff00;
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 12px;
    border: 2px solid #00ff00;
    text-transform: uppercase;
}

.game-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ff00ff;
    color: #fff;
    padding: 5px 8px;
    font-size: 7px;
    border: 2px solid #000;
    box-shadow: 2px 2px 0px #000;
}

.game-info {
    padding: 10px;
}

.game-info h3 {
    font-size: 9px;
    color: #ffff00;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.game-stats {
    display: flex;
    justify-content: space-between;
    font-size: 7px;
    color: #00ff00;
}

.rating {
    color: #ffff00;
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.category-card {
    background: #16213e;
    border: 3px solid #00ff00;
    padding: 20px;
    text-align: center;
    box-shadow: 3px 3px 0px #000;
    cursor: pointer;
    transition: all 0.1s;
}

.category-card:hover {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #000;
    background: #1a4d73;
}

.category-icon {
    font-size: 32px;
    margin-bottom: 10px;
    image-rendering: pixelated;
}

.category-card h3 {
    font-size: 9px;
    color: #ffff00;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.category-card p {
    font-size: 7px;
    color: #00ff00;
}

/* Popular Games */
.popular-games {
    background: #16213e;
    border: 3px solid #00ff00;
    padding: 10px;
    box-shadow: 4px 4px 0px #000;
}

.popular-game-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    border-bottom: 2px solid #00ff00;
    background: #0f0f1e;
    margin-bottom: 5px;
}

.popular-game-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.popular-rank {
    font-size: 14px;
    color: #ff00ff;
    min-width: 30px;
    text-align: center;
    font-weight: bold;
}

.popular-thumbnail {
    width: 60px;
    height: 60px;
    background: #000;
    border: 2px solid #00ff00;
    image-rendering: pixelated;
    background-image: 
        repeating-linear-gradient(90deg, #1a1a2e 0px, #1a1a2e 5px, #0f0f1e 5px, #0f0f1e 10px);
}

.popular-info {
    flex: 1;
}

.popular-info h4 {
    font-size: 9px;
    color: #ffff00;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.popular-info p {
    font-size: 7px;
    color: #00ff00;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.sidebar-box {
    background: #16213e;
    border: 3px solid #00ff00;
    padding: 15px;
    box-shadow: 3px 3px 0px #000;
}

.sidebar-box h3 {
    font-size: 9px;
    color: #ffff00;
    margin-bottom: 12px;
    text-transform: uppercase;
    border-bottom: 2px solid #00ff00;
    padding-bottom: 8px;
}

/* Search Box */
.search-box {
    display: flex;
    gap: 5px;
}

.search-box input {
    flex: 1;
    padding: 10px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    background: #000;
    color: #00ff00;
    border: 2px solid #00ff00;
    box-shadow: inset 2px 2px 0px #333;
    /* Mobile-friendly inputs */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0; /* Remove iOS rounded corners */
}

.search-box input::placeholder {
    color: #006600;
}

/* Form inputs - make touch-friendly */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
    font-family: 'Press Start 2P', monospace;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 0;
    /* Prevent zoom on iOS */
    font-size: 16px;
}

@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px; /* Prevents iOS zoom on focus */
        min-height: 44px;
        padding: 12px;
        width: 100%;
    }
}

.btn-search {
    padding: 10px 15px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    background: #00ff00;
    color: #000;
    border: 2px solid #000;
    cursor: pointer;
    box-shadow: 2px 2px 0px #000;
}

.btn-search:hover {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px #000;
}

.btn-search:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

/* Quick Links */
.quick-links {
    list-style: none;
}

.quick-links li {
    margin-bottom: 8px;
}

.quick-links a {
    color: #00ff00;
    text-decoration: none;
    font-size: 7px;
    display: block;
    padding: 6px;
    background: #0f0f1e;
    border-left: 3px solid #00ff00;
    text-transform: uppercase;
    transition: all 0.1s;
}

.quick-links a:hover {
    background: #1a4d73;
    border-left-color: #ffff00;
    color: #ffff00;
}

/* Stats */
.stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 7px;
    padding: 6px;
    background: #0f0f1e;
    border: 1px solid #00ff00;
}

.stat-label {
    color: #00ff00;
}

.stat-value {
    color: #ffff00;
    font-weight: bold;
}

/* Ad Banner */
.ad-banner {
    width: 100%;
    height: 250px;
    background: #000;
    border: 2px dashed #00ff00;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #006600;
    font-size: 8px;
}

.ad-banner small {
    font-size: 6px;
    margin-top: 5px;
}

/* Footer */
.footer {
    background: #16213e;
    border: 3px solid #00ff00;
    padding: 15px;
    margin-top: 20px;
    box-shadow: 4px 4px 0px #000;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.footer-links a {
    color: #00ff00;
    text-decoration: none;
    font-size: 7px;
    text-transform: uppercase;
    padding: 5px;
    border-bottom: 1px solid transparent;
    transition: all 0.1s;
}

.footer-links a:hover {
    color: #ffff00;
    border-bottom-color: #ffff00;
}

.copyright {
    text-align: center;
    font-size: 7px;
    color: #006600;
    margin-top: 10px;
}

/* Game Modal */
.game-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
}

.game-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-modal-content {
    background: #0f0f1e;
    border: 4px solid #00ff00;
    box-shadow: 8px 8px 0px #00ff00;
    width: 95%;
    max-width: 1400px;
    height: 95%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.8);
}

.game-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #16213e;
    border-bottom: 3px solid #00ff00;
}

.game-modal-header h2 {
    font-size: 12px;
    color: #ffff00;
    text-transform: uppercase;
    margin: 0;
}

.btn-close {
    background: #ff0000;
    color: #fff;
    border: 2px solid #000;
    padding: 8px 12px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    box-shadow: 2px 2px 0px #000;
    transition: all 0.1s;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px #000;
    background: #ff3333;
}

.btn-close:active {
    transform: translate(2px, 2px);
    box-shadow: none;
    background: #cc0000;
}

.game-modal-body {
    flex: 1;
    padding: 10px;
    background: #000;
    overflow: hidden;
}

#gameFrame {
    width: 100%;
    height: 100%;
    border: 2px solid #00ff00;
    background: #000;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Retro Scanlines Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    z-index: 9999;
    opacity: 0.5;
}

/* Mobile Hamburger Menu */
.mobile-menu-toggle {
    display: none;
    background: #00ff00;
    color: #000;
    border: 3px solid #00ff00;
    padding: 10px 15px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    cursor: pointer;
    box-shadow: 2px 2px 0px #000;
    text-transform: uppercase;
}

.mobile-menu-toggle:hover {
    background: #00cc00;
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0px #000;
}

.mobile-menu-toggle:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        padding: 15px;
    }
    
    .main-content {
        grid-template-columns: 1fr 250px;
        gap: 15px;
    }
    
    .featured-games {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 9px;
    }
    
    .container {
        padding: 10px;
        border-width: 2px;
        box-shadow: 4px 4px 0px #00ff00;
    }
    
    /* Header */
    .header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
        position: relative;
    }
    
    .logo h1 {
        font-size: 18px;
        margin-bottom: 5px;
    }
    
    .tagline {
        font-size: 7px;
    }
    
    .header-buttons {
        width: 100%;
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-header {
        width: 100%;
        padding: 14px 20px;
        font-size: 7px;
        min-height: 44px; /* Touch-friendly size */
    }
    
    /* Mobile Menu Toggle */
    .mobile-menu-toggle {
        display: block;
        width: 100%;
        margin-bottom: 10px;
        min-height: 44px;
    }
    
    /* Navigation */
    .nav-menu {
        flex-direction: column;
        gap: 8px;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out;
        margin-bottom: 0;
    }
    
    .nav-menu.active {
        max-height: 1000px;
        margin-bottom: 20px;
    }
    
    .nav-link {
        width: 100%;
        padding: 14px 15px;
        font-size: 7px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Main Content */
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .sidebar {
        order: 2;
        margin-top: 20px;
    }
    
    .section-title {
        font-size: 10px;
        padding: 8px;
    }
    
    /* Games Grid */
    .featured-games {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .category-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .game-card {
        border-width: 2px;
        box-shadow: 3px 3px 0px #000;
    }
    
    .game-thumbnail {
        height: 120px;
    }
    
    .game-info {
        padding: 12px;
    }
    
    .game-info h3 {
        font-size: 8px;
    }
    
    .game-stats {
        font-size: 6px;
    }
    
    /* Popular Games List */
    .popular-game-item {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        padding: 15px;
    }
    
    .popular-rank {
        font-size: 16px;
    }
    
    .popular-thumbnail {
        width: 80px;
        height: 80px;
        margin: 0 auto;
    }
    
    .popular-info h4 {
        font-size: 8px;
    }
    
    .popular-info p {
        font-size: 6px;
    }
    
    /* Sidebar */
    .sidebar-box {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .sidebar-box h3 {
        font-size: 8px;
        margin-bottom: 10px;
    }
    
    .search-box {
        flex-direction: column;
    }
    
    .search-box input {
        width: 100%;
        padding: 12px;
        font-size: 7px;
        min-height: 44px;
        margin-bottom: 8px;
    }
    
    .btn-search {
        width: 100%;
        padding: 14px;
        font-size: 8px;
        min-height: 44px;
    }
    
    .quick-links a {
        padding: 12px;
        font-size: 6px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .stat-item {
        padding: 10px;
        font-size: 6px;
        min-height: 44px;
    }
    
    .ad-banner {
        height: 200px;
    }
    
    /* Buttons */
    .btn-play-small {
        width: 100%;
        padding: 14px 16px;
        font-size: 6px;
        min-height: 44px;
    }
    
    /* Footer */
    .footer {
        padding: 12px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
    
    .footer-links a {
        padding: 8px;
        font-size: 6px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .copyright {
        font-size: 6px;
        margin-top: 15px;
    }
    
    /* Game Modal */
    .game-modal-content {
        width: 100%;
        height: 100%;
        max-width: 100%;
        border-width: 2px;
        box-shadow: none;
    }
    
    .game-modal-header {
        padding: 12px 15px;
        flex-wrap: wrap;
    }
    
    .game-modal-header h2 {
        font-size: 10px;
        flex: 1;
        min-width: 200px;
    }
    
    .btn-close {
        padding: 10px 15px;
        font-size: 8px;
        min-height: 44px;
        min-width: 60px;
    }
    
    .game-modal-body {
        padding: 5px;
    }
    
    #gameFrame {
        border-width: 1px;
    }
}

@media (max-width: 480px) {
    body {
        font-size: 8px;
    }
    
    .container {
        padding: 8px;
        margin: 5px;
        border-width: 2px;
    }
    
    .header {
        padding: 12px;
    }
    
    .logo h1 {
        font-size: 16px;
    }
    
    .tagline {
        font-size: 6px;
    }
    
    .section-title {
        font-size: 9px;
        padding: 6px;
    }
    
    .game-card {
        border-width: 2px;
    }
    
    .game-thumbnail {
        height: 100px;
    }
    
    .category-card {
        padding: 15px;
    }
    
    .category-icon {
        font-size: 28px;
    }
    
    .category-card h3 {
        font-size: 8px;
    }
    
    .category-card p {
        font-size: 6px;
    }
    
    /* Ensure touch targets are at least 44px */
    button, a, input, .nav-link, .btn-header, .btn-play-small, .btn-search, .mobile-menu-toggle {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Adjust text sizes for readability */
    .btn-header {
        font-size: 6px;
        padding: 12px 16px;
    }
    
    .nav-link {
        font-size: 6px;
    }
    
    .popular-rank {
        font-size: 14px;
    }
    
    .popular-info h4 {
        font-size: 7px;
    }
    
    .popular-info p {
        font-size: 5px;
    }
    
    /* Form inputs on mobile */
    form input[type="text"],
    form input[type="email"],
    form input[type="password"] {
        font-size: 16px !important; /* Prevent iOS zoom */
        min-height: 48px !important;
        padding: 14px !important;
    }
    
    /* Form labels */
    form label {
        font-size: 7px !important;
        margin-bottom: 8px !important;
    }
    
    /* Modal improvements for small screens */
    .game-modal-body {
        padding: 0;
    }
    
    #gameFrame {
        border: none;
    }
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }
    
    .container {
        max-width: 100%;
        margin: 0;
    }
    
    /* Improve touch scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better scrolling containers */
    .popular-games, .sidebar-box, #leaderboardList, #scoresList {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .header {
        padding: 10px;
    }
    
    .logo h1 {
        font-size: 14px;
    }
    
    .section-title {
        font-size: 8px;
        padding: 6px;
    }
    
    .game-modal-content {
        height: 100vh;
    }
}

/* Tablet adjustments */
@media (min-width: 481px) and (max-width: 768px) {
    .featured-games {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Large mobile devices */
@media (min-width: 376px) and (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .game-thumbnail {
        height: 110px;
    }
}