/* ===== 通用组件：卡片、按钮、顶栏、弹窗、Toast、难度 ===== */

/* ===== 首页游戏宫格 ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
}
.card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 14px 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  position: relative; overflow: hidden;
}
.card:hover, .card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--grape);
}
.card .emoji {
  font-size: 40px; line-height: 1; width: 64px; height: 64px;
  display: grid; place-items: center; border-radius: 16px;
  background: var(--surface-2);
}
.card h3 { font-size: 17px; margin: 2px 0 0; }
.card p { font-size: 12.5px; color: var(--muted); margin: 0; }
.card .tag {
  position: absolute; top: 10px; right: 10px;
  font-size: 11px; font-weight: 700; color: #fff;
  background: var(--coral); padding: 2px 8px; border-radius: 999px;
}
.card .tag.hard { background: var(--grape); }
.card .tag.mid  { background: var(--sky); }

/* ===== 游戏内顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--line);
}
.icon-btn {
  min-width: var(--tap); min-height: var(--tap);
  border: 2px solid var(--line); background: var(--surface);
  border-radius: 14px; font-size: 20px; font-weight: 800;
  color: var(--ink); display: grid; place-items: center;
  transition: transform .1s ease, background .15s ease;
}
.icon-btn:active { transform: scale(.92); }
#game-title { font-size: clamp(17px, 4.6vw, 22px); margin: 0; flex: 1; }
.topbar .spacer { flex: 1; }
.topbar .meta { font-size: 13px; color: var(--muted); font-weight: 700; }

/* ===== 游戏内容容器 ===== */
.game-wrap {
  width: min(680px, 100%); margin: 0 auto; padding: 18px 14px 60px;
}

/* ===== 按钮 ===== */
.btn {
  min-height: var(--tap);
  border: none; border-radius: 14px;
  padding: 0 18px; font-size: 15px; font-weight: 800;
  color: #fff; background: var(--grape);
  box-shadow: var(--shadow-sm);
  transition: transform .1s ease, filter .15s ease;
}
.btn:active { transform: scale(.96); }
.btn.secondary { background: var(--surface); color: var(--ink); border: 2px solid var(--line); }
.btn.coral { background: var(--coral); }
.btn.mint { background: var(--mint); }
.btn.sun { background: var(--sun); color: var(--ink); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* 行内按钮组 */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.row.end { justify-content: flex-end; }
.mt { margin-top: 14px; }
.mt-s { margin-top: 8px; }

/* ===== 难度 / 选项胶囊 ===== */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface);
  font-weight: 700; font-size: 14px; color: var(--ink);
  transition: all .12s ease;
}
.chip[aria-pressed="true"] {
  background: var(--grape); color: #fff; border-color: var(--grape);
}

/* ===== 弹窗 ===== */
.modal-back {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(43,36,64,0.45);
  display: none; place-items: center; padding: 18px;
}
.modal-back.show { display: grid; animation: fade .2s ease; }
.modal {
  width: min(420px, 100%);
  background: var(--surface); border-radius: 22px;
  padding: 22px; text-align: center; box-shadow: var(--shadow);
  animation: pop .22s cubic-bezier(.2,1.3,.5,1);
}
.modal h2 { font-size: 22px; }
.modal p { color: var(--muted); margin: 6px 0 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg); color: var(--toast-fg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 700; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 60; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 帮助文本 ===== */
.help {
  background: var(--surface-2); border: 2px dashed var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 13.5px; color: var(--ink);
}
.help b { color: var(--grape); }

/* 通用网格棋盘基类由各自 game.css 细化 */

/* ===== 设备兼容徽标 ===== */
.dev { display: flex; gap: 4px; margin-top: 10px; }
.dev-ic {
  font-style: normal; font-size: 10.5px; line-height: 1; padding: 3px 6px;
  border-radius: 6px; border: 1px solid var(--line); color: #9fb3d1;
  background: var(--surface-2); opacity: .55;
}
.dev-ic.on { color: #0c2a17; background: #6bcb77; border-color: #6bcb77; opacity: 1; font-weight: 700; }

/* ===== 数字键盘（数独类触屏输入） ===== */
.palette { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 320px; margin-left: auto; margin-right: auto; }
.pal-btn {
  width: 40px; height: 44px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 18px; font-weight: 700; cursor: pointer;
}
.pal-btn:active { background: var(--grape); color: #fff; }
.pal-btn.erase { color: #e23b3b; }

/* ===== 通用方向键 / 触屏控制（多端通用） ===== */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 52px);
  gap: 8px;
  justify-content: center;
}
.dpad .dp {
  font-size: 22px; border: none; border-radius: 12px;
  background: var(--surface-2); color: var(--ink); cursor: pointer;
  display: grid; place-items: center; user-select: none; -webkit-user-select: none;
}
.dpad .dp:active { background: var(--grape); color: #fff; }
.dpad .up { grid-column: 2; grid-row: 1; }
.dpad .left { grid-column: 1; grid-row: 2; }
.dpad .right { grid-column: 3; grid-row: 2; }
.dpad .down { grid-column: 2; grid-row: 2; }

/* 左右/上下 控制按钮行 */
.ctrl-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ctrl-btn {
  min-width: 56px; padding: 12px 16px; border-radius: 12px; border: none;
  background: var(--surface-2); color: var(--ink); font-size: 18px; font-weight: 700;
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.ctrl-btn:active { background: var(--grape); color: #fff; }

/* ============================================================
 * 首页 · 紧凑 App 风格（像手机 App 一样）
 * ============================================================ */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 10px 14px 8px;
}
.appbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-size: 20px; font-weight: 900; letter-spacing: .5px; display: flex; align-items: center; gap: 6px; }
.brand span {
  background: linear-gradient(90deg, var(--coral), var(--grape), var(--sky));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.search-wrap { margin-top: 10px; }
.search {
  width: 100%; min-height: 42px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text); font-size: 15px; padding: 0 14px; font-family: inherit;
}
.search:focus-visible { outline: none; border-color: var(--grape); }
.tabstrip {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-bottom: 2px;
}
.tab {
  flex: 0 1 auto; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--bg); color: var(--ink);
  font-weight: 800; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: all .12s ease;
}
.tab.active { background: var(--grape); color: #fff; border-color: var(--grape); }
.appmain { width: min(960px, 100%); margin: 0 auto; padding: 14px 14px 56px; }
.count { text-align: center; color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.apgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 14px 10px;
}
.apptile { display: flex; flex-direction: column; align-items: center; gap: 7px; text-decoration: none; }
.appicon {
  width: 100%; aspect-ratio: 1 / 1; max-width: 84px; display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.appicon .emoji { font-size: 34px; line-height: 1; }
.apptile:active .appicon { transform: scale(.94); }
.apptile:hover .appicon { border-color: var(--grape); box-shadow: var(--shadow); }
.apptitle { font-size: 12.5px; font-weight: 700; color: var(--text); text-align: center; line-height: 1.25; }

