/* =====================================================================
 * 《双环》官方网站样式。
 *
 * 这不是"另做一个好看的页面"——它是**游戏视觉系统的延伸**。
 * 颜色取自 godot/scripts/ui/theme.gd 的同一套 token，含义也照搬：
 *
 *   红味近黑  60%  基底。刻意偏红不偏蓝（纯中性黑是没人选过的默认值）
 *   骨白/灰   30%  正文与结构线
 *   青  OWN   10%  我方 / 可交互 / **唯一的主要动作**
 *   橙  FOE   10%  敌方 / 威胁 / 警告
 *   金  VALUE 10%  经济（版本号、数据）
 *
 * 三条自定规则（与游戏内一致）：
 *   1. 控件默认中性灰，只有主要动作上青 —— 否则等于没有主次。
 *   2. 底板用**切角**不用圆角。圆角是模板默认值，切角是选择。
 *   3. 表面要有材质（颗粒 + 扫描线），纯色矢量填充一眼就是生成的。
 *      但 **可读性 > 风格**：颗粒只在底板与背景上，正文所在的面板保持干净。
 * ===================================================================== */

:root {
  /* --- 基底 60% --- */
  --ink:        rgb(14 13 11);
  --ink-deep:   rgb(8 7 6);
  --surface:    rgb(22 20 19);
  --surface-hi: rgb(31 29 26);
  --surface-lo: rgb(12 11 10);

  /* --- 结构 30% --- */
  --bone:       rgb(224 218 207);
  --bone-dim:   rgb(156 151 142);
  --bone-faint: rgb(96 93 88);
  --rule:       rgb(55 53 50);
  --rule-hi:    rgb(81 78 73);

  /* --- 语义 10% --- */
  --own:      rgb(77 217 205);
  --own-deep: rgb(41 130 123);
  --foe:      rgb(242 122 66);
  --value:    rgb(234 191 90);

  /* 切角尺寸，和 theme.gd 的 CHAMFER_* 同刻度 */
  --ch-lg: 16px;
  --ch-md: 11px;
  --ch-sm: 7px;

  /* 间距刻度：给布局留节奏，不是处处等距 */
  --s1: 4px;
  --s2: 8px;
  --s3: 14px;
  --s4: 22px;
  --s5: 34px;

  /* 动效：短、准、有分工。没有"到处淡入"这回事 */
  --t-tap: 70ms;
  --t-hover: 110ms;
  --t-reveal: 260ms;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink-deep);
  color: var(--bone);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  /* 移动端：地址栏收起/展开时不再抖动 */
  min-height: 100svh;
}

/* ---------------------------------------------------------------- 切角底板
 * 用 clip-path 造切角。**只切一个角**（右上），形成方向性 ——
 * 四角全切的"八边形卡片"是另一个模板默认值。
 * 为什么不用 border-radius：圆角是浏览器/组件库送你的默认值，切角是决定。 */
.plate {
  position: relative;
  background: var(--surface);
  clip-path: polygon(0 0, calc(100% - var(--ch-lg)) 0, 100% var(--ch-lg), 100% 100%, 0 100%);
}
.plate--sm {
  clip-path: polygon(0 0, calc(100% - var(--ch-sm)) 0, 100% var(--ch-sm), 100% 100%, 0 100%);
}

/* 发丝线：替代彩色描边。语义色只在需要暗示归属时以极淡的形式出现在边缘 */
.plate::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  clip-path: inherit;
  /* 用内阴影画 1px 边，比 border 更贴合 clip-path 的斜边 */
  box-shadow: inset 0 0 0 1px var(--rule);
}
.plate--own::after { box-shadow: inset 0 0 0 1px rgb(77 217 205 / .28); }
.plate--foe::after { box-shadow: inset 0 0 0 1px rgb(242 122 66 / .30); }

/* ---------------------------------------------------------------- 扫描线材质
 * 纯色矢量面一眼是生成的。真表面有纹理。
 * 这里只给**背景层**加，正文面板保持干净（可读性 > 风格）。 */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image:
    repeating-linear-gradient(
      to bottom,
      rgb(255 255 255 / .022) 0 1px,
      transparent 1px 3px
    ),
    /* 颗粒：用 SVG 噪声而不是循环背景图，零外部资源 */
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='.30'/></svg>");
  background-size: auto, 140px 140px;
  mix-blend-mode: overlay;
}

/* 顶部一条极淡的青色辉光：交代"这是深空里的仪表"，不是白纸 */
.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgb(77 217 205 / .07), transparent 62%),
    radial-gradient(100% 70% at 50% 110%, rgb(242 122 66 / .05), transparent 60%);
}

/* ---------------------------------------------------------------- 布局 */
.wrap {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--s5) var(--s4) var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

/* ---------------------------------------------------------------- 标题区 */
.head { display: flex; flex-direction: column; gap: var(--s3); }

.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 11px;
  letter-spacing: .30em;
  color: var(--bone-faint);
}
/* 工作室署名 */
.eyebrow .studio { color: var(--bone-dim); letter-spacing: .18em; }
.eyebrow .dot {
  width: 4px; height: 4px;
  background: var(--own);
  transform: rotate(45deg);   /* 菱形：和切角同一套几何语言 */
  flex: none;
}

.title {
  margin: 0;
  font-size: clamp(34px, 11vw, 54px);
  font-weight: 900;
  line-height: .96;
  letter-spacing: -.02em;
  color: var(--bone);
}
/* 中英混排：中文重、英文做副调。一个字重走到底正是"没人排过版"的破绽 */
.title .en {
  display: block;
  font-size: .40em;
  font-weight: 500;
  letter-spacing: .42em;
  color: var(--own);
  margin-top: var(--s2);
  text-indent: .42em;   /* 抵掉末字多出的字距，视觉才居中 */
}

.tagline {
  margin: 0;
  font-size: 15px;
  line-height: 1.75;
  color: var(--bone-dim);
  max-width: 46ch;
}
.tagline b { color: var(--bone); font-weight: 600; }
.tagline .own { color: var(--own); font-weight: 600; }
.tagline .foe { color: var(--foe); font-weight: 600; }

/* 版本号属于"经济/数据"信息 → 金色，且用等宽数字 */
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s3);
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--bone-faint);
  font-variant-numeric: tabular-nums;
}
.meta-row .v { color: var(--value); }

/* ---------------------------------------------------------------- 按钮
 * 三级语义，**默认中性**：
 *   .btn            中性   次要动作（返回、看说明）
 *   .btn--primary   青     全站唯一的主要动作（开始玩 / 下载）
 *   .btn--ghost     无底   第三级（外链）
 * 橙只用于"警告/危险"提示，不做按钮底色 —— 否则语义就废了。 */
.btn {
  --btn-bg: var(--surface-hi);
  --btn-fg: var(--bone);
  --btn-line: var(--rule-hi);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  width: 100%;
  padding: var(--s4) var(--s4);
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: none;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .04em;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  position: relative;
  transition: background var(--t-hover) var(--ease), transform var(--t-tap) var(--ease);
}
/* 切角 + 发丝线：和游戏内 uikit 同构 */
.btn {
  clip-path: polygon(0 0, calc(100% - var(--ch-md)) 0, 100% var(--ch-md), 100% 100%, 0 100%);
  box-shadow: inset 0 0 0 1px var(--btn-line);
}
/* 左侧 4px 竖条 = 「行动条」，不是装饰彩条：
 * 它只在主要动作上出现，充当"这个按钮是这台仪器的操作杆"的读数。 */
.btn--primary {
  --btn-bg: var(--own);
  --btn-fg: rgb(6 20 19);
  --btn-line: rgb(77 217 205 / .9);
  font-weight: 800;
}
.btn--primary .go { color: rgb(6 20 19); }

.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--bone-dim);
  --btn-line: var(--rule);
  font-weight: 500;
  padding: var(--s3) var(--s4);
  font-size: 14px;
}

.btn:hover { background: color-mix(in srgb, var(--btn-bg) 88%, white 12%); }
.btn:active { transform: scale(.977); }        /* 0.07s 的机械触点感 */
.btn:focus-visible { outline: 2px solid var(--own); outline-offset: 3px; }
.btn[disabled], .btn[aria-disabled="true"] {
  --btn-fg: var(--bone-faint);
  --btn-bg: var(--surface-lo);
  cursor: not-allowed;
  transform: none;
}

.btn .k { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.btn .k small {
  font-size: 11px;
  font-weight: 400;
  letter-spacing: .12em;
  color: color-mix(in srgb, var(--btn-fg) 62%, transparent);
}
.btn .go {
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--bone-faint);
  flex: none;
  font-variant-numeric: tabular-nums;
}

.actions { display: flex; flex-direction: column; gap: var(--s2); }

/* ---------------------------------------------------------------- 信息面板 */
.panel { padding: var(--s4); }
.panel h2 {
  margin: 0 0 var(--s3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .26em;
  color: var(--bone-faint);
}
.panel p { margin: 0 0 var(--s3); font-size: 14px; line-height: 1.8; color: var(--bone-dim); }
.panel p:last-child { margin-bottom: 0; }
/* 面板里也可能放按钮（例如「去 TapTap 给个好评」）。
   段落自带 margin-bottom，按钮只有内边距 —— 不补这一条，按钮会紧贴上一段文字。 */
.panel .btn { margin-top: var(--s4); }
/* 「给个好评」那块给一道青色发丝边：它承担的是**唯一一次请求**，值得比普通面板亮一点，
   但又不能亮到像广告位 —— 所以只借 site.css 里已有的 .plate--own 手法（inset 1px 描边）。 */
.plate.panel--rate::after { box-shadow: inset 0 0 0 1px rgb(77 217 205 / .22); }

/* 规则条目：编号用金色（数据/经济），正文骨白 —— 和游戏内"标签-数值"同一读法 */
.rules { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: var(--s3); }
.rules li { display: flex; gap: var(--s3); font-size: 14px; line-height: 1.75; color: var(--bone-dim); }
.rules li .n {
  flex: none;
  width: 22px;
  color: var(--value);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.rules li b { color: var(--bone); font-weight: 600; }

/* ------------------------------------------------- 宣传图与实机录屏两块
 * 这两块都是"往外看的窗口"（一张宣传图 + 一段录屏），
 * 所以边框语言**故意不与 .plate 相同** —— 全站都切同一个角就成了模板。
 * 分工：
 *   .hero-shot  用 1px 骨白发丝边 + 底边一条「青→橙」的极性线：这条线是这游戏专属的签名
 *               （环的左半青、右半橙），和 banner 画面里环的双色分工是同一个读法。
 *   .demo__frame 用切角（右上 + 左下，对角两处），装竖屏录屏，像握在手里的那块屏。
 * 底色都用 --ink-deep：图还没解码出来时先是一块深色，不会闪白。 */

.hero-shot {
  position: relative;
  margin: 0;
  background: var(--ink-deep);
}
.hero-shot img { display: block; width: 100%; height: auto; }
.hero-shot::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  /* 1px 骨白发丝边（比 .plate 的边暗一档：它是配图，不该比正文面板更响） */
  box-shadow: inset 0 0 0 1px rgb(81 78 73 / .5);
  /* 底边那条极性线：两端实、中间几乎断开 —— 和游戏里"两个半环"同一个读法 */
  background:
    linear-gradient(90deg,
      rgb(77 217 205 / .9)  0%,
      rgb(77 217 205 / .12) 44%,
      rgb(242 122 66 / .12) 56%,
      rgb(242 122 66 / .9)  100%)
    bottom left / 100% 2px no-repeat;
}

.demo {
  margin: var(--s4) 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s3);
}

/* 外框只做两件事：填那 1px 的线、切出角。真正的画面是里面的 <video>。 */
.demo__frame {
  width: min(78vw, 320px);
  padding: 1px;
  background: linear-gradient(155deg,
    rgb(77 217 205 / .42) 0%,
    var(--rule-hi) 46%,
    rgb(242 122 66 / .34) 100%);
  clip-path: polygon(
    0 0,
    calc(100% - var(--ch-lg)) 0,
    100% var(--ch-lg),
    100% 100%,
    var(--ch-lg) 100%,
    0 calc(100% - var(--ch-lg)));
}
.demo__frame > video {
  display: block;
  width: 100%;
  height: auto;
  background: var(--ink-deep);
  clip-path: polygon(
    0 0,
    calc(100% - var(--ch-lg)) 0,
    100% var(--ch-lg),
    100% 100%,
    var(--ch-lg) 100%,
    0 calc(100% - var(--ch-lg)));
}

/* 提示语压暗、限宽：它是注释，不该和正文抢注意力 */
.demo__note {
  margin: 0;
  max-width: 46ch;
  text-align: center;
  font-size: 12px;
  line-height: 1.8;
  color: var(--bone-faint);
}
.demo__note b { color: var(--bone-dim); font-weight: 600; }

/* ---------------------------------------------------------------- 状态行
 * 用来交代"网页版需要下载约 55MB"这类事实 —— 不藏起来。
 * 金色 = 经济/数据信息。 */
.status {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 12px;
  line-height: 1.7;
  color: var(--bone-faint);
  letter-spacing: .04em;
}
.status .led {
  width: 6px; height: 6px; flex: none;
  background: var(--bone-faint);
  transform: rotate(45deg);
}
.status--warn { color: var(--foe); }
.status--warn .led { background: var(--foe); }
.status--ok { color: var(--own); }
.status--ok .led { background: var(--own); }

/* ---------------------------------------------------------------- 页脚 */
.foot {
  font-size: 11px;
  line-height: 1.9;
  color: var(--bone-faint);
  letter-spacing: .06em;
  border-top: 1px solid var(--rule);
  padding-top: var(--s4);
}
.foot a { color: var(--bone-dim); text-decoration: none; border-bottom: 1px solid var(--rule-hi); }
.foot a:hover { color: var(--own); border-color: var(--own); }
.foot p { margin: 0 0 var(--s2); }

/* =====================================================================
 * 游戏层（点「开始」之后）
 * 全屏 + 竖屏正中。**不做全屏 API 请求**：iOS Safari 上它不可靠，
 * 而且地址栏一收一放会改变 canvas 尺寸，Godot 会重排（画面闪一下）。
 * 用 fixed 覆盖 + 顶栏退出，行为在各端一致。
 * ===================================================================== */
#game-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--ink-deep);
  display: none;
  flex-direction: column;
}
#game-screen.on { display: flex; }

#game-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  padding-top: max(var(--s2), env(safe-area-inset-top));
  background: var(--surface-lo);
  border-bottom: 1px solid var(--rule);
}
#game-bar .name {
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--bone-faint);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#game-bar .name b { color: var(--bone-dim); font-weight: 600; }

#quit {
  flex: none;
  background: transparent;
  color: var(--bone-dim);
  border: none;
  box-shadow: inset 0 0 0 1px var(--rule-hi);
  clip-path: polygon(0 0, calc(100% - var(--ch-sm)) 0, 100% var(--ch-sm), 100% 100%, 0 100%);
  font: inherit;
  font-size: 12px;
  letter-spacing: .18em;
  padding: 7px var(--s3);
  cursor: pointer;
}
#quit:hover { color: var(--foe); box-shadow: inset 0 0 0 1px rgb(242 122 66 / .5); }

/* canvas 舞台：Godot 自己管缩放（canvas_resize_policy=2 + stretch expand），
 * 这里只负责把它居中、占满剩余高度。 */
#stage {
  flex: 1;
  position: relative;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--ink-deep);
}
/* 画布尺寸必须**显式**定，不能靠 max-width/max-height：
 * canvas 是替换元素，max-* 与 auto 的交互在各浏览器不一致（曾出现宽扁拉伸）。
 * 游戏是 720×1280（9:16），这里就把 9:16 写死，让 max-* 去决定"装得下"的倍数。
 * Godot 侧 canvas_resize_policy=2 + stretch expand，会跟着这个 CSS 尺寸重排。 */
#stage canvas {
  display: block;
  aspect-ratio: 9 / 16;
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;
}

/* 加载进度：wasm 有 39MB，手机上不是瞬间的。**必须给看得见的进度**，
 * 否则玩家会以为坏了 —— 这是网页游戏最常见的流失点。 */
#load {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  background: var(--ink-deep);
  z-index: 2;
}
#load.off { display: none; }
#load .label {
  font-size: 11px;
  letter-spacing: .30em;
  color: var(--bone-faint);
}
#load .pct {
  font-size: 40px;
  font-weight: 800;
  color: var(--own);
  font-variant-numeric: tabular-nums;
}
#load .track {
  width: min(280px, 62vw);
  height: 3px;
  background: var(--surface-hi);
  overflow: hidden;
}
#load .fill {
  height: 100%;
  width: 0%;
  background: var(--own);
  transition: width 160ms linear;
}
#load .hint { font-size: 12px; color: var(--bone-faint); letter-spacing: .06em; }

/* 竖屏提示：横屏时游戏会被压得很小。这是手游，直接告诉玩家转回来 */
#rotate {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  background: var(--ink-deep);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--s5);
  font-size: 14px;
  line-height: 2;
  color: var(--bone-dim);
  letter-spacing: .1em;
}
#rotate b { display: block; color: var(--own); font-size: 18px; margin-bottom: var(--s2); }
@media (orientation: landscape) and (max-height: 500px) {
  #rotate { display: flex; }
}

/* 广告适配层（网页版备用，游戏本体自己也有播放层） */
#polarity-ad-layer { z-index: 9999; }

/* 无障碍：尊重系统的"减少动态效果" */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 1ms !important; animation-duration: 1ms !important; }
}
