@font-face {
    font-family: 'EduKai';
    src: url('../../../fonts/edukai-site-subset.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Newsreader';
    src: url('../../../fonts/newsreader-latin.woff2') format('woff2');
    font-weight: 400 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Newsreader';
    src: url('../../../fonts/newsreader-italic-latin.woff2') format('woff2');
    font-weight: 400 600;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Sans';
    src: url('../../../fonts/ibm-plex-sans-latin.woff2') format('woff2');
    font-weight: 100 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('../../../fonts/ibm-plex-mono-latin.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --space: #070914;
    --space-soft: #0b0e1d;
    --starlight: #fff8e7;
    --starlight-cool: #dce8ff;
    --paper: #f7f4ec;
    --paper-soft: rgba(247,244,236,0.965);
    --ink: #202225;
    --ink-soft: #67696d;
    --ink-faint: #96989c;
    --rule: rgba(38,40,44,0.13);
    --ui: 'IBM Plex Sans', 'Aptos', 'Segoe UI', 'PingFang SC', 'PingFang TC', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', sans-serif;
    --editorial: 'Newsreader', 'Iowan Old Style', 'Baskerville', 'Georgia', serif;
    --kai: 'EduKai', 'DFKai-SB', 'KaiTi', serif;
    --mono: 'IBM Plex Mono', 'SFMono-Regular', 'Cascadia Mono', 'Consolas', monospace;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--space);
}

body {
    color: #f6f2e9;
    font-family: var(--editorial);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

body.lang-zh-CN,
body.lang-zh-TW {
    font-family: var(--kai);
}

button,
input,
textarea,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
    outline: 1px solid rgba(255,248,231,0.9);
    outline-offset: 5px;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.galaxy-world {
    position: fixed;
    inset: 0;
    isolation: isolate;
    overflow: hidden;
    background:
        radial-gradient(circle at 62% 44%, rgba(92,108,160,0.19), transparent 38%),
        radial-gradient(circle at 26% 62%, rgba(143,103,81,0.12), transparent 34%),
        var(--space);
    touch-action: none;
    user-select: none;
}

#spaceCanvas,
#constellationCanvas,
#celestialCloseupCanvas,
#celestialCloseupFallbackCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#spaceCanvas {
    z-index: 0;
}

#constellationCanvas {
    z-index: 2;
    pointer-events: none;
}

#celestialCloseupCanvas,
#celestialCloseupFallbackCanvas {
    z-index: 4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 260ms ease;
}

#celestialCloseupFallbackCanvas {
    z-index: 5;
}

body.celestial-transition #celestialCloseupCanvas,
body.celestial-transition #celestialCloseupFallbackCanvas,
body.celestial-closeup #celestialCloseupCanvas,
body.celestial-closeup #celestialCloseupFallbackCanvas,
body.celestial-returning #celestialCloseupCanvas,
body.celestial-returning #celestialCloseupFallbackCanvas {
    opacity: 1;
}

.space-vignette,
.space-grain {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.space-vignette {
    background:
        radial-gradient(ellipse at center, transparent 52%, rgba(1,2,7,0.06) 76%, rgba(1,2,7,0.27) 100%),
        linear-gradient(180deg, rgba(2,3,8,0.08), transparent 20%, transparent 80%, rgba(2,3,8,0.11));
}

.space-grain {
    opacity: 0.025;
    background-image:
        repeating-radial-gradient(circle at 17% 31%, rgba(255,255,255,0.8) 0 0.4px, transparent 0.7px 3px);
    background-size: 5px 5px;
    mix-blend-mode: soft-light;
}

.life-mark {
    position: fixed;
    top: max(24px, env(safe-area-inset-top));
    left: max(28px, env(safe-area-inset-left));
    z-index: 12;
    display: grid;
    gap: 2px;
    pointer-events: none;
    text-shadow: 0 1px 18px rgba(0,0,0,0.65);
}

.life-mark strong {
    font-family: var(--editorial);
    font-size: 1.05rem;
    font-weight: 500;
    letter-spacing: 0.08em;
}

.life-mark span {
    color: rgba(239,242,250,0.6);
    font-family: var(--mono);
    font-size: 0.58rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.language-switch {
    position: fixed;
    top: max(22px, env(safe-area-inset-top));
    right: max(26px, env(safe-area-inset-right));
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px;
    border: 1px solid rgba(231,237,255,0.12);
    border-radius: 999px;
    background: rgba(7,9,17,0.32);
    backdrop-filter: blur(12px);
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 180ms ease, background 180ms ease;
}

body.cursor-free .language-switch,
body:not(.has-entered) .language-switch,
.language-switch:focus-within {
    opacity: 1;
    pointer-events: auto;
}

.lang-btn {
    min-width: 31px;
    height: 27px;
    padding: 0 8px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: rgba(239,242,250,0.58);
    font-family: var(--ui);
    font-size: 0.68rem;
    cursor: pointer;
    transition: color 160ms ease, background 160ms ease;
}

.lang-btn:hover,
.lang-btn.active {
    color: #fffaf0;
    background: rgba(255,255,255,0.1);
}

.control-legend {
    position: fixed;
    left: max(28px, env(safe-area-inset-left));
    bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 12;
    display: grid;
    gap: 5px;
    color: rgba(235,239,250,0.62);
    font-family: var(--ui);
    font-size: 0.67rem;
    letter-spacing: 0.02em;
    pointer-events: none;
    transition: opacity 500ms ease;
}

body.panel-open .control-legend,
body.celestial-open .control-legend {
    opacity: 0.2;
}

.control-legend span::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 1px;
    margin: 0 8px 3px 0;
    background: rgba(255,248,231,0.32);
}

.scene-status {
    position: fixed;
    right: max(28px, env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 12;
    color: rgba(235,239,250,0.56);
    font-family: var(--mono);
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    pointer-events: none;
}

.entry-gate {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at center, rgba(20,25,45,0.025), rgba(2,3,8,0.1));
    transition: opacity 420ms ease, visibility 420ms ease;
}

.entry-gate.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.entry-trigger {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 7px;
    min-width: 260px;
    padding: 48px;
    border: 0;
    background: transparent;
    color: #fff8e7;
    cursor: pointer;
    text-align: center;
    text-shadow: 0 0 24px rgba(218,230,255,0.28);
}

.entry-trigger::before,
.entry-trigger::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 20px;
    border-radius: 50%;
    transform: translateX(-50%);
}

.entry-trigger::before {
    width: 5px;
    height: 5px;
    background: #fff8e7;
    box-shadow: 0 0 8px #fff, 0 0 24px rgba(205,220,255,0.85), 0 0 54px rgba(205,220,255,0.38);
    animation: entry-star 2.4s ease-in-out infinite;
}

.entry-trigger::after {
    width: 44px;
    height: 44px;
    margin-top: -20px;
    border: 1px solid rgba(229,237,255,0.16);
    animation: entry-ring 2.4s ease-out infinite;
}

.entry-title {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 400;
    letter-spacing: 0.035em;
}

.entry-hint {
    color: rgba(235,239,250,0.48);
    font-family: var(--ui);
    font-size: 0.68rem;
    letter-spacing: 0.04em;
}

.entry-location {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    max-width: min(80vw, 380px);
    margin-top: 7px;
    padding: 6px 10px 5px;
    border: 1px solid rgba(188,211,242,0.13);
    border-radius: 999px;
    background: rgba(8,13,25,0.22);
    color: rgba(210,224,246,0.58);
    font-family: var(--mono);
    font-size: 0.56rem;
    line-height: 1.45;
    letter-spacing: 0.055em;
    text-shadow: none;
}

.entry-location::before {
    content: '';
    flex: 0 0 auto;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(174,211,247,0.88);
    box-shadow: 0 0 9px rgba(137,190,241,0.7);
}

.entry-fallback {
    position: absolute;
    left: 50%;
    top: calc(50% + 92px);
    translate: -50% 0;
    padding: 7px 0;
    border: 0;
    border-bottom: 1px solid rgba(232,239,255,0.22);
    background: transparent;
    color: rgba(235,239,250,0.58);
    font-family: var(--ui);
    font-size: 0.64rem;
    letter-spacing: 0.04em;
    cursor: pointer;
}

.entry-fallback:hover,
.entry-fallback:focus-visible {
    color: rgba(255,250,236,0.94);
    border-bottom-color: rgba(255,250,236,0.7);
    outline: none;
}

@keyframes entry-star {
    0%, 100% { opacity: 0.58; transform: translateX(-50%) scale(0.8); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.22); }
}

@keyframes entry-ring {
    0% { opacity: 0; transform: translateX(-50%) scale(0.35); }
    32% { opacity: 0.72; }
    100% { opacity: 0; transform: translateX(-50%) scale(1.45); }
}

.reticle {
    position: fixed;
    left: 50%;
    top: 50%;
    z-index: 10;
    width: 42px;
    height: 42px;
    transform: translate(-50%, -50%);
    opacity: 0.18;
    pointer-events: none;
    transition: opacity 240ms ease, transform 240ms ease;
}

.reticle::before,
.reticle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    background: rgba(255,248,231,0.7);
    transform: translate(-50%, -50%);
}

.reticle::before {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(221,232,255,0.8);
}

.reticle::after {
    width: 1px;
    height: 1px;
}

.reticle span {
    position: absolute;
    background: rgba(231,238,255,0.52);
    transition: transform 240ms ease, opacity 240ms ease;
}

.reticle .r-top,
.reticle .r-bottom {
    left: 20px;
    width: 1px;
    height: 7px;
}

.reticle .r-left,
.reticle .r-right {
    top: 20px;
    width: 7px;
    height: 1px;
}

.reticle .r-top { top: 2px; }
.reticle .r-bottom { bottom: 2px; }
.reticle .r-left { left: 2px; }
.reticle .r-right { right: 2px; }

body.has-target .reticle {
    opacity: 0.82;
    transform: translate(-50%, -50%) scale(1.08);
}

body.has-target .reticle .r-top { transform: translateY(4px); }
body.has-target .reticle .r-bottom { transform: translateY(-4px); }
body.has-target .reticle .r-left { transform: translateX(4px); }
body.has-target .reticle .r-right { transform: translateX(-4px); }

.gaze-label {
    position: fixed;
    left: 50%;
    top: calc(50% + 34px);
    z-index: 11;
    display: grid;
    justify-items: center;
    width: min(460px, calc(100vw - 40px));
    min-width: 230px;
    transform: translate(-50%, 9px);
    opacity: 0;
    pointer-events: none;
    text-align: center;
    text-shadow: 0 2px 22px rgba(0,0,0,0.75);
    transition:
        opacity 560ms cubic-bezier(0.22, 0.74, 0.26, 1),
        transform 620ms cubic-bezier(0.22, 0.74, 0.26, 1);
}

body.has-target .gaze-label {
    opacity: 1;
    transform: translate(-50%, 0);
}

body.panel-open .gaze-label,
body.celestial-open .gaze-label {
    opacity: 0;
}

.gaze-primary {
    color: #fffaf0;
    font-size: clamp(1rem, 2.2vw, 1.35rem);
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.gaze-secondary {
    margin-top: 2px;
    color: rgba(232,237,248,0.56);
    font-family: var(--ui);
    font-size: 0.63rem;
    letter-spacing: 0.12em;
}

.gaze-constellation {
    margin-top: 10px;
    color: rgba(244,240,229,0.84);
    font-family: var(--editorial);
    font-size: 0.76rem;
    letter-spacing: 0.06em;
}

body.lang-zh-CN .gaze-constellation,
body.lang-zh-TW .gaze-constellation {
    font-family: var(--kai);
    letter-spacing: 0.035em;
}

.gaze-description {
    max-width: 440px;
    margin: 6px 0 0;
    color: rgba(232,237,248,0.62);
    font-size: clamp(0.68rem, 1.25vw, 0.76rem);
    line-height: 1.58;
}

.gaze-instruction {
    position: fixed;
    left: 50%;
    top: calc(50% + 72px);
    z-index: 10;
    color: rgba(232,237,248,0.28);
    font-family: var(--ui);
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    transform: translateX(-50%);
    pointer-events: none;
    transition: opacity 400ms ease;
}

body.has-target .gaze-instruction,
body.panel-open .gaze-instruction,
body.celestial-open .gaze-instruction {
    opacity: 0;
}

body.celestial-transition .reticle,
body.celestial-transition .gaze-label,
body.celestial-transition .gaze-instruction,
body.celestial-closeup .reticle,
body.celestial-closeup .gaze-label,
body.celestial-closeup .gaze-instruction,
body.celestial-returning .reticle,
body.celestial-returning .gaze-label,
body.celestial-returning .gaze-instruction {
    opacity: 0;
    pointer-events: none;
}
