:root {
  --bg: #14110d;
  --bg-soft: #1e1a15;
  --card: #262119;
  --line: #3a3226;
  --gold: #f0c04a;
  --gold-dim: #b8912f;
  --text: #f3ece0;
  --muted: #a1958a;
  --red: #d9534f;
  --green: #5cb85c;
  --tabbar-h: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: #ffd76a; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  background: rgba(30, 26, 21, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  font-size: 17px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 1px;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav { display: flex; gap: 4px; flex: 1; }

.nav a {
  color: var(--muted);
  padding: 7px 13px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
}
.nav a:hover { background: #2b251c; color: var(--text); }
.nav a.active { color: var(--gold); background: #2b251c; }

.userbox { display: flex; align-items: center; gap: 12px; font-size: 13px; margin-left: auto; }
.userbox .email { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

/* ---------------- 布局 ---------------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 26px 20px 60px; }

h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
h2 { font-size: 17px; font-weight: 600; margin: 26px 0 12px; }
.sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

/* ---------------- 公告栏 ---------------- */
.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, #3a2f14, #2a2416);
  border: 1px solid #4d3f1c;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13px;
  color: #f0d79a;
}
.notice .tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  color: #221c10;
  background: var(--gold);
  border-radius: 4px;
  padding: 1px 7px;
}
.notice .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 分类筛选 ---------------- */
.cats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.cat {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.cat:hover { color: var(--text); border-color: var(--gold-dim); }
.cat.on { background: var(--gold); border-color: var(--gold); color: #221c10; font-weight: 600; }
.cat .n { font-size: 11px; opacity: .7; font-family: ui-monospace, Consolas, monospace; }
.cat.on .n { opacity: .6; }

.cat-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  padding-left: 2px;
}
.cat-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 12px;
  background: var(--gold-dim);
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: -1px;
}

/* ---------------- 游戏网格 ---------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--gold-dim); transform: translateY(-2px); }

.cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  height: auto;
  background: linear-gradient(135deg, #3a2f1c, #211a12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--gold-dim);
  letter-spacing: 3px;
  overflow: hidden;
}

.card-body { padding: 12px 13px 13px; flex: 1; display: flex; flex-direction: column; }
.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.card-desc { color: var(--muted); font-size: 12.5px; flex: 1; margin-bottom: 12px; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  background: #3a2f1c;
  color: var(--gold);
  margin-bottom: 8px;
  align-self: flex-start;
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 6px;
  background: var(--gold);
  color: #221c10;
  font-weight: 600;
  text-align: center;
  transition: opacity .15s;
  width: 100%;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 400; }
.btn.ghost:hover { color: var(--text); border-color: var(--gold-dim); }
.btn.sm { width: auto; padding: 6px 12px; font-size: 13px; }

/* ---------------- 表单 ---------------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
  max-width: 420px;
  margin: 30px auto;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  background: #1a1611;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold-dim); }

.msg {
  padding: 10px 13px;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 14px;
  display: none;
}
.msg.err { background: #3a1f1f; color: #f0a09c; border: 1px solid #5c2c2c; display: block; }
.msg.ok  { background: #1f3320; color: #98d998; border: 1px solid #2c5c2e; display: block; }

/* ---------------- 后台用 ---------------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab {
  flex: 1;
  padding: 9px;
  text-align: center;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}
.tab.on { background: var(--gold); color: #221c10; border-color: var(--gold); font-weight: 600; }

.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
td.code { font-family: ui-monospace, Consolas, monospace; letter-spacing: .5px; }
.used { color: var(--muted); }
.fresh { color: var(--green); }

.cellsel { width: auto; min-width: 96px; padding: 5px 8px; font-size: 12.5px; }

.statrow { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 20px;
  min-width: 120px;
  flex: 1;
}
.stat .n { font-size: 24px; font-weight: 600; color: var(--gold); }
.stat .l { font-size: 12px; color: var(--muted); }

.codebox {
  background: #1a1611;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  max-height: 260px;
  overflow: auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.9;
  margin-top: 14px;
  white-space: pre-wrap;
  word-break: break-all;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row .field { flex: 1; min-width: 120px; margin-bottom: 0; }

/* ---------------- 搜索 / 更多 ---------------- */
.searchbar { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.searchbar input {
  flex: 1; padding: 11px 16px; border-radius: 22px; border: 1px solid var(--line);
  background: #1a1611; color: var(--text); font-size: 14px; outline: none;
}
.searchbar input:focus { border-color: var(--gold-dim); }
.searchbar .count { font-size: 13px; color: var(--muted); white-space: nowrap; }

.morebox { text-align: center; padding: 18px 0 8px; }
.morebox button {
  padding: 11px 28px; border-radius: 22px; border: 1px solid #2b3244;
  background: #171c28; color: #c9d1e4; font-size: 14px; cursor: pointer; font-family: inherit;
}
.morebox button:hover { border-color: var(--gold-dim); color: #fff; }

/* ---------------- 底部标签栏（仅手机） ---------------- */
.tabbar { display: none; }

.empty { color: var(--muted); text-align: center; padding: 40px 0; font-size: 13px; }
.hidden { display: none !important; }
.flash { animation: flash .5s; }
@keyframes flash { 0% { background: #3a2f1c; } 100% { background: transparent; } }

/* 我的页底部管理入口（不显眼，但自己能找到） */
.foot-admin {
  text-align: center;
  padding: 34px 0 6px;
}
.foot-admin a {
  color: #5d5546;
  font-size: 12px;
  text-decoration: none;
}
.foot-admin a:hover { color: var(--muted); }

/* =========================================================
   手机端（< 768px）
   ========================================================= */
@media (max-width: 767px) {
  /* 顶栏只留 logo + 登录/用户，导航挪到底部标签栏 */
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar .nav { display: none; }
  .brand { font-size: 16px; }

  /* 底部标签栏（适配 iPhone 底部安全区） */
  .tabbar {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 60;
    background: rgba(24, 20, 15, .96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--muted);
    font-size: 11px;
    min-height: 44px;              /* 触控目标 */
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a.active { color: var(--gold); }
  .tabbar svg { width: 22px; height: 22px; display: block; }

  /* 给底部栏腾出空间 */
  .wrap { padding: 18px 14px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 22px); }
  .panel { margin: 18px auto; padding: 18px; }

  h1 { font-size: 20px; }

  /* 分类横向滑动，不再占三行 */
  .cats {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0 -14px 14px;
    padding: 2px 14px 6px;
  }
  .cats::-webkit-scrollbar { display: none; }
  .cat { flex: 0 0 auto; padding: 7px 13px; }

  /* 两列紧凑卡片：一屏看 4 款 */
  .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .card { border-radius: 9px; }
  .card:hover { transform: none; }
  .cover { aspect-ratio: 16 / 11; font-size: 17px; letter-spacing: 2px; }
  .card-body { padding: 8px 9px 10px; }
  .card-title { font-size: 13px; margin-bottom: 6px; -webkit-line-clamp: 1; }
  .badge { font-size: 10px; padding: 1px 6px; margin-bottom: 5px; }
  .btn { padding: 8px 10px; font-size: 12.5px; border-radius: 6px; }
  .card .btn.ghost { font-weight: 500; }

  .notice { margin: 0 -2px 14px; font-size: 12.5px; }

  /* 后台表格在手机上横向滚动，不撑破布局 */
  .statrow { gap: 8px; }
  .stat { padding: 10px 12px; min-width: 0; }
  .stat .n { font-size: 19px; }
  .row .field { min-width: 100%; }
  .userbox .email { display: none; }
}

/* 手机上更窄的屏（< 360px）再压一点 */
@media (max-width: 359px) {
  .brand { font-size: 14.5px; }
  .grid { gap: 8px; }
}
