:root {
  --primary-color: #ff4081;
  --secondary-color: #ff6b6b;
  --accent-color: #ff7675;
  --text-color: #2d3436;
  --text-light: #636e72;
  --bg-color: #f8f9fa;
  --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  --card-bg: #ffffff;
  --border-color: rgba(0, 0, 0, 0.1);
  --border-radius: 12px;
  --box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
  --box-shadow-hover: 0 15px 30px rgba(0, 0, 0, 0.1);
  --live-indicator: #ff3838;
  --transition: all 0.3s ease;
  --font-family: 'Zen Kaku Gothic New', 'Arial', sans-serif;
}

html {
  position: relative;
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  background-image: var(--bg-gradient);
  margin: 0;
  padding: 0 0 70px 0;
  color: var(--text-color);
  overflow-x: hidden;
  transition: var(--transition);
  line-height: 1.6;
}

.membership-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: #FF3838;
  color: white;
  font-size: 0.8rem;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 4px;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Make sure thumbnail-container has position relative for absolute positioning to work */
.thumbnail-container {
  position: relative;
  overflow: hidden;
}

/* Header & Navigation */
.menu-container {
  background-color: var(--card-bg);
  padding: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

/* Theme Toggle (Checkbox Switch) */
.theme-switcher {
  position: fixed;
  top: 1rem;
  left: 1rem;
  display: flex;
  align-items: center;
  z-index: 1001;
}

.theme-toggle {
  display: flex;
  align-items: center;
  position: relative;
}

.theme-toggle input {
  display: none;
}

.theme-toggle .slider {
  width: 40px;
  height: 20px;
  background-color: var(--border-color);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  transition: var(--transition);
}

.theme-toggle .slider:before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background-color: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: var(--transition);
}

.theme-toggle input:checked + .slider {
  background-color: var(--primary-color);
}

.theme-toggle input:checked + .slider:before {
  transform: translateX(20px);
}

.theme-label {
  margin-left: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-color);
}

/* Language Switcher */
.language-switcher {
  position: fixed;
  right: 1rem;
  top: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  z-index: 1001;
}

/* 語言按鈕（電腦版） */
.lang-btn {
  background: none;
  border: none;
  color: var(--text-color);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  font-family: var(--font-family);
  line-height: 1;
  min-width: 60px;
  text-align: center;
}

/* Hover 效果（電腦版） */
.lang-btn:hover {
  color: var(--primary-color);
}

/* Hover 底線動畫（電腦版） */
.lang-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background-color: var(--primary-color);
  transition: width 0.3s ease;
}

.lang-btn:hover::after {
  width: 70%;
}

/* 活躍狀態 */
.lang-btn.active {
  color: var(--primary-color);
  background-color: rgba(255, 64, 129, 0.3); /* 增加透明度，突出深色主題 */
  border-radius: 4px;
}

.lang-btn.active::after {
  width: 70%;
}

/* 手機版下拉選單 */
.lang-select {
  display: none; /* 桌面版隱藏 */
  background-color: var(--card-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.5rem;
  font-family: var(--font-family);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.lang-select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Filter Button Styles */
.filter-btn {
  background: none;
  border: none;
  color: var(--text-color);
  font-weight: 600;
  font-size: 1rem;
  padding: 1rem 1.5rem;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  font-family: var(--font-family);
}

.filter-btn:hover {
  color: var(--primary-color);
}

.filter-btn::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background-color: var(--primary-color);
  transition: width 0.3s ease;
}

.filter-btn:hover::after {
  width: 70%;
}

.filter-btn.active {
  color: var(--primary-color);
}

.filter-btn.active::after {
  width: 70%;
}

/* Navigation */
nav ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
}

nav li {
  margin: 0;
}

h1 {
  text-align: center;
  font-size: 2rem;
  margin: 1.5rem 0;
  font-weight: 700;
  color: var(--text-color);
  position: relative;
  display: inline-block;
  left: 50%;
  transform: translateX(-50%);
}

h1::after {
  content: '';
  position: absolute;
  width: 50px;
  height: 4px;
  background: var(--primary-color);
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 2px;
}

#live-count {
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-light);
  margin-bottom: 2rem;
  background-color: rgba(255, 64, 129, 0.1);
  border-radius: 50px;
  padding: 0.5rem 1.5rem;
  display: inline-block;
  margin: 0 auto 2rem;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.05);
}

.stats-container {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}

/* Live Streams List */
#live-streams-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  justify-content: center;
  margin: 0 auto;
  max-width: 1200px;
  padding: 0 1rem;
}

.live-stream-box {
  position: relative;
  background-color: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--border-color);
  opacity: 1;
}

/* 淡入動畫 */
.fade-in {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 淡出動畫 */
.fade-out {
  animation: fadeOut 0.3s ease-out;
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

.live-stream-box:hover {
  transform: translateY(-5px);
  box-shadow: var(--box-shadow-hover);
}

.thumbnail-container {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding-top: 56.25%;
  background-color: #f0f0f0;
}

.thumbnail {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.live-stream-box:hover .thumbnail {
  transform: scale(1.05);
}

.content-container {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0.5rem 0;
  color: var(--text-color);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  text-align: center;
}

.channel-name {
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 0.25rem 0 0.75rem;
}

.separator {
  height: 1px;
  background-color: var(--border-color);
  margin: 0.75rem 0;
  border: none;
}

.schedule-time {
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 0.5rem 0;
  text-align: center;
}

.timer {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--primary-color);
  margin-top: auto;
  padding-top: 0.5rem;
  text-align: center;
}

/* Live Indicator */
.live-stream-tag {
  display: inline-block;
  background-color: var(--live-indicator);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-right: 0.5rem;
  text-transform: uppercase;
}

/* Live Border */
.live {
  border: none;
  position: relative;
}

.live::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--border-radius);
  padding: 3px;
  background: linear-gradient(135deg, #ff3838, #ff6b6b);
  -webkit-mask: 
    linear-gradient(#fff 0 0) content-box, 
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 1;
}

/* No Live Stream State */
.no-live-stream {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  font-size: 1.2rem;
  color: var(--text-light);
  background-color: rgba(0, 0, 0, 0.03);
  border-radius: var(--border-radius);
  margin: 2rem 0;
  border: 1px dashed var(--border-color);
}

/* Footer */
footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  background-color: #f1f2f6;
  color: var(--text-light);
  padding: 1rem 0;
  text-align: center;
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
}

footer p {
  margin: 0.3rem 0;
}

footer a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

footer a:hover {
  color: var(--secondary-color);
  text-decoration: underline;
}

/* Back to Top Button */
.back-top {
  z-index: 999;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  cursor: pointer;
  width: 3rem;
  height: 3rem;
  background: var(--primary-color);
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(0);
  transition: var(--transition);
  color: white;
}

.back-top:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.back-top.hide {
  opacity: 0;
  transform: translateY(100px);
  pointer-events: none;
}

/* Loading State */
.loading-indicator {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  margin: 2rem 0;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 64, 129, 0.2);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error State */
.error-message {
  text-align: center;
  padding: 2rem;
  color: #d63031;
  background-color: rgba(214, 48, 49, 0.1);
  border-radius: var(--border-radius);
  margin: 2rem 0;
}

/* Media Queries */
@media (max-width: 1200px) {
  .container {
    width: 95%;
  }
  
  #live-streams-list {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 992px) {
  #live-streams-list {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  body {
    padding-bottom: 100px;
  }
  
  h1 {
    font-size: 1.5rem;
    margin: 1rem 0;
  }
  
  #live-count {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
  }
  
  #live-streams-list {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }
  
  .title {
    font-size: 0.9rem;
  }
  
  .channel-name, .schedule-time {
    font-size: 0.8rem;
  }
  
  .timer {
    font-size: 0.85rem;
  }
  
  .filter-btn {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }
  
  .lang-btn {
    display: none; /* 手機版隱藏按鈕 */
  }

  .lang-select {
    display: block; /* 手機版顯示下拉選單 */
	background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    font-family: var(--font-family);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    width: auto; /* 確保寬度適應內容 */
    margin-left: auto; /* 進一步確保靠右 */
  }

  .lang-select:focus {
    outline: none;
    border-color: var(--primary-color);
  }

  .language-switcher {
    top: 1rem;
    right: 0.75rem;
	display: flex;
    justify-content: flex-end; /* 確保內容靠右對齊 */
    width: auto; /* 避免寬度限制影響對齊 */
    gap: 0; /* 移除間距，確保下拉選單獨立靠右 */
  }
  
  .theme-label {
    font-size: 0.8rem;
  }
  
  .theme-switcher {
    top: 1rem;
    left: 0.75rem;
  }
  
  .no-live-stream {
    font-size: 1rem;
    padding: 2rem 1rem;
  }
  
  footer {
    padding: 0.75rem 0;
    font-size: 0.75rem;
  }
}

@media (max-width: 480px) {
  #live-streams-list {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  
  .container {
    width: 92%;
  }
  
  .filter-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
  
  .language-switcher {
    right: 0.5rem;
  }

  .lang-select {
    font-size: 0.8rem;
    padding: 0.4rem;
  }
  
  .theme-switcher {
    left: 0.5rem;
  }
  
  .back-top {
    width: 2.5rem;
    height: 2.5rem;
    bottom: 1rem;
    right: 1rem;
  }
}