/* ── 기본 리셋 ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', sans-serif;
  background: #0f1117;
  color: #e2e8f0;
  min-height: 100vh;
}

/* ── 네비게이션 ────────────────────────────────────────── */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 32px;
  background: #1a1d27;
  border-bottom: 1px solid #2d3148;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-left { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 1.3rem; font-weight: 700; color: #a78bfa; }
.network-badge {
  font-size: 0.75rem;
  background: #2d1f63;
  color: #a78bfa;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid #4c3799;
}

/* ── 컨테이너 ──────────────────────────────────────────── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 20px;
}

/* ── 버튼 ──────────────────────────────────────────────── */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:hover:not(:disabled) { opacity: 0.85; transform: translateY(-1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary  { background: #7c3aed; color: #fff; }
.btn-secondary{ background: #2d3148; color: #e2e8f0; border: 1px solid #3d4268; }
.btn-success  { background: #059669; color: #fff; }
.btn-danger   { background: #dc2626; color: #fff; }

/* ── 상태 뱃지 ─────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}
.status-badge.ready  { background: #374151; color: #9ca3af; }
.status-badge.active { background: #064e3b; color: #34d399; }
.status-badge.ended  { background: #1e3a5f; color: #60a5fa; }

/* ── 메인 화면 ─────────────────────────────────────────── */
.status-card {
  background: #1a1d27;
  border: 1px solid #2d3148;
  border-radius: 12px;
  padding: 28px;
  text-align: center;
  margin-bottom: 20px;
}
.status-card h2 { font-size: 1.4rem; margin-bottom: 14px; color: #c4b5fd; }
.stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 16px;
  color: #94a3b8;
}
.stats strong { color: #e2e8f0; }
.main-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 16px;
}
.info-text  { color: #64748b; font-size: 0.85rem; text-align: center; margin-top: 8px; }
.warn-text  { color: #f59e0b; font-size: 0.85rem; margin-top: 12px; }

/* ── 패널 ──────────────────────────────────────────────── */
.panel {
  background: #1a1d27;
  border: 1px solid #2d3148;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}
.admin-panel h3 { margin-bottom: 16px; color: #c4b5fd; }
.admin-status { margin-bottom: 16px; color: #94a3b8; }
.admin-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }

/* ── 후보자 그리드 ─────────────────────────────────────── */
.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.candidate-card {
  background: #12151f;
  border: 2px solid #2d3148;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
.candidate-card:hover { border-color: #7c3aed; }
.candidate-card.selected { border-color: #a78bfa; background: #1e1535; }
.candidate-card.winner  { border-color: #f59e0b; background: #1c1506; }
.candidate-card img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 50%;
  margin-bottom: 8px;
  background: #2d3148;
}
.candidate-card .cname { font-weight: 600; font-size: 0.95rem; }
.candidate-card .radio-label {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.8rem;
  color: #94a3b8;
}
.candidate-card.selected .radio-label { color: #a78bfa; }
.delete-btn {
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 0.75rem;
  background: #3b0a0a;
  color: #f87171;
  border: 1px solid #7f1d1d;
  border-radius: 6px;
  cursor: pointer;
}
.delete-btn:hover { background: #7f1d1d; }

/* ── 모달 ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: #1a1d27;
  border: 1px solid #3d4268;
  border-radius: 14px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
}
.modal h3 { margin-bottom: 18px; color: #c4b5fd; }
.modal label { display: block; margin: 12px 0 4px; font-size: 0.9rem; color: #94a3b8; }
.modal input {
  width: 100%;
  padding: 10px 12px;
  background: #12151f;
  border: 1px solid #3d4268;
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 0.95rem;
}
.modal input:focus { outline: none; border-color: #7c3aed; }
.preview-box {
  margin: 14px 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #12151f;
  border: 1px dashed #3d4268;
  border-radius: 8px;
}
.preview-box img { max-height: 120px; max-width: 100%; border-radius: 6px; }
.preview-error { color: #f87171; font-size: 0.85rem; }
.modal-buttons { display: flex; gap: 12px; margin-top: 18px; justify-content: flex-end; }

/* ── 투표 화면 ─────────────────────────────────────────── */
.vote-header {
  display: flex;
  gap: 20px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.vote-guide { color: #94a3b8; margin-bottom: 20px; }
.selected-info {
  margin: 16px 0;
  padding: 10px 16px;
  background: #1e1535;
  border: 1px solid #4c3799;
  border-radius: 8px;
  color: #c4b5fd;
}
.vote-action { text-align: center; margin-top: 20px; }
.already-voted-box {
  text-align: center;
  padding: 28px;
  background: #063d2a;
  border: 1px solid #065f46;
  border-radius: 12px;
  margin-top: 20px;
}
.already-voted-box p { margin-bottom: 10px; color: #6ee7b7; }

/* ── 결과 화면 ─────────────────────────────────────────── */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.results-list { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.result-row {
  background: #12151f;
  border: 1px solid #2d3148;
  border-radius: 10px;
  padding: 14px 16px;
}
.result-row.first-place { border-color: #f59e0b; }
.result-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.result-meta img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: #2d3148;
}
.result-rank { font-size: 1.1rem; min-width: 28px; }
.result-name { font-weight: 600; flex: 1; }
.result-count { color: #94a3b8; font-size: 0.9rem; }
.bar-wrap { background: #1a1d27; border-radius: 4px; height: 8px; overflow: hidden; }
.bar-fill {
  height: 100%;
  background: #7c3aed;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.result-row.first-place .bar-fill { background: #f59e0b; }
.results-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  color: #64748b;
  font-size: 0.85rem;
}

/* ── 우승자 카드 ────────────────────────────────────────── */
.winner-card {
  background: #1c1506;
  border: 2px solid #f59e0b;
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  margin-bottom: 24px;
}
.winner-card h4 { color: #fbbf24; margin-bottom: 16px; font-size: 1.1rem; }
.winner-card img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #f59e0b;
  margin-bottom: 12px;
  background: #2d3148;
}
.winner-card .winner-name { font-size: 1.4rem; font-weight: 700; color: #fef3c7; }
.winner-card .winner-votes { color: #fbbf24; margin-top: 4px; }
.winner-cards-wrap { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }

/* ── Etherscan 박스 ────────────────────────────────────── */
.etherscan-box {
  background: #12151f;
  border: 1px solid #2d3148;
  border-radius: 10px;
  padding: 16px;
  margin-top: 16px;
  font-size: 0.9rem;
  color: #94a3b8;
}
.etherscan-box a { color: #60a5fa; text-decoration: none; }
.etherscan-box a:hover { text-decoration: underline; }
.etherscan-box code { color: #a78bfa; font-size: 0.85rem; }
.final-all-results { margin-top: 8px; }

/* ── 토스트 ────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  z-index: 999;
  animation: fadeIn 0.3s ease;
}
.toast.success { background: #065f46; color: #6ee7b7; border: 1px solid #059669; }
.toast.error   { background: #7f1d1d; color: #fca5a5; border: 1px solid #dc2626; }
.toast.info    { background: #1e3a5f; color: #93c5fd; border: 1px solid #2563eb; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── 로딩 스피너 ────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 유틸 ──────────────────────────────────────────────── */
.hidden { display: none !important; }
section { margin-bottom: 32px; }
