/* 全局樣式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow: hidden;
}

/* 界面容器 */
.screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* 認證界面 */
.auth-container {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 400px;
}

.auth-container h1 {
  text-align: center;
  color: #333;
  margin-bottom: 30px;
  font-size: 28px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 20px;
  border-bottom: 2px solid #eee;
}

.auth-tab {
  flex: 1;
  padding: 15px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 16px;
  color: #666;
  transition: all 0.3s;
}

.auth-tab.active {
  color: #667eea;
  border-bottom: 2px solid #667eea;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth-form input {
  padding: 15px;
  border: 2px solid #eee;
  border-radius: 10px;
  font-size: 16px;
  transition: border-color 0.3s;
}

.auth-form input:focus {
  outline: none;
  border-color: #667eea;
}

.auth-form button {
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.3s;
}

.auth-form button:hover {
  transform: translateY(-2px);
}

.auth-form .guest-btn {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
  margin-top: 10px;
}

.auth-form .guest-btn:hover {
  background: #f7fafc;
  transform: translateY(-2px);
}

.auth-form .google-btn {
  background: #4285f4;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 5px;
}

.auth-form .google-btn:hover {
  background: #357ae8;
  transform: translateY(-2px);
}

.auth-form .google-icon {
  fill: currentColor;
}

/* 主界面 */
.main-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.top-nav {
  background: rgba(255, 255, 255, 0.95);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.user-info {
  display: flex;
  gap: 10px;
  align-items: center;
}

.user-info span {
  font-weight: bold;
  color: #333;
}

.nav-buttons {
  display: flex;
  gap: 10px;
}

.nav-buttons button {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

#btn-profile {
  background: #667eea;
  color: white;
}

#btn-shop {
  background: #f093fb;
  color: white;
}

#btn-logout {
  background: #ff6b6b;
  color: white;
}

.map-container {
  flex: 1;
  width: 100%;
}

#map {
  width: 100%;
  height: 100%;
}

.user-marker .user-icon {
  font-size: 30px;
  text-align: center;
  line-height: 40px;
}

.player-marker .player-icon {
  font-size: 24px;
  text-align: center;
  line-height: 30px;
}

.bottom-bar {
  background: rgba(255, 255, 255, 0.95);
  padding: 15px 20px;
  display: flex;
  gap: 15px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.primary-btn {
  flex: 1;
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.3s;
}

.primary-btn:hover {
  transform: translateY(-2px);
}

.secondary-btn {
  padding: 15px 30px;
  background: #f093fb;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.3s;
}

.secondary-btn:hover {
  transform: translateY(-2px);
}

/* 戰鬥界面 */
.battle-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.battle-info {
  background: rgba(255, 255, 255, 0.1);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  backdrop-filter: blur(10px);
}

.battle-timer {
  font-size: 24px;
  font-weight: bold;
}

.battle-score {
  font-size: 20px;
  font-weight: bold;
}

.aiming-interface {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.crosshair {
  font-size: 60px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: bold;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.power-bar {
  width: 200px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  margin-top: 20px;
  overflow: hidden;
}

.power-fill {
  height: 100%;
  background: linear-gradient(90deg, #00ff88 0%, #00ccff 100%);
  width: 0%;
  transition: width 0.1s;
}

.wind-indicator {
  margin-top: 20px;
  color: white;
  font-size: 16px;
}

.skill-buttons {
  display: flex;
  gap: 15px;
  padding: 20px;
  justify-content: center;
}

.skill-btn {
  padding: 15px 30px;
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.3s;
}

.skill-btn:hover {
  transform: translateY(-2px);
}

.exit-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 10px 20px;
  background: rgba(255, 107, 107, 0.8);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.exit-btn:hover {
  background: rgba(255, 107, 107, 1);
}

/* 結果界面 */
.result-container {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 400px;
  text-align: center;
}

.result-container h1 {
  color: #333;
  margin-bottom: 30px;
  font-size: 32px;
}

.result-stats {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 30px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
}

.stat-label {
  color: #666;
  font-weight: bold;
}

.stat-value {
  color: #333;
  font-weight: bold;
  font-size: 18px;
}

/* 資料界面 */
.profile-container {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
}

.profile-container h2 {
  color: #333;
  margin-bottom: 20px;
  font-size: 24px;
}

.profile-info {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 30px;
}

.info-item {
  display: flex;
  justify-content: space-between;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
}

.info-item .label {
  color: #666;
  font-weight: bold;
}

.info-item span:last-child {
  color: #333;
  font-weight: bold;
}

.safe-house-section {
  margin-bottom: 30px;
}

.safe-house-section h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 18px;
}

#safe-houses-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

.safe-house-item {
  display: flex;
  justify-content: space-between;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
}

.house-type {
  color: #667eea;
  font-weight: bold;
}

.house-coords {
  color: #666;
  font-size: 14px;
}

/* 匹配界面 */
.matching-container {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 400px;
  text-align: center;
}

.matching-container h2 {
  color: #333;
  margin-bottom: 30px;
  font-size: 24px;
}

.matching-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.matching-info {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 30px;
  color: #666;
}

.matching-progress {
  margin-bottom: 20px;
}

.progress-bar-container {
  width: 100%;
  height: 20px;
  background: #f3f3f3;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 10px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  color: #666;
  font-size: 14px;
}

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

.modal-content {
  background: white;
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 400px;
  text-align: center;
}

.modal-content h3 {
  color: #333;
  margin-bottom: 20px;
  font-size: 20px;
}

.reward-preview-info {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.reward-item {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
}

.reward-label {
  color: #666;
  font-size: 14px;
}

.reward-value {
  color: #667eea;
  font-weight: bold;
  font-size: 16px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* NPC血量條 */
.npc-hp-bar-container {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 400px;
  z-index: 100;
}

.npc-hp-bar {
  width: 100%;
  height: 30px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 15px;
  overflow: hidden;
  border: 2px solid #ff4444;
}

.npc-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff4444 0%, #ff8800 50%, #ffcc00 100%);
  transition: width 0.3s ease;
  width: 100%;
}

.npc-hp-text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
  color: white;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.npc-name {
  color: #ff4444;
}

/* 傷害數字彈跳動畫 */
.damage-number {
  position: absolute;
  color: #ff4444;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  transition: all 0.5s ease;
  transform: translateY(0) scale(1);
  opacity: 1;
  z-index: 200;
}

/* 好友列表 */
.friend-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
}

.friend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 8px;
}

.friend-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.friend-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #667eea;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
}

.friend-name {
  font-weight: bold;
  color: #333;
}

.friend-status {
  font-size: 12px;
  color: #666;
}

.invite-btn {
  padding: 8px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.2s;
}

.invite-btn:hover {
  transform: scale(1.05);
}

.invite-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

/* 傷害排行榜 */
.damage-leaderboard {
  margin: 20px 0;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 12px;
}

.damage-leaderboard h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 18px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: white;
  border-radius: 8px;
  transition: transform 0.2s;
}

.leaderboard-item:hover {
  transform: translateX(5px);
}

.leaderboard-item:first-child {
  background: linear-gradient(135deg, #ffd700 0%, #ffec8b 100%);
  font-weight: bold;
}

.leaderboard-item:nth-child(2) {
  background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
}

.leaderboard-item:nth-child(3) {
  background: linear-gradient(135deg, #cd7f32 0%, #e8a862 100%);
}

.leaderboard-rank {
  font-weight: bold;
  color: #667eea;
  width: 30px;
}

.leaderboard-name {
  flex: 1;
  color: #333;
}

.leaderboard-damage {
  color: #ff4444;
  font-weight: bold;
}

/* MVP動畫 */
.mvp-animation {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 1000;
  animation: mvpFadeIn 0.5s ease;
}

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

.mvp-badge {
  font-size: 48px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  animation: mvpPulse 1s ease infinite;
}

@keyframes mvpPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.mvp-name {
  font-size: 24px;
  color: white;
  margin: 10px 0;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.mvp-damage {
  font-size: 20px;
  color: #ff4444;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

/* 離線收益 */
.offline-rewards-section {
  margin: 20px 0;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 12px;
}

.offline-rewards-section h3 {
  color: #333;
  margin-bottom: 15px;
  font-size: 18px;
}

.offline-rewards-info {
  margin-bottom: 15px;
  color: #666;
}

.offline-rewards-info p {
  margin: 8px 0;
}

.offline-rewards-info span {
  color: #667eea;
  font-weight: bold;
}

/* 新手引導 */
.tutorial-content {
  max-width: 500px;
}

.tutorial-steps {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.tutorial-step {
  display: none;
  text-align: center;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.tutorial-step.active {
  display: block;
  animation: tutorialFadeIn 0.3s ease;
}

@keyframes tutorialFadeIn {
  0% {
    opacity: 0;
    transform: translateX(20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.tutorial-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.tutorial-step h4 {
  color: #333;
  margin-bottom: 10px;
  font-size: 18px;
}

.tutorial-step p {
  color: #666;
  font-size: 14px;
}

.tutorial-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.tutorial-page-indicator {
  color: #666;
  font-weight: bold;
}

.tutorial-skip {
  text-align: center;
  color: #666;
  font-size: 14px;
}

.tutorial-skip label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .auth-container,
  .result-container,
  .profile-container,
  .matching-container {
    padding: 20px;
    width: 95%;
  }

  .top-nav {
    padding: 10px 15px;
  }

  .nav-buttons button {
    padding: 6px 12px;
    font-size: 12px;
  }

  .bottom-bar {
    padding: 10px 15px;
  }

  .primary-btn,
  .secondary-btn {
    padding: 12px;
    font-size: 14px;
  }
}

/* 手機專用優化 */
@media (max-width: 480px) {
  .auth-container {
    padding: 15px;
    width: 90%;
  }

  .auth-container h1 {
    font-size: 24px;
  }

  .auth-form input {
    padding: 12px;
    font-size: 14px;
  }

  .auth-form button {
    padding: 12px;
    font-size: 14px;
  }

  .top-nav {
    padding: 8px 12px;
  }

  .user-info {
    font-size: 14px;
  }

  .nav-buttons button {
    padding: 5px 10px;
    font-size: 11px;
  }

  .bottom-bar {
    padding: 8px 12px;
    gap: 10px;
  }

  .primary-btn,
  .secondary-btn {
    padding: 14px;
    font-size: 16px;
    font-weight: bold;
  }

  .battle-info {
    padding: 10px 15px;
  }

  .battle-timer {
    font-size: 20px;
  }

  .battle-score {
    font-size: 16px;
  }

  .crosshair {
    font-size: 50px;
  }

  .power-bar {
    width: 150px;
    height: 15px;
  }

  .skill-buttons {
    padding: 15px;
    gap: 10px;
  }

  .skill-btn {
    padding: 12px 20px;
    font-size: 14px;
  }

  .exit-btn {
    padding: 8px 15px;
    font-size: 12px;
  }

  .result-container {
    padding: 15px;
    width: 90%;
  }

  .result-container h1 {
    font-size: 28px;
  }

  .stat-item {
    padding: 12px;
  }

  .stat-value {
    font-size: 16px;
  }

  .profile-container {
    padding: 15px;
    width: 90%;
    max-height: 85vh;
  }

  .profile-container h2 {
    font-size: 20px;
  }

  .info-item {
    padding: 12px;
    font-size: 14px;
  }

  .matching-container {
    padding: 15px;
    width: 90%;
  }

  .matching-container h2 {
    font-size: 20px;
  }

  .matching-spinner {
    width: 50px;
    height: 50px;
  }
}

/* 橫屏優化 */
@media (max-height: 500px) and (orientation: landscape) {
  .auth-container,
  .result-container,
  .profile-container,
  .matching-container {
    padding: 10px;
    width: 60%;
    max-height: 90vh;
    overflow-y: auto;
  }

  .auth-container h1,
  .result-container h1,
  .profile-container h2,
  .matching-container h2 {
    font-size: 18px;
    margin-bottom: 15px;
  }

  .battle-info {
    padding: 5px 10px;
  }

  .skill-buttons {
    padding: 5px 10px;
  }

  .skill-btn {
    padding: 8px 15px;
    font-size: 12px;
  }
}

/* 觸摸優化 */
@media (hover: none) and (pointer: coarse) {
  button {
    min-height: 44px;
    min-width: 44px;
  }

  .skill-btn {
    min-height: 50px;
    min-width: 50px;
  }

  .nav-buttons button {
    min-height: 40px;
  }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  }

  .auth-container,
  .result-container,
  .profile-container,
  .matching-container {
    background: #2a2a4a;
    color: #ffffff;
  }

  .auth-container h1,
  .result-container h1,
  .profile-container h2,
  .matching-container h2 {
    color: #ffffff;
  }

  .auth-form input {
    background: #3a3a5a;
    border-color: #4a4a6a;
    color: #ffffff;
  }

  .info-item {
    background: #3a3a5a;
    color: #ffffff;
  }

  .safe-house-item {
    background: #3a3a5a;
  }

  .stat-item {
    background: #3a3a5a;
  }

  .stat-label {
    color: #aaaaaa;
  }

  .stat-value {
    color: #ffffff;
  }
}
