/* ============================================================
   style.css — 高仰角弾道シミュレーター  v1.2
   ============================================================ */

/* ---- ラッパー ---- */
.bsim-wrapper {
    font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    color: #222;
    max-width: 900px;
    margin: 0 auto;
    padding: 12px;
    box-sizing: border-box;
}

/* ---- タイトル ---- */
.bsim-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a3550;
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid #5b9bd5;
}

/* ============================================================
   コントロールパネル
   ============================================================ */
.bsim-controls {
    background: #f5f7fa;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    padding: 16px 18px 14px;
    margin-bottom: 14px;
}

/* ============================================================
   コントロールグリッド — PC:2列 / モバイル:1列
   ============================================================ */
.bsim-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

/* カード（各項目ブロック） — 縦積み: ラベル → 入力 → スライダー */
.bsim-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #fff;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    padding: 10px 12px 12px;
    box-sizing: border-box;
}

/* 全幅カード（単位系・プリセット） */
.bsim-card--full {
    grid-column: 1 / -1;
}

/* カード内ラベル */
.bsim-card-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* 後方互換: 旧 .bsim-label は管理者パネルで使用しているため残す */
.bsim-label {
    font-size: 15px;
    color: #444;
    white-space: nowrap;
}

.bsim-input {
    width: 72px;
    padding: 4px 6px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 15px;
    text-align: right;
    background: #fff;
    color: #222;
    box-sizing: border-box;
}

/* カード内では幅100%に広げる */
.bsim-input--full {
    width: 100%;
    font-size: 17px;
    padding: 6px 8px;
    text-align: left;
}

.bsim-input:focus {
    outline: none;
    border-color: #5b9bd5;
    box-shadow: 0 0 0 2px rgba(91,155,213,0.22);
}

.bsim-select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 15px;
    background: #fff;
    color: #222;
    cursor: pointer;
    box-sizing: border-box;
}

.bsim-unit-toggle {
    display: flex;
    gap: 18px;
    font-size: 15px;
}

.bsim-unit-toggle label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ============================================================
   プリセット 2列
   ============================================================ */
.bsim-preset-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.bsim-preset-col {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bsim-preset-sublabel {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================================
   ボタン — 全種統一の淡いブルー
   ============================================================ */
.bsim-buttons {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.bsim-btn {
    padding: 8px 24px;
    border: 1px solid #5b9bd5;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.04em;
    background: #daeaf7;
    color: #1a3550;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    -webkit-user-select: none;
    user-select: none;
}

.bsim-btn:hover:not(:disabled) {
    background: #b8d8f0;
    border-color: #3d7db3;
}

.bsim-btn:active:not(:disabled) {
    transform: scale(0.97);
    background: #9ccae8;
}

.bsim-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    transform: none;
}

/* 保存ボタン（管理者パネル内） */
.bsim-btn--save {
    padding: 7px 20px;
    font-size: 15px;
}

/* ============================================================
   HUD
   ============================================================ */
.bsim-hud {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

@media (max-width: 600px) {
    .bsim-hud { grid-template-columns: repeat(2, 1fr); }
}

.bsim-hud-item {
    background: #1a3550;
    border-radius: 8px;
    padding: 12px 10px;
    text-align: center;
    color: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.bsim-hud-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #90caf9;
    margin-bottom: 5px;
}

.bsim-hud-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #e3f2fd;
    letter-spacing: 0.02em;
}

/* ============================================================
   チャートエリア — 高さ500px固定・幅100%
   ============================================================ */
.bsim-chart-wrap {
    background: #fff;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    width: 100%;
    height: 500px;          /* 高さ固定 */
    box-sizing: border-box;
    margin-bottom: 14px;
}

#bsim-canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ============================================================
   管理者パネル
   ============================================================ */
.bsim-admin-panel {
    background: #f0f4f8;
    border: 1px solid #c5d5e8;
    border-left: 4px solid #5b9bd5;
    border-radius: 8px;
    padding: 16px 18px 14px;
    margin-top: 8px;
}

.bsim-admin-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a3550;
    margin: 0 0 14px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

/* 3行グリッド（K / Cd / Lag） */
.bsim-admin-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
}

.bsim-admin-row {
    display: grid;
    grid-template-columns: 220px 1fr;
    align-items: center;
    gap: 12px;
}

.bsim-admin-label {
    font-size: 15px;
    color: #333;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bsim-admin-hint {
    font-size: 12px;
    color: #888;
    font-weight: 400;
}

/* スピナー（−  入力  ＋） */
.bsim-spinner {
    display: flex;
    align-items: center;
    gap: 0;
    width: fit-content;
}

.bsim-admin-input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid #bbb;
    border-left: none;
    border-right: none;
    border-radius: 0;
    font-size: 16px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    background: #fff;
    color: #222;
    -moz-appearance: textfield;
    outline: none;
    box-sizing: border-box;
}

/* 終端速度など整数値が大きい項目用の幅広バリアント */
.bsim-admin-input--wide {
    width: 96px;
}

.bsim-admin-input::-webkit-inner-spin-button,
.bsim-admin-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bsim-admin-input:focus {
    background: #f0f7ff;
    border-color: #5b9bd5;
    border-left: 1px solid #5b9bd5;
    border-right: 1px solid #5b9bd5;
    z-index: 1;
    position: relative;
}

/* −/＋ ボタン */
.bsim-spin-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #bbb;
    background: #daeaf7;
    color: #1a3550;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
}

.bsim-spin-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.bsim-spin-btn:last-child {
    border-radius: 0 4px 4px 0;
}

.bsim-spin-btn:hover {
    background: #b8d8f0;
    border-color: #5b9bd5;
}

.bsim-spin-btn:active {
    background: #9ccae8;
}

/* 管理者フッター（保存ボタン + メッセージ） */
.bsim-admin-footer {
    display: flex;
    align-items: center;
    gap: 14px;
}

.bsim-admin-msg {
    font-size: 15px;
    color: transparent;
    transition: color 0.2s;
}

.bsim-admin-msg--ok  { color: #2e7d32; font-weight: 600; }
.bsim-admin-msg--err { color: #c62828; font-weight: 600; }

/* ============================================================
   レスポンシブ — モバイル (≤640px): グリッドを1列に
   ============================================================ */
@media (max-width: 640px) {
    /* グリッド: 1列 */
    .bsim-grid {
        grid-template-columns: 1fr;
    }

    /* 全幅カードはそのまま（grid-column指定が有効） */
    .bsim-card--full {
        grid-column: 1;
    }

    /* プリセット: 縦積み */
    .bsim-preset-cols {
        grid-template-columns: 1fr;
    }

    /* 単位系ラジオ: 縦並び */
    .bsim-unit-toggle {
        flex-direction: column;
        gap: 6px;
    }

    /* チャート高さ */
    .bsim-chart-wrap { height: 280px; }

    /* タイトル */
    .bsim-title { font-size: 1.2rem; }

    /* ボタン: 均等幅 */
    .bsim-btn { flex: 1; padding: 10px 8px; font-size: 16px; }

    /* HUD: 2列 */
    .bsim-hud { grid-template-columns: repeat(2, 1fr); }

    /* 管理者パネル */
    .bsim-admin-row { grid-template-columns: 1fr; gap: 5px; }
}

/* ============================================================
   速度単位トグル（HUD内）
   ============================================================ */

/* HUD速度アイテムは縦並びにしてトグルを下に収める */
.bsim-hud-item:has(.bsim-speed-toggle) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* トグルボタン群のコンテナ */
.bsim-speed-toggle {
    display: flex;
    gap: 0;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.25);
}

/* 各トグルボタン */
.bsim-speed-btn {
    flex: 1;
    padding: 2px 7px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    background: rgba(255,255,255,0.10);
    color: #90caf9;
    border: none;
    border-right: 1px solid rgba(255,255,255,0.15);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.6;
}

.bsim-speed-btn:last-child {
    border-right: none;
}

.bsim-speed-btn:hover {
    background: rgba(255,255,255,0.20);
    color: #e3f2fd;
}

/* アクティブ状態 */
.bsim-speed-btn--active {
    background: rgba(91,155,213,0.55);
    color: #fff;
}

.bsim-speed-btn--active:hover {
    background: rgba(91,155,213,0.70);
}

/* ============================================================
   スライダー (.bsim-slider) — カード内でフル幅表示
   ============================================================ */
.bsim-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: #ddd;
  border-radius: 4px;
  outline: none;
  margin: 0;
  /* 棒の部分へのクリックを無効化 */
  pointer-events: none;
  cursor: default;
}

/* つまみ部分（Chrome, Safari, Edge用） */
.bsim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  background: #5b9bd5;
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  /* つまみ部分だけ操作を有効化 */
  pointer-events: auto;
  margin-top: -3px;
}

/* つまみ部分（Firefox用） */
.bsim-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  background: #5b9bd5;
  cursor: pointer;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  pointer-events: auto;
}

/* トラック部分（Firefox用） */
.bsim-slider::-moz-range-track {
  pointer-events: none;
  background: #ddd;
  height: 8px;
  border-radius: 4px;
}

/* モバイル: つまみを少し大きく */
@media (max-width: 640px) {
  .bsim-slider::-webkit-slider-thumb { width: 34px; height: 34px; }
  .bsim-slider::-moz-range-thumb     { width: 34px; height: 34px; }
}