@font-face {
    font-family: PortalSystem;
    src: local("Noto Sans Thai"), local("Thonburi"), local("Tahoma");
    font-display: swap;
}
:root {
    color-scheme: dark;
    --ink: #eff2ed;
    --muted: #a3adaf;
    --line: #cbdedb30;
    --accent: #dbff80;
    --gutter: clamp(18px, 3vw, 54px);
    --safe-top: max(20px, env(safe-area-inset-top));
    --safe-bottom: max(16px, env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { margin: 0; background: #050709; color: var(--ink); font-family: PortalSystem, system-ui, sans-serif; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, select:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 5px; box-shadow: 0 0 0 8px #050709c4;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.skip { position: fixed; left: var(--gutter); top: -100px; z-index: 30; padding: 12px 18px; background: var(--accent); color: #13190c; }
.skip:focus { top: var(--safe-top); }
/* ผืนจักรวาลเต็มจอ ให้เงาดำและแสงของฉากเป็นองค์ประกอบหลัก */
.universe {
    position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh;
    overflow: hidden; isolation: isolate; background: radial-gradient(ellipse at 62% 42%, #12303244, transparent 60%), #050709;
}
#city { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#city:active { cursor: grabbing; }
#city.has-target { cursor: pointer; }
#city:focus-visible { outline: 1px solid #dbff8060; outline-offset: -8px; box-shadow: inset 0 0 0 8px #05070955; }
.atmosphere {
    position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(180deg, #03060765, transparent 20%, transparent 68%, #030607c9), radial-gradient(ellipse at center, transparent 48%, #01040535);
}
.grain {
    position: absolute; inset: 0; opacity: .022; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 150 150' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23fff' filter='url(%23n)' d='M0 0h150v150H0z'/%3E%3C/svg%3E");
}
.orbit-rail { position: absolute; left: max(var(--gutter), env(safe-area-inset-left)); top: 48%; display: flex; flex-direction: column; align-items: center; gap: 16px; color: #b5c7c787; pointer-events: none; }
.orbit-rail span { font: 10px/1.2 ui-monospace, monospace; letter-spacing: 1px; writing-mode: vertical-rl; transform: rotate(180deg); }
.orbit-rail i { display: block; width: 7px; height: 100px; border-right: 1px solid #c8ded533; background: repeating-linear-gradient(180deg, #c8ded560 0 1px, transparent 1px 14px); }
/* เครื่องมือเป็นกรอบเส้นบาง โดยยังลากฉากผ่านพื้นที่ว่างได้ */
.masthead {
    position: absolute; top: var(--safe-top); left: max(var(--gutter), env(safe-area-inset-left)); right: max(var(--gutter), env(safe-area-inset-right));
    z-index: 6; display: flex; align-items: center; gap: 10px; min-height: 44px; padding-bottom: 16px;
    border-bottom: 1px solid #d9eee324; pointer-events: none;
}
.masthead a, .masthead button, .masthead form { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 11px; font: 800 25px/1 system-ui, sans-serif; letter-spacing: -1.4px; text-shadow: 0 2px 18px #000; }
.brand-symbol { display: grid; place-items: center; width: 38px; height: 38px; color: var(--accent); font-size: 40px; line-height: 1; }
.brand-name { display: inline-flex; align-items: baseline; gap: 5px; }
.brand-dot { color: #b9c1bf; font: 500 9px/1 ui-monospace, monospace; letter-spacing: 1px; }
.view-controls { display: flex; align-items: center; gap: 5px; margin-left: auto; }
.hud-button, .language-form { min-height: 40px; border: 1px solid var(--line); background: #070c10b0; backdrop-filter: blur(18px); }
.hud-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 9px 13px; font-size: 10px; transition: border-color .2s, color .2s, background .2s; }
.hud-button > span[aria-hidden] { color: #d9e4e0; font-size: 19px; line-height: 1; }
.hud-button:hover { color: var(--accent); border-color: #dbff8090; background: #142019c9; }
.hud-button[aria-pressed="true"] { border-color: var(--accent); }
.language-form { display: flex; align-items: center; gap: 1px; padding-left: 6px; }
.language-form select { background: transparent; color: var(--ink); border: 0; padding: 8px 4px; max-width: 86px; font-size: 10px; }
.language-form option { background: #10191c; }
.language-form button { border: 0; background: none; color: var(--accent); width: 31px; min-height: 38px; }
.language-form button:hover { background: #dbff8022; }
main { position: absolute; inset: 0; pointer-events: none; }
main a, main button { pointer-events: auto; }
/* ตัวอักษรหลักขนาดใหญ่ โดยเปิดพื้นที่ด้านขวาให้ประติมากรรมมิติ */
.intro, .dimension-panel {
    position: absolute; left: max(var(--gutter), env(safe-area-inset-left)); top: calc(var(--safe-top) + 94px); z-index: 4;
    width: min(350px, calc(100% - 2 * var(--gutter))); max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 278px);
    overflow: auto; padding: 4px 24px 24px 0; scrollbar-width: thin; pointer-events: auto;
    background: linear-gradient(90deg, #04090bb8, #04090b4d 78%, transparent); text-shadow: 0 2px 24px #000;
}
.eyebrow { display: flex; align-items: center; gap: 9px; color: var(--accent); font: 500 9px/1.5 ui-monospace, monospace; letter-spacing: 2.4px; margin: 0; }
.status-dot { display: inline-block; flex: 0 0 4px; width: 4px; height: 4px; background: var(--accent); box-shadow: 0 0 10px #dbff8077; }
h1 { font-size: clamp(30px, 2.7vw, 46px); line-height: 1.28; letter-spacing: -1.4px; font-weight: 450; margin: 23px 0 17px; text-wrap: balance; }
.intro-copy { max-width: 280px; color: #bdc9c8; font-size: 12px; line-height: 1.9; margin: 0; }
.explore {
    display: inline-flex; align-items: center; justify-content: space-between; gap: 36px; min-height: 44px; margin-top: 23px; padding: 11px 17px;
    border: 1px solid var(--accent); background: var(--accent); color: #14200c; font-size: 11px; font-weight: 650;
    text-shadow: none; transition: background .2s, transform .2s; box-shadow: 5px 5px 0 #dbff801a;
}
.explore:hover { background: #edffba; transform: translateY(-2px); }
.explore span { font: 23px/1 system-ui, sans-serif; }
.is-exploring .intro { display: none; }
.city-caption {
    position: absolute; top: calc(var(--safe-top) + 76px); right: max(var(--gutter), env(safe-area-inset-right));
    display: flex; align-items: center; gap: 8px; font-size: 9px; letter-spacing: .2px; color: #c3d0cd; text-shadow: 0 1px 8px #000;
}
.dimension-panel h2 { margin: 22px 0 17px; font-size: clamp(29px, 2.7vw, 42px); line-height: 1.3; font-weight: 450; letter-spacing: -.8px; text-wrap: balance; }
.dimension-panel > p:not(.eyebrow) { margin: 0; color: #bdc9c8; font-size: 12px; line-height: 1.9; }
.dimension-panel .explore { justify-content: flex-start; gap: 14px; }
/* แผงสถานที่วาร์ป: ชื่อจริงของฉากและสถานะผลงานอยู่ริมจอ ไม่ทับเวทีตรงกลาง */
.universe[data-world="cinema"] { --accent: #8dfff1; }
.universe[data-world="music"] { --accent: #dbff80; }
.universe[data-world="stories"] { --accent: #c4a3ff; }
.universe[data-world="characters"] { --accent: #ffac8d; }
.universe[data-world]:not([data-world=""]) .orbit-rail { display: none; }
.dimension-panel {
    top: calc(var(--safe-top) + 83px); width: min(300px, calc(100% - 2 * var(--gutter)));
    max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 250px); padding: 17px 19px 19px;
    border: 1px solid #d4e9df26; border-left: 2px solid var(--accent);
    background: linear-gradient(120deg, #060c12e6, #071019ba); backdrop-filter: blur(12px);
}
.dimension-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 12px; }
.dimension-heading .eyebrow { flex-shrink: 0; font-size: 9px; letter-spacing: 1px; }
.dimension-category { margin: 0; color: #bfcdca; font-size: 10px; line-height: 1.6; }
.dimension-panel h2 { font-size: clamp(23px, 2vw, 29px); line-height: 1.35; margin: 13px 0 11px; letter-spacing: -.5px; }
.dimension-panel .dimension-description { font-size: 11px; line-height: 1.8; }
.dimension-panel .dimension-status { margin-top: 13px; padding-top: 11px; border-top: 1px solid #c4ded32b; color: #a5b5b2; font-size: 9px; line-height: 1.75; }
.dimension-panel .explore { min-height: 38px; margin-top: 15px; padding: 9px 12px; font-size: 10px; box-shadow: none; }
.dimension-panel .explore span { font-size: 19px; }
/* แถบเส้นทางสี่มิติ เส้นและเลขนำสายตาแทนการ์ดทรงแคปซูล */
.dimensions {
    position: absolute; z-index: 5; left: max(var(--gutter), env(safe-area-inset-left)); right: max(var(--gutter), env(safe-area-inset-right));
    bottom: calc(var(--safe-bottom) + 48px); max-width: 1120px; margin: 0 auto; pointer-events: none;
}
.dimensions-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 13px; text-shadow: 0 1px 9px #000; }
.dimensions-heading h2 { display: flex; align-items: center; gap: 10px; margin: 0; color: #d6e1dc; font-size: 10px; font-weight: 500; letter-spacing: 1px; flex-shrink: 0; }
.dimensions-heading h2::before { content: ""; width: 14px; height: 5px; border-top: 1px solid var(--accent); border-bottom: 1px solid var(--accent); }
.dimensions-heading p { margin: 0; color: #b8c5c3; font-size: 9px; text-align: right; line-height: 1.6; }
.portal-list { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; border-top: 1px solid #d5eadd66; border-bottom: 1px solid #d5eadd30; }
.portal-card {
    --portal: #8dfff1; position: relative; display: grid; grid-template-columns: auto auto minmax(0,1fr) auto; align-items: center; gap: 13px;
    min-height: 74px; padding: 15px 19px; border-right: 1px solid #cbdedb26; background: linear-gradient(110deg, #0c1517a8, #080d10ad);
    backdrop-filter: blur(12px); transition: color .2s, background .2s;
}
.portal-card:last-child { border-right: 0; }
.portal-card::before { content: ""; position: absolute; left: 0; right: 100%; bottom: -1px; height: 2px; background: var(--portal); box-shadow: 0 0 16px var(--portal); transition: right .25s; }
.portal-card:hover, .portal-card.is-targeted, .portal-card[aria-current] { background: linear-gradient(110deg, #243431e3, #0d171bd9); }
.portal-card:hover::before, .portal-card.is-targeted::before, .portal-card[aria-current]::before { right: 0; }
.portal-card:hover .portal-number, .portal-card.is-targeted .portal-number, .portal-card[aria-current] .portal-number { color: var(--portal); }
.portal-card:hover .portal-arrow { transform: translate(2px,-2px); }
.music { --portal: #dbff80; }
.stories { --portal: #c4a3ff; }
.characters { --portal: #ffac8d; }
.portal-number { color: #a4b8b66b; font: 300 30px/1 ui-monospace, monospace; letter-spacing: -2px; transition: color .2s; }
.portal-icon { color: var(--portal); font-size: 17px; line-height: 1; }
.portal-name { color: #e8eeeb; font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
.portal-arrow { color: var(--portal); font: 19px/1 system-ui, sans-serif; transition: transform .2s; }
footer {
    position: absolute; z-index: 5; bottom: var(--safe-bottom); left: max(var(--gutter), env(safe-area-inset-left)); right: max(var(--gutter), env(safe-area-inset-right));
    display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 30px; color: #9caeaa; font-size: 9px; pointer-events: none;
}
footer p { margin: 0 auto 0 0; text-shadow: 0 1px 8px #000; }
footer button { min-height: 34px; padding: 7px 11px; border: 1px solid #b4cbc22e; background: #060c0eb0; backdrop-filter: blur(12px); color: #d2dcd6; font-size: 9px; pointer-events: auto; }
footer button:hover { border-color: var(--accent); }
.footer-mark { color: var(--accent); font-size: 22px; }
/* ป้ายประตูมีเส้นชี้ลงไปยังวัตถุ สีสัมพันธ์กับเส้นทางด้านล่าง */
.scene-portal {
    --portal: #8dfff1; position: absolute; z-index: 2; transform: translate(-50%,-50%); min-height: 30px; padding: 8px 12px;
    border: 1px solid #b6d6cc5c; border-left: 2px solid var(--portal); background: #071116cf; color: #eff6f2;
    backdrop-filter: blur(12px); box-shadow: 0 3px 20px #0008; font-size: 9px; letter-spacing: .2px; line-height: 1.4; white-space: nowrap;
    transition: border-color .2s, background .2s;
}
.scene-portal::after { content: ""; position: absolute; left: 50%; top: 100%; height: 14px; width: 1px; background: linear-gradient(var(--portal), transparent); pointer-events: none; }
.scene-portal[href="#world/music"] { --portal: #dbff80; }
.scene-portal[href="#world/stories"] { --portal: #c4a3ff; }
.scene-portal[href="#world/characters"] { --portal: #ffac8d; }
.scene-portal:hover, .scene-portal.is-targeted { background: #182927e8; border-color: var(--portal); box-shadow: 0 0 24px #8dfff121; }
.warp { position: absolute; inset: 0; z-index: 20; opacity: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 50%, #f5ffe9 0, #d7ffada6 4%, #65fff46b 17%, transparent 58%); }
.warp.active { animation: warp 950ms ease-in-out; }
@keyframes warp { 0%,100% { opacity: 0; transform: scale(.7); } 45% { opacity: 1; transform: scale(2); } }
.still #city { cursor: grab; }
.fallback-sky { position: absolute; left: 30%; top: 23%; width: 43%; height: 48%; border-radius: 48% 52% 20% 80%; border: 2px solid #a7fff599; box-shadow: 0 0 70px #59fff84d, inset 0 0 90px #47c7bf25; transform: rotate(-32deg); }
.fallback-sky::before, .fallback-sky::after { content: ""; position: absolute; inset: 16% -5%; border: 1px solid #d2ff889c; border-radius: 20% 80% 60% 40%; box-shadow: 0 0 35px #dbff8033; transform: rotate(55deg); }
.fallback-sky::after { inset: -10% 24%; transform: rotate(105deg); border-color: #bc9eff77; }
.noscript-message { position: absolute; top: calc(var(--safe-top) + 90px); right: var(--gutter); max-width: 260px; z-index: 7; padding: 14px; border-left: 2px solid var(--accent); background: #081013eb; color: var(--accent); font-size: 12px; }
@media (min-width: 1500px) {
    .intro { top: calc(var(--safe-top) + 120px); width: 390px; }
    h1 { font-size: 47px; }
    .portal-card { min-height: 82px; }
}
@media (max-width: 1000px) {
    .portal-card { gap: 10px; padding: 15px 13px; }
    .portal-number { font-size: 25px; }
    .portal-icon { display: none; }
    .portal-card { grid-template-columns: auto minmax(0,1fr) auto; }
}
@media (max-width: 760px) {
    .control-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
    .hud-button { width: 42px; min-height: 42px; padding: 9px; }
    .intro { width: 285px; padding-right: 18px; top: calc(var(--safe-top) + 89px); }
    .dimension-panel { width: 270px; top: calc(var(--safe-top) + 78px); padding: 15px 16px; }
    h1 { font-size: 33px; }
    .orbit-rail { display: none; }
    .portal-number { font-size: 22px; }
    .portal-name { font-size: 10px; }
    .portal-card { gap: 9px; padding: 13px 10px; }
    .portal-arrow { display: none; }
    .portal-card { grid-template-columns: auto minmax(0,1fr); }
}
@media (max-width: 520px) {
    :root { --gutter: 16px; --safe-top: max(13px, env(safe-area-inset-top)); --safe-bottom: max(12px, env(safe-area-inset-bottom)); }
    .masthead { gap: 6px; padding-bottom: 12px; }
    .brand { gap: 7px; font-size: 21px; }
    .brand-symbol { width: 28px; height: 32px; font-size: 32px; }
    .brand-dot { font-size: 7px; letter-spacing: .4px; }
    .brand-name { gap: 3px; }
    .view-controls { gap: 4px; }
    .language-form select { max-width: 51px; padding: 8px 1px; font-size: 9px; }
    .language-form button { width: 25px; }
    .language-form { padding-left: 4px; }
    .intro { top: calc(var(--safe-top) + 79px); width: min(267px, calc(100% - 2 * var(--gutter))); max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 274px); padding: 4px 18px 18px 0; }
    .dimension-panel { top: calc(var(--safe-top) + 74px); width: min(253px, calc(100% - 2 * var(--gutter))); max-height: min(228px, calc(100% - var(--safe-top) - var(--safe-bottom) - 274px)); padding: 12px 14px; }
    .eyebrow { font-size: 8px; letter-spacing: 1.8px; }
    h1 { margin: 17px 0 12px; font-size: 30px; line-height: 1.3; letter-spacing: -.9px; }
    .intro-copy { font-size: 11px; line-height: 1.8; }
    .dimension-panel h2 { font-size: 22px; margin: 10px 0 8px; }
    .dimension-panel .dimension-description { font-size: 10px; line-height: 1.7; }
    .dimension-panel .dimension-status { margin-top: 10px; padding-top: 9px; font-size: 9px; line-height: 1.6; }
    .dimension-panel .explore { margin-top: 11px; min-height: 36px; padding: 8px 11px; }
    .dimension-category { font-size: 9px; }
    .explore { margin-top: 16px; padding: 10px 13px; font-size: 10px; }
    .city-caption { top: calc(var(--safe-top) + 68px); font-size: 8px; max-width: 56%; text-align: right; }
    .dimensions { bottom: calc(var(--safe-bottom) + 47px); }
    .dimensions-heading { gap: 15px; margin-bottom: 10px; }
    .dimensions-heading h2 { gap: 6px; font-size: 9px; letter-spacing: 0; }
    .dimensions-heading h2::before { width: 9px; }
    .dimensions-heading p { max-width: 225px; font-size: 8px; }
    .portal-list { gap: 0; }
    .portal-card { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 8px; min-height: 89px; padding: 11px 9px 9px; }
    .portal-number { font-size: 25px; }
    .portal-name { font-size: 9px; line-height: 1.45; }
    footer { gap: 10px; font-size: 8px; }
    footer p { max-width: 62%; line-height: 1.6; }
    footer button { padding: 7px 9px; font-size: 9px; }
    .footer-mark { display: none; }
    .scene-portal { min-height: 29px; padding: 7px 9px; font-size: 8px; }
}
@media (max-width: 350px) {
    :root { --gutter: 13px; }
    .brand-dot { display: none; }
    .brand { font-size: 20px; }
    .brand-symbol { width: 25px; font-size: 29px; }
    .hud-button { width: 38px; }
    .language-form select { max-width: 48px; }
    .language-form button { width: 22px; }
    .portal-card { padding-left: 7px; padding-right: 7px; }
}
@media (max-height: 540px) and (min-width: 521px) {
    :root { --safe-top: max(12px, env(safe-area-inset-top)); --safe-bottom: max(9px, env(safe-area-inset-bottom)); }
    .masthead { padding-bottom: 8px; }
    .intro { top: calc(var(--safe-top) + 65px); width: 290px; padding: 4px 16px 12px 0; max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 207px); }
    .dimension-panel { top: calc(var(--safe-top) + 65px); width: min(250px, 32vw); padding: 11px 13px; max-height: calc(100% - var(--safe-top) - var(--safe-bottom) - 207px); }
    h1 { font-size: 26px; line-height: 1.3; margin: 12px 0; }
    .dimension-panel h2 { font-size: 20px; line-height: 1.3; margin: 10px 0 8px; }
    .intro-copy, .dimension-panel .dimension-description { font-size: 10px; line-height: 1.7; }
    .dimension-panel .dimension-status { margin-top: 10px; padding-top: 9px; font-size: 9px; }
    .dimension-panel .explore { margin-top: 11px; }
    .explore { min-height: 38px; margin-top: 12px; padding: 8px 12px; }
    .dimensions { bottom: calc(var(--safe-bottom) + 37px); }
    .portal-card { min-height: 52px; padding-top: 9px; padding-bottom: 9px; }
    .portal-number { font-size: 23px; }
    .dimensions-heading { margin-bottom: 7px; }
    .city-caption { top: calc(var(--safe-top) + 61px); }
    .orbit-rail { display: none; }
}
/* แนวตั้งให้ชื่อสถานที่อยู่เหนือฉาก จอภาพยนตร์และเวทีกลางภาพยังมองเห็นได้ */
@media (max-width: 700px) and (orientation: portrait) {
    .dimension-panel {
        top: calc(var(--safe-top) + 70px); width: calc(100% - 2 * var(--gutter));
        padding: 9px 12px; max-height: 120px;
    }
    .dimension-panel .dimension-heading, .dimension-panel .dimension-description { display: none; }
    .dimension-panel h2 { margin: 0 35px 5px 0; font-size: 18px; line-height: 1.3; }
    .dimension-panel .dimension-status { margin: 0; padding: 0; border: 0; font-size: 8px; line-height: 1.45; }
    .dimension-panel .explore {
        position: absolute; top: 8px; right: 9px; display: flex; justify-content: center;
        width: 32px; min-height: 30px; margin: 0; padding: 5px; gap: 0; font-size: 0;
    }
    .dimension-panel .explore span { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
.still .warp { animation: none !important; opacity: 0; }
