:root {
    --page-max-width: 1100px;
    --gap: 1rem;
    --radius: 8px;
    --surface-bg: #c5fabf;
    --shadow: rgba(0,0,0,0.05);
    --header-height: 64px;
    --transition-time: 300ms;
}

/* sensible base type + colors so text is visible and readable */
html, body {
    color: #222;
    background: #96FBFF;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    font-size: 16px;
}

/* Reserve space for fixed header */
body { padding-top: var(--header-height); }

/* Header layout */
header {
    background: var(--surface-bg);
    border-bottom: 1px solid rgba(0,0,0,0.04);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 1000;
}

.header-inner {
    max-width: var(--page-max-width);
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: space-between;
    height: 100%;
}

.logo-link {
    display: inline-flex;
    align-items: center;
    padding: 0;
    margin: 0;
}

.site-logo {
    width: 48px;
    height: 48px;
    display: block;
    object-fit: contain;
    object-position: center;
}

#nav {
    display: none;
}

#nav.mobile-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    height: calc(100vh - var(--header-height));
    background: var(--surface-bg);
    padding: 1.25rem;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    z-index: 40;
    align-items: center;
    justify-content: center;
}

@media (min-width: 768px) {
    /* Desktop / large tablet: make nav an inline horizontal bar */
    #nav {
        display: flex;
        position: static;
        height: auto;
        top: auto;
        left: auto;
        right: auto;
        background: transparent;
        padding: 0;
        box-shadow: none;
        gap: 0;
        align-items: center;
    }
    /* ensure the list is horizontal and compact */
    #nav ul { flex-direction: row; gap: 0.5rem; align-items: center; }
    /* hide the mobile menu button on wider viewports */
    #mobile-btn {
        display: none;
    }
    /* slightly tighter link padding on desktop */
    #nav a { padding: 0.35rem 0.6rem; border-radius: 6px; }
}

/* Nav list + link styling */
#nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; align-items: center; height: 100%; }
#nav li { list-style: none; display: flex; align-items: center; }
#nav a { display: inline-block; padding: 0.4rem 0.8rem; border-radius: 6px; color: inherit; text-decoration: none; font-weight: 600; white-space: nowrap; }
#nav a:hover, #nav a:focus { background: rgba(0,0,0,0.08); outline: none; }

/* ensure header inner contains absolutely-positioned mobile nav */
.header-inner { position: relative; }

/* Desktop nav container styling when nav is inline */
.header-inner nav {
    margin-left: auto;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    padding: 1rem;
    box-sizing: border-box
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--gap);
    padding: var(--gap);
    max-width: var(--page-max-width);
}

.grid-item {
    background: var(--surface-bg);
    padding: calc(var(--gap) * 0.75);
    border-radius: var(--radius);
    box-shadow: 0 1px 4px var(--shadow);
    transform: translateY(16px);
    opacity: 0;
    transition: transform var(--transition-time) ease, opacity var(--transition-time) ease;
}

.grid-item.in-view {
    transform: none;
    opacity: 1;
}

/* Paragraph spacing and readable line-height */
p {
    margin-bottom: calc(var(--gap) * 0.6);
    line-height: 1.6;
}

.bold {
    font-weight: 700;
}

/* Images: scale responsively, keep them contained inside cards */
.grid-item img,
img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    margin-top: 0.75rem;
    border-radius: 6px;
}

/* Prevent overly tall images from breaking the card layout on narrow viewports */
.grid-item img {
    max-height: 360px;
    object-fit: cover;
}

/* Reduce text spacing for specific sections */
#info p,
#nes p {
    margin-bottom: 0.3rem;
    line-height: 1.4;
}

#info h3,
#nes h3, 
#crash h3,
#atari-burial h3,
#master-system h3 {
    margin-bottom: 0.7rem;
}

#info img,
#nes img {
    margin-top: 0.3rem;
}

#info,
#nes,
#atari-burial {
    padding: calc(var(--gap) * 0.5);
    height: fit-content;
}

/* Responsive breakpoints */
@media (max-width: 479px) {
    :root { --gap: 0.75rem; }
    html, body { font-size: 15px; }
    .grid-container { padding: calc(var(--gap) * 0.8); }
    .grid-item { padding: calc(var(--gap) * 0.6); }
}

@media (min-width: 480px) and (max-width: 767px) {
    :root { --gap: 0.9rem; }
    .grid-container { grid-template-columns: repeat(1, 1fr); }
}

@media (min-width: 768px) and (max-width: 1023px) {
    :root { --gap: 1rem; }
    .header-inner { padding: 0.75rem 1rem; }
    .site-logo { width: 56px; }
    /* keep the nav inline but visually subtle on medium screens */
    #nav { display: flex; background: transparent; padding: 0; border-radius: 0; }
    #nav ul { flex-direction: row; gap: 0.75rem; }
    .grid-container { grid-template-columns: repeat(2, 1fr); }
    .grid-item img { max-height: 320px; }
}

@media (min-width: 1024px) {
    .grid-container { grid-template-columns: repeat(3, 1fr); gap: calc(var(--gap) * 1.1); }
    .grid-item { padding: calc(var(--gap) * 1); }
    h3, h4 { font-size: 1.125rem; }
    .site-logo { width: 64px; }
}