@media (max-width: 600px) {
    #modePvP, #modePvAI {
        width: 48%; /* Take up half the screen width */
        padding: 10px;
        font-size: 1rem;
    }
}

/* --- CSS Variables & Reset --- */
:root {
    /* Palette: Dark + Cute Pink */
    --bg-dark: #121212;
    --bg-card: #1e1e24;
    --bg-card-hover: #25252d;
    
    --primary-pink: #ff758f;
    --soft-pink: #ffb3c1;
    --glow-pink: rgba(255, 117, 143, 0.4);
    
    --text-main: #ffffff;
    --text-muted: #b0b0b0;
    
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* --- Layout Utilities --- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

.section-title {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    font-weight: 800;
}

.section-title span {
    color: var(--primary-pink);
}

.section-padding {
    padding: 80px 0;
}

/* --- Navigation --- */
header {
    background-color: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1rem 0;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
}

.logo span {
    color: var(--primary-pink);
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    font-weight: 600;
    color: var(--text-muted);
    transition: var(--transition);
    position: relative;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary-pink);
}

.nav-links a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    background-color: var(--primary-pink);
    transition: var(--transition);
}

.nav-links a:hover::after, .nav-links a.active::after {
    width: 100%;
}

/* --- Mobile Navigation --- */
.hamburger {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-main);
}

.mobile-nav {
    display: none;
    background-color: var(--bg-card);
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 5px 10px rgba(0,0,0,0.2);
    z-index: 999;
}

.mobile-nav a {
    display: block;
    padding: 15px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.mobile-nav a:hover, .mobile-nav a.active {
    color: var(--primary-pink);
    background-color: rgba(255, 117, 143, 0.1);
}

/* Responsive Breakpoint */
@media (max-width: 768px) {
    .nav-links {
        display: none; /* Hide desktop links */
    }
    
    .hamburger {
        display: block; /* Show hamburger icon */
    }
    
    .mobile-nav.open {
        display: block; /* Show dropdown when active */
    }

    .section-title {
        font-size: 2rem;
    }
}

/* --- Hero Section --- */
.hero {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: radial-gradient(circle at 50% 50%, rgba(255, 117, 143, 0.15) 0%, rgba(18, 18, 18, 0) 70%);
}

.hero-content h1 {
    font-size: 4rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.1;
}

.hero-content h1 span {
    color: var(--primary-pink);
    text-shadow: 0 0 20px var(--glow-pink);
}

.hero-content p {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.btn {
    display: inline-block;
    padding: 12px 32px;
    border-radius: 50px;
    font-weight: 700;
    transition: var(--transition);
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-pink), #ff4d6d);
    color: white;
    box-shadow: 0 5px 15px rgba(255, 117, 143, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 117, 143, 0.6);
}

/* --- Skills Section --- */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.skill-category {
    background-color: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
}

.skill-category:hover {
    transform: translateY(-5px);
    border-color: var(--primary-pink);
    box-shadow: var(--shadow);
}

.skill-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.skill-header i {
    font-size: 1.5rem;
    color: var(--primary-pink);
    background: rgba(255, 117, 143, 0.1);
    padding: 10px;
    border-radius: 50%;
}

.skill-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tag {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
}

.tag:hover {
    background-color: var(--primary-pink);
    color: white;
}

/* --- Projects Section --- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}

.project-card {
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
    border-color: rgba(255, 117, 143, 0.3);
}

.project-img {
    height: 200px;
    background-color: #2a2a35;
    position: relative;
    overflow: hidden;
}

.project-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
    transition: var(--transition);
}

.project-card:hover .project-img img {
    opacity: 1;
    transform: scale(1.05);
}

.project-content {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.project-date {
    font-size: 0.85rem;
    color: var(--primary-pink);
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.project-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.project-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.project-list {
    list-style: none;
    margin-bottom: 1.5rem;
}

.project-list li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #d0d0d0;
}

.project-list li::before {
    content: '✦';
    color: var(--primary-pink);
    position: absolute;
    left: 0;
    top: 0;
}

.project-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1rem;
    text-align: right;
}

.btn-small {
    font-size: 0.9rem;
    color: var(--primary-pink);
    font-weight: 700;
}

.btn-small:hover {
    text-decoration: underline;
}

/* --- Footer --- */
footer {
    background-color: #0d0d0d;
    padding: 2rem 0;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.social-links {
    margin-bottom: 1rem;
}

.social-links a {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-card);
    color: var(--text-main);
    margin: 0 5px;
    transition: var(--transition);
}

.social-links a:hover {
    background-color: var(--primary-pink);
    color: white;
    transform: translateY(-3px);
}

.copyright {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .hero-content h1 {
        font-size: 2.8rem;
    }
    
    .nav-links {
        display: none;
    }
    
    nav {
        justify-content: center;
    }
    
    .section-title {
        font-size: 2rem;
    }
}

/* --- About Section --- */
.about-wrapper {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr; /* Text gets more space than image */
    gap: 4rem;
    align-items: center;
}

.about-content h2 {
    margin-bottom: 1.5rem;
}

.stats-grid {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-pink);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .about-wrapper {
        grid-template-columns: 1fr;
        gap: 2rem;
        text-align: center;
    }
    
    .stats-grid {
        justify-content: center;
    }

    .section-title {
        text-align: center !important; /* Force center on mobile */
    }
    
    .about-image {
        order: -1; /* Moves image to top on mobile */
    }
}

/* --- Game Styles --- */
/* --- Mobile D-Pad Controls --- */
.mobile-controls {
    display: none; /* Hidden on Computer */
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    width: 150px;
    margin: 10px auto;
    justify-content: center;
}

.mobile-controls .row-controls {
    grid-column: 1 / 4; /* Spans all 3 columns */
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.control-btn {
    background-color: var(--bg-card);
    border: 2px solid var(--primary-pink);
    color: var(--primary-pink);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.control-btn:active {
    background-color: var(--primary-pink);
    color: white;
    transform: scale(0.9);
}

/* Show controls on small screens only */
@media (max-width: 768px) {
    .mobile-controls {
        display: grid;
    }
}

#gameCanvas {
    background-color: var(--bg-dark);
    border: 2px solid var(--primary-pink);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    display: block;
    margin: 0 auto;
    
    /* THE FIX: Make it responsive */
    max-width: 100%; /* Never be wider than the card */
    height: auto;    /* Keep the aspect ratio */
    aspect-ratio: 1 / 1; /* Force it to stay a square */
}

/* --- Game Over Overlay --- */
#gameOverScreen {
    display: none; /* Hidden by default */
    flex-direction: column; /* Stacks text vertically */
    align-items: center;    /* Centers text horizontally */
    justify-content: center; /* Centers text vertically */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(18, 18, 18, 0.9);
    border-radius: var(--radius-md);
    color: white;
    z-index: 10;
}

.game-wrapper {
    position: relative; /* THIS KEEPS THE OVERLAY INSIDE THE CARD */
    width: fit-content;
    margin: 0 auto;
}

#gameOverScreen h3 {
    font-size: 2rem;
    color: var(--primary-pink);
    margin-bottom: 10px;
    margin-top: 0;
}

#gameOverScreen p {
    margin-bottom: 5px;
}

/* Ensure the card is wide enough for the game */
.project-card {
    /* ... existing styles ... */
    min-width: 320px;
}

/* Force the Grid to allow cards to be wider if needed */
.projects-grid {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); /* Increased min-width to fit the game */
}

/* --- Tic Tac Toe Styles --- */
#tttGrid {
    /* Make grid responsive: Fills card width, but max 300px */
    width: 100%;
    max-width: 300px; 
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px; /* More space between squares */
    touch-action: manipulation; /* Stops double-tap zoom on phone */
}

.ttt-cell {
    width: 100%; /* Fill the grid column */
    aspect-ratio: 1 / 1; /* Force them to be perfect squares */
    background-color: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem; /* BIGGER FONT for mobile visibility */
    font-weight: 800;
    cursor: pointer;
    transition: var(--transition);
}

.ttt-cell:hover, .ttt-cell:active {
    background-color: rgba(255, 117, 143, 0.2); /* Darker pink when tapped */
    transform: scale(0.95); /* Button press effect */
}

.ttt-cell.x { color: var(--primary-pink); }
.ttt-cell.o { color: var(--text-main); }

/* --- Memory Match Styles --- */
.memory-card {
    background-color: transparent;
    width: 50px;
    height: 50px;
    perspective: 1000px;
    cursor: pointer;
}

.memory-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* When flipped */
.memory-card.flipped .memory-inner {
    transform: rotateY(180deg);
}

/* Front and Back of card */
.memory-front, .memory-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.memory-front {
    background-color: var(--primary-pink);
    color: white;
}

.memory-back {
    background-color: var(--bg-card);
    color: white;
    transform: rotateY(180deg);
    border: 2px solid var(--primary-pink);
}

/* --- Leaderboards Top Section --- */
.leaderboards-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.leaderboard-card {
    background-color: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
}

.leaderboard-card:hover {
    border-color: var(--primary-pink);
}

.leaderboard-card h3 {
    color: var(--text-main);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary-pink);
    padding-bottom: 5px;
}

.leaderboard-card li {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}