.kifu-viewer {
  max-width: 550px;
  margin: 20px auto;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 20px;
  font-family: sans-serif;
  box-sizing: border-box;
}

.kifu-viewer h3 {
  margin-top: 0;
  color: #333;
  text-align: center;
  font-size: 18px;
  margin-bottom: 15px;
}

.kifu-board-wrapper {
  text-align: center;
  width: 100%;
}

.kifu-board {
  display: inline-block;
  background-color: #dcb672;
  padding: 15px;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  box-sizing: border-box;
}

.kifu-grid {
  display: grid;
  gap: 0;
  background-color: transparent;
  margin: 0 auto;
}

.kifu-intersection {
  width: 22px;
  height: 22px;
  position: relative;
}

/* 横線 - 統一された細い線 */
.kifu-intersection::before {
  content: '';
  position: absolute;
  background-color: #000;
  left: 0;
  top: 50%;
  width: 100%;
  height: 1px;
  transform: translateY(-0.5px);
}

/* 縦線 - 統一された細い線 */
.kifu-intersection::after {
  content: '';
  position: absolute;
  background-color: #000;
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
  transform: translateX(-0.5px);
}

/* 端の処理 */
.kifu-intersection.top::after {
  top: 50%;
  height: 50%;
  transform: translateX(-0.5px);
}

.kifu-intersection.bottom::after {
  height: 50%;
  transform: translateX(-0.5px);
}

.kifu-intersection.left::before {
  left: 50%;
  width: 50%;
  transform: translateY(-0.5px);
}

.kifu-intersection.right::before {
  width: 50%;
  transform: translateY(-0.5px);
}

/* 星 - 線の上に表示 */
.star-point {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  background-color: #000;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
}

/* 碁石 - シンプルでクリーン */
.kifu-stone {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

/* 黒石 - エフェクトなし */
.kifu-stone.black {
  background: radial-gradient(circle at 40% 40%, #555 0%, #000 100%);
  border: none;
}

/* 白石 - エフェクトなし */
.kifu-stone.white {
  background: radial-gradient(circle at 40% 40%, #fff 0%, #ddd 100%);
  border: 1px solid #999;
}

/* 最後の手マーカー - シンプルな点 */
.kifu-stone.last-move::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
}

.kifu-stone.black.last-move::after {
  background-color: #fff;
}

.kifu-stone.white.last-move::after {
  background-color: #000;
}

/* 手数 - さらに大きく見やすく */
.kifu-move-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  font-weight: bold;
  z-index: 12;
  pointer-events: none;
  line-height: 1;
}

.kifu-stone.black .kifu-move-number {
  color: #fff;
}

.kifu-stone.white .kifu-move-number {
  color: #000;
}

/* ボタン - シンプルなデザイン */
.kifu-controls {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.kifu-controls button {
  padding: 8px 14px;
  font-size: 14px;
  border: 1px solid #999;
  border-radius: 3px;
  cursor: pointer;
  background-color: #f5f5f5;
  color: #333;
  transition: all 0.2s;
  min-width: 60px;
}

.kifu-controls button[style*="background-color: #ff"] {
  color: white !important;
}

.kifu-controls button:hover:not(:disabled) {
  background-color: #e8e8e8;
  transform: translateY(-1px);
}

.kifu-controls button:active:not(:disabled) {
  transform: translateY(0);
}

.kifu-controls button:disabled {
  background-color: #f5f5f5;
  color: #999;
  cursor: not-allowed;
  border-color: #ccc;
}

.kifu-info {
  margin-top: 12px;
  text-align: center;
}

.kifu-game-info {
  margin-bottom: 8px;
  padding: 8px;
  background-color: #f8f8f8;
  border-radius: 5px;
  font-size: 12px;
  color: #555;
}

.kifu-move-info {
  font-size: 15px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #333;
}

.kifu-comment {
  margin-top: 10px;
  padding: 8px;
  background-color: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 5px;
  font-size: 13px;
  color: #856404;
  text-align: left;
  white-space: pre-wrap;
}

.kifu-comment.hidden {
  display: none;
}

/* SGF編集エリア */
.kifu-sgf-editor {
  margin-top: 15px;
  padding: 10px;
  background-color: #f8f8f8;
  border-radius: 5px;
}

.kifu-sgf-editor h4 {
  margin: 0 0 10px 0;
  font-size: 14px;
  color: #333;
}

.kifu-sgf-textarea {
  width: 100%;
  min-height: 100px;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  resize: vertical;
  box-sizing: border-box;
}

.kifu-sgf-buttons {
  display: flex;
  gap: 5px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.kifu-sgf-buttons button {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid #999;
  border-radius: 3px;
  cursor: pointer;
  background-color: #4CAF50;
  color: white;
  transition: background-color 0.2s;
}

.kifu-sgf-buttons button:hover {
  background-color: #45a049;
}

.kifu-sgf-buttons button.secondary {
  background-color: #2196F3;
}

.kifu-sgf-buttons button.secondary:hover {
  background-color: #0b7dda;
}

/* 変化図ボタン */
.kifu-variation-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #ff4444;
  transform: translate(-50%, -50%);
  z-index: 15;
  cursor: pointer;
  border: 1px solid #fff;
}

.kifu-variation-btn:hover {
  width: 10px;
  height: 10px;
  background-color: #ff0000;
}

/* スマホ対応 - 375px基準で最適化 */
@media (max-width: 500px) {
  .kifu-viewer {
    padding: 8px;
    margin: 10px auto;
  }
  
  .kifu-viewer h3 {
    font-size: 16px;
    margin-bottom: 8px;
  }
  
  .kifu-board {
    padding: 8px;
  }
  
  /* 375px幅: 375 - 16(padding) - 16(board padding) = 343px
     343 / 19 = 18px/マス */
  .kifu-intersection {
    width: 16px;
    height: 16px;
  }
  
  .kifu-stone {
    width: 14px;
    height: 14px;
  }
  
  .kifu-move-number {
    font-size: 9px;
  }
  
  .star-point {
    width: 3.5px;
    height: 3.5px;
  }
  
  .kifu-stone.last-move::after {
    width: 4px;
    height: 4px;
  }
  
  .kifu-controls {
    gap: 4px;
  }
  
  .kifu-controls button {
    padding: 6px 10px;
    font-size: 13px;
    min-width: 55px;
  }
  
  .kifu-game-info {
    font-size: 11px;
    padding: 6px;
  }
  
  .kifu-move-info {
    font-size: 13px;
  }
}

/* 極小画面対応(320px幅) */
@media (max-width: 340px) {
  .kifu-viewer {
    padding: 5px;
  }
  
  .kifu-board {
    padding: 6px;
  }
  
  /* 320px幅: 320 - 10(padding) - 12(board padding) = 298px
     298 / 19 = 15.7px → 15px */
  .kifu-intersection {
    width: 14px;
    height: 14px;
  }
  
  .kifu-stone {
    width: 12px;
    height: 12px;
  }
  
  .kifu-move-number {
    font-size: 8px;
  }
  
  .star-point {
    width: 3px;
    height: 3px;
  }
  
  .kifu-stone.last-move::after {
    width: 3px;
    height: 3px;
  }
  
  .kifu-controls button {
    padding: 5px 8px;
    font-size: 12px;
    min-width: 50px;
  }
}