:root {
  --red: #8e1c1c;
  --red-deep: #5c1010;
  --red-soft: #a83a3a;
  --gold: #c9a24a;
  --gold-2: #e8d39a;
  --ink: #2b1c14;
  --muted: #7a6858;
  --paper: #fffaf2;
  --cream: #f4ead8;
  --line: rgba(201, 162, 74, 0.45);
  --shadow: 0 12px 40px rgba(92, 16, 16, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -80px, #b42323 0%, transparent 55%),
    linear-gradient(180deg, #5c1010 0%, #7a1818 320px, #efe3cf 320px, #f7f0e3 100%);
  min-height: 100%;
  overflow-x: hidden;
}
.bg-glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(201,162,74,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,162,74,.08) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, #000 0, #000 300px, transparent 440px);
}

#app { max-width: 920px; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) 16px 32px; }

.masthead { text-align: center; color: #fff; padding: 18px 0 42px; }
.masthead .org {
  letter-spacing: 18px;
  font-size: 30px;
  color: var(--gold-2);
  font-weight: 600;
}
.masthead h1 {
  font-family: "STSong", "Songti SC", "Noto Serif SC", serif;
  font-size: 50px;
  font-weight: 700;
  margin: 18px 0 15px;
  letter-spacing: 2px;
  line-height: 1.35;
}
.masthead .sub {
  display: inline-flex;
  align-items: center;
  gap: 21px;
  color: var(--gold);
  font-size: 33px;
  letter-spacing: 9px;
}
.masthead .sub::before, .masthead .sub::after {
  content: "";
  width: 78px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 16px 20px;
}

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 14px;
}

.branch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 640px) {
  .branch-grid { grid-template-columns: repeat(3, 1fr); }
}

.branch-btn {
  appearance: none;
  border: 1px solid #ead9b4;
  background: linear-gradient(180deg, #fff 0%, #fbf4e6 100%);
  color: var(--ink);
  border-radius: 12px;
  padding: 16px 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: .15s transform, .15s box-shadow;
}
.branch-btn:active { transform: scale(.98); }
.branch-btn.done {
  color: #8a744e;
  background: #f3ead8;
}
.branch-btn.done .tag { color: #2f7d4a; }
.branch-btn .tag {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.staff-entry {
  margin-top: 16px;
  text-align: center;
}
.staff-entry button {
  background: none;
  border: none;
  color: #9a8060;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.hero-branch {
  text-align: center;
  margin-bottom: 18px;
}
.hero-branch .label { font-size: 12px; color: var(--muted); letter-spacing: 2px; }
.hero-branch .name {
  font-size: 28px;
  font-weight: 800;
  margin-top: 4px;
  color: var(--red);
}

.draw-wrap { text-align: center; padding: 12px 0 8px; }
.draw-btn {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: 6px solid var(--gold);
  background: radial-gradient(circle at 35% 30%, #d13a3a, #7a1414 62%, #4c0c0c);
  color: #ffe9b0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(122, 20, 20, .35), inset 0 0 0 3px rgba(255,255,255,.08);
}
.draw-btn:disabled { opacity: .55; cursor: not-allowed; }
.warn { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.7; }

.q-no {
  text-align: center;
  color: var(--red);
  font-family: "STSong", "Songti SC", serif;
  font-size: 15px;
  letter-spacing: 3px;
  margin-bottom: 6px;
}
.q-title {
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.45;
  margin-bottom: 16px;
}
.block { margin-top: 14px; }
.block h3 {
  font-size: 14px;
  color: var(--red);
  letter-spacing: 2px;
  border-left: 3px solid var(--gold);
  padding-left: 8px;
  margin-bottom: 8px;
}
.block .body {
  background: #fff;
  border: 1px solid #f0e2c6;
  border-radius: 12px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
  color: #3a2a1d;
}

.stamp {
  display: inline-block;
  margin: 0 auto 10px;
  padding: 4px 10px;
  border: 2px solid #b42323;
  color: #b42323;
  border-radius: 4px;
  transform: rotate(-8deg);
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 13px;
}

.toolbar { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.btn {
  border: 1px solid #e1c98a;
  background: #fff8ea;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}
.btn.primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.btn.danger { background: #fff; color: var(--red); border-color: #e2b4b4; }

.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.admin-head h2 { font-size: 18px; }
.progress { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.qr-box { text-align: center; background: #fff; border: 1px dashed var(--gold); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.qr-box img, .qr-box canvas { width: 280px; height: 280px; background: #fff; padding: 8px; image-rendering: pixelated; }
.qr-url { margin-top: 10px; font-size: 16px; word-break: break-all; color: var(--red); font-weight: 700; }
.ip-pick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 12px 0 4px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { border-bottom: 1px solid #efe0c6; padding: 10px 6px; text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; }
.status-on { color: #2f7d4a; font-weight: 700; }
.status-off { color: #a18b72; }

.login { max-width: 360px; margin: 40px auto; text-align: center; }
.login input {
  width: 100%;
  margin: 12px 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #e1c98a;
  font-size: 16px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 8, 8, .78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.slot {
  width: min(86vw, 320px);
  background: #fffaf2;
  border: 2px solid var(--gold);
  border-radius: 16px;
  padding: 28px 16px;
  text-align: center;
}
.slot .num {
  font-size: 64px;
  font-weight: 800;
  color: var(--red);
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
}
.slot p { color: var(--muted); margin-top: 8px; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px;
}
.modal {
  background: var(--paper); border-radius: 16px; padding: 20px; width: min(92vw, 400px); text-align: center;
}
.modal h3 { margin-bottom: 8px; }
.modal p { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 16px; }

.remain { margin-top: 16px; font-size: 13px; color: var(--muted); line-height: 1.8; }
.remain b { color: var(--ink); }
