:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #232732;
  --line: #2a2f3c;
  --text: #e8ecf1;
  --muted: #8a93a5;
  --primary: #ff7a59;
  --primary-hover: #ff8e72;
  --accent: #4cc9f0;
  --danger: #ef476f;
  --ok: #06d6a0;
  --shadow: 0 12px 40px rgba(0,0,0,0.45);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  max-width: 720px;
  margin: 0 auto;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--danger); min-height: 18px; margin: 4px 0 0; font-size: 13px; }

/* ===== buttons ===== */
button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 10px;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:active { transform: scale(0.97); }
button.primary {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
button.primary:hover { background: var(--primary-hover); }
button.primary:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
button.ghost { background: var(--surface); }
button.ghost:hover { background: var(--surface-2); }
button.icon { padding: 6px 10px; background: var(--surface); }

/* ===== login ===== */
#login { justify-content: center; align-items: center; }
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  padding: 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: 1px; }
.login-card p { margin: 0 0 18px; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  margin-bottom: 12px;
}
.login-card button { width: 100%; padding: 12px; font-size: 16px; }

/* ===== bar ===== */
.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.bar .menu { display: flex; gap: 6px; }
.bar .loc { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.bar .loc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== filters ===== */
.filters { margin-bottom: 8px; }
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 6px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}
.tab.active { background: var(--primary); color: #fff; }
.tab:hover { background: var(--surface-2); }
.tab.active:hover { background: var(--primary-hover); }
.stats { padding: 4px 0; font-size: 13px; }

/* ===== wheel ===== */
.wheel-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-width: 320px;
  margin: 8px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#wheel { width: 100%; height: 100%; display: block; filter: drop-shadow(0 18px 30px rgba(0,0,0,0.5)); }
.wheel-rotor { transition: transform 4.6s cubic-bezier(0.17, 0.67, 0.16, 0.99); }
.wheel-rotor.idle { transition: none; }

.pointer {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 22px solid var(--primary);
  filter: drop-shadow(0 4px 4px rgba(0,0,0,0.4));
  z-index: 4;
}

.spin {
  position: absolute;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: #fff;
  color: #111;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 1px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.35), inset 0 -3px 0 rgba(0,0,0,0.1);
  z-index: 3;
}
.spin:hover { background: #fafafa; }
.spin:disabled { background: #444; color: #888; cursor: not-allowed; }

.wheel-slice { stroke: rgba(0,0,0,0.18); stroke-width: 0.6; }

/* ===== candidates list ===== */
.candidates {
  flex: 1;
  overflow-y: auto;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}
.candidates-title {
  font-size: 12px;
  color: var(--muted);
  padding: 0 4px 6px;
  position: sticky;
  top: 0;
  background: var(--bg);
}
.candidate-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
.candidate-item:hover { background: var(--surface-2); }
.candidate-item:active { transform: scale(0.99); }
.candidate-item.is-last-pick {
  background: linear-gradient(135deg, rgba(255,122,89,0.22), rgba(76,201,240,0.10));
  border: 1px solid rgba(255,122,89,0.45);
  position: relative;
  box-shadow: 0 4px 14px rgba(255,122,89,0.18);
}
.candidate-item.is-last-pick::before {
  content: "🎲 上次抽中";
  position: absolute;
  top: -9px;
  left: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}
.candidate-item .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.06);
}
.candidate-item .name { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.candidate-item .meta { color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.candidate-item .ban {
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 16px;
  opacity: 0.5;
  flex-shrink: 0;
}
.candidate-item .ban:hover { opacity: 1; color: var(--danger); background: rgba(239,71,111,0.1); }
.candidates-empty {
  color: var(--muted);
  text-align: center;
  padding: 20px;
  font-size: 13px;
}

/* ===== blacklist ===== */
.blacklist-card { max-width: 460px; text-align: left; }
.blacklist-card h2 { margin: 0 0 6px; text-align: center; }
.blacklist-card > p { margin: 0 0 14px; text-align: center; }
.blacklist-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50dvh;
  overflow-y: auto;
  margin-bottom: 14px;
}
.bl-empty {
  color: var(--muted);
  text-align: center;
  padding: 20px;
  font-size: 13px;
}
.bl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
}
.bl-item .name { flex: 1; font-size: 14px; }
.bl-item button { padding: 6px 10px; font-size: 13px; }

.hint { text-align: center; margin: 8px 0; font-size: 13px; }

/* ===== modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}
.modal.hidden { display: none; }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 20px;
  padding: 28px 22px 22px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-card h2 { margin: 0 0 12px; font-size: 26px; line-height: 1.2; }
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 0 12px;
}
.meta .chip {
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}
.meta .chip.ok { background: rgba(6, 214, 160, 0.18); color: var(--ok); }
.meta .chip.bad { background: rgba(239, 71, 111, 0.18); color: var(--danger); }
.addr { font-size: 13px; margin: 6px 0; }
.open { font-size: 13px; margin: 4px 0 16px; }
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.actions button { padding: 12px; }
.actions .primary { grid-column: 1 / -1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes bounceIn {
  0% { opacity: 0; transform: scale(0.5); }
  100% { opacity: 1; transform: scale(1); }
}

/* confetti container */
.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 20px;
}
.confetti i {
  position: absolute;
  top: -10px;
  width: 6px;
  height: 10px;
  opacity: 0;
  animation: fall linear forwards;
}
@keyframes fall {
  0% { opacity: 1; transform: translateY(-20px) rotate(0deg); }
  100% { opacity: 0; transform: translateY(360px) rotate(720deg); }
}
