/* --- モバイル対応（画面幅 768px 以下） --- */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        /* サイドバーを上に配置（または隠す） */
        overflow-y: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 10px;
        overflow-y: visible;
    }

    .main-content {
        height: auto;
        min-height: 100vh;
    }

    .header-nav {
        flex-direction: column;
        height: auto;
        padding: 10px;
        gap: 10px;
    }

    .control-group {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    #symbol-search {
        width: 100% !important;
        margin-bottom: 8px;
    }

    #symbol-select {
        flex: 1;
        min-width: 120px;
    }

    #range-btns {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 4px;
    }

    .chart-grid {
        display: block;
        /* グリッドを解除 */
        padding: 5px;
    }

    .chart-area {
        height: 300px;
        /* 各チャートに高さを固定 */
        margin-bottom: 10px;
    }

    /* メインチャートだけ少し大きく */
    .chart-area:first-child {
        height: 350px;
    }

    /* 数値表示の調整 */
    .pl-value-main {
        font-size: 20px;
    }

    #price-live {
        font-size: 32px;
        text-align: center;
        width: 100%;
        margin: 5px 0;
    }

    /* スクロールをスムーズに */
    .sidebar,
    .main-content {
        overflow-y: visible;
    }

    /* --- 追加：メニューボタンのスタイル --- */
    #mobile-menu-btn {
        display: block;
        position: fixed;
        bottom: 20px;
        right: 20px;
        background: var(--accent);
        color: #000;
        padding: 12px 20px;
        border-radius: 50px;
        font-weight: bold;
        z-index: 9999;
        box-shadow: 0 4px 15px rgba(0, 242, 255, 0.4);
    }

    /* --- 追加：ナビメニューのスタイル --- */
    #mobile-nav {
        position: fixed;
        top: 0;
        left: -100%;
        /* 初期状態は隠す */
        width: 250px;
        height: 100%;
        background: var(--panel-bg);
        border-right: 2px solid var(--accent);
        z-index: 10000;
        transition: 0.3s;
        display: flex;
        flex-direction: column;
        padding: 20px;
    }

    #mobile-nav.open {
        left: 0;
    }

    #mobile-nav a {
        color: white;
        text-decoration: none;
        padding: 15px;
        border-bottom: 1px solid var(--border);
        font-size: 16px;
    }

    .menu-close {
        text-align: right;
        font-size: 24px;
        color: var(--accent);
        margin-bottom: 20px;
    }

    /* スムーズスクロールを有効化 */
    html {
        scroll-behavior: smooth;
    }

    canvas {
        /* 縦方向のスクロール(pan-y)をブラウザに許可し、
                ピンチ操作などはJS側に任せる設定 */
        touch-action: pan-y !important;
        -webkit-tap-highlight-color: transparent;
    }

    .chart-area {
        /* チャートエリアでの操作が外に漏れすぎないよう、かつスクロールを妨げない */
        position: relative;
        overflow: hidden;
    }
}

@media (max-width: 768px) {
    .chart-grid {
        display: block;
        padding: 10px 15px;
        /* 左右の余白を少し増やす */
    }

    .chart-area {
        margin-bottom: 20px;
        /* チャート間の隙間を広げてスクロールの「逃げ道」を作る */
    }
}

/* PC版ではボタンを隠す */
@media (min-width: 769px) {

    #mobile-menu-btn,
    #mobile-nav {
        display: none;
    }
}