:root {
    --text-color: #23272a;
    --link-color: #23272a;
    /* Links are subtle until hover perhaps? Original is greyish */
    --bg-color: #ffffff;
    /* White */
    --font-family: 'Space Grotesk', sans-serif;
}

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

body {
    font-family: var(--font-family);
    color: var(--text-color);
    width: 100%;
    height: 100vh;
    overflow: hidden;
    /* Prevent scroll */
    position: relative;
    background-color: var(--bg-color);
    /* Mobile-first adjustment */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background Animation (a small light, room by room) */
#bg-houses {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: 0;
    background: #ffffff;
    touch-action: none;
    cursor: grab;
    outline: none;
}

#bg-houses.drag {
    cursor: grabbing;
}

/* Riso sky with clouds and birds drifting across the top */
#bg-sky {
    position: fixed;
    top: 0;
    right: 0;
    width: 100vw;
    height: min(26vh, 220px);
    z-index: 0;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(to top, transparent, #000 35%);
    mask-image: linear-gradient(to top, transparent, #000 35%);
    transition: opacity 0.6s ease;
}

/* Riso meadow with flowers and butterflies in the bottom-right corner */
#bg-meadow {
    position: fixed;
    bottom: 0;
    right: 0;
    width: min(44vw, 600px);
    height: min(40vh, 300px);
    z-index: 0;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 28%);
    mask-image: linear-gradient(to right, transparent, #000 28%);
    transition: opacity 0.6s ease;
}

body.home.inside #bg-sky,
body.home.inside #bg-meadow {
    opacity: 0;
}

/* Outside the house: the camera parks the rooms in the bottom-left corner */
body.home:not(.inside) #bg-houses {
    pointer-events: none;
}

body.home #main {
    transition: opacity 0.6s ease !important;
}

body.home.inside #main {
    opacity: 0 !important;
    pointer-events: none;
}

body.home.inside #main * {
    pointer-events: none !important;
}

.enter-btn {
    position: fixed;
    z-index: 3;
    left: max(20px, calc(50vw - 480px));
    bottom: max(24px, 20vh);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.7rem;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    color: #23272a;
    background: #fff;
    border: 1px solid #23272a;
    border-radius: 99px;
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.4s, transform 0.2s ease, background 0.2s, color 0.2s;
}

.enter-dot {
    display: grid;
    place-items: center;
}

.enter-dot svg {
    width: 14px;
    height: 14px;
}

.enter-arrow {
    display: inline-block;
    transition: transform 0.2s ease;
}

.enter-btn:hover,
.enter-btn:focus-visible {
    background: #23272a;
    color: #fff;
    outline: none;
}

.enter-btn:hover .enter-arrow { transform: translateX(3px); }
.enter-btn:active { transform: scale(0.97); }

body.home.inside .enter-btn {
    opacity: 0;
    pointer-events: none;
}

.leave-btn {
    position: fixed;
    z-index: 3;
    left: 20px;
    top: 20px;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: #23272a;
    background: #fff;
    border: 1px solid #23272a;
    border-radius: 7px;
    cursor: pointer;
    box-shadow:
        4px 4px 0 -1px #fff,
        4px 4px 0 0 #23272a,
        8px 8px 0 -1px #fff,
        8px 8px 0 0 #23272a;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s, transform 0.18s ease;
}

.leave-btn:hover { transform: rotate(-2deg); }

body.home.inside .leave-btn {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.5s 1.1s, transform 0.18s ease;
}

.inside-hint {
    position: fixed;
    z-index: 3;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    margin: 0;
    padding: 0.2rem 0.8rem;
    font-size: 0.85rem;
    color: #4a4f55;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 99px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
}

body.home.inside .inside-hint {
    opacity: 1;
    transition: opacity 0.6s 1.3s;
}

@media (max-width: 760px) {
    .enter-btn { left: auto; right: 16px; bottom: 18px; }
}

/* Centered Content */
#main {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    text-align: center;
    background: transparent;
    pointer-events: none;
    /* Let clicks pass through to canvas if needed, but links need pointer-events: auto */
}

.hero-card {
    max-width: 780px;
    margin: 1.5rem;
    padding: 2rem 2.5rem;
    pointer-events: auto;
}

.hero-card h1,
.hero-card p,
.hero-card nav a {
    -webkit-text-stroke: 5px #ffffff;
    paint-order: stroke fill;
    text-shadow: 0 0 12px #ffffff, 0 0 24px #ffffff;
}

#main .hero-card h1 {
    font-size: 2rem;
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: 0.025em;
    color: #23272a;
}

#main .hero-card h1.intro {
    line-height: 1.7;
}

.intro .nowrap {
    white-space: nowrap;
}

/* boxed words in the intro: a white tag with two paper sheets stacked behind it */
.intro .tag {
    display: inline-block;
    margin: 0 0.3em;
    transition: transform 0.2s ease;
}

.intro .tag:hover {
    transform: rotate(2deg);
}

.intro .tag ~ .tag:hover {
    transform: rotate(-2deg);
}

.intro .tag-stack {
    position: relative;
}

.intro .tag-sheet,
.intro .tag-face {
    background: #ffffff;
    border: 1px solid #23272a;
    border-radius: 6px;
}

.intro .tag-sheet {
    position: absolute;
    width: 100%;
    height: 100%;
    right: -8px;
    bottom: -8px;
}

.intro .tag-sheet + .tag-sheet {
    right: -4px;
    bottom: -4px;
}

.intro .tag-face {
    position: relative;
    padding: 0 8px;
    -webkit-text-stroke: 0;
    text-shadow: none;
}

.intro .caret {
    display: inline-block;
    width: 2px;
    height: 0.95em;
    margin-left: 2px;
    vertical-align: -0.1em;
    background: #23272a;
    animation: caret-blink 1s steps(1) infinite;
}

@keyframes caret-blink {
    50% { opacity: 0; }
}

#main .hero-card p,
#main .hero-card nav a {
    font-weight: 500;
    color: #23272a;
}

#main .hero-card p {
    font-size: 1.05rem;
}

.hero-card br {
    display: none;
}

.hero-card nav {
    margin-top: 1.25rem;
}

.hero-card nav ul {
    justify-content: center;
}

.socials {
    gap: 1.4rem;
    align-items: center;
}

#main .socials .social {
    display: inline-flex;
    width: 26px;
    height: 26px;
    color: #23272a !important;
    transition: transform 0.18s ease, color 0.18s ease;
}

#main .socials .social:hover,
#main .socials .social:focus-visible {
    color: #6b7b8e !important;
    transform: translateY(-2px) rotate(-4deg);
    outline: none;
}

.socials svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
    filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px #fff);
}

.socials svg.outline {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hero-card .menu-container {
    margin-top: 1.5rem;
    gap: 0.9rem;
}

#main .hero-card .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 300px;
    padding: 0.6rem 1.4rem;
    font-size: 1.1rem;
    font-weight: 500;
    color: #23272a;
    background: #ffffff;
    border: 1px solid #23272a;
    border-radius: 7px;
    /* two outlined paper sheets peeking out behind the button */
    box-shadow:
        4px 4px 0 -1px #ffffff,
        4px 4px 0 0 #23272a,
        8px 8px 0 -1px #ffffff,
        8px 8px 0 0 #23272a;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

#main .hero-card .menu-btn::before {
    content: "\2197";
    font-size: 0.95em;
    line-height: 1;
}

#main .hero-card .menu-btn:hover,
#main .hero-card .menu-btn:focus-visible {
    background: #ffffff;
    color: #23272a;
    transform: rotate(-2deg);
    box-shadow:
        4px 4px 0 -1px #ffffff,
        4px 4px 0 0 #23272a,
        8px 8px 0 -1px #ffffff,
        8px 8px 0 0 #23272a;
    outline: none;
}

#main .hero-card .menu-btn:active {
    transform: translate(4px, 4px);
    box-shadow:
        0 0 0 -1px #ffffff,
        0 0 0 0 #23272a,
        4px 4px 0 -1px #ffffff,
        4px 4px 0 0 #23272a;
}

#main h1 {
    font-weight: 600;
    font-size: 2.2rem;
    /* Reduced size */
    margin-bottom: 1rem;
    letter-spacing: 0.025em;
    color: #23272a;
}

#main p {
    font-weight: 300;
    font-size: 1.2rem;
    color: #23272a;
    margin-bottom: 0.5rem;
}

#main a {
    color: #42b983;
    /* Vue green or a similar accent */
    text-decoration: none;
    font-weight: 400;
    pointer-events: auto;
    transition: color 0.2s ease;
}

/* A pen stroke: uneven on purpose, stretched to the width of each linked word. */
#main .hero-card p a,
.subpage .content-section a:not([class]),
.source-link a {
    text-decoration: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 9' preserveAspectRatio='none'%3E%3Cpath d='M0 4.6C18 2.2 34 7.2 62 4.1C86 1.4 104 7.6 136 4.8C162 2.4 178 6.6 200 3.7L200 5.2C176 8.2 158 3.6 132 6.4C108 8.8 84 3.2 58 6.1C36 8.4 16 4.4 0 6.4Z' fill='%23DA291C'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 0 100%;
    background-size: 100% 7px;
    padding-bottom: 5px;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

#main .hero-card p a {
    color: inherit;
}

#main a:hover {
    color: #3aa876;
}

/* Nav links styling */
nav {
    margin-top: 2rem;
    pointer-events: auto;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 1.5rem;
}

nav li a {
    color: #6b7b8e !important;
    /* Override the green for these secondary links */
    font-size: 1rem;
    position: relative;
}

nav li a:hover {
    color: #23272a !important;
}

@media (max-width: 600px) {
    #main h1 {
        font-size: 1.8rem;
    }

    #main p {
        font-size: 1rem;
        padding: 0 1rem;
    }

    nav ul {
        flex-direction: row;
        /* Keep row even on mobile usually, or wrap */
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Menu Buttons on Index */
.menu-container {
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    /* Stack them for better separation */
    align-items: center;
    gap: 1.5rem;
    pointer-events: auto;
}

.menu-btn {
    text-decoration: none;
    color: #23272a;
    border: 2px solid #23272a;
    /* Thicker border */
    padding: 1rem 3rem;
    /* Wider padding */
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.4);
    transition: all 0.3s ease;
    width: 300px;
    /* Fixed width for uniformity */
    display: inline-block;
    /* Ensure width is respected */
}

.menu-btn:hover {
    background: #23272a;
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

/* Content Sections */
.content-section {
    max-width: 700px;
    /* Reduced from 800px */
    margin: 4rem auto;
    /* Increased margin */
    padding: 0 2rem;
    /* Increased padding */
    text-align: left;
    color: #23272a;
    pointer-events: auto;
    /* Allow text selection */
}

.text-left {
    text-align: left;
}

.content-section h2 {
    font-weight: 600;
    font-size: 1.35rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 0.5rem;
    margin-top: 2rem;
}

.project-item {
    margin-bottom: 2rem;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.project-header h3 {
    font-weight: 500;
    font-size: 1.2rem;
    margin: 0;
    color: #23272a;
}

.project-header .date {
    font-size: 0.9rem;
    color: #6b7b8e;
    font-style: italic;
}

.content-section ul {
    list-style-type: disc;
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.content-section li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    font-size: 1rem;
    font-weight: 300;
}

.content-section p {
    font-weight: 300;
    line-height: 1.6;
    margin-bottom: 1rem;
    font-size: 1rem;
    color: #23272a;
}

hr {
    border: 0;
    height: 1px;
    background: rgba(0, 0, 0, 0.1);
    margin: 2rem 0;
}

/* Scrollable container if needed, but body overflow is hidden? 
   We need to allow scrolling now that content is long. 
*/
body {
    overflow-y: auto !important;
    /* Enable scroll */
}

/* Subpage Styling */
.pixel-stage {
    text-align: center;
}

.pixel-canvas {
    width: min(80vw, 512px);
    height: auto;
    aspect-ratio: 1;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
    margin: 0 auto;
}

.content-section .pixel-caption {
    text-align: center;
    margin-top: 1rem;
    font-style: italic;
    color: #6b7b8e;
}

/* Interactive Risograph Face Buddy (bottom-right on home) */
.sam-buddy {
    position: fixed;
    right: 22px;
    bottom: 20px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
    transition: opacity 0.45s ease;
}

body.home.inside .sam-buddy {
    opacity: 0;
    pointer-events: none;
}

body.home.inside .sam-buddy * {
    pointer-events: none !important;
}

.sam-face-btn {
    pointer-events: auto;
    width: 108px;
    height: 108px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.16s ease;
}

.sam-face-btn:hover {
    transform: scale(1.06) rotate(-2deg);
}

.sam-face-btn:active {
    transform: scale(0.95);
}

#sam-face {
    display: block;
    width: 100%;
    height: 100%;
}

.sam-bubble {
    pointer-events: auto;
    position: relative;
    max-width: 295px;
    background: #ffffff;
    color: #23272a;
    border: 1.5px solid #2e4682;
    border-radius: 12px;
    padding: 0.75rem 1.85rem 0.75rem 0.9rem;
    box-shadow: 4px 4px 0 #2e4682;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.86rem;
    line-height: 1.42;
    text-align: left;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sam-bubble::after {
    content: '';
    position: absolute;
    right: 36px;
    bottom: -8px;
    width: 13px;
    height: 13px;
    background: #ffffff;
    border-right: 1.5px solid #2e4682;
    border-bottom: 1.5px solid #2e4682;
    transform: rotate(45deg);
}

.sam-bubble.hidden {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    pointer-events: none;
}

.sam-close {
    position: absolute;
    top: 4px;
    right: 6px;
    border: 0;
    background: none;
    color: #6b7b8e;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
}

.sam-close:hover { color: #23272a; }

.sam-text {
    margin: 0 0 0.55rem;
    color: #23272a;
}

.sam-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.sam-chip {
    font-family: inherit;
    font-size: 0.74rem;
    color: #2e4682;
    background: #ffffff;
    border: 1px solid rgba(46, 70, 130, 0.45);
    border-radius: 999px;
    padding: 3px 9px;
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease;
}

.sam-chip:hover,
.sam-chip:focus-visible {
    background: #ffcc2e;
    border-color: #2e4682;
    color: #2e4682;
    outline: none;
}

html.night .sam-bubble,
html.night .sam-bubble::after {
    background: var(--paper);
    color: var(--ink);
    border-color: var(--ink);
}

html.night .sam-bubble {
    box-shadow: 4px 4px 0 var(--ink);
}

html.night .sam-text { color: var(--ink); }

html.night .sam-chip {
    color: var(--ink);
    background: transparent;
    border-color: rgba(236, 235, 228, 0.35);
}

html.night .sam-chip:hover {
    background: var(--ink);
    color: var(--paper);
}

@media (max-width: 760px) {
    .sam-buddy {
        right: 12px;
        bottom: 68px;
    }
    .sam-face-btn { width: 84px; height: 84px; }
    .sam-bubble { max-width: 245px; font-size: 0.8rem; }
}

.subpage.fun-body .container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.subpage.fun-body header {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0.75rem 1.25rem;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.65rem 1rem;
    box-sizing: border-box;
}

.game-switcher {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.game-switch-btn {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.88rem;
    font-weight: 500;
    color: #2e4682;
    background: #ffffff;
    border: 1.5px solid #2e4682;
    border-radius: 7px;
    padding: 0.34rem 0.82rem;
    cursor: pointer;
    box-shadow: 2px 2px 0 #2e4682;
    transition: transform 0.13s ease, background 0.13s ease;
}

.game-switch-btn:hover,
.game-switch-btn:focus-visible {
    transform: translate(-1px, -1px);
    outline: none;
}

.game-switch-btn.active {
    background: #ffcc2e;
    color: #2e4682;
}

html.night .game-switch-btn {
    color: var(--ink);
    background: var(--paper);
    border-color: var(--ink);
    box-shadow: 2px 2px 0 var(--ink);
}

html.night .game-switch-btn.active {
    background: var(--ink);
    color: var(--paper);
}

.subpage.fun-body .content-section.fun-page {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.subpage.fun-body .game-frame {
    flex: 1 1 auto;
    width: 100%;
    min-height: calc(100vh - 118px);
    aspect-ratio: auto;
    border: 0;
    display: block;
}

/* Site-wide footer */
.site-footer {
    max-width: 700px;
    margin: 3.5rem auto 0;
    padding: 1.4rem 2rem 2.2rem;
    border-top: 1px solid rgba(35, 39, 42, 0.12);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem 1.5rem;
    font-size: 0.88rem;
    color: #6b7b8e;
    box-sizing: border-box;
}

.subpage .container:has(.achievements-layout) .site-footer {
    max-width: 1200px;
}

.subpage .container:has(.ucl-section) .site-footer {
    max-width: 960px;
}

.subpage.fun-body .site-footer {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0.85rem 1.25rem;
}

.site-footer a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

.site-footer a:hover,
.site-footer a:focus-visible {
    color: #23272a;
}

body.home .site-footer {
    max-width: 700px;
    width: 100%;
    margin: 2.25rem auto 0;
    padding: 0.75rem 1.5rem 1.25rem;
    border-top: 0;
    pointer-events: none;
    justify-content: center;
    gap: 0.5rem 1.25rem;
    -webkit-text-stroke: 4px #ffffff;
    paint-order: stroke fill;
    text-shadow: 0 0 10px #ffffff;
}

body.home .site-footer a,
#main .site-footer a {
    pointer-events: auto;
    color: inherit;
}

#main .site-footer a:hover,
#main .site-footer a:focus-visible {
    color: #23272a;
}

@media (max-width: 600px) {
    .site-footer {
        padding: 1.2rem 1.25rem 1.8rem;
        justify-content: center;
        text-align: center;
    }
    body.home .site-footer {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }
}

.subpage header:has(+ .fun-page),
.content-section.fun-page {
    max-width: 1100px;
}

.fun-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 0 0 2rem;
}

.fun-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.42rem 1rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: #23272a;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid #23272a;
    border-radius: 7px;
    box-shadow: 3px 3px 0 #23272a;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fun-tab:hover,
.fun-tab:focus-visible {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #23272a;
    outline: none;
}

.fun-part {
    scroll-margin-top: 1.5rem;
}

.fun-part + .fun-part {
    margin-top: 3.5rem;
}

.fun-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2rem 1.5rem;
}

.fun-card {
    margin: 0;
}

.fun-card .pixel-canvas {
    width: 100%;
    max-width: 440px;
    border-radius: 6px;
}

/* Jensen's figure fills more of its frame than the other scenes; inset it to match their scale. */
.fun-card .pixel-canvas.is-compact {
    transform: scale(0.56);
}

.content-section .fun-credit {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 0.85rem;
    color: #6b7b8e;
}

.game-card {
    border: 1px solid rgba(35, 39, 42, 0.2);
    border-radius: 10px;
    padding: 1.25rem;
    background: #ffffff;
}

.game-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.game-card-head h3 {
    margin: 0 0 0.25rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.content-section .game-desc {
    margin: 0;
    font-size: 0.95rem;
    color: #6b7b8e;
}

.game-open-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 0.38rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #23272a;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid #23272a;
    border-radius: 7px;
    box-shadow: 3px 3px 0 #23272a;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.game-open-btn:hover,
.game-open-btn:focus-visible {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #23272a;
    outline: none;
}

.game-frame-wrap {
    width: 100%;
    border: 1px solid rgba(35, 39, 42, 0.15);
    border-radius: 8px;
    overflow: hidden;
    background: #ffffff;
}

.game-frame {
    display: block;
    width: 100%;
    aspect-ratio: 400 / 264;
    min-height: 360px;
    border: 0;
}

@media (max-width: 640px) {
    .game-card-head {
        flex-direction: column;
    }
    .game-frame {
        min-height: 280px;
    }
}

.subpage header:has(+ .ucl-section),
.content-section.ucl-section,
.subpage header:has(+ .skills-section),
.content-section.skills-section,
.subpage .container:has(.skills-section) .site-footer,
.subpage header:has(+ .research-section),
.content-section.research-section,
.subpage .container:has(.research-section) .site-footer {
    max-width: 960px;
}

.subpage header:has(+ .achievements-stage-wrap) {
    max-width: 1200px;
}

.content-section.achievements-stage-wrap {
    max-width: 960px;
    margin-bottom: 1.5rem;
}

.skills-stage {
    margin: 0 0 2.25rem;
}

#skills-canvas,
#research-canvas,
#achievements-canvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: pointer;
}

.skills-pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    margin-top: 0.9rem;
}

.skills-pill {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    color: #2e4682;
    background: #ffffff;
    border: 1.25px solid rgba(46, 70, 130, 0.45);
    border-radius: 999px;
    padding: 0.28rem 0.8rem;
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, transform 0.12s ease;
}

.skills-pill:hover,
.skills-pill:focus-visible {
    border-color: #2e4682;
    transform: translateY(-1px);
    outline: none;
}

.skills-pill.active {
    background: #ffcc2e;
    border-color: #2e4682;
    color: #2e4682;
    box-shadow: 2px 2px 0 #2e4682;
}

html.night .skills-pill {
    color: var(--ink);
    background: transparent;
    border-color: rgba(236, 235, 228, 0.35);
}

html.night .skills-pill.active {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
}

.ucl-figure {
    margin: 0 0 1rem;
}

#ucl-canvas {
    display: block;
    width: 100%;
    height: auto;
}

.ucl-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem 2rem;
}

.ucl-fact {
    border-left: 3px solid #5e3f8f;
    padding-left: 0.9rem;
}

.ucl-fact-key {
    display: block;
    font-weight: 600;
    font-size: 1.1rem;
    color: #5e3f8f;
    margin-bottom: 0.25rem;
}

.content-section .ucl-fact p {
    margin: 0;
}

.content-section .ucl-motto {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.9rem;
    color: #6b7b8e;
}

@media (max-width: 640px) {
    .ucl-facts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .content-section.fun-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .content-section.fun-grid {
        grid-template-columns: 1fr;
    }
}

body.subpage {
    overflow-y: auto;
    background-color: #ffffff;
    /* White background */
}

/* Subpage header: back button above the page title, lined up with the content */
.subpage header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 700px;
    margin: 2.5rem auto 0;
    padding: 0 2rem;
}

.subpage header:has(+ .achievements-layout) {
    max-width: 1200px;
}

.subpage header:has(+ .fun-grid) {
    max-width: 1100px;
}

.subpage header h1 {
    margin-top: 1.75rem;
    font-size: 2.25rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: 0.01em;
    color: #23272a;
}

.subpage header + .content-section {
    margin-top: 2.25rem;
}

.subpage .content-section a:not([class]) {
    color: inherit;
}

.subpage .content-section a:not([class]):hover {
    color: #6b7b8e;
}

.subpage header + .content-section > h2:first-child {
    margin-top: 0;
}

.btn-back {
    order: -1;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.95rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: #23272a;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid #23272a;
    border-radius: 7px;
    box-shadow:
        3px 3px 0 -1px #ffffff,
        3px 3px 0 0 #23272a,
        6px 6px 0 -1px #ffffff,
        6px 6px 0 0 #23272a;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.btn-back:hover,
.btn-back:focus-visible {
    transform: rotate(-2deg);
    outline: none;
}

.btn-back:active {
    transform: translate(3px, 3px);
    box-shadow:
        0 0 0 -1px #ffffff,
        0 0 0 0 #23272a,
        3px 3px 0 -1px #ffffff,
        3px 3px 0 0 #23272a;
}

@media (max-width: 600px) {
    .subpage header {
        margin-top: 1.5rem;
        padding: 0 1.25rem;
    }

    .subpage header h1 {
        font-size: 1.8rem;
    }
}

/* Adjust main container to flow naturally */
#main {
    height: auto;
    min-height: 100vh;
    justify-content: flex-start;
    padding-top: 100px;
    /* Space for the initial centered text to look good */
    padding-bottom: 50px;
}

/* Man Utd Button */
.btn-manutd {
    border-color: #DA291C;
    color: #DA291C;
}

.btn-manutd:hover {
    background: #DA291C;
    color: #ffffff;
    box-shadow: 0 6px 15px rgba(218, 41, 28, 0.3);
}

/* Achievements Layout */
.achievements-layout {
    display: flex;
    flex-wrap: wrap;
    /* Stack on mobile */
    gap: 2rem;
    align-items: flex-start;
    max-width: 1200px;
    /* Wider container */
}

.achievements-text {
    flex: 1;
    /* Less flexible space, more fixed */
    min-width: 300px;
}

.achievements-image-container {
    flex: 2;
    /* More space for images */
    display: flex;
    /* Flex container for images */
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

.image-wrapper {
    flex: 1;
    min-width: 180px;
    /* Reduced to ensure they fit side-by-side */
    max-width: 100%;
    text-align: center;
}

.achievements-image-container img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 0.5rem;
}

.photo-caption {
    font-size: 1rem;
    font-weight: 600;
    color: #23272a;
    margin-bottom: 0.25rem;
}

.source-link {
    font-size: 0.9rem;
    color: #555;
    margin-top: 0;
}

.source-link a {
    color: #DA291C;
}

/* Dictionary / Gallery Styles */
.text-center {
    text-align: center;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.gallery-item {
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.gallery-item:hover {
    transform: translateY(-5px);
}

.gallery-item img {
    width: 100%;
    height: auto;
    /* Maintain aspect ratio */
    display: block;
    position: relative;
    z-index: 2;
    /* Image on top */
}

/* Specific style for the 3rd item (Stadium) to have the logo behind */
/* Specific style for the 3rd item (Stadium) to have the logo behind */
/* Specific style for the 3rd item (Stadium) to have the logo on the side */
.gallery-item:nth-child(3) {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    background: #fff;
    /* Remove previous background image styles */
    background-image: none;
}

/* Style for the photo in the 3rd item */
.gallery-item:nth-child(3) .photo {
    flex: 2;
    /* Photo takes up more space */
    width: auto;
    max-width: 70%;
    z-index: 1;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* Style for the logo in the 3rd item */
.gallery-item:nth-child(3) .logo {
    flex: 1;
    /* Logo takes less space */
    width: auto;
    max-width: 30%;
    height: auto;
    object-fit: contain;
    z-index: 0;
}

/* ---------- Day / night ---------- */
.theme-toggle {
    position: fixed;
    z-index: 4;
    top: 14px;
    right: 14px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: #23272a;
    background: #fff;
    border: 1px solid #23272a;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.25s ease, background 0.4s, color 0.4s, border-color 0.4s;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    transform: rotate(-12deg);
    outline: none;
}

.theme-toggle svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-toggle .icon-sun { display: none; }
html.night .theme-toggle .icon-sun { display: block; }
html.night .theme-toggle .icon-moon { display: none; }

body {
    transition: background-color 0.5s ease, color 0.5s ease;
}

html.night {
    --ink: #ecebe4;
    --paper: #1d2140;
    --muted: #9aa6c4;
    --night: #161a38;
    color-scheme: dark;
}

html.night body,
html.night body.subpage {
    background-color: var(--night);
    color: var(--ink);
}

/* home */
html.night .hero-card h1,
html.night .hero-card p,
html.night .hero-card nav a {
    -webkit-text-stroke-color: var(--night);
    text-shadow: 0 0 12px var(--night), 0 0 24px var(--night);
}

html.night #main .hero-card h1,
html.night #main .hero-card p,
html.night #main .hero-card nav a,
html.night #main p,
html.night #main h1 {
    color: var(--ink);
}

html.night .intro .tag-sheet,
html.night .intro .tag-face {
    background: var(--paper);
    border-color: var(--ink);
}

html.night .intro .caret {
    background: var(--ink);
}

html.night #main .socials .social {
    color: var(--ink) !important;
}

html.night #main .socials .social:hover,
html.night #main .socials .social:focus-visible {
    color: var(--muted) !important;
}

html.night .socials svg {
    filter: drop-shadow(0 0 3px var(--night)) drop-shadow(0 0 6px var(--night));
}

html.night #main .hero-card .menu-btn,
html.night #main .hero-card .menu-btn:hover,
html.night #main .hero-card .menu-btn:focus-visible {
    color: var(--ink);
    background: var(--paper);
    border-color: var(--ink);
    box-shadow:
        4px 4px 0 -1px var(--paper),
        4px 4px 0 0 var(--ink),
        8px 8px 0 -1px var(--paper),
        8px 8px 0 0 var(--ink);
}

html.night #main .hero-card .menu-btn:active {
    box-shadow:
        0 0 0 -1px var(--paper),
        0 0 0 0 var(--ink),
        4px 4px 0 -1px var(--paper),
        4px 4px 0 0 var(--ink);
}

html.night .enter-btn,
html.night .theme-toggle {
    color: var(--ink);
    background: var(--paper);
    border-color: var(--ink);
}

html.night .enter-btn:hover,
html.night .enter-btn:focus-visible {
    color: var(--paper);
    background: var(--ink);
}

html.night .leave-btn {
    color: var(--ink);
    background: var(--paper);
    border-color: var(--ink);
    box-shadow:
        4px 4px 0 -1px var(--paper),
        4px 4px 0 0 var(--ink),
        8px 8px 0 -1px var(--paper),
        8px 8px 0 0 var(--ink);
}

html.night .inside-hint {
    color: var(--ink);
    background: rgba(29, 33, 64, 0.85);
}

/* subpages */
html.night .subpage header h1,
html.night .content-section,
html.night .content-section p,
html.night .content-section li,
html.night .project-header h3,
html.night .photo-caption {
    color: var(--ink);
}

html.night .content-section h2 {
    border-bottom-color: rgba(236, 235, 228, 0.15);
}

html.night .project-header .date,
html.night .content-section .pixel-caption,
html.night .content-section .fun-credit,
html.night .content-section .game-desc,
html.night .content-section .ucl-motto,
html.night .source-link {
    color: var(--muted);
}

html.night .fun-tab,
html.night .game-open-btn {
    color: var(--ink);
    background: var(--paper);
    border-color: var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
}

html.night .game-card {
    background: var(--paper);
    border-color: rgba(236, 235, 228, 0.2);
}

html.night .site-footer {
    color: var(--muted);
    border-top-color: rgba(236, 235, 228, 0.15);
}

html.night .site-footer a:hover,
html.night .site-footer a:focus-visible {
    color: var(--ink);
}

html.night body.home .site-footer {
    -webkit-text-stroke-color: var(--night);
    text-shadow: 0 0 10px var(--night);
}

html.night .ucl-fact {
    border-left-color: #b39ddb;
}

html.night .ucl-fact-key {
    color: #b39ddb;
}

html.night hr {
    background: rgba(236, 235, 228, 0.15);
}

html.night .subpage .content-section a:not([class]):hover {
    color: var(--muted);
}

html.night .btn-back {
    color: var(--ink);
    background: var(--paper);
    border-color: var(--ink);
    box-shadow:
        3px 3px 0 -1px var(--paper),
        3px 3px 0 0 var(--ink),
        6px 6px 0 -1px var(--paper),
        6px 6px 0 0 var(--ink);
}

html.night .btn-back:active {
    box-shadow:
        0 0 0 -1px var(--paper),
        0 0 0 0 var(--ink),
        3px 3px 0 -1px var(--paper),
        3px 3px 0 0 var(--ink);
}
