/* 抽奖系统前端样式 —— 原生 CSS，浅色主题 */
:root {
  --primary: #d9483b;
  --primary-dark: #b9382e;
  --gold: #f5b301;
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #2b2f36;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ok: #16a34a;
  --running: #d97706;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}
header {
  background: linear-gradient(135deg, var(--primary), #e8654a);
  color: #fff;
  padding: 22px 16px;
  text-align: center;
}
header h1 { font-size: 26px; }
header .subtitle { font-size: 13px; opacity: .85; margin-top: 6px; }
header .subtitle a { color: #fff; text-decoration: none; border-bottom: 1px dashed rgba(255, 255, 255, .5); }
header.admin { background: linear-gradient(135deg, #334155, #1e293b); }
footer a { color: var(--primary); }

main { max-width: 860px; margin: 20px auto; padding: 0 16px; display: grid; gap: 20px; }
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
.panel h2 { font-size: 18px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.history-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.history-head h2 { margin-bottom: 0; }

label { font-size: 14px; color: var(--muted); display: block; margin: 10px 0 6px; }
textarea, input[type="number"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; }
textarea:focus, input:focus { outline: 2px solid rgba(217, 72, 59, .25); border-color: var(--primary); }

.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.row input[type="number"] { width: 130px; }
.center { justify-content: center; }

button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--primary-dark); color: #fff; }
button.big { padding: 12px 28px; font-size: 16px; }

.stats { color: var(--muted); font-size: 14px; }

/* 展示区高度必须与滚轮的三行窗口一致（96 * 3 = 288）。
   否则待机时舞台矮一截、抽奖时被滚轮撑高，画面会跳。 */
.draw-display {
  --roller-row: 96px;
  margin: 16px 0;
  height: calc(var(--roller-row) * 3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--muted);
  background: #faf7f0;
  border: 1px dashed var(--gold);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  word-break: break-all;
}
.draw-display.result { color: var(--primary); background: #fff8f7; border-style: solid; }

h3 { font-size: 15px; margin: 16px 0 8px; }
ol#winnerList { padding-left: 24px; font-size: 15px; line-height: 1.9; }
ol#winnerList li.new { color: var(--primary); font-weight: 700; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: #fafafa; }
td.names { max-width: 280px; word-break: break-all; }
tr.current td { background: #fff8f7; }

.badge { padding: 2px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.badge.running { background: #fef3c7; color: var(--running); }
.badge.done { background: #dcfce7; color: var(--ok); }

.empty { text-align: center; color: var(--muted); padding: 20px !important; }
.hidden { display: none; }
.tip { font-size: 13px; color: var(--ok); margin-top: 8px; min-height: 18px; }

footer { text-align: center; color: var(--muted); font-size: 12px; padding: 18px 16px 26px; }
code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* 删除历史记录相关 */
button.danger { border-color: #f3d0ce; color: #dc2626; }
button.danger:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; color: #fff; }
button.del { padding: 4px 12px; font-size: 12px; border-color: #f3d0ce; color: #dc2626; }
button.del:hover:not(:disabled) { background: #dc2626; border-color: #dc2626; color: #fff; }

/* 页面内确认弹窗（不依赖浏览器原生 confirm） */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-mask.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  width: min(380px, 100%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
}
.modal-box h3 { margin: 0 0 8px; font-size: 17px; }
.modal-msg { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 10px; }
.link-btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  text-decoration: none;
}
.link-btn:hover { background: var(--primary-dark); }

/* 后台 Excel 文件上传控件 */
.file-input {
  font-size: 13px;
  max-width: 100%;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}
.file-input::file-selector-button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  margin-right: 10px;
  cursor: pointer;
  font-size: 13px;
}
.file-input::file-selector-button:hover { border-color: var(--primary); color: var(--primary); }

/* ============================================================
   以下为前台抽奖页视觉增强（仅 body.lottery-page 生效，不影响后台）
   ============================================================ */

body.lottery-page {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(245, 179, 1, .16), transparent 60%),
    radial-gradient(700px 500px at 95% 5%, rgba(217, 72, 59, .10), transparent 60%),
    linear-gradient(180deg, #fff9f2 0%, #f6f7fb 42%, #eef1f8 100%);
  background-attachment: fixed;
}

/* 彩带画布：覆盖全屏但不拦截点击 */
/* canvas-confetti 自行创建并管理全屏 canvas（fixed、pointer-events:none、
   z-index 由调用时的 zIndex 控制），因此页面里不再预置 canvas 元素。 */

/* 头图 */
body.lottery-page .hero {
  position: relative;
  overflow: hidden;
  padding: 40px 16px 60px;
  border-radius: 0 0 34px 34px;
  background: linear-gradient(135deg, #d9483b 0%, #e8654a 48%, #f5a623 100%);
  box-shadow: 0 12px 30px rgba(217, 72, 59, .20);
}
.hero-orb {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  pointer-events: none;
}
.hero-orb-a { width: 240px; height: 240px; top: -120px; left: -60px; }
.hero-orb-b { width: 320px; height: 320px; right: -110px; bottom: -200px; }
.hero-inner { position: relative; z-index: 1; }
.hero-kicker {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .32em;
  padding: 5px 14px;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 999px;
  margin-bottom: 12px;
  opacity: .9;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 40px);
  letter-spacing: 2px;
  text-shadow: 0 3px 12px rgba(0, 0, 0, .15);
}
.hero-emoji { display: inline-block; animation: hero-bob 4s ease-in-out infinite; }
.hero-sub { font-size: 14px; opacity: .9; margin-top: 10px; }
@keyframes hero-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* 主舞台容器 */
body.lottery-page .stage-wrap {
  max-width: 880px;
  margin: -30px auto 24px;
  padding: 0 16px;
  position: relative;
  z-index: 2;
}
.stage {
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(255, 255, 255, .9);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 18px 50px rgba(31, 41, 55, .10);
}

/* 轮次信息 + 数据卡片 */
.stage-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.round-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff4e5;
  color: #b45309;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
}
/* 抽奖舞台 */
.draw-stage {
  position: relative;
  margin: 22px 0 18px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #fff 0%, #fff8ef 55%, #fef2e6 100%);
  border: 1px solid #fde3c8;
}
.ring {
  position: absolute;
  left: 50%; top: 50%;
  border-radius: 50%;
  pointer-events: none;
}
.ring-1 { width: 150px; height: 150px; margin: -75px 0 0 -75px; border: 2px dashed rgba(217, 72, 59, .22); }
.ring-2 { width: 230px; height: 230px; margin: -115px 0 0 -115px; border: 2px solid rgba(245, 179, 1, .18); }
.draw-stage.rolling .ring-1 { animation: spin 3s linear infinite; }
.draw-stage.rolling .ring-2 { animation: spin 5s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 抽奖显示区（覆盖通用 .draw-display 的底色） */
body.lottery-page .draw-display {
  position: relative;
  z-index: 1;
  margin: 0;
  width: 100%;
  min-height: 120px;
  padding: 16px;
  gap: 10px;
  flex-wrap: wrap;
  background: transparent;
  border: 0;
}
body.lottery-page .draw-display.result { background: transparent; border: 0; }
.display-hint { color: #b0845a; font-size: 16px; font-weight: 500; }
.roll-chip {
  display: inline-block;
  background: #fff;
  border: 1px solid #f3d9b0;
  color: #a16207;
  padding: 8px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(245, 179, 1, .18);
  animation: chip-pop .18s ease-out;
}
.result-label { width: 100%; font-size: 15px; color: #b45309; margin-bottom: 4px; }
.result-chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; width: 100%; }
.result-chip {
  display: inline-block;
  background: linear-gradient(135deg, #fff, #fff5e6);
  border: 1px solid var(--gold);
  color: var(--primary);
  font-weight: 800;
  font-size: 22px;
  padding: 10px 20px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(217, 72, 59, .15);
  animation: result-pop .45s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes chip-pop { from { transform: scale(.9); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes result-pop { from { transform: scale(.5) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 操作按钮 */
body.lottery-page .actions { margin-top: 4px; }
.draw-btn {
  background: linear-gradient(135deg, var(--primary), #e8654a);
  border: 0;
  box-shadow: 0 8px 20px rgba(217, 72, 59, .28);
  padding: 14px 38px;
  font-size: 17px;
  letter-spacing: 1px;
  transition: transform .15s, box-shadow .15s;
}
.draw-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(217, 72, 59, .34);
  background: linear-gradient(135deg, var(--primary-dark), #e8654a);
  color: #fff;
}
.ghost-btn { background: #fff; color: var(--muted); }

/* 中奖名单卡片 */
.winners-block { margin-top: 24px; border-top: 1px dashed #e8d9c5; padding-top: 18px; }
.winners-block h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; margin: 0 0 14px; }
.winner-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 7px;
  background: #fff1e8; color: var(--primary);
  border-radius: 999px; font-size: 13px;
}
.winner-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.winner-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #f0e6d8;
  border-radius: 10px;
  padding: 8px 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
  font-size: 15px;
}
.winner-card.new { border-color: var(--gold); background: #fffdf5; animation: result-pop .5s both; }
.winner-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #f5f5f4;
  color: #888;
  font-size: 11px;
  font-weight: 700;
}
.winner-card.new .winner-index { background: var(--gold); color: #fff; }
.winner-name { font-weight: 600; }
.winner-placeholder { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* 空状态 */
.empty-stage { text-align: center; padding: 48px 24px; }
.empty-gift {
  width: 84px; height: 84px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff1e8, #fff8e8);
  box-shadow: 0 8px 24px rgba(245, 179, 1, .20);
  animation: hero-bob 4s ease-in-out infinite;
}
.empty-stage h2 { font-size: 22px; margin-bottom: 10px; }
.empty-stage .stats { max-width: 520px; margin: 0 auto 18px; line-height: 1.7; }

/* ==========================================================================
   抽奖模式切换
   卡片式单选，与后台其他 panel 保持一致的外观。
   ========================================================================== */
.mode-option {
  flex: 1 1 220px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border: 2px solid var(--line, #d8dbe6);
  border-radius: 12px;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s ease, background .15s ease;
}
.mode-option:hover { border-color: var(--accent, #5b6cff); }
.mode-option:has(input:checked) {
  border-color: var(--accent, #5b6cff);
  background: #f4f6ff;
}
.mode-option input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--accent, #5b6cff);
  flex: none;
}
.mode-option span { display: flex; flex-direction: column; gap: 3px; }
.mode-option b { font-size: 15px; }
.mode-option small { color: #6b7280; font-size: 12px; }
.mode-option.is-disabled { opacity: .6; }

/* 模式提示的警告态：弹幕抽奖尚未接入时使用 */
.tip.warn { color: #b45309; }


/* ==========================================================================
   等待动画
   现场大屏的等待指示：三个点依次呼吸，避免静止画面被误认为卡死。
   ========================================================================== */
.empty-wait {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 22px;
}
.empty-wait span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: currentColor;
  opacity: .25;
  animation: empty-wait-pulse 1.4s ease-in-out infinite;
}
.empty-wait span:nth-child(2) { animation-delay: .18s; }
.empty-wait span:nth-child(3) { animation-delay: .36s; }
@keyframes empty-wait-pulse {
  0%, 100% { opacity: .25; transform: scale(.85); }
  50%      { opacity: 1;   transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .empty-wait span { animation: none; opacity: .6; }
}


/* ==========================================================================
   大屏强化：三层光环 + 中奖卡片入场
   现场投影距离远，静止元素容易显得空，光环缓慢旋转提供"在跑"的暗示。
   ========================================================================== */
.ring-3 {
  animation: ring-breathe 6s ease-in-out infinite;
}
@keyframes ring-breathe {
  0%, 100% { transform: scale(1); opacity: .28; }
  50%      { transform: scale(1.06); opacity: .5; }
}

/* 中奖卡片：逐张浮起，最后一批额外带一圈光晕 */
.winner-card {
  animation: card-in .45s cubic-bezier(.22, 1.2, .36, 1) both;
}
.winner-card.new {
  box-shadow: 0 0 0 2px rgba(245, 179, 1, .55), 0 8px 26px rgba(245, 179, 1, .3);
  animation: card-in .5s cubic-bezier(.22, 1.2, .36, 1) both, card-glow 1.6s ease-out 2;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(.92); }
  to   { opacity: 1; transform: none; }
}
@keyframes card-glow {
  0%   { box-shadow: 0 0 0 2px rgba(245,179,1,.7), 0 0 0 rgba(245,179,1,.5); }
  100% { box-shadow: 0 0 0 2px rgba(245,179,1,.25), 0 0 34px rgba(245,179,1,0); }
}

/* 结果揭示时给中奖名字一点强调 */
.win-chip {
  animation: chip-pop .4s cubic-bezier(.22, 1.4, .36, 1) both;
}
@keyframes chip-pop {
  from { opacity: 0; transform: scale(.7) rotate(-4deg); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ring-3, .winner-card, .winner-card.new, .win-chip { animation: none; }
}


/* ==========================================================================
   老虎机滚轮
   一列名字垂直排列，靠 transform 上移形成滚动，到点缓停到目标行。
   高度与 app.js 的 ROLLER_ROW_HEIGHT (96) 必须一致。
   ========================================================================== */
.roller-frame {
  --roller-row: 96px;
  position: relative;
  width: 100%;
  /* 三行高：中间行是焦点，上下两行露出相邻名字，读起来像老虎机 */
  height: calc(var(--roller-row) * 3);
  overflow: hidden;
  /* 上下渐隐，让滚动的首尾不要硬切 */
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
          mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
}
.roller-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
}
/* 非目标行稍小、稍淡，形成前后层次；目标行最大最亮 */
.roller-row {
  height: var(--roller-row);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 800;
  color: #b45309;
  letter-spacing: .04em;
  white-space: nowrap;
  opacity: .78;
}
.roller-row.is-target {
  font-size: 68px;
  color: #c2410c;
  opacity: 1;
}

/* 揭晓后的大字定格 */
.win-chip {
  display: inline-block;
  font-size: 64px;
  font-weight: 900;
  color: #c2410c;
  letter-spacing: .06em;
  text-shadow: 0 6px 18px rgba(194, 65, 12, .28);
  animation: chip-pop .42s cubic-bezier(.22, 1.4, .36, 1) both;
}
@keyframes chip-pop {
  from { opacity: 0; transform: scale(.72); }
  to   { opacity: 1; transform: none; }
}

/* 抽奖进行中：中间的光环加速旋转 */
.draw-stage.rolling .ring-1 { animation-duration: 2.2s; }
.draw-stage.rolling .ring-2 { animation-duration: 3s; }

@media (prefers-reduced-motion: reduce) {
  .roller-strip { transition: none !important; }
  .win-chip { animation: none; }
}

