/* ==========================================
   マルチスポーツ作戦ボード CSS
   プレフィックス: msb-
   サッカー・ハンドボール・タグラグビー・フラッグフットボールを
   1つのCanvasコートで切り替え表示する
   ========================================== */

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

.msb-root {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "BIZ UDGothic", "M PLUS Rounded 1c", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: #eef2ec;
  color: #1f2937;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 9999;
}

/* ===== 修正(v3.2.0): 固定ヘッダー／スポーツ切り替えバーを撤去し、
   左上のスポーツ切り替えトリガー・右上の2分割比較／選手名編集ボタンとして
   コート上に浮かべる方式に変更（ユーザー指示：「タブで切り替えではなくモーダル切り替えに
   したい。その分ヘッダーを削除してアプリ画面を大きくしたい」）。 ===== */
.msb-root .msb-float-btn {
  border: none; background: #1e3a5f; color: #fff;
  width: 44px; height: 44px; border-radius: 50%;
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s;
}
.msb-root .msb-float-btn:active { transform: scale(0.92); }

.msb-root .msb-sport-trigger {
  position: fixed; top: 12px; left: 12px; z-index: 20;
  border: 2px solid #d4af37;
}
/* 修正(v3.2.2): 絵文字アイコンをやめ線画SVGに変更したため、文字サイズ指定は不要（削除） */

.msb-root .msb-top-right-controls {
  position: fixed; top: 12px; right: 12px; z-index: 20;
  display: flex; gap: 10px;
}
/* 修正: 2分割比較ボタンは他の浮動ボタンと同じ丸ボタンだが、ONの間は緑で強調する
   （以前のスポーツ切り替えバー内での配色を踏襲。JS側は .msb-sport-btn--active の
   付け外しのみで、このクラス自体は他のスポーツボタンと共有しない） */
.msb-root .msb-top-right-controls .msb-float-btn.msb-sport-btn--active {
  background: #10b981;
}

/* 修正(v3.2.0・再修正): 浮動ピル表示だとコートの最上部に重なって見づらいとのフィードバックを受け、
   以前のヘッダーと同じ「専用の帯」に戻した（左上のスポーツ切り替え・右上の2分割比較／選手名編集は
   引き続き浮動ボタンのままこの帯の上に重ねる。タイトルやスポーツ切り替えバーは復活させない）。 */
.msb-root .msb-hint {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  z-index: 10;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: bold;
  background: #1e3a5f; color: #fff;
  padding: 0 68px;
  max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* ===== スポーツ切り替えモーダル ===== */
.msb-root .msb-sport-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;
}
.msb-root .msb-sport-modal--open { display: flex; }
.msb-root .msb-sport-modal-content {
  background: #fff; border-radius: 16px; padding: 24px;
  width: min(94vw, 420px);
}
.msb-root .msb-sport-modal-content h3 { font-size: 17px; color: #1e3a5f; margin: 0 0 16px; text-align: center; }
.msb-root .msb-sport-modal-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px;
}
.msb-root .msb-sport-modal .msb-sport-btn {
  flex-direction: column; gap: 6px;
  border: 2px solid #dde4ef; background: #f5f7fa; color: #1e3a5f;
  border-radius: 14px; padding: 16px 8px;
  font-size: 13px; font-weight: bold;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .15s, border-color .15s;
}
.msb-root .msb-sport-modal .msb-sport-btn span { font-size: 13px; white-space: nowrap; }
.msb-root .msb-sport-modal .msb-sport-btn:active { background: #eaeef3; }
.msb-root .msb-sport-modal .msb-sport-btn.msb-sport-btn--active {
  background: #d4af37; border-color: #d4af37; color: #1e3a5f;
}
.msb-root .msb-sport-modal-close {
  display: block; width: 100%;
  border: none; background: #eef2f6; color: #6b7e99;
  border-radius: 999px; padding: 12px; font-size: 14px; font-weight: bold;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.msb-root .msb-sport-modal-close:active { background: #dde4ef; }

/* ===== フルスクリーンcourt（先生モードでA/B 2面に分割できる） ===== */
/* 修正(v3.2.0): ヘッダー／スポーツ切り替えバー分(92px)の上余白を廃止し、画面いっぱいに拡大 */
/* 修正(v3.2.0・再修正): ヒント文を専用の帯(56px)に戻したため、その高さ分だけコート開始位置を下げる */
.msb-root #msb-court-wrap {
  position: fixed;
  top: 56px; left: 0; width: 100vw; height: calc(100vh - 56px);
  display: flex; align-items: stretch; justify-content: center;
  padding: 12px; gap: 10px;
}

.msb-root .msb-court-panel {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  outline: 3px solid transparent;
  outline-offset: -3px;
  border-radius: 12px;
  transition: outline-color .2s;
}
.msb-root .msb-court-panel--hidden { display: none; }
/* 修正: 操作対象（アクティブ）パネルをゴールドの枠で示す。2分割時のみ意味を持つ */
.msb-root #msb-court-wrap.msb-court-wrap--split .msb-court-panel--active {
  outline-color: #d4af37;
}

.msb-root .msb-panel-badge {
  position: absolute; top: 8px; left: 8px; z-index: 30;
  width: 26px; height: 26px; border-radius: 50%;
  background: rgba(30,58,95,0.75); color: #d4af37;
  font-size: 13px; font-weight: 900;
  display: none; align-items: center; justify-content: center;
  border: 1px solid #d4af37;
  pointer-events: none;
}
.msb-root #msb-court-wrap.msb-court-wrap--split .msb-panel-badge { display: flex; }

.msb-root .msb-court {
  position: relative;
  width: 100%; height: 100%;
  max-width: 1100px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  touch-action: none;
}
/* 修正: ハンドボールのみ円弧(6m/9mライン)を正しい比率で描くため縦横比を固定 */
/* 修正(v3.2.0): ヘッダー／バー分(92px)の上余白が無くなったため、その項を数式から除いた */
/* 修正(v3.2.0・画角修正): 基本ルールのheight:100%が残ったままだとwidth・heightの両方が
   確定値になってしまい、aspect-ratioが無視される（ブラウザの仕様）。その結果、画面が縦に
   広がった分だけコートが本来の400:279.2比率から外れ、円弧が卵形に歪んで見えていた。
   height:autoに変更してaspect-ratioから高さを計算させることで、画面の高さに関わらず
   常に正しい比率（＝見た目の画角）を保つようにした。 */
/* 修正(v3.2.0・再修正): ヒント文の帯(56px)が復活した分、高さの計算式にも反映 */
.msb-root[data-sport="handball"] .msb-court {
  width: min(100%, calc((100vh - 56px - 24px) * 400 / 279.2));
  height: auto;
  max-height: 100%;
  aspect-ratio: 400 / 279.2;
}
.msb-root .msb-court-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ===== 選手マーカー ===== */
/* 修正: マーカーを20%拡大（40px→48px、フォント12px→14px） */
.msb-root .player {
  position: absolute;
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: bold; color: #fff;
  cursor: grab;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  border: 3px solid rgba(255,255,255,0.85);
  touch-action: none;
  transition: box-shadow .1s;
  z-index: 3;
}
.msb-root .player.offense { background: linear-gradient(135deg, #FF6B6B, #FF8E53); }
.msb-root .player.defense { background: linear-gradient(135deg, #4ECDC4, #44A08D); }
.msb-root .player.dragging { cursor: grabbing; box-shadow: 0 4px 14px rgba(0,0,0,0.5); z-index: 6; }

/* 修正: 先生モードのマーカー強調表示（タップで選択） */
.msb-root .player.msb-unfocused {
  filter: grayscale(0.85) brightness(0.65);
  opacity: 0.65;
}
.msb-root .player.msb-highlighted {
  transform: translate(-50%, -50%) scale(1.28);
  z-index: 8;
  box-shadow: 0 0 0 4px #d4af37, 0 6px 18px rgba(0,0,0,0.5);
  animation: msb-highlight-pulse 1.3s ease-in-out infinite;
}
@keyframes msb-highlight-pulse {
  0%, 100% { box-shadow: 0 0 0 4px #d4af37, 0 6px 18px rgba(0,0,0,0.5); }
  50%      { box-shadow: 0 0 0 9px rgba(212,175,55,0.35), 0 6px 18px rgba(0,0,0,0.5); }
}

/* ===== 強調表示ヒント（先生モードのみ） ===== */
/* 修正(v3.2.0): ヘッダー廃止に伴い位置を調整 */
/* 修正(v3.2.0・再修正): ヒント文の帯(56px)が復活したため、そのすぐ下に来るよう再調整 */
/* 修正(v3.2.2): 2分割比較時、コート左上のA/Bバッジ（top:8px、高さ26px）と重なっていたため、
   バッジの下（コート上端から48px＝バッジ分＋余白）まで下げて回避した */
.msb-root .msb-highlight-hint {
  position: fixed; top: 116px; left: 50%; transform: translateX(-50%);
  z-index: 15;
  background: rgba(30,58,95,0.85); color: #d4af37;
  font-size: 11px; font-weight: bold;
  padding: 5px 14px; border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
}

/* 修正: ボールマーカー。ハンドボールは黄×黒アイコン(svg)、フラッグフットボールは絵文字🏈 */
.msb-root .player.ball {
  width: 28px; height: 28px;
  font-size: 17px;
  background: #f4d13a;
  border: 2px solid rgba(255,255,255,0.9);
  overflow: hidden;
  z-index: 5;
}
.msb-root .player.ball svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.msb-root .player.ball.msb-ball-emoji { background: radial-gradient(circle at 35% 30%, #a0653d, #6b3410); }
/* 修正: サッカーボール（白黒・円形）マーカー */
.msb-root .player.ball.msb-ball-soccer {
  width: 28px; height: 28px;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: hidden;
}
/* 修正: ラグビーボール（楕円形・茶色）マーカー */
.msb-root .player.ball.msb-ball-rugby {
  width: 34px; height: 22px;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}
.msb-root .player.ball.dragging { z-index: 7; }

/* ===== 記録中インジケーター ===== */
/* 修正(v3.2.0): ヘッダー廃止に伴い位置調整 */
/* 修正(v3.2.0・再修正): ヒント文の帯(56px)のすぐ下に来るよう再調整 */
/* 修正(v3.2.2): 2分割比較時、コート左上のA面バッジと重なっていたため、強調表示ヒントと
   同じ高さ(top:116px)まで下げて回避した */
.msb-root .msb-recording-indicator {
  position: fixed; left: 16px; top: 116px;
  display: none;
  background: #ef4444; color: #fff; font-size: 12px; font-weight: bold;
  padding: 6px 14px; border-radius: 999px; z-index: 15;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ===== 速度パネル（右側・ツールバーの上に縦配置） ===== */
.msb-root .msb-speed-panel {
  position: fixed; right: 16px; bottom: 380px;
  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;
  z-index: 10;
}
.msb-root .msb-speed-val { font-size: 12px; font-weight: bold; color: #1e3a5f; }
.msb-root .msb-speed-label { font-size: 10px; font-weight: bold; color: #6b7e99; }
/* 修正: 縦向きのスライダー（Chrome/Safari と Firefox の両方に対応） */
.msb-root .msb-speed-slider {
  width: 8px;
  height: 110px;
  writing-mode: vertical-lr;
  direction: rtl;
  accent-color: #d4af37;
  cursor: pointer;
}

/* ===== 右下ツールバー ===== */
.msb-root .msb-toolbar {
  position: fixed; right: 16px; bottom: 20px;
  display: flex; flex-direction: column; gap: 12px; z-index: 10;
}
.msb-root .msb-btn {
  width: 60px; height: 60px; border-radius: 999px; border: none;
  font-size: 22px; cursor: pointer; box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s; -webkit-tap-highlight-color: transparent;
  background: #fff; color: #7F8C8D; border: 2px solid #dde4ef;
}
.msb-root .msb-btn:active { transform: scale(0.92); }
.msb-root .msb-btn:disabled { opacity: 0.35; cursor: default; }
.msb-root .msb-btn:disabled:active { transform: none; }
.msb-root .msb-btn-confirm { background: #10b981; color: #fff; }
.msb-root .msb-btn-danger { background: #fff; color: #ef4444; border-color: #ef4444; }
.msb-root .msb-btn-primary { background: #d4af37; color: #fff; }
.msb-root .msb-btn-setting { background: #fff; color: #1e3a5f; border: 2px solid #1e3a5f; }

/* 修正: 攻撃／守備追加ボタンは＋マークなしのボール表示に */
.msb-root .msb-ball-btn { border: none; }
.msb-root .msb-ball-btn.msb-ball-offense { background: linear-gradient(135deg, #FF6B6B, #FF8E53); }
.msb-root .msb-ball-btn.msb-ball-defense { background: linear-gradient(135deg, #4ECDC4, #44A08D); }
.msb-root .msb-ball-btn.msb-ball-ball { background: #fff; padding: 6px; }
.msb-root .msb-ball-btn.msb-ball-ball svg { width: 100%; height: 100%; border-radius: 50%; display: block; }
.msb-root .msb-ball-btn.msb-ball-ball.msb-ball-emoji { background: radial-gradient(circle at 35% 30%, #a0653d, #6b3410); font-size: 22px; padding: 0; }
/* 修正: サッカー／ラグビーのボールボタンもマーカーと同じ見た目に */
.msb-root .msb-ball-btn.msb-ball-ball.msb-ball-soccer { background: #fff; padding: 8px; }
.msb-root .msb-ball-btn.msb-ball-ball.msb-ball-rugby { background: #fff; padding: 14px 8px; }
.msb-root .msb-ball-btn.msb-ball-ball.msb-ball-rugby svg { border-radius: 0; }
/* 修正: hasBall:false のスポーツが増えた場合はボタンごと隠す（.hiddenを流用） */

/* 戻る／進む（アンドゥ・リドゥ）のペアボタン（縦積み） */
.msb-root .msb-btn-pair {
  display: flex; flex-direction: column;
  border-radius: 999px; overflow: hidden;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}
.msb-root .msb-btn-pair button {
  width: 60px; height: 30px; border: none; background: #fff; color: #7F8C8D;
  font-size: 16px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.msb-root .msb-btn-pair button:first-child { border-bottom: 1px solid #dde4ef; }
.msb-root .msb-btn-pair button:disabled { opacity: 0.35; cursor: default; }
.msb-root .msb-btn-pair button:active { background: #eef2f6; }

/* ===== フレームメッセージ ===== */
/* 修正(v3.2.0): ヘッダー廃止に伴い位置調整 */
/* 修正(v3.2.0・再修正): ヒント文の帯(56px)＋強調表示ヒント(top:64px)のすぐ下に来るよう再調整 */
/* 修正(v3.2.2): 強調表示ヒントを116pxまで下げたため、その下に来るよう再調整 */
.msb-root .msb-frame-message {
  position: fixed; left: 50%; top: 152px; transform: translateX(-50%);
  display: none;
  background: rgba(30,58,95,0.9); color: #fff; font-size: 13px; font-weight: bold;
  padding: 8px 18px; border-radius: 999px; z-index: 16;
}

/* ===== 選手名編集モーダル ===== */
.msb-root .msb-name-edit-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;
}
.msb-root .msb-name-edit-content {
  background: #fff; border-radius: 16px; padding: 24px;
  width: min(94vw, 460px); max-height: 88vh; overflow-y: auto;
}
.msb-root .msb-name-edit-content h3 { font-size: 17px; color: #1e3a5f; margin: 0 0 14px; text-align: center; }
.msb-root .msb-name-edit-content h4 { font-size: 13px; margin: 14px 0 8px; }
.msb-root .msb-offense-label { color: #e8534a; }
.msb-root .msb-defense-label { color: #2196a8; }
.msb-root .msb-name-input-group { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.msb-root .msb-name-input-group label { width: 40px; font-size: 13px; font-weight: bold; flex-shrink: 0; }
.msb-root .msb-name-input-group input {
  flex: 1; padding: 8px 10px; border-radius: 8px; border: 2px solid #dde4ef;
  font-size: 13px; font-family: inherit;
}

.msb-root .hidden { display: none !important; }
