/* ============================================
   天天三国 - 战斗页面样式
   Canvas 战场 · 操作面板 · 结算
   ============================================ */

/* ============================================
   页面布局
   ============================================ */
.battle-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(139,0,0,0.08) 0%, transparent 60%),
    var(--color-bg-dark);
}

.battle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.75rem;
  background: linear-gradient(180deg, rgba(26,10,10,0.95), rgba(26,10,10,0.7));
  border-bottom: 1px solid var(--color-border);
}

.battle-back-btn {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-dim);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.battle-back-btn:active {
  background: var(--color-bg-hover);
  color: var(--color-text);
}

.battle-stage-name {
  font-family: var(--font-display);
  font-size: 1.125rem;
  color: var(--color-gold);
  text-shadow: 0 0 8px rgba(218,165,32,0.3);
}

.battle-header-spacer,
.battle-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 3.75rem;
  justify-content: flex-end;
}

.battle-speed-btn {
  background: rgba(218,165,32,0.12);
  border: 1px solid var(--color-gold-dark);
  color: var(--color-gold);
  padding: 0.1875rem 0.625rem;
  border-radius: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.battle-speed-btn:active {
  transform: scale(0.93);
  background: rgba(218,165,32,0.25);
}

.battle-skip-btn {
  background: rgba(231,76,60,0.12);
  border: 1px solid rgba(231,76,60,0.4);
  color: var(--color-danger);
  padding: 0.1875rem 0.625rem;
  border-radius: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.battle-skip-btn:active {
  transform: scale(0.93);
  background: rgba(231,76,60,0.25);
}

/* ============================================
   英雄选择阶段
   ============================================ */
.battle-select-phase {
  padding: 1rem 0.75rem;
  animation: fadeSlideUp 0.3s ease;
}

.battle-select-info {
  text-align: center;
  margin-bottom: 1.25rem;
}

.battle-select-title {
  font-family: var(--font-display);
  font-size: 1.375rem;
  color: var(--color-gold);
  margin-bottom: 0.25rem;
}

.battle-select-subtitle {
  font-size: 0.8125rem;
  color: var(--color-text-dim);
}

.battle-hero-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
  max-height: 25rem;
  overflow-y: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

@media (min-width: 420px) {
  .battle-hero-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.battle-hero-card {
  position: relative;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.375rem;
  min-height: 8.125rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  overflow: hidden;
}

.battle-hero-card:active {
  transform: scale(0.96);
}

.battle-hero-card.selected {
  border-color: var(--color-gold);
  background: rgba(218,165,32,0.08);
  box-shadow: 0 0 12px rgba(218,165,32,0.2);
}

.battle-hero-avatar {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.375rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-border);
}
.battle-hero-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }

.rarity-bg-n { background: linear-gradient(135deg, #555, #777); }
.rarity-bg-r { background: linear-gradient(135deg, #2e7d32, #4caf50); }
.rarity-bg-sr { background: linear-gradient(135deg, #1565c0, #42a5f5); }
.rarity-bg-ssr { background: linear-gradient(135deg, #6a1b9a, #ab47bc); }

.battle-hero-emoji {
  font-size: 1.375rem;
}

.battle-hero-name {
  font-size: 0.75rem;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.125rem;
}

.battle-hero-meta {
  font-size: 0.625rem;
  color: var(--color-text-dim);
}
.battle-hero-power {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-gold);
  margin-top: 0.25rem;
}

.battle-hero-check {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.25rem;
  height: 1.25rem;
  background: var(--color-gold);
  color: #1a1a1a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
  animation: popIn 0.2s ease;
}

.battle-select-actions {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  flex-shrink: 0;
}

.battle-select-actions .btn {
  flex: 1;
  padding: 0.75rem;
  font-size: 0.9375rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition-fast);
}

.battle-select-actions .btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: var(--color-gold-light);
  box-shadow: 0 2px 8px rgba(139,0,0,0.4);
}

.battle-select-actions .btn-primary:active {
  transform: scale(0.97);
}

.battle-select-actions .btn-primary.disabled,
.battle-select-actions .btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.battle-select-actions .btn-secondary {
  background: var(--color-bg-card);
  color: var(--color-text-dim);
  border: 1px solid var(--color-border);
}

.battle-empty {
  text-align: center;
  padding: 2.5rem 0;
  color: var(--color-text-dim);
  font-size: 0.875rem;
}

/* ============================================
   战斗场景
   ============================================ */
.battle-arena {
  display: flex;
  flex-direction: column;
  flex: 1;
  animation: fadeSlideUp 0.3s ease;
}

.battle-canvas-wrap {
  width: 100%;
  border-bottom: 1px solid var(--color-border);
  background: #1a0a0a;
  position: relative;
  overflow: hidden;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.battle-canvas-wrap canvas {
  display: block;
  width: 100%;
}

/* ============================================
   回合指示器
   ============================================ */
.battle-turn-indicator {
  text-align: center;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(90deg, transparent, rgba(218,165,32,0.08), transparent);
}

.turn-text {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  color: var(--color-gold);
  text-shadow: 0 0 6px rgba(218,165,32,0.3);
}

/* ============================================
   单位血条面板
   ============================================ */
.battle-unit-bars {
  padding: 0.375rem 0.75rem;
}

.unit-bars-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.unit-bars-side {
  display: flex;
  gap: 0.375rem;
  flex: 1;
}

.unit-bars-side.enemy {
  justify-content: flex-end;
}

.unit-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  min-width: 2rem;
}

.unit-bar-item.dead {
  opacity: 0.35;
}

.unit-bar-name {
  font-size: 0.625rem;
  color: var(--color-text-dim);
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: rgba(46,204,113,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.unit-bar-name.enemy {
  background: rgba(231,76,60,0.15);
}

.unit-bar-hp,
.unit-bar-mp {
  width: 2rem;
  height: 0.1875rem;
  background: rgba(0,0,0,0.4);
  border-radius: 0.125rem;
  overflow: hidden;
}

.unit-bar-fill {
  height: 100%;
  border-radius: 0.125rem;
  transition: width 0.3s ease;
}

.unit-bar-fill.hp {
  background: var(--color-success);
}

.unit-bar-fill.mp {
  background: var(--color-info);
}

/* ============================================
   战斗日志
   ============================================ */
.battle-log-panel {
  margin: 0.25rem 0.75rem;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.battle-log-title {
  font-size: 0.6875rem;
  color: var(--color-text-dim);
  padding: 0.25rem 0.5rem;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--color-border);
}

.battle-log-list {
  max-height: 5rem;
  overflow-y: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  line-height: 1.6;
}

.battle-log-entry {
  color: var(--color-text-dim);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  padding: 0.0625rem 0;
}

.battle-log-entry.log-player {
  color: rgba(46,204,113,0.8);
}

.battle-log-entry.log-enemy {
  color: rgba(231,76,60,0.7);
}

/* ============================================
   操作面板
   ============================================ */
.battle-action-panel {
  padding: 0.5rem 0.75rem 1rem;
  background: linear-gradient(0deg, rgba(26,10,10,0.95), rgba(26,10,10,0.6));
  border-top: 1px solid var(--color-border);
  margin-top: auto;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  -webkit-overflow-scrolling: touch;
}

.action-buttons::-webkit-scrollbar {
  height: 0.125rem;
}

.action-btn {
  flex-shrink: 0;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  color: var(--color-text);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  min-width: 4.5rem;
}

.action-btn:active {
  transform: scale(0.95);
  background: var(--color-bg-hover);
}

.attack-btn {
  border-color: var(--color-primary-light);
  background: rgba(139,0,0,0.15);
}

.skill-btn {
  border-color: var(--color-info);
  background: rgba(52,152,219,0.08);
}

.skill-btn .skill-name {
  font-size: 0.75rem;
  white-space: nowrap;
}

.skill-btn .skill-cost {
  font-size: 0.625rem;
  color: var(--color-info);
}

.skill-btn .skill-cd {
  font-size: 0.5625rem;
  color: var(--color-warning);
  background: rgba(243,156,18,0.15);
  padding: 0.0625rem 0.25rem;
  border-radius: 0.1875rem;
}

.skill-btn.disabled,
.skill-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.auto-btn {
  border-color: var(--color-gold-dark);
  background: rgba(218,165,32,0.08);
  color: var(--color-gold);
  margin-left: auto;
}

.auto-btn.active {
  background: rgba(218,165,32,0.2);
  border-color: var(--color-gold);
  box-shadow: 0 0 8px rgba(218,165,32,0.3);
}

.target-hint {
  text-align: center;
  padding: 0.5rem;
  color: var(--color-warning);
  font-size: 0.8125rem;
  animation: pulse 1s ease infinite;
}

/* ============================================
   战斗结算
   ============================================ */
.battle-result {
  padding: 1.5rem 1rem;
  text-align: center;
  animation: fadeSlideUp 0.4s ease;
}

.battle-result.victory {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(218,165,32,0.1) 0%, transparent 60%),
    transparent;
}

.battle-result.defeat {
  background:
    radial-gradient(ellipse at 50% 30%, rgba(139,0,0,0.1) 0%, transparent 60%),
    transparent;
}

.result-banner {
  margin-bottom: 1.25rem;
}

.result-title {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.2;
}

.victory .result-title {
  color: var(--color-gold);
  text-shadow: 0 0 20px rgba(218,165,32,0.5);
}

.defeat .result-title {
  color: var(--color-danger);
  text-shadow: 0 0 15px rgba(231,76,60,0.4);
}

.result-stars {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.result-star {
  font-size: 2.25rem;
  transition: all 0.3s ease;
}

.result-star.filled {
  color: var(--color-gold);
  text-shadow: 0 0 12px rgba(218,165,32,0.6);
  animation: starPop 0.4s ease backwards;
}

.result-star.filled:nth-child(1) { animation-delay: 0.1s; }
.result-star.filled:nth-child(2) { animation-delay: 0.3s; }
.result-star.filled:nth-child(3) { animation-delay: 0.5s; }

.result-star.empty {
  color: var(--color-text-dim);
  opacity: 0.3;
}

.result-rewards {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
}

.result-reward-title {
  font-size: 0.875rem;
  color: var(--color-text-dim);
  margin-bottom: 0.75rem;
}

.result-reward-grid {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 0.75rem;
}

.result-reward-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.reward-icon {
  font-size: 1.75rem;
}

.reward-amount {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-gold);
}

.reward-label {
  font-size: 0.6875rem;
  color: var(--color-text-dim);
}

.result-turns {
  font-size: 0.75rem;
  color: var(--color-text-dim);
}

.result-defeat-msg {
  padding: 1.25rem;
  color: var(--color-text-dim);
  font-size: 0.875rem;
  line-height: 1.8;
}

.result-actions {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 0;
}

.result-actions .btn {
  flex: 1;
  padding: 0.75rem;
  font-size: 0.9375rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition-fast);
}

.result-actions .btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: var(--color-gold-light);
  box-shadow: 0 2px 8px rgba(139,0,0,0.4);
}

.result-actions .btn-primary:active {
  transform: scale(0.97);
}

.result-actions .btn-secondary {
  background: var(--color-bg-card);
  color: var(--color-text-dim);
  border: 1px solid var(--color-border);
}

/* ============================================
   动画
   ============================================ */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes starPop {
  from {
    transform: scale(0) rotate(-30deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 360px) {
  .battle-hero-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.375rem;
  }

  .battle-hero-avatar {
    width: 2.5rem;
    height: 2.5rem;
  }

  .battle-hero-emoji {
    font-size: 1.125rem;
  }

  .action-btn {
    padding: 0.5rem 0.625rem;
    min-width: 3.75rem;
    font-size: 0.75rem;
  }

  .battle-stage-name {
    font-size: 1rem;
  }
}

@media (min-width: 480px) {
  .battle-hero-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .battle-log-list {
    max-height: 6.25rem;
  }
}

/* ============================================
   移动端响应式 - 战斗页
   ============================================ */
@media (max-width: 480px) {
  .battle-header {
    padding: 0.5rem;
  }

  .battle-stage-name {
    font-size: 0.9375rem;
  }

  .battle-speed-btn,
  .battle-skip-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    min-height: 2rem;
  }

  .battle-back-btn {
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    min-height: 2.25rem;
  }

  /* Battle hero selection */
  .battle-select-title {
    font-size: 1.125rem;
  }

  .battle-hero-grid {
    max-height: 20rem;
    gap: 0.5rem;
  }

  .battle-hero-card {
    padding: 0.5rem 0.25rem;
    min-height: 6.875rem;
  }

  .battle-hero-avatar {
    width: 2.5rem;
    height: 2.5rem;
  }

  .battle-hero-emoji {
    font-size: 1.125rem;
  }

  .battle-hero-name {
    font-size: 0.6875rem;
  }

  /* Action buttons — touch targets */
  .action-btn {
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
    min-width: 4rem;
    font-size: 0.75rem;
  }

  .battle-select-actions .btn {
    min-height: 2.75rem;
    padding: 0.625rem;
    font-size: 0.875rem;
  }

  /* Battle log — compact */
  .battle-log-list {
    max-height: 3.75rem;
    font-size: 0.625rem;
  }

  /* Unit bars — smaller */
  .unit-bar-item {
    min-width: 1.75rem;
  }

  .unit-bar-name {
    width: 1rem;
    height: 1rem;
    font-size: 0.5625rem;
  }

  .unit-bar-hp,
  .unit-bar-mp {
    width: 1.75rem;
  }

  /* Result page */
  .result-title {
    font-size: 1.625rem;
  }

  .result-star {
    font-size: 1.75rem;
  }

  .result-reward-grid {
    gap: 1rem;
  }

  .reward-icon {
    font-size: 1.375rem;
  }

  .reward-amount {
    font-size: 0.9375rem;
  }

  .result-actions .btn {
    min-height: 2.75rem;
    font-size: 0.875rem;
  }
}
