/* ===== 寶珠冒險 RPG - 遊戲樣式 ===== */

:root {
  --bg-dark: #0a0a1a;
  --bg-panel: rgba(20, 20, 40, 0.95);
  --accent-gold: #ffd700;
  --accent-red: #ff4444;
  --accent-green: #44ff44;
  --accent-blue: #44aaff;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== 主選單畫面 ===== */
#menu-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: linear-gradient(180deg, #1a1a2e 0%, #0a0a1a 100%);
}

#game-logo {
  width: 90%;
  max-width: 400px;
  height: auto;
  margin-bottom: 30px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* 角色選擇 */
.hero-select {
  display: flex;
  gap: 15px;
  margin-bottom: 30px;
  flex-wrap: wrap;
  justify-content: center;
}

.hero-card {
  width: 100px;
  height: 140px;
  background: var(--bg-panel);
  border: 3px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px;
}

.hero-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(255, 215, 0, 0.3);
}

.hero-card.selected {
  border-color: var(--accent-gold);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.hero-card img {
  width: 70px;
  height: 70px;
  object-fit: contain;
}

.hero-card .name {
  margin-top: 8px;
  font-size: 14px;
  font-weight: bold;
}

/* 難度選擇 */
.difficulty-select {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  flex-wrap: wrap;
  justify-content: center;
}

.diff-btn {
  padding: 12px 24px;
  border: 2px solid var(--text-secondary);
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s;
}

.diff-btn:hover {
  border-color: var(--accent-gold);
}

.diff-btn.selected {
  background: linear-gradient(135deg, #ffd700, #ff8c00);
  border-color: transparent;
  color: #000;
  font-weight: bold;
}

/* 開始按鈕 */
.start-btn {
  padding: 16px 60px;
  font-size: 20px;
  font-weight: bold;
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  border: none;
  border-radius: 50px;
  color: white;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 5px 20px rgba(238, 90, 36, 0.4);
}

.start-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 30px rgba(238, 90, 36, 0.6);
}

.start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== 遊戲主畫面 ===== */
#game-screen {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  background-size: cover;
  background-position: center;
}

/* 頂部 HUD */
.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
}

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

.player-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid var(--accent-gold);
  object-fit: contain;
  background: var(--bg-panel);
}

.player-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bar-container {
  width: 120px;
  height: 16px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  transition: width 0.3s ease;
  border-radius: 8px;
}

.hp-bar .bar-fill {
  background: linear-gradient(90deg, #ff4444, #ff6666);
}

.skill-bar .bar-fill {
  background: linear-gradient(90deg, #4444ff, #6666ff);
}

.bar-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: bold;
  text-shadow: 1px 1px 2px #000;
}

.stage-info {
  text-align: right;
}

.stage-info .stage {
  font-size: 14px;
  color: var(--accent-gold);
}

.stage-info .wave {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 戰鬥區域 */
.battle-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.monster-container {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 20px;
}

.monster {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s;
}

.monster.dead {
  opacity: 0;
  transform: scale(0);
}

.monster img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.5));
}

.monster.attacking img {
  animation: monster-attack 0.5s ease;
}

@keyframes monster-attack {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(20px) scale(1.1); }
}

.monster-hp {
  width: 70px;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  margin-top: 5px;
  overflow: hidden;
}

.monster-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff0000, #ff4444);
  transition: width 0.3s ease;
}

/* 轉珠區域 */
.board-container {
  padding: 10px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 16px;
  backdrop-filter: blur(10px);
}

#board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  touch-action: none;
}

.orb {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: inherit;
  box-shadow: inset -3px -3px 8px rgba(0, 0, 0, 0.4),
              inset 3px 3px 8px rgba(255, 255, 255, 0.3);
}

.orb::after {
  content: '';
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  top: 15%;
  left: 20%;
}

.orb.fire { background: linear-gradient(135deg, #ff6b6b, #ee5a24); }
.orb.water { background: linear-gradient(135deg, #74b9ff, #0984e3); }
.orb.wood { background: linear-gradient(135deg, #55efc4, #00b894); }
.orb.light { background: linear-gradient(135deg, #ffeaa7, #fdcb6e); }
.orb.dark { background: linear-gradient(135deg, #a29bfe, #6c5ce7); }
.orb.heart { background: linear-gradient(135deg, #fd79a8, #e84393); }

.orb.dragging {
  transform: scale(1.2);
  z-index: 100;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.orb.matched {
  animation: orb-clear 0.3s ease forwards;
}

@keyframes orb-clear {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.5; }
  100% { transform: scale(0); opacity: 0; }
}

/* 技能按鈕 */
.skill-btn {
  position: absolute;
  bottom: 200px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid var(--accent-gold);
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: white;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.skill-btn:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(108, 92, 231, 0.6);
}

.skill-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(1);
}

/* 傷害數字 */
.damage-number {
  position: absolute;
  font-size: 24px;
  font-weight: bold;
  color: #ff4444;
  text-shadow: 2px 2px 4px #000;
  animation: damage-float 1s ease forwards;
  pointer-events: none;
  z-index: 1000;
}

.damage-number.heal {
  color: #44ff44;
}

@keyframes damage-float {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-50px) scale(1.5); }
}

/* Combo 顯示 */
.combo-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: bold;
  color: var(--accent-gold);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
  animation: combo-pop 0.5s ease;
  pointer-events: none;
  z-index: 1000;
}

@keyframes combo-pop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ===== 結果畫面 ===== */
.result-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.result-overlay.show {
  display: flex;
}

.result-banner {
  width: 80%;
  max-width: 400px;
  margin-bottom: 30px;
}

.result-text {
  font-size: 24px;
  margin-bottom: 20px;
  text-align: center;
}

.result-btn {
  padding: 15px 40px;
  font-size: 18px;
  margin: 10px;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s;
}

.result-btn.retry {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: white;
}

.result-btn.menu {
  background: linear-gradient(135deg, #74b9ff, #0984e3);
  color: white;
}

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

/* ===== 響應式設計 ===== */
@media (max-width: 400px) {
  .orb {
    width: 45px;
    height: 45px;
  }
  
  .hero-card {
    width: 85px;
    height: 120px;
  }
  
  .hero-card img {
    width: 55px;
    height: 55px;
  }
  
  .monster img {
    width: 60px;
    height: 60px;
  }
}

@media (min-width: 500px) {
  .orb {
    width: 55px;
    height: 55px;
  }
}
