/* ==========================================================================
   Casual Games — 设计令牌 + 组件样式
   所有间距使用逻辑属性（margin-inline / padding-block / inset-inline），
   因此 RTL（阿拉伯语）无需额外样式即可正确镜像。
   ========================================================================== */

:root {
  --brand: #6c5ce7;
  --brand-ink: #ffffff;
  --ink: #14161f;
  --ink-2: #4b5063;
  --ink-3: #767c92;
  --surface: #ffffff;
  --surface-2: #f5f6fb;
  --surface-3: #eceefa;
  --line: #e3e6f2;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow-1: 0 1px 2px rgba(20, 22, 31, 0.06), 0 4px 12px rgba(20, 22, 31, 0.05);
  --shadow-2: 0 10px 28px rgba(20, 22, 31, 0.12);
  --wrap: 1140px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans SC", "Noto Sans JP",
    "Noto Sans KR", "Noto Naskh Arabic", "Malgun Gothic", "Hiragino Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #8b7cf6;
    --brand-ink: #0d0f16;
    --ink: #f2f4fb;
    --ink-2: #b9bfd4;
    --ink-3: #8d94ab;
    --surface: #14161f;
    --surface-2: #1b1e2a;
    --surface-3: #232739;
    --line: #2b3044;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.32);
    --shadow-2: 0 14px 34px rgba(0, 0, 0, 0.5);
  }
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--surface-2);
  color: var(--ink);
  line-height: 1.65;
  font-size: 16px;
  text-rendering: optimizeLegibility;
}

img,
svg,
iframe {
  max-width: 100%;
}

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

a:hover {
  color: var(--brand);
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  inset-block-start: -100px;
  inset-inline-start: 12px;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 20;
}

.skip:focus {
  inset-block-start: 12px;
}

.wrap {
  width: min(100% - 32px, var(--wrap));
  margin-inline: auto;
}

.muted {
  color: var(--ink-3);
  font-size: 0.9rem;
}

/* ---------- header ---------- */

.head {
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-block-end: 1px solid var(--line);
}

.head__in {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand__mark {
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #fd79a8);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, #fff 30%, transparent);
}

.nav {
  display: flex;
  gap: 6px;
  margin-inline-start: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.92rem;
  color: var(--ink-2);
  font-weight: 600;
  white-space: nowrap;
}

.nav a:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.nav a[aria-current="page"] {
  background: var(--brand);
  color: var(--brand-ink);
}

/* 语言切换 */
.lang {
  position: relative;
  flex: none;
}

.lang summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-2);
  background: var(--surface);
}

.lang summary::-webkit-details-marker {
  display: none;
}

.lang__menu {
  position: absolute;
  inset-block-start: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 160px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
}

.lang__menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.lang__menu a:hover {
  background: var(--surface-3);
}

.lang__menu a[aria-current="true"] {
  font-weight: 700;
  color: var(--brand);
}

/* ---------- 通用排版 ---------- */

main {
  padding-block: 28px 48px;
}

h1 {
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}

h2 {
  font-size: clamp(1.15rem, 1rem + 0.5vw, 1.45rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 40px 0 16px;
}

.lead {
  font-size: 1.05rem;
  color: var(--ink-2);
  margin: 0 0 20px;
  max-width: 68ch;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}

.badges li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-2);
}

.badges li::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00b894;
  margin-inline-end: 8px;
  vertical-align: 1px;
}

.btn {
  display: inline-block;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 999px;
  border: 0;
  box-shadow: var(--shadow-1);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  color: var(--brand-ink);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}

.prose {
  max-width: 72ch;
}

.prose p {
  color: var(--ink-2);
}

/* ---------- 游戏页的步骤与问答 ---------- */

.steps {
  margin: 0;
  padding-inline-start: 1.25em;
  color: var(--ink-2);
}

.steps li {
  margin-block-end: 0.4em;
}

.faq {
  margin: 0;
}

.faq dt {
  font-weight: 700;
  color: var(--ink);
  margin-block-start: 0.9em;
}

.faq dt:first-child {
  margin-block-start: 0;
}

.faq dd {
  margin: 0.2em 0 0;
  color: var(--ink-2);
}

/* ---------- 分类磁贴 ---------- */

.tiles {
  display: grid;
  /* 分类固定 6 个，用确定列数，避免 auto-fill 在某档宽度下把第 6 个挤到第二行 */
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px;
  border-radius: var(--radius);
  background: linear-gradient(150deg, var(--c1), var(--c2));
  color: #fff;
  min-height: 104px;
  justify-content: flex-end;
  box-shadow: var(--shadow-1);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.tile:hover {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

.tile__mono {
  font-size: 1.5rem;
  font-weight: 800;
  opacity: 0.9;
  line-height: 1;
  margin-block-end: auto;
}

.tile__name {
  font-weight: 700;
  font-size: 1rem;
}

.tile__count {
  font-size: 0.8rem;
  opacity: 0.9;
}

.tiles--sm {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.tiles--sm .tile {
  min-height: 84px;
  padding: 12px;
}

.tiles--sm .tile__mono {
  font-size: 1.1rem;
}

/* ---------- 游戏卡片 ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 14px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
}

.card__thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: linear-gradient(150deg, var(--c1), var(--c2));
  overflow: hidden;
}

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

/* 未上线的游戏降低视觉权重，避免和可玩游戏抢注意力 */
.card--soon .card__thumb {
  filter: saturate(0.55) brightness(0.96);
}
.card--soon .card__play {
  opacity: 1;
  transform: none;
  background: rgba(10, 12, 18, 0.52);
}

.card__mono {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.card__body {
  display: block;
  padding: 10px 12px 12px;
}

.card__name {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.35;
}

.card__meta {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-3);
  margin-block-start: 2px;
}

.card__play {
  position: absolute;
  inset-block-start: 8px;
  inset-inline-end: 8px;
  background: rgba(10, 12, 18, 0.68);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.card:hover .card__play,
.card:focus-visible .card__play {
  opacity: 1;
  transform: none;
}

/* ---------- 筛选条 ---------- */

.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-block-end: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover {
  border-color: color-mix(in srgb, var(--brand) 45%, var(--line));
  color: var(--ink);
}

.chip.is-on {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

.search input {
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-width: 180px;
}

/* ---------- 面包屑与标签 ---------- */

.crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  font-size: 0.84rem;
  color: var(--ink-3);
}

.crumbs li + li::before {
  content: "/";
  margin-inline-end: 6px;
  color: var(--line);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.chips li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  color: var(--ink-2);
}

.chips a {
  font-weight: 700;
  color: var(--brand);
}

/* ---------- 游戏播放区 ---------- */

.player {
  position: relative;
  /* 固定高度而非 16:9：竖版棋盘（数独、翻牌）和横版牌桌（接龙）都能拿到可用空间 */
  height: clamp(430px, 72vh, 760px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: radial-gradient(120% 120% at 20% 0%, #2b2450 0%, #12131c 70%);
  box-shadow: var(--shadow-2);
  margin-block-end: 20px;
}

.player iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.player__start {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  border: 0;
  background: none;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.player--soon .player__start {
  cursor: default;
}

.player__icon {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(255, 255, 255, 0.55);
  display: grid;
  place-items: center;
  margin-block-end: 8px;
  transition: transform 0.18s ease, background 0.18s ease;
}

.player__icon::after {
  content: "";
  width: 0;
  height: 0;
  border-inline-start: 16px solid #fff;
  border-block: 11px solid transparent;
  margin-inline-start: 4px;
}

.player__start:hover .player__icon {
  transform: scale(1.06);
  background: rgba(255, 255, 255, 0.24);
}

.player__label {
  font-size: 1.1rem;
  font-weight: 800;
}

.player__sub {
  font-size: 0.86rem;
  opacity: 0.7;
}

/* ---------- footer ---------- */

.foot {
  border-block-start: 1px solid var(--line);
  background: var(--surface);
  padding-block: 32px 40px;
  margin-block-start: 40px;
  font-size: 0.9rem;
}

.foot p {
  margin: 8px 0 0;
  color: var(--ink-2);
  max-width: 70ch;
}

.foot__cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-block-end: 12px;
}

.foot__cats a {
  font-weight: 600;
  color: var(--ink-2);
  font-size: 0.88rem;
}

/* ---------- 响应式 ---------- */

@media (max-width: 720px) {
  .head__in {
    gap: 10px;
  }

  .brand {
    font-size: 0.98rem;
  }

  .nav a {
    padding: 6px 10px;
    font-size: 0.86rem;
  }

  .cards {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .tiles {
    /* 手机端 3 列两行，比 6 列挤压更好读 */
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
