/* ==========================================================================
   Etopia Rings — Web 版样式
   竖屏 9:16 舞台,桌面端居中带圆角,移动端满屏。
   视觉语言借鉴本地 Unity 素材包「Super Clean UI - Flat Pack v2.4.2」:
   扁平渐变填充 + 实心 glyph 图标 + halo 光晕 + Sweep/Stamp 微交互。
   从素材包抽取的 PNG 位于 assets/cleanflatui/(图标/光晕/条纹/渐变),
   统一用 CSS mask 着色,颜色跟随 currentColor 或主题变量。
   ========================================================================== */

:root {
  --ink: #eaf1ff;
  --ink-dim: rgba(206, 218, 255, 0.66);
  --glass: rgba(255, 255, 255, 0.06);
  --glass-line: rgba(255, 255, 255, 0.13);
  --cyan: #6ee7ff;
  --violet: #b18cff;
  --gold: #ffd76a;
  --panel: #0b1022;
  /* 竖屏 9:16 舞台:窄高屏铺满,宽屏/桌面按 9:16 居中显示 */
  --stage-w: 100vw;
  --stage-h: 100dvh;
  /* 动效令牌取自 CleanFlatUI 60fps 帧数换算(见 docs/CLEANFLATUI_ANALYSIS.md §8.1) */
  --ease-spring: cubic-bezier(0.2, 1.35, 0.4, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-pack: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-stamp: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-hover: 0.25s;
  --dur-press: 0.1667s;
  --dur-in: 0.333s;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #04050c;
  color: var(--ink);
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-user-select: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 45% at 20% 12%, rgba(78, 56, 160, 0.20), transparent 70%),
    radial-gradient(ellipse 55% 40% at 82% 78%, rgba(20, 92, 140, 0.16), transparent 70%);
  pointer-events: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stage {
  position: relative;
  width: var(--stage-w);
  height: var(--stage-h);
  max-width: 100vw;
  max-height: 100dvh;
  overflow: hidden;
  background: #070a16;
  isolation: isolate;
}

/* 视口比 9:16 更宽(桌面/平板横屏/宽屏预览)→ 收成 9:16 竖屏舞台 */
@media (min-aspect-ratio: 9/16) {
  :root {
    --stage-w: min(100vw, 560px, calc(100dvh * 9 / 16));
    --stage-h: calc(var(--stage-w) * 16 / 9);
  }
}

@media (min-width: 620px) {
  :root {
    --stage-w: min(calc(100vw - 36px), 560px, calc((100dvh - 36px) * 9 / 16));
    --stage-h: calc(var(--stage-w) * 16 / 9);
  }
  .stage {
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    box-shadow:
      0 40px 120px rgba(0, 0, 0, 0.75),
      0 0 0 1px rgba(120, 180, 255, 0.06),
      0 0 90px rgba(70, 120, 255, 0.10);
  }
}

#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: default;
}

/* ==========================================================================
   CleanFlatUI 素材原语
   形状由 css/cleanflatui-assets.css 内联的 data URI 变量提供:
   file:// 下 CSS mask-image 引用本地 PNG 会被 CORS 拦截(origin null),
   内联后 file:// 与 HTTP 表现一致。素材源文件保留在 assets/cleanflatui/。
   PNG 都是白色/透明形状,这里统一转成 mask 用 currentColor 着色,
   既能保持素材的原始形状,又能跟随主题色(避免把亮色 UI 直接搬进深色主题)。
   ========================================================================== */

.cf-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  pointer-events: none;
}

.cf-icon-menu       { -webkit-mask-image: var(--cfui-icon-menu);       mask-image: var(--cfui-icon-menu); }
.cf-icon-sound      { -webkit-mask-image: var(--cfui-icon-sound);      mask-image: var(--cfui-icon-sound); }
.cf-icon-question   { -webkit-mask-image: var(--cfui-icon-question);   mask-image: var(--cfui-icon-question); }
.cf-icon-lock       { -webkit-mask-image: var(--cfui-icon-lock);       mask-image: var(--cfui-icon-lock); }
.cf-icon-check      { -webkit-mask-image: var(--cfui-icon-check);      mask-image: var(--cfui-icon-check); }
.cf-icon-star       { -webkit-mask-image: var(--cfui-icon-star);       mask-image: var(--cfui-icon-star); }
.cf-icon-checklist  { -webkit-mask-image: var(--cfui-icon-checklist);  mask-image: var(--cfui-icon-checklist); }
.cf-icon-info       { -webkit-mask-image: var(--cfui-icon-info);       mask-image: var(--cfui-icon-info); }
.cf-icon-alert      { -webkit-mask-image: var(--cfui-icon-alert);      mask-image: var(--cfui-icon-alert); }
.cf-icon-next       { -webkit-mask-image: var(--cfui-icon-next);       mask-image: var(--cfui-icon-next); }
.cf-icon-next-thin  { -webkit-mask-image: var(--cfui-icon-next-thin);  mask-image: var(--cfui-icon-next-thin); }
.cf-icon-prev {
  -webkit-mask-image: var(--cfui-icon-next-thin);
  mask-image: var(--cfui-icon-next-thin);
  transform: scaleX(-1);
}
.cf-icon-prev-thick {
  -webkit-mask-image: var(--cfui-icon-next);
  mask-image: var(--cfui-icon-next);
  transform: scaleX(-1);
}

.icon-svg { display: block; width: 21px; height: 21px; }
.icon-btn .icon-svg path { stroke-width: 2.6; }

/* ============================== HUD ============================== */

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.hud > * { pointer-events: auto; }
.hud.hidden { opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(-8px); transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s linear 0.3s; }
.hud.hidden > * { pointer-events: none; }

.icon-btn {
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.04));
  color: #dbe6ff;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  transition: transform var(--dur-hover) var(--ease-pack), background 0.2s ease,
    border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
/* CleanFlatUI 的 halo-circle:悬停时从按钮外圈亮起 */
.icon-btn::before {
  content: "";
  position: absolute;
  inset: -11px;
  z-index: 0;
  background-color: #58c8ff;
  -webkit-mask: var(--cfui-glow-halo-circle) center / 100% 100% no-repeat;
  mask: var(--cfui-glow-halo-circle) center / 100% 100% no-repeat;
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}
.icon-btn > * { position: relative; z-index: 1; }
.icon-btn .cf-icon { width: 20px; height: 20px; }
.icon-btn:hover {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(150, 220, 255, 0.32);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.icon-btn:hover::before { opacity: 0.55; }
.icon-btn:active { transform: scale(0.92); transition-duration: var(--dur-press); }
.icon-btn.muted { color: rgba(219, 230, 255, 0.4); }
.icon-btn.muted::before { opacity: 0; }

.mute-slash {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 25px;
  height: 2.5px;
  margin: -1.25px 0 0 -12.5px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 2px rgba(9, 12, 24, 0.85);
  transform: rotate(-45deg) scaleX(0.4);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s var(--ease-stamp);
  z-index: 2;
}
.icon-btn.muted .mute-slash { opacity: 1; transform: rotate(-45deg) scaleX(1); }

.level-chip {
  flex: 1;
  text-align: center;
  padding-top: 15px;
  min-width: 0;
}
.level-chip-top {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: rgba(200, 216, 255, 0.74);
  text-transform: uppercase;
}
.level-chip-top b { color: #fff; font-size: 13px; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; }
.hud-right { display: flex; gap: 8px; }

.move-row {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 68px);
  left: 0;
  right: 0;
  z-index: 9;
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.26em;
  color: rgba(190, 206, 250, 0.56);
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.move-row b { color: rgba(235, 243, 255, 0.85); font-weight: 800; font-variant-numeric: tabular-nums; }
.move-row .dot { opacity: 0.55; }
.move-row.hidden { opacity: 0; }

/* ============================== Hint ============================== */

.hint-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  z-index: 10;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.hint-wrap.hidden { opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(10px); transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s linear 0.3s; }

.hint-btn {
  position: relative;
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 13px 26px 13px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 220, 150, 0.30);
  background: linear-gradient(180deg, rgba(255, 236, 190, 0.16), rgba(255, 200, 120, 0.05));
  color: #ffe9b8;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  transition: transform var(--dur-hover) var(--ease-pack), background 0.2s ease, border-color 0.2s ease;
}
/* 金色 halo + 顶部高光:沿用 CleanFlatUI 的圆角按钮发光语言 */
.hint-btn::before {
  content: "";
  position: absolute;
  inset: -13px -8px;
  background-color: #ffcf6e;
  -webkit-mask: var(--cfui-glow-halo-round) center / 100% 100% no-repeat;
  mask: var(--cfui-glow-halo-round) center / 100% 100% no-repeat;
  opacity: 0.34;
  pointer-events: none;
  z-index: -1;
  transition: opacity 0.22s ease;
}
.hint-btn .cf-icon { width: 18px; height: 18px; }
.hint-btn:hover { background: rgba(255, 226, 160, 0.2); border-color: rgba(255, 226, 160, 0.5); }
.hint-btn:hover::before { opacity: 0.6; }
.hint-btn:active { transform: scale(0.95); transition-duration: var(--dur-press); }

/* ============================== Toast ============================== */

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 9px;
  transform: translate(-50%, 12px) scale(0.96);
  max-width: 84%;
  padding: 11px 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(30, 40, 72, 0.96), rgba(13, 18, 36, 0.97));
  border: 1px solid rgba(140, 190, 255, 0.2);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.46),
    0 0 26px rgba(70, 160, 255, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: rgba(226, 238, 255, 0.92);
  font-size: 12.5px;
  line-height: 1.45;
  letter-spacing: 0.02em;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform var(--dur-in) var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.toast-icon {
  width: 17px;
  height: 17px;
  color: var(--cyan);
  -webkit-mask-image: var(--cfui-icon-info);
  mask-image: var(--cfui-icon-info);
}
.toast--alert { border-color: rgba(255, 205, 120, 0.34); }
.toast--alert .toast-icon {
  color: var(--gold);
  -webkit-mask-image: var(--cfui-icon-alert);
  mask-image: var(--cfui-icon-alert);
}
.toast--hint { border-color: rgba(110, 231, 255, 0.34); }
.toast--hint .toast-icon {
  color: var(--cyan);
  -webkit-mask-image: var(--cfui-icon-question);
  mask-image: var(--cfui-icon-question);
}
.toast--lock { border-color: rgba(177, 140, 255, 0.34); }
.toast--lock .toast-icon {
  color: var(--violet);
  -webkit-mask-image: var(--cfui-icon-lock);
  mask-image: var(--cfui-icon-lock);
}
.toast--star { border-color: rgba(255, 215, 106, 0.34); }
.toast--star .toast-icon {
  color: var(--gold);
  -webkit-mask-image: var(--cfui-icon-star);
  mask-image: var(--cfui-icon-star);
}
.toast-msg { min-width: 0; }

/* ============================== Screens ============================== */

.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 30px) 26px calc(env(safe-area-inset-bottom, 0px) + 30px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}
.screen.active { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.35s ease; }

/* ---------- title ---------- */

.title-screen {
  background:
    radial-gradient(ellipse 70% 55% at 50% 34%, rgba(48, 40, 118, 0.34), transparent 68%),
    linear-gradient(180deg, rgba(5, 6, 15, 0.15) 0%, rgba(4, 5, 12, 0.55) 62%, rgba(3, 4, 10, 0.92) 100%);
}
/* 素材包的斜纹 pattern 只做极低透明度的环境纹理,避免抢走星环主体 */
.title-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cfui-pattern-diagonal-stripes) 0 0 / 300px 300px repeat;
  opacity: 0.014;
  pointer-events: none;
}

.title-ambient { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.ambient-glow {
  position: absolute;
  display: block;
  width: min(150vw, 640px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  -webkit-mask: var(--cfui-glow-soft-round) center / contain no-repeat;
  mask: var(--cfui-glow-soft-round) center / contain no-repeat;
  filter: blur(28px);
}
.ambient-a {
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  background-color: #2f8dff;
  opacity: 0.26;
  animation: ambient-drift 9s ease-in-out infinite;
}
.ambient-b {
  left: 58%;
  top: 64%;
  transform: translate(-50%, -50%);
  background-color: #9a5cff;
  opacity: 0.16;
  animation: ambient-drift 12s ease-in-out infinite reverse;
}

.title-deco {
  position: absolute;
  top: 34%;
  left: 50%;
  width: min(84vw, 420px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  opacity: 0.55;
  pointer-events: none;
  filter: drop-shadow(0 0 28px rgba(80, 160, 255, 0.22));
  z-index: 1;
}
.deco-svg { width: 100%; height: 100%; overflow: visible; }
.deco-ring { transform-origin: 200px 200px; transform-box: view-box; }
.deco-a { animation: spin 52s linear infinite; }
.deco-b { animation: spin 38s linear infinite reverse; }
.deco-cyan { filter: drop-shadow(0 0 10px rgba(50, 175, 221, 0.65)); }
@keyframes spin { to { transform: rotate(360deg); } }

.logo-wrap { position: relative; z-index: 2; text-align: center; }
/* 标题后方的圆角柔光(素材包 halo-circle 拉伸成竖向光柱) */
.logo-wrap::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(104vw, 470px);
  height: 150%;
  transform: translate(-50%, -50%);
  background-color: rgba(62, 170, 255, 0.55);
  -webkit-mask: var(--cfui-glow-soft-round) center / 100% 100% no-repeat;
  mask: var(--cfui-glow-soft-round) center / 100% 100% no-repeat;
  opacity: 0.16;
  filter: blur(14px);
  pointer-events: none;
  z-index: -1;
}
.logo-sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.52em;
  color: #8ad8ff;
  margin-bottom: 16px;
  opacity: 0.9;
  text-shadow: 0 0 18px rgba(90, 200, 255, 0.6);
}
.logo {
  margin: 0;
  font-size: clamp(52px, 16.5vw, 86px);
  line-height: 0.87;
  font-weight: 900;
  letter-spacing: 0.045em;
  color: #ffffff;
  text-shadow:
    0 0 26px rgba(120, 180, 255, 0.42),
    0 0 70px rgba(80, 120, 255, 0.28),
    0 8px 0 rgba(20, 30, 70, 0.45);
}
.logo span {
  background: linear-gradient(95deg, #6ee7ff 5%, #b18cff 52%, #ff9ad5 98%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(140, 150, 255, 0.45));
}
/* 直接使用素材包 gradient/blue.png 作为 logo 分隔线渐变 */
.logo-line {
  width: 78px;
  height: 3px;
  margin: 22px auto 0;
  border-radius: 3px;
  background: var(--cfui-gradient-accent) center / 100% 100% no-repeat;
  box-shadow: 0 0 16px rgba(110, 180, 255, 0.55);
}
.tagline {
  margin: 13px 0 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}
.title-actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(300px, 78%);
  margin-top: clamp(28px, 7vh, 52px);
}
.footnote {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  z-index: 2;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(198, 214, 255, 0.52);
}

/* ============================== Buttons ============================== */

.btn-wrap {
  position: relative;
  display: block;
  width: 100%;
  isolation: isolate;
}
/* CleanFlatUI halo-round:按钮外扩散的彩色柔光 */
.btn-halo {
  position: absolute;
  inset: -22% -9%;
  z-index: 0;
  background-color: #3fc2ff;
  -webkit-mask: var(--cfui-glow-halo-round) center / 100% 100% no-repeat;
  mask: var(--cfui-glow-halo-round) center / 100% 100% no-repeat;
  opacity: 0.38;
  filter: blur(6px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s var(--ease-out);
}
.btn-wrap:hover .btn-halo { opacity: 0.72; transform: scale(1.04); }
.btn-auto .btn-halo { animation: halo-pulse 4.4s ease-in-out infinite; }

.primary-btn {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 18px 20px;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #05141f;
  background: linear-gradient(180deg, #a6f4ff 0%, #5dd8fb 44%, #339dff 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.72),
    inset 0 -3px 0 rgba(9, 64, 130, 0.30),
    0 14px 30px -10px rgba(40, 160, 255, 0.55);
  cursor: pointer;
  transition: transform var(--dur-hover) var(--ease-pack), box-shadow 0.2s ease, filter 0.2s ease;
}
/* 顶部高光(扁平按钮的立体感,替代沉重的 drop shadow) */
.primary-btn::before {
  content: "";
  position: absolute;
  inset: 1px 2px 52% 2px;
  border-radius: 999px 999px 45% 45% / 999px 999px 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
  pointer-events: none;
}
/* 素材包 glow_line 拉伸成竖直光束,做 Sweep 扫光 */
.primary-btn::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 58%;
  background-color: rgba(255, 255, 255, 0.85);
  -webkit-mask: var(--cfui-glow-beam-horizontal) center / 100% 100% no-repeat;
  mask: var(--cfui-glow-beam-horizontal) center / 100% 100% no-repeat;
  transform: translateX(-150%);
  opacity: 0;
  pointer-events: none;
}
.btn-auto .primary-btn::after { animation: sweep 4.4s ease-in-out infinite; }
.btn-wrap:hover .primary-btn::after { animation: sweep 0.9s var(--ease-out) both; }
.primary-btn:hover { filter: brightness(1.05); transform: scale(1.02); }
.primary-btn:active { transform: scale(0.965); transition-duration: var(--dur-press); }
.primary-btn:disabled { filter: grayscale(0.5) brightness(0.7); cursor: default; }

.ghost-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 15px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(230, 239, 255, 0.9);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform var(--dur-hover) var(--ease-pack), background 0.2s ease,
    border-color 0.2s ease, box-shadow 0.2s ease;
}
.ghost-btn .cf-icon { width: 16px; height: 16px; opacity: 0.9; }
.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(150, 220, 255, 0.38);
  box-shadow: 0 0 26px rgba(80, 180, 255, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.ghost-btn:active { transform: scale(0.97); transition-duration: var(--dur-press); }

@keyframes halo-pulse {
  0%, 100% { opacity: 0.34; transform: scale(0.99); }
  50% { opacity: 0.62; transform: scale(1.035); }
}
@keyframes sweep {
  0% { transform: translateX(-150%); opacity: 0; }
  18% { opacity: 0.34; }
  72% { opacity: 0.22; }
  100% { transform: translateX(250%); opacity: 0; }
}
@keyframes ambient-drift {
  0%, 100% { opacity: 0.18; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.32; transform: translate(-50%, -52%) scale(1.05); }
}

/* ---------- level select ---------- */

.select-screen {
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 42% at 50% 0%, rgba(42, 44, 110, 0.35), transparent 70%),
    linear-gradient(180deg, rgba(6, 8, 18, 0.93), rgba(5, 6, 13, 0.98));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.select-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--cfui-pattern-diagonal-stripes) 0 0 / 260px 260px repeat;
  opacity: 0.011;
  pointer-events: none;
}
.select-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 440px;
  max-height: calc(100% - 24px);
  flex: 0 1 auto;
}
.select-head {
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: 18px;
  flex: 0 0 auto;
}
.select-head h2 {
  flex: 1;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  text-align: center;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #eef4ff;
}
.head-icon {
  width: 16px;
  height: 16px;
  color: rgba(130, 214, 255, 0.9);
  filter: drop-shadow(0 0 8px rgba(90, 200, 255, 0.5));
}
.head-spacer { width: 46px; }

.chapter-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin: -8px 0 12px;
  flex: 0 0 auto;
}
.chapter-nav #select-chapter {
  min-width: 132px;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: rgba(190, 206, 250, 0.74);
  white-space: nowrap;
}
.chapter-nav .icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  opacity: 0.9;
}
.chapter-nav .icon-btn .cf-icon { width: 17px; height: 17px; }
.chapter-nav .icon-btn:disabled { opacity: 0.22; pointer-events: none; }

.hidden { display: none !important; }

.level-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 440px;
  overflow-y: auto;
  padding: 2px 2px 8px;
  flex: 0 1 auto;
  margin: 0;
  max-height: none;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.level-grid::-webkit-scrollbar { display: none; width: 0; height: 0; }

.lv-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 10px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.028));
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--dur-hover) var(--ease-pack), border-color 0.2s ease,
    background 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.lv-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.2);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04));
  box-shadow:
    0 10px 24px -12px rgba(0, 0, 0, 0.7),
    0 0 26px -8px var(--lv-color, rgba(110, 210, 255, 0.5));
}
.lv-tile:active { transform: scale(0.975); transition-duration: var(--dur-press); }
/* 状态角标:素材包 glyph 图标(mask 着色) */
.lv-tile::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  background-color: currentColor;
  -webkit-mask: var(--cfui-icon-lock) center / contain no-repeat;
  mask: var(--cfui-icon-lock) center / contain no-repeat;
  opacity: 0;
  pointer-events: none;
}
.lv-tile.locked { opacity: 0.55; filter: saturate(0.55) brightness(0.85); }
.lv-tile.locked::after { opacity: 0.5; color: rgba(205, 218, 255, 0.7); }
.lv-tile.locked .lv-title { color: rgba(220, 230, 255, 0.62); }
.lv-tile.locked .lv-badge {
  color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 4px 10px -4px rgba(0, 0, 0, 0.5);
}
.lv-tile.clear-mark::after {
  opacity: 0.62;
  color: var(--cyan);
  -webkit-mask-image: var(--cfui-icon-check);
  mask-image: var(--cfui-icon-check);
}
.lv-tile.current {
  border-color: rgba(110, 231, 255, 0.55);
  background: linear-gradient(180deg, rgba(90, 220, 255, 0.16), rgba(60, 140, 255, 0.06));
  box-shadow:
    0 0 0 1px rgba(110, 231, 255, 0.2),
    0 12px 30px -12px rgba(50, 170, 255, 0.55),
    0 0 30px rgba(80, 200, 255, 0.16);
}

.lv-badge {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 900;
  color: #071019;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 0 rgba(0, 0, 0, 0.16),
    0 5px 14px -4px rgba(0, 0, 0, 0.45),
    0 0 16px -6px var(--lv-color, transparent);
}
.lv-meta { min-width: 0; flex: 1; overflow: hidden; padding-right: 14px; }
.lv-title {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.015em;
  color: rgba(234, 242, 255, 0.92);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lv-best {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255, 200, 80, 0.45);
  min-height: 12px;
}
.lv-best::before {
  content: "";
  width: 9px;
  height: 9px;
  background-color: currentColor;
  -webkit-mask: var(--cfui-icon-star) center / contain no-repeat;
  mask: var(--cfui-icon-star) center / contain no-repeat;
}
.lv-tile.locked .lv-best { display: none; }

/* 通关进度条(CleanFlatUI ProgressBar 语言:圆角轨道 + 渐变填充 + 末端光点) */
.select-progress {
  width: 100%;
  max-width: 440px;
  margin-top: 12px;
  flex: 0 0 auto;
}
.select-progress-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(190, 206, 250, 0.66);
}
.select-progress-top b { color: #fff; font-size: 12px; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.select-progress-top .dim { color: rgba(190, 206, 250, 0.5); }
.select-best b { color: var(--gold); text-shadow: 0 0 12px rgba(255, 200, 80, 0.45); }
.progress-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.10);
  overflow: hidden;
}
.progress-fill {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--cfui-gradient-accent) center / 100% 100% no-repeat;
  box-shadow: 0 0 14px rgba(90, 190, 255, 0.6);
  transition: width var(--dur-in) var(--ease-pack);
}
.progress-fill::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  transform: translate(35%, -50%);
  background: #e7fbff;
  box-shadow: 0 0 10px 2px rgba(120, 220, 255, 0.8);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.progress-fill.has-progress::after { opacity: 0.95; }

#btn-unlock-all {
  width: auto;
  margin-top: 12px;
  padding: 10px 18px;
  font-size: 10px;
  flex: 0 0 auto;
}

/* ---------- win modal ---------- */

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background: rgba(3, 5, 12, 0.66);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.26s ease, visibility 0s linear 0.26s;
}
.modal-backdrop.show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.26s ease; }

.win-card {
  position: relative;
  width: min(364px, 100%);
  border-radius: 28px;
  padding: 26px 22px 20px;
  background: linear-gradient(168deg, rgba(34, 42, 78, 0.97), rgba(11, 15, 30, 0.99));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.66),
    0 0 70px rgba(60, 140, 255, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  overflow: hidden;
  opacity: 0;
  transform: scale(1.12);
  transition: transform var(--dur-in) var(--ease-pack), opacity 0.18s var(--ease-out);
}
.modal-backdrop.show .win-card { opacity: 1; transform: scale(1); }

/* 素材包 gradient/blue.png 作为弹窗顶部 accent 条 */
.win-accent {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--cfui-gradient-accent) center / 100% 100% no-repeat;
  box-shadow: 0 0 18px rgba(90, 190, 255, 0.55);
}
/* 素材包 soft-round 柔光做弹窗顶部 aura */
.win-aura {
  position: absolute;
  left: 50%;
  top: -42%;
  width: 160%;
  aspect-ratio: 1;
  transform: translateX(-50%);
  background-color: rgba(80, 190, 255, 0.6);
  -webkit-mask: var(--cfui-glow-soft-round) center / contain no-repeat;
  mask: var(--cfui-glow-soft-round) center / contain no-repeat;
  opacity: 0.34;
  filter: blur(6px);
  pointer-events: none;
}

.win-badge {
  position: relative;
  width: 54px;
  height: 54px;
  margin: 2px auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #a6f4ff 0%, #55d2fa 46%, #339dff 100%);
  color: #062033;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -3px 0 rgba(9, 64, 130, 0.28),
    0 10px 24px -8px rgba(60, 190, 255, 0.7);
  isolation: isolate;
}
.win-badge-halo {
  position: absolute;
  inset: -20px;
  z-index: -1;
  background-color: #5fd8ff;
  -webkit-mask: var(--cfui-glow-halo-circle) center / 100% 100% no-repeat;
  mask: var(--cfui-glow-halo-circle) center / 100% 100% no-repeat;
  opacity: 0.55;
  animation: halo-pulse 3.8s ease-in-out infinite;
}
.win-badge .cf-icon { width: 26px; height: 26px; }
.modal-backdrop.show .win-badge { animation: cfui-pop var(--dur-in) var(--ease-out) both; }
@keyframes cfui-pop {
  0% { transform: scale(0.2); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.win-kicker {
  position: relative;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.34em;
  color: #7fd4ff;
  text-transform: uppercase;
  margin-bottom: 5px;
}
.win-title {
  position: relative;
  margin: 0 0 14px;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #fff;
  text-shadow: 0 0 26px rgba(120, 200, 255, 0.45);
}
.win-score-row {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 16px;
}
/* 分数背后的金色柔光 */
.win-score-row::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 42%;
  width: 230px;
  height: 150px;
  transform: translate(-50%, -50%);
  background-color: rgba(255, 198, 78, 0.5);
  -webkit-mask: var(--cfui-glow-soft-round) center / 100% 100% no-repeat;
  mask: var(--cfui-glow-soft-round) center / 100% 100% no-repeat;
  opacity: 0.34;
  filter: blur(6px);
  pointer-events: none;
}
.win-score {
  position: relative;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(255, 198, 70, 0.55);
}
.win-score-row small {
  position: relative;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: rgba(200, 215, 255, 0.64);
}
.win-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.win-stats > div {
  padding: 10px 4px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.win-stats span {
  display: block;
  font-size: 19px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.win-stats small {
  display: block;
  margin-top: 2px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: rgba(200, 215, 255, 0.62);
}
.win-row { display: flex; gap: 10px; margin-top: 10px; }
.win-row .ghost-btn { flex: 1 1 0; width: auto; }
.win-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 15px;
  margin-top: 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--gold);
  text-transform: uppercase;
}
.win-foot::before {
  content: "";
  width: 11px;
  height: 11px;
  background-color: currentColor;
  -webkit-mask: var(--cfui-icon-star) center / contain no-repeat;
  mask: var(--cfui-icon-star) center / contain no-repeat;
  opacity: 0.85;
}
.win-foot:empty { min-height: 0; margin-top: 0; }
.win-foot:empty::before { display: none; }

/* ---------- fade ---------- */
.screen-fade {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #05060d;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease;
}
.screen-fade.show { opacity: 1; pointer-events: auto; }

/* ---------- keyboard focus ---------- */
button:focus-visible {
  outline: 2px solid rgba(120, 220, 255, 0.85);
  outline-offset: 3px;
}

/* ---------- small screens ---------- */
@media (max-height: 680px) {
  .logo { font-size: clamp(46px, 14vw, 70px); }
  .tagline { font-size: 12px; }
  .title-actions { margin-top: 26px; gap: 10px; }
  .primary-btn { padding: 15px 18px; font-size: 16px; }
  .deco-svg { transform: scale(0.86); }
  .win-card { padding: 20px 20px 16px; }
  .win-badge { width: 46px; height: 46px; margin-bottom: 9px; }
  .win-badge .cf-icon { width: 22px; height: 22px; }
  .win-title { font-size: 25px; margin-bottom: 10px; }
  .win-score { font-size: 36px; }
  .win-score-row { margin-bottom: 12px; }
  .win-stats { margin-bottom: 14px; }
  .win-foot { margin-top: 8px; }
  .lv-tile { padding: 8px 9px; }
  .lv-badge { width: 31px; height: 31px; font-size: 15px; }
  .select-head { margin-bottom: 12px; }
  .chapter-nav { margin-bottom: 8px; }
}
@media (max-width: 360px) {
  .icon-btn { width: 42px; height: 42px; }
  .hint-btn { padding: 12px 22px 12px 18px; }
  .level-chip { padding-top: 13px; }
  .move-row { top: calc(env(safe-area-inset-top, 0px) + 64px); }
  .lv-tile { gap: 8px; }
  .lv-title { font-size: 11px; }
  .chapter-nav #select-chapter { min-width: 118px; font-size: 9.5px; }
}

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