/* ========== 可自定义主题变量 ========== */
:root {
  --primary-from: #6366f1;
  --primary-to: #8b5cf6;
  --accent: #f59e0b;
  --accent-glow: rgba(245, 158, 11, 0.5);
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.85);
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --success: #22c55e;
  --danger: #ef4444;
  --scroll-font-size: 2rem;
}

@media (min-width: 640px) {
  :root { --scroll-font-size: 2.75rem; }
}

@media (min-width: 1024px) {
  :root { --scroll-font-size: 3.5rem; }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text-primary);
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(245, 158, 11, 0.05) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.page-wrap { position: relative; z-index: 10; }

.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.glass-card:hover { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-from), var(--primary-to));
  transition: all 0.3s;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.btn-accent {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  transition: all 0.3s;
}

.btn-accent:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

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

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  font-size: 0.875rem;
  text-decoration: none;
  transition: all 0.2s;
}

.nav-link:hover {
  color: white;
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.15);
}

.lottery-display {
  position: relative;
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.6) 0%, rgba(30, 41, 59, 0.4) 100%);
  border: 2px solid rgba(99, 102, 241, 0.3);
}

.lottery-display.lg { height: 380px; }

.lottery-name {
  font-size: var(--scroll-font-size);
  font-weight: 800;
  text-align: center;
  background: linear-gradient(135deg, #fff 0%, #c7d2fe 50%, #fff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: transform 0.1s;
  filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.3));
}

.lottery-name.scrolling { animation: textShimmer 0.3s linear infinite; }

.lottery-name.winner-reveal {
  animation: winnerPop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  -webkit-text-fill-color: #fbbf24;
  background: none;
  color: #fbbf24;
  filter: drop-shadow(0 0 30px var(--accent-glow));
}

@keyframes textShimmer {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

@keyframes winnerPop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.lottery-display::before,
.lottery-display::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 2;
  pointer-events: none;
}

.lottery-display::before {
  top: 0;
  background: linear-gradient(to bottom, rgba(15, 23, 42, 0.9), transparent);
}

.lottery-display::after {
  bottom: 0;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.9), transparent);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.show { opacity: 1; visibility: visible; }

.modal-content {
  transform: scale(0.8);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal-content { transform: scale(1); }

.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -10px;
  z-index: 101;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  to { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.participant-list {
  max-height: 480px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.5) transparent;
}

.participant-list::-webkit-scrollbar { width: 6px; }
.participant-list::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.5);
  border-radius: 3px;
}

.participant-item { transition: all 0.2s; }
.participant-item:hover { background: rgba(99, 102, 241, 0.15); }

.participant-item.winner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.2), rgba(239, 68, 68, 0.1));
  border-left: 3px solid var(--accent);
}

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-number.lg { font-size: 2.75rem; }

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

.qr-wrapper {
  animation: pulse-ring 2s infinite;
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: white;
  display: inline-block;
}

.title-gradient {
  background: linear-gradient(135deg, #fff 0%, #c7d2fe 50%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.winner-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.7rem;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-radius: 9999px;
  color: white;
  font-weight: 600;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary-from);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.register-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.hub-card {
  transition: transform 0.25s, box-shadow 0.25s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.hub-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(99, 102, 241, 0.25);
}

/* ========== 触控与移动端通用 ========== */
.touch-target {
  min-height: 44px;
  touch-action: manipulation;
}

.mobile-input {
  font-size: 16px;
  min-height: 44px;
}

button, .nav-link, select, input[type="checkbox"] {
  touch-action: manipulation;
}

.app-header {
  gap: 0.75rem;
}

.app-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}

@media (min-width: 768px) {
  .app-header-actions { width: auto; justify-content: flex-end; }
}

/* 管理页：奖品轮次 */
.prize-round-list-header { display: none; }

.prize-round-row {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0.875rem;
  border-radius: 0.75rem;
  background: rgba(30, 41, 59, 0.35);
  margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
  .prize-round-list-header {
    display: grid;
    grid-template-columns: 4rem 1fr 6rem 5rem 7rem;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: #64748b;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    margin-bottom: 0.25rem;
  }

  .prize-round-row {
    display: grid;
    grid-template-columns: 4rem 1fr 6rem 5rem 7rem;
    gap: 0.5rem;
    align-items: center;
    padding: 0.625rem 0.75rem;
    margin-bottom: 0.25rem;
  }

  .prize-round-field-label { display: none; }
}

.prize-round-field-label {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 0.25rem;
}

/* 管理页：中奖记录表格 */
.history-table-header { display: none; }

.history-row {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
}

.history-row-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.history-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.75rem;
  color: #94a3b8;
}

@media (min-width: 768px) {
  .history-table-header {
    display: grid;
    grid-template-columns: 2.5rem 1fr 1.2fr 1fr 3.5rem 1.2fr;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: #64748b;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    margin-bottom: 0.25rem;
  }

  .history-row {
    display: grid;
    grid-template-columns: 2.5rem 1fr 1.2fr 1fr 3.5rem 1.2fr;
    gap: 0.5rem;
    align-items: center;
    padding: 0.625rem 0.75rem;
  }

  .history-row-line,
  .history-row-meta { display: contents; }
}

/* 参与名单条目 */
.participant-item {
  transition: all 0.2s;
  gap: 0.5rem;
}

.participant-item-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  min-width: 0;
  flex: 1;
}

@media (max-width: 639px) {
  .participant-item {
    flex-direction: column;
    align-items: stretch !important;
  }

  .participant-item .delete-btn {
    align-self: flex-end;
    padding: 0.35rem 0.75rem;
    min-height: 36px;
  }

  .participant-list {
    max-height: none;
  }

  .lottery-display { height: 200px; min-height: 180px; }
  .lottery-display.lg { height: 240px; }

  .lottery-name {
    padding: 0 0.75rem;
    word-break: break-all;
    line-height: 1.2;
  }

  .modal-content {
    padding: 1.5rem !important;
    margin: 1rem;
    max-height: 90dvh;
    overflow-y: auto;
  }

  .stat-number { font-size: 1.5rem; }
}

@media (min-width: 640px) and (max-width: 1023px) {
  .lottery-display { height: 260px; }
  .lottery-display.lg { height: 300px; }

  .participant-list { max-height: 360px; }
}

/* 抽奖大屏控制区 */
.lottery-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  width: 100%;
}

.lottery-controls-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

@media (min-width: 640px) {
  .lottery-controls-row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
  }
}

.lottery-controls select,
.lottery-controls .btn-accent,
.lottery-controls .btn-reset {
  width: 100%;
  min-height: 48px;
}

@media (min-width: 640px) {
  .lottery-controls select { width: auto; min-width: 220px; }
  .lottery-controls .btn-accent,
  .lottery-controls .btn-reset { width: auto; }
}

.lottery-round-select {
  width: 100%;
}

@media (min-width: 640px) {
  .lottery-round-select { width: auto; min-width: 220px; }
}
