:root {
  --bg: #f2f5f9;
  --bg-deep: #e9eef5;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --surface-tint: #f1f5fa;
  --line: #e4eaf3;
  --line-strong: #d5deea;
  --ink: #17223a;
  --ink-soft: #43516a;
  --sub: #68758c;
  --muted: #95a1b4;
  --teal: #0e9e8a;
  --teal-dark: #08796c;
  --teal-soft: #e4f7f3;
  --coral: #f06a5d;
  --coral-dark: #d25347;
  --coral-soft: #fdedea;
  --gold: #d7a33e;
  --gold-dark: #a97a20;
  --gold-soft: #fff5de;
  --blue: #4b7fe8;
  --blue-soft: #eaf1fe;
  --danger: #d9534f;
  --danger-soft: #fdecec;
  --shadow: 0 10px 30px rgba(23, 34, 58, .08);
  --shadow-sm: 0 4px 14px rgba(23, 34, 58, .06);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--teal-dark); }

/* ---------- 布局 ---------- */
.shell { min-height: 100%; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(242, 245, 249, .92);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 12px 22px;
  display: flex; align-items: center; gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }

.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(145deg, var(--teal), var(--teal-dark));
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
  box-shadow: 0 6px 14px rgba(14, 158, 138, .28);
}

.brand-text b { display: block; font-size: 17px; letter-spacing: .3px; }
.brand-text small { color: var(--muted); font-size: 11.5px; }

.nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }

.nav a {
  text-decoration: none; color: var(--sub); font-size: 13.5px;
  padding: 7px 12px; border-radius: 10px; transition: .15s;
}
.nav a:hover { background: #fff; color: var(--ink); }
.nav a.on { background: var(--ink); color: #fff; }

.main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 26px 22px 60px; }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}

.card-pad { padding: 22px; }

.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 16px; }
.card-head .spacer { margin-left: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 12px;
  background: var(--surface-tint); color: var(--ink);
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .16s; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { background: linear-gradient(180deg, var(--teal), var(--teal-dark)); color: #fff; box-shadow: 0 8px 18px rgba(14, 158, 138, .24); }
.btn-coral { background: linear-gradient(180deg, var(--coral), var(--coral-dark)); color: #fff; box-shadow: 0 8px 18px rgba(240, 106, 93, .24); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: 15px 26px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--teal-soft); color: var(--teal-dark);
}
.pill.gold { background: var(--gold-soft); color: var(--gold-dark); }
.pill.gray { background: var(--surface-tint); color: var(--sub); }
.pill.coral { background: var(--coral-soft); color: var(--coral-dark); }

.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; color: var(--sub); font-weight: 600; margin-bottom: 7px; }

.input, .textarea, .select {
  width: 100%; padding: 11px 13px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface-soft);
  outline: none; transition: .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--teal); background: #fff; box-shadow: 0 0 0 3px rgba(14, 158, 138, .12); }
.textarea { min-height: 190px; resize: vertical; line-height: 1.7; font-family: inherit; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 0; }
.row.tight { gap: 8px; }

.hint { color: var(--muted); font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

.empty {
  text-align: center; color: var(--muted); padding: 46px 20px;
}
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ---------- 首页 ---------- */
.hero { padding: 8px 4px 22px; }
.hero h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -.4px; }
.hero p { margin: 0; color: var(--sub); }

.entry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.entry {
  position: relative; overflow: hidden;
  padding: 24px; border-radius: 22px;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); transition: .18s;
  display: flex; flex-direction: column; gap: 14px;
}
.entry:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.entry::after {
  content: ""; position: absolute; right: -40px; top: -40px;
  width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle, rgba(14, 158, 138, .12), transparent 70%);
}
.entry.coral::after { background: radial-gradient(circle, rgba(240, 106, 93, .13), transparent 70%); }

.entry-icon {
  width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center;
  font-size: 22px; font-weight: 700; color: #fff;
  background: linear-gradient(145deg, var(--teal), var(--teal-dark));
  box-shadow: 0 8px 18px rgba(14, 158, 138, .26);
}
.entry.coral .entry-icon { background: linear-gradient(145deg, var(--coral), var(--coral-dark)); box-shadow: 0 8px 18px rgba(240, 106, 93, .26); }

.entry h3 { margin: 0; font-size: 19px; }
.entry .desc { color: var(--sub); font-size: 13.5px; min-height: 40px; }
.entry .meta { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.entry .actions { margin-top: auto; display: flex; gap: 10px; }

.progress { height: 7px; border-radius: 99px; background: var(--surface-tint); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--teal), #43c4ad); transition: width .3s; }
.progress.coral > i { background: linear-gradient(90deg, var(--coral), #f79b91); }

.recent-list { display: flex; flex-direction: column; }
.recent-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.recent-item:last-child { border-bottom: 0; }
.recent-item:hover { background: var(--surface-soft); }
.recent-item .t { font-weight: 600; font-size: 13.5px; }
.recent-item .d { color: var(--muted); font-size: 12px; }
.recent-item .at { margin-left: auto; color: var(--muted); font-size: 12px; }

/* ---------- 抽签台 ---------- */
.stage {
  background: linear-gradient(180deg, #ffffff, var(--surface-tint));
  border: 1px solid var(--line); border-radius: 22px;
  padding: 34px 26px; text-align: center; position: relative; overflow: hidden;
  min-height: 300px; display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.stage .stage-top { position: absolute; top: 16px; left: 18px; right: 18px; display: flex; align-items: center; gap: 10px; }
.stage .stage-top .spacer { margin-left: auto; }

.stage-number {
  font-size: 76px; font-weight: 800; letter-spacing: -2px;
  color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.stage-number.rolling { color: var(--teal); }
.stage-number.settled { color: var(--coral); animation: pop .45s cubic-bezier(.2, 1.5, .4, 1); }
.stage-text { font-size: 34px; font-weight: 800; color: var(--coral); word-break: break-word; }
.stage-label { color: var(--sub); font-size: 14px; margin-bottom: 10px; }
.stage-hint { color: var(--muted); font-size: 13px; margin-top: 12px; }

@keyframes pop { 0% { transform: scale(.8); opacity: .4; } 100% { transform: scale(1); opacity: 1; } }

.results { display: flex; flex-direction: column; gap: 8px; max-height: 430px; overflow: auto; }
.result-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px; background: var(--surface-soft);
  border: 1px solid var(--line);
}
.result-row .badge {
  width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-tint); color: var(--sub); font-size: 11px; font-weight: 700;
}
.result-row .v { font-weight: 700; }
.result-row .time { margin-left: auto; color: var(--muted); font-size: 12px; }
.result-row.latest { background: var(--teal-soft); border-color: #c8ece4; }

.progress-row { display: flex; align-items: baseline; gap: 10px; }
.progress-row b { font-size: 26px; }
.progress-row span { color: var(--muted); font-size: 13px; }

/* ---------- 抽奖设置 ---------- */
.prize-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.prize-row .input { flex: 1; }
.prize-row .num { width: 96px; flex: 0 0 96px; text-align: center; }
.prize-row .del {
  flex: 0 0 38px; width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--muted); cursor: pointer;
}
.prize-row .del:hover { color: var(--danger); border-color: #f2c4c2; background: var(--danger-soft); }

.seg { display: inline-flex; background: var(--surface-tint); padding: 4px; border-radius: 13px; gap: 4px; }
.seg button {
  border: 0; background: transparent; color: var(--sub);
  padding: 8px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 13.5px;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

.summary-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border-radius: 14px; background: var(--teal-soft); color: var(--teal-dark);
  font-weight: 600; font-size: 14px;
}

/* ---------- 转盘 ---------- */
.wheel-wrap { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.wheel-stage { position: relative; display: grid; place-items: center; padding: 18px; }
#wheelCanvas { width: 100%; max-width: 560px; height: auto; display: block; touch-action: manipulation; cursor: pointer; }
.wheel-center {
  position: absolute; width: 20%; aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  background: linear-gradient(180deg, #fff, var(--surface-tint));
  border: 3px solid #fff; box-shadow: 0 8px 22px rgba(23, 34, 58, .16);
  cursor: pointer; font-weight: 700; color: var(--ink);
}
.wheel-center small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }

.legend { display: flex; flex-direction: column; gap: 7px; max-height: 320px; overflow: auto; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 12px; }
.legend-row .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .c { margin-left: auto; color: var(--sub); font-variant-numeric: tabular-nums; }

/* ---------- 盲袋 ---------- */
.bag-grid { display: grid; gap: 12px; }
.bag {
  position: relative; border-radius: 16px; padding: 14px 8px;
  background: linear-gradient(180deg, #fff, var(--surface-soft));
  border: 1.5px solid var(--line-strong);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; min-height: 96px; cursor: pointer; transition: .16s;
  user-select: none;
}
.bag:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.bag .no { font-size: 20px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.bag .tag { font-size: 11.5px; color: var(--muted); }
.bag.selected { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14, 158, 138, .16); background: var(--teal-soft); }
.bag.opened { cursor: default; background: var(--surface-tint); border-style: dashed; opacity: .92; }
.bag.opened .no { font-size: 13px; font-weight: 600; color: var(--sub); }
.bag.opened .prize { font-size: 14px; font-weight: 800; color: var(--coral-dark); word-break: break-all; text-align: center; }
.bag.opened:hover { transform: none; box-shadow: none; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }

/* ---------- 历史 ---------- */
.hist-row {
  display: flex; gap: 14px; align-items: center;
  padding: 14px 16px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--line); margin-bottom: 10px;
}
.hist-row .icon {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; color: #fff; flex: 0 0 40px;
}
.hist-row .icon.draw { background: linear-gradient(145deg, var(--teal), var(--teal-dark)); }
.hist-row .icon.lottery { background: linear-gradient(145deg, var(--coral), var(--coral-dark)); }
.hist-row .info { min-width: 0; }
.hist-row .info b { display: block; font-size: 14px; }
.hist-row .info span { color: var(--muted); font-size: 12.5px; }
.hist-row .acts { margin-left: auto; display: flex; gap: 8px; }

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(23, 34, 58, .42); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(480px, 100%); background: var(--surface); border-radius: 22px;
  box-shadow: 0 24px 60px rgba(23, 34, 58, .28); overflow: hidden;
  animation: rise .18s cubic-bezier(.2, 1.2, .4, 1);
}
@keyframes rise { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-head { padding: 20px 24px 0; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px 24px 8px; color: var(--ink-soft); font-size: 14px; max-height: 58vh; overflow: auto; }
.modal-foot { padding: 8px 24px 22px; display: flex; gap: 10px; justify-content: flex-end; }

.prize-modal { text-align: center; }
.prize-modal .star {
  width: 74px; height: 74px; border-radius: 24px; margin: 6px auto 12px;
  display: grid; place-items: center; font-size: 34px; color: #fff;
  background: linear-gradient(145deg, var(--coral), var(--coral-dark));
  box-shadow: 0 12px 26px rgba(240, 106, 93, .34);
}
.prize-modal .badge { color: var(--coral-dark); font-weight: 700; font-size: 13px; letter-spacing: 1px; }
.prize-modal .name { font-size: 30px; font-weight: 800; margin: 6px 0; word-break: break-word; }
.prize-modal .sub { color: var(--sub); font-size: 13px; }

.detail-pre {
  white-space: pre-wrap; background: var(--surface-soft); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; font-size: 13px; color: var(--ink-soft);
  max-height: 300px; overflow: auto;
}

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 50%; top: 74px; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 12px;
  font-size: 13.5px; box-shadow: var(--shadow); animation: rise .18s ease;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--teal-dark); }

/* ---------- 后台设置同步提示 ---------- */
.sync-bar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 130; display: flex; align-items: center; gap: 12px;
  max-width: min(92vw, 560px); padding: 10px 14px;
  background: var(--ink); color: #fff; border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15, 25, 45, .28); font-size: 13.5px;
  animation: rise .18s ease;
}
.sync-bar[hidden] { display: none; }
.sync-bar .btn { flex: 0 0 auto; }
.sync-bar #syncText { min-width: 0; }

/* ---------- 房间 ---------- */
.room-chip {
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft);
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: .15s;
}
.room-chip:hover { border-color: var(--teal); color: var(--teal-dark); background: var(--teal-soft); }

.room-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-strong); background: var(--surface-soft); color: var(--ink-soft);
  padding: 7px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; transition: .15s;
}
.chip:hover { border-color: var(--teal); color: var(--teal-dark); background: var(--teal-soft); }

.gate-mark {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center;
  font-size: 30px; font-weight: 800; color: #fff;
  background: linear-gradient(145deg, var(--teal), var(--teal-dark));
  box-shadow: 0 12px 26px rgba(14, 158, 138, .3);
}

/* ---------- 抽签台 ---------- */
.draw-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stage-body { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.stage-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; justify-content: center; }
.actions-row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.legend-row.off { opacity: .6; }
.bag-actions { display: flex; gap: 10px; align-items: center; margin-top: 18px; flex-wrap: wrap; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .entry-grid, .wheel-wrap { grid-template-columns: 1fr; }
  .draw-layout { grid-template-columns: 1fr; gap: 14px; }
  .stage { min-height: 0; padding: 26px 18px 22px; }
  .stage-number { font-size: 56px; }
  .nav a { padding: 6px 9px; font-size: 12.5px; }
  .brand-text small { display: none; }
  .main { padding: 18px 14px 50px; }
  .topbar-inner { padding: 10px 14px; gap: 10px; }
  .room-chip { max-width: 110px; }
  .hist-row { flex-wrap: wrap; }
  .hist-row .acts { margin-left: 0; width: 100%; justify-content: flex-end; }
}

@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .stage-number { font-size: 46px; }
  .stage-text { font-size: 26px; }
  .hero h1 { font-size: 22px; }
  .hero p { font-size: 13px; }
  .bag { min-height: 72px; }
  .bag-grid { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)) !important; }
  .hist-row .acts .btn { padding: 6px 10px; }
  .wheel-center { width: 26%; }
  .nav { gap: 0; }
  .nav a { padding: 6px 7px; font-size: 12px; }
  .room-chip { max-width: 84px; font-size: 11.5px; padding: 5px 9px; }
  .card-pad { padding: 16px; }
  .card-head { padding: 14px 16px; }
  .results { max-height: 320px; }
  .modal { border-radius: 18px; }
  .stage-actions, .actions-row { gap: 8px; }
  .stage-actions .btn-lg, .actions-row .btn-lg { flex: 1 1 auto; }
  .foot { font-size: 11px; }
}
