/* ================================================================
   4人はさみ将棋 — スタイル（ネオン系: グラデ背景・将棋駒シェイプ・グロー）
   ================================================================ */

:root {
  --c0: #3b7bff; /* 青(上) */
  --c1: #2ecc40; /* 緑(左) */
  --c2: #f5d90a; /* 黄(下) */
  --c3: #ff4136; /* 赤(右) */
  --turn-color: var(--c0);
}

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

body {
  min-height: 100vh;
  padding: 12px;
  background:
    radial-gradient(1000px 600px at 80% -10%, #2a1b5e 0%, transparent 60%),
    radial-gradient(800px 500px at -10% 110%, #0b3b52 0%, transparent 60%),
    #0d1021;
  background-attachment: fixed;
  color: #e8ecff;
  font-family: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Segoe UI', sans-serif;
}

.hidden { display: none !important; }

/* ---------------------------------------------------------------- レイアウト */
#setup { max-width: 640px; margin: 0 auto; }
.title {
  text-align: center; margin: 18px 0 4px; letter-spacing: 0.08em;
  background: linear-gradient(90deg, #6ea8ff, #b26eff, #ff6ec7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 40px;
}
.subtitle { text-align: center; font-size: 12px; color: #9aa5d8; opacity: 0.9; margin-bottom: 20px; }

.setup-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 18px 22px;
  backdrop-filter: blur(8px);
}
.setup-box h2 { font-size: 14px; margin: 18px 0 8px; opacity: 0.85; }
.player-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap;
}
.player-row input[type='text'] { width: 130px; padding: 5px 7px; }
.pos-label { width: 70px; font-size: 13px; }
.opt-rows { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }

input[type='text'],
select {
  background: rgba(0, 0, 0, 0.35); color: #e8ecff;
  border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 6px;
}
button {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
  color: #e8ecff; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 8px;
}
button:hover { border-color: #8fb3ff; box-shadow: 0 0 8px rgba(110, 168, 255, 0.5); }
button.off { opacity: 0.5; }

.big-btn {
  display: block; width: 100%; margin: 22px 0 12px; padding: 12px;
  font-size: 18px; cursor: pointer; letter-spacing: 0.2em;
  background: linear-gradient(90deg, #4c6fff, #9b4cff);
  border: none; border-radius: 10px; color: #fff;
  box-shadow: 0 4px 24px rgba(110, 100, 255, 0.5);
}
.rules { font-size: 12px; margin-top: 10px; }
.rules summary { cursor: pointer; margin-bottom: 6px; }
.rules li { margin: 4px 0 4px 18px; }

.chip {
  width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none;
}
.chip.p0 { background: var(--c0); }
.chip.p1 { background: var(--c1); }
.chip.p2 { background: var(--c2); }
.chip.p3 { background: var(--c3); }

#gameHeader {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.title-mini { font-weight: bold; letter-spacing: 0.06em; }
.controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.controls button { padding: 5px 10px; cursor: pointer; font-size: 12px; }
.speed-label { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.speed-label input { width: 80px; }

#gameMain { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

/* ---------------------------------------------------------------- 盤とコマ */
#boardWrap { position: relative; }
#board {
  --size: 12;
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  width: min(92vw, 76vh, 640px);
  aspect-ratio: 1;
  position: relative;
  border: 4px solid var(--turn-color);
  border-radius: 10px;
  box-shadow: 0 0 26px var(--turn-color), inset 0 0 40px rgba(0, 0, 0, 0.6);
  background: linear-gradient(135deg, #171a33 0%, #10132a 100%);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.cell { position: relative; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06); }
.cell.odd { background: rgba(255, 255, 255, 0.025); }

/* コマ: 将棋駒シェイプ。先端が敵陣（盤中央）を向く */
.piece { position: absolute; inset: 9%; filter: drop-shadow(0 0 5px currentColor); }
.piece.p0 { color: var(--c0); clip-path: polygon(50% 96%, 84% 72%, 76% 4%, 24% 4%, 16% 72%); }
.piece.p1 { color: var(--c1); clip-path: polygon(96% 50%, 72% 84%, 4% 76%, 4% 24%, 72% 16%); }
.piece.p2 { color: var(--c2); clip-path: polygon(50% 4%, 84% 28%, 76% 96%, 24% 96%, 16% 28%); }
.piece.p3 { color: var(--c3); clip-path: polygon(4% 50%, 28% 16%, 96% 24%, 96% 76%, 28% 84%); }
.piece.p0,
.piece.p1,
.piece.p2,
.piece.p3 {
  background: linear-gradient(160deg, currentColor 0%, currentColor 55%, rgba(0, 0, 0, 0.55) 140%);
}
.piece.ghost {
  position: absolute; top: 0; left: 0; inset: auto; z-index: 30; pointer-events: none;
}
.piece.dead { filter: grayscale(0.8) brightness(0.6); }

/* 手番・移動先ハイライト */
.cell.dest::after {
  content: ''; position: absolute; inset: 36%; border-radius: 50%;
  background: rgba(140, 190, 255, 0.75);
  box-shadow: 0 0 8px #8fb3ff;
}
.cell.dest.cap::after {
  inset: 24%; background: transparent; border: 3px solid #ff5f8f;
  box-shadow: 0 0 10px #ff5f8f;
  animation: pulse 0.8s infinite alternate;
}
@keyframes pulse { from { opacity: 0.5; } to { opacity: 1; } }

.cell.sel .piece { animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { filter: brightness(2.2); } }

.cell.last-to { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35); }

.cell.boom { animation: boom 0.5s; }
@keyframes boom {
  0% { background-color: #fff; }
  100% { background-color: transparent; }
}

/* ---------------------------------------------------------------- サイドパネル */
#side { display: flex; flex-direction: column; gap: 10px; width: 280px; max-width: 92vw; }
.pcard {
  display: flex; align-items: center; gap: 7px; padding: 7px 9px; font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
.pcard .pname { font-weight: bold; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .ptype { opacity: 0.7; font-size: 10px; white-space: nowrap; }
.pcard .pstat { margin-left: auto; white-space: nowrap; }
.pcard .pmark { width: 44px; text-align: right; font-size: 11px; white-space: nowrap; }
.pcard .team { font-size: 10px; opacity: 0.8; }
.pcard.turn {
  border-color: var(--turn-color);
  box-shadow: 0 0 12px var(--turn-color);
}
.pcard.dead { opacity: 0.45; }

#log {
  height: 220px; overflow-y: auto; padding: 8px; font-size: 11px; line-height: 1.7;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #b9c3ef;
}

/* ---------------------------------------------------------------- 勝敗バナー */
#banner {
  position: absolute; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 10px; backdrop-filter: blur(4px);
}
#banner .game-end { font-size: 20px; letter-spacing: 0.1em; margin-bottom: 8px; color: #8fb3ff; }
#banner .winner {
  font-size: 30px; font-weight: bold;
  background: linear-gradient(90deg, #6ea8ff, #ff6ec7);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.banner-btns { display: flex; gap: 10px; }
.banner-btns button { padding: 8px 16px; cursor: pointer; }

/* モバイル */
@media (max-width: 720px) {
  #side { width: 100%; }
  #log { height: 120px; }
}
