@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: 18px;
    width: min(520px, 100%);
    min-height: 178px;
    margin-left: auto;
    padding: 14px;
    overflow: hidden;
    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);
}

.quick-links {
    flex: 1 1 auto;
    min-width: 0;
    font-family: 'IBM Plex Sans Thai', sans-serif;
    text-align: left;
}

.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;
    list-style: none;
}

.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 {
    flex: 0 0 150px;
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    height: 150px;
    object-fit: cover;
    overflow: hidden;
    border: 1px solid rgba(49, 36, 31, 0.12);
    border-radius: 16px 16px 10px 10px;
    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: 12px;
    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 {
        flex-basis: 150px;
        width: 150px;
        min-width: 150px;
        max-width: 150px;
        height: 150px;
    }

    .hero-section { gap: 12px; }

    .quick-links {
        flex: 1 1 auto;
    }

    .quick-links h2 { font-size: 0.9rem; }
    .quick-links a { font-size: 0.7rem; }

    .runner-game-section {
        margin-top: 12px;
    }

    .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;
    }
}

.duelblade-shell { width: 100%; height: 100vh; height: 100svh; display: flex; flex-direction: column; background: #d8efff; overscroll-behavior: none; }
.duelblade-stage { position: relative; width: 100%; min-height: 0; flex: 1 1 auto; background: #d8efff; }
.duelblade-stage iframe { display: block; width: 100%; height: 100%; border: 0; }
.game-stage-actions { flex: 0 0 auto; min-height: 52px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 7px max(12px,env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); background: #fffaf5; border-top: 1px solid #d9c5e4; box-shadow: 0 -4px 16px rgba(73,52,88,.12); position: relative; z-index: 9; }
.game-scroll-link,.game-fullscreen-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 7px 14px; border: 1px solid #d9c5e4; border-radius: 16px; background: #fffaf0; color: #574466; font-family: inherit; font-size: 12px; font-weight: 600; text-decoration: none; box-shadow: none; }
.game-fullscreen-button { cursor: pointer; }
.duelblade-shell:fullscreen,.duelblade-shell.pseudo-fullscreen { width: 100vw; height: 100dvh; background: #d8efff; }
.duelblade-shell.pseudo-fullscreen { position: fixed; inset: 0; z-index: 9999; }
body.duelblade-playing,body.game-pseudo-fullscreen { overflow: hidden; height: 100dvh; overscroll-behavior: none; }
.site-shell { padding-top: 28px; }
.runner-game-section[hidden] { display: none !important; }
.homepage-columns { display: grid; grid-template-columns: minmax(0, 2fr) minmax(270px, calc((100% - 46px) / 3)); gap: 28px; align-items: start; }
.projects-column, .links-column { min-width: 0; }
.links-column { padding-top: 115px; }
.links-column .hero-section { display: flex; width: 100%; min-height: 0; margin: 0; padding: 14px 14px 0; flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: flex-start; gap: 0; }
.links-column .hero-image,
.links-column .hero-placeholder { order: -1; flex: 0 0 auto; width: 100%; min-width: 0; max-width: none; height: auto; aspect-ratio: 3 / 2; border-radius: 16px 16px 10px 10px; object-fit: contain; background: #fff; }
.links-column .quick-links { position: relative; z-index: 1; width: auto; min-height: 190px; margin: -24px -14px 0; padding: 22px; flex: none; border-radius: 24px 24px 0 0; background: #fff; }
.links-column .quick-links h2 { font-size: 1.35rem; }
.links-column .quick-links a { font-size: .84rem; }
.links-column .quick-links a span { white-space: normal; overflow-wrap: anywhere; }
.projects-column .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.projects-column .headline-section { padding: 18px 0; min-height: 0; }
.projects-column .project-card > img { height: auto; }
@media (max-width: 760px) {
    .homepage-columns { grid-template-columns: minmax(0, 1fr); gap: 24px; }
    .links-column { width: calc((100% - 12px) / 2); padding-top: 0; }
    .projects-column .project-grid { gap: 12px; }
    .project-card { padding: 10px 10px 0; }
    .project-card > img { height: auto; }
    .project-copy { margin: -16px -10px 0; padding: 16px 12px; }
    .project-copy h3 { font-size: 18px; overflow-wrap: anywhere; }
    .project-number { right: 10px; }
    .runner-game-overlay { padding-top: 36px; }
    .game-stage-actions { min-height: 48px; gap: 7px; padding-top: 5px; }
    .game-scroll-link,.game-fullscreen-button { min-height: 36px; padding: 6px 10px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
/* The game fills the shell; these controls overlay only their own small targets. */
.duelblade-shell{position:relative}
.game-stage-actions{position:absolute;inset:0;min-height:0;padding:0;border:0;box-shadow:none;background:transparent;pointer-events:none;display:block}
.game-fullscreen-button{position:absolute;top:18px;right:12px;width:32px;min-height:32px;padding:0;border:1px solid #755b8b55;border-radius:7px;background:transparent;font-size:22px;font-weight:400;pointer-events:auto}
.game-scroll-link{display:none;position:absolute;right:12px;bottom:12px;min-height:28px;padding:4px 8px;font-size:10px;font-weight:400;background:#fffaf522;border:1px solid #755b8b55;border-radius:8px;pointer-events:auto}
.duelblade-home .game-scroll-link{display:inline-flex}
@media(max-width:650px){
 .game-fullscreen-button{top:14px;right:8px;width:28px;min-height:30px;padding:0;font-size:21px}
 .game-scroll-link{bottom:122px;right:12px;min-height:24px;font-size:10px;padding:3px 6px}
}
