/* --- Base Resets and Variables (from root style.css) --- */
:root {
    --primary-color-50: #EFF6FF;
    --primary-color-100: #DBEAFE;
    --primary-color-500: #3B82F6;
    --primary-color-600: #2563EB;
    --primary-color-700: #1D4ED8;
    --primary-color-800: #1E40AF;
    --gray-color-50: #F9FAFB;
    --gray-color-100: #F3F4F6;
    --gray-color-200: #E5E7EB;
    --gray-color-300: #D1D5DB;
    --gray-color-500: #6B7280;
    --gray-color-600: #4B5563;
    --gray-color-700: #374151;
    --gray-color-900: #111827;
    --white-color: #ffffff;
    --black-color: #000000;
}

*, *::before, *::after {
    box-sizing: border-box;
    border-width: 0;
    border-style: solid;
    border-color: var(--gray-color-200);
}

html {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    font-family: 'Nunito', ui-sans-serif, system-ui, sans-serif; /* Match root */
}

body {
    margin: 0;
    line-height: inherit;
    background-color: var(--primary-color-50); /* Match root */
    font-family: 'Nunito', sans-serif; /* Match root */
    display: flex; /* Added for footer positioning */
    flex-direction: column; /* Added for footer positioning */
    min-height: 100vh; /* Added for footer positioning */
}

main.site-content {
    flex-grow: 1; /* Ensures main content takes up space */
    padding: 1rem; /* Add padding around main content */
}

.content-wrapper {
    max-width: 1280px; /* Example max-width, adjust as needed */
    margin-left: auto;
    margin-right: auto;
    /* padding: 2rem 1rem; Example padding, adjust as needed */
}

h1, h2, h3, h4, h5, h6 {
    font-size: inherit;
    font-weight: inherit;
    font-family: 'Quicksand', sans-serif; /* Match root */
}

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

img, svg {
    display: block;
    vertical-align: middle;
    max-width: 100%;
    height: auto;
}

.sr-only { 
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* --- Header Styles (from root style.css) --- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background-color: var(--white-color);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.site-nav {
    max-width: 64rem; /* max-w-5xl */
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem; /* px-4 */
    padding-right: 1rem;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    height: 4rem; /* h-16 */
}

.site-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.site-logo img {
    height: 2.25rem; /* h-9 */
    width: 2.25rem; /* w-9 */
}

.site-title {
    margin-left: 0.5rem; /* ml-2 */
    font-size: 1.25rem; /* text-xl */
    font-weight: 700; /* font-bold */
    color: var(--gray-color-900);
}

.nav-links-desktop {
    display: none; /* hidden by default */
}

.nav-links-desktop a {
    padding: 0.5rem 0.75rem; /* px-3 py-2 */
    font-size: 0.875rem; /* text-sm */
    font-weight: 500; /* font-medium */
    color: var(--gray-color-600);
    text-decoration: none;
    transition: color 150ms ease-in-out;
}

.nav-links-desktop a:hover {
    color: var(--primary-color-600);
}

.nav-links-desktop a.active {
    color: var(--primary-color-600);
    font-weight: 600;
}

.mobile-menu-button-wrapper {
    display: flex;
    align-items: center;
}

.mobile-menu-toggle {
    color: var(--gray-color-500);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}

.mobile-menu-toggle:hover {
    color: var(--primary-color-600);
}

.mobile-menu-toggle svg {
    height: 1.5rem; /* h-6 */
    width: 1.5rem; /* w-6 */
}

.mobile-nav-links {
    display: none; /* hidden by default */
    background-color: var(--white-color);
    border-top: 1px solid var(--gray-color-200);
}

.mobile-nav-links > div {
    padding: 0.5rem 0.5rem 0.75rem; /* px-2 pt-2 pb-3 */
}

.mobile-nav-links > div > :not([hidden]) ~ :not([hidden]) {
    margin-top: 0.25rem; /* space-y-1 */
}

.mobile-nav-links a {
    display: block;
    padding: 0.5rem 0.75rem; /* px-3 py-2 */
    border-radius: 0.375rem; /* rounded-md */
    font-size: 1rem; /* text-base */
    font-weight: 500; /* font-medium */
    color: var(--gray-color-700);
    text-decoration: none;
}

.mobile-nav-links a:hover {
    background-color: var(--primary-color-50);
    color: var(--primary-color-700);
}

.mobile-nav-links a.active {
    background-color: var(--primary-color-100);
    color: var(--primary-color-700);
    font-weight: 600;
}


/* --- Footer Styles (from root style.css) --- */
.site-footer {
    background-color: var(--white-color);
    border-top: 1px solid var(--gray-color-200);
    padding-top: 1.5rem; /* py-6 */
    padding-bottom: 1.5rem;
    margin-top: auto; /* Pushes footer down */
}

.footer-container {
    max-width: 64rem; /* max-w-5xl */
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem; /* px-4 */
    padding-right: 1rem;
}

.footer-content {
    display: flex;
    flex-direction: column; /* flex-col */
    align-items: center; /* items-center */
}

.footer-content > div:first-child {
    display: flex;
    align-items: center;
}

.footer-content img {
    height: 2.25rem; /* h-9 */
    width: 2.25rem; /* w-9 */
}

.footer-content span {
    margin-left: 0.5rem; /* ml-2 */
    font-size: 0.875rem; /* text-sm */
    font-weight: 500; /* font-medium */
    color: var(--gray-color-900);
}

.footer-copyright {
    font-size: 0.875rem; /* text-sm */
    color: var(--gray-color-500);
    margin-top: 1rem; /* mt-4 */
    text-align: center;
}

/* --- Media Queries for Nav/Footer (from root style.css) --- */
@media (min-width: 640px) { /* sm */
    .site-nav {
        padding-left: 1.5rem; /* sm:px-6 */
        padding-right: 1.5rem;
    }
    .footer-container {
        padding-left: 1.5rem; /* sm:px-6 */
        padding-right: 1.5rem;
    }
}

@media (min-width: 768px) { /* md */
    .nav-links-desktop {
        display: flex; /* md:flex */
        align-items: center;
    }
    .nav-links-desktop > :not([hidden]) ~ :not([hidden]) {
        margin-left: 0.25rem; /* space-x-1 */
    }
    .mobile-menu-button-wrapper {
        display: none; /* md:hidden */
    }
    #mobile-menu {
        display: none !important; /* md:hidden ensure */
    }
    .footer-content {
        flex-direction: row; /* md:flex-row */
        justify-content: space-between; /* md:justify-between */
    }
    .footer-copyright {
        margin-top: 0; /* md:mt-0 */
    }
}

@media (min-width: 1024px) { /* lg */
    .site-nav {
        padding-left: 2rem; /* lg:px-8 */
        padding-right: 2rem;
    }
    .footer-container {
        padding-left: 2rem; /* lg:px-8 */
        padding-right: 2rem;
    }
}

/* --- Mobile Menu Fixes --- */
@media (max-width: 767px) {
    /* Header basics */
    header.site-header {
        position: relative;
        z-index: 1000;
        width: 100%;
        background-color: white;
    }
    
    html.dark .site-header {
        background-color: #1F2937;
    }
    
    /* Mobile menu container */
    #mobile-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        width: 100%;
        background-color: white;
        border-top: 1px solid #ddd;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.2s ease-in-out;
    }
    
    /* Show mobile menu when not hidden */
    #mobile-menu:not(.hidden) {
        display: block !important;
        opacity: 1;
    }
    
    /* Inner container */    
    #mobile-menu > div {
        display: block !important;
        padding: 8px !important;
    }
        
    /* Style for mobile nav links */    
    #mobile-menu .nav-link {
        display: block;
        width: 100%;
        padding: 12px 16px;
        margin: 8px 0;
        font-size: 16px;
        font-weight: 500;
        text-align: center;
        color: #000000;
        background-color: #f8f9fa;
        border-radius: 8px;
        text-decoration: none;
        transition: all 0.2s ease-in-out;
    }
        
    #mobile-menu .nav-link:hover {
        background-color: #e9ecef;
    }
        
    #mobile-menu .nav-link.active {
        color: #ffffff;
        background-color: #2563EB;
        font-weight: 600;
    }

    /* Dark mode adjustments */    
    html.dark #mobile-menu {
        background-color: #1F2937;
        border-top-color: #374151;
    }
        
    html.dark #mobile-menu .nav-link {
        color: #ffffff;
        background-color: #374151;
    }
        
    html.dark #mobile-menu .nav-link.active {
        color: #ffffff;
        background-color: #1D4ED8;
    }
    
    /* Main content positioning */
    main {
        margin-top: 0;
        transition: margin-top 0.3s ease;
    }
    
    /* When menu is visible, push main down */
    header.site-header.menu-open + main {
        margin-top: 22rem; /* Ensure enough space for all menu items */
    }
    
    /* For very small screens, adjust the margin */
    @media (max-width: 375px) {
        header.site-header.menu-open + main {
            margin-top: 24rem; /* More space for smaller screens */
        }
    }
}

/* --- Gomoku Specific Styles --- */

/* Adjust Gomoku container within the main content area */
.container {
    background-color: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    width: 100%;
    margin-top: 2rem; /* Add space from header */
}

.screen#mode-selection {
    max-width: 500px;
    margin: 2rem auto 4rem; /* Adjust centering margins */
}

.screen {
    text-align: center;
}

.hidden {
    display: none;
}

/* Use root font if desired, or override */
h1 {
    font-family: 'Quicksand', sans-serif; /* Match root */
    color: #333;
    margin-bottom: 2rem;
    font-size: 2.5rem;
}

/* Styling for h1 inside mode selection */
.screen#mode-selection h1 {
    font-size: 3.5rem; /* Made Gomoku text bigger */
    margin-bottom: 1rem; /* Adjusted margin */
}

h2 {
    font-family: 'Quicksand', sans-serif; /* Match root */
    color: #555;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    font-weight: normal;
}

/* Increase size for welcome message */
.screen#mode-selection h2 {
    font-size: 2.2rem; /* Made Welcome to text bigger */
    margin-bottom: 0.1rem; /* Adjusted margin */
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2.5rem; /* Added space between heading and buttons */
}

/* Base style for Gomoku buttons */
button {
    font-family: 'Nunito', sans-serif; /* Match root */
    /* Remove general padding/font-size, apply more specifically */
    /* padding: 1.2rem 2.5rem; */
    /* font-size: 1.3rem; */
    border: none;
    border-radius: 8px;
    /* background-color: #4CAF50; Set specifically below */
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    text-align: center;
    display: inline-block; /* Ensure button nature */
    line-height: 1.5; /* Adjust line height if needed */
}

/* Enhanced styles specifically for Mode Selection buttons */
.mode-buttons button {
    padding: 1rem 2rem; /* Slightly smaller padding */
    font-size: 1.1rem; /* Slightly smaller font */
    font-weight: 600;
    width: 100%; /* Make them full width of container */
    max-width: 300px; /* Max width for better appearance */
    margin-left: auto;
    margin-right: auto;
    color: white; /* Explicitly set text color to white */
}

/* Assign specific background colors */
#pvc-mode {
    background-color: var(--primary-color-600, #2563EB); /* Use CSS var, fallback blue */
}
#pvc-mode:hover {
    background-color: var(--primary-color-700, #1D4ED8);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#pvp-mode {
    /* background-color: var(--gray-color-600, #4B5563); Gray for PvP */
    background-color: #f44336; /* Red color (like restart button) */
}
#pvp-mode:hover {
    /* background-color: var(--gray-color-700, #374151); */
    background-color: #da190b; /* Darker red on hover */
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}


/* Keep general button hover effect (redundant but safe) */
button:hover {
    /* background-color: #45a049; Handled specifically now */
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Style specific buttons by ID */
#restart-btn {
    background-color: #f44336;
}

#restart-btn:hover {
    background-color: #da190b;
}

#menu-btn {
    background-color: #2196F3; /* Blue color */
}

#menu-btn:hover {
    background-color: #0b7dda;
}

#status {
    font-family: 'Nunito', sans-serif; /* Match root */
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #333;
    font-weight: bold;
}

/* Game Area Layout */
.game-area {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.board-container {
    flex-grow: 1;
    width: auto;
    max-width: none;
    padding: 20px;
    background-color: #f8f8f8;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#board {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 2px;
    background-color: #DEB887;
    padding: 20px;
    border-radius: 8px;
    width: 100%;
    max-width: 80vh;
    max-height: 80vh;
    aspect-ratio: 1;
    margin: 0 auto;
}

/* Info Box Styles */
.info-box {
    width: 250px;
    flex-shrink: 0;
    padding: 1.5rem;
    background-color: #f1f1f1;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.info-box #status {
    margin-bottom: 0;
    text-align: center;
}

.game-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    align-items: center;
    margin-top: 1.5rem;
}

/* Styles for buttons specifically inside the info-box */
.info-box button {
    width: 80%;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    margin: 0;
    /* Inherit base button styles from above */
}

.cell {
    aspect-ratio: 1;
    background-color: #DEB887;
    border: 1px solid #000;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
}

.cell:hover {
    background-color: #d4a76a;
}

/* REMOVED inner grid lines */
/* .cell::before { ... } */
/* .cell::after { ... } */

.stone {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85%;
    height: 85%;
    border-radius: 50%;
    z-index: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.stone:hover {
    transform: translate(-50%, -50%) scale(1.05);
}

.stone.black {
    background-color: #000;
}

.stone.white {
    background-color: #fff;
    border: 1px solid #000;
}

.winning-line {
    background-color: rgba(255, 255, 0, 0.3);
}

/* Adjust media query for game-area stacking */
@media (max-width: 1000px) { /* Stack below 1000px */
    .game-area {
        flex-direction: column;
        align-items: center;
    }

    .info-box {
        width: 100%;
        max-width: 400px;
    }

    .board-container {
         width: 100%;
    }
}

@media (max-width: 800px) {
    /* Adjust Gomoku container padding if needed */
    .container {
        padding: 1rem;
        margin-top: 1rem; /* Reduce space on smaller screens */
    }

    .board-container {
        padding: 10px;
    }

    #board {
        padding: 10px;
        max-width: 90vw;
        max-height: 90vw;
    }

    h1 {
        font-size: 2rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    /* Adjust base button size on smaller screens */
    button {
        padding: 1rem 2rem;
        font-size: 1.2rem;
    }

    /* Adjust info box button size on small screens */
    .info-box button {
        width: 90%;
        padding: 0.7rem 1.2rem;
        font-size: 0.9rem;
    }

    #status {
        font-size: 1.3rem;
    }
} 