/* =====================================================================
   style.css — ペグソリティア ツール固有の微調整のみ。
   共通スタイルは /_shared/shirugear.css に任せる。
   ツール固有クラスは接頭辞 ps- を付ける。
   ===================================================================== */

/* 盤の種類の切替（既存ゲームのモード切替と同じ見た目） */
.sg-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: var(--sg-space-1, 4px);
}
.sg-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}

/* ステータス（案内・結果） */
.ps-status {
  min-height: 2.8em;
  margin: 4px 0 8px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
}
.ps-status.is-ok { color: var(--sg-success, #1f9d57); }
.ps-status.is-warn { color: var(--sg-warm, #b54708); }

/* 手数・残り */
.ps-stats {
  display: flex;
  justify-content: center;
  gap: 8px 20px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  font-size: 0.92rem;
  color: var(--sg-muted, #5a6573);
}
.ps-stat strong {
  font-size: 1.15rem;
  color: var(--sg-fg, #1a2230);
  font-variant-numeric: tabular-nums;
}

/* ---------- 盤 ---------- */
.ps-board-wrap {
  position: relative; /* 移動アニメーションの飛ぶペグの基準 */
  display: flex;
  justify-content: center;
  padding: 4px 0;
}
.ps-board {
  display: grid;
  width: min(100%, 420px);
  box-sizing: border-box;
  padding: 10px;
  gap: 2px;
  border-radius: var(--sg-radius-lg, 16px);
  background: var(--sg-surface-2, #eef1f6);
  border: 1px solid var(--sg-border, #dde2ec);
  /* 盤は外枠が小さくても穴が押しやすいようにセル全体をボタンにする */
}
.ps-board--english,
.ps-board--european {
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  aspect-ratio: 1 / 1;
}
/* 三角盤：10 列の細かい格子に各穴を2列ぶん使って並べる（半個ずらし）。
   正三角形の格子にするため、行の高さは穴の間隔の約 0.866 倍。 */
.ps-board--triangle {
  width: min(100%, 380px);
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(5, 1fr);
  aspect-ratio: 10 / 8.9;
}

.ps-hole {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  justify-self: stretch;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.ps-hole:focus-visible {
  outline: 3px solid var(--sg-primary, #3b5bdb);
  outline-offset: -1px;
  z-index: 2;
}

/* 穴（くぼみ） */
.ps-spot {
  position: relative;
  display: block;
  width: 78%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--sg-bg, #f4f6fb);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.28);
  box-sizing: border-box;
}
.ps-board--triangle .ps-spot {
  width: auto;
  height: 84%;
}

/* ペグ（駒）：自作の球体風の円。明暗どちらのテーマでも目立つ橙系 */
.ps-peg {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ffd19a 0%, #f08c2e 45%, #b8530f 100%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}
.ps-hole.is-peg .ps-peg {
  opacity: 1;
  transform: scale(1);
}
/* 飛んでくる最中は着地先のペグを隠す */
.ps-hole.is-arriving .ps-peg {
  opacity: 0;
  transition: none;
}

/* 選択中のペグ（色に加えて太いリングと持ち上げで区別） */
.ps-hole.is-selected .ps-peg {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px var(--sg-surface, #fff), 0 0 0 6px var(--sg-primary, #3b5bdb),
    0 4px 8px rgba(0, 0, 0, 0.35);
}

/* 移動先候補（点線リング） */
.ps-hole.is-target .ps-spot {
  background: var(--sg-primary-soft, #eaeefc);
  box-shadow: inset 0 0 0 3px var(--sg-primary, #3b5bdb);
  outline: 2px dashed var(--sg-primary, #3b5bdb);
  outline-offset: 3px;
}

/* 完全クリアの目標の穴（★）。空いているときに★を表示 */
.ps-hole.is-goal .ps-spot::after {
  content: "★";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(10px, 3.2vw, 16px);
  line-height: 1;
  color: var(--sg-warm, #f59f3c);
  pointer-events: none;
}
.ps-hole.is-goal.is-peg .ps-spot::after {
  content: "";
}
.ps-hole.is-goal .ps-spot {
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.28), 0 0 0 2px var(--sg-warm, #f59f3c);
}
.ps-hole.is-goal.is-target .ps-spot {
  box-shadow: inset 0 0 0 3px var(--sg-primary, #3b5bdb), 0 0 0 2px var(--sg-warm, #f59f3c);
}

/* ヒント：動かすペグと移動先（太い実線リング＋点滅） */
.ps-hole.is-hint-from .ps-spot,
.ps-hole.is-hint-to .ps-spot {
  outline: 3px solid var(--sg-success, #1f9d57);
  outline-offset: 3px;
  animation: ps-hint-pulse 0.9s ease-in-out infinite alternate;
}
.ps-hole.is-hint-to .ps-spot {
  outline-style: dashed;
}
@keyframes ps-hint-pulse {
  from { outline-offset: 2px; }
  to { outline-offset: 5px; }
}

/* 移動アニメーション用（app.js が一時的に生成） */
.ps-fly {
  position: absolute;
  inset: auto;
  opacity: 1;
  transform: none;
  transition: none;
  z-index: 5;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .ps-peg {
    transition: none;
  }
  .ps-hole.is-hint-from .ps-spot,
  .ps-hole.is-hint-to .ps-spot {
    animation: none;
  }
}

/* 終了時の結果 */
.ps-result {
  margin: 12px auto 0;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: var(--sg-radius, 10px);
  border: 1px solid var(--sg-border, #dde2ec);
  background: var(--sg-surface-2, #eef1f6);
  text-align: center;
}
.ps-result.is-clear {
  border-color: var(--sg-success, #1f9d57);
}
.ps-result.is-perfect {
  border-color: var(--sg-warm, #f59f3c);
  background: var(--sg-warm-soft, #fff3e2);
}
.ps-result__title {
  margin: 0;
  font-weight: 700;
  font-size: 1.1rem;
}
.ps-result__text {
  margin: 4px 0 0;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* 操作ボタン群 */
.ps-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.ps-actions .sg-btn {
  padding: 8px 14px;
  font-size: 0.95rem;
}

/* ベスト記録 */
.ps-best {
  text-align: center;
  font-size: 0.9rem;
  color: var(--sg-muted, #5a6573);
}

/* 早見表 */
.sg-chart {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 2px 16px;
}
.sg-chart-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--sg-border, #e5e7eb);
}
.sg-chart-row__key {
  flex: 0 0 6em;
  font-weight: 600;
}
.sg-chart-row__val {
  flex: 1 1 auto;
  color: var(--sg-muted, #555);
}
