body {
  margin: 0;
  padding: 0;
  background: #000;
  font-family: Arial, sans-serif;
}

.game-container {
  max-width: 800px;
  margin: 20px auto;
  padding: 20px;
}

.game-info {
  display: flex;
  justify-content: space-between;
  color: white;
  font-size: 24px;
  margin-bottom: 20px;
}

#game-area {
  width: 100%;
  height: 400px;
  background: #000;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
}

.target {
  position: absolute;
  width: 65px;
  height: 65px;
  cursor: pointer;
  transition: all 0.1s ease;
}

.target img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.leaderboard {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.9);
  padding: 15px;
  border-radius: 10px;
}

#start-button {
  display: block;
  margin: 20px auto;
  padding: 10px 20px;
  font-size: 18px;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

#start-button:hover {
  background: #45a049;
}

.difficulty-selector {
  margin-bottom: 20px;
  color: white;
}

#difficulty {
  padding: 5px 10px;
  font-size: 16px;
  border-radius: 5px;
}

.countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 100px;
  color: white;
  z-index: 100;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
}

.input-group {
  margin: 20px 0;
}

.input-group input {
  padding: 5px 10px;
  font-size: 16px;
  margin-left: 10px;
}

.hidden {
  display: none;
}

@media screen and (max-width: 768px) {
  .game-container {
    max-width: 100%;
    margin: 5px;
    padding: 5px;
    position: relative;
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  .game-info {
    font-size: 16px;
    margin-bottom: 10px;
  }

  #game-area {
    height: 60vh;
    width: 95vw;
    margin: 0 auto;
    margin-bottom: 80px;
  }

  .leaderboard-container {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    z-index: 1000;
  }

  .toggle-leaderboard-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    font-size: 16px;
  }

  .leaderboard {
    padding: 10px;
    max-height: 50vh;
    overflow-y: auto;
    transition: max-height 0.3s ease;
  }

  .leaderboard.collapsed {
    max-height: 0;
    overflow: hidden;
    padding: 0;
  }

  #leaderboard-list {
    margin: 0;
    padding: 0;
  }

  #start-button {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 98;
    padding: 12px 30px;
    font-size: 18px;
    border-radius: 25px;
    background: linear-gradient(145deg, #4caf50, #45a049);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
  }

  .target {
    width: 60px;
    height: 60px;
  }

  .countdown-timer {
    font-size: 60px;
  }

  .modal-content {
    width: 90%;
    margin: 0 10px;
    font-size: 14px;
  }

  .input-group input {
    width: 80%;
    margin: 5px 0;
  }

  /* 調整開始按鈕位置和層級 */
  #start-button {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 98;
    padding: 12px 30px;
    font-size: 18px;
    border-radius: 25px;
    background: linear-gradient(145deg, #4caf50, #45a049);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
  }

  /* 提高排行榜容器的層級 */
  .leaderboard-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
  }

  /* 確保排行榜內容也有較高的層級 */
  .mobile-leaderboard {
    position: relative;
    z-index: 9999;
    padding: 10px;
    max-height: 50vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
  }

  /* 確保切換按鈕也有較高的層級 */
  .toggle-leaderboard-btn {
    position: relative;
    z-index: 9999;
    width: 100%;
    padding: 12px;
    background: linear-gradient(145deg, #4caf50, #45a049);
    color: white;
    border: none;
    border-radius: 10px 10px 0 0;
    font-weight: bold;
  }

  /* 添加開始按鈕隱藏的樣式 */
  #start-button.hidden-mobile {
    display: none;
  }
}

.countdown-timer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 120px;
  color: rgba(255, 255, 255, 0.3);
  z-index: 1;
  pointer-events: none;
}

.particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

#leaderboard-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

#leaderboard-list li:last-child {
  border-bottom: none;
}

#leaderboard-list .rank {
  width: 80px;
  font-weight: bold;
}

#leaderboard-list .name {
  width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#leaderboard-list .score {
  width: 80px;
  color: #e44d26;
  font-weight: bold;
}

#leaderboard-list .difficulty {
  width: 60px;
  color: #4caf50;
}

#leaderboard-list .date {
  width: 120px;
  color: #666;
  font-size: 0.9em;
}

/* 桌面版的排行榜樣式 */
.leaderboard {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.9);
  padding: 15px;
  border-radius: 10px;
}

/* 在桌面隱藏手機版的排行榜容器和按鈕 */
.leaderboard-container {
  display: none; /* 完全隱藏手機版容器 */
}

.toggle-leaderboard-btn {
  display: none; /* 完全隱藏切換按鈕 */
}

/* 手機版的樣式 */
@media screen and (max-width: 768px) {
  /* ... 其他手機版樣式保持不變 ... */

  /* 在手機版顯示排行榜容器和按鈕 */
  .leaderboard-container {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
    z-index: 1000;
  }

  .toggle-leaderboard-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    font-size: 16px;
  }

  /* 在手機版隱藏原本的排行榜 */
  .leaderboard:not(.collapsed) {
    display: block;
  }

  .mobile-leaderboard {
    padding: 10px;
    max-height: 50vh;
    overflow-y: auto;
    transition: max-height 0.3s ease;
  }

  /* 確保收起狀態時完全隱藏 */
  .mobile-leaderboard.collapsed {
    max-height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
    border: none;
  }
}

/* 桌面版排行榜 */
.desktop-leaderboard {
  display: block;
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.9);
  padding: 15px;
  border-radius: 10px;
}

/* 手機版排行榜容器（預設隱藏） */
.leaderboard-container {
  display: none;
}

/* 手機版樣式 */
@media screen and (max-width: 768px) {
  /* 隱藏桌面版排行榜 */
  .desktop-leaderboard {
    display: none !important; /* 強制隱藏 */
  }

  /* 顯示手機版排行榜容器 */
  .leaderboard-container {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
  }

  .toggle-leaderboard-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    font-size: 16px;
  }

  .mobile-leaderboard {
    padding: 10px;
    max-height: 50vh;
    overflow-y: auto;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
  }

  .mobile-leaderboard.collapsed {
    max-height: 0 !important;
    padding: 0 !important;
    overflow: hidden;
    border: none;
  }

  /* ... 其他手機版樣式保持不變 ... */
}

/* 桌面版排行榜樣式 */
.desktop-leaderboard {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.9);
  padding: 15px;
  border-radius: 10px;
}

/* 手機版按鈕預設隱藏 */
.leaderboard-container .toggle-leaderboard-btn {
  display: none;
}

/* 手機版樣式 */
@media screen and (max-width: 768px) {
  /* 排行榜容器樣式 */
  .leaderboard-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
  }

  /* 顯示切換按鈕 */
  .leaderboard-container .toggle-leaderboard-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    font-size: 16px;
  }

  /* 排行榜樣式 */
  .desktop-leaderboard {
    margin: 0;
    padding: 10px;
    max-height: 50vh;
    overflow-y: auto;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
  }

  /* 收起狀態 */
  .desktop-leaderboard.collapsed {
    max-height: 0;
    padding: 0;
    overflow: hidden;
    border: none;
  }

  /* 調整排行榜內容樣式 */
  .desktop-leaderboard h2 {
    margin: 0 0 10px 0;
    font-size: 18px;
  }

  #leaderboard-list {
    margin: 0;
    padding: 0;
    font-size: 14px;
  }

  #leaderboard-list li {
    padding: 5px 0;
  }
}

/* 手機版排行榜樣式 */
@media screen and (max-width: 768px) {
  /* ... 其他手機版樣式保持不變 ... */

  .leaderboard-container {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
  }

  .toggle-leaderboard-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(145deg, #4caf50, #45a049);
    color: white;
    border: none;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
  }

  .toggle-leaderboard-btn:active {
    background: linear-gradient(145deg, #45a049, #4caf50);
  }

  .mobile-leaderboard {
    padding: 15px;
    max-height: 50vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    border-radius: 15px 15px 0 0;
    transition: all 0.3s ease;
  }

  .mobile-leaderboard h2 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 20px;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
  }

  .mobile-leaderboard #leaderboard-list-mobile {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .mobile-leaderboard #leaderboard-list-mobile li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 10px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease;
  }

  .mobile-leaderboard #leaderboard-list-mobile li:last-child {
    margin-bottom: 0;
  }

  .mobile-leaderboard #leaderboard-list-mobile li:active {
    transform: scale(0.98);
  }

  .mobile-leaderboard .rank {
    font-weight: bold;
    color: #4caf50;
    min-width: 70px;
  }

  .mobile-leaderboard .name {
    flex: 1;
    margin: 0 10px;
    color: #333;
    font-weight: 500;
  }

  .mobile-leaderboard .score {
    color: #e44d26;
    font-weight: bold;
    min-width: 80px;
    text-align: right;
  }

  .mobile-leaderboard .date {
    color: #666;
    font-size: 0.8em;
    min-width: 100px;
    text-align: right;
  }

  /* 收起狀態的動畫 */
  .mobile-leaderboard.collapsed {
    max-height: 0;
    padding: 0;
    opacity: 0;
    transform: translateY(20px);
  }

  /* 調整開始按鈕位置，避免被排行榜遮擋 */
  #start-button {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    padding: 12px 30px;
    font-size: 18px;
    border-radius: 25px;
    background: linear-gradient(145deg, #4caf50, #45a049);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
  }

  #start-button:active {
    transform: translateX(-50%) scale(0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  }
}

/* 排行榜標題和切換按鈕容器 */
.leaderboard-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 15px;
  text-align: center;
}

/* 切換按鈕容器 */
.leaderboard-switch {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.1);
  padding: 5px;
  border-radius: 50px;
  position: relative;
  margin: 10px 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 切換按鈕樣式 */
.switch-btn {
  min-width: 100px;
  height: 40px;
  background: transparent;
  border: none;
  padding: 0 20px;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #666;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 25px;
  z-index: 1;
}

/* 活動狀態和懸停效果 */
.switch-btn.active {
  color: #fff;
  background: linear-gradient(145deg, #4caf50, #45a049);
  box-shadow: 0 2px 10px rgba(76, 175, 80, 0.3);
}

.switch-btn:hover:not(.active) {
  color: #4caf50;
  background: rgba(76, 175, 80, 0.1);
}

/* 手機版特別樣式 */
@media screen and (max-width: 768px) {
  .leaderboard-switch {
    padding: 4px;
  }

  .switch-btn {
    min-width: 80px;
    height: 36px;
    font-size: 15px;
    padding: 0 15px;
  }
}

/* 添加動畫效果 */
.switch-btn {
  overflow: hidden;
}

.switch-btn:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: -100%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transition: all 0.3s ease;
}

.switch-btn:hover:after {
  left: 100%;
}

/* 按鈕點擊效果 */
.switch-btn:active {
  transform: scale(0.95);
}

/* 防止頁面捲動 */
@media screen and (max-width: 768px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  .game-container {
    height: 100%;
    overflow: hidden;
    position: relative;
    margin: 0;
    padding: 10px;
  }

  #game-area {
    height: calc(100vh - 200px); /* 調整高度，留出空間給其他元素 */
    margin-bottom: 60px;
  }

  .mobile-leaderboard {
    /* 確保排行榜可以滾動 */
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* 為 iOS 提供平滑滾動 */
  }

  /* 確保開始按鈕位置正確 */
  #start-button {
    position: fixed;
    bottom: 80px;
  }
}

/* 模態框按鈕基本樣式 */
#submit-score {
  padding: 12px 30px;
  font-size: 18px;
  background: linear-gradient(145deg, #4caf50, #45a049);
  color: white;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* 手機版模態框樣式 */
@media screen and (max-width: 768px) {
  #submit-score {
    width: 80%; /* 加寬按鈕 */
    padding: 15px 30px; /* 增加內邊距 */
    font-size: 20px; /* 加大字體 */
    margin: 10px auto; /* 置中對齊 */
    border-radius: 30px; /* 更圓潤的邊角 */
  }

  .modal-content {
    width: 90%;
    padding: 25px;
    border-radius: 15px;
  }

  .input-group {
    margin: 25px 0;
  }

  .input-group input {
    width: 80%;
    padding: 12px;
    font-size: 18px;
    margin: 10px auto;
    border-radius: 10px;
    border: 2px solid #4caf50;
  }
}

/* 連擊顯示效果 */
.combo-display {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 36px;
  color: #fff;
  text-shadow: 0 0 10px #ff0, 0 0 20px #ff0;
  z-index: 1000;
  pointer-events: none;
}

@keyframes comboPopup {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* 金色目標效果 */
.target.golden {
  animation: goldenPulse 1s infinite;
}

@keyframes goldenPulse {
  0% {
    box-shadow: 0 0 10px #ff0;
  }
  50% {
    box-shadow: 0 0 30px #ff0;
  }
  100% {
    box-shadow: 0 0 10px #ff0;
  }
}

/* 粒子效果優化 */
.particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1000;
}

/* 目標點擊效果 */
.target {
  transition: transform 0.1s ease;
}

.target:active {
  transform: scale(0.9);
}

/* 遊戲區域背景效果 */
#game-area {
  background: linear-gradient(45deg, #1a1a1a, #2a2a2a);
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.5);
}

/* 修改金色目標效果 */
.target img.golden {
  filter: brightness(150%) sepia(100%) hue-rotate(0deg);
  animation: goldenPulse 1s infinite;
}

@keyframes goldenPulse {
  0% {
    filter: brightness(150%) sepia(100%) hue-rotate(0deg)
      drop-shadow(0 0 10px #ff0);
  }
  50% {
    filter: brightness(150%) sepia(100%) hue-rotate(0deg)
      drop-shadow(0 0 30px #ff0);
  }
  100% {
    filter: brightness(150%) sepia(100%) hue-rotate(0deg)
      drop-shadow(0 0 10px #ff0);
  }
}

/* 命中率統計樣式 */
.accuracy-stats {
  margin-top: 15px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
}

.accuracy-stats div {
  margin: 5px 0;
  font-size: 16px;
  color: #666;
}

/* 排行榜命中率列樣式 */
#leaderboard-list .accuracy,
#leaderboard-list-mobile .accuracy {
  width: 80px;
  color: #2196f3;
  font-weight: bold;
}

@media screen and (max-width: 768px) {
  .accuracy-stats {
    margin-top: 10px;
    padding: 8px;
  }

  .accuracy-stats div {
    font-size: 14px;
  }
}
