@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@400;500;600;700&family=Outfit:wght@500;600;700&display=swap');

:root {
    --ink: #31241f;
    --muted: #786b66;
    --paper: #fdf8f5;
    --blue: #8fc7ee;
    --blue-deep: #5992c6;
    --pink: #e9b8c9;
    --cream: #f5d8a8;
    --lavender: #d8c9f2;
    --shadow: 0 18px 55px rgba(49, 36, 31, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 5% 18%, rgba(233, 184, 201, 0.28), transparent 28rem),
        radial-gradient(circle at 95% 42%, rgba(143, 199, 238, 0.22), transparent 30rem),
        var(--paper);
    font-family: 'IBM Plex Sans Thai', sans-serif;
}

img {
    display: block;
    max-width: 100%;
}

.site-shell {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 56px 0 90px;
}

.hero-section {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 22px;
}

.quick-links {
    width: min(270px, calc(100% - 172px));
    min-width: 0;
    font-family: 'IBM Plex Sans Thai', sans-serif;
}

.quick-links h2 {
    margin: 0 0 5px;
    font-size: 0.98rem;
    font-weight: 700;
    line-height: 1.2;
}

.quick-links ul {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 0 36px 0 0;
    list-style: none;
}

.quick-links li:nth-child(2) { transform: translateX(12px); }
.quick-links li:nth-child(3) { transform: translateX(24px); }
.quick-links li:nth-child(4) { transform: translateX(36px); }

.quick-links a {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--ink);
    font-size: 0.78rem;
    line-height: 1.35;
    text-decoration: none;
}

.quick-links a:hover span {
    color: #b43742;
    text-decoration: underline;
}

.quick-links svg {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    fill: #d94b4b;
}

.quick-links a span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hero-image,
.hero-placeholder {
    width: min(150px, 82vw);
    aspect-ratio: 1;
    object-fit: cover;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.hero-placeholder {
    display: grid;
    place-content: center;
    color: #fff;
    text-align: center;
    background: linear-gradient(145deg, var(--blue-deep), #82b9df 58%, var(--pink));
}

.hero-placeholder span {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(4rem, 15vw, 8rem);
    font-weight: 700;
    line-height: 0.9;
    letter-spacing: -0.08em;
}

.hero-placeholder small {
    margin-top: 18px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.28em;
}

.runner-game-section {
    position: relative;
    margin-top: 2px;
    overflow: hidden;
    isolation: isolate;
    border-radius: 0;
    background: #dff3ff;
    box-shadow: none;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.runner-game-hud {
    position: absolute;
    z-index: 4;
    top: 14px;
    right: 18px;
    display: flex;
    gap: 18px;
    color: #4b6b7d;
    font-family: 'Outfit', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.runner-game-hud strong {
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

#runner-game {
    display: block;
    width: 100%;
    height: auto;
}

.runner-game-overlay {
    position: absolute;
    z-index: 3;
    inset: 0;
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    padding: 44px 20px 24px;
    text-align: center;
    background: rgba(223, 243, 255, 0.68);
    transition: opacity 160ms ease;
}

.runner-game-overlay.is-hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.runner-game-overlay h2 {
    margin: 0;
    font-size: clamp(1.7rem, 4vw, 2.8rem);
    line-height: 1.1;
}

.runner-game-overlay span {
    margin-top: 5px;
    color: #607483;
    font-size: 0.9rem;
}

.runner-leaderboard {
    width: min(330px, 92%);
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.runner-leaderboard li {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 25px;
    padding: 2px 8px;
    color: #4b6b7d;
    border-bottom: 1px solid rgba(49, 36, 31, 0.1);
    font-size: 0.78rem;
    text-align: left;
}

.runner-leaderboard li > b {
    color: #5992c6;
    font-family: 'Outfit', sans-serif;
}

.runner-leaderboard li > span {
    margin: 0;
    overflow: hidden;
    color: var(--ink);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.runner-leaderboard li > strong {
    color: var(--ink);
    font-family: 'Outfit', sans-serif;
    font-variant-numeric: tabular-nums;
}

.runner-name-form {
    width: min(350px, 94%);
    margin-top: 10px;
}

.runner-name-form label {
    display: block;
    margin-bottom: 5px;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 700;
}

.runner-name-form > div {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.runner-name-form input {
    flex: 1 1 auto;
    min-width: 0;
    height: 38px;
    padding: 0 11px;
    border: 1px solid rgba(49, 36, 31, 0.2);
    border-radius: 8px;
    outline: none;
    background: #fff;
    font: 500 0.88rem 'IBM Plex Sans Thai', sans-serif;
}

.runner-name-form button {
    flex: 0 0 auto;
    min-height: 38px;
    margin: 0;
    padding: 0 15px;
}

.runner-name-form small {
    display: block;
    min-height: 1em;
    margin-top: 3px;
    color: #a53e4d;
    font-size: 0.72rem;
}

.runner-game-overlay button {
    min-height: 42px;
    padding: 0 22px;
    color: #fff;
    cursor: pointer;
    border: 0;
    border-radius: 99px;
    background: #5992c6;
    font: 700 0.88rem 'IBM Plex Sans Thai', sans-serif;
}

.runner-game-overlay .runner-name-form button {
    height: 38px;
    min-height: 38px;
    margin: 0;
}

#runner-start-button {
    margin-top: 15px;
    background: #d94b4b;
    transform: translateY(-8px);
}

.runner-game-overlay.has-name-form {
    padding-top: 8px;
    padding-bottom: 8px;
}

.runner-game-overlay.has-name-form h2 {
    font-size: clamp(1.45rem, 3.2vw, 2.3rem);
}

.runner-game-overlay.has-name-form .runner-leaderboard {
    margin-top: 6px;
}

.runner-game-overlay.has-name-form .runner-name-form {
    margin-top: 7px;
}

.runner-game-section.has-error .runner-game-overlay {
    background: #f9e3e7;
}

.game-copy {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    min-height: 200px;
    padding: 36px 20px;
    text-align: center;
}

.game-label {
    margin-bottom: 8px;
    color: #4b79a3;
    font-family: 'Outfit', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2em;
}

.game-copy strong {
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 1.1;
}

.game-copy small {
    margin-top: 6px;
    color: #607483;
    font-size: 1rem;
}

.cloud {
    position: absolute;
    width: 90px;
    height: 28px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.8);
}

.cloud::before,
.cloud::after {
    position: absolute;
    bottom: 0;
    content: '';
    border-radius: 50%;
    background: inherit;
}

.cloud::before {
    left: 16px;
    width: 38px;
    height: 38px;
}

.cloud::after {
    right: 12px;
    width: 50px;
    height: 50px;
}

.cloud-one {
    top: 46px;
    left: 8%;
}

.cloud-two {
    top: 78px;
    right: 9%;
    transform: scale(0.72);
}

.game-ground {
    position: absolute;
    z-index: 1;
    right: 0;
    bottom: 30px;
    left: 0;
    height: 4px;
    background: #765d49;
}

.game-ground span,
.game-ground i,
.game-ground b {
    position: absolute;
    bottom: 4px;
    width: 18px;
    height: 38px;
    background: #7a9c72;
}

.game-ground span { left: 13%; }
.game-ground i { right: 20%; height: 28px; }
.game-ground b { right: 11%; width: 11px; height: 52px; }

.headline-section {
    display: grid;
    min-height: 0;
    padding: 54px 22px 18px;
    place-items: center;
    text-align: center;
}

.headline-section h1 {
    max-width: 900px;
    margin: 0;
    color: var(--headline-color);
    font-size: clamp(18px, 5vw, var(--headline-size));
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.projects-section {
    padding-top: 0;
}

.section-heading {
    margin-bottom: 18px;
    text-align: center;
}

.section-heading p {
    margin: 0;
    color: var(--blue-deep);
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.2em;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.project-card {
    position: relative;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    padding: 14px 14px 0;
    border: 1px solid rgba(49, 36, 31, 0.04);
    border-radius: 24px;
    background: var(--pink);
    box-shadow: 0 10px 28px rgba(49, 36, 31, 0.08);
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.project-card:nth-child(4n + 2) { background: var(--blue); }
.project-card:nth-child(4n + 3) { background: var(--cream); }
.project-card:nth-child(4n + 4) { background: var(--lavender); }

.project-card:hover,
.project-card:focus-visible {
    transform: translateY(-5px);
    box-shadow: 0 18px 38px rgba(49, 36, 31, 0.13);
    outline: none;
}

.project-card > img {
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    border-radius: 16px 16px 10px 10px;
}

.project-copy {
    position: relative;
    z-index: 1;
    min-height: 190px;
    margin: -24px -14px 0;
    padding: 22px 22px 20px;
    border-radius: 24px 24px 0 0;
    background: #fff;
}

.project-number {
    position: absolute;
    top: 17px;
    right: 18px;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    font-family: 'Outfit', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 50%;
    background: #f7f4f1;
    opacity: 0.75;
}

.project-copy h3 {
    max-width: calc(100% - 38px);
    margin: 0 0 7px;
    font-size: 1.35rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.project-copy p {
    display: -webkit-box;
    min-height: 3em;
    margin: 0;
    overflow: hidden;
    color: rgba(49, 36, 31, 0.72);
    font-size: 0.94rem;
    line-height: 1.5;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.project-link-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: max-content;
    margin-top: 18px;
    padding: 7px 13px;
    color: var(--ink);
    border: 0;
    border-radius: 99px;
    background: #e7f1fb;
    font-size: 0.78rem;
    font-weight: 700;
}

.project-link-label b {
    margin-left: 10px;
    font-size: 0.95rem;
}

.empty-projects {
    padding: 60px 24px;
    color: var(--muted);
    text-align: center;
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.62);
}

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

@media (max-width: 620px) {
    .site-shell {
        width: min(100% - 24px, 1180px);
        padding: 22px 0 56px;
    }

    .hero-image,
    .hero-placeholder {
        width: min(150px, 100%);
    }

    .hero-section { gap: 12px; }

    .quick-links {
        width: calc(100% - 162px);
    }

    .quick-links h2 { font-size: 0.9rem; }
    .quick-links a { font-size: 0.7rem; }

    .runner-game-section {
        margin-top: 2px;
    }

    .runner-game-hud {
        top: 10px;
        right: 10px;
        gap: 10px;
        font-size: 0.62rem;
    }

    #runner-game {
        height: auto;
    }

    .runner-game-overlay span {
        max-width: 260px;
        font-size: 0.8rem;
    }

    .runner-game-overlay {
        padding: 24px 8px 8px;
    }

    .runner-leaderboard {
        margin-top: 7px;
    }

    .runner-leaderboard li {
        min-height: 21px;
        font-size: 0.7rem;
    }

    .headline-section {
        min-height: 0;
        padding: 38px 12px 14px;
    }

    .project-grid {
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .project-card {
        border-radius: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
