/* 小游戏合集 · 站点公共样式
 * 首页、赞助作者、以及各游戏页的外壳都用这一份。
 * 每个游戏页只内联自己的棋盘样式，并用 :root{--accent:...} 指定自己的主题色。
 */

:root {
  --paper: #F7F1E7;
  --paper-2: #EFE6D7;
  --card: #FFFCF6;
  --ink: #2B2533;
  --ink-2: #6E6577;
  --ink-3: #9A9199;
  --line: #DFD3BF;
  --line-2: #E8DECD;
  --gold: #B08D57;
  --accent: #B08D57;
  --accent-soft: rgba(176, 141, 87, .14);
  --shadow: 0 10px 24px -18px rgba(43, 37, 51, .55);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { min-height: 100%; }

body {
  background: #E9E1D4;
  background-image:
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, .6), transparent 46%),
    radial-gradient(circle at 82% 92%, rgba(176, 141, 87, .12), transparent 52%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}

a, button { -webkit-tap-highlight-color: transparent; }

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

.page {
  width: 100%;
  max-width: 960px;
  padding: calc(30px + var(--sat)) 22px calc(34px + var(--sab));
}

/* ---------------- 首页 ---------------- */

.page--home {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.home-top {
  text-align: center;
  margin-bottom: 30px;
}

.home-kicker {
  font-size: 10px;
  letter-spacing: .38em;
  color: var(--gold);
  text-transform: uppercase;
}

.home-title {
  font-family: var(--serif);
  font-size: clamp(30px, 6vw, 42px);
  font-weight: 600;
  letter-spacing: .1em;
  margin-top: 10px;
}

.home-sub {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 10px;
  letter-spacing: .04em;
}

.home-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--gold);
  margin-top: 18px;
  font-size: 12px;
}
.home-rule::before,
.home-rule::after {
  content: "";
  width: 90px;
  height: 1px;
  background: currentColor;
  opacity: .4;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  grid-auto-rows: 1fr;
}

@media (max-width: 860px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 152px;
  padding: 18px 16px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: border-color .22s ease, transform .22s cubic-bezier(.16, 1, .3, 1), box-shadow .22s ease;
  animation: card-in .5s cubic-bezier(.16, 1, .3, 1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 16px 30px -20px rgba(43, 37, 51, .6);
}

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

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--accent);
  margin-bottom: 6px;
  transition: transform .22s cubic-bezier(.16, 1, .3, 1);
}
.card-icon svg { width: 34px; height: 34px; }
.card:hover .card-icon { transform: scale(1.06); }

.card-name {
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: .06em;
  color: var(--ink);
  margin-top: auto;
}

.card-desc {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

.card-tag {
  position: absolute;
  top: 16px;
  right: 14px;
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--ink-3);
}

/* 还没做的卡片，占住网格位置 */
.card--soon {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  cursor: default;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.card--soon:hover { transform: none; border-color: var(--line); box-shadow: none; }
.card--soon .card-icon { color: var(--line); }
.card--soon .card-name { color: var(--ink-3); }
.card--soon .card-desc { color: var(--ink-3); }

.home-foot {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .04em;
}
.home-foot a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--line); }
.home-foot a:hover { color: var(--accent); border-color: var(--accent); }

/* 首页搜索与分类 */

.home-main { width: 100%; }

.home-tools {
  width: 100%;
  max-width: 720px;
  margin: 0 auto 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 2px;
  transition: border-color .16s ease;
}
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { width: 16px; height: 16px; flex: none; color: var(--ink-3); }
.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 11px 0;
  outline: none;
}
.search-box input::placeholder { color: var(--ink-3); }

.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.cat {
  appearance: none;
  font: inherit;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.cat:hover { border-color: var(--accent); color: var(--accent); }
.cat[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.find-hint {
  margin: -6px 0 14px;
  text-align: center;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--ink-3);
}
.find-hint[hidden] { display: none; }

.empty {
  padding: 30px 0;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: .04em;
}
.empty[hidden] { display: none; }

/* ---------------- 游戏页外壳 ---------------- */

.page--game {
  max-width: 560px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(24px + var(--sab));
}

.game-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.back {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 12.5px;
  color: var(--ink-2);
  text-decoration: none;
  padding: 7px 10px 7px 0;
  letter-spacing: .04em;
}
.back:hover { color: var(--accent); }

.game-title {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: .12em;
}

.game-tag {
  position: absolute;
  right: 0;
  top: 4px;
  font-size: 10px;
  letter-spacing: .18em;
  color: var(--ink-3);
}

.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 0;
}

.game-tip {
  margin-top: 18px;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-2);
  text-align: center;
}

/* 计分牌：放在游戏区上方 */
.hud {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: .06em;
}
.hud b {
  font-family: var(--serif);
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
  font-size: 20px;
  margin-left: 6px;
  line-height: 1;
}
.hud .btn { margin-left: auto; align-self: center; }

/* 游戏台面：把画布 / 棋盘装进一块纸面板 */
.stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow: 0 12px 26px -22px rgba(43, 37, 51, .8), inset 0 0 0 1px rgba(255, 255, 255, .6);
}

/* 按钮 */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--paper);
  font-family: inherit;
  font-size: 14px;
  letter-spacing: .1em;
  padding: 0 24px;
  border-radius: 1px;
  cursor: pointer;
  transition: transform .16s ease, opacity .16s ease, filter .16s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn:disabled { opacity: .35; pointer-events: none; }

.btn-sm {
  min-height: 36px;
  font-size: 12px;
  padding: 0 14px;
  letter-spacing: .08em;
}

/* 结束遮罩 */

.overlay {
  position: absolute;
  inset: -11px;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(247, 241, 231, .9);
  backdrop-filter: blur(2px);
  z-index: 5;
  border-radius: 2px;
}
.overlay.show { display: flex; animation: fade-in .25s ease both; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.overlay-card {
  text-align: center;
  padding: 22px 26px;
  animation: pop-in .32s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(.94); }
  to { opacity: 1; transform: none; }
}

.overlay-title {
  font-family: var(--serif);
  font-size: 24px;
  letter-spacing: .1em;
  margin-bottom: 8px;
  padding-bottom: 10px;
  position: relative;
}
.overlay-title::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 36px;
  height: 2px;
  background: var(--accent);
  transform: translateX(-50%);
}
.overlay-text {
  font-size: 13px;
  color: var(--ink-2);
  margin: 10px 0 18px;
}

/* 触屏方向键 */

.pad {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 288px;
}
.pad-3 { grid-template-columns: repeat(3, 1fr); }
.pad-4 { grid-template-columns: repeat(4, 1fr); }

.pad button {
  appearance: none;
  font-family: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #D6C7AE;
  border-radius: 2px;
  min-height: 48px;
  padding: 0;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: background .12s ease, border-color .12s ease;
}
.pad button:hover { border-color: var(--accent); color: var(--accent); }
.pad button:active { background: var(--accent-soft); border-color: var(--accent); }
.pad .spacer { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
  }
}
