/* ============================================================
   雲笈物語 Cloudscroll Tales — 门户全站样式
   深色古风：暗夜底 + 金色萤火 + 中文衬线（延续 legacy-demo 主菜单审美）
   移动端 375px 优先；触控目标 >= 44px；封面 3:4
   ============================================================ */

:root {
  --bg: #0e1020;
  --bg-soft: #151832;
  --panel: rgba(21, 24, 50, 0.78);
  --panel-solid: #171a36;
  --line: rgba(255, 202, 40, 0.18);
  --line-strong: rgba(255, 202, 40, 0.45);
  --gold: #ffca28;
  --gold-dim: #c9a227;
  --text: #ece6d6;
  --muted: #a49dae;
  --danger: #ff8a80;
  --ok: #a5d6a7;
  --serif: "Noto Serif TC", "Noto Serif SC", "Source Han Serif TC",
    "Source Han Serif SC", "Songti TC", "SimSun", "PMingLiU", Georgia, serif;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--serif);
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% -10%, #232a5e 0%, transparent 55%),
    radial-gradient(ellipse at 85% 110%, #2a1a3e 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.7;
  letter-spacing: 0.02em;
}

img { max-width: 100%; display: block; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 电影级暗角 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, transparent 45%, rgba(0, 0, 0, 0.55) 130%);
  z-index: 0;
}
.site-header, .site-main, .site-footer { position: relative; z-index: 1; }

/* ---------- 萤火粒子 ---------- */
#fireflies {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.firefly {
  position: absolute;
  bottom: -20px;
  width: 4px;
  height: 4px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 12px 3px rgba(255, 202, 40, 0.85);
  opacity: 0;
  animation: floatUp 9s linear infinite, flicker 2.2s ease-in-out infinite alternate;
}
@keyframes floatUp {
  0% { transform: translateY(0) translateX(0); }
  100% { transform: translateY(-105vh) translateX(48px); }
}
@keyframes flicker {
  0% { opacity: 0.15; transform: scale(0.8); }
  100% { opacity: 0.9; transform: scale(1.2); }
}
@media (prefers-reduced-motion: reduce) {
  .firefly { animation: none; opacity: 0.25; }
}

/* ---------- 页头 ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 12, 26, 0.72);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  align-items: center;
}
.brand a { text-decoration: none; }
.brand-zh {
  font-size: 1.35rem;
  color: var(--gold);
  letter-spacing: 0.35em;
  text-shadow: 0 0 18px rgba(255, 202, 40, 0.35);
  white-space: nowrap;
}
.brand-en {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}
.site-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--text);
  font-size: 0.95rem;
}
.site-nav a:hover { color: var(--gold); text-decoration: none; }
.lang-select {
  min-height: 44px;
  padding: 6px 10px;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.lang-select:focus { outline: none; border-color: var(--line-strong); }

/* ---------- 主体 ---------- */
.site-main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

.section-title {
  font-size: 1.15rem;
  color: var(--gold);
  letter-spacing: 0.25em;
  margin: 34px 0 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.section-title::before,
.section-title::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

/* ---------- 主推 banner ---------- */
.featured-banner {
  position: relative;
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  min-height: 300px;
  text-decoration: none;
}
.featured-banner:hover { text-decoration: none; }
.featured-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1);
  transition: transform 8s ease;
}
.featured-banner:hover .featured-bg { transform: scale(1.06); }
.featured-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 12, 26, 0.15) 0%, rgba(10, 12, 26, 0.9) 85%);
}
.featured-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 300px;
  padding: 22px 20px;
}
.featured-label {
  color: var(--gold);
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 12px;
  align-self: flex-start;
  background: rgba(10, 12, 26, 0.6);
}
.featured-title {
  margin: 12px 0 4px;
  font-size: 2rem;
  color: var(--gold);
  letter-spacing: 0.22em;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.9), 0 0 24px rgba(255, 202, 40, 0.35);
}
.featured-tagline { color: var(--text); font-size: 1rem; margin: 0 0 14px; }
.featured-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 游戏卡片网格 ---------- */
.games-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.game-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, border-color 0.25s ease;
  text-decoration: none;
  color: var(--text);
  min-height: 44px;
}
.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  text-decoration: none;
}
.card-cover {
  aspect-ratio: 3 / 4;           /* 封面统一 3:4 */
  width: 100%;
  object-fit: cover;
  background: var(--bg-soft);
}
.card-body { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-size: 1.05rem; color: var(--gold); letter-spacing: 0.12em; margin: 0; }
.card-tagline {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge-free { color: var(--ok); border-color: rgba(165, 214, 167, 0.4); }
.badge-gold { color: var(--gold); border-color: var(--line-strong); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 22px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(255, 202, 40, 0.16), rgba(255, 202, 40, 0.05));
  color: var(--gold);
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover {
  text-decoration: none;
  transform: translateY(-2px);
  filter: brightness(1.15);
  box-shadow: 0 6px 18px rgba(255, 202, 40, 0.25);
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, #ffca28, #d9a413);
  color: #241a02;
  font-weight: bold;
  border-color: transparent;
}
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-block { width: 100%; }

/* ---------- 详情页 ---------- */
.game-hero { display: flex; flex-direction: column; gap: 18px; margin-top: 8px; }
.game-cover-wrap {
  align-self: center;
  width: min(62vw, 300px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow), 0 0 40px rgba(255, 202, 40, 0.12);
}
.game-cover-wrap img { aspect-ratio: 3 / 4; object-fit: cover; width: 100%; }
.game-head { text-align: center; }
.game-title {
  font-size: 1.9rem;
  color: var(--gold);
  letter-spacing: 0.25em;
  margin: 0 0 6px;
  text-shadow: 0 0 22px rgba(255, 202, 40, 0.3);
}
.game-tagline { color: var(--muted); font-size: 1rem; margin: 0 0 10px; }
.game-tags { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.game-desc {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px;
  font-size: 0.98rem;
}
.game-desc p { margin: 0 0 1em; }
.game-desc p:last-child { margin-bottom: 0; }
.game-actions { display: flex; flex-direction: column; gap: 10px; }
.game-actions .redeem-link { text-align: center; font-size: 0.92rem; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.game-meta-line { text-align: center; color: var(--muted); font-size: 0.85rem; }

.char-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.char-item {
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 6px;
}
.char-portrait {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top;
  border-radius: 8px;
  background: var(--bg-soft);
}
.char-name { margin-top: 8px; font-size: 0.88rem; color: var(--gold); letter-spacing: 0.08em; }

.shots-row { display: grid; grid-template-columns: 1fr; gap: 12px; }
.shots-row img {
  width: 100%;
  aspect-ratio: 16 / 9;         /* 截图统一 16:9 */
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

/* ---------- 面板 / 表单（账户、兑换） ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 18px;
  margin: 18px 0;
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: var(--gold);
  letter-spacing: 0.15em;
}
.panel .hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 14px; }

.form-row { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.input {
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--line-strong); }
.input::placeholder { color: rgba(164, 157, 174, 0.6); }

.msg { border-radius: 10px; padding: 12px 14px; font-size: 0.92rem; margin: 10px 0; display: none; }
.msg.show { display: block; }
.msg-error { background: rgba(255, 138, 128, 0.1); border: 1px solid rgba(255, 138, 128, 0.4); color: var(--danger); }
.msg-ok { background: rgba(165, 214, 167, 0.1); border: 1px solid rgba(165, 214, 167, 0.4); color: var(--ok); }
.msg-info { background: rgba(255, 202, 40, 0.08); border: 1px solid var(--line); color: var(--text); }

/* 降级状态（后端未开通） */
.offline-notice {
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 202, 40, 0.05);
  padding: 34px 20px;
  margin: 24px 0;
}
.offline-notice .offline-icon { font-size: 2rem; margin-bottom: 8px; }
.offline-notice h2 { color: var(--gold); letter-spacing: 0.2em; margin: 0 0 10px; font-size: 1.25rem; }
.offline-notice p { color: var(--muted); max-width: 560px; margin: 0 auto 18px; }
.offline-notice .offline-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }

/* 游戏库列表 */
.lib-list { display: flex; flex-direction: column; gap: 12px; }
.lib-item {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.lib-cover { width: 66px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.lib-info { flex: 1; min-width: 0; }
.lib-title { color: var(--gold); font-size: 1rem; margin: 0 0 4px; letter-spacing: 0.08em; }
.lib-chapters { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 静态页 ---------- */
.static-page { max-width: 760px; margin: 0 auto; }
.static-page h1 {
  color: var(--gold);
  letter-spacing: 0.25em;
  font-size: 1.6rem;
  text-align: center;
  margin: 26px 0 6px;
}
.static-page .page-sub { text-align: center; color: var(--muted); font-size: 0.88rem; margin: 0 0 24px; }
.static-page h2 { color: var(--gold); font-size: 1.12rem; letter-spacing: 0.12em; margin: 28px 0 8px; }
.static-page p, .static-page li { color: var(--text); font-size: 0.95rem; }
.static-page .placeholder-note {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 20px;
}
.lang-block { display: none; }
.lang-block.active { display: block; }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 26px 16px 34px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: rgba(10, 12, 26, 0.6);
}
.footer-links { display: flex; justify-content: center; gap: 4px 18px; flex-wrap: wrap; margin-bottom: 10px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }
.footer-links a:hover { color: var(--gold); }
.footer-ai-note { margin: 4px 0; font-size: 0.78rem; opacity: 0.85; }
.footer-lang { margin-top: 10px; }

.loading-hint { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- >= 640px ---------- */
@media (min-width: 640px) {
  .games-grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
  .featured-content { min-height: 360px; padding: 30px 32px; }
  .featured-title { font-size: 2.6rem; }
  .game-hero { flex-direction: row; align-items: flex-start; }
  .game-cover-wrap { width: 280px; flex-shrink: 0; }
  .game-head { text-align: left; }
  .game-tags { justify-content: flex-start; }
  .game-hero-right { flex: 1; display: flex; flex-direction: column; gap: 14px; }
  .game-actions { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .game-meta-line { text-align: left; }
  .shots-row { grid-template-columns: 1fr 1fr; }
  .offline-notice .offline-actions { flex-direction: row; justify-content: center; }
  .form-row { flex-direction: row; }
  .form-row .input { flex: 1; }
}

/* ---------- >= 960px ---------- */
@media (min-width: 960px) {
  .games-grid { grid-template-columns: repeat(4, 1fr); }
  .featured-title { font-size: 3rem; }
}
