/* 공통 */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
  overflow: hidden;
}

.main {
  width: 800px;
  padding: 20px;
  max-height: 100vh;
  overflow: hidden;
}

/* 선택 화면 */
.unitSelect {
  display: none;
  text-align: center;
}
.unitSelect.active {
  display: block;
}

.title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 15px;
}

/* 카드 컨테이너 */
.unit {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 15px;
}

/* 카드 */
.unitCard {
  background: #333;
  border: 2px solid #555;
  border-radius: 12px;
  width: 160px;
  cursor: pointer;
  padding: 10px;
  transition: transform 0.25s ease, box-shadow 0.25s ease,
    border-color 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.unitCard:hover {
  transform: scale(1.08);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

.unitCard picture {
  display: block;
  width: 100px;
  height: 100px;
  margin-bottom: 10px;
  border-radius: 8px;
  overflow: hidden;
  background-color: #666;
}
.unitCard img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 상태창 */
.unitStatus {
  background: #222;
  padding: 8px 10px;
  border-radius: 5px;
  width: 100%;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
  transition: background 0.2s, box-shadow 0.2s;
}

.unitStatus .status {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.unitStatus .status span:first-child {
  color: #aaa;
  font-weight: 500;
}

.unitStatus .status span:last-child {
  color: #fff;
  font-weight: bold;
}

/* 카드 호버 시 상태창 강조 */
.unitCard:hover .unitStatus {
  background: #333;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

/* 주요 수치 강조 */
.status span:last-child.hp {
  color: #f55;
}
.status span:last-child.atk {
  color: #ffb74d;
}
.status span:last-child.def {
  color: #4db6ac;
}
.status span:last-child.acc {
  color: #ffeb3b;
}
.status span:last-child.eva {
  color: #81c784;
}

/* 배틀 화면 */
.battleScreen {
  display: none;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  padding: 10px 20px;
  box-sizing: border-box;
}

.battleContent {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 90%;
  max-height: 90vh;
}

.battleScreen.active {
  display: flex;
}

.battleField {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  height: 40vh;
  max-height: 300px;
  margin-bottom: 15px;
  position: relative;
  background: rgba(30, 30, 30, 0.8);
  border-radius: 16px;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
  padding: 20px;
}

/* 버튼 + 로그 영역 */
.controls {
  display: flex;
  flex-direction: column;
  gap: 25px;
  width: 100%;
  align-items: center;
}

.heroArea,
.monsterArea {
  background: #222;
  padding: 10px;
  border-radius: 12px;
  width: 160px;
  text-align: center;
  position: relative;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
  transition: box-shadow 0.3s;
}
.heroArea:hover,
.monsterArea:hover {
  box-shadow: 0 0 25px rgba(59, 130, 246, 0.6);
}

.heroArea img,
.monsterArea img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 10px;
}

.hpBarContainer {
  background: #555;
  width: 100%;
  height: 16px;
  border-radius: 8px;
  margin: 5px 0;
  overflow: hidden;
}

.hpBar {
  height: 100%;
  width: 100%;
  border-radius: 8px;
  background: red;
  transition: width 0.3s ease;
}

/* 가위바위보 버튼 영역 */
.rpsButtons {
  display: flex;
  justify-content: center;
  gap: 20px;
}

/* 버튼 */
.rpsButtons button {
  padding: 12px 24px;
  font-size: 18px;
  border: none;
  border-radius: 12px;
  background: #3b82f6;
  color: white;
  cursor: pointer;
  transition: 0.2s;
}
.rpsButtons button:hover {
  background: #2563eb;
}

/* 로그 */
.battleLog {
  width: 90%;
  max-height: 200px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 16px;
  border-radius: 12px;
  overflow-y: auto;
  padding: 12px;
  line-height: 1.6;
  font-family: "Courier New", monospace;
  word-break: break-word;
  box-shadow: 0 0 10px rgba(0, 0, 255, 0.3);
}

/* 로그 종류별 색상 */
.battleLog div {
  margin-bottom: 6px;
}
.playerAttack {
  color: #4db6ac;
}
.monsterAttack {
  color: #ff7043;
}
.miss {
  color: #ffeb3b;
  font-style: italic;
}
.critical {
  color: #f44336;
  font-weight: bold;
}

.logBlock {
  background: rgba(50, 50, 50, 0.6);
  border-left: 4px solid #3b82f6;
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  line-height: 1.4;
  font-size: 14px;
  transition: background 0.2s;
}
.logBlock strong {
  display: block;
  margin-bottom: 4px;
  color: #ffd54f;
}
.logBlock .playerAttack {
  color: #76ff03;
}
.logBlock .monsterAttack {
  color: #00e5ff;
}
.logBlock .miss {
  color: #ffeb3b;
}
.logBlock .critical {
  color: #f44336;
}
.logBlock:hover {
  background: rgba(70, 70, 70, 0.8);
}

/* damageText */
.damageText {
  position: absolute;
  color: #ff4d4d;
  font-weight: bold;
  font-size: 20px;
  animation: floatUp 0.8s ease-out forwards;
  text-shadow: 1px 1px 4px black;
}
@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-30px);
  }
}

/* 공격/피격/회피 */
.attackAni {
  animation: shake 0.3s;
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(10px);
  }
}
.hitAni {
  animation: flash 0.2s;
}
@keyframes flash {
  0% {
    filter: brightness(2);
  }
  100% {
    filter: brightness(1);
  }
}
.missAni {
  transform: translateX(15px);
  transition: transform 0.3s;
}

/* 게임 종료 시 */
.endContainer {
  text-align: center;
  margin-top: 30px;
  padding: 25px;
  background: #2a2a2a;
  border: 2px solid #b8860b;
  border-radius: 16px;
  box-shadow: 0 0 10px rgba(184, 134, 11, 0.4);
}
.endMessage {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 15px;
  letter-spacing: 1px;
}
.endMessage.win {
  color: #4caf50;
  font-size: 20px;
  font-weight: bold;
}
.endMessage.lose {
  color: #f44336;
  font-size: 20px;
  font-weight: bold;
  text-shadow: 1px 1px 5px black;
}
.restart-btn {
  margin-top: 12px;
  background-color: #2196f3;
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
}
.restart-btn:hover {
  background-color: #1565c0;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
}
@keyframes fadeInEnd {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 배경 */
.background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  background: #0d0d0d;
}
.stars {
  position: absolute;
  width: 100%;
  height: 100%;
}
.stars::before {
  content: "";
  position: absolute;
  width: 2px;
  height: 2px;
  background: white;
  border-radius: 50%;
  box-shadow: 50px 80px white, 120px 200px white, 300px 150px white,
    500px 400px white, 800px 50px white, 700px 300px white;
  animation: twinkle 2s infinite alternate;
}
@keyframes twinkle {
  from {
    opacity: 0.2;
  }
  to {
    opacity: 1;
  }
}
.dust {
  position: absolute;
  width: 100%;
  height: 100%;
}
.dust::before {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  box-shadow: 100px 100px rgba(255, 255, 255, 0.15),
    200px 300px rgba(255, 255, 255, 0.15), 400px 150px rgba(255, 255, 255, 0.15),
    600px 250px rgba(255, 255, 255, 0.15), 750px 350px rgba(255, 255, 255, 0.15);
  animation: float 10s linear infinite;
}
@keyframes float {
  0% {
    transform: translateY(0) translateX(0);
  }
  100% {
    transform: translateY(-300px) translateX(50px);
  }
}
