/**
 * VirtualController - 共通CSS
 * グリッドベース コントローラーレイアウト
 * Ver.0.008 20260114-19:30
 */

/* CSS Variables for theming */
:root {
    --vc-primary: #44aa44;
    --vc-primary-bg: rgba(68, 170, 68, 0.6);
    --vc-primary-active: rgba(68, 170, 68, 0.9);

    --vc-secondary: #cc4444;
    --vc-secondary-bg: rgba(204, 68, 68, 0.6);
    --vc-secondary-active: rgba(204, 68, 68, 0.9);

    --vc-tertiary: #ffaa44;
    --vc-tertiary-bg: rgba(255, 170, 68, 0.6);
    --vc-tertiary-active: rgba(255, 170, 68, 0.9);

    --vc-blue: #4488cc;
    --vc-blue-bg: rgba(68, 136, 204, 0.6);
    --vc-blue-active: rgba(68, 136, 204, 0.9);
}

/* ============================================
   Container - 左右分割レイアウト
   ============================================ */
.virtual-controls {
    display: none;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 10px 15px;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    gap: 20px;
}

/* ============================================
   D-pad - 3x3 グリッド配置（十字キー）
   ============================================ */
.vc-dpad {
    display: grid !important;
    grid-template-columns: 50px 50px 50px !important;
    grid-template-rows: 50px 50px 50px !important;
    gap: 2px;
    pointer-events: auto;
    width: 156px;
    height: 156px;
}

.vc-dpad-btn {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    background: var(--vc-primary-bg);
    border: 2px solid var(--vc-primary);
    color: #fff;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.vc-dpad-btn:active {
    background: var(--vc-primary-active);
    transform: scale(0.95);
}

/* 空セル（四隅と中央）- 非表示ボタン */
.vc-dpad-spacer {
    width: 50px;
    height: 50px;
    visibility: hidden;
}

/* ============================================
   Action Buttons - 2x2 グリッド配置（SFC準拠）
   配置: Y | X
         B | A
   ============================================ */
.vc-action-btns {
    display: grid;
    grid-template-columns: repeat(2, 60px);
    grid-template-rows: repeat(2, 60px);
    gap: 4px;
    pointer-events: auto;
}

.vc-action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--vc-primary-bg);
    border: 2px solid var(--vc-primary);
    color: #fff;
    font-size: 1.1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0,0,0,0.4);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.vc-action-btn:active {
    background: var(--vc-primary-active);
    transform: scale(0.92);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* SFC配置: 左上=Y、右上=X、左下=B、右下=A */
.vc-btn-y { grid-column: 1; grid-row: 1; }
.vc-btn-x { grid-column: 2; grid-row: 1; }
.vc-btn-b { grid-column: 1; grid-row: 2; }
.vc-btn-a { grid-column: 2; grid-row: 2; }

/* Secondary (B/赤) */
.vc-action-btn.vc-secondary {
    background: var(--vc-secondary-bg);
    border-color: var(--vc-secondary);
}

.vc-action-btn.vc-secondary:active {
    background: var(--vc-secondary-active);
}

/* Tertiary (Y/黄) */
.vc-action-btn.vc-tertiary {
    background: var(--vc-tertiary-bg);
    border-color: var(--vc-tertiary);
}

.vc-action-btn.vc-tertiary:active {
    background: var(--vc-tertiary-active);
}

/* Blue (X/青) */
.vc-action-btn.vc-blue {
    background: var(--vc-blue-bg);
    border-color: var(--vc-blue);
}

.vc-action-btn.vc-blue:active {
    background: var(--vc-blue-active);
}

/* ============================================
   ボタンが少ない場合のバリエーション
   ============================================ */

/* 1ボタンのみ (Aだけ) */
.vc-action-btns.vc-single {
    grid-template-columns: 65px;
    grid-template-rows: 65px;
}

.vc-action-btns.vc-single .vc-action-btn {
    width: 65px;
    height: 65px;
    grid-column: 1;
    grid-row: 1;
}

/* 2ボタン (A/B - 右列のみ or 下行のみ) */
.vc-action-btns.vc-two-vertical {
    grid-template-columns: 60px;
    grid-template-rows: repeat(2, 60px);
}

.vc-action-btns.vc-two-horizontal {
    grid-template-columns: repeat(2, 60px);
    grid-template-rows: 60px;
}

/* 非表示のボタン */
.vc-action-btn.vc-hidden {
    visibility: hidden;
    pointer-events: none;
}

/* ============================================
   Responsive - モバイル表示
   ============================================ */
@media (pointer: coarse), (max-width: 800px) {
    .virtual-controls {
        display: flex;
    }

    .controls-help {
        display: none;
    }
}

/* デスクトップでは非表示 */
@media (pointer: fine) and (min-width: 801px) {
    .virtual-controls {
        display: none !important;
    }
}

/* 小さい画面用の調整 */
@media (max-width: 400px) {
    .virtual-controls {
        padding: 8px 10px;
        gap: 10px;
    }

    .vc-dpad {
        grid-template-columns: 42px 42px 42px !important;
        grid-template-rows: 42px 42px 42px !important;
        width: 130px;
        height: 130px;
    }

    .vc-dpad-btn {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }

    .vc-dpad-spacer {
        width: 42px;
        height: 42px;
    }

    .vc-action-btns {
        grid-template-columns: repeat(2, 50px);
        grid-template-rows: repeat(2, 50px);
    }

    .vc-action-btn {
        width: 50px;
        height: 50px;
        font-size: 0.95rem;
    }

    .vc-action-btns.vc-single {
        grid-template-columns: 55px;
        grid-template-rows: 55px;
    }

    .vc-action-btns.vc-single .vc-action-btn {
        width: 55px;
        height: 55px;
    }
}
