/* 休闲小游戏合集 · 深色渐变风格 */
:root {
  --bg-deep: #070b16;
  --panel-bg: rgba(255, 255, 255, 0.055);
  --panel-br: rgba(255, 255, 255, 0.11);
  --text: #e9eefb;
  --muted: #94a1bf;
  --accent: #6ea8fe;
  --accent-2: #b388ff;
  --ok: #4ade80;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1100px 720px at 12% -12%, rgba(60, 96, 190, 0.55) 0%, rgba(60, 96, 190, 0) 62%),
    radial-gradient(900px 640px at 106% 6%, rgba(126, 66, 190, 0.45) 0%, rgba(126, 66, 190, 0) 58%),
    linear-gradient(165deg, #080c18 0%, #0e1428 48%, #080c18 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(420px 420px at 50% 118%, rgba(110, 168, 254, 0.16), transparent 70%);
  z-index: 0;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(14px, 4vw, 40px);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(8, 12, 24, 0.62);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: clamp(14px, 3.6vw, 17px);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.brand .logo { font-size: 1.15em; }

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tab {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: clamp(12px, 3.2vw, 14px);
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

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

.tab.is-active {
  color: #0a1020;
  background: linear-gradient(135deg, #9ec3ff, #c2a8ff);
  box-shadow: 0 6px 18px rgba(120, 150, 255, 0.35);
}

/* ---------- 主体 ---------- */
main {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(18px, 4.5vw, 42px) clamp(14px, 4vw, 28px) 40px;
}

.view { display: none; }
.view.is-active { display: block; animation: fadeUp 0.32s ease both; }

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

.hero { text-align: center; margin: clamp(10px, 4vw, 34px) 0 clamp(20px, 5vw, 38px); }

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 8vw, 42px);
  line-height: 1.18;
  letter-spacing: 0.5px;
  background: linear-gradient(120deg, #cfe0ff 0%, #9ec3ff 40%, #c9aeff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(12.5px, 3.5vw, 15px);
}

/* ---------- 卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 3vw, 20px);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: clamp(18px, 4vw, 26px);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.085), rgba(255, 255, 255, 0.035));
  border: 1px solid var(--panel-br);
  box-shadow: var(--shadow);
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
  overflow: hidden;
}

.card::after {
  content: "";
  position: absolute;
  inset: -40% -60% auto auto;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(110, 168, 254, 0.35), transparent 68%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.card:hover { transform: translateY(-4px); border-color: rgba(158, 195, 255, 0.45); }
.card:hover::after { opacity: 1; }

.card-icon {
  font-size: clamp(28px, 8vw, 38px);
  line-height: 1;
  margin-bottom: 6px;
}

.card h2 {
  margin: 0;
  font-size: clamp(17px, 4.6vw, 21px);
  letter-spacing: 0.3px;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(12px, 3.3vw, 13.5px);
  line-height: 1.6;
}

.card-go {
  margin-top: 12px;
  font-size: clamp(12px, 3.3vw, 13.5px);
  font-weight: 600;
  color: #9ec3ff;
}

.card-go i { font-style: normal; }

.footnote {
  margin: clamp(20px, 5vw, 30px) 0 0;
  text-align: center;
  color: rgba(148, 161, 191, 0.8);
  font-size: clamp(11.5px, 3.1vw, 12.5px);
}

/* ---------- 面板 ---------- */
.panel {
  padding: clamp(16px, 4vw, 28px);
  border-radius: var(--radius-lg);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.028));
  border: 1px solid var(--panel-br);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: clamp(14px, 3.5vw, 20px);
}

.panel-head h2 {
  margin: 0;
  font-size: clamp(20px, 5.6vw, 26px);
  letter-spacing: 0.6px;
}

.scores { display: flex; gap: 8px; }

.score-box {
  min-width: 68px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  text-align: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.score-box span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.6px;
}

.score-box strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(15px, 4.4vw, 18px);
  font-variant-numeric: tabular-nums;
  color: #d8e5ff;
}

/* ---------- 按钮 ---------- */
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: clamp(14px, 3.5vw, 18px);
}

.btn {
  appearance: none;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: clamp(13px, 3.5vw, 14.5px);
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 999px;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.btn:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.24); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  border: 0;
  color: #08101f;
  background: linear-gradient(135deg, #9ec3ff, #c2a8ff);
  box-shadow: 0 10px 26px rgba(130, 160, 255, 0.4);
}

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }

.hint {
  margin: 14px 0 0;
  color: rgba(148, 161, 191, 0.85);
  font-size: clamp(11.5px, 3.1vw, 12.5px);
  line-height: 1.7;
}

kbd {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 6px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.92em;
  color: #cdd9f3;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

/* ---------- 2048 棋盘 ---------- */
.board-wrap {
  position: relative;
  width: min(100%, 420px);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  touch-action: none;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: clamp(6px, 1.6vw, 10px);
  width: 100%;
  height: 100%;
  padding: clamp(6px, 1.6vw, 10px);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: clamp(18px, 6vw, 30px);
  color: #dbe6ff;
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.14s ease, color 0.14s ease, transform 0.14s ease;
  user-select: none;
  animation: pop 0.16s ease;
}

@keyframes pop {
  from { transform: scale(0.9); }
  to { transform: scale(1); }
}

.cell[data-val="0"] { background: rgba(255, 255, 255, 0.04); }
.cell[data-val="2"] { background: #263255; color: #cbd8f5; }
.cell[data-val="4"] { background: #2f4472; color: #e2ecff; }
.cell[data-val="8"] { background: #3a5aa8; color: #ffffff; }
.cell[data-val="16"] { background: #4570cf; color: #ffffff; }
.cell[data-val="32"] { background: #5186e8; color: #ffffff; }
.cell[data-val="64"] { background: #5f9cf4; color: #08101f; }
.cell[data-val="128"] { background: #7bb6f7; color: #08101f; font-size: clamp(16px, 5.2vw, 27px); }
.cell[data-val="256"] { background: #8fd0f7; color: #08101f; font-size: clamp(16px, 5.2vw, 27px); }
.cell[data-val="512"] { background: #a7ecc9; color: #06251a; font-size: clamp(16px, 5.2vw, 27px); }
.cell[data-val="1024"] { background: #ffe08a; color: #2a1c00; font-size: clamp(14px, 4.4vw, 24px); }
.cell[data-val="2048"] { background: #ffb347; color: #2a1c00; font-size: clamp(14px, 4.4vw, 24px); }
.cell.is-super { background: linear-gradient(135deg, #ff8a8a, #ffd166); color: #2a0b0b; font-size: clamp(13px, 4vw, 22px); }

/* ---------- 遮罩 ---------- */
.board-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-radius: 18px;
  background: rgba(6, 10, 22, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeUp 0.22s ease both;
  z-index: 5;
}

.board-overlay[hidden] { display: none; }

.board-overlay p {
  margin: 0;
  font-size: clamp(15px, 4.4vw, 19px);
  font-weight: 700;
  color: #e9eefb;
  text-align: center;
  padding: 0 16px;
}

/* ---------- 贪吃蛇 ---------- */
.snake-stage {
  position: relative;
  width: min(100%, 420px);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
}

.snake-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0a1024;
  touch-action: none;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 56px);
  gap: 8px;
  justify-content: center;
  margin: clamp(14px, 3.5vw, 18px) auto 0;
}

.dpad-btn {
  appearance: none;
  cursor: pointer;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.07);
  color: #d5e2ff;
  font-size: 20px;
  line-height: 1;
  transition: background 0.15s ease, transform 0.12s ease;
}

.dpad-btn:active { background: rgba(110, 168, 254, 0.35); transform: scale(0.94); }

.dpad-btn.up { grid-column: 2; grid-row: 1; }
.dpad-btn.left { grid-column: 1; grid-row: 2; }
.dpad-btn.down { grid-column: 2; grid-row: 2; }
.dpad-btn.right { grid-column: 3; grid-row: 2; }

/* ---------- 页脚 ---------- */
.site-footer {
  position: relative;
  z-index: 1;
  padding: 18px 16px 26px;
  text-align: center;
  color: rgba(148, 161, 191, 0.65);
  font-size: 12px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 560px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .brand-text { font-size: 14px; }
  .tabs { padding: 3px; }
  .tab { padding: 6px 12px; }
  .cards { grid-template-columns: 1fr; }
  .score-box { min-width: 60px; padding: 6px 10px; }
  .panel-actions .btn { flex: 1 1 auto; }
  .dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 52px); }
}

@media (min-width: 761px) {
  .dpad { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
