/* ============================================================================
   云衢杀 · 中转站
   沿用 styles.css 里「焚城」那一套色板和字体：底色是烧过的木头，强调只用金，
   红色只在“连不上”的时候出现。整页只有一个焦点：三个入口。
   ========================================================================= */

:root {
  --board: #120907;
  --board-deep: #080403;

  --chalk: #f7ecda;
  --chalk-2: #ddc9b1;
  --dim: #b39a83;

  --red: #d2552f;
  --red-text: #f0a080;

  --gold: #f2b878;
  --gold-dim: rgba(242, 184, 120, 0.42);

  --hair: rgba(242, 184, 120, 0.18);
  --hair-soft: rgba(242, 184, 120, 0.1);

  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun",
    "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC",
    "PingFang SC", "Microsoft YaHei", sans-serif;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* 形状规则：结构件（外框、角花）直角；一切可以点的东西 4px 圆角。 */
  --radius: 4px;

  --frame: clamp(9px, 1.3vw, 18px);
}

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--board-deep);
  color: var(--chalk);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* ------------------------------------------------------------------ 背景 */

/* 焚城：主题插画先烤成一张糊掉、去掉大半饱和度的底（tools/make-veil.mjs），
   页面上只叠渐变。这样有火光和温度，但不会有一张脸压在标题后面，
   手机也不用为 full-screen blur 每帧买单。 */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(85% 60% at 26% 4%, rgba(255, 128, 44, 0.16) 0%, transparent 66%),
    radial-gradient(60% 45% at 92% 84%, rgba(210, 85, 47, 0.1) 0%, transparent 72%),
    linear-gradient(180deg, rgba(8, 4, 3, 0.52) 0%, rgba(8, 4, 3, 0.7) 48%, rgba(8, 4, 3, 0.9) 100%),
    url("theme/wdf-veil.webp") center 16% / cover no-repeat,
    var(--board-deep);
}

/* 四角压暗：像一块被灯照着打的幕布 */
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(122% 92% at 44% 44%, transparent 34%, rgba(4, 2, 1, 0.66) 100%);
}

/* 黑板上的粉笔灰 */
.dust {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 火星：一层薄薄的、往上飘的粒子（portal.js 生成，减少动态效果时不生成） */
.embers {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.ember {
  position: absolute;
  bottom: -14px;
  width: var(--size, 3px);
  height: var(--size, 3px);
  border-radius: 50%;
  background: radial-gradient(circle, #ffe0b4 0%, var(--red) 55%, transparent 72%);
  opacity: 0;
  animation: ember-rise var(--dur, 14s) linear var(--delay, 0s) infinite;
  will-change: transform, opacity;
}

@keyframes ember-rise {
  0% { opacity: 0; transform: translate3d(0, 0, 0) scale(0.6); }
  14% { opacity: 0.72; }
  72% { opacity: 0.4; }
  100% { opacity: 0; transform: translate3d(var(--drift, 30px), -92vh, 0) scale(1.1); }
}

/* ------------------------------------------------------------------ 外框 */

.frame {
  position: fixed;
  inset: var(--frame);
  z-index: 3;
  pointer-events: none;
  border: 1px solid rgba(242, 184, 120, 0.12);
}

.frame__corner {
  position: absolute;
  width: clamp(14px, 2vw, 24px);
  height: clamp(14px, 2vw, 24px);
  border: 1px solid rgba(242, 184, 120, 0.55);
}

.frame__corner--tl { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.frame__corner--tr { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.frame__corner--bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.frame__corner--br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* ------------------------------------------------------------------ 骨架 */

.shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(18px, 3vw, 34px);
  width: min(1340px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(var(--frame) + clamp(16px, 2.4vw, 30px))
    calc(var(--frame) + clamp(18px, 3.2vw, 48px))
    calc(var(--frame) + clamp(14px, 2vw, 24px));
}

/* ------------------------------------------------------------------ 顶栏 */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: clamp(12px, 1.6vw, 18px);
  border-bottom: 1px solid var(--hair-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__mark {
  width: clamp(28px, 3vw, 34px);
  height: clamp(28px, 3vw, 34px);
  flex: 0 0 auto;
  color: var(--gold);
  opacity: 0.92;
  filter: drop-shadow(0 0 14px rgba(242, 184, 120, 0.28));
}

.brand__text { display: flex; flex-direction: column; }

.brand__name {
  font-family: var(--serif);
  font-size: 0.98rem;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--chalk);
}

.brand__latin {
  margin-top: 5px;
  font-size: 0.52rem;
  letter-spacing: 0.44em;
  text-indent: 0.44em;
  color: var(--dim);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: rgba(12, 6, 4, 0.55);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--chalk-2);
  white-space: nowrap;
}

.status__dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--dim);
  transition: background-color 0.3s, box-shadow 0.3s;
}

.status[data-state="online"] .status__dot {
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(242, 184, 120, 0.14), 0 0 10px rgba(242, 184, 120, 0.55);
}

.status[data-state="offline"] .status__dot {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(210, 85, 47, 0.14);
}

.status[data-state="offline"] .status__text { color: var(--red-text); }

/* 静态托管（Cloudflare Pages）没有 /api/stats，状态条整个收掉，不留一个假状态 */
.status[hidden] { display: none; }

/* ------------------------------------------------------------------ 主区 */

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(340px, 0.86fr);
  align-items: center;
  gap: clamp(26px, 4.4vw, 76px);
  align-content: center;
}

/* 左：一句话把游戏说清楚 */
.intro {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(12px, 1.6vw, 20px);
  min-width: 0;
}

/* logo 背后的一层暖光：让火焰亮起来，而不是贴在黑底上 */
.intro::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 2%;
  top: 12%;
  width: 62%;
  height: 58%;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255, 132, 48, 0.18) 0%, transparent 68%);
}

.intro__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.38em;
  text-indent: 0.1em;
  color: var(--gold-dim);
}

.intro__eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  flex: 0 0 auto;
  background: linear-gradient(90deg, var(--gold), rgba(242, 184, 120, 0));
}

.intro__logo {
  margin: 0;
  width: min(100%, 600px);
  line-height: 0;
  filter: drop-shadow(0 26px 44px rgba(0, 0, 0, 0.5));
}

.intro__logo img { display: block; width: 100%; height: auto; }

/* 图挂了也不能空一块：把三个字用字体补回来 */
.logo--fallback {
  display: flex;
  align-items: center;
  min-height: 96px;
  line-height: 1.3;
}
.logo--fallback img { display: none; }
.logo--fallback::after {
  content: "云衢杀";
  font-family: var(--serif);
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: var(--chalk);
}

.intro__lead {
  margin: 0;
  max-width: 26em;
  font-size: clamp(0.92rem, 1.05vw, 1.04rem);
  line-height: 1.95;
  letter-spacing: 0.02em;
  color: var(--chalk-2);
}

/* 两句话两行：中文断行交给浏览器，它总会把“一整个”拆开 */
.intro__lead span { display: block; }

/* ------------------------------------------------------------------ 三个入口 */

.gate {
  position: relative;
  padding: clamp(16px, 1.9vw, 24px);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(29, 16, 11, 0.86) 0%, rgba(10, 5, 3, 0.9) 100%);
  box-shadow:
    0 40px 80px -56px #000,
    inset 0 1px 0 rgba(242, 184, 120, 0.14);
  backdrop-filter: blur(7px) saturate(118%);
  -webkit-backdrop-filter: blur(7px) saturate(118%);
}

/* 面板顶上那道金线：整块牌桌的“灯” */
.gate::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.gate__head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: clamp(12px, 1.5vw, 18px);
}

.gate__title {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.36em;
  text-indent: 0.36em;
  color: var(--gold);
}

.gate__rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--hair), rgba(242, 184, 120, 0));
}

.gate__list { display: grid; gap: 9px; }

/* 三行入口：图标 / 文字 / 标签 / 箭头 */
.entry {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  gap: 13px;
  padding: 14px 15px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.014);
  color: inherit;
  text-decoration: none;
  overflow: hidden;
  transition:
    transform 0.24s var(--ease),
    border-color 0.24s,
    background-color 0.24s,
    box-shadow 0.24s;
}

.entry--play { grid-template-columns: auto 1fr auto; }
.entry--pkg { grid-template-columns: auto 1fr auto auto; }

.entry__icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: rgba(242, 184, 120, 0.055);
  color: var(--gold);
  transition: border-color 0.24s, background-color 0.24s;
}

.entry__icon svg { width: 20px; height: 20px; display: block; }

.entry__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.entry__name {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--chalk);
}

.entry__meta {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--dim);
}

/* 网页版：主入口，满金。牌桌上“准备”那颗按钮的样子 */
.entry--play {
  padding: 18px 16px;
  border-color: #b98442;
  background: linear-gradient(180deg, #f8cd94 0%, #e8a862 100%);
  box-shadow:
    0 20px 38px -30px #000,
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.entry--play .entry__icon {
  width: 42px;
  height: 42px;
  border-color: rgba(42, 23, 8, 0.26);
  background: rgba(42, 23, 8, 0.07);
  color: #35200d;
}

.entry--play .entry__icon svg { width: 22px; height: 22px; }

.entry--play .entry__name {
  font-size: 1.16rem;
  letter-spacing: 0.1em;
  color: #241304;
}

.entry--play .entry__meta { color: rgba(42, 23, 8, 0.74); }

/* 回车提示：键盘上直接进 */
.entry__key {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid rgba(42, 23, 8, 0.3);
  border-radius: var(--radius);
  font-size: 0.78rem;
  line-height: 1;
  color: #2f1c0b;
  background: rgba(255, 255, 255, 0.22);
}

.entry__tag {
  padding: 3px 7px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  color: var(--gold);
  background: rgba(242, 184, 120, 0.05);
}

.entry__go {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--dim);
  transition: color 0.24s, transform 0.24s var(--ease);
}

.entry__go svg { width: 17px; height: 17px; display: block; }

/* 悬停 / 按下 */
.entry:hover { transform: translateY(-2px); }

.entry--pkg:hover {
  border-color: rgba(242, 184, 120, 0.5);
  background: rgba(242, 184, 120, 0.055);
  box-shadow: 0 22px 40px -36px rgba(0, 0, 0, 0.9);
}

.entry--pkg:hover .entry__icon {
  border-color: rgba(242, 184, 120, 0.42);
  background: rgba(242, 184, 120, 0.12);
}

.entry--pkg:hover .entry__go { color: var(--gold); transform: translateY(2px); }

.entry--play:hover {
  background: linear-gradient(180deg, #fbdcae 0%, #eaae6b 100%);
  box-shadow:
    0 26px 46px -30px rgba(0, 0, 0, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.entry--play:hover .entry__icon { border-color: rgba(42, 23, 8, 0.4); }

.entry:active { transform: translateY(0); }

/* 主入口的扫光：只在一瞬间，不循环 */
.entry--play::after {
  content: "";
  position: absolute;
  inset: -10% -20%;
  z-index: -1;
  background: linear-gradient(100deg, transparent 24%, rgba(255, 255, 255, 0.5) 50%, transparent 66%);
  transform: translateX(-130%) skewX(-14deg);
  opacity: 0;
  pointer-events: none;
}

.entry--play:hover::after { animation: entry-sheen 0.9s var(--ease); }

@keyframes entry-sheen {
  0% { opacity: 0.85; transform: translateX(-130%) skewX(-14deg); }
  100% { opacity: 0; transform: translateX(130%) skewX(-14deg); }
}

/* 安装包还没放上去：不装作能下。用虚线 + 灰字，红色只留给“连不上服务器”。 */
.entry[data-missing="true"] .entry__tag {
  border-style: dashed;
  border-color: rgba(179, 154, 131, 0.5);
  color: var(--dim);
  background: transparent;
}

.gate__foot {
  margin: 13px 2px 0;
  font-size: 0.72rem;
  line-height: 1.65;
  letter-spacing: 0.03em;
  color: var(--dim);
}

/* ------------------------------------------------------------------ 页脚 */

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: clamp(12px, 1.6vw, 18px);
  border-top: 1px solid var(--hair-soft);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--dim);
}

.foot__left, .foot__right { margin: 0; }

.foot__right { display: inline-flex; align-items: baseline; gap: 9px; }

.foot__label { color: rgba(179, 154, 131, 0.72); }

#foot-host { color: var(--chalk-2); letter-spacing: 0.05em; }

/* ------------------------------------------------------------------ 提示条 */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--frame) + 24px);
  z-index: 20;
  max-width: min(90vw, 460px);
  padding: 11px 18px;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: rgba(14, 7, 4, 0.95);
  box-shadow: 0 24px 50px -30px #000;
  font-size: 0.8rem;
  line-height: 1.6;
  letter-spacing: 0.05em;
  color: var(--chalk);
  transform: translate(-50%, 14px);
  opacity: 0;
  transition: opacity 0.26s, transform 0.26s var(--ease);
}

.toast[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------------ 入场 */

@media (prefers-reduced-motion: no-preference) {
  .bar,
  .intro__eyebrow,
  .intro__logo,
  .intro__lead,
  .gate,
  .foot {
    animation: rise-in 0.9s var(--ease) both;
  }

  .bar { animation-delay: 0.02s; }
  .intro__eyebrow { animation-delay: 0.1s; }
  .intro__logo { animation-delay: 0.16s; }
  .intro__lead { animation-delay: 0.26s; }
  .gate { animation-delay: 0.22s; }
  .foot { animation-delay: 0.34s; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------------ 收窄 */

/* 中间那一段（竖屏平板、小笔记本）：两栏保留，但把 ZIP / APK 的小标签收掉，
   否则“下载 Windows 版”会被挤成两行。 */
@media (max-width: 1100px) {
  .stage { grid-template-columns: minmax(0, 1fr) minmax(360px, 0.95fr); }

  .entry__tag { display: none; }
  .entry--pkg { grid-template-columns: auto 1fr auto; }
}

/* 大屏且不矮：牌子可以再大一点，别让首屏下半截空着 */
@media (min-width: 1101px) and (min-height: 820px) {
  .intro__logo { width: min(100%, 640px); }

  .gate { padding: clamp(20px, 2vw, 26px); }
  .gate__list { gap: 11px; }

  .entry { padding: 16px 17px; }
  .entry--play { padding: 21px 18px; }
  .entry--play .entry__name { font-size: 1.22rem; }

  .intro__lead { font-size: clamp(0.98rem, 1.1vw, 1.08rem); }
}

/* 竖屏平板：两栏摆在这儿会空成两条缝。改成一列、整体收窄居中，
   ZIP / APK 的小标签也就有地方待了。 */
@media (min-width: 781px) and (max-width: 1100px) and (orientation: portrait) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    gap: 30px;
    width: min(100%, 560px);
    margin: 0 auto;
  }

  .intro__logo { width: min(100%, 460px); }

  .entry__tag { display: inline-block; }
  .entry--pkg { grid-template-columns: auto 1fr auto auto; }
}

@media (max-width: 780px) {
  .shell { grid-template-rows: auto 1fr auto; }

  .stage {
    grid-template-columns: minmax(0, 1fr);
    gap: clamp(22px, 4vw, 32px);
    align-content: center;
  }

  .intro__logo { width: min(100%, 430px); }

  .intro__lead { max-width: 34em; }

  /* 面板本来就不透明，手机上省掉一层 backdrop-filter */
  .gate {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (max-width: 620px) {
  .shell {
    gap: 20px;
    padding:
      calc(var(--frame) + 16px)
      calc(var(--frame) + 16px)
      calc(var(--frame) + 14px);
  }

  .status { padding: 6px 10px; font-size: 0.64rem; }

  .intro__eyebrow { font-size: 0.58rem; letter-spacing: 0.3em; }
  .intro__logo { width: 100%; }
  .intro__lead { font-size: 0.9rem; line-height: 1.9; }

  .gate { padding: 15px; }

  .entry { gap: 11px; padding: 13px; }
  .entry__icon { width: 34px; height: 34px; }
  .entry__icon svg { width: 18px; height: 18px; }
  .entry__name { font-size: 0.95rem; }
  .entry__meta { font-size: 0.7rem; }

  .entry--play { padding: 16px 14px; }
  .entry--play .entry__name { font-size: 1.06rem; }
  .entry--play .entry__icon { width: 38px; height: 38px; }

  .foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.64rem;
  }
}

@media (max-width: 420px) {
  .entry__tag { display: none; }
  .entry--pkg { grid-template-columns: auto 1fr auto; }
  .entry__key { display: none; }
}

/* 横屏手机（高度很矮）：把 logo、字号、留白全收一档，三个入口必须一屏看完 */
@media (max-height: 560px) and (orientation: landscape) {
  .shell {
    gap: 12px;
    padding:
      calc(var(--frame) + 10px)
      calc(var(--frame) + 18px)
      calc(var(--frame) + 8px);
  }

  .brand__mark { width: 26px; height: 26px; }
  .brand__name { font-size: 0.86rem; }
  .brand__latin { display: none; }
  .status { padding: 5px 9px; font-size: 0.62rem; }

  .stage {
    grid-template-columns: minmax(0, 0.86fr) minmax(300px, 1fr);
    gap: 22px;
    align-items: center;
  }

  .intro { gap: 8px; }
  .intro__eyebrow { display: none; }
  .intro__logo { width: min(100%, 280px); }
  .intro__lead { font-size: 0.78rem; line-height: 1.65; max-width: 22em; }

  .gate { padding: 12px; }
  .gate__head { margin-bottom: 8px; }
  .gate__title { font-size: 0.6rem; }
  .gate__list { gap: 7px; }

  .entry { padding: 9px 11px; gap: 10px; }
  .entry__icon { width: 30px; height: 30px; }
  .entry__icon svg { width: 16px; height: 16px; }
  .entry__name { font-size: 0.9rem; }
  .entry__meta { font-size: 0.66rem; }
  .entry__key { display: none; }
  .entry__tag { display: none; }
  .entry--pkg { grid-template-columns: auto 1fr auto; }

  .entry--play { padding: 11px 12px; }
  .entry--play .entry__icon { width: 32px; height: 32px; }
  .entry--play .entry__name { font-size: 0.98rem; }

  .gate__foot { display: none; }

  .foot { display: none; }
}
