:root {
  --cell: 64px;
  --hand-size: 50px;
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  margin: 0;
  overflow-x: hidden;
}
body {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  background: #3b2b20;
  color: #eee;
  display: flex;
  justify-content: center;
  padding: 12px 8px;
}
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 620px;
}
h1 {
  font-size: 18px;
  margin: 4px 0;
  text-align: center;
}
#turn-indicator {
  font-size: 16px;
  font-weight: bold;
  min-height: 22px;
}
#btn-resign {
  background: #b3413a;
  color: #fff;
  border-color: #7a2a24;
}
#btn-resign:hover:not(:disabled) { background: #9c352f; }
#btn-resign:disabled {
  opacity: 0.4;
  cursor: default;
}
#settings {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  background: rgba(255,255,255,0.06);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}
#settings label { display: flex; align-items: center; gap: 4px; }
#settings select, #settings input {
  font-size: 13px;
  padding: 2px 4px;
}
#depth-input { width: 50px; }

#eval-indicator {
  font-size: 14px;
  font-weight: bold;
  background: rgba(255,255,255,0.08);
  padding: 4px 10px;
  border-radius: 6px;
}
#eval-indicator.hidden { display: none; }

#rule-note {
  font-size: 12px;
  color: #f0d9a0;
  background: rgba(0,0,0,0.2);
  padding: 4px 10px;
  border-radius: 6px;
}

.hand {
  display: flex;
  gap: 8px;
  min-height: 56px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.hand-piece {
  position: relative;
  width: var(--hand-size);
  height: var(--hand-size);
  background: #e8c07a;
  border: 2px solid #6b4a26;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--hand-size) * 0.44);
  cursor: pointer;
  color: #222;
  user-select: none;
}
.hand-piece.flipped-piece { transform: rotate(180deg); }
.hand-piece.disabled { opacity: 0.25; cursor: default; }
.hand-piece.selected { outline: 3px solid #ff5252; }
.hand-piece .count {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: #333;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: none;
}

#view-settings {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
#view-settings label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

#cylinder-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
#cylinder-slider { width: 240px; }

#board-wrapper {
  position: relative;
}
#board {
  display: grid;
  grid-template-columns: repeat(5, var(--cell));
  grid-template-rows: repeat(5, var(--cell));
  background: #e8c07a;
  border: 4px solid #6b4a26;
}
.cell {
  border: 1px solid #6b4a26;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell) * 0.47);
  position: relative;
  cursor: pointer;
  color: #111;
  user-select: none;
  background: #e8c07a;
}
.cell.selected {
  background: #ffe082;
}
.cell.last-move {
  box-shadow: inset 0 0 0 999px rgba(255, 140, 0, 0.35);
}
.cell .piece {
  color: #111;
}
.cell .piece.flipped-piece {
  transform: rotate(180deg);
}
.cell .piece.promoted {
  color: #b3261e;
}

/* ===== 円筒(立体)表示 ===== */
/* 幅・高さはJS側でウィンドウサイズに応じて動的に設定する */
#board3d-scene {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  max-width: 100%;
}
#board3d-inner {
  position: relative;
  transform-style: preserve-3d;
}
.col-panel {
  position: absolute;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  backface-visibility: hidden;
}
.col-panel .cell {
  border-width: 0.5px;
}

#overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
}
#overlay.hidden, .hidden { display: none !important; }
#overlay-box {
  background: #fffdf5;
  color: #222;
  padding: 20px 28px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
#overlay-message {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 14px;
}
#overlay-buttons, #review-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
button {
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #6b4a26;
  background: #e8c07a;
  cursor: pointer;
}
button:hover { background: #d9a95a; }

#review-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
#review-info {
  font-size: 14px;
}

#promote-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
#promote-box {
  background: #fffdf5;
  color: #222;
  padding: 20px 28px;
  border-radius: 10px;
  text-align: center;
}
#promote-box button { margin: 0 6px; }

/* ===== スマホ対応 ===== */
@media (max-width: 480px) {
  :root {
    --cell: 15vw;
    --hand-size: 13vw;
  }
  body { padding: 8px 4px; }
  h1 { font-size: 15px; }
  #settings, #view-settings, #cylinder-slider-row { font-size: 11px; gap: 6px; }
  #rule-note { font-size: 10px; }
  #eval-indicator { font-size: 12px; }
  #cylinder-slider { width: 70vw; max-width: 240px; }
  button { font-size: 12px; padding: 6px 9px; }
  #overlay-message { font-size: 18px; }
  #depth-input { width: 42px; }
}