/* ==========================================================================
   game_landing · 公共基础样式
   --------------------------------------------------------------------------
   这里只放「所有落地页共用」的东西：变量、reset、多语言字体栈、RTL 适配、
   语言切换器，以及一组通用组件类（.gl-*）。游戏专属视觉放各页自己的 <style>。

   全部用 CSS 逻辑属性（padding-inline / margin-inline-start / inset-inline），
   阿拉伯语 RTL 不用写第二套样式，只靠 <html dir="rtl"> 自动镜像。
   用 physical 属性（left/right）会破坏 RTL，除非确实需要，否则别用。
   ========================================================================== */

/* --------------------------------------------------------------- 设计变量 */
:root {
  --gl-bg: #0a0b14;
  --gl-bg-2: #11131f;
  --gl-surface: #171a29;
  --gl-line: #262a3d;
  --gl-ink: #f4f5fb;
  --gl-ink-2: #b9bed2;
  --gl-muted: #7d8399;
  --gl-brand: #6d5cff;
  --gl-brand-ink: #ffffff;
  --gl-accent: #ff4d8d;
  --gl-ok: #35d39a;

  --gl-radius: 16px;
  --gl-radius-lg: 24px;
  --gl-maxw: 480px;
  --gl-tap: 48px;          /* 最小可点区域，移动端不要低于这个值 */
  /* 页边距把刘海/圆角的横屏安全区算进去。env() 不支持时回退 0，max() 取到 20px。 */
  --gl-gutter: max(20px, env(safe-area-inset-left), env(safe-area-inset-right));

  --gl-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 窄屏（≤360px，含 320px 的老机型）收紧页边距，把宽度让给顶栏。
   顶栏要同时放「品牌名 + 130px 语言切换器」，20px 页边距在这里太奢侈。 */
@media (max-width: 360px) {
  :root {
    --gl-gutter: max(14px, env(safe-area-inset-left), env(safe-area-inset-right));
  }
}

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

html {
  background: var(--gl-bg);
  /* iOS 横屏会自行放大正文，版式跑掉；锁住。 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* 去掉 iOS 点击时的系统灰色闪块，改用下面的 :active 品牌反馈。 */
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  /* 这里原来有 min-width: 320px，已删除。
     它会让内容在视口窄于 320px 时【宽于视口】：比如 320px 的窗口，
     竖向滚动条占掉 15px 后可见宽度只有 305px，而 body 仍被撑到 320px
     —— 于是「宽度超出 100%」，底部冒出横向滚动条（或内容被裁掉）。
     本页布局本来就是全流式的（.gl-page 是 min(100%,480px)、字号用 clamp()、
     网格用 minmax(0,1fr)），不需要这个下限。 */
  overflow-x: hidden;
  background: var(--gl-bg);
  color: var(--gl-ink);
  font-family: var(--gl-font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, video { display: block; max-width: 100%; }
img { object-fit: contain; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

a { color: inherit; }

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }

:focus-visible { outline: 3px solid var(--gl-brand); outline-offset: 3px; border-radius: 6px; }

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

/* --------------------------------------------------- 多语言字体与行高适配 */
/* 各语系默认字体不覆盖拉丁文，所以按 :lang() 精确指定，避免影响英文渲染。 */
:lang(ja)      { font-family: "Hiragino Sans", "Yu Gothic", Meiryo, "Noto Sans JP", var(--gl-font); }
:lang(ko)      { font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", var(--gl-font); }
:lang(th)      { font-family: Thonburi, "Leelawadee UI", "Noto Sans Thai", var(--gl-font); }
:lang(ar)      { font-family: "Geeza Pro", "Segoe UI", "Noto Naskh Arabic", var(--gl-font); }
:lang(zh-Hant) { font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", var(--gl-font); }
:lang(ru)      { font-family: "Helvetica Neue", "PT Sans", var(--gl-font); }

/* 泰文上下延展、阿拉伯语连写都需要更大行高，否则会挤在一起 */
:lang(th) body, :lang(th) .gl-title { line-height: 1.75; }
:lang(ar) body { line-height: 1.8; }
:lang(ja) body, :lang(ko) body { line-height: 1.65; }

/* 德语/俄语单词长，标题容易溢出；给这些语言收紧字号 */
:lang(de) .gl-title, :lang(ru) .gl-title { font-size: clamp(26px, 7.4vw, 34px); }

/* 阿拉伯语数字与拉丁字母混排时保持数字 LTR */
[dir="rtl"] .gl-num { direction: ltr; unicode-bidi: embed; }

/* ------------------------------------------------------------- 页面骨架 */
.gl-page {
  width: min(100%, var(--gl-maxw));
  margin-inline: auto;
  padding-block-end: calc(var(--gl-tap) + 32px);
  position: relative;
}

.gl-topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding-inline: var(--gl-gutter);
  /* 必须先给一条普通 rgba 回退：iOS < 16.2 不认 color-mix()，整条声明会被丢弃，
     吸顶栏就变成全透明，滚动时文字直接压在内容上。顺序不能反。 */
  background: rgb(10 11 20 / 92%);
  background: color-mix(in srgb, var(--gl-bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-block-end: 1px solid var(--gl-line);
}

.gl-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
  min-width: 0;
}
.gl-brand img, .gl-brand .gl-brand-mark { flex: none; }
.gl-brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--gl-brand), var(--gl-accent));
  font-size: 18px; font-weight: 900;
}
.gl-brand-name {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gl-section {
  padding-inline: var(--gl-gutter);
  margin-block-start: 56px;
}
.gl-section > h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-block-end: 18px;
}

/* --------------------------------------------------------- 语言切换器 */
/* 刻意不用原生 <select>：它的选项列表样式完全由系统接管，手机上就是一行行小字号
   系统列表，读不清也点不准（下拉列表没法用 CSS 控制）。
   改成底部弹层：每行 52px、主文字 16px，拇指够得着。 */
.lang-switcher { flex: none; }

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  /* 顶栏宽度要和品牌名分，钉一个上限防止长语言名把品牌挤掉 */
  max-width: 44vw;
  padding: 0 11px;
  border: 1px solid var(--gl-line);
  border-radius: 999px;
  background: var(--gl-surface);
  color: var(--gl-ink-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.lang-trigger:hover { color: var(--gl-ink); border-color: #3a3f58; }
.lang-trigger:active { transform: scale(0.97); }
.lang-trigger:focus-visible { outline: 2px solid var(--gl-brand); outline-offset: 2px; }

.lang-trigger__globe,
.lang-trigger__chev { display: inline-flex; flex: none; }
.lang-trigger__globe { opacity: 0.7; }
.lang-trigger__globe svg { width: 15px; height: 15px; }
.lang-trigger__chev { opacity: 0.6; }
.lang-trigger__chev svg { width: 9px; height: 6px; }

.lang-trigger__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 弹层本体：挂在 body 下，不受 .gl-page 的 overflow 裁切 */
.lang-sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.lang-sheet[hidden] { display: none; }

.lang-sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(4 5 10 / 64%);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.lang-sheet__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--gl-maxw);
  max-height: 82vh;
  padding-block: 8px calc(8px + env(safe-area-inset-bottom, 0px));
  border-block-start: 1px solid var(--gl-line);
  border-radius: var(--gl-radius-lg) var(--gl-radius-lg) 0 0;
  background: var(--gl-bg-2);
  box-shadow: 0 -18px 50px rgb(0 0 0 / 55%);
  transform: translateY(100%);
  transition: transform 0.26s cubic-bezier(0.22, 0.8, 0.3, 1);
}
.lang-sheet.is-open .lang-sheet__backdrop { opacity: 1; }
.lang-sheet.is-open .lang-sheet__panel { transform: translateY(0); }

.lang-sheet__title {
  margin: 6px 0 4px;
  padding-inline: var(--gl-gutter);
  color: var(--gl-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lang-sheet__list {
  margin: 0;
  padding: 0 8px 6px;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.lang-sheet__item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding-inline: 12px;
  border-radius: 12px;
  cursor: pointer;
}
.lang-sheet__item:active { background: var(--gl-surface); }
.lang-sheet__item[aria-selected="true"] { background: var(--gl-surface); }
.lang-sheet__item:focus-visible { outline: 2px solid var(--gl-brand); outline-offset: -2px; }
/* 触屏打开弹层时，初始 focus 是代码给的，不该画焦点环（会跟选中态的背景和勾打架）。
   用户一旦按键，i18n.js 会移除这个类，键盘焦点环照常显示。 */
.lang-sheet--pointer .lang-sheet__item:focus-visible { outline: none; }

.lang-sheet__native { color: var(--gl-ink); font-size: 16px; font-weight: 600; }
/* 英文名推到右边做参照，方便不认识原生名的用户找语言 */
.lang-sheet__en { margin-inline-start: auto; color: var(--gl-muted); font-size: 12px; }

.lang-sheet__tick { display: inline-flex; flex: none; width: 16px; color: var(--gl-brand); opacity: 0; }
.lang-sheet__tick svg { width: 16px; height: 12px; }
.lang-sheet__item[aria-selected="true"] .lang-sheet__tick { opacity: 1; }

/* 弹层打开时锁住页面滚动，否则背景会跟着滑 */
body.lang-sheet-open { overflow: hidden; }

/* 桌面端居中成一张卡片，比贴底更像样 */
@media (min-width: 640px) {
  .lang-sheet { align-items: center; }
  .lang-sheet__panel {
    max-width: 396px;
    max-height: 70vh;
    border: 1px solid var(--gl-line);
    border-radius: var(--gl-radius-lg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lang-sheet__backdrop,
  .lang-sheet__panel { transition: none; }
}

/* --------------------------------------------------------------- 组件 */
.gl-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--gl-tap);
  padding-inline: 20px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gl-brand), #8a6bff);
  color: var(--gl-brand-ink);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-decoration: none;
  box-shadow: 0 10px 26px rgb(109 92 255 / 32%);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
/* hover 只在真有指针的设备上生效：触屏上 :hover 会「粘」在最后一次点击的元素上，
   导致按钮看起来一直处于悬停态。 */
@media (hover: hover) and (pointer: fine) {
  .gl-cta:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgb(109 92 255 / 40%); }
}
/* 触屏的即时反馈靠 :active —— 手指按下就缩一点，这是 iOS 上唯一有效的点击反馈 */
.gl-cta:active { transform: scale(0.975); box-shadow: 0 6px 16px rgb(109 92 255 / 28%); }

.gl-cta--ghost {
  background: transparent;
  border: 1px solid var(--gl-line);
  color: var(--gl-ink);
  box-shadow: none;
}

.gl-cards { display: grid; gap: 12px; }

.gl-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px solid var(--gl-line);
  border-radius: var(--gl-radius);
  background: var(--gl-surface);
}
.gl-card strong { font-size: 16px; font-weight: 800; }
.gl-card p { color: var(--gl-ink-2); font-size: 14px; }

.gl-trust {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-inline: var(--gl-gutter);
  margin-block-start: 24px;
}
.gl-trust > div {
  display: grid;
  gap: 2px;
  padding: 12px 8px;
  border: 1px solid var(--gl-line);
  border-radius: 12px;
  background: var(--gl-bg-2);
  text-align: center;
}
.gl-trust b {
  font-size: 15px;
  font-weight: 800;
  overflow-wrap: break-word;
}
/* 三列在 320px 上每格只有 ~76px 可用。德语 "Dinosaurierarten"、俄语
   "Бесплатно" 这类长词会顶破格子（实测溢出 3–5px）。
   hyphens 优先按语言连字符断词（html lang 已经设了），
   overflow-wrap 兜底，保证任何语言都不会溢出。 */
.gl-trust span {
  color: var(--gl-muted);
  font-size: 11px;
  line-height: 1.35;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}

/* 320–360px 三列每格只剩 ~78px 内容宽，15px 粗体的长词（俄语 "Бесплатно"
   约 78px）会顶破格子。这里收一档字号和内边距，比断词好看。
   iPhone 最窄也有 375px，这段只影响安卓的窄机型。 */
@media (max-width: 360px) {
  .gl-trust > div { padding: 11px 6px; }
  .gl-trust b { font-size: 13.5px; }
}

.gl-faq { display: grid; gap: 10px; }
.gl-faq details {
  border: 1px solid var(--gl-line);
  border-radius: 12px;
  background: var(--gl-surface);
  padding: 14px 16px;
}
.gl-faq summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  list-style: none;
}
.gl-faq summary::-webkit-details-marker { display: none; }
.gl-faq summary::after {
  content: "+";
  float: inline-end;
  color: var(--gl-muted);
  font-weight: 800;
}
.gl-faq details[open] summary::after { content: "–"; }
.gl-faq p { margin-block-start: 10px; color: var(--gl-ink-2); font-size: 14px; }

/* ------------------------------------------------------ 广告声明（合规） */
/* 页脚两条广告声明要「看得见但不抢转化」，所以给一个克制的边框块，
   而不是混在一堆灰字里 —— 广告审核和搜索引擎要能明确读到这是第三方广告页。
   不要用 display:none / 字号小于 11px / 需要交互才展开。 */
.gl-disclaimer {
  display: grid;
  gap: 8px;
  margin-block-end: 18px;
  padding: 14px 16px;
  border: 1px solid var(--gl-line);
  border-radius: 12px;
  background: var(--gl-bg-2);
  color: var(--gl-muted);
  font-size: 12px;
  line-height: 1.65;
}
.gl-disclaimer p { margin: 0; }

.gl-footer {
  margin-block-start: 56px;
  padding-inline: var(--gl-gutter);
  padding-block-end: 24px;
  color: var(--gl-muted);
  font-size: 12px;
  line-height: 1.6;
}
.gl-footer p + p { margin-block-start: 10px; }

/* 移动端常驻底部 CTA —— 转化率关键位，桌面端隐藏 */
.gl-sticky-cta {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  z-index: 30;
  display: none;
  padding: 10px var(--gl-gutter) calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--gl-bg) 65%, transparent);
}
.gl-sticky-cta .gl-cta { box-shadow: 0 8px 24px rgb(0 0 0 / 45%); }

/* 主 CTA 还在视口里时藏起来（由 js/ui.js 切换）。
   两个一样的按钮同时可见会被当成排版错误。选择器权重够压过上面的 media 块。 */
.gl-sticky-cta.is-hidden { display: none; }

@media (max-width: 560px) {
  .gl-sticky-cta { display: block; }
  /* 常驻 CTA 会盖住页脚，多留出空间 */
  .gl-page { padding-block-end: 96px; }
}

/* 语言相关的可见性钩子：某些文案只对特定语言出现时用 */
[hidden] { display: none !important; }
