/* ============================================================
   図形パズル（しきつめボード） - スタイルシート
   全セレクタを .shape-puzzle-root 配下に限定し、テーマ干渉を防止
   ============================================================ */

.shape-puzzle-root, .shape-puzzle-root * {
  box-sizing: border-box;
}

.shape-puzzle-root {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "BIZ UDGothic", "M PLUS Rounded 1c", "Hiragino Kaku Gothic ProN", sans-serif;
  background: #f5f7fa;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 9999; /* 修正: Cocoonテーマのヘッダー等より前面に出す */
}

/* ===== ヘッダー ===== */
.shape-puzzle-root .sp-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: 52px;
  background: #1e3a5f;
  color: #fff;
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 10;
}
.shape-puzzle-root .sp-header h1 { font-size: 18px; font-weight: bold; flex: 1; margin: 0; }
.shape-puzzle-root .sp-info { font-size: 14px; opacity: 0.85; }

/* ===== アプリ画面キャンバス ===== */
.shape-puzzle-root #sp-canvas {
  position: fixed;
  top: 52px; left: 0;
  width: 100vw;
  height: calc(100vh - 52px);
  background: #f0f4f9;
  display: block;
}

/* ===== ツールバー（右下） ===== */
.shape-puzzle-root .sp-toolbar {
  position: fixed;
  right: 16px; bottom: 20px;
  display: flex; flex-direction: column;
  gap: 12px;
  z-index: 10;
}
.shape-puzzle-root .sp-btn {
  width: 60px; height: 60px;
  border-radius: 999px;
  border: none;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.shape-puzzle-root .sp-btn:active { transform: scale(0.92); }
.shape-puzzle-root .sp-btn-add    { background: #d4af37; color: #fff; font-size: 34px; }
.shape-puzzle-root .sp-btn-rotate,
.shape-puzzle-root .sp-btn-rotate-left { background: #1e3a5f; color: #fff; }
.shape-puzzle-root .sp-btn-delete { background: #fff; color: #c0392b; border: 2px solid #c0392b; }
.shape-puzzle-root .sp-btn-setting{ background: #fff; color: #1e3a5f; border: 2px solid #1e3a5f; }
.shape-puzzle-root .sp-btn:disabled { opacity: 0.35; cursor: default; }
.shape-puzzle-root .sp-btn:disabled:active { transform: none; }

/* ===== ステップ画面（オーバーレイ） ===== */
.shape-puzzle-root .sp-overlay {
  position: fixed; inset: 0;
  background: rgba(30,58,95,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 12px;
  touch-action: none;
}
.shape-puzzle-root .sp-overlay.hidden { display: none; }
.shape-puzzle-root .sp-dialog {
  background: #fff;
  border-radius: 16px;
  padding: 22px 24px;
  width: min(94vw, 560px);
  max-height: 94vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  text-align: center;
  touch-action: pan-y;
}
.shape-puzzle-root .sp-dialog h2 {
  color: #1e3a5f;
  font-size: 19px;
  margin: 0 0 6px;
}
.shape-puzzle-root .sp-step-label {
  display: inline-block;
  background: #d4af37;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
  border-radius: 999px;
  padding: 3px 14px;
  margin-bottom: 10px;
}
.shape-puzzle-root .sp-hint {
  font-size: 13px;
  color: #5a708a;
  margin: 0 0 16px;
}

/* モード選択 */
.shape-puzzle-root .sp-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.shape-puzzle-root .sp-mode-btn {
  padding: 20px 12px;
  border-radius: 14px;
  border: 2px solid #1e3a5f;
  background: #fff;
  color: #1e3a5f;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}
.shape-puzzle-root .sp-mode-btn:active { background: #eef2f6; }
.shape-puzzle-root .sp-mode-btn .mode-name {
  display: block;
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 8px;
}
.shape-puzzle-root .sp-mode-btn .mode-desc {
  display: block;
  font-size: 12px;
  color: #5a708a;
  line-height: 1.5;
}

/* 基本図形えらび */
.shape-puzzle-root .sp-vertex-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.shape-puzzle-root .sp-vertex-btn {
  padding: 14px 0;
  border-radius: 12px;
  border: 2px solid #1e3a5f;
  background: #fff;
  color: #1e3a5f;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.shape-puzzle-root .sp-vertex-btn:active { background: #eef2f6; }

/* ふしぎな図形（複雑な敷き詰めタイル）えらび */
.shape-puzzle-root .sp-escher-title {
  margin: 20px 0 4px;
  font-size: 14px;
  font-weight: bold;
  color: #1e3a5f;
}
.shape-puzzle-root .sp-escher-note {
  font-size: 11px;
  color: #5a708a;
  margin: 0 0 10px;
}
.shape-puzzle-root .sp-escher-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.shape-puzzle-root .sp-escher-btn {
  padding: 8px 4px 10px;
  border-radius: 12px;
  border: 2px solid #d4af37;
  background: #fffdf5;
  color: #1e3a5f;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.shape-puzzle-root .sp-escher-btn:active { background: #faf3dd; }
.shape-puzzle-root .sp-escher-btn svg {
  width: 100%;
  height: 56px;
  display: block;
  margin-bottom: 4px;
}

/* 作図エディタ */
.shape-puzzle-root #sp-edit-canvas {
  background: #fff;
  border: 2px solid #c8d4e8;
  border-radius: 12px;
  display: block;
  margin: 0 auto 16px;
  touch-action: none;
}
.shape-puzzle-root .sp-edit-btns {
  display: flex;
  gap: 12px;
}
.shape-puzzle-root .sp-back-btn {
  flex: 1;
  padding: 14px 0;
  border-radius: 999px;
  border: 2px solid #1e3a5f;
  background: #fff;
  color: #1e3a5f;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.shape-puzzle-root .sp-decide-btn {
  flex: 2;
  padding: 14px 0;
  border-radius: 999px;
  border: none;
  background: #d4af37;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.shape-puzzle-root .sp-decide-btn:active,
.shape-puzzle-root .sp-back-btn:active { transform: scale(0.97); }
.shape-puzzle-root .sp-step-back {
  margin-top: 16px;
  background: none;
  border: none;
  color: #5a708a;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  -webkit-tap-highlight-color: transparent;
}
.shape-puzzle-root .hidden { display: none !important; }
