/* ==========================================================================
   シンクロ将棋 (SyncShogi) - 将棋盤・駒・駒台スタイル
   ========================================================================== */

/* 対局エリア全体レイアウト */
.game-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  gap: 12px;
  position: relative;
}

/* PC横並び用ラッパー */
.game-board-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 540px;
  position: relative;
}

@media (min-width: 900px) {
  .game-layout {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 32px;
  }

  .game-board-wrapper {
    max-width: 580px;
  }
}

/* 持ち駒台エリア（相手側 / 自分側） */
.stand-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: border-color var(--transition-normal);
}

.stand-container.active-turn {
  border-color: var(--color-gold);
  box-shadow: 0 0 16px rgba(229, 185, 92, 0.2);
}

.stand-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stand-player-badge {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-gold);
  border: 1px solid rgba(229, 185, 92, 0.3);
}

.stand-player-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* 駒台の駒リスト */
.stand-pieces {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 44px;
}

.stand-piece-item {
  position: relative;
  width: 40px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

.stand-piece-item:hover {
  transform: translateY(-2px);
  border-color: var(--color-gold);
  background: rgba(229, 185, 92, 0.1);
}

.stand-piece-item.selected {
  transform: translateY(-4px) scale(1.05);
  border-color: var(--color-vermilion);
  background: rgba(230, 83, 73, 0.15);
  box-shadow: 0 0 12px var(--color-vermilion-glow);
}

.stand-piece-item img {
  width: 32px;
  height: 35px;
  object-fit: contain;
  pointer-events: none;
}

.stand-piece-count {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--color-vermilion);
  color: #fff;
  font-family: var(--font-en);
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   9×9 将棋盤
   ========================================================================== */
.shogi-board-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 540px;
  max-height: 540px;
  padding: 10px;
  background: var(--board-border);
  background-image: 
    linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 50% 50%, #9e692f 0%, #683e13 100%);
  border-radius: var(--radius-md);
  box-shadow: var(--board-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-smooth);
}

.shogi-board-surface {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background: var(--board-wood-gradient);
  border: 1.5px solid var(--board-line);
  box-shadow: inset 0 0 12px rgba(40, 20, 5, 0.35);
  border-radius: 4px;
  overflow: hidden;
}

/* 星（盤上の4つの目印） */
/*
.shogi-board-surface::before,
.shogi-board-surface::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--board-star);
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}
*/

/* マス目 */
.board-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--board-line);
  border-bottom: 1px solid var(--board-line);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.board-cell:nth-child(9n) {
  border-right: none;
}

.board-cell:nth-child(n + 73) {
  border-bottom: none;
}

/* ハイライト表示 */
.board-cell:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

/* 駒選択中マス */
.board-cell.selected {
  background-color: rgba(230, 83, 73, 0.35) !important;
  box-shadow: inset 0 0 10px rgba(230, 83, 73, 0.6);
}

/* 移動可能マス */
.board-cell.valid-move::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: rgba(46, 196, 182, 0.7);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(46, 196, 182, 0.8);
  pointer-events: none;
  animation: pulseMove 1.5s infinite;
}

/* 敵駒を取れるマス */
.board-cell.valid-capture {
  background-color: rgba(230, 83, 73, 0.28) !important;
}

.board-cell.valid-capture::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 2px dashed rgba(230, 83, 73, 0.8);
  border-radius: 4px;
  pointer-events: none;
}

/* 前回着手位置ハイライト */
.board-cell.last-move {
  background-color: rgba(229, 185, 92, 0.25);
}

/* 仮決定（ステージング）中の移動元マス */
.board-cell.staged-from {
  background-color: rgba(229, 185, 92, 0.3) !important;
  box-shadow: inset 0 0 12px rgba(229, 185, 92, 0.8);
}

.board-cell.staged-from::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 2px dashed var(--color-gold);
  border-radius: 4px;
  pointer-events: none;
  animation: pulseMove 2s infinite;
}

/* 仮決定（ステージング）中の移動先マス */
.board-cell.staged-to {
  background-color: rgba(46, 196, 182, 0.25) !important;
  box-shadow: inset 0 0 12px rgba(46, 196, 182, 0.7);
}

.board-cell.staged-to::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 2px solid var(--color-jade);
  border-radius: 4px;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(46, 196, 182, 0.5);
}

/* 移動先マスに表示する半透明プレビュー駒 */
.staged-preview-piece {
  position: absolute;
  width: 86%;
  height: 86%;
  object-fit: contain;
  opacity: 0.78;
  filter: drop-shadow(0 0 8px rgba(46, 196, 182, 0.6)) brightness(1.15);
  pointer-events: none;
  z-index: 10;
  animation: floatPreview 2s ease-in-out infinite alternate;
}

@keyframes floatPreview {
  0% { transform: translateY(0) scale(0.96); }
  100% { transform: translateY(-3px) scale(1.02); }
}

@keyframes pulseMove {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
}

/* 盤上の駒画像 */
.board-piece {
  width: 86%;
  height: 86%;
  object-fit: contain;
  pointer-events: none;
  transition: transform var(--transition-fast);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.board-cell:hover .board-piece {
  transform: scale(1.06);
}

/* ソロプレイ時の盤面180度反転トランジション用アニメーション */
.flip-transition {
  animation: boardFlip 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes boardFlip {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(90deg) scale(0.92); opacity: 0.7; }
  100% { transform: rotate(180deg) scale(1); opacity: 1; }
}
