/* ============================================================
   PageGames 主样式
   设计目标：深色主题、移动优先、零依赖（无框架无字体外链）
   ============================================================ */

:root {
  --bg: #0f1117;
  --bg-elev: #171a23;
  --bg-elev-2: #1f2330;
  --border: #2a2f3d;
  --text: #e8eaf0;
  --text-dim: #9aa3b8;
  --accent: #6c8cff;
  --accent-hover: #8aa2ff;
  --accent-soft: rgba(108, 140, 255, 0.14);
  --success: #4ade80;
  --warn: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  --header-h: 56px;
  --maxw: 1200px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* ---------- 页头 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--header-h);
  padding: 0 16px;
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
}

.brand__mark { font-size: 20px; }

.site-nav {
  display: flex;
  gap: 16px;
  font-size: 14px;
  color: var(--text-dim);
}

.site-nav a:hover { color: var(--text); }

.site-header__membership {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- 主区 ---------- */
.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 32px 0 24px;
}

.hero__title {
  margin: 0;
  font-size: clamp(28px, 6vw, 44px);
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 30%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero__tagline {
  margin: 8px 0 0;
  color: var(--text-dim);
  font-size: 16px;
}

.hero__count {
  margin: 12px 0 0;
  font-size: 14px;
  color: var(--text-dim);
}

.hero__count strong { color: var(--accent); }

/* ---------- 搜索与筛选 ---------- */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.controls__search input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}

.controls__search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.controls__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 5px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
}

.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* ---------- 游戏网格 ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.card__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--bg-elev-2), var(--accent-soft));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card__badges {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
}

.card__body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.card__desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
  /* 最多两行，超出省略，保证卡片高度一致 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__meta {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.badge--member {
  background: rgba(251, 191, 36, 0.15);
  border-color: var(--warn);
  color: var(--warn);
}

.badge--soon {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.badge--muted { opacity: 0.8; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 7px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover { border-color: var(--accent); color: var(--accent-hover); }
.btn--sm { padding: 5px 10px; font-size: 13px; }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover { background: var(--accent-hover); color: #fff; }

/* ---------- 播放页 ---------- */
.page-play .site-main { padding: 0; max-width: none; }

.play-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.play-bar__back {
  color: var(--text-dim);
  font-size: 14px;
  white-space: nowrap;
}

.play-bar__back:hover { color: var(--text); }

.play-bar__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.play-bar__actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.play-stage {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: #000;
}

/* 游戏容器：按清单声明的宽高比自适应，横屏游戏不会变形 */
.game-frame {
  position: relative;
  width: 100%;
  max-width: min(100%, calc((100vh - 220px) * 16 / 9));
  max-height: calc(100vh - 200px);
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.game-frame__iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  opacity: 0;
  transition: opacity 0.2s;
}

.game-frame__iframe.is-loaded { opacity: 1; }

.game-frame__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 14px;
}

.game-frame.is-loaded .game-frame__loading { display: none; }

/* 全屏时撑满屏幕 */
.game-frame:fullscreen {
  max-width: none;
  max-height: none;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  border: 0;
}

.game-info {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.game-info__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.game-info__head h2 { margin: 0; font-size: 20px; }

.game-info__badges { display: flex; gap: 6px; flex-wrap: wrap; }

.game-info__desc {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
}

.game-info__tags {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-dim);
  opacity: 0.8;
}

/* ---------- 空状态 / 页脚 ---------- */
.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 48px 0;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.site-footer p { margin: 4px 0; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .site-nav { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .card__thumb { font-size: 32px; }
  .play-stage { padding: 0; }
  .game-frame { border-radius: 0; border: 0; max-height: none; }
}

/* 尊重系统的减少动效设置 */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
