@font-face {
    font-family: 'Pokemon';
    src: url('pokemon.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --pokemon-red: #E3350D;
    --pokemon-blue: #2A75BB;
    --pokemon-yellow: #FFCC00;
    --pokemon-green: #4DAD5B;
    --dark-bg: #0D1117;
    --darker-bg: #010409;
    --card-bg: #161B22;
    --card-bg-hover: #1c2128;
    --card-border: #30363D;
    --text-primary: #F0F6FC;
    --text-secondary: #8B949E;
    --gb-green: #9BBC0F;
    --gba-purple: #5C2D91;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--darker-bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.bg-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='30' cy='30' r='20' fill='none' stroke='%23fff' stroke-width='2'/%3E%3Cline x1='10' y1='30' x2='50' y2='30' stroke='%23fff' stroke-width='2'/%3E%3Ccircle cx='30' cy='30' r='8' fill='%23fff'/%3E%3C/svg%3E");
    animation: floatBg 80s linear infinite;
}

@keyframes floatBg {
    0% { background-position: 0 0; }
    100% { background-position: 1000px 1000px; }
}

/* Header */
header {
    background: linear-gradient(180deg, var(--dark-bg) 0%, transparent 100%);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
}

.logo-icon {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--pokemon-red) 50%, #fff 50%);
    border-radius: 50%;
    border: 3px solid var(--text-primary);
    position: relative;
    animation: pulse 2s ease-in-out infinite;
}

.logo-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background: var(--text-primary);
    border-radius: 50%;
    border: 2px solid var(--card-border);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(227, 53, 13, 0.4); }
    50% { box-shadow: 0 0 20px 8px rgba(227, 53, 13, 0); }
}

.logo h1 {
    font-family: 'Pokemon', 'Press Start 2P', cursive;
    font-size: 1.8rem;
    background: linear-gradient(90deg, var(--pokemon-yellow), var(--pokemon-red));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Ad Banners */
.ad-banner {
    max-width: 1400px;
    margin: 1rem auto;
    padding: 0 2rem;
}

.ad-placeholder {
    background: linear-gradient(135deg, var(--card-bg) 0%, #1a1f26 100%);
    border: 2px dashed var(--card-border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    position: relative;
}

.ad-placeholder.leaderboard {
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-placeholder.rectangle {
    width: 100%;
    height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ad-placeholder span {
    color: var(--text-secondary);
    font-size: 0.8rem;
    opacity: 0.6;
}

.ad-label {
    position: absolute;
    top: 5px;
    right: 10px;
    font-size: 0.6rem;
    color: var(--text-secondary);
    opacity: 0.4;
}

/* Main Content */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem 2rem;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

/* Tabs */
.section-tabs {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.8rem 1.5rem;
    border: 2px solid var(--card-border);
    border-radius: 10px;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.55rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    color: var(--text-secondary);
}

.tab-btn.active {
    border-color: var(--pokemon-yellow);
    color: var(--pokemon-yellow);
    background: rgba(255, 204, 0, 0.1);
}

.tab-btn:hover:not(.active) {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.tab-btn .count {
    background: var(--card-border);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.7rem;
}

.tab-btn.active .count {
    background: var(--pokemon-yellow);
    color: var(--darker-bg);
}

/* ROM Grid & Cards */
.rom-grid {
    display: grid;
    gap: 1rem;
}

.rom-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.2rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
    transition: all 0.3s ease;
}

.rom-card:hover {
    background: var(--card-bg-hover);
    border-color: rgba(255, 204, 0, 0.3);
    transform: translateX(5px);
}

.rom-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Icon Colors */
.rom-icon.emerald { background: linear-gradient(135deg, #50c878, #2e8b57); }
.rom-icon.firered { background: linear-gradient(135deg, #ff6b35, var(--pokemon-red)); }
.rom-icon.leafgreen { background: linear-gradient(135deg, #7cb342, #4DAD5B); }
.rom-icon.ruby { background: linear-gradient(135deg, #e74c3c, #c0392b); }
.rom-icon.sapphire { background: linear-gradient(135deg, var(--pokemon-blue), #1a4a75); }
.rom-icon.pinball { background: linear-gradient(135deg, #9b59b6, #8e44ad); }
.rom-icon.mystery { background: linear-gradient(135deg, #3498db, #2980b9); }
.rom-icon.crystal { background: linear-gradient(135deg, #4fc3f7, #0288d1); }
.rom-icon.gold { background: linear-gradient(135deg, #f1c40f, #d4a017); }
.rom-icon.silver { background: linear-gradient(135deg, #bdc3c7, #95a5a6); }
.rom-icon.yellow { background: linear-gradient(135deg, var(--pokemon-yellow), #f39c12); }
.rom-icon.red { background: linear-gradient(135deg, var(--pokemon-red), #991f00); }
.rom-icon.blue { background: linear-gradient(135deg, var(--pokemon-blue), #1a4a75); }

.rom-details {
    min-width: 0;
}

.rom-details h4 {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rom-meta {
    display: flex;
    gap: 0.8rem;
    flex-wrap: wrap;
    align-items: center;
}

.rom-meta span {
    color: var(--text-secondary);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.platform-badge {
    background: var(--card-border);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.platform-badge.gba {
    background: rgba(92, 45, 145, 0.3);
    color: #a855f7;
}

.platform-badge.gbc {
    background: rgba(155, 188, 15, 0.2);
    color: var(--gb-green);
}

.platform-badge.gb {
    background: rgba(155, 188, 15, 0.15);
    color: #7a9c07;
}

.volume-indicator {
    color: var(--pokemon-yellow) !important;
    font-weight: 600;
}

/* Download Button */
.download-btn {
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--pokemon-blue);
    color: white;
    white-space: nowrap;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(42, 117, 187, 0.4);
    background: #3485cb;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--card-border);
    padding: 1.5rem;
}

.sidebar-card h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.6rem;
    color: var(--pokemon-yellow);
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.top-rom-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--card-border);
}

.top-rom-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.top-rank {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    color: var(--pokemon-yellow);
    width: 25px;
}

.top-rom-info h5 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.top-rom-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Emulator Links */
.emulator-links a {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem;
    background: var(--dark-bg);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.emulator-links a:last-child {
    margin-bottom: 0;
}

.emulator-links a:hover {
    border-color: var(--pokemon-yellow);
    transform: translateX(5px);
}

.emulator-icon {
    width: 38px;
    height: 38px;
    background: var(--card-border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.emulator-info {
    flex: 1;
}

.emulator-info strong {
    display: block;
    font-size: 0.9rem;
}

.emulator-info span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Footer */
footer {
    background: var(--dark-bg);
    margin-top: 3rem;
    padding: 2rem 2rem 1.5rem;
    border-top: 1px solid var(--card-border);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 3rem;
}

.footer-brand h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    color: var(--pokemon-yellow);
    margin-bottom: 0.8rem;
}

.footer-brand p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-links h4 {
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.footer-links ul {
    list-style: none;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: var(--pokemon-yellow);
}

.footer-bottom {
    max-width: 1400px;
    margin: 1.5rem auto 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--card-border);
    text-align: center;
}

.disclaimer {
    color: var(--text-secondary);
    font-size: 0.75rem;
    max-width: 700px;
    margin: 0 auto;
}

.copyright {
    margin-top: 0.8rem;
    color: var(--text-secondary);
    font-size: 0.7rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-content {
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid var(--card-border);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.modal-content h3 {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.85rem;
    color: var(--pokemon-yellow);
    margin-bottom: 1rem;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
    font-size: 0.95rem;
}

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

.modal-btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.modal-btn.confirm {
    background: var(--pokemon-green);
    color: white;
}

.modal-btn.cancel {
    background: var(--card-border);
    color: var(--text-primary);
}

.modal-btn:hover {
    transform: scale(1.05);
}

/* Back to Top */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--pokemon-red);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-decoration: none;
    font-size: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 99;
    box-shadow: 0 5px 20px rgba(227, 53, 13, 0.4);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    transform: translateY(-5px);
    background: var(--pokemon-yellow);
    color: var(--darker-bg);
}

/* Responsive */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .ad-placeholder.rectangle {
        height: 150px;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .section-tabs {
        overflow-x: auto;
        padding-bottom: 0.5rem;
        flex-wrap: nowrap;
    }
    
    .tab-btn {
        flex-shrink: 0;
    }
    
    .rom-card {
        grid-template-columns: auto 1fr;
        gap: 0.8rem;
    }
    
    .download-btn {
        grid-column: 1 / -1;
        justify-self: stretch;
        text-align: center;
    }
    
    .sidebar {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 1.5rem;
    }
    
    .footer-links ul {
        justify-content: center;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--darker-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--card-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--pokemon-red);
}

/* Selection */
::selection {
    background: var(--pokemon-yellow);
    color: var(--darker-bg);
}
