/**
 * 安全なパフォーマンス最適化CSS
 * レイアウト崩れを避けつつ、効果的な最適化を適用
 */

/* ========================================
   安全なGPU加速（メインキャンバスのみ）
   ======================================== */

/* メインゲームキャンバスのみGPU加速 */
#gameCanvas {
    /* GPU加速 */
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* エフェクトキャンバス */
#effectCanvas,
#backgroundCanvas {
    /* 軽量なGPU加速 */
    transform: translateZ(0);
}

/* ========================================
   安全なcontain使用
   ======================================== */

/* ゲーム全体のコンテナ */
#gameContainer,
.game-wrapper {
    /* paintのみ（レイアウト崩れを防ぐ） */
    contain: paint;
}

/* ========================================
   フォント最適化
   ======================================== */

body {
    /* フォント読み込みの最適化 */
    font-display: swap;
}

/* ========================================
   アニメーション最適化
   ======================================== */

/* 頻繁に動く要素 */
.moving-piece,
.falling-block {
    /* アニメーション時のみGPU加速 */
    will-change: transform;
}

/* アニメーション完了後はwill-changeを削除 */
.animation-complete {
    will-change: auto;
}

/* ========================================
   画像最適化
   ======================================== */

img {
    /* 画像のデコードを非同期に */
    content-visibility: auto;
}

/* ========================================
   タッチフィードバック最適化
   ======================================== */

button,
.touch-button,
.control-button {
    /* タップフィードバックを軽量化 */
    transition: opacity 0.1s ease-out;
}

button:active,
.touch-button:active {
    opacity: 0.8;
}

/* ========================================
   低スペックモード
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   スコア表示の最適化
   ======================================== */

#score,
#level,
#lines {
    /* 数値更新時のレイアウトシフトを防ぐ */
    font-variant-numeric: tabular-nums;
    display: inline-block;
}

/* ========================================
   NEXT/HOLDピース表示の保護
   ======================================== */

#nextDisplay,
#holdDisplay,
#next2Display,
#next3Display {
    /* 元のレイアウトを維持 */
    position: relative !important;
    width: auto !important;
    height: auto !important;
}

#nextCanvas,
#holdCanvas,
#next2Canvas,
#next3Canvas {
    /* 元のサイズを維持 */
    position: relative !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
}

/* ========================================
   モバイル最適化
   ======================================== */

@media (max-width: 768px) {
    /* モバイルでの過度な最適化を避ける */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* スクロールの最適化 */
    .scrollable {
        -webkit-overflow-scrolling: touch;
    }
}