/*
 * congruence-shape-builder.css
 * じゆう作図で合同さがし！ スタイル
 * Version: 2.0.0（ヘッダー＋フルスクリーン＋右下ツールバーのシンプルUIに変更）
 * すべてのセレクタは .csb- プレフィックスでスコープ化しています。
 * WordPressのCSSとの干渉を防ぐため、html/bodyへの指定は body:has(.csb-root) 等で
 * このアプリのページにのみ限定しています（グローバルな上書きは行いません）。
 */

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

/* 修正: 画面下の空白対策。html/bodyを100%化し、ページ側の背景が
   見えないようにする（:has()はこのアプリが使われているページにのみ適用） */
html:has(.csb-root),
body:has(.csb-root) {
  height: 100%;
  margin: 0;
}

/* 修正: シンプルUI化。ヘッダー＋フルスクリーンstage＋右下ツールバーの
   固定レイアウトに変更（他アプリと共通のスケルトン）。 */
.csb-root {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "BIZ UDGothic", "M PLUS Rounded 1c", "Hiragino Maru Gothic Pro", sans-serif;
  background: #eef4fb;
  color: #1e3a5f;
  -webkit-tap-highlight-color: transparent;
  z-index: 9999;
}

/* ===== ヘッダー ===== */
.csb-root .csb-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: 20;
}
.csb-root .csb-header h1 {
  font-size: 15px;
  font-weight: bold;
  margin: 0;
  white-space: nowrap;
}
.csb-root .csb-hint {
  flex: 1;
  font-size: 13px;
  font-weight: bold;
  color: #1e3a5f;
  background: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}
.csb-root .csb-hint.csb-ok   { color: #fff; background: #2e7d32; }
.csb-root .csb-hint.csb-near { color: #fff; background: #b8860b; }

/* ===== フルスクリーンstage ===== */
.csb-root .csb-stage-wrap {
  position: fixed;
  top: 52px; left: 0;
  width: 100vw;
  height: calc(100vh - 52px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.csb-root .csb-stage-inner {
  position: relative;
  width: min(100%, calc((100vh - 52px - 24px) * 1000 / 600));
  aspect-ratio: 1000 / 600;
  max-width: 1200px;
  max-height: 100%;
  background: #ffffff;
  border-radius: 16px;
  border: 3px solid #1e3a5f;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  touch-action: none;
}
.csb-root .csb-stage {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.csb-grid-line {
  stroke: #e3eaf3;
  stroke-width: 1;
}
.csb-divider {
  stroke: #cdd9e6;
  stroke-width: 2;
  stroke-dasharray: 8 8;
}
.csb-zone-label {
  font-size: 16px;
  fill: #9aa9bb;
  font-weight: bold;
}
.csb-draw-point { fill: #1e3a5f; }
.csb-draw-line {
  stroke: #1e3a5f;
  stroke-width: 3;
  fill: none;
}
.csb-left-shape {
  fill: #bcdffa;
  stroke: #1e3a5f;
  stroke-width: 3;
}
.csb-right-shape {
  stroke: #1e3a5f;
  stroke-width: 3;
  cursor: grab;
}
.csb-right-group:active .csb-right-shape { cursor: grabbing; }

.csb-vertex-text {
  font-size: 20px;
  font-weight: bold;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}
.csb-left-text  { fill: #1e3a5f; }
.csb-right-text { fill: #7a4b00; }
.csb-vertex-dot {
  fill: #ffffff;
  stroke: #1e3a5f;
  stroke-width: 2;
  opacity: 0.55;
  cursor: pointer;
}
.csb-vertex-dot.csb-labeled {
  fill: #ff6f3c;
  stroke: #c1431a;
  opacity: 1;
}

/* ===== 右下：ツールバー＋スライダーの縦積みコンテナ ===== */
/* 修正: スライダーとツールバーを別々にposition:fixedしていたため、
   ツールバーのボタン数によっては重なってしまっていた。1つのコンテナに
   まとめて縦に積み上げる形にし、内容量に応じて自動で高さが決まるようにした。 */
.csb-root .csb-toolbar-area {
  position: fixed;
  right: 16px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 10;
}
.csb-root .csb-toolbar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.csb-root .csb-btn {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 2px solid #dde4ef;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s;
  background: #ffffff;
  color: #1e3a5f;
}
.csb-root .csb-btn:active         { transform: scale(0.92); }
.csb-root .csb-btn:disabled       { opacity: 0.35; cursor: default; }
.csb-root .csb-btn:disabled:active { transform: none; }
.csb-root .csb-btn-confirm { background: #10b981; border-color: #10b981; color: #fff; }
.csb-root .csb-btn-danger  { background: #fff; color: #ef4444; border-color: #ef4444; }
.csb-root .csb-btn-gold    { background: #d4af37; border-color: #d4af37; color: #fff; }
/* 「Aあ」（ラベルの種類を選ぶ）状態のボタン。文字2文字が入るので少しだけ小さめの文字。 */
.csb-root .csb-btn.csb-btn-labeltype { font-size: 16px; background: #1e3a5f; color: #fff; border-color: #1e3a5f; }

/* ===== ずらす／ぴったり スライダー ===== */
.csb-root .csb-slider-panel {
  width: 60px;
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
  padding: 12px 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.csb-root .csb-slider-top-label,
.csb-root .csb-slider-bottom-label {
  font-size: 10px;
  font-weight: bold;
  color: #6b7e99;
  text-align: center;
}
.csb-root .csb-slider-panel input[type="range"] {
  width: 8px;
  height: 110px;
  writing-mode: vertical-lr;
  direction: rtl;
  accent-color: #d4af37;
  cursor: pointer;
}

/* ===== 重なった後の中央表示（最終結果画面） ===== */
.csb-celebrate-layer {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.csb-celebrate-layer.csb-show {
  opacity: 1;
  pointer-events: none;
}
.csb-celebrate-bg {
  fill: #ffffff;
  fill-opacity: 1;
}
.csb-celebrate-shape-left {
  fill: #bcdffa;
  stroke: #1e3a5f;
  stroke-width: 3;
}
.csb-celebrate-shape-right {
  fill: #ffd54f;
  stroke: #7a4b00;
  stroke-width: 3;
  fill-opacity: 0.85;
}
.csb-celebrate-vertex-text {
  font-size: 22px;
  font-weight: bold;
  text-anchor: middle;
  dominant-baseline: middle;
}
.csb-celebrate-text {
  font-size: 26px;
  font-weight: bold;
  fill: #2e7d32;
  text-anchor: middle;
}

/* ===== ラベルの種類を選ぶモーダル ===== */
.csb-root .csb-label-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30,58,95,0.6);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.csb-root .csb-label-modal.csb-show { display: flex; }
.csb-root .csb-label-modal-content {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  width: min(94vw, 360px);
  text-align: center;
}
.csb-root .csb-label-modal-content h3 {
  font-size: 16px;
  color: #1e3a5f;
  margin: 0 0 14px;
}
.csb-root .csb-settings {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.csb-root .csb-label-btn {
  border: 2px solid #1e3a5f;
  background: #fff;
  color: #1e3a5f;
  font-weight: bold;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.csb-root .csb-label-btn.csb-active {
  background: #1e3a5f;
  color: #fff;
}
.csb-root .csb-modal-close-btn {
  width: auto;
  height: auto;
  border-radius: 999px;
  padding: 10px 24px;
  font-size: 14px;
  margin-top: 18px;
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
}

@media (max-width: 480px) {
  .csb-root .csb-header h1 { font-size: 13px; }
  .csb-root .csb-btn { width: 48px; height: 48px; font-size: 18px; }
  .csb-root .csb-slider-panel { width: 50px; }
  .csb-root .csb-toolbar-area { right: 10px; bottom: 14px; }
}
