body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #111217;
  color: #fff;
  margin: 0;
  padding: 20px;
  overflow-x: hidden;
}
h1 {
  color: #f1c40f;
  text-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
  margin-bottom: 5px;
}

/* 🎛️ 난이도 및 컨트롤 UI */
#controls {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1e272e;
  padding: 8px 18px;
  border-radius: 20px;
  border: 1px solid #34495e;
  flex-wrap: wrap;
  justify-content: center;
}
#controls label {
  font-weight: bold;
  color: #f1c40f;
}
#difficulty-select {
  background: #2c3e50;
  color: #fff;
  border: 1px solid #f1c40f;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  outline: none;
}
.btn-action {
  background: #34495e;
  color: #f1c40f;
  border: 1px solid #f1c40f;
  padding: 5px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-action:hover {
  background: #f1c40f;
  color: #111217;
}

#status {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 15px;
  color: #bdc3c7;
  min-height: 28px;
  text-align: center;
}
#board-wrapper {
  position: relative;
  padding: 10px;
  background: linear-gradient(135deg, #1e272e, #0f141c);
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
}
#board {
  display: grid;
  grid-template-columns: repeat(8, 70px);
  grid-template-rows: repeat(8, 70px);
  border: 6px solid #2c3e50;
  border-radius: 8px;
  position: relative;
  background-color: #2c3e50;
}

/* 💥 보드 흔들림 이펙트 */
.shake-board {
  animation: board-hit 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes board-hit {
  10%,
  90% {
    transform: translate3d(-2px, -1px, 0);
  }
  20%,
  80% {
    transform: translate3d(3px, 2px, 0);
  }
  30%,
  50%,
  70% {
    transform: translate3d(-5px, -3px, 0);
  }
  40%,
  60% {
    transform: translate3d(5px, 4px, 0);
  }
}

.square {
  width: 70px;
  height: 70px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 45px;
  cursor: pointer;
  user-select: none;
  transition:
    background-color 0.2s,
    transform 0.1s;
  position: relative;
  box-sizing: border-box;
}
.white-sq {
  background-color: #eadeca;
}
.black-sq {
  background-color: #769656;
}

/* 🌟 기물 선택 시 아우라 효과 */
.selected {
  background-color: #baca44 !important;
  box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.6);
}
.selected span {
  animation: pulse-aura 1s infinite ease-in-out;
}
@keyframes pulse-aura {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.5));
  }
  50% {
    transform: scale(1.08);
    filter: drop-shadow(0 0 12px #f1c40f);
  }
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.5));
  }
}

/* 📍 마지막 이동 경로 하이라이트 */
.last-move-src {
  background-color: rgba(241, 196, 15, 0.35) !important;
}
.last-move-dst {
  background-color: rgba(241, 196, 15, 0.55) !important;
  box-shadow: inset 0 0 0 3px #f1c40f;
}

.suggested {
  position: relative;
}
.suggested::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  background-color: rgba(241, 196, 15, 0.6);
  border-radius: 50%;
  box-shadow: 0 0 8px #f1c40f;
  animation: pulse-dot 1.2s infinite;
  pointer-events: none;
}
@keyframes pulse-dot {
  0%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* 🚀 일반 기물 이동 대시 애니메이션 */
.move-dash {
  animation: dash-in 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes dash-in {
  0% {
    transform: scale(0.4) cubic-bezier(0.6, -0.28, 0.735, 0.045);
    filter: blur(4px);
    opacity: 0.5;
  }
  100% {
    transform: scale(1);
    filter: blur(0);
    opacity: 1;
  }
}

/* ✨ 타격 스파크 이펙트 */
.spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #ff9f43;
  pointer-events: none;
  z-index: 999;
  animation: spark-fly 0.4s ease-out forwards;
}
@keyframes spark-fly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}

/* 🔥 킹 처치 시 폭발 연출 CSS 애니메이션 */
.king-explosion {
  animation:
    shake 0.4s infinite,
    explode 1s forwards 0.4s;
  color: #ff3333 !important;
  background-color: #2c0000 !important;
  text-shadow:
    0 0 30px #ff0000,
    0 0 60px #ff5555 !important;
  z-index: 9999;
  pointer-events: none;
}

@keyframes shake {
  0% {
    transform: translate(2px, 1px) rotate(0deg);
  }
  10% {
    transform: translate(-1px, -2px) rotate(-2deg);
  }
  20% {
    transform: translate(-3px, 0px) rotate(3deg);
  }
  30% {
    transform: translate(0px, 2px) rotate(0deg);
  }
  40% {
    transform: translate(1px, -1px) rotate(1deg);
  }
  50% {
    transform: translate(-1px, 2px) rotate(-1deg);
  }
  60% {
    transform: translate(-3px, 1px) rotate(0deg);
  }
  70% {
    transform: translate(2px, 1px) rotate(-2deg);
  }
  80% {
    transform: translate(-1px, -1px) rotate(3deg);
  }
  100% {
    transform: translate(1px, -2px) rotate(-1deg);
  }
}

@keyframes explode {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: hue-rotate(0deg);
  }
  50% {
    transform: scale(2.5) rotate(180deg);
    opacity: 0.8;
    filter: blur(2px) hue-rotate(90deg);
  }
  100% {
    transform: scale(0) rotate(360deg);
    opacity: 0;
    filter: blur(20px);
  }
}

/* 🎬 결과 화면 오버레이 모달 */
#result-modal,
#promotion-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 5, 10, 0.9);
  backdrop-filter: blur(10px);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.4s ease;
}
#result-modal.show,
#promotion-modal.show {
  display: flex;
  opacity: 1;
}
.modal-content {
  text-align: center;
  transform: scale(0.6);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#result-modal.show .modal-content,
#promotion-modal.show .modal-content {
  transform: scale(1);
}

.modal-title {
  font-size: 4.5rem;
  font-weight: 900;
  margin-bottom: 10px;
  letter-spacing: 3px;
}
.win-title {
  color: #f1c40f;
  text-shadow: 0 0 40px rgba(241, 196, 15, 0.7);
}
.lose-title {
  color: #e74c3c;
  text-shadow: 0 0 40px rgba(231, 76, 60, 0.7);
}
.draw-title {
  color: #3498db;
  text-shadow: 0 0 40px rgba(52, 152, 219, 0.7);
}
.modal-desc {
  font-size: 1.4rem;
  color: #a6b1b9;
  margin-bottom: 30px;
}

.restart-btn {
  background: linear-gradient(135deg, #f1c40f, #f39c12);
  color: #111217;
  border: none;
  padding: 15px 45px;
  font-size: 1.2rem;
  font-weight: bold;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(241, 196, 15, 0.3);
  transition: all 0.2s;
}
.restart-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 25px rgba(241, 196, 15, 0.5);
}

/* 👑 승급 셀렉터 UI */
.promo-options {
  display: flex;
  gap: 20px;
  margin-top: 20px;
}
.promo-btn {
  background: #2c3e50;
  border: 2px solid #f1c40f;
  border-radius: 12px;
  font-size: 3.5rem;
  width: 80px;
  height: 80px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
  text-shadow: 0 0 4px #000;
}
.promo-btn:hover {
  background: #f1c40f;
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(241, 196, 15, 0.4);
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confetti-fall 3.5s linear infinite;
  top: -10px;
  z-index: 10001;
}
@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}
