* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: sans-serif;
  background: #f0f0f0;
  padding: 10px;
}

/* ===== 共通パネル ===== */
.panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  padding: 12px;
}

h1 { font-size: 24px; margin-bottom: 6px; }

#info {
  font-size: 18px;
  color: #333;
  word-break: keep-all;
  overflow-wrap: normal;
}

/* ===== ターン表示 ===== */
.turn-mine {
  display: inline-block;
  background: #c8f0c8;
  color: #2a7a2a;
  padding: 4px 14px;
  border-radius: 20px;
  font-weight: bold;
  margin-top: 6px;
}
.turn-opponent {
  display: inline-block;
  background: #e0e0e0;
  color: #333;
  padding: 4px 14px;
  border-radius: 20px;
  margin-top: 6px;
}

/* ===== ボード ===== */
#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  background: #2d6a2d;
  padding: 6px;
  border-radius: 6px;
  margin: 0 auto;
}

.cell {
  background: #3a8f3a;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
  width: 100%;
  height: 100%;
}
.cell.clickable { cursor: pointer; }
.cell.clickable:hover { background: #4aaa4a; }

.piece {
  width: 84%; height: 84%;
  border-radius: 50%;
  position: absolute;
}
.piece.black {
  background: radial-gradient(circle at 35% 35%, #555, #000);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}
.piece.white {
  background: radial-gradient(circle at 35% 35%, #fff, #ccc);
  box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
.hint {
  width: 32%; height: 32%;
  border-radius: 50%;
  background: rgba(232,160,0,0.9);
  position: absolute;
}

/* ===== 待ったボタン ===== */
#mattaBtn {
  padding: 14px 28px;
  font-size: 18px;
  font-weight: bold;
  border: 2px solid #aaa;
  border-radius: 8px;
  background: #eee;
  color: #555;
  cursor: default;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
  position: relative;
  width: 100%;
}
#mattaBtn.active {
  background: #e8a000;
  color: white;
  border-color: #c47f00;
  cursor: pointer;
}
#mattaBtn.active:hover { background: #c47f00; }

#mattaStatus {
  font-size: 13px;
  color: #555;
  text-align: center;
  min-height: 32px;
  margin-top: 6px;
}

/* ===== 視線コントロール ===== */
#gazeControl {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}

#gazeToggleRow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

#gazeToggle, #testModeToggle {
  padding: 8px 12px;
  font-size: 14px;
  border: 2px solid #aaa;
  border-radius: 6px;
  background: #eee;
  cursor: pointer;
  white-space: nowrap;
  flex: 1;
}
#gazeToggle.on {
  background: #4a90d9; color: white; border-color: #357abd;
}
#testModeToggle.on {
  background: #e8a000; color: white; border-color: #c47f00;
}

#gazeSliders {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 16px;
}
.sliderRow {
  display: flex;
  align-items: center;
  gap: 4px;
}
.sliderRow label {
  width: 100px;
  text-align: right;
  white-space: nowrap;
  font-size: 16px;
}
.sliderRow input[type=range] {
  width: 110px;
  height: 6px;
  cursor: pointer;
  accent-color: #4a90d9;
}

/* ===== テストバナー ===== */
#testModeBanner {
  display: none;
  background: #fff3cd;
  color: #856404;
  border: 2px solid #ffc107;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  text-align: center;
  margin-top: 8px;
}

/* ===== メッセージ ===== */
#message {
  font-size: 18px;
  font-weight: bold;
  color: #c00;
  min-height: 26px;
  margin-top: 6px;
  text-align: center;
}

/* ===== 円形プログレス ===== */
.gaze-progress {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 80%; height: 80%;
  pointer-events: none;
}
.gaze-progress circle {
  fill: none;
  stroke: orange;
  stroke-width: 4;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
}

/* 視線滞留中のhover抑制 */
#board.gaze-locked .cell.clickable:not(.gaze-active):hover {
  background: #3a8f3a;
  cursor: default;
}

/* ===== ロゴ ===== */
#logoWrap {
  margin-top: auto;
  padding-top: 16px;
  text-align: center;
}
#logo {
  width: 80%;
  max-width: 200px;
  opacity: 0.85;
}

/* ===== パネルコントロール ===== */
#panelControls {
  display: flex;
  flex-direction: column;
}

/* ===== 勝敗オーバーレイ ===== */
#overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  justify-content: center;
  align-items: center;
  z-index: 100;
}
#overlay.show { display: flex; }
#overlayBox {
  background: white;
  border-radius: 16px;
  padding: 40px 50px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: popIn 0.3s ease;
}
@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
#overlayTitle { font-size: 48px; margin-bottom: 16px; }
#overlayMessage { font-size: 22px; color: #444; margin-bottom: 30px; }
#overlayBtn {
  padding: 12px 36px; font-size: 18px;
  background: #4a90d9; color: white;
  border: none; border-radius: 8px; cursor: pointer;
}
#overlayBtn:hover { background: #357abd; }

.info-sep {
  display: block;
  margin-bottom: 2px;
}

/* ========================================
   PCレイアウト（1025px以上）
   ======================================== */
#layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "header   board"
    "controls board";
  gap: 12px;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  height: calc(100vh - 20px);
}

#panelHeader {
  grid-area: header;
  text-align: center;
}
#panelBoard {
  grid-area: board;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#panelControls {
  grid-area: controls;
}

#board {
  width: min(calc(100vh - 80px), calc(100vw - 360px), 760px);
  height: min(calc(100vh - 80px), calc(100vw - 360px), 760px);
}

/* ========================================
   iPad・タブレットレイアウト（1024px以下）
   ======================================== */
@media (max-width: 1024px) {
  #layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "header"
      "board"
      "controls";
    height: auto;
  }

  #panelHeader { text-align: center; }

  #board {
    width: min(calc(100vw - 44px), 660px);
    height: min(calc(100vw - 44px), 660px);
  }

  #gazeToggleRow { justify-content: center; }
  #gazeToggle, #testModeToggle { flex: unset; }

  #logoWrap { padding-top: 12px; }
  #logo { max-width: 160px; }

  #gazeControl {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
  }

  #gazeToggleRow {
    flex-direction: row;
    flex-shrink: 0;
  }

  #gazeSliders {
    flex-direction: row;
    gap: 16px;
    flex-wrap: wrap;
  }

  .sliderRow label {
    width: auto;
  }
  .info-sep {
    display: inline;
  }
  .info-sep::after {
    content: '\00a0\00a0\00a0\00a0\00a0';
  }
}

.logoWrap { padding-top: 12px; }
.logo { max-width: 160px; }