/* ============================================================
   修改盒子 - 全局样式 (本地版)
   ============================================================ */

:root {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #222244;
  --bg-elevated: #252542;
  --text: #e0e0f0;
  --text-secondary: #a0a0c0;
  --muted: #7070a0;
  --primary: #6c5ce7;
  --primary-hover: #7c6cf7;
  --primary-glow: rgba(108, 92, 231, 0.3);
  --success: #00cec9;
  --warning: #fdcb6e;
  --danger: #ff7675;
  --border: #2a2a4a;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

[data-theme="light"] {
  --bg: #f4f4f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f0ff;
  --bg-elevated: #eeeef8;
  --text: #1a1a2e;
  --text-secondary: #555577;
  --muted: #8888aa;
  --border: #d0d0e0;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

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

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 0 12px;
  height: 56px; display: flex; align-items: center; gap: 12px;
}
.logo { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.logo:hover { color: var(--primary); }
.search-box {
  flex: 1; max-width: 440px; display: flex;
  background: var(--bg); border: 1px solid var(--border); border-radius: 24px;
  overflow: hidden; transition: var(--transition);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.search-box input {
  flex: 1; border: none; outline: none; padding: 8px 14px; font-size: .88rem;
  background: transparent; color: var(--text);
}
.search-box button {
  border: none; background: transparent; padding: 0 14px; cursor: pointer;
  font-size: 1rem; color: var(--muted); transition: var(--transition);
}
.search-box button:hover { color: var(--primary); }

.theme-toggle {
  background: none; border: 1px solid var(--border); border-radius: 50%;
  width: 36px; height: 36px; cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition); color: var(--text); flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--primary); }

/* ============================================================
   Layout
   ============================================================ */
.layout {
  max-width: 1440px; margin: 0 auto; padding: 12px;
  display: grid; grid-template-columns: 90px 1fr 90px; gap: 16px;
}
@media (max-width: 1200px) { .layout { grid-template-columns: 1fr; } .sidebar-left, .sidebar-right { display: none; } }

.sidebar-left { }
.qq-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 4px; text-align: center; position: sticky; top: 80px;
}
.qq-card .qq-icon { font-size: 1.6rem; margin-bottom: 4px; }
.qq-card .qq-label { font-size: .7rem; color: var(--muted); }
.qq-card .qq-number { font-size: .75rem; font-weight: 600; margin: 2px 0 8px; word-break: break-all; }
.qq-btn {
  display: inline-block; padding: 5px 10px; background: var(--primary);
  color: #fff; border-radius: 14px; font-size: .72rem; font-weight: 500;
  transition: var(--transition);
}
.qq-btn:hover { background: var(--primary-hover); color: #fff; }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative; overflow: hidden; border-radius: var(--radius);
  margin-bottom: 28px; min-height: 220px; display: flex; align-items: center;
  background: #1a1030 center/cover no-repeat;
}
.hero-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(15,15,26,.85) 0%, rgba(15,15,26,.6) 100%);
}
.hero-overlay { position: relative; z-index: 1; padding: 40px 36px; }
.hero-overlay h1 { font-size: 1.6rem; margin-bottom: 6px; }
.hero-overlay p { font-size: .95rem; color: var(--text-secondary); }
.hero-sub { font-size: .82rem !important; color: var(--muted) !important; margin-top: 4px; }

/* ============================================================
   Toolbar
   ============================================================ */
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.toolbar-title { font-size: 1.1rem; font-weight: 600; }
.sort-select {
  margin-left: auto; padding: 6px 14px; border: 1px solid var(--border);
  border-radius: 20px; background: var(--bg-card); color: var(--text);
  font-size: .82rem; cursor: pointer;
}

/* ============================================================
   Card Grid
   ============================================================ */
.card-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 28px; }
@media (max-width: 1280px) { .card-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 900px)  { .card-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px)  { .card-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; } .card-body { padding: 8px; } .card-title { font-size: .82rem; } }

.game-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  display: block; text-decoration: none; color: inherit;
}
.game-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}
.card-image {
  width: 100%; aspect-ratio: 6 / 9; background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.card-image img { width: 100%; height: 100%; object-fit: cover; }
.card-placeholder { font-size: 2.8rem; opacity: 0.4; }
.card-placeholder.large { font-size: 5rem; }
.card-body { padding: 12px; }
.card-title { font-size: .9rem; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-price { color: var(--danger); font-weight: 700; font-size: .92rem; margin: 4px 0; }
.card-meta { font-size: .72rem; color: var(--muted); display: flex; gap: 8px; }
.card-download-btn {
  margin-top: 8px; text-align: center; padding: 6px 0;
  background: var(--primary); color: #fff; border-radius: 6px;
  font-size: .78rem; font-weight: 500; transition: var(--transition);
}
.game-card:hover .card-download-btn { background: var(--primary-hover); }

/* ============================================================
   Pagination
   ============================================================ */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-bottom: 28px; flex-wrap: wrap; }
.pagination button {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: .82rem;
  transition: var(--transition);
}
.pagination button:hover:not(:disabled):not(.active) { border-color: var(--primary); color: var(--primary); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.35; cursor: default; }
.page-total { color: var(--muted); font-size: .78rem; margin-left: 6px; }

/* ============================================================
   Features
   ============================================================ */
.features { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 768px) { .features { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .features { grid-template-columns: 1fr; } }
.feature-item {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; text-align: center; transition: var(--transition);
}
.feature-item:hover { border-color: var(--primary); }
.feature-icon { font-size: 1.8rem; display: block; margin-bottom: 6px; }
.feature-item strong { display: block; font-size: .9rem; margin-bottom: 2px; }
.feature-item p { font-size: .78rem; color: var(--muted); }

/* ============================================================
   Footer
   ============================================================ */
.footer { border-top: 1px solid var(--border); padding: 18px 0; margin-top: 32px; }
.footer-inner { max-width: 1280px; margin: 0 auto; padding: 0 20px; display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); }

/* ============================================================
   Empty / Loading
   ============================================================ */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 1rem; }
.loading { text-align: center; padding: 60px; color: var(--muted); font-size: 1rem; }

/* ============================================================
   Detail Page
   ============================================================ */
.breadcrumb { padding: 10px 0; font-size: .82rem; color: var(--muted); }
.breadcrumb span { margin: 0 4px; }
.detail-container { animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.detail-header {
  display: flex; gap: 28px; margin-bottom: 24px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; align-items: flex-start;
}
@media (max-width: 768px) { .detail-header { flex-direction: column; } }
.detail-image { width: 240px; height: 240px; flex-shrink: 0; background: var(--bg-elevated); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.detail-image img { width: 100%; height: 100%; object-fit: cover; }
.detail-info { flex: 1; min-width: 0; }
.detail-info h1 { font-size: 1.5rem; margin-bottom: 4px; }
.detail-price { font-size: 1.4rem; font-weight: 700; color: var(--danger); margin-bottom: 8px; }
.detail-summary { color: var(--text-secondary); font-size: .9rem; margin-bottom: 12px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tag {
  display: inline-block; padding: 4px 10px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 16px; font-size: .78rem; color: var(--text-secondary);
}
.detail-stats { display: flex; gap: 18px; margin-bottom: 18px; font-size: .88rem; color: var(--muted); }
.download-btn, .buy-btn {
  display: inline-block; padding: 10px 32px; background: var(--primary); color: #fff;
  border: none; border-radius: 24px; font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: var(--transition); margin-right: 10px;
}
.download-btn:hover, .buy-btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 16px var(--primary-glow); }
.buy-btn { background: var(--success); }
.buy-btn:hover { background: #00e6d9; box-shadow: 0 4px 16px rgba(0, 206, 201, 0.3); }

.detail-desc, .detail-features {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 16px;
}
.detail-desc h3, .detail-features h3 { font-size: 1rem; margin-bottom: 10px; }
.detail-desc p { font-size: .88rem; color: var(--text-secondary); line-height: 1.8; }
.desc-content img { max-width: 100%; height: auto; border-radius: var(--radius); display: block; }
.desc-content { overflow: hidden; word-break: break-word; }
.feature-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.feature-tag {
  padding: 4px 10px; background: rgba(108, 92, 231, 0.12); color: var(--primary);
  border-radius: 6px; font-size: .8rem; font-weight: 500;
}

.detail-nav { display: flex; justify-content: space-between; margin-top: 16px; margin-bottom: 20px; }
.nav-link {
  padding: 7px 16px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 18px; font-size: .82rem; color: var(--text-secondary);
  transition: var(--transition);
}
.nav-link:hover { border-color: var(--primary); color: var(--primary); }

/* ============================================================
   Purchase flow
   ============================================================ */
.cardkey-display {
  background: linear-gradient(135deg, rgba(108,92,231,0.15), rgba(0,206,201,0.1));
  border: 2px dashed var(--primary); border-radius: var(--radius); padding: 20px 24px; margin: 16px 0; text-align: center;
}
.cardkey-display .ck-label { font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.cardkey-display .ck-key { font-size: 1.3rem; font-weight: 700; color: var(--success); letter-spacing: 2px; font-family: monospace; word-break: break-all; }
.cardkey-display .ck-hint { font-size: .78rem; color: var(--muted); margin-top: 6px; }

.qrcode-box {
  background: #fff; border-radius: var(--radius); padding: 16px; margin: 16px 0; text-align: center; display: inline-block;
}
.qrcode-box canvas { display: block; margin: 0 auto; }

/* toast */
.toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  padding: 10px 24px; background: var(--bg-elevated); color: var(--text);
  border: 1px solid var(--border); border-radius: 24px; font-size: .88rem;
  z-index: 9999; opacity: 0; pointer-events: none; transition: opacity .3s;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; max-width: 520px; width: 92%; max-height: 85vh; overflow-y: auto;
}
.modal h2 { font-size: 1.15rem; margin-bottom: 18px; }
.modal .modal-close {
  position: absolute; top: 14px; right: 14px; background: none; border: none;
  font-size: 1.2rem; cursor: pointer; color: var(--muted);
}

/* ============================================================
   Admin Page
   ============================================================ */
.admin-wrapper { max-width: 1280px; margin: 0 auto; padding: 20px; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
@media (max-width: 768px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center;
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .82rem; color: var(--muted); margin-top: 2px; }

.admin-tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab-btn {
  padding: 10px 20px; background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: .88rem; border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover { color: var(--text); }

.tab-toolbar { display: flex; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
  padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border);
  font-size: .86rem;
}
.admin-table th { color: var(--muted); font-weight: 600; background: var(--bg-elevated); white-space: nowrap; }
.admin-table tr:hover td { background: var(--bg-card-hover); }
.admin-table td .btn { white-space: nowrap; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-block; padding: 8px 18px; border-radius: 8px;
  font-size: .86rem; cursor: pointer; transition: var(--transition);
  border: none; font-weight: 500; font-family: var(--font);
}
.btn-xs { padding: 3px 10px; font-size: .74rem; border-radius: 5px; }
.btn-sm { padding: 5px 14px; font-size: .8rem; border-radius: 6px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-accent { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-accent:hover { background: var(--accent); color: #fff; }

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 3px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 6px; font-size: .85rem; background: var(--bg); color: var(--text);
  outline: none; transition: var(--transition); font-family: var(--font);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-glow);
}
.form-group textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }

/* ============================================================
   Tab Content
   ============================================================ */
.tab-content { padding: 0; }

/* ============================================================
   Card key lookup
   ============================================================ */
.cardkey-lookup {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.cardkey-lookup h3 { font-size: .95rem; margin-bottom: 10px; }
.lookup-row { display: flex; gap: 8px; }
.lookup-row input { flex: 1; }
.lookup-results { margin-top: 14px; }
.lookup-item {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin-bottom: 8px;
}
.lookup-item .lo-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.lookup-item .lo-name { font-weight: 600; }
.lookup-item .lo-status { font-size: .78rem; padding: 2px 8px; border-radius: 10px; }
.lookup-item .lo-status.paid { background: rgba(0,206,201,.15); color: var(--success); }
.lookup-item .lo-status.pending { background: rgba(253,203,110,.15); color: var(--warning); }
.lookup-item .lo-key { font-family: monospace; font-size: .88rem; color: var(--success); word-break: break-all; }
.lookup-item .lo-meta { font-size: .76rem; color: var(--muted); margin-top: 4px; }

/* ============================================================
   Order lookup link (topbar)
   ============================================================ */
.order-lookup-link {
  color: var(--text-secondary); font-size: .85rem; font-weight: 500;
  padding: 6px 12px; border-radius: 16px; transition: var(--transition);
}
.order-lookup-link:hover { color: var(--primary); background: var(--bg-elevated); }

/* ============================================================
   Card price row (index grid)
   ============================================================ */
.card-price-row { display: flex; gap: 6px; margin-top: 8px; }
.card-price { font-size: .72rem; padding: 3px 8px; border-radius: 10px; font-weight: 500; }
.card-price.free { background: rgba(0,206,201,.12); color: var(--success); }
.card-price.buy { background: rgba(108,92,231,.12); color: var(--primary); }

/* ============================================================
   Badges & Tips
   ============================================================ */
.tip { padding: 10px 14px; border-radius: 6px; background: var(--bg-elevated); font-size: .85rem; text-align: center; }
.tip.error { color: var(--danger); background: rgba(255,118,117,.1); }
.badge { font-size: .72rem; padding: 2px 8px; border-radius: 10px; }
.badge.ok { background: rgba(0,206,201,.15); color: var(--success); }
.badge.pend { background: rgba(253,203,110,.15); color: var(--warning); }

/* ============================================================
   Order item (lookup result)
   ============================================================ */
.order-item {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px 16px; margin-bottom: 8px; text-align: left;
}
.order-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: .88rem; }
.order-meta { font-size: .76rem; color: var(--muted); margin-bottom: 4px; }
.order-key { font-size: .85rem; margin-top: 4px; }
.order-key code { font-family: monospace; background: var(--bg); padding: 2px 6px; border-radius: 4px; color: var(--success); font-size: .82rem; word-break: break-all; }

/* ============================================================
   Detail actions (detail page)
   ============================================================ */
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.free-btn { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.free-btn:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }

/* ============================================================
   QR code placeholder (detail purchase)
   ============================================================ */
.qrcode-placeholder {
  background: var(--bg-elevated); border: 2px dashed var(--border);
  border-radius: var(--radius); padding: 20px; margin: 12px 0; text-align: center;
}

/* ============================================================
   Modal small variant
   ============================================================ */
.modal-sm { max-width: 400px; }

/* ============================================================
   Settings section
   ============================================================ */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
