/* Reset & Base */
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #f9fafb; /* 非常淺的灰白背景 */
  color: #111827;
  margin: 0;
  padding: 0;
}
.container {
  max-width: 1536px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* Header */
header {
  margin-bottom: 30px;
}
header h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin: 0;
  color: #1f2937;
  letter-spacing: -0.5px;
}
header h1 span {
  font-size: 1.1rem;
  font-weight: 500;
  color: #6b7280;
  margin-left: 12px;
}

/* Auth Button */
.auth-btn {
  background: #111827;
  color: white;
  border: none;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 15px));
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.2s;
}
.auth-btn:hover { background: #374151; }
#user-info { display: flex; align-items: center; }

/* Intro & Filters */
.home-intro {
  text-align: center;
  font-size: 1.1rem;
  color: #4b5563;
  margin-bottom: 25px;
}
.filter-section {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 40px;
}
.filter-section select {
  padding: 12px 40px 12px 16px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background-color: white;
  font-size: 0.95rem;
  color: #374151;
  font-weight: 500;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
  outline: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

/* Grid */
.city-section { margin-bottom: 0; }
.city-section h2 {
  font-size: 1.5rem;
  margin-bottom: 24px;
  color: #374151;
  font-weight: 700;
}
.candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

/* Card - Apple/Vercel Style */
.candidate-card {
  background: white;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  border: 1px solid #f3f4f6;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
}
.candidate-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

/* Card Top: Avatar & Info */
.card-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.candidate-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover; object-position: top;
  border: 1px solid #e5e7eb;
}
.card-info { flex: 1; min-width: 0; width: 100%; }
.candidate-name {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 2px;
  color: #111827;
}
.candidate-office {
  font-size: 0.95rem;
  color: #6b7280;
  font-weight: 600;
}

/* Card Middle: Party & Score */
.card-middle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid #f3f4f6;
  margin-bottom: 16px;
}
.party-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  background: #f9fafb;
}
.party-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.party-kmt .party-dot { background-color: #000095; }
.party-dpp .party-dot { background-color: #1B9431; }
.party-tpp .party-dot { background-color: #28C8C8; }

.candidate-score {
  font-size: 3rem;
  font-weight: 800;
  color: #111827;
  letter-spacing: -1.5px;
  line-height: 1;
}

/* Card Bottom: Metrics */
.card-metrics {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
  font-weight: 600;
}
.metric-label { color: #4b5563; }
.metric-value { color: #111827; font-weight: 700; }

/* ================= Vote View ================= */
#vote-view .vote-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
}
.back-btn {
  background: white;
  border: 1px solid #d1d5db;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 15px));
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
  color: #374151;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.back-btn:hover { background: #f9fafb; border-color: #9ca3af; }
.score-board {
  font-size: 1.1rem;
  font-weight: 600;
  color: #4b5563;
  display: flex;
  align-items: center;
  gap: 15px;
}
#current-score {
  font-size: 1.8rem;
  font-weight: 800;
  color: #111827;
}

/* Input Form */
.input-section {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05);
  margin: 0 0 40px 0;
  width: 100%;
  border: 1px solid #f3f4f6;
}
.input-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
  color: #374151;
}
.input-section input, .input-section textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  margin-bottom: 25px;
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s;
}
.input-section input:focus, .input-section textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
input[readonly] { background-color: #f9fafb; color: #6b7280; }

.stance-buttons {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
}
.stance-btn {
  flex: 1; min-width: 0; width: 100%;
  min-width: 0;
  width: 100%;
  padding: 14px 5px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: white;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
  color: #374151;
  transition: all 0.2s;
  white-space: nowrap;
}
.stance-btn:hover { background: #f9fafb; }
.stance-btn.selected {
  border-color: #111827;
  background: #111827;
  color: white;
}

#submit-btn {
  width: 100%;
  background: #2563eb;
  color: white;
  padding: 16px;
  border: none;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
  transition: background 0.2s;
}
#submit-btn:hover:not(:disabled) { background: #1d4ed8; }
#submit-btn:disabled { background: #9ca3af; cursor: not-allowed; }

/* History */
.history-section { width: 100%; }
.history-section h2 { margin-bottom: 20px; font-weight: 800; }
#history-list { list-style: none; padding: 0; }
#history-list li {
  background: white;
  padding: 24px;
  border-radius: 16px;
  margin-bottom: 16px;
  border-left: 6px solid #ccc;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  border-top: 1px solid #f3f4f6;
  border-right: 1px solid #f3f4f6;
  border-bottom: 1px solid #f3f4f6;
}
#history-list li.passed { border-left-color: #10b981; }
#history-list li.failed { border-left-color: #ef4444; }
.ai-comment {
  display: block;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px dashed #e5e7eb;
  color: #4b5563;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ====== 投票頁面專屬樣式 ====== */
/* 頂部候選人檔案 Header */
.candidate-profile-header {
  background: white;
  border-radius: 20px;
  padding: 30px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.08);
  margin-bottom: 30px;
  width: 100%;
}
.profile-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover; object-position: top;
  border: 3px solid #f3f4f6;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.profile-info { flex: 1; min-width: 0; width: 100%; }
#vote-name {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 8px 0;
  color: #111827;
}
.profile-score {
  text-align: right;
}
.profile-score .score-label {
  font-size: 0.9rem;
  color: #6b7280;
  font-weight: 600;
  margin-bottom: 5px;
}
.profile-score .score-number {
  font-size: 3rem;
  font-weight: 900;
  color: #111827;
  letter-spacing: -2px;
  line-height: 1;
}

/* 投票按鈕特化 */
.section-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-top: 0;
  margin-bottom: 24px;
  color: #111827;
  padding-bottom: 12px;
  border-bottom: 2px solid #f3f4f6;
}
.stance-buttons {
  display: flex;
  gap: 20px;
}
.btn-o-style {
  color: #059669;
  border-color: #a7f3d0;
  background-color: #ecfdf5;
}
.btn-o-style:hover { background-color: #d1fae5; }
.btn-o-style.selected {
  background-color: #059669;
  border-color: #059669;
  color: white;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.2);
}

.btn-x-style {
  color: #dc2626;
  border-color: #fecaca;
  background-color: #fef2f2;
}
.btn-x-style:hover { background-color: #fee2e2; }
.btn-x-style.selected {
  background-color: #dc2626;
  border-color: #dc2626;
  color: white;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.2);
}

/* 歷史紀錄卡片化 (Chat Bubble Style) */
#history-list li {
  padding: 0;
  border-left: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background-color: #f9fafb;
  border-bottom: 1px solid #f3f4f6;
}
.history-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge-o { background: #ecfdf5; color: #059669; }
.badge-x { background: #fef2f2; color: #dc2626; }
.badge-triangle { background: #f3f4f6; color: #4b5563; }
.history-time { font-size: 0.85rem; color: #9ca3af; }

.history-body {
  padding: 20px;
  font-size: 1.05rem;
  color: #1f2937;
  line-height: 1.6;
}
.history-ai {
  background: #f8fafc;
  padding: 16px 20px;
  margin: 0 20px 20px 20px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  border-top: none;
  font-size: 0.95rem;
  color: #334155;
  line-height: 1.5;
}
.empty-state, .loading {
  text-align: center;
  padding: 40px !important;
  color: #6b7280;
  font-size: 1.1rem;
  background: transparent !important;
  box-shadow: none !important;
  border: 2px dashed #e5e7eb !important;
}





#candidates-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 50px;
  align-items: start;
}

@media (min-width: 1024px) {
  #candidates-container {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1600px) {
  #candidates-container {
    grid-template-columns: repeat(3, 1fr);
  }
}

.vote-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
  align-items: start;
}

@media (min-width: 1024px) {
  .vote-grid {
    grid-template-columns: 1fr 1fr; /* 2 columns on desktop */
    gap: 60px;
  }
}

@media (min-width: 1440px) {
  .vote-grid {
    grid-template-columns: 4fr 5fr; /* History slightly wider on ultra wide */
  }
}


/* ================= Mobile Adjustments (Horizontal Preservation) ================= */
@media (max-width: 640px) {
  .container {
    padding: 20px 10px; /* Maximize usable screen width */
  }
  
  /* Header: Keep horizontal, shrink font */
  header {
    gap: 10px;
    margin-bottom: 20px;
  }
  header h1 {
    font-size: 1.4rem;
    line-height: 1.2;
  }
  header h1 span {
    font-size: 0.8rem;
    display: block; /* Move subtitle to next line to save horizontal space */
  }
  
  /* Candidate Card: Keep horizontal, shrink paddings and avatar */
  .candidate-profile-header {
    padding: 15px;
    gap: 15px;
    margin-bottom: 20px;
  }
  .profile-avatar {
    width: 65px !important;
    height: 65px !important;
  }
  .profile-info h2 {
    font-size: 1.5rem !important;
  }
  
  /* Metrics: shrink text so it fits horizontally */
  .vote-profile-metrics {
    padding: 12px 5px !important;
  }
  .vote-profile-metrics span {
    font-size: 0.75rem !important;
  }
  .vote-profile-metrics span[id^="vote-count"] {
    font-size: 1.1rem !important;
  }
  
  /* Input section: just reduce padding */
  .input-section {
    padding: 20px 15px;
  }
}

/* ================= Like Button ================= */
.like-btn {
  background: transparent;
  border: 1px solid #e5e7eb;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: #6b7280;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  margin-top: 10px;
}
.like-btn:hover:not(:disabled) {
  background: #f3f4f6;
  color: #374151;
}
.like-btn.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #2563eb;
  font-weight: 600;
}
.like-btn.active:hover:not(:disabled) {
  background: #dbeafe;
}
.like-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ================= Heat Badge ================= */
.heat-badge {
  margin-left: auto; /* Push to the right end of flex container */
  font-size: 1.05rem;
  font-weight: 800;
  color: #f97316; /* Orange color for heat */
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff7ed; /* Light orange background */
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid #ffedd5;
}

/* ================= Comments System ================= */
.comment-btn, .share-btn {
  background: transparent;
  border: 1px solid #e5e7eb;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: #6b7280;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
  margin-top: 10px;
  margin-right: 8px;
}
.comment-btn:hover, .share-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.comments-section {
  display: none;
  background-color: #f9fafb;
  border-top: 1px solid #f3f4f6;
  padding: 16px 20px;
  margin-top: 10px;
}
.comments-section.expanded {
  display: block;
}

.comments-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 250px;
  overflow-y: auto;
}
.comment-item {
  padding: 8px 0;
  border-bottom: 1px dashed #e5e7eb;
  font-size: 0.95rem;
  line-height: 1.4;
}
.comment-item:last-child {
  border-bottom: none;
}
.comment-author {
  font-weight: 600;
  color: #374151;
  margin-right: 6px;
}
.comment-text {
  color: #4b5563;
}
.comment-ai {
  background: #f5f3ff;
  border-radius: 6px;
  padding: 8px 10px;
}
.comment-ai .comment-author {
  color: #6d28d9;
}
.comment-ai-badge {
  display: inline-block;
  background: #7c3aed;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: 1px;
}
.comment-time {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-left: 8px;
}

.comment-input-area {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.comment-input {
  flex: 1; min-width: 0; width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  font-size: 16px; /* iOS Safari 自動放大的關鍵防線，必須 >= 16px */
  outline: none;
  transition: border-color 0.2s;
}
.comment-input:focus {
  border-color: #3b82f6;
}
.comment-submit-btn {
  background-color: #3b82f6;
  color: white;
  border: none;
  padding: 0 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer; flex-shrink: 0; white-space: nowrap;
  transition: background-color 0.2s;
}
.comment-submit-btn:hover:not(:disabled) {
  background-color: #2563eb;
}
.comment-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ================= Thread View ================= */
.thread-view {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 120px);
  padding-bottom: 80px; /* space for fixed input */
  position: relative;
}
.thread-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.thread-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: #1f2937;
}
.thread-comments-container {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  flex: 1; min-width: 0; width: 100%;
}
.thread-comments-container h3 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 10px;
}
.thread-comments-list {
  max-height: none; /* Override standard limit */
  overflow: visible;
}
.thread-input-fixed {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: white;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
  border-top: 1px solid #e5e7eb;
  z-index: 100;
}
/* Ensure the container inside fixed input stays aligned */
.thread-input-fixed .container {
  max-width: 1536px;
  margin: 0 auto;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 15px));
}


/* ================= 跑馬燈樣式 ================= */
.marquee-wrapper {
  background-color: #1f2937;
  color: #f3f4f6;
  overflow: hidden;
  margin-top: 12px;
  border-radius: 8px; /* 增加圓角讓它看起來更有質感 */
  position: relative;
  height: 36px;
  display: flex;
  align-items: center;
  border-bottom: 2px solid #fbbf24; /* 增加一點黃色底線點綴 */
}

.marquee-content {
  display: flex;
  white-space: nowrap;
  animation: marquee-scroll 25s linear infinite;
  padding-left: 100%; /* 開始時從最右邊進來 */
}

.marquee-content:hover {
  animation-play-state: paused; /* 滑鼠移上去暫停 */
}

@keyframes marquee-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

.marquee-item {
  margin-right: 80px; /* 留言之間的間距 */
  font-size: 0.95rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
}

.marquee-colorful {
  background: linear-gradient(90deg, #ff8a00, #e52e71, #9b51e0);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  animation: shine 3s linear infinite;
}

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


/* ================= 乾爹專區 (Sponsor View) ================= */
.sponsor-header {
  text-align: center;
  margin-bottom: 30px;
}
.sponsor-header h2 {
  font-size: 1.8rem;
  color: #1f2937;
  margin-bottom: 8px;
}
.sponsor-header p {
  color: #6b7280;
}

.sponsor-plans-container {
  background: white;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  margin-bottom: 40px;
}
.sponsor-plans-container h3 {
  margin-bottom: 16px;
  font-size: 1.2rem;
  color: #374151;
}

.sponsor-input-group {
  margin-bottom: 20px;
}
.sponsor-input-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.sponsor-input-group input:focus {
  border-color: #3b82f6;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.plan-card {
  cursor: pointer;
  position: relative;
}
.plan-card input[type="radio"] {
  display: none;
}
.plan-content {
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  height: 100%;
  transition: all 0.2s;
}
.plan-content h4 {
  font-size: 1rem;
  margin-bottom: 8px;
  color: #4b5563;
}
.plan-price {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}
.plan-content p {
  font-size: 0.85rem;
  color: #6b7280;
  margin: 0;
}
.plan-card input[type="radio"]:checked + .plan-content {
  border-color: #3b82f6;
  background-color: #eff6ff;
}
.plan-vip input[type="radio"]:checked + .plan-content {
  border-color: #e52e71;
  background-color: #fdf2f8;
}

.checkout-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(90deg, #10b981, #059669);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s;
}
.checkout-btn:active {
  transform: scale(0.98);
}

.current-sponsors h3 {
  font-size: 1.3rem;
  color: #1f2937;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e5e7eb;
}
.sponsor-list {
  list-style: none;
  padding: 0;
}
.sponsor-item {
  background: white;
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  border-left: 4px solid #9ca3af;
}
.sponsor-item.vip-item {
  border-left: 4px solid #e52e71;
  background: linear-gradient(to right, #fdf2f8, #ffffff);
}
.sponsor-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.sponsor-name {
  font-weight: 600;
  color: #374151;
}
.sponsor-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: bold;
}
.badge-normal { background: #f3f4f6; color: #4b5563; }
.badge-week { background: #dbeafe; color: #1d4ed8; }
.badge-vip { background: #fce7f3; color: #be185d; }
.sponsor-msg {
  color: #1f2937;
  font-size: 1rem;
}


.sponsor-expiry {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-top: 4px;
}

.sponsor-terms {
  background: #fef2f2;
  border: 1px solid #f87171;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 14px;
  color: #991b1b;
  line-height: 1.5;
}
.sponsor-terms p {
  margin: 0 0 8px 0;
}
.sponsor-terms p:last-child {
  margin: 0;
}

/* Category Buttons Responsive Sizing */
.category-btn {
  font-size: 0.9rem !important; /* Desktop size */
  transition: all 0.2s ease;
}

@media (max-width: 768px) {
  .category-btn {
    font-size: 0.85rem !important; /* Slightly smaller to fit 3 in a row */
    padding: 6px 10px !important; /* Reduce padding to save horizontal space */
  }
}

/* Candidate Card Score Styling */
.candidate-card .score-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-top: -16px;
}
.candidate-card .score-label {
  font-size: 0.75rem;
  color: #6b7280;
  margin-bottom: 2px;
}
.candidate-card .score-number {
  font-size: 2.25rem;
  font-weight: 900;
  color: #111827;
  line-height: 1;
  letter-spacing: -1px;
}

/* ── 通知系統 ── */

/* 頭像 wrapper：相對定位讓紅點能絕對定位 */
.notif-avatar-wrapper {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  flex-shrink: 0;
}

.notif-avatar-wrapper img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: block;
  transition: opacity 0.15s;
}

.notif-avatar-wrapper:hover img {
  opacity: 0.85;
}

/* 紅點角標 */
.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 17px;
  height: 17px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  pointer-events: none;
}

/* 浮動通知面板 */
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-height: 420px;
  background: #1f2937;
  border: 1px solid #374151;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 1000;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* user-auth 要是 relative 讓面板能定位 */
.user-auth {
  position: relative;
}

/* 面板標題列 */
.notif-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #374151;
  font-size: 0.9rem;
  font-weight: 700;
  color: #f9fafb;
}

.notif-mark-all {
  background: none;
  border: none;
  color: #60a5fa;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.notif-mark-all:hover {
  background: rgba(96,165,250,0.15);
}

/* 通知列表捲動區 */
.notif-list {
  overflow-y: auto;
  flex: 1;
}

/* 單筆通知 */
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #1f2937;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}

.notif-item:hover {
  background: #273344;
}

.notif-item.unread {
  background: #1e3a5f;
}

.notif-item.unread:hover {
  background: #1d4373;
}

/* 通知左側 icon */
.notif-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 2px;
}

/* 通知內文 */
.notif-body {
  flex: 1;
  min-width: 0;
}

.notif-body .notif-text {
  font-size: 0.82rem;
  color: #e5e7eb;
  line-height: 1.4;
  margin-bottom: 4px;
  word-break: break-all;
}

.notif-body .notif-text strong {
  color: #f9fafb;
}

.notif-body .notif-sub {
  font-size: 0.75rem;
  color: #6b7280;
}

/* 未讀藍點 */
.notif-dot {
  width: 8px;
  height: 8px;
  background: #3b82f6;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}

/* 空通知提示 */
.notif-empty {
  padding: 32px 16px;
  text-align: center;
  color: #6b7280;
  font-size: 0.85rem;
}

/* 手機版：面板全寬 */
@media (max-width: 480px) {
  .notif-panel {
    width: calc(100vw - 24px);
    right: -8px;
  }

  #user-name {
    display: inline-block;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
    vertical-align: middle;
  }
}

/* ================= 分類標籤列 (Category Tabs - 方案 A) ================= */
.category-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
  flex-wrap: wrap;
  padding-bottom: 6px;
}

.category-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-weight: bold;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s ease;
  user-select: none;
}

/* 手機版：單排橫向滑動膠囊列 (極致節省垂直高度) */
@media (max-width: 768px) {
  .category-tabs {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE 10+ */
    padding: 2px 8px 8px 8px;
    margin-bottom: 16px;
    mask-image: linear-gradient(to right, black 88%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 88%, transparent 100%);
  }

  .category-tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
  }

  .category-btn {
    padding: 7px 15px;
    font-size: 0.9rem;
  }
}


/* ================= 鄉民好感度 ================= */
.favor-card {
  background: white;
  margin-bottom: 24px;
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  width: 100%;
  box-sizing: border-box;
}
.favor-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  gap: 8px;
}
.favor-title {
  font-weight: 800;
  color: #111827;
  font-size: 1rem;
}
.favor-total {
  font-size: 0.8rem;
  color: #6b7280;
}
.favor-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.favor-bar-label {
  width: 20px;
  text-align: center;
}
.favor-bar {
  flex: 1;
  height: 10px;
  background: #f3f4f6;
  border-radius: 999px;
  overflow: hidden;
}
.favor-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 0.4s ease;
}
.favor-fill-like { background: #ec4899; }
.favor-fill-dislike { background: #64748b; }
.favor-bar-pct {
  width: 40px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: #374151;
}
.favor-buttons {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.favor-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  border: 1px solid;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.favor-btn-like {
  color: #db2777;
  border-color: #fbcfe8;
  background: #fdf2f8;
}
.favor-btn-like:hover { background: #fce7f3; }
.favor-btn-like.active {
  background: #ec4899;
  border-color: #ec4899;
  color: white;
}
.favor-btn-dislike {
  color: #475569;
  border-color: #cbd5e1;
  background: #f8fafc;
}
.favor-btn-dislike:hover { background: #f1f5f9; }
.favor-btn-dislike.active {
  background: #64748b;
  border-color: #64748b;
  color: white;
}
.favor-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}
.favor-to-trial {
  display: block;
  margin-top: 12px;
  text-align: center;
  font-size: 0.85rem;
  color: #6b7280;
  text-decoration: none;
}
.favor-to-trial:hover {
  color: #111827;
  text-decoration: underline;
}

/* 首頁候選人卡片：好感度橫條 */
.card-favor {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}
.card-favor-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-favor-bar {
  flex: 1;
  height: 8px;
  background: #64748b;
  border-radius: 999px;
  overflow: hidden;
}
.card-favor-fill {
  height: 100%;
  background: #ec4899;
}
.card-favor-pct {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.card-favor-pct-like { color: #db2777; }
.card-favor-pct-dislike { color: #475569; }
.card-favor-total {
  margin-top: 4px;
  text-align: right;
  font-size: 0.75rem;
  color: #9ca3af;
}
.card-favor-empty {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* ================= 選前十日依法暫停顯示 ================= */
.blackout-notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.6;
  width: 100%;
  box-sizing: border-box;
}
.card-blackout-note,
.board-blackout-note {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fffbeb;
  color: #92400e;
  border-radius: 8px;
  font-size: 0.8rem;
  text-align: center;
}
.blackout-hidden {
  display: none !important;
}

/* SEO 用的卡片連結：外觀維持原樣 (最新戰報的連結保留各自原本的顏色) */
a.seo-link {
  text-decoration: none;
}
.candidate-name a.seo-link,
.board-name a.seo-link {
  color: inherit;
}

/* ====== 事件擂台 ====== */
.arena-rule {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 10px;
  margin: -4px 0 18px;
}
#history-list li.event-card {
  display: block;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  overflow: visible;
}
.event-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.event-card-title { font-weight: 800; font-size: 1.05rem; color: #111827; }
.event-card-meta { font-size: 0.8rem; color: #9ca3af; white-space: nowrap; }
.event-sides {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.event-side { display: flex; flex-direction: column; min-width: 0; }
.event-side-label { font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; }
.event-side-o .event-side-label { color: #059669; }
.event-side-x .event-side-label { color: #dc2626; }
.event-slot { list-style: none; padding: 0; margin: 0; }
#history-list .event-slot li { margin-bottom: 10px; }
#history-list .event-slot li:last-child { margin-bottom: 0; }
.event-empty-slot {
  flex: 1;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  background: white;
  color: #475569;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.event-empty-slot small { font-size: 0.8rem; font-weight: 500; color: #94a3b8; }
.event-empty-slot:hover { border-color: #3b82f6; background: #eff6ff; }
.event-challenge-btn {
  margin-top: 8px;
  align-self: flex-end;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
}
.event-challenge-btn:hover { border-color: #3b82f6; color: #1d4ed8; }
.event-history { margin-top: 12px; }
.event-history summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  padding: 6px 0;
}
.event-history .event-slot { margin-top: 8px; }
.role-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-left: 4px;
}
.role-champion { background: #fef3c7; color: #b45309; }
.role-former { background: #f1f5f9; color: #64748b; }
.badge-lost { background: #eef2ff; color: #4f46e5; }
.history-event-tag {
  display: block;
  width: fit-content;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 2px 8px;
  margin-bottom: 8px;
}
@media (max-width: 640px) {
  #history-list li.event-card { padding: 12px; }
  .event-sides { grid-template-columns: 1fr; }
}
