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

body {
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ====== 主菜单 ====== */
.main-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  text-align: center;
  padding: 20px;
}

.main-menu h1 {
  font-size: 3em;
  background: linear-gradient(45deg, #ffd700, #ff8c00, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
  text-shadow: none;
}

.main-menu .subtitle {
  font-size: 1.2em;
  color: #aaa;
  margin-bottom: 40px;
}

.main-menu .menu-desc {
  max-width: 500px;
  color: #888;
  line-height: 1.8;
  margin-bottom: 30px;
  font-size: 0.95em;
}

.btn-primary {
  padding: 15px 50px;
  font-size: 1.3em;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(135deg, #e94560, #c23152);
  color: white;
  font-weight: bold;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(233, 69, 96, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(233, 69, 96, 0.6);
}

.btn-primary:disabled {
  background: #555;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ====== 准备界面 ====== */
.prepare-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
}

.prepare-screen h2 {
  font-size: 2em;
  color: #ffd700;
  margin: 20px 0 10px;
}

.prepare-screen .prepare-desc {
  color: #aaa;
  margin-bottom: 20px;
}

.skill-select {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  max-width: 900px;
  width: 100%;
  margin-bottom: 20px;
}

.skill-option {
  background: #252540;
  border: 2px solid #333;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.skill-option:hover {
  border-color: #e94560;
  background: #2a2a4a;
}

.skill-option.chosen {
  border-color: #2ecc71;
  background: #1a3a2a;
  box-shadow: 0 0 10px rgba(46, 204, 113, 0.3);
}

.skill-option .skill-icon {
  font-size: 1.5em;
  margin-right: 8px;
}

.skill-option strong {
  color: #fff;
  font-size: 1.05em;
}

.skill-option .skill-meta {
  display: block;
  color: #6688cc;
  font-size: 0.85em;
  margin-top: 4px;
}

.skill-option .skill-desc {
  display: block;
  color: #888;
  font-size: 0.8em;
  margin-top: 4px;
}

.prepare-actions {
  display: flex;
  gap: 15px;
  align-items: center;
  margin: 10px 0 30px;
}

.skill-count {
  color: #aaa;
  font-size: 1.1em;
}

/* ====== 战斗界面 ====== */
.battle-screen {
  display: none;
  max-width: 800px;
  margin: 0 auto;
  padding: 10px;
  min-height: 100vh;
  background: linear-gradient(180deg, #0d0d1a 0%, #1a1a2e 30%, #16213e 100%);
}

.shake {
  animation: screenShake 0.3s ease-out;
}

@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px) translateY(2px); }
  40% { transform: translateX(5px) translateY(-2px); }
  60% { transform: translateX(-3px) translateY(1px); }
  80% { transform: translateX(3px); }
}

/* 回合信息 */
.turn-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 15px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  margin-bottom: 8px;
}

.turn-info .turn-number {
  font-size: 1.1em;
  color: #ffd700;
}

.phase-indicator {
  color: #aaa;
  font-size: 0.95em;
}

/* 敌人区域 */
.enemy-area {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 15px;
  margin-bottom: 8px;
}

/* 意图预览 */
.intentions {
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid #e94560;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 0 8px 8px 0;
  min-height: 30px;
}

.intent-item {
  font-size: 0.85em;
  color: #ccc;
  padding: 2px 0;
}

.intent-danger {
  color: #ff6b6b;
  font-weight: bold;
}

/* 友方区域 */
.ally-area {
  display: flex;
  justify-content: center;
  gap: 15px;
  padding: 10px;
  margin-bottom: 8px;
}

/* 角色卡片 */
.character-card {
  background: rgba(30, 30, 50, 0.8);
  border: 2px solid #333;
  border-radius: 10px;
  padding: 10px;
  min-width: 180px;
  text-align: center;
  position: relative;
  transition: all 0.2s;
}

.character-card.dead {
  opacity: 0.4;
  filter: grayscale(0.8);
}

.character-card.targetable {
  border-color: #2ecc71;
  cursor: pointer;
  animation: targetPulse 1s infinite;
}

.character-card.targetable:hover {
  background: rgba(46, 204, 113, 0.15);
  border-color: #27ae60;
  transform: translateY(-3px);
}

@keyframes targetPulse {
  0%, 100% { box-shadow: 0 0 5px rgba(46, 204, 113, 0.3); }
  50% { box-shadow: 0 0 15px rgba(46, 204, 113, 0.6); }
}

.char-icon {
  font-size: 2em;
  margin-bottom: 4px;
}

.char-name {
  font-size: 0.9em;
  color: #ddd;
  margin-bottom: 6px;
}

.danger-pulse {
  animation: dangerPulse 0.8s infinite;
}

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

/* 血条 */
.hp-bar-container {
  width: 100%;
  height: 18px;
  background: #333;
  border-radius: 9px;
  overflow: hidden;
  position: relative;
  margin-bottom: 3px;
}

.hp-bar {
  height: 100%;
  border-radius: 9px;
  transition: width 0.4s ease, background 0.3s;
}

.hp-bar.danger {
  animation: hpDanger 0.6s infinite;
}

@keyframes hpDanger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.shield-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(52, 152, 219, 0.6);
  border-radius: 9px;
  transition: width 0.4s;
}

.hp-text {
  font-size: 0.8em;
  color: #aaa;
}

.dead-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  color: #e74c3c;
  border-radius: 10px;
}

/* 状态效果 */
.status-effects {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 5px;
  flex-wrap: wrap;
}

.status-icon {
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.4);
  padding: 1px 5px;
  border-radius: 4px;
  cursor: help;
}

/* 玩家状态 */
.player-status {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 15px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  margin-bottom: 8px;
}

.player-status .player-label {
  font-size: 1.1em;
  color: #ffd700;
  white-space: nowrap;
}

.bar-container {
  flex: 1;
  height: 16px;
  background: #333;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

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

.bar-fill.hp { background: linear-gradient(90deg, #27ae60, #2ecc71); }
.bar-fill.mp { background: linear-gradient(90deg, #2980b9, #3498db); }

.bar-text {
  font-size: 0.75em;
  color: #aaa;
  min-width: 90px;
  text-align: right;
}

#cast-info {
  color: #f39c12;
  font-size: 0.9em;
  font-style: italic;
}

/* 技能栏 */
.skill-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  margin-bottom: 8px;
  justify-content: center;
}

.skill-btn {
  background: #252540;
  border: 2px solid #444;
  color: #eee;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  font-size: 0.85em;
}

.skill-btn:hover:not(.disabled) {
  border-color: #e94560;
  background: #302550;
  transform: translateY(-2px);
}

.skill-btn.selected {
  border-color: #ffd700;
  background: #3a3020;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.skill-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.skill-btn .skill-icon { font-size: 1.3em; }
.skill-btn .skill-name { font-weight: bold; margin: 2px 0; }
.skill-btn .skill-cost { font-size: 0.75em; color: #6688cc; }

.end-turn-btn {
  background: linear-gradient(135deg, #e94560, #c23152);
  border-color: #e94560;
  padding: 10px 25px;
  font-size: 1em;
  font-weight: bold;
  min-width: 160px;
}

.end-turn-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
}

/* 战斗日志 */
.battle-log {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  padding: 10px;
  height: 180px;
  overflow-y: auto;
  font-size: 0.82em;
  line-height: 1.5;
  scroll-behavior: smooth;
}

.battle-log::-webkit-scrollbar {
  width: 6px;
}

.battle-log::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}

.log-entry {
  padding: 1px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.log-heal { color: #2ecc71; }
.log-danger { color: #e74c3c; }
.log-crit { color: #ffd700; font-weight: bold; }
.log-event { color: #9b59b6; font-weight: bold; }
.log-turn { color: #f39c12; font-weight: bold; margin-top: 5px; }

/* 飘字效果 */
.floating-text {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-weight: bold;
  font-size: 1.3em;
  pointer-events: none;
  z-index: 100;
  animation: floatUp 1.5s ease-out forwards;
}

.float-heal { color: #2ecc71; }
.float-crit-heal { color: #ffd700; font-size: 1.8em; }
.float-shield { color: #3498db; }
.float-buff { color: #f39c12; }
.float-dispel { color: #9b59b6; }
.float-damage { color: #e74c3c; }

@keyframes floatUp {
  0% { opacity: 1; top: 30%; transform: translateX(-50%) scale(1); }
  30% { transform: translateX(-50%) scale(1.3); }
  100% { opacity: 0; top: -10%; transform: translateX(-50%) scale(0.8); }
}

/* ====== 结果界面 ====== */
.result-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}

.result-overlay.result-win {
  background: rgba(0, 50, 0, 0.9);
}

.result-overlay.result-lose {
  background: rgba(50, 0, 0, 0.9);
}

#result-title {
  font-size: 2.5em;
  margin-bottom: 20px;
}

#result-details {
  font-size: 1.1em;
  line-height: 2;
  color: #ccc;
  margin-bottom: 30px;
}

.result-buttons {
  display: flex;
  gap: 15px;
}

/* ====== 响应式 ====== */
@media (max-width: 600px) {
  .ally-area, .enemy-area {
    flex-wrap: wrap;
    gap: 8px;
  }
  .character-card {
    min-width: 140px;
    padding: 8px;
  }
  .skill-btn {
    min-width: 65px;
    padding: 6px 8px;
  }
  .main-menu h1 {
    font-size: 2em;
  }
}

/* ====== 模式选择 ====== */
.mode-select {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  padding: 20px;
  text-align: center;
}

.mode-select h2 {
  font-size: 2em;
  color: #ffd700;
  margin-bottom: 30px;
}

.mode-options {
  display: flex;
  gap: 20px;
  max-width: 700px;
  width: 100%;
}

.mode-card {
  flex: 1;
  background: rgba(30, 30, 50, 0.8);
  border: 2px solid #333;
  border-radius: 15px;
  padding: 25px 20px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
}

.mode-card:hover {
  border-color: #e94560;
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(233, 69, 96, 0.3);
}

.mode-icon {
  font-size: 3em;
  margin-bottom: 10px;
}

.mode-card h3 {
  color: #fff;
  font-size: 1.3em;
  margin-bottom: 10px;
}

.mode-card p {
  color: #aaa;
  font-size: 0.9em;
  line-height: 1.5;
}

.mode-tag {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8em;
  color: #ffd700;
  border: 1px solid #ffd700;
}

/* ====== ATB 战斗界面 ====== */
.atb-battle-screen {
  display: none;
  max-width: 850px;
  margin: 0 auto;
  padding: 10px;
  min-height: 100vh;
  background: linear-gradient(180deg, #0a0a15 0%, #1a1a2e 30%, #16213e 100%);
}

.atb-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 15px;
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
  margin-bottom: 8px;
  color: #aaa;
  font-size: 0.95em;
}

.atb-mode-label {
  color: #f39c12;
  font-weight: bold;
}

.atb-divider {
  text-align: center;
  color: #555;
  padding: 5px;
  font-size: 0.9em;
}

/* ATB 角色卡片 */
.atb-enemy-area,
.atb-ally-area {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 8px;
  flex-wrap: wrap;
}

.atb-char-card {
  background: rgba(30, 30, 50, 0.8);
  border: 2px solid #333;
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 170px;
  text-align: center;
  position: relative;
  transition: all 0.2s;
}

.atb-char-card.dead {
  opacity: 0.4;
  filter: grayscale(0.8);
}

.atb-char-card.targetable {
  border-color: #2ecc71;
  cursor: pointer;
  animation: targetPulse 1s infinite;
}

.atb-char-card.targetable:hover {
  background: rgba(46, 204, 113, 0.15);
  transform: translateY(-3px);
}

.atb-char-icon {
  font-size: 1.8em;
  margin-bottom: 2px;
}

.atb-char-name {
  font-size: 0.85em;
  color: #ddd;
  margin-bottom: 4px;
}

/* ATB 血条 */
.atb-hp-bar-wrap {
  width: 100%;
  height: 14px;
  background: #333;
  border-radius: 7px;
  overflow: hidden;
  position: relative;
  margin-bottom: 2px;
}

.atb-hp-bar {
  height: 100%;
  border-radius: 7px;
  transition: width 0.3s;
}

.atb-hp-bar.danger {
  animation: hpDanger 0.6s infinite;
}

.atb-shield-bar {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  background: rgba(52, 152, 219, 0.6);
  border-radius: 7px;
  transition: width 0.3s;
}

.atb-hp-text {
  font-size: 0.75em;
  color: #aaa;
  margin-bottom: 3px;
}

/* ATB 行动条 */
.atb-bar-wrap {
  width: 100%;
  height: 8px;
  background: #222;
  border-radius: 4px;
  overflow: hidden;
  margin: 2px 0;
}

.atb-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.1s linear;
}

.atb-bar.ally-atb {
  background: linear-gradient(90deg, #27ae60, #2ecc71);
}

.atb-bar.enemy-atb {
  background: linear-gradient(90deg, #c0392b, #e74c3c);
}

.atb-bar.atb-fill {
  background: linear-gradient(90deg, #f39c12, #f1c40f);
}

/* 读条 */
.cast-bar-wrap {
  width: 100%;
  height: 10px;
  background: #222;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
  margin-top: 3px;
}

.cast-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 0.1s linear;
}

.cast-bar.ally-cast {
  background: linear-gradient(90deg, #3498db, #2ecc71);
}

.cast-bar.enemy-cast {
  background: linear-gradient(90deg, #e74c3c, #f39c12);
  animation: castBarPulse 0.5s infinite;
}

@keyframes castBarPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.cast-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.65em;
  color: #fff;
  text-shadow: 0 0 3px #000;
  white-space: nowrap;
}

.recovery-indicator {
  font-size: 0.7em;
  color: #666;
  margin-top: 2px;
}

/* 玩家面板 */
.atb-player-panel {
  background: rgba(20, 20, 40, 0.8);
  border: 2px solid #f39c12;
  border-radius: 10px;
  padding: 10px 15px;
  margin: 8px 0;
}

.atb-player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.atb-player-label {
  font-size: 1.05em;
  color: #ffd700;
}

.atb-player-state {
  font-size: 0.85em;
  padding: 2px 10px;
  border-radius: 10px;
}

.atb-player-state.filling { color: #888; }
.atb-player-state.ready {
  color: #2ecc71;
  background: rgba(46, 204, 113, 0.2);
  animation: readyPulse 0.8s infinite;
}
.atb-player-state.casting { color: #3498db; }
.atb-player-state.recovering { color: #888; }

@keyframes readyPulse {
  0%, 100% { box-shadow: 0 0 5px rgba(46, 204, 113, 0.3); }
  50% { box-shadow: 0 0 15px rgba(46, 204, 113, 0.6); }
}

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

.atb-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-label {
  font-size: 0.8em;
  color: #888;
  min-width: 28px;
}

.atb-bar-container {
  background: #222;
}

/* 玩家读条大条 */
.atb-player-cast {
  margin-top: 6px;
  height: 18px;
  background: #222;
  border-radius: 9px;
  overflow: hidden;
  position: relative;
}

.atb-player-cast .cast-fill {
  height: 100%;
  background: linear-gradient(90deg, #3498db, #2ecc71);
  border-radius: 9px;
  transition: width 0.1s linear;
}

.atb-player-cast .cast-text {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.8em;
  color: #fff;
  text-shadow: 0 0 4px #000;
}

.atb-cancel-btn {
  margin-top: 5px;
  padding: 4px 16px;
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.2s;
}

.atb-cancel-btn:hover {
  background: #e74c3c;
}

/* ATB 技能栏 */
.atb-skill-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  margin-bottom: 8px;
  justify-content: center;
}

.atb-skill-btn {
  background: #252540;
  border: 2px solid #444;
  color: #eee;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 75px;
  font-size: 0.8em;
}

.atb-skill-btn:hover:not(.disabled) {
  border-color: #e94560;
  background: #302550;
  transform: translateY(-2px);
}

.atb-skill-btn.selected {
  border-color: #ffd700;
  background: #3a3020;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.atb-skill-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.atb-skill-btn .skill-icon { font-size: 1.2em; }
.atb-skill-btn .skill-name { font-weight: bold; margin: 1px 0; }
.atb-skill-btn .skill-meta { font-size: 0.7em; color: #6688cc; }
.atb-skill-btn .skill-timing { font-size: 0.65em; color: #888; }

/* 准备界面额外样式 */
.skill-option .skill-timing {
  display: block;
  color: #999;
  font-size: 0.75em;
  margin-top: 2px;
}

@media (max-width: 600px) {
  .mode-options {
    flex-direction: column;
  }
  .atb-char-card {
    min-width: 140px;
    padding: 6px 8px;
  }
}
