/* 一局三分钟 · Web 版样式
   移动优先；桌面上居中成一列，宽度不超过 560px，观感接近手机。 */

:root {
  --bg: #eef2ff;
  --bg2: #f8fafc;
  --card: #ffffff;
  --ink: #1e1b4b;
  --ink2: #4c1d95;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --accent: #f97316;
  --ok: #16a34a;
  --warn: #ef4444;
  --radius: 18px;
  --shadow: 0 8px 26px rgba(30, 27, 75, .10);
  --shadow-sm: 0 2px 10px rgba(30, 27, 75, .07);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 14px 34px;
  min-height: 100vh;
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 340px, #f8fafc 100%);
}

a { color: var(--primary); text-decoration: none; }

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 10px;
  background: rgba(238, 242, 255, .88);
  backdrop-filter: saturate(160%) blur(10px);
}

.topbar .logo {
  width: 34px; height: 34px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  flex: none;
}

.topbar .brand { font-weight: 800; letter-spacing: .3px; font-size: 17px; }

.topbar .spacer { flex: 1; }

.icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  width: 36px; height: 36px;
  border-radius: 11px;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex: none;
}
.icon-btn:active { transform: scale(.94); }

.pill-btn {
  border: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  padding: 9px 15px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .28);
}
.pill-btn:active { transform: scale(.96); }
.pill-btn.ghost {
  background: #fff; color: var(--ink2);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}

/* ---------------- 首屏 ---------------- */

.hero {
  margin: 4px 0 16px;
  padding: 20px 18px;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #a855f7 100%);
  box-shadow: 0 14px 34px rgba(79, 70, 229, .28);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; right: -40px; top: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255, 255, 255, .14);
}
.hero h1 { margin: 0; font-size: 26px; letter-spacing: 1px; }
.hero .sub { margin-top: 6px; font-size: 13px; opacity: .92; }
.hero .desc { margin-top: 12px; font-size: 13px; opacity: .88; line-height: 1.6; }
.hero .stats { display: flex; gap: 18px; margin-top: 14px; }
.hero .stats b { display: block; font-size: 19px; }
.hero .stats span { font-size: 11px; opacity: .82; }

/* ---------------- 搜索 / 分组 ---------------- */

.search {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 9px 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}
.search input {
  border: 0; outline: 0; flex: 1; font-size: 15px;
  background: transparent; color: var(--ink);
}

.tabs {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 4px; margin-bottom: 12px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 1px solid var(--line); background: #fff;
  color: var(--muted); padding: 7px 14px; border-radius: 999px;
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tab.on {
  background: var(--ink); color: #fff; border-color: var(--ink);
  font-weight: 700;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(226, 232, 240, .9);
  cursor: pointer;
  position: relative;
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:active { transform: scale(.975); }
.card:hover { box-shadow: var(--shadow); }

.card .ico {
  width: 46px; height: 46px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-bottom: 9px;
}
.card .nm { font-weight: 800; font-size: 15px; }
.card .ds {
  font-size: 12px; color: var(--muted); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 32px;
}
.card .tg { margin-top: 8px; display: flex; gap: 5px; flex-wrap: wrap; }
.card .tg i {
  font-style: normal; font-size: 10px; padding: 2px 7px;
  border-radius: 999px; background: #f1f5f9; color: #64748b;
}
.card .best {
  position: absolute; right: 12px; top: 12px;
  font-size: 10px; color: var(--ok); font-weight: 700;
}

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

/* ---------------- 游戏页 ---------------- */

.play {
  position: fixed; inset: 0; z-index: 40;
  background: var(--bg);
  display: flex; flex-direction: column;
  max-width: 560px; margin: 0 auto;
}

.play-top {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .95);
  border-bottom: 1px solid var(--line);
}
.play-top .t { font-weight: 800; font-size: 16px; flex: 1; text-align: center; }
.play-hud {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px; font-size: 13px; color: var(--muted);
  background: #fff; border-bottom: 1px solid var(--line);
}
.play-hud b { color: var(--ink); font-size: 15px; }

.stage {
  flex: 1;
  position: relative;
  padding: 8px 8px 0;
  min-height: 0;
}
.stage canvas {
  width: 100%; height: 100%;
  display: block;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  touch-action: none;
  cursor: crosshair;
}

.play-bottom { padding: 8px 12px 12px; }

/* ---------------- 遮罩面板 ---------------- */

.mask {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .58);
  display: flex; align-items: center; justify-content: center;
  padding: 18px; border-radius: 16px;
  backdrop-filter: blur(2px);
  z-index: 20;
}
.panel {
  background: #fff; border-radius: 20px;
  padding: 20px; width: 100%; max-width: 340px;
  box-shadow: 0 22px 48px rgba(2, 6, 23, .3);
  text-align: center;
  max-height: 100%; overflow: auto;
}
.panel h2 { margin: 0 0 4px; font-size: 22px; }
.panel .big { font-size: 34px; font-weight: 800; color: var(--primary); margin: 6px 0; }
.panel .meta { font-size: 13px; color: var(--muted); }
.panel .badge {
  display: inline-block; margin-top: 6px; font-size: 12px;
  background: #fef3c7; color: #b45309; padding: 3px 10px; border-radius: 999px;
}
.actions { display: grid; gap: 9px; margin-top: 16px; }
.btn {
  border: 0; border-radius: 13px; padding: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  background: #f1f5f9; color: var(--ink);
}
.btn:active { transform: scale(.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 8px 18px rgba(79, 70, 229, .26);
}
.btn.warm { background: linear-gradient(135deg, #f97316, #ef4444); color: #fff; }
.btn.ghost { background: #fff; border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.rankbox { margin-top: 14px; text-align: left; border-top: 1px dashed var(--line); padding-top: 12px; }
.rankbox h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 700; }
.rankrow {
  display: flex; justify-content: space-between; font-size: 13px;
  padding: 4px 0; color: var(--ink);
}
.rankrow .no { width: 22px; color: var(--muted); }

/* ---------------- 我的 ---------------- */

.section {
  background: #fff; border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
}
.section h3 { margin: 0 0 10px; font-size: 15px; }
.kv { display: flex; justify-content: space-between; font-size: 14px; padding: 6px 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 700; }

.code-box {
  display: flex; align-items: center; gap: 10px;
  background: #eef2ff; border: 1px dashed #c7d2fe;
  border-radius: 14px; padding: 12px 14px; margin: 10px 0;
}
.code-box .code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 22px; font-weight: 800; letter-spacing: 3px; color: var(--primary);
  flex: 1;
}
.link-box {
  font-size: 12px; color: var(--muted); word-break: break-all;
  background: #f8fafc; border-radius: 10px; padding: 10px;
  border: 1px solid var(--line);
}
.tip { font-size: 12px; color: var(--muted); margin-top: 8px; line-height: 1.6; }
.tip.warn { color: #b45309; background: #fffbeb; border-radius: 10px; padding: 9px 11px; }

.footer {
  text-align: center; font-size: 12px; color: var(--muted);
  padding: 18px 0 0; line-height: 1.8;
}
.footer a { color: var(--muted); text-decoration: underline; }

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

.ad-slot {
  border: 1px dashed #cbd5e1; border-radius: 12px;
  background: #fff; padding: 10px; text-align: center;
  font-size: 12px; color: var(--muted);
}
.ad-slot small { display: block; font-size: 10px; color: #94a3b8; }

.ad-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(2, 6, 23, .72);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.ad-card {
  background: #fff; border-radius: 20px; padding: 18px;
  width: 100%; max-width: 340px; text-align: center;
}
.ad-label {
  display: inline-block; font-size: 10px; color: #94a3b8;
  border: 1px solid #e2e8f0; border-radius: 999px; padding: 1px 8px;
  margin-bottom: 10px;
}
.ad-mock { padding: 10px 4px 4px; }
.ad-mock-title { font-size: 17px; font-weight: 800; margin: 0 0 6px; }
.ad-mock-desc { font-size: 12px; color: var(--muted); margin: 0 0 12px; line-height: 1.6; }
.ad-timer {
  font-size: 34px; font-weight: 800; color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.ad-actions { margin-top: 14px; }

/* ---------------- toast ---------------- */

.toast {
  position: fixed; left: 50%; bottom: 44px;
  transform: translate(-50%, 20px);
  background: rgba(15, 23, 42, .92); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 99; max-width: 82vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 桌面适配 ---------------- */

@media (min-width: 620px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
