:root {
  --bg: #14102a;
  --bg2: #1e1840;
  --card: #26204d;
  --card2: #2f285c;
  --text: #f3eefe;
  --muted: #b6aedc;
  --accent: #8f7bff;
  --accent2: #b14dff;
  --green: #4ade80;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  /* 图片加载前的兜底底色 */
  background: #0d0a1f;
}
body {
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* 全屏背景图。
   用 fixed 定位的伪元素来实现，而不是 background-attachment: fixed ——
   后者在 iOS Safari 上会缩放异常。
   第一层是半透明深色遮罩，压暗背景图，保证卡片和文字清晰可读。
   想调亮/调暗：改下面那行 0.58（越小背景越明显，越大越暗）。 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(13, 10, 31, 0.58), rgba(13, 10, 31, 0.58)),
    url("/static/img/bg.jpg");
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
}

a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0 0 8px; }

.container { max-width: 1080px; margin: 0 auto; padding: 12px; }

/* 导航 */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(30, 24, 64, .9);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
}
.navbar .brand { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.navbar .brand .logo { color: var(--accent2); }
.navbar .actions { display: flex; gap: 8px; align-items: center; }

/* 卡片 */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; border: 1px solid rgba(143,123,255,.15);
}
.card h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card2); color: var(--text); border: 1px solid rgba(143,123,255,.35);
  padding: 12px 16px; border-radius: 12px; cursor: pointer; font-size: 16px;
  font-weight: 600; text-align: center; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: none; }
.btn.green { background: linear-gradient(135deg, #22c55e, #15803d); border: none; }
.btn.red { background: linear-gradient(135deg, #ef4444, #b91c1c); border: none; }
.btn.amber { background: linear-gradient(135deg, #f59e0b, #b45309); border: none; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.big { padding: 16px; font-size: 18px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* 大数字状态 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--bg2); border-radius: 12px; padding: 12px; text-align: center; }
.stat .num { font-size: 26px; font-weight: 800; color: var(--accent); }
.stat .label { font-size: 13px; color: var(--muted); }

/* 表格（PC） */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid rgba(143,123,255,.15); }
th { color: var(--muted); font-weight: 600; }

/* 表单 */
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid rgba(143,123,255,.35);
  background: var(--bg2); color: var(--text); font-size: 16px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); }

/* 徽章/状态 */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge.ok { background: rgba(74,222,128,.15); color: var(--green); }
.badge.warn { background: rgba(251,191,36,.15); color: var(--amber); }
.badge.danger { background: rgba(248,113,113,.15); color: var(--red); }
.badge.muted { background: rgba(182,174,220,.15); color: var(--muted); }

/* 模态框 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--card); border-radius: 16px; padding: 20px;
  width: 100%; max-width: 440px; border: 1px solid rgba(143,123,255,.3);
  max-height: 90vh; overflow: auto;
}
.modal h3 { font-size: 18px; }

/* 相机 */
.camera-video { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 4/3; object-fit: cover; }
.camera-box { position: relative; }
.camera-hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 8px; }

/* Toast */
#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 200; width: min(92vw, 420px); }
.toast {
  background: var(--card2); border: 1px solid rgba(143,123,255,.4);
  padding: 12px 16px; border-radius: 12px; margin-bottom: 8px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: slidein .2s ease;
}
.toast.err { border-color: var(--red); }
.toast.ok { border-color: var(--green); }
@keyframes slidein { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* 二维码展示 */
.qr-img { width: 200px; height: 200px; background: #fff; border-radius: 12px; padding: 8px; }
.redeem-code { font-family: monospace; font-size: 18px; letter-spacing: 2px; }

/* 规则文本 */
.rules { line-height: 1.7; color: #ded8ff; }
.rules h4 { margin: 14px 0 6px; color: var(--accent); }
.rules table { font-size: 13px; }

/* 分割布局 */
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.col { flex: 1 1 300px; }

.pill { display: inline-block; background: var(--bg2); padding: 6px 12px; border-radius: 999px; margin: 3px; }

.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.mono { font-family: monospace; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.center { text-align: center; }
