/* ============ 离线游戏合集 · 全局样式 ============ */
:root {
  --bg: #0b0e1a;
  --panel: #151a30;
  --panel2: #1b2140;
  --line: #2a3155;
  --text: #e9ecf8;
  --muted: #8d95b8;
  --accent: #5b8cff;
  --accent2: #2fe0a8;
  --gold: #ffc857;
  --danger: #ff5c7a;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  padding-bottom: 32px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 50% -260px, #1c2650 0%, transparent 70%),
    radial-gradient(700px 400px at 100% 100%, #14203a 0%, transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: rgba(11, 14, 26, .72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(42, 49, 85, .7);
}
.topbar h1 {
  flex: 1; margin: 0;
  font-size: 17px; font-weight: 650; letter-spacing: .3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 36px; height: 36px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 18px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 11px; cursor: pointer;
  transition: .16s;
}
.icon-btn:hover { background: var(--panel2); transform: translateX(-2px); }

.btn {
  padding: 8px 16px; border-radius: 11px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, #5b8cff, #3f6bdc);
  border: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 8px 20px -12px #5b8cff;
  transition: .16s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.97); }
.btn-ghost {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); box-shadow: none;
}
.btn-ghost:hover { background: var(--panel2); }
.btn-danger { background: linear-gradient(135deg, #ff6b86, #e4405f); }

.badge {
  padding: 5px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--gold);
  background: rgba(255, 200, 87, .1);
  border: 1px solid rgba(255, 200, 87, .3);
  white-space: nowrap;
}

/* ---------- 首页 ---------- */
.view { max-width: 1080px; margin: 0 auto; padding: 22px 20px; }
.hub-intro {
  margin: 4px 0 22px; font-size: 13.5px; color: var(--muted); line-height: 1.7;
}
.hub-intro strong { color: var(--accent2); }

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}
.card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px;
  text-align: left; cursor: pointer;
  color: var(--text);
  background: linear-gradient(160deg, #171d36, #121628);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform .18s ease, border-color .18s, box-shadow .18s;
}
.card::after {
  content: ""; position: absolute; inset: -60% -30% auto auto;
  width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 140, 255, .28), transparent 70%);
  opacity: 0; transition: opacity .2s;
}
.card:hover {
  transform: translateY(-4px);
  border-color: rgba(91, 140, 255, .55);
  box-shadow: 0 18px 34px -22px #5b8cff;
}
.card:hover::after { opacity: 1; }
.card .emoji { font-size: 27px; line-height: 1; }
.card .name { font-size: 15px; font-weight: 650; }
.card .desc { font-size: 11.5px; color: var(--muted); line-height: 1.5; min-height: 2.4em; }
.card .cb { font-size: 11px; color: var(--gold); font-variant-numeric: tabular-nums; }
.hub-foot {
  margin-top: 30px; padding-top: 18px;
  font-size: 11.5px; color: #5d6690; text-align: center; line-height: 1.7;
  border-top: 1px dashed rgba(42, 49, 85, .8);
}

/* ---------- 游戏舞台 ---------- */
.game-root {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding-top: 6px;
  user-select: none;
  -webkit-user-select: none;
}
.game-canvas {
  display: block; width: 100%; height: auto;
  border-radius: 14px;
  background: #0d1024;
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px -30px #000;
  touch-action: none;
}

/* HUD */
.hud { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.hud-item {
  display: flex; align-items: baseline; gap: 7px;
  padding: 7px 13px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--line);
}
.hud-label { font-size: 11px; color: var(--muted); letter-spacing: .5px; }
.hud-value {
  font-size: 14.5px; font-weight: 700; color: var(--accent2);
  font-variant-numeric: tabular-nums; min-width: 1.6em; text-align: right;
}
.hud-value.gold { color: var(--gold); }

/* 工具条 / 说明 */
.toolbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.toolbar .btn { padding: 8px 14px; font-size: 13px; }
.toolbar .btn.active { background: linear-gradient(135deg, #2fe0a8, #1cb98a); color: #06241a; border-color: transparent; }
.hint { font-size: 11.5px; color: #6d76a0; text-align: center; line-height: 1.7; }
.hint kbd {
  padding: 1px 5px; border-radius: 4px; font-size: 10.5px;
  background: #222848; border: 1px solid #333c66; color: #b6bfe0;
}

/* 遮罩 / 结算 */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(6, 8, 18, .74);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.overlay-inner {
  width: 100%; max-width: 340px;
  padding: 26px 22px; text-align: center;
  background: linear-gradient(165deg, #1a2040, #12162a);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 30px 70px -30px #000;
  animation: pop .24s cubic-bezier(.2, 1.3, .5, 1);
}
@keyframes pop { from { transform: scale(.9); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.overlay-title { font-size: 21px; font-weight: 750; margin-bottom: 8px; }
.overlay-sub { font-size: 13.5px; color: var(--muted); line-height: 1.75; margin-bottom: 18px; }
.overlay-sub b { color: var(--accent2); font-size: 16px; }
.overlay-sub .rec { display: inline-block; margin-top: 8px; color: var(--gold); font-weight: 700; }
.overlay-inner .btn { width: 100%; padding: 11px; font-size: 14px; }

/* ---------- 2048 ---------- */
.g2048 {
  position: relative;
  background: #1a2040;
  border: 1px solid var(--line);
  border-radius: 14px;
  touch-action: none;
}
.g2048-cell {
  position: absolute; border-radius: 8px; background: rgba(255, 255, 255, .035);
}
.g2048-layer { position: absolute; inset: 0; }
.g2048-tile {
  position: absolute;
  display: grid; place-items: center;
  border-radius: 8px;
  font-weight: 800; font-variant-numeric: tabular-nums;
  background: #2b3360; color: #dbe2ff;
  transition: transform .12s ease, background .12s, color .12s;
  will-change: transform;
}
.g2048-tile.spawn { animation: tpop .18s ease; }
@keyframes tpop { from { opacity: 0; } }
.g2048-tile[data-v="2"]    { background: #2c3563; color: #cfd8ff; }
.g2048-tile[data-v="4"]    { background: #39447c; color: #dbe2ff; }
.g2048-tile[data-v="8"]    { background: #2f6fbf; color: #fff; }
.g2048-tile[data-v="16"]   { background: #2f8fbf; color: #fff; }
.g2048-tile[data-v="32"]   { background: #26a7a0; color: #fff; }
.g2048-tile[data-v="64"]   { background: #23b57e; color: #fff; }
.g2048-tile[data-v="128"]  { background: #8fbd35; color: #12240a; font-size: .82em; }
.g2048-tile[data-v="256"]  { background: #d0b02c; color: #241c02; font-size: .82em; }
.g2048-tile[data-v="512"]  { background: #e89443; color: #2a1502; font-size: .82em; }
.g2048-tile[data-v="1024"] { background: #ea6b4b; color: #fff; font-size: .66em; }
.g2048-tile[data-v="2048"] { background: #f0506e; color: #fff; font-size: .66em; box-shadow: 0 0 22px rgba(240, 80, 110, .6); }
.g2048-tile[data-v="big"]  { background: #a13ff0; color: #fff; font-size: .6em; }

/* ---------- 扫雷 ---------- */
.ms-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ms-grid {
  display: grid; gap: 3px;
  padding: 8px; border-radius: 14px;
  background: #131832; border: 1px solid var(--line);
  touch-action: manipulation;
}
.ms-cell {
  width: var(--cs); height: var(--cs);
  display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 5px;
  font-size: calc(var(--cs) * .56); font-weight: 800; line-height: 1;
  color: #cfd8ff; background: #2b3360; cursor: pointer;
  transition: background .1s, transform .06s;
  font-variant-numeric: tabular-nums;
}
.ms-cell:hover:not(.open) { background: #39447c; }
.ms-cell:active:not(.open) { transform: scale(.94); }
.ms-cell.open { background: #171d38; cursor: default; }
.ms-cell.mine { background: #7d1f36; }
.ms-cell.wrong { background: #4a2030; }
.ms-cell.n1 { color: #6ea8ff } .ms-cell.n2 { color: #4fe0a0 }
.ms-cell.n3 { color: #ff8c8c } .ms-cell.n4 { color: #c79bff }
.ms-cell.n5 { color: #ffc857 } .ms-cell.n6 { color: #5ce1e6 }
.ms-cell.n7 { color: #ffa8d0 } .ms-cell.n8 { color: #b8c0e0 }

/* ---------- 记忆翻牌 ---------- */
.mem-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(var(--cols), 1fr);
  width: 100%;
}
.mem-card {
  position: relative; aspect-ratio: 1;
  padding: 0; border: 0; background: none; cursor: pointer;
  perspective: 700px;
}
.mem-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .32s cubic-bezier(.4, .1, .2, 1);
}
.mem-card.flipped .mem-inner, .mem-card.done .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 12px; backface-visibility: hidden;
  font-size: clamp(20px, 7vw, 32px);
}
.mem-back {
  background: linear-gradient(150deg, #2c3568, #1a2044);
  border: 1px solid #3a4480; color: #5f6ba8; font-size: 18px;
}
.mem-front {
  transform: rotateY(180deg);
  background: linear-gradient(150deg, #24407f, #1a2b57);
  border: 1px solid #3d5cae;
}
.mem-card.done .mem-front {
  background: linear-gradient(150deg, #1d6b52, #143c33);
  border-color: #2fe0a8;
}

/* ---------- 井字棋 ---------- */
.tic {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px;
  width: 100%;
}
.tic-cell {
  aspect-ratio: 1; display: grid; place-items: center;
  padding: 0; border-radius: 14px; cursor: pointer;
  font-size: clamp(30px, 12vw, 48px); font-weight: 800;
  color: #cfe0ff;
  background: linear-gradient(150deg, #1d2448, #161b34);
  border: 1px solid var(--line);
  transition: .14s;
}
.tic-cell:hover:not(:disabled) { border-color: rgba(91, 140, 255, .6); transform: translateY(-2px); }
.tic-cell:disabled { cursor: default; }
.tic-cell.x { color: #6ea8ff; text-shadow: 0 0 20px rgba(110, 168, 255, .5); }
.tic-cell.o { color: #ff8fa8; text-shadow: 0 0 20px rgba(255, 143, 168, .5); }
.tic-cell.win { background: linear-gradient(150deg, #1d6b52, #143c33); border-color: #2fe0a8; }

/* ---------- 打地鼠 ---------- */
.mole-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%;
}
.mole-hole {
  position: relative; aspect-ratio: 1; overflow: hidden;
  border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 50% 30%, #232a4e, #10142a);
  border: 2px solid #2a3155;
  box-shadow: inset 0 8px 18px -6px #000;
}
.mole-hole .mole {
  position: absolute; left: 50%; bottom: -100%;
  width: 78%; height: 78%;
  transform: translateX(-50%);
  display: grid; place-items: center;
  font-size: clamp(26px, 9vw, 42px);
  transition: bottom .12s ease-out;
  user-select: none;
}
.mole-hole.up .mole { bottom: 4%; }
.mole-hole.hit { border-color: #2fe0a8; }
.mole-hole.hit .mole { animation: hitpop .2s ease forwards; }
@keyframes hitpop { to { transform: translateX(-50%) scale(1.3); opacity: 0 } }

/* ---------- 数字华容道 ---------- */
.slide-board {
  position: relative; width: 100%; aspect-ratio: 1;
  border-radius: 14px; background: #131832;
  border: 1px solid var(--line);
}
.slide-tile {
  position: absolute; display: grid; place-items: center;
  padding: 0; cursor: pointer;
  font-weight: 800; font-variant-numeric: tabular-nums;
  color: #dbe4ff;
  background: linear-gradient(150deg, #2c3568, #1c2348);
  border: 1px solid #3a4480; border-radius: 10px;
  transition: left .15s ease, top .15s ease, background .15s;
  font-size: clamp(16px, 6vw, 28px);
}
.slide-tile:hover { background: linear-gradient(150deg, #36418a, #222a56); }
.slide-tile.ok { background: linear-gradient(150deg, #1d6b52, #143c33); border-color: #2fe0a8; color: #d8fff2; }

/* ---------- 数独 ---------- */
.sudoku {
  display: grid; grid-template-columns: repeat(9, 1fr);
  gap: 0; padding: 4px;
  background: #1a2040; border: 1px solid var(--line); border-radius: 12px;
  touch-action: manipulation;
}
.sd-cell {
  position: relative;
  aspect-ratio: 1; display: grid; place-items: center;
  padding: 0; border: 0; cursor: pointer;
  font-size: clamp(13px, 4.4vw, 20px); font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #8fa8ff; background: #161c36;
  outline: 1px solid rgba(42, 49, 85, .9);
}
.sd-cell.fixed { color: #e9ecf8; font-weight: 800; background: #1b2340; }
.sd-cell.peer { background: #1f2a52; }
.sd-cell.same { background: #26356180; }
.sd-cell.sel { background: #3a5cc9 !important; color: #fff; }
.sd-cell.err { color: #ff6b86; }
.sd-cell.err.fixed { color: #ffb3c0; }
.sd-cell:nth-child(3n):not(:nth-child(9n)) { box-shadow: 2px 0 0 #3b4a86; }
.sd-cell:nth-child(n+19):nth-child(-n+27),
.sd-cell:nth-child(n+46):nth-child(-n+54) { box-shadow: 0 2px 0 #3b4a86; }
.sd-notes {
  position: absolute; inset: 2px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  font-size: .42em; color: #7f8fc8; line-height: 1;
  pointer-events: none;
}
.sd-notes i { font-style: normal; display: grid; place-items: center; }
.sd-pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; width: 100%; }
.sd-pad button {
  padding: 11px 0; border-radius: 10px; cursor: pointer;
  font-size: 16px; font-weight: 700; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
}
.sd-pad button:hover { background: var(--panel2); }
.sd-pad button:active { transform: scale(.95); }

/* ---------- 打字 ---------- */
.type-box {
  width: 100%; padding: 18px;
  border-radius: 14px; background: #131832; border: 1px solid var(--line);
  font-size: clamp(15px, 4vw, 20px); line-height: 1.9;
  letter-spacing: .5px; word-break: break-word; white-space: pre-wrap;
  min-height: 120px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.type-box span { border-radius: 3px; }
.type-box .done { color: #2fe0a8; }
.type-box .bad { color: #ff5c7a; background: rgba(255, 92, 122, .16); }
.type-box .cur { background: rgba(91, 140, 255, .34); box-shadow: inset 2px 0 0 var(--accent); color: #fff; }
.type-box .rest { color: #6d76a0; }
.type-input {
  width: 100%; padding: 13px 16px;
  font-size: 16px; font-family: inherit;
  color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; outline: none;
}
.type-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, .18); }

/* ---------- 移动端 ---------- */
@media (max-width: 640px) {
  .topbar { padding: 12px 14px; }
  .topbar h1 { font-size: 15px; }
  .view { padding: 16px 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .card { padding: 13px; }
  .card .desc { display: none; }
  .game-root { gap: 11px; }
}
