/* ===============================
   全体レイアウト・装飾
=============================== */
.wrapwrap {
  margin: 0 auto;
  padding: 0;
  font-family: "Helvetica Neue", "ＭＳ ゴシック", Meiryo, sans-serif;
  width: 100%;
  color: #202020;
}
.gamewrap {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  padding: 0.5em;
}
.sectitle {
  margin: 0.3em 0;
  font-size: 2em;
  font-weight: bold;
}

/* 上部コントロール: 難易度 / 番号表示 / 完成図プレビュー */
.control-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em;
  margin: 0.5em 0 1em;
}
.control-item {
  display: flex;
  align-items: center;
  gap: 0.2em;
}
.debug-checkbox label {
  font-size: 0.9em;
  cursor: pointer;
}
.debug-checkbox input {
  cursor: pointer;
}

/* 難易度選択メニュー */
#difficultySelector {
  font-size: 0.9em;
  padding: 0.3em;
}

/* ===============================
   ステータスボックス (経過時間 & 手数)
=============================== */
.status-box {
  display: flex;
  justify-content: center;
  gap: 1em;
  margin-bottom: 1em;
  flex-wrap: wrap;
}
.status-item {
  background: #f5f5f5;
  border-radius: 10px;
  min-width: 120px;
  padding: 0.5em;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.2);
  font-weight: bold;
}

/* ===============================
   パズル表示 (正方形, レスポンシブ)
=============================== */
.puzzle-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0.5em auto;
  border: 2px solid #ccc;
  box-sizing: border-box;
  overflow: hidden;
}
.puzzle-container::before {
  content: "";
  display: block;
  width: 100%;
  padding-top: 100%;
}
.puzzle-piece {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid #fff;
  cursor: pointer;
  background-repeat: no-repeat;
  transition: top 0.2s, left 0.2s;
  z-index: 1;

  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 1.2em;
  color: #fff;
  text-shadow: 1px 1px 2px #000;
}
.puzzle-piece.debug-number::after {
  content: attr(data-piece-number);
}

/* ===============================
   ボタン共通スタイル
=============================== */
.button {
  display: inline-block;
  padding: 0.5em 1em;
  border-radius: 5px;
  font-weight: bold;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
  color: #fff;
  /* font-sizeは削除し、共通スタイルから外す */
}

/* 
   スタート/リセットボタンのみフォントサイズを適用 
   （.button-start と .button-retry が対象） 
*/
.button-start,
.button-retry {
  font-size: 1.1em;
}

/* スタートボタン（.button-start） */
.button-start {
  background-color: #15BD61;
}
.button-start:hover {
  background-color: #0da14a;
}

/* リセットボタン（.button-retry） */
.button-retry {
  background-color: #ff063f;
}
.button-retry:hover {
  background-color: #e60238;
}

/* 完成図を見るボタン（.button-preview） */
.button-preview {
  background-color: #15BD61;
}
.button-preview:hover {
  background-color: #0da14a;
}

/* ===============================
   スタート／リセット専用クラス (未使用例)
=============================== */
.startreset-button {
  background-color: #15BD61;
  padding: 0.5em 1.2em;
  margin: 0.2em;
  border-radius: 5px;
  font-size: 1em;
  font-weight: bold;
  border: none;
  cursor: pointer;
  color: #fff;
  transition: background-color 0.2s, opacity 0.2s;
}
.startreset-button:hover {
  background-color: #0da14a;
  opacity: 0.9;
}
.startreset-button[data-status="retry"] {
  background-color: #ff063f;
}
.startreset-button[data-status="retry"]:hover {
  background-color: #e60238;
}

/* ===============================
   SNSボタン
=============================== */
.btn {
  display: inline-block;
  margin: 0.2em;
  padding: 0.5em 1.2em;
  border-radius: 5px;
  text-decoration: none;
  color: #fff;
  transition: opacity 0.2s;
}
.btn:hover {
  opacity: 0.8;
}
.btn-dark {
  background-color: #333;
}
.btn-blue {
  background-color: #4267B2;
}
.btn-light-green {
  background-color: #00c300;
}

/* ===============================
   「完成図を見る」モーダルオーバーレイ（パズル領域内）
=============================== */
.preview-overlay {
  position: absolute; /* fixedからabsoluteに変更 */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.5);
  z-index: 10; /* パズルピース(z-index:1)より前面 */
  display: none;
  justify-content: center;
  align-items: center;
}
.preview-overlay.show {
  display: flex;
}
.preview-modal {
  width: 80%;
  height: 80%;
  background: #fff;
  padding: 1em;
  border-radius: 8px;
  position: relative;
  box-sizing: border-box;
  text-align: center;
  margin: auto; /* flex内で中央寄せ */
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-modal img {
  max-width: 100%;
  max-height: 100%;
}
.close-button {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  width: 2em;
  height: 2em;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
  font-size: 1.2em;
  cursor: pointer;
  opacity: 0.8;
  border: none;
  color: #fff;
}
.close-button:hover {
  opacity: 1;
}

/* ===============================
   クリア時の結果メッセージ
=============================== */
.completion-text {
  margin: 0.8em auto;
  font-size: 1.2em;
  font-weight: bold;
  color: #333;
  line-height: 1.4em;
  max-width: 400px;
}
#resultMessage:empty {
  display: none;
}

/* ===============================
   その他
=============================== */
.item-wrap {
  margin: 0.5em 0;
  text-align: center;
}
.count {
  margin: 0;
  font-weight: bold;
}

/* スタート/リセット用の item-wrap のマージンを多少狭く */
.startreset-container {
  margin: 1.5em 0; 
}
