:root {
  --bg: #f6f3ee;
  --card: #fffdfa;
  --text: #241f1a;
  --sub: #7d746b;
  --line: #e8e1d6;
  --accent: #ff6a3d;
  --accent-soft: #ffe6dc;
  --glow: #ffe9df;
  --shadow: 0 12px 34px rgba(74, 52, 28, 0.10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171513;
    --card: #211e1b;
    --text: #f4efe8;
    --sub: #a69c91;
    --line: #332e28;
    --accent: #ff7a50;
    --accent-soft: #3a241d;
    --glow: #2a1c16;
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

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

body {
  max-width: 840px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 50% -220px, var(--glow), transparent 70%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- 顶部标题 ---------- */

.site-header {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: clamp(36px, 8vw, 58px) 20px clamp(30px, 6vw, 46px);
  border-radius: 30px;
  background: var(--text);
  color: var(--bg);
  margin-bottom: 30px;
  box-shadow: var(--shadow);
}

.site-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 82% -10%, rgba(255, 255, 255, 0.12), transparent 55%);
  pointer-events: none;
}

.eyebrow {
  position: relative;
  margin: 0 0 12px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  opacity: 0.55;
}

.site-header h1 {
  position: relative;
  margin: 0;
  font-size: clamp(2.1rem, 8.5vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.1em;
}

.tagline {
  position: relative;
  margin: 12px 0 0;
  font-size: clamp(0.9rem, 2.6vw, 1rem);
  opacity: 0.72;
}

.header-bubble {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: radial-gradient(circle at 30% 28%, rgba(255, 255, 255, 0.35), transparent 58%);
  opacity: 0.1;
  animation: drift 9s ease-in-out infinite;
  pointer-events: none;
}

.b1 { width: 96px; height: 96px; left: -28px; top: -24px; }
.b2 { width: 54px; height: 54px; right: 8%; top: 18px; animation-delay: -2.4s; }
.b3 { width: 34px; height: 34px; left: 14%; bottom: 16px; animation-delay: -4.1s; }
.b4 { width: 76px; height: 76px; right: -22px; bottom: -30px; animation-delay: -1.2s; }
.b5 { width: 20px; height: 20px; left: 46%; top: 14px; animation-delay: -6s; }

@keyframes drift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ---------- 标题与工具栏 ---------- */

h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

h2::before {
  content: "";
  flex: none;
  width: 6px;
  height: 1.05em;
  border-radius: 3px;
  background: var(--accent);
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

#game-count {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--sub);
}

#random {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 15px;
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}

#random:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

#random:active { transform: translateY(0) scale(0.98); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#search {
  flex: 1 1 220px;
  width: 100%;
  padding: 11px 16px 11px 42px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--card)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8178' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E")
    no-repeat 15px center / 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

#search::-webkit-search-cancel-button { cursor: pointer; }

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 20px;
}

.chips button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--sub);
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chips button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chips button[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

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

.games {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 14px 18px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 2px 8px rgba(60, 40, 20, 0.03);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.game-card:hover,
.game-card:focus-within {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.game-card:active { transform: translateY(-1px) scale(0.99); }

.game-card .icon { line-height: 0; }

.game-card .icon img {
  width: clamp(84px, 22vw, 112px);
  height: auto;
  border-radius: 26px;
  box-shadow: 0 6px 16px rgba(70, 110, 130, 0.18);
  transition: transform 0.25s ease;
}

.game-card:hover .icon img {
  transform: rotate(-5deg) scale(1.05);
}

.card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.card-title {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}

.card-title::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 22px;
}

.card-desc {
  margin: 0;
  font-size: 0.79rem;
  line-height: 1.55;
  color: var(--sub);
}

.card-meta {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 9px;
}

.fav {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--sub);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}

.fav:hover {
  background: var(--accent-soft);
  color: var(--accent);
  transform: scale(1.1);
}

.fav[aria-pressed="true"] { color: var(--accent); }

.soon-card {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.soon-card:hover {
  transform: none;
  border-color: var(--line);
  box-shadow: none;
}

.soon-icon {
  display: grid;
  place-items: center;
  width: clamp(84px, 22vw, 112px);
  height: clamp(84px, 22vw, 112px);
  border: 2px dashed var(--line);
  border-radius: 26px;
  color: var(--line);
  font-size: 2rem;
  font-weight: 300;
}

.soon-card .card-title {
  color: var(--sub);
  font-size: 0.95rem;
  font-weight: 700;
}

.soon-card .card-title::after { content: none; }

.no-hit {
  margin: 18px 0 0;
  text-align: center;
  color: var(--sub);
  font-size: 0.9rem;
}

/* ---------- 广告位 ---------- */

.ad-slot {
  position: relative;
  max-width: 728px;
  min-height: 120px;
  margin: 28px auto 0;
  padding: 24px 8px 8px;
  text-align: center;
}

.ad-label {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  color: var(--sub);
  opacity: 0.65;
}

.ad-slot .adsbygoogle {
  min-height: 90px;
}

/* 预览模式：只展示位置，不加载广告 */
.ad-slot.is-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  padding: 20px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 18px;
}

.ad-preview-note {
  font-size: 0.8rem;
  color: var(--sub);
}

/* ---------- 收藏 / 最近玩过 ---------- */

.shelf { margin-bottom: 24px; }

.shelf h2 {
  margin-bottom: 10px;
  font-size: 0.95rem;
  color: var(--sub);
}

.shelf h2::before {
  height: 0.9em;
  background: var(--sub);
}

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

.recent a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 5px;
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s, transform 0.15s;
}

.recent a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.recent img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

/* ---------- 关于 / 页脚 ---------- */

.about {
  margin-top: 36px;
  padding: 24px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
}

.about p {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--sub);
}

.about-list {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.about-list li {
  position: relative;
  padding-left: 20px;
  font-size: 0.87rem;
  line-height: 1.6;
  color: var(--sub);
}

.about-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.55em;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.7;
}

.about-list strong { color: var(--text); }

footer {
  margin-top: 44px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
  text-align: center;
  color: var(--sub);
  font-size: 0.8rem;
}

footer p { margin: 4px 0; }

footer a {
  color: var(--sub);
  text-decoration: underline;
  text-underline-offset: 3px;
}

footer a:hover { color: var(--accent); }

/* ---------- 文字页（隐私说明 / 404） ---------- */

.doc {
  margin-top: 24px;
  padding: 30px 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
}

.doc h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 900;
}

.doc h2 {
  margin: 26px 0 8px;
  font-size: 1rem;
}

.doc h2::before { height: 0.9em; }

.doc p,
.doc li {
  font-size: 0.9rem;
  color: var(--sub);
}

.doc a { color: var(--accent); }

.doc .updated {
  margin: 0;
  font-size: 0.78rem;
  color: var(--sub);
  opacity: 0.8;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--sub);
  text-decoration: none;
}

.back-link:hover { color: var(--accent); }

/* 桌面端最后一张「敬请期待」落单时，铺满整行做成横幅 */
@media (min-width: 641px) {
  .games > .soon-card:last-child:nth-child(3n + 1) {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    gap: 20px;
    padding: 18px 24px;
    text-align: left;
  }

  .games > .soon-card:last-child:nth-child(3n + 1) .soon-icon {
    width: 72px;
    height: 72px;
    flex: none;
    font-size: 1.6rem;
  }

  .games > .soon-card:last-child:nth-child(3n + 1) .card-body {
    align-items: flex-start;
    max-width: 320px;
  }
}

@media (max-width: 640px) {
  .games { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .game-card { padding: 18px 10px 14px; border-radius: 18px; }
  .card-desc { font-size: 0.74rem; }
  .site-header { border-radius: 24px; }

  /* 奇数个卡片时，让最后一张「敬请期待」占满整行，避免落单 */
  .games > .soon-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: center;
    gap: 18px;
    padding: 18px 20px;
    text-align: left;
  }
  .games > .soon-card:last-child:nth-child(odd) .soon-icon {
    width: 72px;
    height: 72px;
    flex: none;
    font-size: 1.6rem;
  }
  .games > .soon-card:last-child:nth-child(odd) .card-body {
    align-items: flex-start;
    max-width: 260px;
  }
}

@media (max-width: 380px) {
  .games { grid-template-columns: 1fr; }
  .game-card .icon img { width: 96px; }
}

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