/* ============================================================
 * 抽奖系统 - 全局样式
 * 设计目标：暗色背景 + 霓虹高亮，营造舞台感
 * ============================================================ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  background:
    radial-gradient(ellipse at top, #1a1f4d 0%, #0a0a23 60%, #000 100%);
  color: #f0f4ff;
  overflow: hidden;
}

/* ---------- 顶部导航 ---------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(10, 10, 30, 0.7);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 100;
}

.navbar .brand {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(90deg, #ffd700, #ff6b9d, #c44dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 2px;
}

.navbar .nav-links {
  display: flex;
  gap: 8px;
}

.navbar .nav-links a {
  color: #b8c0e0;
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
}

.navbar .nav-links a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.navbar .nav-links a.active {
  color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
}

/* ---------- 主体 ---------- */
.main {
  height: 100vh;
  padding-top: 56px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 准备页 / 抽奖页 公共 ---------- */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 32px;
  position: relative;
}

.stage-title {
  font-size: 28px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 4px;
  text-align: center;
}

.stage-subtitle {
  font-size: 14px;
  color: #8892b8;
  text-align: center;
  margin-top: 8px;
}

/* ---------- 总数大字 ---------- */
.total-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.total-label {
  font-size: 14px;
  color: #8892b8;
  letter-spacing: 2px;
}

.total-number {
  font-size: 72px;
  font-weight: 800;
  background: linear-gradient(180deg, #ffd700, #ff6b9d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
  line-height: 1;
  font-feature-settings: 'tnum';
}

/* ---------- 滚动窗口 ---------- */
.scroller-wrapper {
  width: 100%;
  max-width: 1200px;
  position: relative;
  overflow: hidden;
  height: 130px;
  border-top: 1px solid rgba(255, 215, 0, 0.3);
  border-bottom: 1px solid rgba(255, 215, 0, 0.3);
  background: rgba(0, 0, 0, 0.3);
  mask-image: linear-gradient(90deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 12%, #000 88%, transparent 100%);
}

.scroller-track {
  display: flex;
  gap: 16px;
  padding: 18px 0;
  height: 100%;
  align-items: center;
  will-change: transform;
}

.scroller-track.idle {
  animation: scroll-left 60s linear infinite;
}

.scroller-track.spinning {
  animation: none; /* JS 控制 transform */
}

@keyframes scroll-left {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* 准备阶段每个用户卡片 */
.user-card {
  flex-shrink: 0;
  min-width: 220px;
  max-width: 240px;
  height: 90px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.15));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
}

.user-card .uc-name {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card .uc-meta {
  font-size: 12px;
  color: #a0a8c8;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.user-card .uc-id {
  color: #ffd700;
  font-family: 'SF Mono', Menlo, monospace;
}

.user-card .uc-ticket {
  font-size: 11px;
  color: #ff9a3c;
  font-family: 'SF Mono', Menlo, monospace;
  letter-spacing: 1px;
  margin-top: 2px;
  opacity: 0.85;
}

/* 中间高亮指示器（中奖位） */
.scroller-wrapper::before,
.scroller-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent, #ffd700, transparent);
  z-index: 2;
  pointer-events: none;
}
.scroller-wrapper::before { left: 50%; }
.scroller-wrapper::after { display: none; }

/* ---------- 抽奖数量设置 ---------- */
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 20px;
}

.controls label {
  font-size: 14px;
  color: #b8c0e0;
}

.controls input[type="number"] {
  width: 80px;
  height: 36px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #ffd700;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border 0.2s;
}

.controls input[type="number"]:focus {
  border-color: #ffd700;
}

.controls input[type="number"]::-webkit-inner-spin-button,
.controls input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ---------- 主按钮 ---------- */
.btn {
  height: 56px;
  padding: 0 40px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, #ffd700, #ff6b9d);
  color: #0a0a23;
  box-shadow: 0 4px 24px rgba(255, 107, 157, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(255, 107, 157, 0.6);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  height: 44px;
  padding: 0 24px;
  font-size: 14px;
  letter-spacing: 2px;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.14);
}

.btn-danger {
  background: rgba(220, 38, 38, 0.15);
  color: #ff6b6b;
  border: 1px solid rgba(220, 38, 38, 0.3);
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  letter-spacing: 1px;
}

.btn-danger:hover {
  background: rgba(220, 38, 38, 0.3);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: #b8c0e0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  height: 36px;
  padding: 0 16px;
  font-size: 13px;
  letter-spacing: 1px;
}

.btn-ghost:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

/* ---------- 中奖结果区（大字号高亮）---------- */
.winners-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 24px;
  position: relative;
  animation: fadeIn 0.6s ease-out;
}

.winners-stage.hidden { display: none; }

/* 通用隐藏：prepare-stage / winners-stage 互斥显示，任一加 .hidden 就彻底消失 */
.hidden { display: none !important; }

.winners-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 12px;
  background: linear-gradient(90deg, #ffd700, #ff6b9d, #c44dff, #ffd700);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shine 3s linear infinite;
}

@keyframes shine {
  to { background-position: 200% center; }
}

.winners-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: center;
  align-items: center;
  max-width: 1400px;
}

.winner-card {
  position: relative;
  width: 720px;
  max-width: 92vw;
  padding: 36px 56px 32px;
  background:
    radial-gradient(ellipse at top left, rgba(255, 140, 0, 0.25), transparent 60%),
    radial-gradient(ellipse at bottom right, rgba(255, 80, 0, 0.18), transparent 60%),
    linear-gradient(160deg, rgba(60, 20, 0, 0.65), rgba(20, 10, 0, 0.85));
  border: 2px solid rgba(255, 165, 0, 0.55);
  border-radius: 22px;
  text-align: center;
  box-shadow:
    0 0 50px rgba(255, 140, 0, 0.35),
    inset 0 0 40px rgba(255, 165, 0, 0.05);
  animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.winner-card:nth-child(1) { animation-delay: 0.1s; }
.winner-card:nth-child(2) { animation-delay: 0.3s; }
.winner-card:nth-child(3) { animation-delay: 0.5s; }
.winner-card:nth-child(4) { animation-delay: 0.7s; }
.winner-card:nth-child(5) { animation-delay: 0.9s; }

@keyframes popIn {
  0% { transform: scale(0) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* 顶部 LOTTERY TICKET 标签 */
.winner-card .wc-tagline {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 6px;
  color: #ff8c1a;
  margin-bottom: 14px;
  text-shadow: 0 0 12px rgba(255, 140, 0, 0.4);
}

/* 主标题："用户名 + 专属抽奖卡" */
.winner-card .wc-title {
  font-size: 40px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 3px;
  margin-bottom: 10px;
  line-height: 1.2;
}

.winner-card .wc-title .wc-name {
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
  margin-right: 6px;
}

/* 副标题："完成《formName》调研问卷" */
.winner-card .wc-subtitle {
  font-size: 15px;
  color: #c8b89a;
  margin-bottom: 24px;
  letter-spacing: 1px;
}

/* 内嵌奖品卡片（深色 + 圆角 + 微光） */
.winner-card .wc-prize-box {
  padding: 28px 24px;
  background: linear-gradient(180deg, rgba(15, 8, 0, 0.7), rgba(30, 15, 0, 0.85));
  border: 1px solid rgba(255, 165, 0, 0.2);
  border-radius: 16px;
  margin: 0 auto 24px;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.5);
}

.winner-card .wc-prize-label {
  font-size: 13px;
  color: #a89880;
  letter-spacing: 3px;
  margin-bottom: 14px;
  text-transform: uppercase;
}

.winner-card .wc-prize-name {
  font-size: 32px;
  font-weight: 800;
  color: #ff8c1a;
  letter-spacing: 2px;
  text-shadow: 0 0 18px rgba(255, 140, 0, 0.4);
  line-height: 1.3;
}

/* 底部抽奖编号 */
.winner-card .wc-ticket-block {
  margin-top: 8px;
}

.winner-card .wc-ticket-label {
  font-size: 12px;
  color: #a89880;
  letter-spacing: 3px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.winner-card .wc-ticket-code {
  font-size: 28px;
  font-weight: 700;
  color: #e8f0ff;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  letter-spacing: 4px;
  text-shadow: 0 0 12px rgba(150, 180, 255, 0.3);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.action-row {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

/* ---------- 中奖名单页 ---------- */
.winners-list-page {
  height: 100vh;
  overflow-y: auto;
  padding: 96px 40px 40px; /* top = 56px navbar + 40px 留白 */
}

.winners-list-page .page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.winners-list-page h2 {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 2px;
}

.winners-list-page .count-badge {
  display: inline-block;
  background: rgba(255, 215, 0, 0.15);
  color: #ffd700;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 14px;
  margin-left: 12px;
  font-weight: 600;
}

.winners-table {
  max-width: 1200px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
}

.winners-table .row {
  display: grid;
  grid-template-columns: 50px 1.8fr 1.2fr 1.6fr 1.5fr 1.5fr 90px;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.2s;
}

.winners-table .row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.winners-table .row.header {
  background: rgba(255, 215, 0, 0.06);
  color: #ffd700;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.winners-table .row .col-idx {
  color: #8892b8;
  font-family: 'SF Mono', Menlo, monospace;
}

.winners-table .row .col-name {
  color: #ffd700;
  font-weight: 700;
  font-size: 16px;
}

.winners-table .row .col-id {
  color: #c8d0f0;
  font-family: 'SF Mono', Menlo, monospace;
}

.winners-table .row .col-id-sub {
  font-size: 11px;
  color: #8892b8;
  font-family: 'SF Mono', Menlo, monospace;
  font-weight: 400;
  margin-top: 2px;
}

.winners-table .row .col-ticket {
  color: #e8f0ff;
  font-family: 'SF Mono', Menlo, monospace;
  font-weight: 600;
  letter-spacing: 1.5px;
}

.winners-table .row .col-prize {
  color: #ff9a3c;
  font-size: 14px;
}

.winners-table .row .col-time {
  color: #a0a8c8;
  font-size: 13px;
}

.winners-table .row .col-actions {
  text-align: right;
}

.winners-table .row .col-actions .btn-danger {
  width: 70px;
}

.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: #6c7494;
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state .empty-text {
  font-size: 16px;
  letter-spacing: 1px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(20, 20, 50, 0.95);
  border: 1px solid rgba(255, 215, 0, 0.3);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: rgba(220, 38, 38, 0.5);
  color: #ff8a8a;
}

/* ---------- 加载/错误占位 ---------- */
.loading {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 215, 0, 0.3);
  border-top-color: #ffd700;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.error-box {
  padding: 24px;
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 12px;
  color: #ff8a8a;
  text-align: center;
  max-width: 600px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .stage-title { font-size: 20px; }
  .total-number { font-size: 48px; }
  .winners-title { font-size: 24px; letter-spacing: 6px; }
  .winner-card { padding: 24px 32px; min-width: 220px; }
  .winner-card .wc-name { font-size: 32px; }
  .winners-table .row { grid-template-columns: 36px 1.4fr 1fr 1.2fr 1.2fr 70px; padding: 12px; font-size: 13px; }
  .winners-table .row .col-subtime { display: none; }
  .navbar { padding: 0 16px; }
  .navbar .brand { font-size: 16px; }
}

/* ============================================================
 * 密码锁屏（必须放最末，保证不干扰其它规则）
 * ============================================================ */
body.auth-locked { overflow: hidden; }

.auth-lock {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background:
    radial-gradient(ellipse at top, #1a1f4d 0%, #0a0a23 60%, #000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.3s ease-out;
}

.auth-lock.fade-out {
  animation: fadeOut 0.28s ease-in forwards;
}

@keyframes fadeOut {
  to { opacity: 0; }
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 16px;
  padding: 40px 32px 32px;
  text-align: center;
  backdrop-filter: blur(10px);
  box-shadow:
    0 12px 60px rgba(0, 0, 0, 0.6),
    0 0 30px rgba(255, 215, 0, 0.08);
}

.auth-card.shake {
  animation: authShake 0.4s ease-in-out;
}

@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(90deg, #ffd700, #ff6b9d, #c44dff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 14px;
  color: #8892b8;
  letter-spacing: 2px;
  margin-bottom: 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-input {
  width: 100%;
  height: 48px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #ffd700;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 4px;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
}

.auth-input::placeholder {
  color: #6c7494;
  letter-spacing: 2px;
  font-weight: 400;
}

.auth-input:focus {
  border-color: #ffd700;
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.15);
}

.auth-btn {
  height: 48px;
  background: linear-gradient(135deg, #ffd700, #ff6b9d);
  color: #0a0a23;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(255, 107, 157, 0.45);
}

.auth-btn:active {
  transform: translateY(0);
}

.auth-error {
  height: 22px;
  margin-top: 12px;
  font-size: 13px;
  color: #ff8a8a;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity 0.2s;
}

.auth-error.show { opacity: 1; }
