/* 장기 공통 */
.janggi-page {
  background: #f7f7f5;
  min-height: 100vh;
}

.janggi-hero {
  background: linear-gradient(135deg, #2f4a28 0%, #5a3714 55%, #7a2e24 100%);
  color: #fff;
  padding: 3.5rem 0 4rem;
  text-align: center;
}

.janggi-hero h1 {
  font-size: 2.4rem;
  font-weight: 900;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}

.janggi-hero p {
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.82);
  max-width: 640px;
  margin: 0 auto 1.5rem;
}

.janggi-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.janggi-section {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

/* 연습/게임 오른쪽 카드 간격 */
.janggi-page .col-lg-4 > .janggi-section + .janggi-section,
.janggi-page .col-lg-3 > .janggi-section + .janggi-section {
  margin-top: 1.5rem;
}

.janggi-section h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 1rem;
}

.janggi-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
}

.janggi-info-card {
  border: 1px solid #e8e8e6;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  text-align: center;
}

.janggi-info-card strong {
  display: block;
  font-size: 0.78rem;
  color: #666;
  margin-bottom: 0.25rem;
}

.janggi-info-card span {
  font-weight: 800;
  font-size: 1.05rem;
}

.janggi-piece-info {
  border: 1px solid #ececea;
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  height: 100%;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.janggi-piece-info:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.06);
}

.janggi-piece-info i {
  display: block;
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: #4a4a4a;
}

.janggi-piece-info strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.janggi-piece-info span {
  font-size: 0.82rem;
  color: #666;
}
.janggi-piece-guide-card{display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:.25rem;padding:1.2rem!important;background:linear-gradient(155deg,#fffdf8,#f2e8d7);border-color:#b68a4f55!important}.janggi-piece-guide-images{display:flex;justify-content:center;align-items:center;gap:.45rem;min-height:76px;margin-bottom:.35rem}.janggi-piece-guide-images img{width:64px;height:64px;object-fit:contain;filter:drop-shadow(0 5px 5px rgba(35,21,8,.3));transition:transform .18s}.janggi-piece-guide-card:hover img:first-child{transform:translateX(-3px) rotate(-4deg)}.janggi-piece-guide-card:hover img:last-child{transform:translateX(3px) rotate(4deg)}

.janggi-rule-list {
  padding-left: 1.2rem;
}

.janggi-rule-list li {
  margin-bottom: 0.6rem;
  line-height: 1.55;
}

.janggi-mini-board-demo {
  max-width: 360px;
  margin: 0 auto;
}

/* 보드 — 교차점 정렬 */
.janggi-board-wrap,
.janggi-mini-board-demo {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}

.janggi-board {
  width: 100%;
  user-select: none;
}

.janggi-board-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 10;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 35%),
    repeating-linear-gradient(
      90deg,
      rgba(90, 55, 20, 0.03) 0 2px,
      transparent 2px 6px
    ),
    #e2c089;
  border: 3px solid #5a3714;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(90, 55, 20, 0.2);
  padding: 7.2%;
}

.janggi-board-play {
  position: relative;
  width: 100%;
  height: 100%;
}

.janggi-grid-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.janggi-points {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.janggi-point {
  position: absolute;
  width: 12.5%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  z-index: 1;
}
.janggi-board:not(.is-interactive) .janggi-point {
  cursor: default;
}

.janggi-point:focus-visible {
  outline: 2px solid rgba(30, 77, 156, 0.55);
  outline-offset: 2px;
  border-radius: 50%;
}

.janggi-point.is-selected::before {
  content: '';
  position: absolute;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  background: rgba(40, 110, 60, 0.22);
  z-index: 0;
  pointer-events: none;
}

/* 마지막 수: 출발점은 은은한 표시, 도착한 말은 테두리 깜빡임 */
.janggi-point.is-last:not(.has-piece)::before {
  content: '';
  position: absolute;
  width: 56%;
  height: 56%;
  border-radius: 50%;
  background: rgba(212, 146, 10, 0.22);
  z-index: 0;
  pointer-events: none;
}

.janggi-point.is-last.has-piece::after {
  content: '';
  position: absolute;
  width: 96%;
  height: 96%;
  border-radius: 22%;
  background: transparent !important;
  border: 2.5px solid #d4920a;
  box-shadow: 0 0 0 1px rgba(212, 146, 10, 0.25);
  animation: janggi-last-blink 1.05s ease-in-out infinite;
  z-index: 3;
  pointer-events: none;
}

@keyframes janggi-last-blink {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    border-color: #d4920a;
  }
  50% {
    opacity: 0.2;
    transform: scale(1.06);
    border-color: rgba(212, 146, 10, 0.35);
  }
}

.janggi-point.is-target::after,
.janggi-point.is-capture::after {
  content: '';
  position: absolute;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: rgba(40, 110, 60, 0.5);
  z-index: 2;
  pointer-events: none;
  animation: none;
  box-shadow: none;
  border: none;
  transform: none;
}
.janggi-point.is-capture::after {
  width: 78%;
  height: 78%;
  background: transparent;
  border: 3px solid rgba(180, 40, 40, 0.55);
}

/* 합법 수 표시가 있을 때는 깜빡임 대신 수 표시 유지 */
.janggi-point.is-last.has-piece.is-target::after,
.janggi-point.is-last.has-piece.is-capture::after {
  animation: none;
}

.janggi-piece-img {
  position: relative;
  z-index: 1;
  width: 88%;
  height: auto;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.18));
}
.janggi-point .janggi-piece-img.is-king { width: 100%; }
.janggi-point .janggi-piece-img.is-major { width: 90%; }
.janggi-point .janggi-piece-img.is-minor { width: 80%; }

.janggi-side-dot {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  margin-right: 0.35rem;
}
.janggi-side-dot.is-cho { background: #1e4d9c; }
.janggi-side-dot.is-han { background: #c62828; }

.janggi-board.is-flipped .janggi-board-play {
  transform: rotate(180deg);
}
.janggi-board.is-flipped .janggi-piece-img {
  transform: rotate(180deg);
}

.janggi-piece.white { color: #fff; text-shadow: 0 0 2px rgba(0,0,0,0.5); }
.janggi-piece.black { color: #111; }

/* 런처 */
.janggi-launcher-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}

.janggi-launcher-title {
  font-size: 1.6rem;
  font-weight: 900;
  margin-bottom: 0.25rem;
}

.janggi-launcher-lead {
  color: #666;
  margin: 0;
}

.janggi-launcher-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.janggi-launcher-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.janggi-launcher-card-media {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4a4a4a, #2b2b2b);
  color: #fff;
  font-size: 2.5rem;
  position: relative;
}

.janggi-launcher-card-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255,255,255,0.18);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

.janggi-launcher-card-body {
  padding: 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.janggi-launcher-card-body h3 {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.janggi-launcher-card-body p {
  color: #666;
  font-size: 0.9rem;
  flex: 1;
}

.janggi-launcher-card-body button {
  width: 100%;
}

@media (max-width: 991px) {
  .janggi-launcher-grid { grid-template-columns: 1fr; }
}

/* 게임 화면 */
.janggi-turn-timer {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}

.janggi-turn-timer .progress { height: 12px; background: #e8e8e6; }
.janggi-turn-timer .progress-bar { transition: width 0.1s linear, background-color 0.2s ease; }

.janggi-game-stage { display: none; }
.janggi-game-stage.is-active { display: block; }

.janggi-game-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.janggi-game-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.janggi-turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #fff;
  border: 1px solid #e4e4e2;
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-weight: 700;
  font-size: 0.9rem;
}

.janggi-turn-pill .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #aaa;
  display: inline-block;
}

.janggi-turn-pill .dot.white { background: #1e4d9c; border: 2px solid #163a78; }
.janggi-turn-pill .dot.black { background: #c62828; border: 2px solid #8e1c1c; }

.janggi-game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.75rem;
  align-items: start;
}

@media (max-width: 991px) {
  .janggi-game-layout { grid-template-columns: 1fr; }
}

.janggi-board-card {
  background: #fff;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}

.janggi-side-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.janggi-side-card:last-child {
  margin-bottom: 0;
}

.janggi-side-card h4 {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.janggi-player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0f0ee;
}

.janggi-player-row:last-child { border-bottom: none; }

.janggi-player-info {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.janggi-player-info i { font-size: 1.25rem; }
.janggi-player-info i.white { color: #aaa; }
.janggi-player-info i.black { color: #222; }

.janggi-move-list {
  max-height: 220px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  background: #f9f9f8;
  border-radius: 10px;
  padding: 0.6rem;
}

.janggi-form-inline {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.janggi-code-input {
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 700;
  max-width: 160px;
}

/* 연습 오버레이 */
.janggi-practice-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  z-index: 10;
}

.janggi-practice-overlay-inner { text-align: center; }

/* 기물 설명 패널 */
.janggi-piece-desc-wrap { min-height: 160px; }

.janggi-piece-desc .piece-name {
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.janggi-piece-desc .piece-name i {
  font-size: 1.4rem;
  color: #4a4a4a;
}

.janggi-piece-desc .piece-desc {
  font-size: 0.92rem;
  color: #444;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.janggi-piece-desc .piece-move {
  font-size: 0.85rem;
  color: #666;
  padding: 0.55rem 0.75rem;
  background: #f8f8f7;
  border-radius: 10px;
  border-left: 3px solid #b58863;
}

/* 로비 */
.janggi-lobby-stage { display: none; }
.janggi-lobby-stage.is-active { display: block; }

.janggi-lobby-room-item,
.janggi-lobby-invite-item {
  padding: 0.9rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 0.6rem;
  transition: box-shadow 0.12s ease;
}

.janggi-lobby-room-item:hover,
.janggi-lobby-invite-item:hover { box-shadow: 0 6px 16px rgba(0,0,0,0.06); }

.janggi-lobby-chat-list {
  max-height: 520px;
  min-height: 220px;
  overflow-y: auto;
  background: #f8f8f7;
  border-radius: 12px;
  padding: 0.75rem;
}

.janggi-lobby-chat-item { margin-bottom: 0.7rem; max-width: 92%; }
.janggi-lobby-chat-item.is-me { margin-left: auto; text-align: right; }
.janggi-lobby-chat-meta { display: flex; align-items: center; gap: 0.45rem; font-size: 0.78rem; margin-bottom: 0.15rem; }
.janggi-lobby-chat-item.is-me .janggi-lobby-chat-meta { justify-content: flex-end; }
.janggi-lobby-chat-body {
  display: inline-block;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  color: #222;
  word-break: break-word;
}
.janggi-lobby-chat-item.is-me .janggi-lobby-chat-body { background: #4a4a4a; color: #fff; border-color: #4a4a4a; }

/* 관전 */
.janggi-spectate-status {
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
}
.janggi-spectate-status.waiting { background: #fff3cd; color: #856404; }
.janggi-spectate-status.playing { background: #d1ecf1; color: #0c5460; }
.janggi-spectate-status.finished { background: #d4edda; color: #155724; }

/* 토스트 */
.janggi-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1a1a1a;
  color: #fff;
  padding: 0.8rem 1.25rem;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: 0 12px 32px rgba(0,0,0,0.22);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 1080;
}
.janggi-toast.is-visible { transform: translateX(-50%) translateY(0); opacity: 1; }
