/* ========================================
   元气卡牌 - 二次元风格样式
   ======================================== */

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

:root {
  --bg-primary: #f5f0eb;
  --bg-secondary: #ede5dc;
  --bg-card: rgba(255, 255, 255, 0.75);
  --border-color: rgba(180, 150, 120, 0.25);
  --text-primary: #4a3f35;
  --text-secondary: #8a7d6f;
  --accent-purple: #9b7cbf;
  --accent-pink: #e89db5;
  --accent-yellow: #e8b84e;
  --accent-red: #e08585;
  --accent-blue: #6ba3d6;
  --accent-green: #6dcbb5;
  --glow-purple: 0 0 16px rgba(155, 124, 191, 0.25);
  --glow-pink: 0 0 16px rgba(232, 157, 181, 0.25);
}

body {
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* 背景装饰 */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse 800px 600px at 10% 10%, rgba(155, 124, 191, 0.08), transparent 70%),
    radial-gradient(ellipse 700px 500px at 90% 30%, rgba(232, 157, 181, 0.06), transparent 70%),
    radial-gradient(ellipse 900px 700px at 50% 90%, rgba(109, 203, 181, 0.05), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* 粒子背景 */
.particles {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent-purple);
  border-radius: 50%;
  opacity: 0.6;
  animation: float-up linear infinite;
}

@keyframes float-up {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 0.6;
  }
  90% {
    opacity: 0.6;
  }
  100% {
    transform: translateY(-10vh) scale(1);
    opacity: 0;
  }
}

/* ========== 开始界面 ========== */
.start-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: var(--bg-primary);
}

.start-container {
  text-align: center;
  padding: 40px;
}

.game-title {
  font-size: 64px;
  font-weight: bold;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink), var(--accent-yellow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  animation: title-glow 3s ease-in-out infinite;
}

@keyframes title-glow {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(155, 124, 191, 0.5)); }
  50% { filter: drop-shadow(0 0 25px rgba(232, 157, 181, 0.7)); }
}

.game-subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.start-form {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 32px;
  backdrop-filter: blur(10px);
  max-width: 400px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 24px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.form-group input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.form-group input[type="text"]:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(155, 124, 191, 0.15);
}

.school-select {
  display: flex;
  gap: 12px;
}

.school-option {
  flex: 1;
  padding: 16px;
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.school-option:hover {
  border-color: var(--accent-purple);
  background: rgba(155, 124, 191, 0.08);
}

.school-option.selected {
  border-color: var(--accent-purple);
  background: rgba(155, 124, 191, 0.15);
  box-shadow: var(--glow-purple);
}

.school-option .school-name {
  font-size: 20px;
  font-weight: bold;
  color: var(--text-primary);
}

.school-option .school-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.start-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: 8px;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(155, 124, 191, 0.4);
}

.start-btn:active {
  transform: translateY(0);
}

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

.difficulty-select {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.diff-option {
  flex: 1;
  padding: 10px;
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  font-size: 14px;
}

.diff-option:hover {
  border-color: var(--accent-pink);
}

.diff-option.selected {
  border-color: var(--accent-pink);
  background: rgba(232, 157, 181, 0.15);
}

/* ========== 游戏主界面 ========== */
.game-container {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* 对手区域 */
.opponent-area {
  flex: 0 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

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

.player-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border: 2px solid var(--border-color);
}

.player-details .player-name {
  font-size: 16px;
  font-weight: bold;
  color: var(--text-primary);
}

.player-details .player-school {
  font-size: 12px;
  color: var(--text-secondary);
}

.energy-display {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

.energy-icon {
  font-size: 20px;
  filter: drop-shadow(0 0 5px var(--accent-yellow));
}

.energy-value {
  font-size: 24px;
  font-weight: bold;
  color: var(--accent-yellow);
  text-shadow: 0 0 10px rgba(232, 184, 78, 0.5);
}

.revive-badge {
  padding: 4px 10px;
  background: rgba(109, 203, 181, 0.2);
  border: 1px solid var(--accent-green);
  border-radius: 12px;
  font-size: 12px;
  color: var(--accent-green);
  font-weight: bold;
}

.opponent-hand {
  display: flex;
  gap: -15px;
  justify-content: flex-end;
}

.opponent-hand .card-back {
  width: 60px;
  height: 80px;
  margin-left: -20px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border-radius: 8px;
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

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

.round-info {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 14px;
  color: var(--text-secondary);
  backdrop-filter: blur(10px);
}

.round-info strong {
  color: var(--accent-purple);
  font-size: 16px;
}

.battle-cards {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 60px;
}

.battle-slot {
  width: 140px;
  height: 200px;
  border: 2px dashed var(--border-color);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  position: relative;
}

.battle-slot.has-card {
  border-style: solid;
  border-color: var(--accent-purple);
  box-shadow: var(--glow-purple);
}

.battle-slot .slot-label {
  position: absolute;
  top: -25px;
  font-size: 12px;
  color: var(--text-secondary);
}

.vs-text {
  font-size: 32px;
  font-weight: bold;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* 倒计时 */
.timer-bar {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 8px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-yellow));
  border-radius: 4px;
  transition: width 0.1s linear;
}

.timer-fill.urgent {
  background: linear-gradient(90deg, var(--accent-red), #d96565);
  animation: timer-pulse 0.5s ease-in-out infinite;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.timer-text {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: var(--text-secondary);
}

.timer-text.urgent {
  color: var(--accent-red);
  font-weight: bold;
}

/* 玩家区域 */
.player-area {
  flex: 0 0 auto;
  padding: 16px 24px 24px;
}

.player-area-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.player-hand {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 160px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

/* 卡牌样式 */
.card {
  width: 100px;
  height: 140px;
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  backdrop-filter: blur(10px);
  user-select: none;
}

.card:hover {
  transform: translateY(-10px) scale(1.05);
  box-shadow: 0 10px 30px rgba(155, 124, 191, 0.2);
  z-index: 10;
}

.card.selected {
  transform: translateY(-20px) scale(1.1);
  box-shadow: 0 15px 40px rgba(155, 124, 191, 0.3);
  border-color: var(--accent-purple);
}

.card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.card.disabled:hover {
  transform: none;
  box-shadow: none;
}

.card-cost {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 28px;
  height: 28px;
  background: var(--accent-yellow);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: #4a3f35;
  border: 2px solid var(--bg-primary);
  box-shadow: 0 2px 8px rgba(232, 184, 78, 0.4);
}

.card-cost.free {
  background: var(--accent-green);
}

.card-icon {
  font-size: 36px;
  margin-top: 16px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.12));
}

.card-name {
  font-size: 14px;
  font-weight: bold;
  color: var(--text-primary);
  text-align: center;
}

.card-type-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
}

.card.attack { border-color: rgba(224, 133, 133, 0.5); }
.card.attack:hover { border-color: var(--accent-red); }
.card.defense { border-color: rgba(107, 163, 214, 0.5); }
.card.defense:hover { border-color: var(--accent-blue); }
.card.energy { border-color: rgba(232, 184, 78, 0.5); }
.card.energy:hover { border-color: var(--accent-yellow); }
.card.special { border-color: rgba(109, 203, 181, 0.5); }
.card.special:hover { border-color: var(--accent-green); }

/* 战场中的大卡牌 */
.battle-card {
  width: 120px;
  height: 170px;
  font-size: 1.1em;
  animation: card-appear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes card-appear {
  0% {
    transform: scale(0) rotateY(180deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotateY(0deg);
    opacity: 1;
  }
}

/* 伤害数字 */
.damage-number {
  position: absolute;
  font-size: 36px;
  font-weight: bold;
  color: var(--accent-red);
  text-shadow: 0 0 10px rgba(224, 133, 133, 0.6), 2px 2px 4px rgba(0, 0, 0, 0.15);
  animation: damage-float 1s ease-out forwards;
  pointer-events: none;
  z-index: 100;
}

@keyframes damage-float {
  0% {
    transform: translateY(0) scale(0.5);
    opacity: 0;
  }
  20% {
    transform: translateY(-20px) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translateY(-80px) scale(1);
    opacity: 0;
  }
}

.damage-number.heal {
  color: var(--accent-green);
  text-shadow: 0 0 10px rgba(109, 203, 181, 0.8);
}

/* 结算信息 */
.settle-info {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 50;
}

.settle-text {
  font-size: 24px;
  font-weight: bold;
  padding: 12px 32px;
  background: var(--bg-card);
  border: 2px solid var(--accent-purple);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  animation: settle-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes settle-pop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========== 游戏结束界面 ========== */
.game-over-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(245, 240, 235, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(10px);
  animation: fade-in 0.5s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.game-over-content {
  text-align: center;
  animation: pop-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.game-over-title {
  font-size: 64px;
  font-weight: bold;
  margin-bottom: 20px;
}

.game-over-title.win {
  background: linear-gradient(135deg, var(--accent-yellow), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: win-glow 2s ease-in-out infinite;
}

@keyframes win-glow {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(232, 184, 78, 0.6)); }
  50% { filter: drop-shadow(0 0 40px rgba(232, 157, 181, 0.8)); }
}

.game-over-title.lose {
  color: var(--accent-red);
  text-shadow: 0 0 20px rgba(224, 133, 133, 0.5);
}

.game-over-subtitle {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.game-over-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 40px;
}

.stat-box {
  text-align: center;
  padding: 20px 30px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

.stat-box .stat-value {
  font-size: 32px;
  font-weight: bold;
  color: var(--accent-purple);
}

.stat-box .stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.restart-btn {
  padding: 16px 48px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  margin: 0 8px;
}

.restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(155, 124, 191, 0.4);
}

.restart-btn.secondary {
  background: transparent;
  border: 2px solid var(--border-color);
  color: var(--text-secondary);
}

.restart-btn.secondary:hover {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
}

/* ========== 战斗日志 ========== */
.battle-log {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 240px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  backdrop-filter: blur(10px);
  font-size: 12px;
  z-index: 10;
}

.battle-log-title {
  font-weight: bold;
  color: var(--accent-purple);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.log-entry {
  padding: 6px 0;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry .log-round {
  color: var(--accent-purple);
  font-weight: bold;
}

/* 屏幕震动效果 */
.screen-shake {
  animation: shake 0.3s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* 响应式 */
@media (max-width: 768px) {
  .game-title { font-size: 40px; }
  
  .card {
    width: 70px;
    height: 100px;
    padding: 4px;
  }
  
  .card-icon { font-size: 24px; margin-top: 8px; }
  .card-name { font-size: 11px; }
  .card-cost { width: 22px; height: 22px; font-size: 11px; }
  
  .battle-cards { gap: 30px; }
  .battle-slot { width: 100px; height: 140px; }
  .battle-card { width: 90px; height: 130px; }
  
  .player-hand { gap: 4px; min-height: 120px; }
  
  .battle-log { display: none; }
  
  .opponent-hand .card-back {
    width: 40px;
    height: 56px;
    margin-left: -12px;
    font-size: 16px;
  }
}

/* ===== 游戏内退出按钮 ===== */
.exit-game-btn {
  position: absolute;
  top: 14px;
  right: 66px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  z-index: 20;
  transition: all 0.2s;
}
.exit-game-btn:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
  background: rgba(224, 133, 133, 0.08);
}

/* ===== 音效开关 ===== */
.sound-toggle-btn {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  color: var(--text-primary);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 320;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.sound-toggle-btn:hover {
  border-color: var(--accent-purple);
  transform: scale(1.08);
}

/* ===== 房间准备玩家列表 ===== */
.room-player-list {
  margin: 14px 0 6px;
}
.room-player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(180, 150, 120, 0.2);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}
.room-player-item .rp-left {
  display: flex;
  align-items: center;
}
.room-player-item .rp-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(155, 124, 191, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  margin-right: 10px;
}
.room-player-item .rp-name {
  font-weight: bold;
  color: var(--text-primary);
}
.room-player-item .rp-school {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: 6px;
}
.ready-badge {
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 10px;
  white-space: nowrap;
}
.ready-badge.yes {
  background: rgba(109, 203, 181, 0.2);
  color: #3fa288;
  font-weight: bold;
}
.ready-badge.no {
  background: rgba(180, 150, 120, 0.15);
  color: var(--text-secondary);
}
.ready-badge.waiting {
  background: rgba(246, 190, 111, 0.18);
  color: #b08d3e;
}
