/* ============================================================
 * 每日数字记录 - 移动端样式
 * 主色 #582FFF，仅移动端自适应（最大宽度 480px 居中）
 * ============================================================ */
:root {
  --primary: #582FFF;
  --primary-light: #7B5CFF;
  --primary-bg: #F1EDFF;
  --danger: #FF4D4F;
  --text: #1F2329;
  --text-sub: #8A8F99;
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --radius-card: 16px;
  --radius-btn: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --transition: all 200ms ease-in-out;
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

#app.no-tab { padding-bottom: 0; }

/* ---------------- 通用 ---------------- */
.page { padding: 16px; animation: fadeIn 200ms ease-in-out; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-btn);
  font-size: 1rem;
  padding: 12px 20px;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 12px rgba(88, 47, 255, 0.35);
}
.btn-primary:active { box-shadow: 0 2px 6px rgba(88, 47, 255, 0.3); }

.btn-block { width: 100%; }

.btn-ghost {
  background: var(--primary-bg);
  color: var(--primary);
}

.btn-danger-ghost {
  background: #FFF1F0;
  color: var(--danger);
}

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; border-radius: 8px; }

/* 表单 */
.form-item { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.form-input,
.form-select {
  width: 100%;
  border: 1.5px solid #E5E6EB;
  border-radius: var(--radius-btn);
  padding: 12px 14px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  transition: var(--transition);
  outline: none;
  appearance: none;
}

.form-input:focus,
.form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(88, 47, 255, 0.12); }

.form-input.input-error { border-color: var(--danger); }

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 6px;
  min-height: 1em;
}

/* 页头 */
.page-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: calc(20px + env(safe-area-inset-top)) 16px 20px;
  border-radius: 0 0 24px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header .title { font-size: 1.25rem; font-weight: 600; }
.page-header .sub { font-size: 0.75rem; opacity: 0.85; margin-top: 4px; }

.header-back {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
}
.header-back:active { background: rgba(255, 255, 255, 0.35); }

/* 底部标签栏 */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: #fff;
  border-top: 1px solid #F0F0F0;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}

.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 6px;
  color: var(--text-sub);
  font-size: 0.6875rem;
  cursor: pointer;
  transition: var(--transition);
  background: none;
  border: none;
}

.tabbar-item .icon { font-size: 1.25rem; margin-bottom: 2px; }
.tabbar-item.active { color: var(--primary); }
.tabbar-item:active { opacity: 0.7; }

/* 徽章 / 筹码 */
.badge {
  display: inline-block;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 0.6875rem;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 500;
}

.num-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 600;
  margin: 3px;
}

.num-chip.hl { background: var(--primary); color: #fff; }
/* 幸运号码：命中结果中包含当日幸运号码时红底显示 */
.num-chip.lucky { background: var(--danger); color: #fff; border-color: var(--danger); }

/* 等级标签（SSS/A/B/C/D） */
.grade-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: #b8860b;
  background: linear-gradient(135deg, #fff8e1, #ffecb3);
  border: 1px solid #f0d060;
  margin-right: 4px;
}
.grade-chip.sss { color: #c0392b; background: linear-gradient(135deg, #ffeaea, #ffd6d6); border-color: #ff9d9d; }

/* 等级多选框组（结果面板） */
.grade-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.grade-opt {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 10px; border: 1.5px solid #e2e4ea;
  font-size: 0.8125rem; font-weight: 600; color: var(--text-sub);
  cursor: pointer; transition: all 0.2s ease;
}
.grade-opt.on { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

/* 用户列表 */
.user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  transition: var(--transition);
}

.user-item:active { transform: scale(0.98); }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 1rem; font-weight: 600; }
.user-meta { font-size: 0.75rem; color: var(--text-sub); margin-top: 4px; }

/* 特长选择卡片 */
.spec-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

.spec-option {
  border: 1.5px solid #E5E6EB;
  border-radius: var(--radius-btn);
  padding: 12px 0;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  transition: var(--transition);
  background: #fff;
}

.spec-option.selected {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(88, 47, 255, 0.1);
}

.spec-option:active { transform: scale(0.95); }

/* 用户筹码（自动换行，避免用户多时无法全部展示） */
.chip-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 2px 10px;
}

/* 特长 4/9 的 +12n 扩展预览 */
.expand-preview {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--primary-bg);
  border-radius: 12px;
}

.user-chip {
  flex-shrink: 0;
  border: 1.5px solid #E5E6EB;
  background: #fff;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
}

.user-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(88, 47, 255, 0.3);
}

/* 数字快捷选择网格 */
.num-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.num-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.num-grid.cols-5 { grid-template-columns: repeat(5, 1fr); }
.num-grid.cols-6 { grid-template-columns: repeat(6, 1fr); }
.num-grid.cols-7 { grid-template-columns: repeat(7, 1fr); }

.num-btn {
  aspect-ratio: 1;
  border: 1.5px solid #E5E6EB;
  border-radius: 50%;
  background: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.num-grid.cols-7 .num-btn { font-size: 0.8125rem; }

.num-btn.selected {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 3px 8px rgba(88, 47, 255, 0.35);
}

.num-btn:disabled:not(.selected) { opacity: 0.35; cursor: not-allowed; }
.num-btn:active:not(:disabled) { transform: scale(0.9); }

.counter {
  font-size: 0.875rem;
  color: var(--text-sub);
}
.counter strong { color: var(--primary); font-size: 1.125rem; }

/* 记录项 */
.record-item {
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.record-date { font-size: 0.9375rem; font-weight: 600; }

/* 比对日期复选 */
.date-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid #E5E6EB;
  border-radius: var(--radius-btn);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
  background: #fff;
}

.date-check.selected { border-color: var(--primary); background: var(--primary-bg); }

.date-check .box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid #C9CDD4;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: var(--transition);
}

.date-check.selected .box { background: var(--primary); border-color: var(--primary); }

.date-check .info { flex: 1; min-width: 0; }
.date-check .d { font-weight: 600; font-size: 0.9375rem; }
.date-check .n { font-size: 0.75rem; color: var(--text-sub); margin-top: 2px; word-break: break-all; }

/* 结果区 */
.result-panel {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-card);
  color: #fff;
  padding: 18px 16px;
  box-shadow: 0 6px 20px rgba(88, 47, 255, 0.35);
  margin-bottom: 16px;
}

.result-panel .r-title { font-size: 0.875rem; opacity: 0.9; margin-bottom: 10px; }
.result-panel .r-count { font-size: 1.75rem; font-weight: 700; margin-bottom: 10px; }
.result-panel .num-chip { background: rgba(255, 255, 255, 0.22); color: #fff; }

.result-empty {
  font-size: 0.9375rem;
  opacity: 0.9;
}

/* 空状态 */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-sub);
}
.empty .icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty .text { font-size: 0.875rem; }

/* 区块标题 */
.section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 4px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title .link {
  font-size: 0.8125rem;
  color: var(--primary);
  font-weight: 400;
  cursor: pointer;
  border: none;
  background: none;
}

/* 登录页 */
.login-wrap {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-light) 45%, var(--bg) 45.2%);
  padding: 0 24px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.login-brand { text-align: center; color: #fff; margin-bottom: 32px; }
.login-brand .logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  backdrop-filter: blur(4px);
}
.login-brand .name { font-size: 1.375rem; font-weight: 700; letter-spacing: 1px; }
.login-brand .slogan { font-size: 0.8125rem; opacity: 0.85; margin-top: 6px; }

.login-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  padding: 24px 20px;
  margin-bottom: 24px;
}

.login-tip { text-align: center; font-size: 0.75rem; color: var(--text-sub); }

/* Toast */
.toast {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.875rem;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  z-index: 999;
  max-width: 80%;
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(255, 77, 79, 0.92); }
.toast.success { background: rgba(88, 47, 255, 0.92); }

/* 加载中 */
.btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* 双列输入 */
.form-row { display: flex; gap: 12px; }
.form-row .form-item { flex: 1; }

/* 确认弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 200ms ease-in-out;
}

.modal {
  background: #fff;
  border-radius: 20px;
  padding: 24px 20px;
  width: 82%;
  max-width: 340px;
  text-align: center;
}

.modal .m-title { font-size: 1.0625rem; font-weight: 600; margin-bottom: 8px; }
.modal .m-desc { font-size: 0.875rem; color: var(--text-sub); margin-bottom: 20px; }
.modal .m-actions { display: flex; gap: 12px; }

/* 比对页模式切换 */
.mode-switch {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: #fff;
  border-radius: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.mode-tab {
  flex: 1;
  padding: 10px 0;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--text-sub);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms ease-in-out;
}

.mode-tab.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 12px rgba(88, 47, 255, 0.3);
}
.modal .m-actions .btn { flex: 1; }
