:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --warning: #b54708;
  --ok: #027a48;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 10px;
  background: #fff;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  font-size: 18px;
  font-weight: 700;
}

.main {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 700;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 10px;
  margin-bottom: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #ecfdf3;
  color: var(--ok);
  font-size: 12px;
}

.badge.off {
  background: #fff1f3;
  color: var(--danger);
}

.notice {
  min-height: 24px;
  color: var(--muted);
}

.notice.error {
  color: var(--danger);
}

.notice.ok {
  color: var(--ok);
}

.modal-mask {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(15, 23, 42, 0.42);
  padding: 18px;
}

.modal-mask.show {
  display: grid;
}

.modal {
  width: min(620px, 100%);
  background: var(--panel);
  border-radius: 8px;
  padding: 18px;
}

.modal h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.combo {
  position: relative;
}

.combo-list {
  position: absolute;
  z-index: 10;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: none;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

.combo-list.show {
  display: block;
}

.combo-option {
  display: block;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  padding: 7px 10px;
  text-align: left;
}

.combo-option:hover {
  background: #f0fdfa;
}

.combo-empty {
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
}

.draw-layout {
  position: relative;
  width: 100vw;
  min-height: 100vh;
  margin: 0;
  display: block;
}

.draw-page {
  --bg: #101827;
  --panel: rgba(255, 255, 255, 0.94);
  --text: #182230;
  --line: rgba(255, 255, 255, 0.22);
}

.draw-shell {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 18%, rgba(45, 212, 191, 0.22), transparent 28%),
    radial-gradient(circle at 78% 16%, rgba(245, 158, 11, 0.22), transparent 24%),
    linear-gradient(135deg, #101827 0%, #16324a 44%, #2b224d 100%);
}

.draw-page .topbar {
  position: fixed;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  border-bottom-color: rgba(255, 255, 255, 0.08);
  background: rgba(16, 24, 39, 0.22);
  backdrop-filter: blur(8px);
  color: #fff;
}

.draw-control {
  position: fixed;
  z-index: 7;
  left: 50%;
  bottom: 22px;
  width: min(760px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto minmax(190px, 1fr);
  gap: 10px 12px;
  align-items: end;
  padding: 12px 14px;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(6, 12, 28, 0.28);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
  transform: translateX(-50%);
}

.draw-control .field {
  gap: 5px;
}

.draw-control .field label {
  color: rgba(255, 255, 255, 0.72);
}

.draw-control select,
.draw-control button {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.78);
}

.draw-control button.primary {
  border-color: rgba(20, 184, 166, 0.92);
  background: rgba(15, 118, 110, 0.92);
}

.draw-control .actions {
  margin-top: 0 !important;
}

.draw-control .notice {
  margin: 0;
  min-height: 36px;
  display: flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
}

.draw-control .notice.error {
  color: #fecdd3;
}

.draw-control .notice.ok {
  color: #99f6e4;
}

.draw-stage {
  min-height: 100vh;
  position: relative;
  text-align: center;
  overflow: hidden;
}

.lottery-scene {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  border-radius: 0;
  overflow: hidden;
  border: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    rgba(5, 10, 28, 0.4);
  background-size: 36px 36px;
  box-shadow: inset 0 0 80px rgba(255, 255, 255, 0.08), 0 24px 60px rgba(0, 0, 0, 0.28);
}

.scene-glow {
  position: absolute;
  width: min(62vw, 720px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(from 90deg, rgba(20, 184, 166, 0.62), rgba(250, 204, 21, 0.64), rgba(244, 63, 94, 0.58), rgba(20, 184, 166, 0.62));
  filter: blur(46px);
  opacity: 0.5;
  animation: pulseGlow 2.8s ease-in-out infinite;
}

.orbit {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
}

.spinning .orbit {
  animation: none;
}

.orbit-card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(120px, 15vw, 190px);
  min-height: 58px;
  display: grid;
  place-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  line-height: 1.3;
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.88), rgba(59, 130, 246, 0.84));
  border: 1px solid rgba(255, 255, 255, 0.46);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--tilt)) scale(0.94);
  transition: opacity 1.1s ease, transform 1.1s cubic-bezier(.2, .8, .2, 1), filter 0.4s ease, background 0.3s ease;
  animation: cardDrift var(--duration) ease-in-out infinite alternate;
  animation-delay: var(--delay);
}

.orbit-card:nth-child(3n) {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.9), rgba(236, 72, 153, 0.82));
}

.orbit-card:nth-child(4n) {
  background: linear-gradient(135deg, rgba(132, 204, 22, 0.86), rgba(14, 165, 233, 0.82));
}

.orbit-card.active {
  filter: brightness(1.28);
  box-shadow: 0 16px 38px rgba(34, 211, 238, 0.36);
}

.winner-mode .orbit-card {
  opacity: 0;
  animation: none;
  transform: translate(calc(-50% + var(--fade-x)), calc(-50% + var(--fade-y))) rotate(var(--tilt)) scale(0.45);
  filter: blur(8px);
}

.winner-mode .orbit-card.winner {
  opacity: 1;
  width: min(980px, 76vw);
  min-height: 190px;
  padding: 30px;
  font-size: clamp(34px, 4.8vw, 72px);
  background: linear-gradient(135deg, #facc15, #fb7185 44%, #22d3ee);
  color: #101827;
  transform: translate(-50%, -50%) scale(1);
  filter: none;
  z-index: 2;
}

.winner-podium {
  position: relative;
  z-index: 3;
  width: min(720px, 86%);
  display: grid;
  gap: 12px;
  justify-items: center;
  pointer-events: none;
}

.spinning .winner-podium {
  opacity: 0;
}

.winner-mode .winner-podium {
  opacity: 0;
  transform: translateY(110px);
  transition: transform 0.8s ease;
}

.winner-mode .question-display {
  min-height: 58px;
  font-size: 18px;
  letter-spacing: 0;
}

.question-display {
  width: 100%;
  min-height: 120px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  padding: 22px;
  font-size: clamp(20px, 3vw, 34px);
  font-weight: 800;
  line-height: 1.35;
  color: #fff;
  background: rgba(16, 24, 39, 0.62);
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

@keyframes cardDrift {
  from {
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--tilt)) scale(0.88);
  }
  to {
    transform: translate(calc(-50% + var(--target-x)), calc(-50% + var(--target-y))) rotate(calc(var(--tilt) + var(--spin))) scale(1.06);
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    transform: scale(0.92) rotate(0deg);
  }
  50% {
    transform: scale(1.12) rotate(18deg);
  }
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  margin: 12vh auto;
}

@media (max-width: 760px) {
  .toolbar,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 14px;
  }

  .question-display {
    font-size: 22px;
  }

  .draw-stage,
  .lottery-scene {
    min-height: 100vh;
  }

  .draw-control {
    bottom: 12px;
    grid-template-columns: 1fr;
    align-items: stretch;
    padding: 12px;
  }

  .draw-control .notice {
    min-height: 22px;
    justify-content: center;
    text-align: center;
  }

  .orbit-card {
    width: clamp(108px, 34vw, 150px);
    min-height: 52px;
    font-size: 13px;
  }

  .orbit-card.active {
    box-shadow: 0 14px 32px rgba(34, 211, 238, 0.34);
  }

  .winner-mode .orbit-card.winner {
    width: min(92vw, 620px);
    min-height: 150px;
    font-size: clamp(26px, 9vw, 46px);
  }
}
