/* ===== リセット ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ===== ベース ===== */
body {
  background-color: #0b0b0e;
  color: #e2e2e9;
  font-family: 'Consolas', 'Courier New', monospace, 'BIZ UD Gothic', 'Hiragino Kaku Gothic ProN', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px 16px 40px;
  /* CRT風スキャンライン */
  background-image:
    linear-gradient(rgba(0,0,0,0) 50%, rgba(0,0,0,0.18) 50%),
    linear-gradient(90deg, rgba(255,100,0,0.02), rgba(255,200,0,0.01), rgba(255,100,0,0.02));
  background-size: 100% 4px, 6px 100%;
  user-select: none;
}

.container {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== ヘッダー ===== */
header {
  text-align: center;
  padding: 16px 20px 14px;
  border: 2px double #ffb700;
  background-color: rgba(12, 10, 0, 0.9);
  box-shadow: 0 0 20px rgba(255, 183, 0, 0.12);
  border-radius: 4px;
}

h1 {
  font-size: 2rem;
  color: #ffb700;
  text-shadow: 0 0 10px rgba(255, 183, 0, 0.6);
  letter-spacing: 4px;
  font-weight: bold;
  line-height: 1;
}

.subtitle {
  font-size: 0.72rem;
  color: #665a33;
  letter-spacing: 8px;
  margin-top: 5px;
}

/* ===== ゲームエリア ===== */
.game-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ===== ステータスパネル ===== */
.status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #0f0f18;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 5px;
  border: 1px solid transparent;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  min-width: 70px;
}

.player-info.active {
  border-color: #ffb700;
  background-color: rgba(255, 183, 0, 0.07);
  box-shadow: 0 0 10px rgba(255, 183, 0, 0.15);
}

.stone-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stone-icon.black {
  background: radial-gradient(circle at 36% 34%, #888, #111 65%);
  box-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

.stone-icon.white {
  background: radial-gradient(circle at 36% 34%, #ffffff, #c8c8c8 65%);
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.player-label {
  font-size: 0.85rem;
  color: #aaa;
  letter-spacing: 1px;
  font-weight: bold;
}

.turn-display {
  text-align: center;
  font-size: 0.82rem;
  color: #ffb700;
  letter-spacing: 2px;
  text-shadow: 0 0 6px rgba(255, 183, 0, 0.5);
  white-space: nowrap;
  flex: 1;
}

/* ===== メッセージ ===== */
.message {
  text-align: center;
  padding: 10px 16px;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: bold;
  letter-spacing: 2px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}

.message-hidden {
  opacity: 0;
  border: 1px solid transparent;
  background: transparent;
  pointer-events: none;
}

.message-win {
  background-color: rgba(255, 183, 0, 0.08);
  border: 2px solid rgba(255, 183, 0, 0.5);
  color: #ffb700;
  font-size: 1.1rem;
  text-shadow: 0 0 10px rgba(255, 183, 0, 0.5);
  animation: pulseGlow 1.2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 183, 0, 0.3); }
  50% { box-shadow: 0 0 20px rgba(255, 183, 0, 0.6); }
}

/* ===== 盤面ラッパー ===== */
.board-wrap {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

/* ===== 盤面 ===== */
.board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 1px;
  background-color: #3a2500; /* gap色 = 盤線の色 */
  border: 3px solid #5a3a00;
  border-radius: 3px;
  box-shadow:
    0 0 24px rgba(255, 183, 0, 0.15),
    0 0 60px rgba(100, 60, 0, 0.1),
    inset 0 0 10px rgba(0,0,0,0.5);
  width: 100%;
  outline: 1px solid #ffb70030;
}

/* ===== マス ===== */
.cell {
  aspect-ratio: 1;
  background-color: #1a1200;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.1s;
}

.cell:hover {
  background-color: #251a06;
}

/* 星位（ hoshi ）マーク */
.cell.hoshi::before {
  content: '';
  position: absolute;
  width: 22%;
  height: 22%;
  background-color: #4a3000;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

/* 石が置かれたら星位マークを隠す */
.cell.hoshi.has-stone::before {
  display: none;
}

/* 勝利ライン強調 */
.cell.win-cell {
  background-color: rgba(255, 183, 0, 0.18);
}

/* ===== 石 ===== */
.stone {
  width: 82%;
  height: 82%;
  border-radius: 50%;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

.stone.black {
  background: radial-gradient(circle at 35% 32%, #686868, #0e0e0e 65%);
  box-shadow:
    0 2px 5px rgba(0,0,0,0.85),
    inset 0 1px 2px rgba(255,255,255,0.1);
}

.stone.white {
  background: radial-gradient(circle at 35% 32%, #ffffff, #c4c4c4 65%);
  box-shadow:
    0 2px 5px rgba(0,0,0,0.55),
    inset 0 1px 3px rgba(255,255,255,0.9);
}

/* 石を置いたときのアニメーション */
@keyframes stonePlace {
  0%   { transform: scale(0.2); opacity: 0.5; }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.stone.placing {
  animation: stonePlace 0.2s ease-out forwards;
}

/* 勝利ライン上の石を光らせる */
.win-cell .stone.black {
  box-shadow:
    0 2px 5px rgba(0,0,0,0.85),
    0 0 12px rgba(255, 183, 0, 0.7);
}

.win-cell .stone.white {
  box-shadow:
    0 2px 5px rgba(0,0,0,0.5),
    0 0 12px rgba(255, 183, 0, 0.7);
}

/* ===== コントロール ===== */
.controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: bold;
  letter-spacing: 3px;
  cursor: pointer;
  border-radius: 4px;
  text-decoration: none;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.1s;
  white-space: nowrap;
}

.btn-reset {
  background-color: transparent;
  border: 2px solid #ffb700;
  color: #ffb700;
}

.btn-reset:hover {
  background-color: rgba(255, 183, 0, 0.1);
  box-shadow: 0 0 14px rgba(255, 183, 0, 0.3);
}

.btn-reset:active {
  transform: scale(0.96);
  background-color: rgba(255, 183, 0, 0.2);
}

.btn-back {
  background-color: transparent;
  border: 2px solid #45f3ff;
  color: #45f3ff;
}

.btn-back:hover {
  background-color: rgba(69, 243, 255, 0.1);
  box-shadow: 0 0 14px rgba(69, 243, 255, 0.3);
}

.btn-back:active {
  transform: scale(0.96);
}

/* ===== CPU 思考中：盤面ロック ===== */
.board.locked {
  pointer-events: none;
  opacity: 0.88;
  transition: opacity 0.2s;
}

/* CPU 思考中の手番テキストアニメーション */
#turn-display.thinking {
  color: #45f3ff;
  animation: thinkBlink 0.9s ease-in-out infinite;
}

@keyframes thinkBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

/* ===== CPU 勝利メッセージ ===== */
.message-lose {
  background-color: rgba(255, 60, 60, 0.08);
  border: 2px solid rgba(255, 60, 60, 0.5);
  color: #ff4444;
  font-size: 1.1rem;
  text-shadow: 0 0 10px rgba(255, 60, 60, 0.5);
  animation: pulseGlow 1.2s ease-in-out infinite;
}

/* ===== 引き分けメッセージ ===== */
.message-draw {
  background-color: rgba(130, 130, 130, 0.08);
  border: 2px solid rgba(130, 130, 130, 0.4);
  color: #aaaaaa;
  font-size: 1.1rem;
}

/* ===== レスポンシブ：スマートフォン ===== */
@media (max-width: 480px) {
  body {
    padding: 12px 8px 28px;
  }

  .container {
    gap: 10px;
  }

  header {
    padding: 12px 12px 10px;
  }

  h1 {
    font-size: 1.65rem;
    letter-spacing: 2px;
  }

  .status-panel {
    padding: 8px 10px;
  }

  .player-info {
    gap: 6px;
    padding: 5px 7px;
    min-width: 60px;
  }

  .stone-icon {
    width: 22px;
    height: 22px;
  }

  .player-label {
    font-size: 0.78rem;
  }

  .turn-display {
    font-size: 0.74rem;
    letter-spacing: 1px;
  }

  .message {
    font-size: 0.88rem;
    min-height: 40px;
    letter-spacing: 1px;
  }

  .message-win {
    font-size: 1rem;
  }

  .controls {
    gap: 8px;
  }

  .btn {
    font-size: 0.82rem;
    padding: 10px 18px;
    letter-spacing: 2px;
  }
}

/* ===== レスポンシブ：極小スクリーン ===== */
@media (max-width: 340px) {
  .stone-icon {
    width: 18px;
    height: 18px;
  }

  .player-info {
    min-width: 50px;
    padding: 4px 5px;
  }

  .player-label {
    font-size: 0.7rem;
  }

  .turn-display {
    font-size: 0.68rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .btn {
    text-align: center;
  }
}
