:root {
  --ink: #020304;
  --paper: #ece8df;
  --mute: #8b877e;
  --line: rgba(236, 232, 223, .14);
  --accent: #ed7322;
  --accent-hi: #f0aa3f;
  --blue: #076baf;
  --sky: #66afd4;
  /* 英數走 Unbounded 寬體幾何字，中文逐字回退到思源黑體 */
  --display: "Unbounded", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Noto Sans TC", system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  --gutter: clamp(16px, 2.6vw, 40px);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
html { background: var(--ink); color: var(--paper); -webkit-font-smoothing: antialiased; }
body { font-family: var(--sans); background: var(--ink); -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
::selection { background: var(--accent); color: var(--ink); }
.mono { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; }
kbd { font: inherit; display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border: 1px solid var(--line); border-radius: 3px; color: var(--paper); }

@media (hover: hover) and (pointer: fine) {
  body.has-cursor, body.has-cursor * { cursor: none !important; }
}

/* ---------- 畫布、顆粒、暗角 ---------- */
#space { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
body::after {
  content: ""; position: fixed; inset: 0; z-index: 5; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0, 0, 0, .55));
}
.grain {
  position: fixed; inset: -100%; z-index: 70; pointer-events: none; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-6%, 4%); } 40% { transform: translate(5%, -7%); }
  60% { transform: translate(-3%, 8%); } 80% { transform: translate(8%, 2%); } 100% { transform: translate(0, 0); }
}
body.no-webgl { background: radial-gradient(70% 60% at 50% 40%, rgba(237, 115, 34, .18), transparent 60%), radial-gradient(60% 60% at 10% 100%, rgba(7, 107, 175, .25), transparent), var(--ink); }
body.no-webgl #space, body.no-webgl .labels { display: none; }

/* ---------- 共用：HUD 進退場 ---------- */
.top, .dock, .labels { transition: opacity .9s var(--ease), transform .9s var(--ease); }
.is-gate .top, .is-gate .dock, .is-gate .labels { opacity: 0; pointer-events: none; }
.is-gate .top { transform: translateY(-16px); }
.is-gate .dock { transform: translate(-50%, 24px); }
.is-landing .top, .is-landing .dock, .is-landing .labels { opacity: 0; pointer-events: none; transition-duration: .4s; }

/* ---------- 頂列 ---------- */
.top { position: fixed; z-index: 30; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 22px; padding: 20px var(--gutter); }
.brand { flex: none; line-height: 0; transition: filter .5s var(--ease); }
.brand img { display: block; height: 38px; width: auto; }
.brand:hover { filter: drop-shadow(0 0 14px rgba(237, 115, 34, .55)); }
.top__title { display: flex; flex-direction: column; gap: 3px; padding-left: 22px; border-left: 1px solid var(--line); margin-right: auto; }
.top__title b { font-weight: 900; font-size: 17px; line-height: 1.2; letter-spacing: .28em; }
.top__title span { color: var(--mute); font-size: 12px; font-weight: 500; letter-spacing: .3em; }
.top__right { display: flex; align-items: center; gap: 22px; }
.top__clock { color: var(--mute); }
.top__clock time { color: var(--paper); font-variant-numeric: tabular-nums; }

.sound { display: inline-flex; align-items: center; gap: 10px; padding: 11px 16px; border: 1px solid var(--line); border-radius: 999px; color: var(--mute); transition: color .3s, border-color .3s, background .3s; }
.sound:hover { color: var(--paper); border-color: rgba(236, 232, 223, .35); }
.sound[aria-pressed="true"] { color: var(--paper); border-color: rgba(237, 115, 34, .5); }
.sound__bars { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.sound__bars i { width: 2px; height: 2px; background: currentColor; }
.sound[aria-pressed="true"] .sound__bars i { background: var(--accent); animation: eq .8s ease-in-out infinite alternate; }
.sound[aria-pressed="true"] .sound__bars i:nth-child(2) { animation-delay: -.3s; }
.sound[aria-pressed="true"] .sound__bars i:nth-child(3) { animation-delay: -.55s; }
.sound[aria-pressed="true"] .sound__bars i:nth-child(4) { animation-delay: -.15s; }
.sound[aria-pressed="true"] .sound__bars i:nth-child(5) { animation-delay: -.42s; }
@keyframes eq { from { height: 2px; } to { height: 12px; } }

/* ---------- 行星標籤 ---------- */
.labels { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.plabel {
  position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 10px; white-space: nowrap;
  pointer-events: auto; will-change: transform; transition: opacity .4s var(--ease);
}
.plabel::before { content: ""; width: 18px; height: 1px; background: var(--c, var(--paper)); opacity: .7; transition: width .5s var(--ease); }
.plabel.is-off { opacity: 0; pointer-events: none; }
.plabel__no { color: var(--mute); font-size: 10px; }
.plabel__code { font-family: var(--display); font-weight: 800; font-size: 15px; letter-spacing: 0; text-shadow: 0 2px 14px rgba(0, 0, 0, .9); }
.plabel__more {
  display: flex; flex-direction: column; gap: 3px; overflow: hidden; max-width: 0; opacity: 0;
  transition: max-width .55s var(--ease), opacity .35s var(--ease);
}
.plabel__more b { font-family: var(--sans); font-weight: 700; font-size: 13px; letter-spacing: .06em; text-shadow: 0 2px 12px rgba(0, 0, 0, .9); }
.plabel__more span { color: var(--c); font-size: 10px; }
.plabel.is-on { z-index: 2; }
.plabel.is-on::before { width: 34px; opacity: 1; }
.plabel.is-on .plabel__no { color: var(--c); }
.plabel.is-on .plabel__more { max-width: 260px; opacity: 1; padding: 6px 10px; border-radius: 6px; background: rgba(2, 3, 4, .72); }
/* 探索中行星：平常不顯示標籤，hover 才浮現，降低畫面密度 */
.plabel--ghost:not(.is-on) { opacity: 0; }
.plabel--ghost .plabel__no { color: rgba(236, 232, 223, .5); }
.plabel--ghost::before { opacity: .35; }
.plabel--ghost .plabel__more span { color: var(--mute); }
/* ---------- 對聯：上聯居右、下聯居左，直排框住星系 ---------- */
.couplet { transition: opacity .9s var(--ease); }
.is-gate .couplet, .is-landing .couplet { opacity: 0; transition-duration: .4s; }
.couplet__line {
  position: fixed; z-index: 15; top: 50%; transform: translateY(-50%); pointer-events: none;
  writing-mode: vertical-rl; font-family: var(--sans); font-weight: 700; font-size: 17px; letter-spacing: .62em;
  color: rgba(236, 232, 223, .62); transition: color .8s var(--ease), text-shadow .8s var(--ease);
}
.couplet__line::before { content: ""; position: absolute; left: 50%; top: -64px; width: 1px; height: 44px; background: linear-gradient(transparent, var(--accent)); }
.couplet__line--first { right: calc(var(--gutter) + 8px); }
.couplet__line--second { left: calc(var(--gutter) + 8px); }
.couplet.is-lit .couplet__line { color: var(--paper); text-shadow: 0 0 22px rgba(237, 115, 34, .75); }

/* ---------- 核心標語卡：hover 核心時逐行揭露 ---------- */
.corecard {
  position: fixed; z-index: 21; left: 0; top: 0; pointer-events: none; display: flex; flex-direction: column; gap: 8px;
  padding: 16px 48px 16px 20px; border-left: 1px solid var(--accent);
  background: linear-gradient(90deg, rgba(2, 3, 4, .8), rgba(2, 3, 4, 0));
  opacity: 0; transition: opacity .45s var(--ease);
}
.corecard.is-on { opacity: 1; }
.is-gate .corecard, .is-landing .corecard { display: none; }
.corecard__line { overflow: hidden; white-space: nowrap; }
.corecard__line span { display: inline-block; transform: translateY(105%); transition: transform .7s var(--ease); }
.corecard.is-on .corecard__line span { transform: none; }
.corecard.is-on .corecard__title span { transition-delay: .08s; }
.corecard.is-on .corecard__sub span { transition-delay: .16s; }
.corecard__kicker { font-weight: 700; font-size: 12px; letter-spacing: .42em; color: var(--accent); }
.corecard__title { font-weight: 900; font-size: 32px; line-height: 1.15; letter-spacing: .14em; text-shadow: 0 4px 24px rgba(0, 0, 0, .9); }
.corecard__sub { font-weight: 500; font-size: 14px; letter-spacing: .3em; color: rgba(236, 232, 223, .8); }

/* ---------- Dock：快速入口 ---------- */
.dock { position: fixed; z-index: 30; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 2 * var(--gutter)); }
.dock__hint { color: var(--mute); font-size: 10px; letter-spacing: .08em; text-transform: none; }
.dock__list {
  display: flex; gap: 6px; padding: 6px; border: 1px solid var(--line); border-radius: 14px;
  background: rgba(4, 5, 7, .62); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.dock__item {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 2px; align-items: center;
  min-width: 168px; padding: 11px 18px 11px 14px; border-radius: 9px; text-align: left; overflow: hidden;
  transition: background .35s var(--ease), transform .35s var(--ease);
}
.dock__item::before { content: ""; position: absolute; inset: 0; background: var(--c); opacity: 0; transition: opacity .35s var(--ease); }
.dock__item > * { position: relative; }
.dock__no { grid-row: 1 / 3; align-self: start; padding-top: 3px; color: var(--c); font-size: 10px; }
.dock__code { font-family: var(--display); font-weight: 800; font-size: 15px; line-height: 1.25; }
.dock__title { font-size: 12px; color: var(--mute); letter-spacing: .04em; transition: color .35s; }
.dock__item:hover, .dock__item.is-on { transform: translateY(-2px); }
.dock__item:hover::before, .dock__item.is-on::before { opacity: .16; }
.dock__item:hover .dock__title, .dock__item.is-on .dock__title { color: var(--paper); }
.dock__item:focus-visible { outline: 1px solid var(--c); outline-offset: -1px; }
.dock__item--ghost { --c: rgba(236, 232, 223, .5); min-width: 0; border: 1px dashed var(--line); cursor: default; }
.dock__item--ghost .dock__code { font-weight: 500; color: var(--mute); }
.dock__item--ghost:hover { transform: none; }
.dock__item--ghost:hover::before { opacity: 0; }

/* ---------- 進場門 ---------- */
.gate {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: var(--gutter); text-align: center;
  background: radial-gradient(60% 55% at 50% 50%, rgba(2, 3, 4, .2), rgba(2, 3, 4, .75));
  transition: opacity 1s var(--ease), transform 1.2s var(--ease), filter 1s var(--ease);
}
.gate.is-out { opacity: 0; transform: scale(1.12); filter: blur(10px); pointer-events: none; }
.gate[hidden] { display: none; }
.gate__kicker { color: rgba(236, 232, 223, .78); font-weight: 700; font-size: 16px; letter-spacing: .55em; padding-left: .55em; }
.gate__logo { width: 200px; height: auto; }
.gate__title { font-family: var(--sans); font-weight: 900; font-size: clamp(42px, 6.4vw, 96px); line-height: 1.12; letter-spacing: -.03em; text-shadow: 0 6px 40px rgba(0, 0, 0, .7); }
.gate__title em { font-style: normal; color: var(--accent); }
.gate__go { position: relative; width: 136px; height: 136px; margin-top: 8px; border-radius: 50%; display: grid; place-items: center; }
.gate__go::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent);
  transform: scale(.82); transition: transform .6s var(--ease);
  animation: beacon 2.4s var(--ease) infinite;
}
.gate__go:hover::before, .gate__go:focus-visible::before { transform: scale(.92); }
.gate__go:focus-visible { outline: none; }
@keyframes beacon {
  0% { box-shadow: 0 0 0 0 rgba(237, 115, 34, .5), 0 0 60px rgba(237, 115, 34, .35); }
  70%, 100% { box-shadow: 0 0 0 26px rgba(237, 115, 34, 0), 0 0 60px rgba(237, 115, 34, .35); }
}
.gate__orbit { position: absolute; inset: 0; border-radius: 50%; border: 1px dashed rgba(236, 232, 223, .3); animation: spin 9s linear infinite; }
.gate__orbit i { position: absolute; top: -4px; left: 50%; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--sky); box-shadow: 0 0 12px var(--sky); }
@keyframes spin { to { transform: rotate(360deg); } }
.gate__go-text { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink); }
.gate__go-text b { font-family: var(--sans); font-weight: 900; font-size: 23px; letter-spacing: .12em; padding-left: .12em; }
.gate__go-text small { font-size: 9px; }
.gate__mute { color: var(--mute); padding: 8px 12px; border-bottom: 1px solid transparent; transition: color .3s, border-color .3s; }
.gate__mute:hover, .gate__mute:focus-visible { color: var(--paper); border-color: var(--line); outline: none; }
.gate__note { color: rgba(236, 232, 223, .35); font-size: 10px; }
.gate > * { opacity: 0; transform: translateY(14px); animation: rise 1s var(--ease) forwards; }
.gate > :nth-child(2) { animation-delay: .1s; }
.gate > :nth-child(3) { animation-delay: .2s; }
.gate > :nth-child(4) { animation-delay: .35s; }
.gate > :nth-child(n+5) { animation-delay: .5s; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------- 電影式登陸 ---------- */
.cine { position: fixed; inset: 0; z-index: 60; pointer-events: none; --hit: 1.95s; --c: var(--accent); --arrival-bg: #f1f3f8; --arrival-ink: #14161c; --arrival-line: rgba(20, 22, 28, .12); }
.cine--dark { --arrival-bg: #111217; --arrival-ink: #ece8df; --arrival-line: rgba(236, 232, 223, .18); }
/* 疊層：光線/灼熱（0）< 黑邊（1）< HUD（2）< 微光（3）< 進場層（4） */
.cine__bar { position: absolute; z-index: 1; left: 0; right: 0; height: 12vh; background: #000; transform: scaleY(0); transition: transform .6s var(--ease); }
.cine__bar--top { top: 0; transform-origin: top; }
.cine__bar--bottom { bottom: 0; transform-origin: bottom; }
.is-landing .cine__bar { transform: scaleY(1); }
.cine__hud { position: absolute; z-index: 2; left: var(--gutter); right: var(--gutter); display: flex; justify-content: space-between; align-items: center; gap: 16px; opacity: 0; transition: opacity .4s var(--ease) .25s; }
.cine__hud--top { top: calc(6vh - 7px); color: rgba(236, 232, 223, .75); }
.cine__hud--top b { color: var(--paper); font-weight: 500; font-variant-numeric: tabular-nums; }
.cine__hud--bottom { bottom: calc(6vh - 16px); }
.cine__hud--bottom b { font-family: var(--display); font-weight: 800; font-size: clamp(18px, 2.3vw, 30px); letter-spacing: 0; }
.cine__hud--bottom .mono { color: var(--c); }
.is-landing .cine__hud { opacity: 1; }
.cine__rays, .cine__heat, .cine__flash { position: absolute; inset: 0; opacity: 0; }
.cine__rays {
  background: repeating-conic-gradient(from 0deg at 50% 50%, transparent 0deg 3deg, rgba(255, 255, 255, .16) 3deg 3.25deg);
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 12%, #000 70%);
  mask: radial-gradient(circle at 50% 50%, transparent 12%, #000 70%);
}
.cine__heat { background: radial-gradient(circle at 50% 50%, transparent 25%, var(--c) 120%); mix-blend-mode: screen; }
.cine__flash { z-index: 3; background: radial-gradient(circle at 50% 50%, #fff 0%, var(--c) 75%); }
.is-diving .cine__rays { animation: rays var(--hit) linear forwards; }
.is-diving .cine__heat { animation: heat var(--hit) linear forwards; }
.is-diving .cine__flash { animation: flash .3s ease-out; animation-delay: calc(var(--hit) - .5s); }
@keyframes rays { 0%, 40% { opacity: 0; transform: scale(1) rotate(0deg); } 100% { opacity: .45; transform: scale(1.5) rotate(3deg); } }
@keyframes heat { 0%, 55% { opacity: 0; } 100% { opacity: .35; } }
@keyframes flash { 0%, 100% { opacity: 0; } 40% { opacity: .14; } }
/* 俯衝末段即顯示產品名，遮罩與鏡頭同時落地；只用 opacity／transform，慢速載入時載入條仍可播放。 */
.cine__arrive { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; gap: 18px; background: var(--arrival-bg); opacity: 0; }
.cine__arrive b { font-family: var(--display); font-weight: 800; font-size: clamp(22px, 3vw, 40px); color: var(--arrival-ink); transform: translateY(10px); opacity: 0; }
.cine__arrive i { position: relative; width: min(240px, 50vw); height: 2px; overflow: hidden; background: var(--arrival-line); }
.cine__arrive i::after { content: ''; position: absolute; inset: 0; background: var(--c); transform: translateX(-100%); }
.is-diving .cine__arrive { animation: landingCover .45s ease-in-out calc(var(--hit) - .45s) forwards; }
.is-diving .cine__arrive b { animation: landingTitle .3s var(--ease) calc(var(--hit) - .45s) forwards; }
.is-arriving .cine__arrive { opacity: 1; }
.is-arriving .cine__arrive i::after { animation: arrive 1.1s cubic-bezier(.6, 0, .4, 1) infinite; }
@keyframes landingCover { from { opacity: 0; } to { opacity: 1; } }
@keyframes landingTitle { to { opacity: 1; transform: translateY(0); } }
@keyframes arrive { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ---------- 自訂游標 ---------- */
.cursor {
  position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; display: none;
  width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 1px solid rgba(236, 232, 223, .7);
  place-items: center; transition: width .4s var(--ease), height .4s var(--ease), margin .4s var(--ease), background .3s, border-color .3s, opacity .3s;
}
.has-cursor .cursor { display: grid; }
.cursor.is-planet, .cursor.is-ghost { width: 74px; height: 74px; margin: -37px 0 0 -37px; }
.cursor.is-planet { border-color: var(--accent); border-width: 1.5px; }
.cursor.is-ghost { border-style: dashed; }
.cursor.is-link { width: 10px; height: 10px; margin: -5px 0 0 -5px; background: var(--paper); }
/* 標籤放在環的下方，避免遮住星球本體 */
.cursor__label { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); font-size: 10px; white-space: nowrap; opacity: 0; transition: opacity .2s; }
.cursor.is-planet .cursor__label { color: var(--accent); opacity: 1; }
.cursor.is-ghost .cursor__label { color: var(--mute); opacity: 1; }
.is-landing .cursor { opacity: 0; }

/* ---------- 窄螢幕 ---------- */
@media (max-width: 900px) {
  .top__clock { display: none; }
}
@media (max-width: 760px) {
  .top { padding-top: max(14px, env(safe-area-inset-top)); gap: 14px; }
  .brand img { height: 30px; }
  .top__title { display: none; }
  .top__right { margin-left: auto; }
  .sound { padding: 10px 13px; }
  .dock { width: calc(100vw - 2 * var(--gutter)); }
  .dock__hint { display: none; }
  .dock__list { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .dock__item { min-width: 0; padding: 10px 12px; column-gap: 10px; }
  .dock__code { font-size: 13px; }
  .dock__title { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dock__item--ghost { display: none; }
  .plabel__code { font-size: 12px; }
  .plabel--ghost { display: none; }
  .corecard { padding: 12px 28px 12px 14px; gap: 6px; }
  .cine__hud--bottom b { font-size: 15px; }
  .cine__hud--bottom .mono { font-size: 9px; }
  .corecard__title { font-size: 22px; }
  .corecard__sub { font-size: 12px; letter-spacing: .2em; }
  .couplet { position: fixed; z-index: 15; top: 62px; left: 0; right: 0; display: flex; justify-content: center; gap: 1.4em; pointer-events: none; }
  .couplet__line { position: static; transform: none; writing-mode: horizontal-tb; font-size: 12px; letter-spacing: .3em; }
  .couplet__line::before { content: none; }
  .gate { gap: 18px; }
  .gate__logo { width: 168px; }
}

/* ---------- 減少動態 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}
