/* ===== テトリスモンスターズ CSS構造 ===== */
/* Phase A: 基盤整備システム */

/* CSS変数システムの読み込み - 色・サイズ・タイミングの一元管理 */
@import url('./css/base/variables.css');

/* ブラウザリセット（既存box-sizingと独立） */
@import url('./css/base/reset.css');

/* レスポンシブブレークポイント統合システム（Phase B.3） */
@import url('./css/base/breakpoints.css');

/* タイポグラフィ統合システム（Phase B.4） */
@import url('./css/base/typography.css');

/* ユーティリティクラスシステム - よく使われるパターンの共通化 */
@import url('./css/utilities/layout.css');    /* Flexbox/Grid/位置関係 */
@import url('./css/utilities/spacing.css');   /* マージン・パディング・ギャップ */
@import url('./css/utilities/touch.css');     /* タッチ制御用クラス */
@import url('./css/utilities/display.css');   /* 表示制御用クラス */
@import url('./css/utilities/colors.css');    /* 色関係ユーティリティ（新規追加）*/
@import url('./css/utilities/animations.css'); /* アニメーション・トランジション統合（Phase B.1継続）*/

/* コンポーネントシステム - 再利用可能なコンポーネント */
@import url('./css/components/buttons.css');  /* ボタン共通スタイル（レベル3追加）*/
@import url('./css/components/modals.css');   /* モーダル・オーバーレイ共通スタイル（レベル3追加）*/
@import url('./css/components/cards.css');    /* カード系コンポーネント共通スタイル（レベル3追加）*/

/* レイアウトシステム - 画面構成・配置管理 */
@import url('./css/layout/touch-control.css'); /* タッチ制御ルール統合（Phase B.2追加）*/

/* ===== 既存メインスタイル ===== */

/* ボックスモデルの統一 - borderを含む高さ・幅計算 */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ルートレベルでのブラウザ操作阻止（ゲーム画面でのみ適用） */
/* Phase B.1: !important削除 - ユーティリティクラス活用による詳細度管理正常化 */
html.game-active {
    touch-action: none;
    overscroll-behavior: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ゲーム画面でのbody背景グラデーション */
html.game-active body {
    background: var(--game-bg-gradient);
}

/* ゲーム画面以外では通常のタッチ操作を許可 */
html:not(.game-active) {
    touch-action: manipulation;
    overscroll-behavior: auto;
}

/* ゲーム画面でのタッチ操作を精密に無効化（制御ボタンは除外） */
html.game-active :not(.control-button):not(.pause-button):not(.title-button):not(.game-controls):not(#pauseButton):not(#titleButton), 
html.game-active :not(.control-button):not(.pause-button):not(.title-button):not(.game-controls):not(#pauseButton):not(#titleButton)::before, 
html.game-active :not(.control-button):not(.pause-button):not(.title-button):not(.game-controls):not(#pauseButton):not(#titleButton)::after {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ゲーム画面以外では通常のタッチ操作を許可 */
html:not(.game-active) *, 
html:not(.game-active) *::before, 
html:not(.game-active) *::after {
    touch-action: manipulation;
    -webkit-touch-callout: default;
}

/* 制御ボタンは常にタッチ操作を許可（ゲーム画面でも） - 最高特定度 */
html.game-active .control-button,
html.game-active .control-button:before,
html.game-active .control-button:after,
html.game-active .game-controls,
html.game-active .game-controls *,
html.game-active .pause-button,
html.game-active .title-button,
html.game-active #pauseButton,
html.game-active #titleButton,
html.game-active button.control-button,
html.game-active button.pause-button,
html.game-active button.title-button {
    touch-action: manipulation !important;
    pointer-events: auto !important;
    -webkit-touch-callout: default !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;
}

/* モンスター図鑑・ランキング関連の要素はタッチ操作を許可 */
.encyclopedia-screen *,
.encyclopedia-content *,
.encyclopedia-grid *,
.monster-card,
.monster-card *,
.monster-detail-modal,
.monster-detail-modal *,
.monster-detail-content,
.monster-detail-content *,
.monster-detail-close,
.ranking-screen *,
.ranking-content *,
.ranking-list *,
.ranking-item,
.ranking-item *,
.title-screen *,
.title-btn,
.title-btn *,
.settings-screen *,
.tutorial-screen *,
button {
    touch-action: manipulation;
    -webkit-touch-callout: default;
}

/* ゲーム中モーダル画面のタッチ操作を許可 - 高優先度セレクター */
html.game-active .modal-overlay,
html.game-active .modal-overlay *,
html.game-active .modal-dialog,
html.game-active .modal-dialog *,
html.game-active .modal-content,
html.game-active .modal-content *,
html.game-active .modal-close,
html.game-active .settings-content,
html.game-active .settings-content *,
html.game-active .settings-tabs,
html.game-active .settings-tabs *,
html.game-active .settings-tab,
html.game-active .settings-tab *,
html.game-active .settings-tab-content,
html.game-active .settings-tab-content *,
html.game-active .setting-item,
html.game-active .setting-item *,
html.game-active input[type="range"],
html.game-active input[type="checkbox"],
html.game-active select,
html.game-active .volume-slider-container,
html.game-active .volume-slider-container *,
html.game-active .mute-btn,
html.game-active .performance-level-section,
html.game-active .performance-level-section *,
html.game-active .custom-settings-section,
html.game-active .custom-settings-section *,
html.game-active .settings-actions,
html.game-active .settings-actions *,
html.game-active .settings-btn,
html.game-active .level-option,
html.game-active .level-option *,
html.game-active .custom-setting,
html.game-active .custom-setting * {
    touch-action: manipulation;
    -webkit-touch-callout: default;
    pointer-events: auto;
    user-select: auto;
    -webkit-user-select: auto;
}

/* モンスター詳細モーダルの強制的なタッチ有効化 */
#monsterDetailModal,
#monsterDetailModal *,
#monsterDetailClose {
    touch-action: manipulation;
    pointer-events: auto;
    -webkit-touch-callout: default;
    user-select: none;
    -webkit-user-select: none;
}

/* スクロール可能な要素はタッチスクロールを許可 */
.encyclopedia-grid,
.ranking-list,
.monster-detail-content,
.settings-content,
.tutorial-content {
    touch-action: pan-y;
}

/* ===== ローディング画面スタイル ===== */
/* JS依存: loadingScreen(ID) - audioChoiceManager.jsで制御 */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh; /* フォールバック */
    height: 100dvh; /* 動的ビューポート対応 */
    background: linear-gradient(135deg, var(--dark-bg-primary) 0%, var(--dark-bg-tertiary) 50%, var(--dark-bg-secondary) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: var(--ui-text-primary);
    max-width: 400px;
    width: 90%;
}

.company-logo {
    margin-bottom: 30px;
    animation: logoFadeIn 1s ease-out;
}

.logo-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.4));
    animation: logoGlow 2s ease-in-out infinite alternate;
}

.loading-text {
    margin-bottom: 40px;
}

.loading-title-image {
    width: 90%;
    max-width: 500px;
    min-width: 250px;
    height: auto;
    margin-bottom: 10px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.8));
    animation: titleSlideIn 1s ease-out 0.3s both;
}

.loading-subtitle {
    font-size: 1.2rem;
    color: var(--ui-text-secondary);
    margin: 0;
    animation: subtitleFadeIn 1s ease-out 0.6s both;
}

.loading-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    margin-bottom: 30px;
    overflow: hidden;
    animation: barSlideIn 1s ease-out 0.9s both;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #ffd700 0%, #ffed4e 50%, #ffd700 100%);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.loading-progress::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.5) 100%);
    animation: progressShine 1.5s ease-in-out infinite;
}

.loading-spinner {
    animation: spinnerFadeIn 1s ease-out 1.2s both;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 215, 0, 0.3);
    border-top: 3px solid #ffd700;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

/* ローディングアニメーション */
@keyframes logoFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes logoGlow {
    from {
        filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.4));
    }
    to {
        filter: drop-shadow(0 0 40px rgba(255, 255, 255, 1.0)) 
                drop-shadow(0 0 80px rgba(255, 255, 255, 0.8))
                drop-shadow(0 0 120px rgba(255, 255, 255, 0.6));
    }
}

@keyframes titleSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes subtitleFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes barSlideIn {
    from {
        opacity: 0;
        transform: scaleX(0);
    }
    to {
        opacity: 1;
        transform: scaleX(1);
    }
}

@keyframes spinnerFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes progressShine {
    0% { transform: translateX(-20px); }
    100% { transform: translateX(20px); }
}

/* === 音声設定選択画面 === */
.audio-choice-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh; /* フォールバック */
    height: 100dvh; /* 動的ビューポート対応 */
    background: linear-gradient(135deg, #2c1810 0%, #8b4513 50%, #654321 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9998;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.audio-choice-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.audio-choice-content {
    text-align: center;
    color: var(--ui-text-primary);
    max-width: 500px;
    width: 90%;
}

.audio-choice-logo {
    margin-bottom: 30px;
}

.choice-logo-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.3));
}

.audio-choice-title {
    font-size: 2rem;
    font-size: clamp(1.2rem, 4vw, 2rem);
    color: #ffd700;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-weight: bold;
    white-space: nowrap;
}

.audio-choice-subtitle {
    font-size: 1rem;
    color: var(--ui-text-secondary);
    margin-bottom: 40px;
    line-height: 1.5;
}

.audio-choice-buttons {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.audio-choice-btn {
    background: linear-gradient(135deg, #4a2c2a 0%, #6b3e3e 100%);
    border: 2px solid #ffd700;
    border-radius: 15px;
    padding: 30px 20px;
    min-width: 200px;
    color: var(--ui-text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.audio-choice-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(255, 215, 0, 0.4);
    border-color: #ffed4e;
    background: linear-gradient(135deg, #5a3a38 0%, #7b4e4e 100%);
}

.audio-choice-btn:active {
    transform: translateY(-2px);
}

.audio-choice-btn.keyboard-selected {
    transform: translateY(-5px);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8) !important;
    border-color: #ffed4e;
    background: linear-gradient(135deg, #5a3a38 0%, #7b4e4e 100%);
    animation: keyboardPulse 2s infinite;
}

@keyframes keyboardPulse {
    0%, 100% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.8); }
    50% { box-shadow: 0 0 40px rgba(255, 215, 0, 1.0); }
}

.choice-btn-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.choice-btn-text {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.choice-btn-desc {
    font-size: 0.9rem;
    color: var(--ui-text-secondary);
    line-height: 1.4;
}

.audio-choice-note {
    font-size: 0.85rem;
    color: #999999;
    margin: 0;
}

/* パフォーマンス案内スタイル */
.performance-notice {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(255, 237, 78, 0.1), rgba(255, 215, 0, 0.1));
    border: 1px solid rgba(255, 237, 78, 0.3);
    border-radius: 8px;
    backdrop-filter: blur(5px);
}

.performance-notice-text {
    margin: 0;
    font-size: 0.9rem;
    color: #ffed4e;
    text-align: center;
    line-height: 1.4;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.performance-icon {
    font-size: 1rem;
    opacity: 0.9;
}

/* === ミュートボタンスタイル === */
.volume-slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mute-btn {
    background: linear-gradient(135deg, #4a4a4a 0%, #6a6a6a 100%);
    border: 1px solid #888;
    border-radius: 6px;
    width: 35px;
    height: 35px;
    color: var(--ui-text-primary);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: inherit;
}

.mute-btn:hover {
    background: linear-gradient(135deg, #5a5a5a 0%, #7a7a7a 100%);
    transform: scale(1.05);
}

.mute-btn:active {
    transform: scale(0.95);
}

.mute-btn.muted {
    background: linear-gradient(135deg, #8b0000 0%, #dc143c 100%);
    border-color: #ff4444;
}

.mute-btn.muted:hover {
    background: linear-gradient(135deg, #a00000 0%, #ff1744 100%);
}


.setting-item .volume-slider-container {
    margin-bottom: 5px;
}

body {
    margin: 0;
    padding: 20px;
    /* ローディング画面と同じ背景で初期表示 */
    background: linear-gradient(135deg, #0f0f0f 0%, #2a2a2a 50%, #1a1a1a 100%);
    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* フォールバック */
    min-height: 100dvh; /* 動的ビューポート対応 */
    color: white;
    transition: all 0.1s ease;
    
    /* タッチ操作のブラウザ干渉を完全防止 */
    touch-action: none;
    overscroll-behavior: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    
    /* 追加のタッチ/ジェスチャー阻止 */
    -webkit-user-drag: none !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-overflow-scrolling: auto !important;
    overscroll-behavior-x: none !important;
    overscroll-behavior-y: none !important;
}

.damage-shake {
    animation: shake 0.5s ease-in-out;
}

.damage-flash {
    background: radial-gradient(circle, rgba(255,0,0,0.3) 0%, rgba(139,69,19,0.5) 100%);
}

@keyframes shake {
    0%, 100% { transform: translateX(0) translateY(0); }
    10% { transform: translateX(-5px) translateY(-3px); }
    20% { transform: translateX(5px) translateY(3px); }
    30% { transform: translateX(-3px) translateY(-5px); }
    40% { transform: translateX(3px) translateY(5px); }
    50% { transform: translateX(-2px) translateY(-2px); }
    60% { transform: translateX(2px) translateY(2px); }
    70% { transform: translateX(-1px) translateY(-3px); }
    80% { transform: translateX(1px) translateY(3px); }
    90% { transform: translateX(-1px) translateY(-1px); }
}

@keyframes monsterDamageShake {
    0%, 100% { transform: translateX(0) translateY(0); }
    15% { transform: translateX(-3px) translateY(-2px); }
    30% { transform: translateX(3px) translateY(2px); }
    45% { transform: translateX(-2px) translateY(-3px); }
    60% { transform: translateX(2px) translateY(3px); }
    75% { transform: translateX(-1px) translateY(-1px); }
    90% { transform: translateX(1px) translateY(1px); }
}

@keyframes monsterDamageFlash {
    0% { 
        background: rgba(0, 0, 0, 0.2);
    }
    50% { 
        background: rgba(255, 255, 255, 0.8);
    }
    100% { 
        background: rgba(0, 0, 0, 0.2);
    }
}

/* 必殺技準備警告ポップアップ */
.special-warning-popup {
    color: #cc0000;
    font-size: 24px;
    font-weight: bold;
}

.special-warning-pulse-red {
    filter: drop-shadow(0 0 20px #cc0000);
}

.special-warning-pulse-orange {
    filter: drop-shadow(0 0 20px #ff6600);
    color: #dd1100;
}

.special-warning-pulse-redorange {
    filter: drop-shadow(0 0 20px #ff3300);
    color: #ee2200;
}

@keyframes specialWarningPulse {
    0% { 
        transform: translateX(-50%) scale(1.0);
        opacity: 1;
    }
    50% { 
        transform: translateX(-50%) scale(1.2);
        opacity: 1;
    }
    100% { 
        transform: translateX(-50%) scale(1.0);
        opacity: 1;
    }
}

/* ポーズオーバーレイ */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1500;
    backdrop-filter: blur(2px);
}

.pause-overlay.active {
    display: flex;
}

.pause-text {
    font-size: 72px;
    font-weight: bold;
    color: white;
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        0 0 20px rgba(255, 255, 255, 0.8);
    font-family: Arial, sans-serif;
    animation: pausePulse 2s ease-in-out infinite;
}

@keyframes pausePulse {
    0% { 
        opacity: 0.8;
        transform: scale(1.0);
    }
    50% { 
        opacity: 1.0;
        transform: scale(1.05);
    }
    100% { 
        opacity: 0.8;
        transform: scale(1.0);
    }
}

/* データリセットボタン */
.data-reset-button {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(139, 69, 19, 0.8);
    color: var(--ui-text-primary);
    border: 2px solid #8b4513;
    border-radius: 5px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    z-index: 99999;
    transition: all 0.3s ease;
    font-family: Arial, sans-serif;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.data-reset-button:hover {
    background: rgba(139, 69, 19, 1);
    border-color: #a0522d;
    transform: scale(1.05);
}

.data-reset-button:active {
    transform: scale(0.95);
}

/* スマホ・タブレット用データリセットボタン調整 */
@media (max-width: 768px), (orientation: portrait) {
    .data-reset-button {
        padding: 12px 16px;
        font-size: 14px;
        top: 15px;
        left: 15px;
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }
}

/* Hold機能スタイル */
.top-info-row {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    margin-bottom: 10px;
    gap: 15px;
    height: auto;
}

.hold-area {
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #4a90e2;
    border-radius: 10px;
    padding: 0;
    min-width: 85px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    position: relative;
}

.hold-area.disabled::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 7px;
    z-index: 1;
}

.hold-header {
    color: #4a90e2;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 6px;
    margin-top: 6px;
    text-align: center;
}

.hold-piece-display {
    width: 90px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}

.hold-canvas {
    border-radius: 5px;
}

/* score-stats-gridの新スタイル（縦並び） */
.score-stats-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #666666;
    border-radius: 10px;
    padding: 0 12px;
    flex-grow: 1;
    max-width: 200px;
    height: 100%;
    justify-content: center;
    box-sizing: border-box;
}

.score-stats-grid .score,
.score-stats-grid .lines,
.score-stats-grid .kills {
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-align: left;
    margin: 0;
    white-space: nowrap;
}

.score-stats-grid .score span,
.score-stats-grid .lines span,
.score-stats-grid .kills span {
    color: white;
    margin-left: 8px;
}

/* ゲーム画面全体のフレーム - リッチなシルバー立体デザイン */
.game-frame {
    position: relative;
    background-image: url('./img/backgrounds/webp/game-frame.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    
    /* 立体的なシルバーフレーム - border-radiusと互換性のあるアプローチ */
    border: 3px solid #c0c0c0;
    border-radius: 10px;
    padding: 25px;
    
    /* 多層立体シャドウ効果 */
    box-shadow: 
        /* 外側の大きな影 */
        0 12px 40px rgba(0, 0, 0, 0.4),
        /* 中間の影 */
        0 6px 20px rgba(0, 0, 0, 0.3),
        /* 内側のハイライト */
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2),
        /* 左右のハイライト/シャドウ */
        inset 2px 0 4px rgba(255, 255, 255, 0.2),
        inset -2px 0 4px rgba(0, 0, 0, 0.15),
        /* 外側のシルバーグロー */
        0 0 30px rgba(192, 192, 192, 0.2);
    
    /* 追加の装飾的な境界線 */
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: -4px;
    
    /* 背景にも立体感を追加 */
    background-color: rgba(248, 248, 255, 0.05);
    
}

/* 立体的な境界線効果のための疑似要素 */
.game-frame::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 13px;
    background: linear-gradient(145deg, 
        #f8f8ff 0%, 
        #e6e6fa 15%, 
        #d3d3d3 30%, 
        #c0c0c0 50%, 
        #a9a9a9 70%, 
        #808080 85%, 
        #696969 100%);
    z-index: -1;
    
    /* 内側の立体効果 */
    box-shadow: 
        inset 0 2px 4px rgba(255, 255, 255, 0.5),
        inset 0 -2px 4px rgba(0, 0, 0, 0.3),
        inset 2px 0 4px rgba(255, 255, 255, 0.3),
        inset -2px 0 4px rgba(0, 0, 0, 0.2);
}

/* 内側のハイライト効果 */
.game-frame::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
    z-index: 1;
}

.game-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    position: relative;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    
    /* タッチ操作を完全に制御 */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.game-controls {
    position: fixed;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    z-index: 2000;
}

.control-button {
    width: 40px;
    height: 40px;
    border: 2px solid #8b4513;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10000; /* ポーズオーバーレイ(1500)より上に表示 */
    position: relative;
}

.control-button:hover {
    background: rgba(139, 69, 19, 0.8);
    border-color: #cd853f;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.control-button:active {
    transform: translateY(0px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.pause-button:hover {
    background: rgba(255, 165, 0, 0.8);
    border-color: #ffa500;
}

.settings-button:hover {
    background: rgba(100, 149, 237, 0.8);
    border-color: #6495ed;
}

.title-button:hover {
    background: rgba(255, 69, 69, 0.8);
    border-color: #ff6b6b;
}

/* 左側のコンテナ（モンスター表示とバトルログ用） */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 250px;
    min-width: 250px;
    height: 600px;
    box-sizing: border-box;
}

.game-board {
    background: #000;
    border: 3px solid #666666;
    border-radius: 10px;
    transition: background-color 0.3s ease;
    
    /* ゲームボード専用タッチ制御 */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    
    /* エフェクトより前面に表示 */
    position: relative;
    z-index: 100;
}

.game-board.special-attack-warning {
    background: #2d0a0a;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.3);
}

.game-board.combo-active {
    background: #1a1a1a;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.4);
    border: 3px solid;
    border-image: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3, #ff0000) 1;
    animation: comboGlow 2s ease-in-out infinite, rainbowBorder 3s linear infinite;
}

.game-board.combo-active.special-attack-warning {
    background: #3d1a1a;
    box-shadow: 0 0 25px rgba(255, 100, 0, 0.5);
    border: 3px solid;
    border-image: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3, #ff0000) 1;
    animation: comboGlow 2s ease-in-out infinite, rainbowBorder 3s linear infinite;
}

.monster-visual {
    position: relative;
    background: transparent;
    border: 3px solid #666666;
    border-radius: 10px;
    width: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 8px;
    box-sizing: border-box;
    flex-shrink: 0;
    transition: background-color 0.1s ease;
}

.monster-visual::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('./img/backgrounds/webp/monster-bg-1.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 1;
    border-radius: inherit;
    pointer-events: none;
}

/* 各背景画像のクラス */
.monster-visual.bg-1::before { background-image: url('./img/backgrounds/webp/monster-bg-1.webp'); }
.monster-visual.bg-2::before { background-image: url('./img/backgrounds/webp/monster-bg-2.webp'); }
.monster-visual.bg-3::before { background-image: url('./img/backgrounds/webp/monster-bg-3.webp'); }
.monster-visual.bg-4::before { background-image: url('./img/backgrounds/webp/monster-bg-4.webp'); }
.monster-visual.bg-5::before { background-image: url('./img/backgrounds/webp/monster-bg-5.webp'); }

.monster-visual::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: 2;
    border-radius: inherit;
    transition: background-color 0.1s ease;
    pointer-events: none;
}

/* monster-visualの子要素を背景より上に表示 */
.monster-visual > * {
    position: relative;
    z-index: 3;
}

.monster-visual.danger-slow::after {
    -webkit-animation: dangerFlashSlow 1.0s infinite;
    animation: dangerFlashSlow 1.0s infinite;
}

.monster-visual.danger-medium::after {
    -webkit-animation: dangerFlashMedium 0.5s infinite;
    animation: dangerFlashMedium 0.5s infinite;
}

.monster-visual.danger-fast::after {
    -webkit-animation: dangerFlashFast 0.2s infinite;
    animation: dangerFlashFast 0.2s infinite;
}

.monster-visual.special-attack::after {
    background: rgba(139, 0, 0, 0.7);
}

.monster-visual.special-attack {
    border-color: #ff2222 !important;
    box-shadow: 0 0 30px rgba(255, 34, 34, 0.6);
}

.monster-visual.damage-effect::after {
    -webkit-animation: monsterDamageFlash 0.3s ease-in-out;
    animation: monsterDamageFlash 0.3s ease-in-out;
}

.monster-image.damage-shake {
    -webkit-animation: monsterDamageShake 0.4s ease-in-out;
    animation: monsterDamageShake 0.4s ease-in-out;
}

@keyframes dangerFlashSlow {
    0%, 50% { 
        background: rgba(0, 0, 0, 0.2);
        border-color: #8b4513;
    }
    100% { 
        background: rgba(139, 0, 0, 0.4);
        border-color: #ff4444;
    }
}

@keyframes dangerFlashMedium {
    0%, 50% { 
        background: rgba(0, 0, 0, 0.2);
        border-color: #8b4513;
    }
    100% { 
        background: rgba(139, 0, 0, 0.5);
        border-color: #ff4444;
    }
}

@keyframes dangerFlashFast {
    0%, 50% { 
        background: rgba(0, 0, 0, 0.2);
        border-color: #8b4513;
    }
    100% { 
        background: rgba(139, 0, 0, 0.6);
        border-color: #ff2222;
    }
}

.monster-image {
    width: 140px;
    height: 140px;
    margin-bottom: 0;
    animation: float 3s ease-in-out infinite;
    object-fit: contain;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.monster-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 0;
}

.monster-level {
    font-size: 14px;
    color: #ffd700;
    font-weight: bold;
    margin: 0;
}

.monster-name {
    font-size: 16px;
    font-weight: bold;
    color: #ff6b6b;
    margin: 0;
    text-align: center;
}

.monster-hp-display {
    width: 100%;
    margin-bottom: 5px;
}

.monster-stats-display {
    margin: 5px 0;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    display: flex;
    gap: 15px;
    width: 100%;
    box-sizing: border-box;
    white-space: nowrap;
}

.monster-stats-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.monster-attack-display,
.monster-defense-display,
.monster-speed-display,
.monster-magic-display {
    font-size: 11px;
    font-weight: bold;
    text-align: center;
}

.monster-attack-display {
    color: #ffa500;
}

.monster-defense-display {
    color: #4169e1;
}

.monster-speed-display {
    color: #90ee90;
}

.monster-magic-display {
    color: #dda0dd;
}

.battle-log {
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #666666;
    border-radius: 10px;
    width: 100%;
    flex: 1;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    max-height: 180px;
    min-height: 0;
}

.battle-log-header {
    background: rgba(102, 102, 102, 0.8);
    color: var(--ui-text-primary);
    font-weight: bold;
    font-size: 14px;
    text-align: center;
    padding: 8px;
    border-bottom: 2px solid #666666;
    border-radius: 7px 7px 0 0;
}

.battle-log-content {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    font-size: 11px;
    line-height: 1.3;
}

.log-entry {
    color: #ddd;
    margin-bottom: 4px;
    padding: 2px 0;
    word-wrap: break-word;
}

.log-entry.damage {
    color: #ff6b6b;
    font-weight: bold;
}

.log-entry.victory {
    color: #ffd700;
    font-weight: bold;
}

.log-entry.heal {
    color: #00ff7f;
    font-weight: bold;
}

.log-entry.level-up {
    color: #87ceeb;
    font-weight: bold;
}

.log-entry.monster-spawn {
    color: #ff69b4;
    font-weight: bold;
}

.log-entry.tspin {
    color: #ff00ff;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255, 0, 255, 0.6);
    animation: tspinLogGlow 1s ease-in-out;
}

@keyframes tspinLogGlow {
    0% {
        text-shadow: 0 0 4px rgba(255, 0, 255, 0.4);
    }
    50% {
        text-shadow: 0 0 12px rgba(255, 0, 255, 0.9), 0 0 20px rgba(255, 215, 0, 0.5);
    }
    100% {
        text-shadow: 0 0 8px rgba(255, 0, 255, 0.6);
    }
}

/* パーフェクトクリア バトルログスタイル */
.log-entry.perfect-clear {
    color: #FFD700;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 107, 0, 0.5);
    animation: perfectClearLogGlow 1.5s ease-in-out;
}

@keyframes perfectClearLogGlow {
    0% {
        text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
        color: #FFD700;
    }
    25% {
        text-shadow: 0 0 15px rgba(255, 107, 0, 1), 0 0 25px rgba(0, 255, 0, 0.7);
        color: #FF6B00;
    }
    50% {
        text-shadow: 0 0 20px rgba(0, 255, 255, 1), 0 0 30px rgba(255, 0, 255, 0.7);
        color: #00FFFF;
    }
    75% {
        text-shadow: 0 0 15px rgba(255, 0, 255, 1), 0 0 25px rgba(255, 215, 0, 0.7);
        color: #FF00FF;
    }
    100% {
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 107, 0, 0.5);
        color: #FFD700;
    }
}

/* テトリス バトルログスタイル */
.log-entry.tetris {
    color: #00BFFF;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(0, 191, 255, 0.8);
    animation: tetrisLogGlow 1s ease-in-out;
}

@keyframes tetrisLogGlow {
    0% {
        text-shadow: 0 0 4px rgba(0, 191, 255, 0.5);
    }
    50% {
        text-shadow: 0 0 16px rgba(0, 191, 255, 1), 0 0 24px rgba(135, 206, 250, 0.8);
    }
    100% {
        text-shadow: 0 0 8px rgba(0, 191, 255, 0.8);
    }
}

.log-entry.monster-spawn.rare {
    color: #ffa500;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 165, 0, 0.6);
    animation: textShimmer 2s ease-in-out infinite;
}

.log-entry.monster-spawn.boss {
    color: #ff0000;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255, 0, 0, 0.8);
    animation: textShimmer 1.5s ease-in-out infinite;
}

@keyframes textShimmer {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 5px currentColor;
    }
    50% {
        opacity: 0.8;
        text-shadow: 0 0 15px currentColor;
    }
}

.log-entry.new-encounter {
    color: #00ff00;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(0, 255, 0, 0.6);
    animation: textShimmer 2s ease-in-out infinite;
}

/* スクロールバー */
.battle-log-content::-webkit-scrollbar {
    width: 8px;
}

.battle-log-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.battle-log-content::-webkit-scrollbar-thumb {
    background: rgba(102, 102, 102, 0.7);
    border-radius: 4px;
}

.battle-log-content::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 102, 102, 0.9);
}

.info-panel {
    padding: 0;
    border-radius: 10px;
    width: 250px;
    min-width: 250px;
    height: 600px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.monster-section {
    background: rgba(0, 0, 0, 0.4);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #8b4513;
}

.monster-name {
    font-size: 18px;
    font-weight: bold;
    color: #ff6b6b;
    margin-bottom: 10px;
}

.hp-bar {
    width: 100%;
    height: 20px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 5px;
    border: 1px solid #666;
}

.hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff6666);
    transition: width 0.3s ease;
}

.hp-text {
    font-size: 12px;
    text-align: center;
    margin-top: -18px;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
}

.monster-stats {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #ccc;
}

.combo-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 3px 3px 6px #000;
    pointer-events: none;
    animation: comboAnimation 1s ease-out forwards;
    z-index: 100;
}

@keyframes comboAnimation {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

.combo-info {
    background: rgba(0, 0, 0, 0.8);
    padding: 12px;
    border-radius: 10px;
    margin: 10px 0;
    border: 3px solid #666666;
    text-align: center;
    flex-shrink: 0;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.combo-info.combo-active {
    border: 3px solid;
    border-image: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3, #ff0000) 1;
    animation: comboGlow 2s ease-in-out infinite, rainbowBorder 3s linear infinite;
}

@keyframes comboGlow {
    0% { 
        box-shadow: 0 0 20px rgba(255, 0, 255, 0.6), 0 0 40px rgba(0, 255, 255, 0.3);
    }
    25% { 
        box-shadow: 0 0 25px rgba(255, 255, 0, 0.7), 0 0 50px rgba(255, 0, 0, 0.4);
    }
    50% { 
        box-shadow: 0 0 30px rgba(0, 255, 0, 0.8), 0 0 60px rgba(0, 0, 255, 0.5);
    }
    75% { 
        box-shadow: 0 0 25px rgba(255, 127, 0, 0.7), 0 0 50px rgba(255, 255, 255, 0.4);
    }
    100% { 
        box-shadow: 0 0 20px rgba(255, 0, 255, 0.6), 0 0 40px rgba(0, 255, 255, 0.3);
    }
}

@keyframes rainbowBorder {
    0% { 
        border-image: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3, #ff0000) 1;
    }
    14% { 
        border-image: linear-gradient(45deg, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3, #ff0000, #ff7f00) 1;
    }
    28% { 
        border-image: linear-gradient(45deg, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3, #ff0000, #ff7f00, #ffff00) 1;
    }
    42% { 
        border-image: linear-gradient(45deg, #00ff00, #0000ff, #4b0082, #9400d3, #ff0000, #ff7f00, #ffff00, #00ff00) 1;
    }
    57% { 
        border-image: linear-gradient(45deg, #0000ff, #4b0082, #9400d3, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff) 1;
    }
    71% { 
        border-image: linear-gradient(45deg, #4b0082, #9400d3, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082) 1;
    }
    85% { 
        border-image: linear-gradient(45deg, #9400d3, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3) 1;
    }
    100% { 
        border-image: linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3, #ff0000) 1;
    }
}

.combo-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 8px;
}

.combo-count {
    font-size: 20px;
    font-weight: bold;
    color: #ffd700;
}

.combo-timer-bar {
    width: 100%;
    height: 12px;
    background: #333;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 5px;
    border: 1px solid #666;
}

.combo-timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ffff00, #00ff00);
    transition: width 0.1s linear;
    border-radius: 6px;
}

.combo-timer {
    font-size: 12px;
    color: #ffffe0;
}

.player-section {
    background: rgba(0, 0, 0, 0.8);
    padding: 12px;
    border-radius: 10px;
    margin: 0;
    margin-bottom: 10px;
    border: 3px solid #666666;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.player-level {
    font-size: 28px;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 8px;
    text-align: center;
}

.player-level-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.player-exp-remaining {
    font-size: 12px;
    color: #ccc;
    font-weight: normal;
}

.player-hp {
    margin-bottom: 10px;
}

.player-hp-label {
    font-size: 14px;
    font-weight: bold;
    color: #00ff00;
    margin-bottom: 6px;
}

.player-hp-bar {
    width: 100%;
    height: 20px;
    background: #333;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 5px;
    border: 1px solid #666;
}

.player-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #44ff44);
    transition: width 0.3s ease;
}

.player-hp-text {
    font-size: 12px;
    text-align: center;
    margin-top: -18px;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px #000;
}


.player-stats {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #ffffff;
    display: flex;
    gap: 15px;
}

.player-stats-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.player-attack {
    font-size: 15px;
    color: #ff6b6b;
    font-weight: bold;
}

.player-defense {
    font-size: 15px;
    color: #4169e1;
    font-weight: bold;
}

.player-magic {
    font-size: 15px;
    color: #9370db;
    font-weight: bold;
}

.player-agility {
    font-size: 15px;
    color: #32cd32;
    font-weight: bold;
}

.player-technique {
    font-size: 15px;
    color: #ff8c00;
    font-weight: bold;
}

.attack-warning {
    margin-bottom: 8px;
    width: 100%;
}

.attack-warning-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 5px;
}

.attack-warning-label {
    font-size: 12px;
    font-weight: bold;
    color: #ff6b6b;
    text-align: left;
    flex-shrink: 0;
}

.attack-timer-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.special-attack {
    color: #ff0000;
    animation: specialGlow 1s infinite alternate;
}

@keyframes specialGlow {
    0% { text-shadow: 0 0 5px #ff0000; }
    100% { text-shadow: 0 0 15px #ff0000, 0 0 25px #ff0000; }
}

.attack-timer-bar {
    flex: 1;
    height: 16px;
    background: #333;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #666;
    display: flex;
    justify-content: flex-start;
}

.attack-timer-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff4444, #ff6666);
    transition: width 0.1s linear;
    border-radius: 8px 0 0 8px;
}

.attack-timer-text {
    font-size: 11px;
    color: #ffcccc;
    font-weight: bold;
    min-width: 25px;
    text-align: center;
}

/* 古いscore-stats-gridスタイル（新スタイルで上書き）
.score-stats-grid {
    padding: 4px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #8b4513;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 5px;
}

.score-stats-grid .score {
    font-size: 13px;
    color: #ffd700;
    text-align: center;
}

.score-stats-grid .lines {
    font-size: 13px;
    color: #87ceeb;
    text-align: center;
}

.score-stats-grid .kills {
    font-size: 13px;
    color: #ff6b6b;
    text-align: center;
}
*/

.next-piece {
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    flex-shrink: 0;
}

.next-pieces-container {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    box-sizing: border-box;
}

.next-piece-item {
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #4a90e2;
    border-radius: 10px;
    padding: 0;
    min-width: 94px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.3);
}

.next-piece-item:first-child {
    border: 3px solid #ffd700;
}

/* 2番目・3番目のnext-piece-itemのサイズ調整 */
.next-piece-item:nth-child(2),
.next-piece-item:nth-child(3) {
    min-width: 62px;
    font-size: 12px;
}

.next-piece-item:nth-child(2) .next-piece-display,
.next-piece-item:nth-child(3) .next-piece-display {
    width: 62px;
    height: 37px;
}

.next-piece-item:nth-child(2) .next-header,
.next-piece-item:nth-child(3) .next-header {
    font-size: 12px;
    margin-bottom: 4px;
    margin-top: 4px;
}

.next-header {
    color: #4a90e2;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 6px;
    margin-top: 6px;
    text-align: center;
}

.next-piece-display {
    width: 90px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}

.next-canvas {
    border: none;
    border-radius: 5px;
}




.next-label {
    font-size: 12px;
    color: #ffd700;
    margin-bottom: 5px;
    text-align: center;
}


.damage-popup {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    color: #ff4444;
    text-shadow: 2px 2px 4px #000;
    pointer-events: none;
    animation: damageFloat 1s ease-out forwards;
}

/* 奇跡の一撃ダメージポップアップ */
.miracle-damage-popup {
    position: absolute;
    font-size: 80px;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
}

/* シールドポップアップ */
.shield-popup {
    position: absolute;
    font-size: 48px;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
}

@keyframes damageFloat {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px);
    }
}
@keyframes damageFadeOnly {
    0% {
        opacity: 1;
    }
    60% {
        opacity: 1; /* 1.2秒表示 (60% of 2s = 1.2s) */
    }
    100% {
        opacity: 0; /* 0.8秒でフェードアウト (40% of 2s = 0.8s) */
    }
}

.victory-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: #ffd700;
    padding: 20px 30px;
    border-radius: 15px;
    text-align: center;
    display: none;
    border: 3px solid #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    z-index: 2001;
    animation: victoryPulse 0.5s ease-out;
    max-width: 95vw;
    width: auto;
    min-width: 320px;
}

.victory-message h2 {
    font-size: 24px;
    margin: 0 0 10px 0;
    text-shadow: 2px 2px 4px #000;
}

.victory-message p {
    font-size: 16px;
    margin: 8px 0;
    color: #fff;
}

/* スマートフォン向けのさらなる最適化 */
@media (max-width: 480px) {
    .victory-message {
        padding: 15px 20px;
        max-width: 98vw;
        border-radius: 10px;
    }
    
    .victory-message h2 {
        font-size: 20px;
        margin: 0 0 8px 0;
    }
    
    .victory-message p {
        font-size: 14px;
        margin: 6px 0;
    }
}

@keyframes victoryPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* レベルアップメッセージ */
.levelup-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: #ffd700;
    padding: 40px 60px;
    border-radius: 15px;
    text-align: center;
    border: 3px solid #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
    z-index: 10001;
    min-width: 400px;
    max-width: 90vw;
    animation: levelUpPulse 0.6s ease-out;
    /* タッチ操作を明示的に有効化 */
    touch-action: auto;
    -webkit-touch-callout: auto;
    -webkit-user-select: auto;
    pointer-events: auto;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(255,255,255,0.3);
}

/* スマートフォン用レベルアップメッセージ */
@media (max-width: 768px), (orientation: portrait) {
    .levelup-message {
        padding: 20px 30px;
        min-width: 280px;
        max-width: 95vw;
        margin: 0 10px;
    }
}

/* 超小型画面用レベルアップメッセージ */
@media (max-width: 480px) {
    .levelup-message {
        padding: 15px 20px;
        min-width: 260px;
        max-width: 98vw;
        margin: 0 5px;
    }
    
    .levelup-title {
        font-size: 28px;
        margin: 0 0 15px 0;
    }
    
    .levelup-level {
        font-size: 20px;
        margin: 0 0 15px 0;
    }
}

/* スマートフォン用レベルアップメッセージのテキストサイズ調整 */
@media (max-width: 768px), (orientation: portrait) {
    .levelup-title {
        font-size: 32px;
        margin: 0 0 18px 0;
    }
    
    .levelup-level {
        font-size: 22px;
        margin: 0 0 18px 0;
    }
}

.levelup-title {
    font-size: 36px;
    margin: 0 0 20px 0;
    text-shadow: 2px 2px 4px #000;
    color: #ffd700;
}

.levelup-content {
    margin: 20px 0;
}

.levelup-level {
    font-size: 24px;
    font-weight: bold;
    margin: 0 0 20px 0;
    color: #fff;
}

.levelup-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
}

.stats-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 120px;
}

.stat-header {
    font-weight: bold;
    font-size: 16px;
    color: #ffd700;
    margin-bottom: 10px;
    text-decoration: underline;
}

.stat-item {
    font-size: 14px;
    color: #fff;
    text-align: left;
}

.stats-arrow {
    font-size: 24px;
    font-weight: bold;
    color: #ffd700;
    margin: 0 10px;
}

@keyframes levelUpPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    display: none;
    border: 2px solid #8b4513;
    z-index: 1000;
}

.restart-btn {
    background: #8b4513;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 15px;
}

.restart-btn:hover {
    background: #654321;
}

/* 共通オーバーレイ */
.game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.card-selection-modal {
    background: linear-gradient(135deg, #2c1810 0%, #8b4513 50%, #654321 100%);
    padding: 40px;
    border-radius: 20px;
    border: 3px solid #ffd700;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
    text-align: center;
    max-width: 900px;
    width: 90%;
    display: none;
}

.card-selection-modal.active {
    display: block;
}

.card-selection-title {
    font-size: 28px;
    color: #ffd700;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px #000;
    font-weight: bold;
}

.cards-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

/* カード選択モーダル内のコンテナを確実に隔離 */
.game-overlay .card-selection-modal .cards-container {
    display: flex !important;
    gap: 20px !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    grid-template-areas: none !important;
}

/* スマートフォン用カードレイアウト - 横3つ並び */
@media (max-width: 768px), (orientation: portrait) {
    .game-overlay .card-selection-modal .cards-container {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr !important;
        grid-template-rows: auto !important;
        grid-template-areas: none !important;
        gap: clamp(6px, 2vw, 15px) !important;
        justify-content: center !important;
        align-items: stretch !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 clamp(3px, 1vw, 8px) !important;
    }
    
    .game-overlay .card-selection-modal .card {
        width: auto !important;
        max-width: none !important;
        min-width: 110px !important;
        height: auto !important;
        min-height: 280px !important;
        max-height: 350px !important;
        padding: 10px !important;
        font-size: var(--text-sm);
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        flex: 1 !important;
    }
    
    .game-overlay .card-selection-modal .card-image {
        width: 80px !important;
        height: 80px !important;
        max-width: 80px !important;
        max-height: 80px !important;
        min-width: 60px !important;
        min-height: 60px !important;
        margin: 10px auto !important;
        flex-shrink: 0 !important;
    }
    
    .card-rank {
        font-size: var(--text-responsive-sm);
        padding: clamp(3px, 1vw, 6px) clamp(6px, 2vw, 10px) !important;
        margin-bottom: clamp(6px, 1.5vw, 10px) !important;
        flex-shrink: 0 !important;
    }
    
    .card-name {
        font-size: var(--text-responsive-base);
        margin-bottom: clamp(6px, 1.5vw, 10px) !important;
        flex-shrink: 0 !important;
    }
    
    .card-description {
        font-size: var(--text-responsive-sm);
        line-height: var(--line-height-snug);
        flex-grow: 1 !important;
        display: flex !important;
        align-items: flex-end !important;
    }
    
    .card-selection-modal {
        padding: 20px !important;
        width: 95% !important;
        max-width: 100% !important;
        border-radius: 15px !important;
    }
    
    .card-selection-title {
        font-size: var(--text-responsive-lg);
        margin-bottom: 15px !important;
    }
    
    /* スマートフォンでのカード選択指示テキストも調整 */
    .card-selection-modal p {
        font-size: 12px !important;
        margin-bottom: 15px !important;
    }
}

/* 超小型画面（480px以下）での更なる調整 */
@media (max-width: 480px) {
    .game-overlay .card-selection-modal .cards-container {
        gap: clamp(4px, 1.5vw, 10px) !important;
        padding: 0 clamp(2px, 0.8vw, 6px) !important;
    }
    
    .game-overlay .card-selection-modal .card {
        width: auto !important;
        max-width: none !important;
        min-width: 100px !important;
        height: auto !important;
        min-height: 250px !important;
        max-height: 300px !important;
        padding: 8px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        flex: 1 !important;
    }
    
    .game-overlay .card-selection-modal .card-image {
        width: 70px !important;
        height: 70px !important;
        max-width: 70px !important;
        max-height: 70px !important;
        min-width: 50px !important;
        min-height: 50px !important;
        margin: 8px auto !important;
        flex-shrink: 0 !important;
    }
    
    .card-rank {
        font-size: var(--text-game-tiny);
        padding: clamp(2px, 0.8vw, 5px) clamp(4px, 1.5vw, 8px) !important;
        margin-bottom: clamp(4px, 1vw, 8px) !important;
        flex-shrink: 0 !important;
    }
    
    .card-name {
        font-size: var(--text-game-small);
        margin-bottom: clamp(4px, 1vw, 8px) !important;
        flex-shrink: 0 !important;
    }
    
    .card-description {
        font-size: var(--text-xs);
        line-height: var(--line-height-snug);
        flex-grow: 1 !important;
        display: flex !important;
        align-items: flex-end !important;
    }
    
    .card-selection-title {
        font-size: var(--text-responsive-xl);
    }
    
    /* スマートフォンでは選択状態（.selected）のエフェクトを無効化 */
    .card.selected {
        transform: none;
        border-color: #666;
        box-shadow: none;
    }
    
    .card.selected .card-image {
        border-color: rgba(255, 255, 255, 0.3) !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
        transform: none;
    }
    
    /* タップ時（:active）のみエフェクトを適用 */
    .card:active {
        transform: scale(var(--scale-pressed));
        border-color: #ffd700;
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
        transition: all var(--trans-fast) var(--ease-out);
    }
    
    .card:active .card-image {
        border-color: #ffd700;
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
        transform: scale(var(--scale-active));
        transition: all var(--trans-fast) var(--ease-out);
    }
}

.card {
    background: linear-gradient(145deg, #1a1a1a, #2d2d2d);
    border: 2px solid #666;
    border-radius: 15px;
    padding: 20px;
    width: 200px;
    min-height: 320px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.card.selected {
    transform: translateY(-10px) scale(1.05);
    border-color: #ffd700;
    box-shadow: 0 10px 30px rgba(255, 215, 0, 0.4);
}


.card-image {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 12px;
    margin: 15px auto;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.card.selected .card-image {
    border-color: #ffd700;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    transform: scale(1.1);
}

.card-rank {
    font-size: 14px;
    font-weight: bold;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-rank.common {
    background: linear-gradient(135deg, #8e8e93, #636366);
    color: #fff;
    border: 1px solid #a8a8a8;
}

.card-rank.rare {
    background: linear-gradient(135deg, #007aff, #0051d5);
    color: #fff;
    border: 1px solid #4da6ff;
    box-shadow: 0 0 10px rgba(0, 122, 255, 0.3);
}

.card-rank.legendary {
    background: linear-gradient(135deg, #ff9500, #ff6b00);
    color: #fff;
    border: 1px solid #ffb347;
    box-shadow: 0 0 15px rgba(255, 149, 0, 0.5);
    animation: legendaryGlow 2s infinite alternate;
}

@keyframes legendaryGlow {
    0% { box-shadow: 0 0 15px rgba(255, 149, 0, 0.5); }
    100% { box-shadow: 0 0 25px rgba(255, 149, 0, 0.8); }
}

.card-name {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
    margin-bottom: 15px;
    text-shadow: 1px 1px 2px #000;
}

.card-description {
    font-size: 14px;
    color: #ddd;
    line-height: 1.4;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid #444;
}

.card.common {
    border-color: #8e8e93;
}


.card.rare {
    border-color: #007aff;
}


.card.legendary {
    border-color: #ff9500;
    background: linear-gradient(145deg, #2d1a0d, #3d2a1d);
}


@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.monster-appear-modal {
    background: linear-gradient(135deg, #2c1810 0%, #8b4513 50%, #654321 100%);
    padding: 40px;
    border-radius: 20px;
    border: 3px solid #8b4513;
    box-shadow: 0 0 50px rgba(139, 69, 19, 0.8);
    text-align: center;
    max-width: 600px;
    width: 90%;
    display: none;
}

.monster-appear-modal.active {
    display: block;
}

.monster-appear-modal.rare {
    background: radial-gradient(ellipse at center, rgba(255, 165, 0, 0.2) 0%, rgba(0, 0, 0, 0.9) 70%);
    border: 3px solid rgba(255, 165, 0, 0.5);
    box-shadow: 0 0 30px rgba(255, 165, 0, 0.3);
}

.monster-appear-modal.boss {
    background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.9) 70%);
    border: 3px solid rgba(255, 0, 0, 0.6);
    box-shadow: 0 0 40px rgba(255, 0, 0, 0.4);
}

/* モンスター登場画面のヘッダー部分 - 画像とレーダーチャートを横並び */
.monster-appear-header {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 20px;
    margin-bottom: 20px;
}

.monster-appear-image {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.monster-appear-image img {
    width: 200px;
    height: 200px;
    object-fit: contain;
    border-radius: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    animation: monsterAppearAnimation 1s ease-out;
}

/* フレーバーテキストを独立したセクションに */
.monster-appear-flavor {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 15px 20px;
    border-left: 4px solid #8b4513;
    margin: 10px 0;
    text-align: left;
}

.flavor-text {
    color: #e0e0e0;
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
    font-style: italic;
    text-align: center;
    width: 100%;
}

/* タイトル部分（レベルとモンスター名） */
.monster-appear-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
}

.monster-appear-badges {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
    min-height: 20px;
}

.monster-appear-text {
    font-size: 28px;
    color: #ff6b6b;
    margin: 0 0 10px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-weight: bold;
    animation: textGlow 2s ease-in-out infinite alternate;
}

.monster-appear-rarity {
    margin: 0;
    text-align: center;
}

.rarity-badge {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    animation: rarityGlow 1.5s ease-in-out infinite alternate;
}

.rarity-badge.rare {
    background: linear-gradient(45deg, #ff6b6b, #ffa500);
    color: white;
    border: 2px solid #ffd700;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.6);
}

.rarity-badge.boss {
    background: linear-gradient(45deg, #8b0000, #ff0000);
    color: white;
    border: 2px solid #ffd700;
    box-shadow: 0 0 25px rgba(255, 0, 0, 0.8);
}

@keyframes rarityGlow {
    0% {
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
        transform: scale(1);
    }
    100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
        transform: scale(1.05);
    }
}

.monster-appear-new {
    margin: 0;
    text-align: center;
}

.new-encounter-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: bold;
    color: white;
    background: linear-gradient(45deg, #00ff00, #32cd32);
    border: 2px solid #90ee90;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
    animation: newEncounterGlow 1s ease-in-out infinite alternate;
}

@keyframes newEncounterGlow {
    0% {
        box-shadow: 0 0 10px rgba(0, 255, 0, 0.4);
        transform: scale(1);
    }
    100% {
        box-shadow: 0 0 20px rgba(0, 255, 0, 0.7);
        transform: scale(1.08);
    }
}

.monster-appear-level {
    font-size: 22px;
    color: #ffd700;
    font-weight: bold;
    margin: 5px 0 0 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.monster-appear-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    margin: 0;
}

.appear-stat {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}

.stat-label {
    color: #ccc;
    font-weight: bold;
}

.stat-value {
    color: #ffd700;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

@keyframes monsterAppearAnimation {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(50px);
    }
    50% {
        transform: scale(1.1) translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 続行ボタン */
.monster-appear-continue {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid rgba(139, 69, 19, 0.7);
    text-align: center;
}

.monster-appear-continue p {
    font-size: 16px;
    color: var(--ui-text-primary);
    margin: 0;
    opacity: 0.9;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

@keyframes textGlow {
    0% { text-shadow: 3px 3px 6px #000, 0 0 10px #ff6b6b; }
    100% { text-shadow: 3px 3px 6px #000, 0 0 20px #ff6b6b, 0 0 30px #ff6b6b; }
}


/* オーディオ有効化案内 */
.audio-notice {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 165, 0, 0.9);
    color: #000;
    padding: 10px 20px;
    border-radius: 20px;
    border: 2px solid #ff8c00;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    z-index: 2000;
    animation: pulse 2s infinite;
}

.audio-notice.hidden {
    display: none;
}

@keyframes pulse {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

/* モバイル操作パネル - 完全非表示 */
.mobile-controls {
    display: none !important;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 15px;
    padding: 15px;
    border: 2px solid #8b4513;
    z-index: 1500;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.control-row:last-child {
    margin-bottom: 0;
}

.control-btn {
    width: 60px;
    height: 60px;
    border: 2px solid #8b4513;
    border-radius: 10px;
    background: linear-gradient(145deg, #654321, #8b4513);
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active {
    transform: scale(0.95);
    background: linear-gradient(145deg, #8b4513, #654321);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.rotate-btn {
    background: linear-gradient(145deg, #4169e1, #1e90ff);
    border-color: #1e90ff;
}

.hard-drop-btn {
    background: linear-gradient(145deg, #ff4500, #ff6347);
    border-color: #ff6347;
    width: 100px;
}

.drop-btn {
    background: linear-gradient(145deg, #32cd32, #90ee90);
    border-color: #90ee90;
    color: #000;
}


/* モバイルデバイスでのみ表示 */
/* スマートフォン向け2列レイアウト（1280x720基準） */
@media (max-width: 768px), (orientation: portrait) {
    .mobile-controls {
        display: none !important;
    }
    
    /* 仮想解像度1280x720でアスペクト比維持 */
    body {
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        background: #1a1a1a;
    }
    
    /* 古い2列レイアウト設定（現在は3列レイアウトを使用）
    .game-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important; フォールバック
        height: 100dvh !important; 動的ビューポート対応
        display: grid !important;
        grid-template-columns: 7fr 3fr !important;
        grid-template-rows: auto min-content 1fr auto min-content !important;
        grid-template-areas:
            "monster-area battle-area"
            "combo-area next-area"
            "game-area next-area"
            "game-area player-area"
            "game-area score-area" !important;
        gap: 1px !important;
        padding: 4px !important;
        box-sizing: border-box !important;
        background: #1a1a1a;

        スケーリングを簡素化
        transform: none;
        width: 100vw;
        height: 100vh; フォールバック
        height: 100dvh; 動的ビューポート対応
        
        タッチ操作制御
        touch-action: none;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    */
    
    /* エフェクト専用要素のtransform許可（レイアウト要素は除外、奇跡の一撃エフェクトのz-indexは除外） */
    body > div[style*="position: fixed"]:not(.game-container):not([style*="z-index: 1600"]):not([style*="z-index: 1501"]):not([style*="z-index: 1500"]),
    .damage-popup,
    .combo-display {
        transform: initial !important;
        -webkit-transform: initial !important;
    }
    
    /* 奇跡の一撃エフェクトのtransformを強制許可 */
    body > div[style*="z-index: 1600"],
    body > div[style*="z-index: 1501"],
    body > div[style*="z-index: 1500"],
    body > div[style*="奇跡の一撃"],
    body > div[style*="conic-gradient"] {
        transform: revert !important;
        -webkit-transform: revert !important;
    }
    
    /* モンスターエフェクトのtransformを許可 */
    .monster-visual.damage-shake,
    .monster-image.damage-shake {
        transform: none;
        -webkit-transform: none;
        animation: inherit;
        -webkit-animation: inherit;
    }
    
    /* monster-visualの点滅エフェクトを許可（animation制限を解除） */
    .game-container .monster-visual.danger-slow,
    .game-container .monster-visual.danger-medium, 
    .game-container .monster-visual.danger-fast,
    .game-container .monster-visual.special-attack::after,
    .game-container .monster-visual.damage-effect::after {
        animation: inherit;
        -webkit-animation: inherit;
    }
    
    /* スマホ版でもモンスターエフェクトを確実に動作させるための最高優先度セレクタ */
    .game-container .monster-visual.damage-effect::after {
        animation: monsterDamageFlash var(--anim-medium) var(--ease-in-out);
        -webkit-animation: monsterDamageFlash var(--anim-medium) var(--ease-in-out);
    }
    
    .game-container .monster-image.damage-shake {
        animation: monsterDamageShake var(--anim-slow) var(--ease-in-out);
        -webkit-animation: monsterDamageShake var(--anim-slow) var(--ease-in-out);
        transform: none;
        -webkit-transform: none;
    }
    
    .game-container .monster-visual.danger-slow::after {
        animation: dangerFlashSlow var(--anim-ultra-slow) infinite;
        -webkit-animation: dangerFlashSlow var(--anim-ultra-slow) infinite;
    }
    
    .game-container .monster-visual.danger-medium::after {
        animation: dangerFlashMedium 0.5s infinite;
        -webkit-animation: dangerFlashMedium 0.5s infinite;
    }
    
    .game-container .monster-visual.danger-fast::after {
        animation: dangerFlashFast var(--anim-normal) infinite;
        -webkit-animation: dangerFlashFast var(--anim-normal) infinite;
    }
}

/* スマホ版エフェクト専用：最優先度で強制適用 */
@media (max-width: 768px), (orientation: portrait) {
    .game-container .monster-visual.damage-effect::after {
        animation: monsterDamageFlash var(--anim-medium) var(--ease-in-out);
        -webkit-animation: monsterDamageFlash var(--anim-medium) var(--ease-in-out);
        will-change: background;
    }
    
    .game-container .monster-image.damage-shake {
        animation: monsterDamageShake var(--anim-slow) var(--ease-in-out);
        -webkit-animation: monsterDamageShake var(--anim-slow) var(--ease-in-out);
        transform: none;
        -webkit-transform: none;
        will-change: transform;
    }
    
    .game-container .monster-visual.danger-slow::after {
        animation: dangerFlashSlow var(--anim-ultra-slow) infinite;
        -webkit-animation: dangerFlashSlow var(--anim-ultra-slow) infinite;
        will-change: background;
    }
    
    .game-container .monster-visual.danger-medium::after {
        animation: dangerFlashMedium 0.5s infinite;
        -webkit-animation: dangerFlashMedium 0.5s infinite;
        will-change: background;
    }
    
    .game-container .monster-visual.danger-fast::after {
        animation: dangerFlashFast var(--anim-normal) infinite;
        -webkit-animation: dangerFlashFast var(--anim-normal) infinite;
        will-change: background;
    }
    
    /* 既存のコンテナを強制的に無効化 */
    .game-container .left-column {
        display: contents !important;
        width: auto !important;
        height: auto !important;
        flex-direction: initial !important;
        align-items: initial !important;
        gap: initial !important;
        min-width: initial !important;
    }
    
    .game-container .info-panel {
        display: contents !important;
        width: auto !important;
        min-width: initial !important;
        height: auto !important;
        padding: 0 !important;
        border-radius: 0 !important;
        backdrop-filter: none !important;
        flex-direction: initial !important;
    }
    
    /* 左列上部: monster-visual */
    .game-container .monster-visual {
        grid-area: monster-area !important;
        width: auto !important;
        height: auto !important;
        min-height: 120px !important;
        padding: 8px 8px 8px 0 !important;
        background: rgba(0, 0, 0, 1);
        overflow: visible !important;
        box-sizing: border-box !important;
        align-self: start !important;
        border-width: 2px !important;
        border-radius: 8px !important;
        display: grid !important;
        grid-template-columns: 2fr 3fr !important;
        grid-template-rows: auto auto auto auto !important;
        gap: 0 !important;
        grid-template-areas:
            "monster-left monster-hp"
            "monster-left monster-stats"
            "monster-left monster-attack"
            "monster-left ." !important;
        gap: 4px !important;
        margin: 0 !important;
        align-items: start !important;
    }
    
    /* 左側エリア: monster-title-row と monster-image */
    .game-container .monster-title-row {
        grid-area: monster-left !important;
        width: 100% !important;
        text-align: center;
        align-self: start !important;
        justify-self: center !important;
        font-size: var(--text-xs);
    }
    
    .game-container .monster-image {
        grid-area: monster-left !important;
        width: clamp(100px, 15vw, 160px) !important;
        height: clamp(100px, 15vw, 160px) !important;
        align-self: end !important;
        justify-self: center !important;
    }
    
    /* 右側エリア: 上から順番に配置 */
    .game-container .monster-hp-display {
        grid-area: monster-hp !important;
        width: 100% !important;
        align-self: start !important;
    }
    
    .game-container .monster-stats-display {
        grid-area: monster-stats !important;
        width: 100% !important;
        font-size: var(--text-monster-stats);
        align-self: start !important;
        white-space: normal !important;
    }
    
    .game-container .attack-warning {
        grid-area: monster-attack !important;
        width: 100% !important;
        font-size: var(--text-game-tiny);
        align-self: start !important;
    }
    
    /* 左列中部: combo-info */
    .game-container .combo-info {
        grid-area: combo-area !important;
        width: auto !important;
        height: 100% !important;
        padding: 8px !important;
        margin: 0 !important;
        background: rgba(0, 0, 0, 1);
        border-width: 2px !important;
        border-radius: 8px !important;
        text-align: center;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
    }
    
    /* 左列下部: game-board */
    .game-container .game-board {
        grid-area: game-area !important;
        grid-row: 3 / 5 !important;
        width: auto !important;
        height: 100% !important;
        border-width: 3px !important;
        border-radius: 8px !important;
        justify-self: center !important;
        align-self: stretch !important;
        display: inline-block !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* gameCanvasのサイズを最大化 - アスペクト比固定、3-4行目フル活用 */
    .game-container #gameCanvas {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        aspect-ratio: 1 / 2 !important;
        object-fit: contain !important;
        border-radius: 4px !important;
        
        /* 上下余白に背景画像を配置 - JavaScriptで動的制御 */
        background-repeat: 
            repeat-x,
            repeat-x !important;
        background-size: 
            100% auto,
            100% auto !important;
    }
    
    /* タッチフィードバック強化（緑色の発光を無効化） */
    .game-container .game-board.touch-active {
        /* border-color: #00ff00; */
        /* box-shadow: 0 0 30px rgba(0, 255, 0, 0.6); */
        /* transition: all var(--trans-instant) var(--ease-out); */
        /* 緑色のエフェクトを完全に無効化 */
        border-color: #666666 !important;
        box-shadow: none !important;
        transition: none !important;
    }
    
    /* 右列上部: battle-log - 固定高さ */
    .game-container .battle-log {
        grid-area: battle-area !important;
        grid-row: 1 / 2 !important;
        width: auto !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
        margin: 0 !important;
        background: rgba(0, 0, 0, 1);
        border-width: 2px !important;
        border-radius: 8px !important;
        display: flex !important;
        flex-direction: column !important;
        align-self: stretch !important;
        justify-self: stretch !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        contain: size !important;
        flex: none !important;
    }
    
    .game-container .battle-log-header {
        font-size: var(--text-sm);
        padding: 6px 8px !important;
        background: rgba(102, 102, 102, 0.3) !important;
        border-radius: 6px 6px 0 0 !important;
        flex-shrink: 0 !important;
        text-align: left;
    }
    
    .game-container .battle-log-content {
        font-size: var(--text-xs);
        padding: 8px !important;
        flex: 1 1 0px !important;
        overflow-y: auto !important;
        min-height: 0 !important;
        max-height: 100% !important;
        height: 0 !important;
    }
    
    /* 右列1番目: next-piece */
    .game-container .next-piece {
        grid-area: next-area !important;
        grid-row: 2 / 4 !important;
        width: auto !important;
        height: fit-content !important;
        min-height: fit-content !important;
        background: rgba(0, 0, 0, 1);
        border-width: 2px !important;
        border-radius: 8px !important;
        padding: 8px !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        align-self: start !important;
        justify-content: center !important;
    }
    
    
    /* 右側エリア全体をFlexboxで縦配置 */
    .game-container .next-pieces-container {
        display: grid !important;
        grid-template-columns: 2fr 1fr !important;
        grid-template-rows: auto auto !important;
        grid-template-areas:
            "next-main next-sub-1"
            "next-main next-sub-2" !important;
        gap: 6px !important;
        width: 100% !important;
        height: fit-content !important;
        align-items: start !important;
    }
    
    /* 左側: 最初のnext-piece-item */
    .game-container .next-piece-item:first-child {
        grid-area: next-main !important;
        grid-row: 1 / 3 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        width: 100% !important;
        height: fit-content !important;
    }
    
    /* 右側上: 3番目のnext-piece-item (位置入れ替え) */
    .game-container .next-pieces-container > .next-piece-item:nth-child(5) {
        grid-area: next-sub-1 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    /* 右側下: 2番目のnext-piece-item (位置入れ替え) */
    .game-container .next-pieces-container > .next-piece-item:nth-child(3) {
        grid-area: next-sub-2 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .game-container .next-canvas {
        width: 45px !important;
        height: 45px !important;
    }
    
    /* 左側のnextCanvasを可変サイズに設定 */
    .game-container .next-piece-item:first-child .next-canvas {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: contain !important;
    }
    
    /* next-arrowを非表示 */
    .game-container .next-arrow {
        display: none !important;
    }
    
    /* 右列2番目: player-section - 可変高さ */
    .game-container .player-section {
        grid-area: player-area !important;
        grid-row: 3 / 4 !important;
        width: auto !important;
        height: auto !important;
        background: rgba(0, 0, 0, 1);
        border-width: 2px !important;
        border-radius: 8px !important;
        padding: 8px !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow-y: auto !important;
        align-self: stretch !important;
    }
    
    .game-container .player-level-container {
        margin-bottom: 6px !important;
    }
    
    .game-container .player-level {
        font-size: var(--text-base);
        font-weight: bold !important;
    }
    
    .game-container .player-exp-remaining {
        font-size: var(--text-xs);
        color: #ccc;
    }
    
    .game-container .player-hp-label {
        font-size: var(--text-game-small);
        margin-bottom: 4px !important;
    }
    
    .game-container .player-stats {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        font-size: var(--text-xs);
        margin-top: 6px !important;
    }
    
    .game-container .player-stats-column {
        width: 100% !important;
        flex: none !important;
        margin-bottom: 4px !important;
    }
    
    .game-container .player-buffs {
        font-size: var(--text-game-tiny);
        margin-top: 4px !important;
    }
    
    /* スマートフォン向けゲーム制御ボタン */
    .game-controls {
        top: 7px;
        right: 7px;
        gap: 3px;
        z-index: 9999 !important;
    }
    
    .control-button {
        width: 26px;
        height: 26px;
        font-size: 16px;
        border-radius: 5px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        border: 1px solid #8b4513;
        position: relative;
        z-index: 10000;
        pointer-events: auto !important;
    }
    
    .control-button:active {
        background: rgba(139, 69, 19, 0.8);
        transform: scale(0.95);
    }

    /* タッチ操作の改善 */
    .game-over-btn,
    .encyclopedia-btn,
    .filter-btn,
    .monster-card,
    .title-btn,
    .card,
    .tutorial-btn,
    .ranking-tab,
    .monster-detail-close,
    .control-button,
    #pauseButton,
    #titleButton,
    button {
        touch-action: manipulation;
        user-select: none;
        -webkit-user-select: none;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        cursor: pointer;
    }

    /* タッチフィードバック強化 - より即座に反応 */
    .game-over-btn:active,
    .encyclopedia-btn:active,
    .filter-btn:active,
    .monster-card:active,
    .title-btn:active,
    .card:active,
    .tutorial-btn:active,
    .ranking-tab:active,
    .next-piece-item:active,
    .hold-area:active,
    button:active {
        transform: scale(var(--scale-pressed));
        opacity: var(--opacity-80);
        transition: all var(--trans-instant) var(--ease-out);
        background: rgba(139, 69, 19, 0.2);
    }
    
    /* ゲームエリア全体のタッチ最適化 */
    .game-container {
        -webkit-tap-highlight-color: transparent !important;
        -webkit-touch-callout: none !important;
    }
    
    /* キャンバス要素のタッチ処理改善 */
    #gameCanvas, .next-canvas, #holdCanvas {
        touch-action: none;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* gameCanvasを確実にエフェクトより前面に表示 */
    #gameCanvas {
        position: relative;
        z-index: 20;
    }

    /* 右列3番目: score-stats-grid - 固定高さ */
    .game-container .score-stats-grid {
        grid-area: score-area !important;
        grid-row: 4 / 5 !important;
        width: auto !important;
        height: auto !important;
        display: flex !important;
        justify-content: space-between !important;
        background: rgba(0, 0, 0, 1);
        border-width: 2px !important;
        border-radius: 8px !important;
        padding: 6px !important;
        margin: 0 !important;
        font-size: var(--text-game-small);
        align-items: center !important;
        align-self: end !important;
        min-height: auto !important;
    }
}

/* 小さなスマートフォン用（480px以下） */
/* 修正：866px〜481pxで正常表示されているため、480px以下も同じ表示にする */
/* transform: scaleによる縮小設定を削除し、768px以下のグリッドレイアウトを継承 */
/* テスト方法：ChromeデベロッパーツールでiPhone SE(375px)、その他スマートフォンで確認 */
@media (max-width: 480px) {
    .game-container {
        /* transform縮小設定を削除（768px以下の設定を継承） */
        gap: 6px;
        padding: 2px;
    }
    
    /* より小さいフォントサイズに調整 - 可読性重視 */
    .monster-visual {
        padding: 4px !important;
    }
    
    .monster-image {
        width: clamp(60px, 12vw, 90px) !important;
        height: clamp(60px, 12vw, 90px) !important;
    }
    
    .battle-log-header {
        font-size: var(--text-game-small);
        font-weight: bold !important;
        padding: 5px 8px !important;
        text-align: left !important;
        line-height: 1.2 !important;
    }
    
    .battle-log-content {
        font-size: var(--text-game-tiny);
        padding: 8px !important;
        line-height: 1.3 !important;
        font-weight: 500 !important;
    }
    
    .next-canvas {
        width: 45px !important;
        height: 45px !important;
    }
    
    .next-arrow {
        font-size: 12px;
    }
    
    .player-level {
        font-size: var(--text-md);
        font-weight: bold !important;
        line-height: 1.2 !important;
    }
    
    .player-exp-remaining {
        font-size: var(--text-xs);
        font-weight: 500 !important;
        line-height: 1.2 !important;
    }
    
    .player-hp-label {
        font-size: var(--text-game-small);
        font-weight: 600 !important;
        line-height: 1.2 !important;
    }
    
    .player-stats {
        font-size: var(--text-xs);
        font-weight: 500 !important;
        line-height: 1.3 !important;
    }
    
    .player-buffs {
        font-size: var(--text-game-tiny);
        font-weight: 500 !important;
        line-height: 1.2 !important;
    }
    
    .score-stats-grid {
        font-size: var(--text-game-small);
        font-weight: 600 !important;
        padding: 8px !important;
        line-height: 1.2 !important;
    }
    
    /* white-space: nowrapによるレイアウト崩れを修正 */
    .score-stats-grid .score,
    .score-stats-grid .lines,
    .score-stats-grid .kills {
        white-space: normal !important;
    }
    
    /* モバイル・タブレットで2行表示：コロン非表示、縦並び */
    .score-stats-grid .score,
    .score-stats-grid .lines,
    .score-stats-grid .kills {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        line-height: 1.1 !important;
    }
    
    .score-stats-grid .stat-colon {
        display: none !important;
    }
    
    .score-stats-grid .stat-label {
        font-size: 0.8em !important;
        margin-bottom: 2px !important;
    }
    
    .score-stats-grid .stat-value {
        font-weight: bold !important;
        font-size: 1.1em !important;
    }
    
    /* 小画面でもmobile-repositioned時は2列グリッドに変更 */
    .score-stats-grid.mobile-repositioned {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0 !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    .score-stats-grid.mobile-repositioned .score,
    .score-stats-grid.mobile-repositioned .kills {
        text-align: center;
        font-size: var(--text-xs);
        font-weight: bold !important;
        line-height: 1.1 !important;
        margin: 0 !important;
        padding: 3px 1px !important;
    }
    
    /* 小画面でもlinesを非表示 */
    .score-stats-grid.mobile-repositioned .lines {
        display: none !important;
    }
    
    .game-board {
        width: 280px !important;
        height: 560px !important;
    }
    
    /* 小画面での可読性向上 - 背景とコントラスト強化 */
    .battle-log,
    .player-section,
    .next-piece,
    .hold-area,
    .score-stats-grid {
        background: rgba(0, 0, 0, 1);
        border-width: 3px !important;
    }
    
    /* 小画面でのテキストコントラスト強化 */
    .battle-log-content,
    .player-stats,
    .score-stats-grid {
        color: #ffffff;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8) !important;
    }
    
    /* 小画面でのnext-headerサイズ調整 */
    .next-header {
        font-size: var(--text-xs);
        font-weight: bold !important;
        line-height: 1.1 !important;
        padding: 2px 0 !important;
    }
}

/* ===== タイトル画面スタイル ===== */
.title-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh; /* フォールバック */
    height: 100dvh; /* 動的ビューポート対応 */
    background: linear-gradient(135deg, #1a0d0a 0%, #3d1b14 30%, #5c2e1a 70%, #7d3f24 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow: hidden;
}

.title-content {
    text-align: center;
    color: white;
    z-index: 1001;
    max-width: 90vw;
    animation: titleFadeIn 2s ease-out;
}

.title-logo {
    margin-bottom: 40px;
}

.game-title-image {
    width: 90%;
    max-width: 500px;
    min-width: 250px;
    height: auto;
    margin: 0;
    filter: drop-shadow(3px 3px 6px rgba(0, 0, 0, 0.8)) 
            drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
}

/* レスポンシブ対応 - タイトル画像 */
@media (max-width: 768px) {
    .loading-title-image,
    .game-title-image {
        width: 95%;
        max-width: 400px;
        min-width: 200px;
    }
}

@media (max-width: 480px) {
    .loading-title-image,
    .game-title-image {
        width: 98%;
        max-width: 350px;
        min-width: 180px;
    }
}

.game-subtitle {
    font-size: 1.2rem;
    color: #ddd;
    margin: 10px 0 0 0;
    font-style: italic;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6);
}

.title-monster-showcase {
    position: relative;
    margin: 30px 0;
    display: none;
    justify-content: center;
    align-items: center;
}

.title-monster-image {
    width: 120px;
    height: 120px;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.4));
    animation: monsterFloat 4s ease-in-out infinite;
    transition: transform 0.3s ease;
}

.title-monster-image:hover {
    transform: scale(1.1);
}

.title-monster-effects {
    position: absolute;
    width: 150px;
    height: 150px;
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 50%;
    animation: effectRotate 8s linear infinite;
}

.title-menu {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 40px 0;
}

.title-btn {
    background: linear-gradient(135deg, #4a2c2a 0%, #6d3f3a 50%, #8b4c44 100%);
    border: 2px solid #ffd700;
    color: white;
    padding: 15px 30px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-width: 280px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.title-btn:hover {
    background: linear-gradient(135deg, #6d3f3a 0%, #8b4c44 50%, #a85a52 100%);
    border-color: #ffed4e;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.title-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.btn-text {
    display: block;
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 2px;
}

.btn-subtitle {
    display: block;
    font-size: 0.9rem;
    color: #ccc;
    font-style: italic;
}

.start-btn {
    border-color: #ff6b35;
    background: linear-gradient(135deg, #d73027 0%, #fc8d59 50%, #fee08b 100%);
}

.start-btn:hover {
    background: linear-gradient(135deg, #fc8d59 0%, #fee08b 50%, #ffffcc 100%);
    border-color: #ff8c42;
}

/* キーボード選択時のスタイル */
.title-btn.keyboard-selected {
    background: linear-gradient(135deg, #8b4c44 0%, #a85a52 50%, #c66a5e 100%);
    border-color: #ffed4e;
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    animation: keyboardPulse 1.5s ease-in-out infinite;
}

.start-btn.keyboard-selected {
    background: linear-gradient(135deg, #fc8d59 0%, #fee08b 50%, #ffffcc 100%);
    border-color: #ff8c42;
    box-shadow: 0 8px 25px rgba(255, 140, 66, 0.5);
}

@keyframes keyboardPulse {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    }
    50% {
        box-shadow: 0 8px 25px rgba(255, 215, 0, 0.7);
    }
}

.title-footer {
    margin-top: 40px;
    font-size: 0.9rem;
    color: #888;
}

.keyboard-guide {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.control-hint {
    margin: 0;
    font-size: 0.9rem;
    color: #ddd;
    text-align: center;
    line-height: 1.4;
}

.control-hint strong {
    color: #ffd700;
}

.version-info, .copyright {
    margin: 5px 0;
}

/* タイトル背景エフェクト */
.title-bg-effects {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.floating-blocks {
    position: absolute;
    width: 100%;
    height: 100%;
}

.floating-blocks::before,
.floating-blocks::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    animation: blockFloat 15s linear infinite;
}

.floating-blocks::before {
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.floating-blocks::after {
    top: 70%;
    right: 15%;
    animation-delay: 7s;
}

/* 設定画面・チュートリアル画面のスタイル */
.settings-screen,
.tutorial-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh; /* フォールバック */
    height: 100dvh; /* 動的ビューポート対応 */
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1100;
}

/* ハイスコアランキング画面 */
.ranking-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh; /* フォールバック */
    height: 100dvh; /* 動的ビューポート対応 */
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1100;
}

.ranking-content {
    background: linear-gradient(135deg, #2c1810 0%, #4a2c2a 50%, #654321 100%);
    border: 2px solid #ffd700;
    border-radius: 15px;
    padding: 30px;
    max-width: 700px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

.ranking-title {
    font-size: 32px;
    color: #ffd700;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    font-weight: bold;
}

.ranking-table {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.ranking-header {
    display: grid;
    grid-template-columns: 60px 120px 80px 1fr;
    gap: 15px;
    padding: 10px 0;
    border-bottom: 2px solid #ffd700;
    margin-bottom: 15px;
    font-weight: bold;
    font-size: 16px;
    color: #ffd700;
}

.ranking-list {
    max-height: 400px;
    overflow-y: auto;
    /* スマートフォンでのスムーズスクロール */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.ranking-item {
    display: grid;
    grid-template-columns: 60px 120px 80px 1fr;
    gap: 15px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
    color: #fff;
    font-size: 14px;
    align-items: center;
    transition: background-color 0.2s ease;
}

.ranking-item:hover {
    background-color: rgba(255, 215, 0, 0.1);
}

.ranking-item:last-child {
    border-bottom: none;
}

.rank-col {
    text-align: center;
    font-weight: bold;
    color: #ffd700;
}

.score-col {
    text-align: right;
    font-weight: bold;
    color: #87ceeb;
}

.kills-col {
    text-align: center;
    color: #ff6b6b;
}

.date-col {
    font-size: 12px;
    color: #ccc;
}

.ranking-item:nth-child(1) .rank-col {
    color: #ffd700;
    font-size: 18px;
    text-shadow: 0 0 5px #ffd700;
}

.ranking-item:nth-child(2) .rank-col {
    color: #c0c0c0;
    font-size: 16px;
}

.ranking-item:nth-child(3) .rank-col {
    color: #cd7f32;
    font-size: 16px;
}

.ranking-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.ranking-btn {
    background: linear-gradient(135deg, #8b4513 0%, #a0522d 50%, #cd853f 100%);
    color: white;
    border: 2px solid #ffd700;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.ranking-btn:hover {
    background: linear-gradient(135deg, #a0522d 0%, #cd853f 50%, #daa520 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.ranking-btn.clear-btn {
    background: linear-gradient(135deg, #8b0000 0%, #a52a2a 50%, #dc143c 100%);
}

.ranking-btn.clear-btn:hover {
    background: linear-gradient(135deg, #a52a2a 0%, #dc143c 50%, #ff6347 100%);
}

.no-scores {
    text-align: center;
    color: #ccc;
    font-size: 18px;
    padding: 40px;
    font-style: italic;
}

/* ランキングタブ */
.ranking-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.ranking-tab {
    background: linear-gradient(135deg, #4a4a4a 0%, #666666 50%, #555555 100%);
    color: var(--ui-text-secondary);
    border: 1px solid #777777;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    user-select: none;
}

.ranking-tab:hover {
    background: linear-gradient(135deg, #555555 0%, #777777 50%, #666666 100%);
    transform: translateY(-1px);
}

.ranking-tab.active {
    background: linear-gradient(135deg, #8b4513 0%, #a0522d 50%, #cd853f 100%);
    color: var(--ui-text-primary);
    border-color: #ffd700;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

/* 接続状態表示 */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    font-size: 14px;
    color: var(--ui-text-secondary);
}

.status-indicator {
    font-size: 12px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* プレイヤー列対応のランキングヘッダー */
.ranking-header.with-player {
    grid-template-columns: 60px 120px 80px 120px 1fr;
}

.ranking-item.with-player {
    grid-template-columns: 60px 120px 80px 120px 1fr;
}

.player-col {
    text-align: center;
    font-weight: bold;
    color: #ffd700;
}

/* ローディングスピナー（小） */
.loading-spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid #444444;
    border-top: 2px solid #ffd700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

/* ランキングローディング */
.ranking-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--ui-text-secondary);
    font-size: 16px;
}

/* ランキングエラー */
.ranking-error {
    text-align: center;
    color: #ff6666;
    font-size: 16px;
    padding: 40px;
    background: rgba(255, 0, 0, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 0, 0, 0.3);
}

/* ゲームオーバー画面のランキング選択 */
.game-over-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
}

/* スコア0の場合の単一ボタン中央配置 */
.game-over-buttons:has(.game-over-btn[style*="display: none"]) {
    justify-content: center;
}

.game-over-buttons .game-over-btn:only-child {
    justify-self: center;
}

.game-over-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 180px;
}

.game-over-btn.ranking-btn {
    background: linear-gradient(135deg, #1a7a1a 0%, #2d8f2d 50%, #4db84d 100%);
    color: white;
    border-color: #4db84d;
}

.game-over-btn.ranking-btn:hover {
    background: linear-gradient(135deg, #2d8f2d 0%, #4db84d 50%, #66cc66 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(77, 184, 77, 0.4);
}

.game-over-btn.skip-btn {
    background: linear-gradient(135deg, #666666 0%, #777777 50%, #888888 100%);
    color: white;
    border-color: #888888;
}

.game-over-btn.skip-btn:hover {
    background: linear-gradient(135deg, #777777 0%, #888888 50%, #999999 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(136, 136, 136, 0.4);
}

/* キーボード選択時のボタンスタイル */
.game-over-btn.selected {
    animation: selectedButtonPulse 1.5s infinite;
}

/* === ランキング画面レスポンシブデザイン === */
@media screen and (max-width: 768px) {
    /* ランキング画面全体 */
    .ranking-content {
        padding: 15px;
        max-width: 95vw;
        width: 95vw;
        max-height: 90vh;
    }
    
    /* ランキングタイトル */
    .ranking-title {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    /* ランキングタブ */
    .ranking-tabs {
        gap: 5px;
        margin-bottom: 15px;
        flex-wrap: wrap;
    }
    
    .ranking-tab {
        padding: 8px 12px;
        font-size: 12px;
        flex: 1;
        min-width: 80px;
    }
    
    /* ランキングテーブル */
    .ranking-table {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    /* ランキングヘッダー - モバイル用レイアウト */
    .ranking-header {
        grid-template-columns: 35px 70px 45px 1fr;
        gap: 8px;
        font-size: 12px;
        padding: 8px 0;
        margin-bottom: 10px;
    }
    
    .ranking-header.with-player {
        grid-template-columns: 30px 60px 40px 44px 1fr;
        gap: 5px;
        font-size: 13px;
    }
    
    /* ランキングアイテム - モバイル用レイアウト */
    .ranking-item {
        grid-template-columns: 35px 70px 45px 1fr;
        gap: 8px;
        font-size: 14px;
        padding: 10px 0;
    }
    
    .ranking-item.with-player {
        grid-template-columns: 30px 60px 40px 44px 1fr;
        gap: 5px;
        font-size: 13px;
    }
    
    /* 各列の調整 */
    .rank-col {
        font-size: 14px;
    }
    
    .score-col {
        font-size: 13px;
        font-weight: normal;
    }
    
    .kills-col {
        font-size: 13px;
    }
    
    .player-col {
        font-size: 12px;
        font-weight: normal;
    }
    
    .date-col {
        font-size: 12px;
    }
    
    /* 1位〜3位の特別スタイル調整 */
    .ranking-item:nth-child(1) .rank-col {
        font-size: 16px;
    }
    
    .ranking-item:nth-child(2) .rank-col,
    .ranking-item:nth-child(3) .rank-col {
        font-size: 15px;
    }
    
    /* ランキングリスト */
    .ranking-list {
        max-height: 300px;
    }
    
    /* ランキングアクション */
    .ranking-actions {
        gap: 10px;
        margin-top: 15px;
    }
    
    .ranking-btn {
        padding: 10px 16px;
        font-size: 14px;
        flex: 1;
        max-width: 150px;
    }
    
    /* 接続状態表示 */
    .connection-status {
        font-size: 12px;
        margin-bottom: 10px;
    }
    
    /* エラー・ローディング表示 */
    .ranking-loading,
    .ranking-error,
    .no-scores {
        font-size: 14px;
        padding: 20px;
    }
}

/* より小さなスマートフォン向け調整 */
@media screen and (max-width: 480px) {
    .ranking-content {
        padding: 12px;
    }
    
    .ranking-title {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    /* ランキングヘッダー - 超小画面用 */
    .ranking-header {
        grid-template-columns: 30px 65px 40px 1fr;
        gap: 5px;
        font-size: 11px;
    }
    
    .ranking-header.with-player {
        grid-template-columns: 25px 55px 35px 36px 1fr;
        gap: 3px;
        font-size: 12px;
    }
    
    /* ランキングアイテム - 超小画面用 */
    .ranking-item {
        grid-template-columns: 30px 65px 40px 1fr;
        gap: 5px;
        font-size: 13px;
        padding: 8px 0;
    }
    
    .ranking-item.with-player {
        grid-template-columns: 25px 55px 35px 36px 1fr;
        gap: 3px;
        font-size: 12px;
    }
    
    /* 各列のさらなる調整 */
    .rank-col {
        font-size: 13px;
    }
    
    .score-col {
        font-size: 12px;
    }
    
    .kills-col {
        font-size: 12px;
    }
    
    .player-col {
        font-size: 11px;
    }
    
    .date-col {
        font-size: 11px;
    }
    
    /* 1位〜3位の調整 */
    .ranking-item:nth-child(1) .rank-col {
        font-size: 15px;
    }
    
    .ranking-item:nth-child(2) .rank-col,
    .ranking-item:nth-child(3) .rank-col {
        font-size: 14px;
    }
    
    /* ランキングタブをさらにコンパクトに */
    .ranking-tab {
        padding: 6px 8px;
        font-size: 11px;
        min-width: 70px;
    }
    
    /* ボタンサイズ調整 */
    .ranking-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* === モンスター図鑑レスポンシブデザイン === */
@media screen and (max-width: 768px) {
    /* 図鑑画面全体 */
    .encyclopedia-content {
        padding: 20px;
        max-width: 95%;
        max-height: 85vh;
    }
    
    /* 図鑑タイトル */
    .encyclopedia-title {
        font-size: 1.8rem;
        margin-bottom: 15px;
    }
    
    /* 図鑑統計表示 */
    .encyclopedia-stats {
        display: flex;
        flex-direction: row !important;
        gap: 25px;
        margin-bottom: 15px;
        padding: 12px;
        flex-wrap: wrap;
        justify-content: space-around;
    }
    
    .stat-item {
        font-size: 1rem;
        min-width: 120px;
    }
    
    .stat-label {
        font-size: 0.9rem;
    }
    
    .stat-value {
        font-size: 1.1rem;
        font-weight: bold;
    }
    
    .stat-total {
        font-size: 0.9rem;
    }
    
    /* フィルターボタン */
    .encyclopedia-filters {
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .filter-btn {
        padding: 8px 14px;
        font-size: 0.9rem;
        flex: 1;
        min-width: 60px;
    }
    
    /* グリッドレイアウト */
    .encyclopedia-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
        max-height: 45vh;
        margin-bottom: 15px;
    }
    
    /* アクション */
    .encyclopedia-actions {
        margin-top: 15px;
    }
    
    .encyclopedia-btn {
        padding: 10px 20px;
        font-size: 1rem;
    }
}

/* より小さなスマートフォン向け調整 */
@media screen and (max-width: 480px) {
    .encyclopedia-content {
        padding: 15px;
    }
    
    /* タイトルをさらに小さく */
    .encyclopedia-title {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }
    
    /* 統計表示 */
    .encyclopedia-stats {
        display: flex;
        flex-direction: row;
        gap: 12px;
        margin-bottom: 12px;
        padding: 10px;
        justify-content: space-around;
    }
    
    .stat-item {
        font-size: 0.8rem;
        text-align: center;
        flex: 1;
        max-width: 45%;
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 4px;
    }
    
    .stat-label {
        font-size: 0.75rem;
        display: inline;
    }
    
    .stat-value {
        font-size: 0.9rem;
        font-weight: bold;
    }
    
    .stat-total {
        font-size: 0.75rem;
    }
    
    /* フィルターボタンをより小さく */
    .encyclopedia-filters {
        gap: 5px;
        margin-bottom: 12px;
    }
    
    .filter-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
        min-width: 50px;
    }
    
    /* グリッドをより密に */
    .encyclopedia-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
        max-height: 40vh;
        margin-bottom: 12px;
    }
    
    /* ボタンサイズ調整 */
    .encyclopedia-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
}
    border-color: #ffef94;
}

.name-btn.selected {
    animation: selectedButtonPulse 1.5s infinite;
    border-color: #ffef94;
}

@keyframes selectedButtonPulse {
    0%, 100% { 
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
        transform: scale(1.05);
    }
    50% { 
        box-shadow: 0 0 25px rgba(255, 215, 0, 1.0);
        transform: scale(1.08);
    }
}

/* プレイヤー名入力画面 */
.player-name-input {
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #ffd700;
    border-radius: 15px;
    padding: 30px;
    margin: 20px 0;
    text-align: center;
}

.name-input-title {
    color: #ffd700;
    font-size: 20px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.name-input-container {
    margin-bottom: 20px;
}

.name-input-field {
    width: 300px;
    max-width: 90%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid #ffd700;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    text-align: center;
    margin-bottom: 10px;
}

.name-input-field:focus {
    outline: none;
    border-color: #ffef94;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.name-input-info {
    font-size: 14px;
    color: var(--ui-text-secondary);
}

.current-name {
    color: #ffd700;
    font-weight: bold;
    margin-bottom: 5px;
}

.name-input-note {
    color: #aaaaaa;
    font-style: italic;
}

.name-input-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 15px;
}

.name-input-help {
    margin-bottom: 15px;
}

.keyboard-help {
    font-size: 12px;
    color: #999999;
    text-align: center;
    margin: 0;
    font-style: italic;
}

.name-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.name-btn.confirm-btn {
    background: linear-gradient(135deg, #1a7a1a 0%, #2d8f2d 50%, #4db84d 100%);
    color: white;
    border-color: #4db84d;
}

.name-btn.confirm-btn:hover {
    background: linear-gradient(135deg, #2d8f2d 0%, #4db84d 50%, #66cc66 100%);
    transform: translateY(-1px);
}

.name-btn.cancel-btn {
    background: linear-gradient(135deg, #8b0000 0%, #a52a2a 50%, #dc143c 100%);
    color: white;
    border-color: #dc143c;
}

.name-btn.cancel-btn:hover {
    background: linear-gradient(135deg, #a52a2a 0%, #dc143c 50%, #ff6347 100%);
    transform: translateY(-1px);
}

.name-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ランキング送信状態表示 */
.submission-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    color: #ffd700;
    font-size: 14px;
}

.status-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #444444;
    border-top: 2px solid #ffd700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.settings-content,
.tutorial-content {
    background: linear-gradient(135deg, #2c1810 0%, #4a2c2a 50%, #654321 100%);
    border: 2px solid #ffd700;
    border-radius: 15px;
    padding: 30px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.settings-title,
.tutorial-title {
    font-size: 2rem;
    color: #ffd700;
    text-align: center;
    margin-bottom: 25px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
}

.settings-section,
.tutorial-section {
    margin-bottom: 25px;
}

.settings-section h3,
.tutorial-section h3 {
    color: #ffed4e;
    font-size: 1.3rem;
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    padding-bottom: 5px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-item input[type="range"] {
    flex: 1;
    margin: 0 15px;
    /* reset.cssのappearance: noneを上書きしてブラウザデフォルトに戻す */
    -webkit-appearance: auto;
    -moz-appearance: auto;
    appearance: auto;
    /* キーボード操作を無効化 */
    outline: none !important;
    border: none !important;
}

.setting-item input[type="range"]:focus {
    outline: none !important;
    box-shadow: none !important;
}

.volume-value {
    min-width: 50px;
    color: #ffd700;
    font-weight: bold;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
}

.control-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
}

.control-item ul {
    margin-top: 10px;
    padding-left: 20px;
}

.control-item li {
    margin-bottom: 5px;
}

.settings-actions,
.tutorial-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
}

.settings-btn,
.tutorial-btn {
    background: linear-gradient(135deg, #4a2c2a 0%, #6d3f3a 100%);
    border: 2px solid #ffd700;
    color: white;
    padding: 10px 25px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.settings-btn:hover,
.tutorial-btn:hover {
    background: linear-gradient(135deg, #6d3f3a 0%, #8b4c44 100%);
    transform: translateY(-1px);
}

.reset-btn {
    border-color: #ff6b35;
    background: linear-gradient(135deg, #d73027 0%, #fc8d59 100%);
}

.reset-btn:hover {
    background: linear-gradient(135deg, #fc8d59 0%, #fee08b 100%);
}

/* アニメーション */
@keyframes titleFadeIn {
    from {
        opacity: 0;
        transform: translateY(50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes titlePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes monsterFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes effectRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes blockFloat {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }
    
    .title-btn {
        min-width: 250px;
        padding: 12px 25px;
    }
    
    .btn-text {
        font-size: 1.1rem;
    }
    
    .title-monster-image {
        width: 100px;
        height: 100px;
    }
    
    .controls-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-content,
    .tutorial-content {
        padding: 20px;
        margin: 10px;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 2rem;
    }
    
    .title-btn {
        min-width: 200px;
        padding: 10px 20px;
    }
    
    .btn-text {
        font-size: 1rem;
    }
    
    .title-monster-image {
        width: 80px;
        height: 80px;
    }
}

/* モンスター図鑑画面スタイル */
.encyclopedia-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2c1810 0%, #8b4513 50%, #654321 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.encyclopedia-content {
    background: rgba(0, 0, 0, 0.9);
    padding: 30px;
    border-radius: 20px;
    border: 3px solid #8b4513;
    box-shadow: 0 0 50px rgba(139, 69, 19, 0.8);
    max-width: 1000px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.encyclopedia-title {
    text-align: center;
    color: #ffd700;
    font-size: 2.5rem;
    margin-bottom: 25px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.encyclopedia-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(139, 69, 19, 0.3);
    border-radius: 10px;
}

.stat-item {
    text-align: center;
    color: white;
    font-size: 1.1rem;
}

.stat-label {
    color: #ccc;
    margin-right: 5px;
}

.stat-value {
    color: #ffd700;
    font-weight: bold;
    font-size: 1.3rem;
}

.stat-total {
    color: #aaa;
}

.encyclopedia-filters {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filter-btn {
    background: rgba(139, 69, 19, 0.6);
    color: white;
    border: 2px solid #8b4513;
    border-radius: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.filter-btn:hover {
    background: rgba(139, 69, 19, 0.8);
    transform: translateY(-2px);
}

.filter-btn.active {
    background: #ffd700;
    color: #2c1810;
    border-color: #ffd700;
    font-weight: bold;
}

.encyclopedia-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    max-height: 50vh;
    overflow-y: auto;
    padding: 10px;
    /* スマートフォンでのスムーズスクロール */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.monster-card {
    background: rgba(139, 69, 19, 0.4);
    border: 2px solid #8b4513;
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.monster-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(139, 69, 19, 0.6);
    border-color: #ffd700;
}

.monster-card.discovered {
    border-color: #32cd32;
    background: rgba(50, 205, 50, 0.1);
}

.monster-card.undiscovered {
    border-color: #666;
    background: rgba(102, 102, 102, 0.2);
}

.monster-card-image {
    width: 80px;
    height: 80px;
    margin: 0 auto 10px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.monster-card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.monster-card-image.silhouette img {
    filter: contrast(0) brightness(0.4);
}

.monster-card-name {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: white;
}

.monster-card.undiscovered .monster-card-name {
    color: #666;
}

.monster-card-type {
    font-size: 0.8rem;
    color: #ccc;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.monster-card-defeats {
    font-size: 0.9rem;
    color: #ffd700;
    font-weight: bold;
}

.monster-card.undiscovered .monster-card-defeats {
    color: #666;
}

.encyclopedia-actions {
    text-align: center;
    margin-top: 20px;
}

.encyclopedia-btn {
    background: linear-gradient(135deg, #8b4513 0%, #a0522d 100%);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 25px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 10px;
}

.encyclopedia-btn:hover {
    background: linear-gradient(135deg, #a0522d 0%, #8b4513 100%);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 69, 19, 0.4);
}

/* ===== モンスター詳細モーダル ===== */

.monster-detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.monster-detail-content {
    background: linear-gradient(135deg, #2c1810, #3d2520);
    border: 3px solid #8b4513;
    border-radius: 15px;
    width: 90%;
    max-width: 800px;
    max-height: 90%;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 0 30px rgba(139, 69, 19, 0.5);
    /* スマートフォンでのスムーズスクロール */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.monster-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #8b4513;
    padding-bottom: 10px;
}

.monster-detail-title {
    color: #ffd700;
    font-size: 28px;
    font-weight: bold;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.monster-detail-close {
    background: rgba(139, 69, 19, 0.8);
    border: 2px solid #cd853f;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
    z-index: 9999;
    /* スマートフォンタッチ対応を強化 */
    touch-action: manipulation;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.3);
    /* タッチターゲットのサイズを拡張 */
    min-width: 50px !important;
    min-height: 50px !important;
}

.monster-detail-close:hover {
    background: rgba(205, 133, 63, 0.8);
    transform: scale(1.1);
}

.monster-detail-close:active {
    background: rgba(205, 133, 63, 1.0);
    transform: scale(0.95);
    transition: all 0.1s ease;
}

/* スマートフォン専用のクローズボタン強化 */
@media (max-width: 768px), (pointer: coarse) {
    .monster-detail-close {
        width: 60px !important;
        height: 60px !important;
        font-size: var(--text-4xl);
        min-width: 60px !important;
        min-height: 60px !important;
        z-index: 99999 !important;
        border: 3px solid #cd853f !important;
        /* タッチ領域をさらに拡張 */
        padding: 10px !important;
        margin: 10px !important;
    }
    
    .monster-detail-close:active {
        background: rgba(255, 165, 0, 0.9);
        border-color: #ffa500;
        transform: scale(var(--scale-small));
    }
}

.monster-detail-main {
    display: flex;
    gap: 30px;
    margin-bottom: 25px;
    height: 400px;
}

.monster-detail-left {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 400px;
    width: 50%;
}

.monster-detail-image-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.monster-detail-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 3px solid #8b4513;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.monster-detail-right {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 400px;
    width: 50%;
}

.monster-detail-radar {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #8b4513;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#monsterDetailRadarCanvas {
    max-width: 100%;
    max-height: 100%;
}


.monster-detail-flavor {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #8b4513;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.flavor-title {
    color: #ffd700;
    font-size: 20px;
    font-weight: bold;
    margin: 0 0 15px 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.flavor-text {
    color: #e6ddd4;
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
}

.monster-detail-info {
    display: flex;
    justify-content: center;
}

.detail-info-item {
    background: rgba(139, 69, 19, 0.3);
    border: 2px solid #8b4513;
    border-radius: 8px;
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.detail-info-item .info-label {
    color: #cd853f;
    font-size: 14px;
    font-weight: bold;
}

.detail-info-item .info-value {
    color: #ffd700;
    font-size: 18px;
    font-weight: bold;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .monster-detail-main {
        flex-direction: column;
        gap: 20px;
        height: auto;
    }
    
    .monster-detail-left {
        height: 300px;
    }
    
    
    .monster-detail-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .encyclopedia-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }
    
    .encyclopedia-stats {
        flex-direction: column;
        gap: 15px;
    }
    
    .encyclopedia-filters {
        gap: 5px;
    }
    
    .filter-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

/* スマートフォン向け最適化 */
@media (max-width: 480px) {
    .monster-appear-modal {
        padding: 12px 15px;
        max-width: 98vw;
        border-radius: 12px;
    }
    
    .monster-appear-header {
        gap: 10px;
    }
    
    .monster-appear-image img {
        width: 150px;
        height: 150px;
    }
    
    .monster-appear-text {
        font-size: 18px;
    }
    
    .monster-appear-header {
        flex-direction: row;
        justify-content: space-between;
        gap: 10px;
        padding: 0 5px;
    }
    
    .monster-appear-image {
        flex: 1;
        max-width: 45vw;
    }
    
    .monster-appear-image img {
        width: min(150px, 40vw);
        height: min(150px, 40vw);
        max-width: 100%;
        max-height: 100%;
    }
    
    .monster-radar-chart {
        flex: 1;
        height: min(150px, 40vw);
        max-width: 45vw;
    }
    
    #monsterRadarCanvas {
        max-width: 100%;
        max-height: 100%;
        width: auto !important;
        height: auto !important;
    }
    
    .monster-appear-stats {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .appear-stat {
        font-size: 14px;
        gap: 6px;
    }
    
    .monster-appear-flavor {
        padding: 10px 15px;
    }
}

/* タブレット向け最適化 */
@media (max-width: 768px) {
    .monster-appear-modal {
        padding: 15px 20px;
        max-width: 98vw;
        border-radius: 15px;
    }
    
    .monster-appear-header {
        flex-direction: row;
        justify-content: space-between;
        gap: 15px;
        padding: 0 10px;
    }
    
    .monster-appear-image {
        flex: 1;
        max-width: 48%;
    }
    
    .monster-appear-image img {
        width: min(160px, 45vw);
        height: min(160px, 45vw);
        max-width: 100%;
        max-height: 100%;
    }
    
    .monster-radar-chart {
        flex: 1;
        height: min(160px, 45vw);
        max-width: 48%;
    }
    
    #monsterRadarCanvas {
        max-width: 100%;
        max-height: 100%;
        width: auto !important;
        height: auto !important;
    }
    
    .monster-appear-title {
        flex-direction: column;
        gap: 10px;
    }
    
    .monster-appear-text {
        font-size: 20px;
    }
    
    .monster-appear-stats {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .appear-stat {
        font-size: 15px;
        gap: 7px;
    }
    
    .monster-appear-flavor {
        padding: 12px 18px;
    }
}

.monster-appear-content {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid rgba(139, 69, 19, 0.3);
    margin: 10px 0;
}

.monster-radar-chart {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    box-sizing: border-box;
    min-width: 0;
}

#monsterRadarCanvas {
    background: transparent;
}

/* プレイヤーバフエリアスタイル */
.player-buffs {
    background: rgba(0, 100, 200, 0.2);
    border: 2px solid rgba(0, 100, 200, 0.5);
    border-radius: 10px;
    padding: 8px 12px;
    margin-top: 8px;
    text-align: center;
}

.player-shield {
    color: #00aaff;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.player-shield span {
    color: var(--ui-text-primary);
    font-size: 16px;
}

.player-berserk {
    color: #ff4444;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    margin-top: 4px;
}

.player-berserk span {
    color: var(--ui-text-primary);
    font-size: 16px;
}

.player-pending-effect {
    color: #ffaa00;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    margin-top: 4px;
    animation: pendingPulse 2s ease-in-out infinite;
}

.player-pending-effect span {
    color: var(--ui-text-primary);
    font-size: 16px;
}

@keyframes pendingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ゲームオーバー要素のフェードインアニメーション */
@keyframes gameOverFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-over-element.fade-in {
    animation: gameOverFadeIn var(--anim-very-slow) var(--ease-out) forwards;
    opacity: 1; /* アニメーション完了後の状態を確実に適用 */
}

/* シールドエフェクトアニメーション */
@keyframes shieldPulse {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    25% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.0);
    }
    75% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
}

@keyframes shieldText {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0);
    }
    15% {
        opacity: 1;
        transform: translateX(-50%) scale(1.2);
    }
    30% {
        opacity: 1;
        transform: translateX(-50%) scale(1.0);
    }
    85% {
        opacity: 1;
        transform: translateX(-50%) scale(1.0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }
}


/* ===== 統合スマートフォン用メディアクエリ（リファクタリング版） ===== */
/*
分散していたスマートフォン用メディアクエリを1箇所に統合
新しいレイアウト実装用のクリーンな基盤を提供
*/

@media (max-width: 768px), (orientation: portrait) {
    /* 基本設定 - すべての要素のborderを内側に配置 */
    * {
        box-sizing: border-box !important;
    }
    
    body {
        font-size: 14px;
        overflow-x: hidden;
    }
    
    /* canvas-top-margin-overlay モバイル専用スタイル */
    #canvas-top-margin-overlay {
        background-size: 95% auto !important;
    }
    
    /* ゲームフレーム - モバイル向け調整 */
    .game-frame {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important; /* フォールバック */
        height: 100dvh !important; /* 動的ビューポート対応 */
        border: none !important;
        border-radius: 0 !important;
        padding: 4px !important;
        background: #1a1a1a;
        box-shadow: none !important;
    }
    
    /* メインゲームコンテナを4行3列に変更 */
    .game-container {
        display: grid !important;
        grid-template-columns: 2.4fr 6fr 4.8fr !important;
        grid-template-rows: auto clamp(60px, 15vw, 120px) 1fr auto !important;
        grid-template-areas:
            "monster-area monster-area battle-area"
            "hold-area combo-area next-area"
            "game-area game-area player-area"
            "game-area game-area score-area" !important;
        gap: 1px !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        background: transparent !important;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0 !important;
    }
    
    /* PCレイアウトを壊さないよう慎重にscore-stats-gridを移動 */
    
    /* top-info-rowは残し、子要素をグリッドに再配置 */
    
    /* score-stats-gridを4行3列目に確実に配置（position:absolute削除） */
    .score-stats-grid {
        grid-area: score-area !important;
        grid-row: 4 / 5 !important;
        grid-column: 3 / 4 !important;
        display: flex !important;
        justify-content: space-between !important;
        background: rgba(0, 0, 0, 1);
        border-width: 2px !important;
        border-radius: 8px !important;
        padding: 6px !important;
        margin: 0 !important;
        width: auto !important;
        height: auto !important;
        align-self: stretch !important;
        justify-self: stretch !important;
        /* 親要素の制約を無効化 */
        order: 999 !important;
    }
    
    /* モンスター画像のレスポンシブサイズ設定 */
    .monster-image {
        width: clamp(80px, 14vw, 140px) !important;
        height: clamp(80px, 14vw, 140px) !important;
        max-width: 90% !important;
        object-fit: contain !important;
    }
    
    /* hold-areaもtop-info-rowから独立させてグリッドに配置 */
    .hold-area {
        position: relative !important;
        grid-area: hold-area !important;
        background: rgba(0, 0, 0, 1);
        border-width: 3px !important;
        border-radius: 4px !important;
        padding: 0 !important;
        margin: 0 !important;
        text-align: center;
        z-index: 10 !important;
        width: 100% !important;
        height: auto !important;
        align-self: stretch !important;
        justify-self: stretch !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    /* top-info-rowのmargin-bottomを0に */
    .top-info-row {
        margin-bottom: 0 !important;
    }
    
    /* hold-areaの無効化オーバーレイを正しく動作させる */
    .hold-area.disabled::after {
        content: "" !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        background: rgba(0, 0, 0, 0.4) !important;
        border-radius: 4px !important;
        z-index: 1 !important;
        pointer-events: none !important;
    }
    
    /* next-piece-displayのスマートフォン可変サイズ対応 - より効率的なサイズ計算 */
    .next-piece-display {
        width: clamp(45px, 12vw, 90px) !important;
        height: clamp(27px, 7vw, 54px) !important;
        min-width: 40px !important;
        min-height: 24px !important;
        flex: 1 !important;
        aspect-ratio: 5/3 !important;
        max-width: 100% !important;
    }
    
    /* 2番目・3番目のnext-pieceサイズを最適化 */
    .next-piece-item:nth-child(2) .next-piece-display,
    .next-piece-item:nth-child(3) .next-piece-display {
        width: clamp(35px, 8vw, 62px) !important;
        height: clamp(21px, 5vw, 37px) !important;
        min-width: 30px !important;
        min-height: 18px !important;
        aspect-ratio: 5/3 !important;
    }
    
    /* next-canvasサイズを改善されたサイズ計算に合わせて調整 */
    .next-canvas {
        width: clamp(45px, 12vw, 90px) !important;
        height: clamp(27px, 7vw, 54px) !important;
    }
    
    .next-piece-item:nth-child(2) .next-canvas,
    .next-piece-item:nth-child(3) .next-canvas {
        width: clamp(35px, 8vw, 62px) !important;
        height: clamp(21px, 5vw, 37px) !important;
    }
    
    /* ゲーム画面テキストサイズを画面横幅に応じて可変 */
    
    /* hold-areaのテキスト */
    .hold-header {
        font-size: var(--text-responsive-sm);
        margin-top: 0 !important;
        margin-bottom: 4px !important;
        padding: 4px 8px 0 8px !important;
    }
    
    /* next-piece headerのテキスト */
    .next-header {
        font-size: var(--text-responsive-sm);
    }
    
    .next-piece-item:nth-child(2) .next-header,
    .next-piece-item:nth-child(3) .next-header {
        font-size: var(--text-xs);
    }
    
    /* 2番目と3番目のnext-headerを非表示 */
    .next-piece-item:nth-child(2) .next-header,
    .next-piece-item:nth-child(3) .next-header,
    .next-piece-item:nth-child(5) .next-header {
        display: none !important;
    }
    
    /* スマートフォンでのnext-piece関連の調整 */
    .next-piece {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .game-container .next-piece {
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
    }
    
    .next-piece-display {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .next-header {
        padding: 4px 0 !important;
        margin: 0 !important;
    }
    
    .next-piece-item {
        padding: 0 !important;
        border-radius: 3px !important;
    }
    
    .next-piece-item:first-child {
        /* first-childのスタイルはデフォルトのまま維持 */
    }
    
    .next-pieces-container {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0 !important;
    }
    
    .game-container .next-pieces-container {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0 !important;
    }
    
    .next-piece-display {
        width: 100% !important;
        height: 100% !important;
    }
    
    /* スマートフォンでのnext-canvas アスペクト比修正（正方形に） */
    .next-canvas {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: contain !important;
    }
    
    .game-container .next-piece-item:first-child .next-canvas {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: contain !important;
    }
    
    .next-piece-item:nth-child(2) .next-canvas,
    .next-piece-item:nth-child(3) .next-canvas {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: contain !important;
    }
    
    /* score-stats-gridのテキスト */
    .score-stats-grid .score,
    .score-stats-grid .lines,
    .score-stats-grid .kills {
        font-size: var(--text-responsive-sm);
        white-space: normal !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        line-height: 1.1 !important;
    }
    
    .score-stats-grid .stat-colon {
        display: none !important;
    }
    
    .score-stats-grid .stat-label {
        font-size: 0.8em !important;
        margin-bottom: 2px !important;
    }
    
    .score-stats-grid .stat-value {
        font-weight: bold !important;
        font-size: 1.1em !important;
    }
    
    /* combo-infoのテキスト */
    .combo-count {
        font-size: var(--text-responsive-lg);
    }
    
    .combo-timer {
        font-size: var(--text-xs);
    }
    
    /* player-sectionのテキスト */
    .player-level {
        font-size: clamp(18px, 5.5vw, 28px) !important;
    }
    
    .player-exp-remaining {
        font-size: var(--text-xs);
    }
    
    .player-hp-label {
        font-size: var(--text-responsive-sm);
    }
    
    .player-hp-text {
        font-size: var(--text-xs);
    }
    
    .player-attack,
    .player-defense,
    .player-magic,
    .player-agility,
    .player-technique {
        font-size: clamp(10px, 3vw, 15px) !important;
    }
    
    .player-shield,
    .player-berserk,
    .player-pending-effect {
        font-size: var(--text-responsive-sm);
    }
    
    .player-shield span,
    .player-berserk span,
    .player-pending-effect span {
        font-size: clamp(12px, 3.2vw, 16px) !important;
    }
    
    /* battle-logのテキスト */
    .battle-log {
        font-size: clamp(8px, 2.2vw, 11px) !important;
    }
    
    .log-entry {
        font-size: clamp(8px, 2.2vw, 11px) !important;
    }
    
    /* monster-nameのフォントサイズを画面サイズに応じて可変 */
    .monster-name {
        font-size: clamp(10px, 3vw, 16px) !important;
    }
    
    /* ポップアップテキストのモバイル対応 */
    .special-warning-popup {
        font-size: clamp(16px, 4vw, 24px) !important;
    }
    
    .damage-popup {
        font-size: clamp(18px, 5vw, 28px) !important;
    }
    
    .miracle-damage-popup {
        font-size: clamp(24px, 6vw, 36px) !important;
    }
    
    .shield-popup {
        font-size: clamp(20px, 5vw, 32px) !important;
    }
    
    /* 3列目グリッドの幅制約を可変にする */
    
    /* next-piece-itemの最小幅を可変に */
    .next-piece-item {
        min-width: clamp(50px, 12vw, 94px) !important;
    }
    
    .next-piece-item:nth-child(2),
    .next-piece-item:nth-child(3) {
        min-width: clamp(35px, 8vw, 62px) !important;
        align-self: stretch !important;
        height: 100% !important;
    }
    
    /* next-piece-displayの幅を可変に */
    .next-piece-display {
        width: 100% !important;
        height: 100% !important;
        min-width: 30px !important;
        flex: 1 !important;
    }
    
    .next-piece-item:nth-child(2) .next-piece-display,
    .next-piece-item:nth-child(3) .next-piece-display {
        width: clamp(40px, 6vw, 62px) !important;
        height: clamp(24px, 4vw, 37px) !important;
        min-width: 35px !important;
        min-height: 21px !important;
    }
    
    /* score-stats-gridの幅をグリッドいっぱいに */
    .score-stats-grid {
        max-width: unset !important;
        min-width: unset !important;
        width: 100% !important;
    }
    
    /* hold-areaの幅制約を削除して完全可変に */
    .hold-area {
        min-width: unset !important;
        max-width: unset !important;
        width: 100% !important;
    }
    
    /* hold-area内の要素も可変に */
    .hold-piece-display {
        width: 100% !important;
        height: 100% !important;
        min-width: unset !important;
        max-width: unset !important;
        padding: 0 !important;
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .hold-canvas {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
    }
    
    /* battle-logの幅をグリッドいっぱいに */
    .battle-log {
        max-width: unset !important;
        min-width: unset !important;
        width: 100% !important;
    }
    
    /* player-sectionの幅をグリッドいっぱいに */
    .player-section {
        max-width: unset !important;
        min-width: unset !important;
        width: 100% !important;
    }
    
    /* JavaScriptで移動されたscore-stats-gridのスタイル - 3列グリッドレイアウト */
    .score-stats-grid.mobile-repositioned {
        grid-area: score-area !important;
        grid-row: 4 / 5 !important;
        grid-column: 3 / 4 !important;
        position: static !important;
        background: rgba(0, 0, 0, 1);
        border-width: 2px !important;
        border-radius: 8px !important;
        padding: 8px !important;
        margin: 0 !important;
        z-index: 5 !important;
        max-width: unset !important;
        min-width: unset !important;
        width: 100% !important;
        
        /* 2列グリッドレイアウトに変更（linesが非表示のため） */
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0 !important;
        justify-content: center !important;
        align-items: center !important;
    }
    
    /* mobile-repositioned時のスコア項目のスタイル調整 */
    .score-stats-grid.mobile-repositioned .score,
    .score-stats-grid.mobile-repositioned .kills {
        text-align: center;
        font-size: clamp(10px, 3vw, 14px) !important;
        font-weight: bold !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        padding: 4px 2px !important;
    }
    
    /* mobile-repositioned時にlinesを非表示 */
    .score-stats-grid.mobile-repositioned .lines {
        display: none !important;
    }
}

/* 480px以下での追加テキストサイズ調整のみ（next-canvasの重複削除） */
@media (max-width: 480px) {
    
    /* 超小型画面でのテキストサイズ微調整 */
    .player-level {
        font-size: clamp(16px, 6vw, 24px) !important;
    }
    
    .combo-count {
        font-size: clamp(12px, 4.5vw, 18px) !important;
    }
    
    .hold-header,
    .next-header {
        font-size: clamp(8px, 3.2vw, 12px) !important;
    }
    
    /* 超小型画面でも2番目と3番目のnext-headerを非表示 */
    .next-piece-item:nth-child(2) .next-header,
    .next-piece-item:nth-child(3) .next-header,
    .next-piece-item:nth-child(5) .next-header {
        display: none !important;
    }
    
    .score-stats-grid .score,
    .score-stats-grid .lines,
    .score-stats-grid .kills {
        font-size: clamp(8px, 3.2vw, 12px) !important;
        white-space: normal !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        line-height: 1.1 !important;
    }
    
    .score-stats-grid .stat-colon {
        display: none !important;
    }
    
    .score-stats-grid .stat-label {
        font-size: 0.75em !important;
        margin-bottom: 1px !important;
    }
    
    .score-stats-grid .stat-value {
        font-weight: bold !important;
        font-size: 1.2em !important;
    }
    
    /* 超小型画面でのmonster-name調整 */
    .monster-name {
        font-size: clamp(8px, 4vw, 12px) !important;
    }
    
    /* 超小型画面でのモンスター画像サイズ調整 */
    .monster-image {
        width: clamp(60px, 10vw, 100px) !important;
        height: clamp(60px, 10vw, 100px) !important;
    }
    
    /* 超小型画面での3列目要素のさらなる幅制約緩和 */
    .next-piece-item {
        min-width: clamp(40px, 15vw, 70px) !important;
    }
    
    .next-piece-item:nth-child(2),
    .next-piece-item:nth-child(3) {
        min-width: clamp(30px, 12vw, 50px) !important;
        align-self: stretch !important;
        height: 100% !important;
    }
    
    .score-stats-grid {
        max-width: unset !important;
        min-width: unset !important;
        width: 100% !important;
    }
    
    .player-section {
        max-width: unset !important;
        min-width: unset !important;
        width: 100% !important;
    }
    
    .battle-log {
        max-width: unset !important;
        min-width: unset !important;
        width: 100% !important;
    }
    
    /* 超小型画面でのhold-area調整 */
    .hold-piece-display {
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .hold-canvas {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
    }
}

/* 大型スマートフォン（768px以上）でのnext-piece-displayサイズ調整 */
@media (min-width: 769px) and (max-width: 1024px) and (orientation: portrait) {
    .next-piece-display {
        width: clamp(60px, 10vw, 110px) !important;
        height: clamp(36px, 6vw, 66px) !important;
        min-width: 50px !important;
        min-height: 30px !important;
        flex: 1 !important;
        aspect-ratio: 5/3 !important;
    }
    
    .next-piece-item:nth-child(2) .next-piece-display,
    .next-piece-item:nth-child(3) .next-piece-display {
        width: clamp(45px, 7vw, 70px) !important;
        height: clamp(27px, 4vw, 42px) !important;
        min-width: 40px !important;
        min-height: 24px !important;
        aspect-ratio: 5/3 !important;
    }
    
    .next-canvas {
        width: clamp(60px, 10vw, 110px) !important;
        height: clamp(36px, 6vw, 66px) !important;
    }
    
    .next-piece-item:nth-child(2) .next-canvas,
    .next-piece-item:nth-child(3) .next-canvas {
        width: clamp(45px, 7vw, 70px) !important;
        height: clamp(27px, 4vw, 42px) !important;
    }
    
    /* タブレットでのnext-header margin設定 */
    .next-header {
        padding: 4px 0 !important;
        margin: 0 !important;
    }
    
    /* タブレット用グリッドレイアウト（スマートフォンと同じ） */
    .game-container {
        display: grid !important;
        grid-template-columns: 2.4fr 6fr 4.8fr !important;
        grid-template-rows: auto clamp(60px, 15vw, 120px) 1fr auto !important;
        grid-template-areas:
            "monster-area monster-area battle-area"
            "hold-area combo-area next-area"
            "game-area game-area player-area"
            "game-area game-area score-area" !important;
        gap: 1px !important;
        padding: 4px !important;
        box-sizing: border-box !important;
        background: #1a1a1a;
        width: 100vw !important;
        height: 100vh !important; /* フォールバック */
        height: 100dvh !important; /* 動的ビューポート対応 */
    }
    
    /* タブレット用 score-stats-grid 配置 */
    .score-stats-grid {
        grid-area: score-area !important;
        grid-row: 4 / 5 !important;
        grid-column: 3 / 4 !important;
        display: flex !important;
        justify-content: space-between !important;
        background: rgba(0, 0, 0, 1);
        border-width: 2px !important;
        border-radius: 8px !important;
        padding: 8px !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    .game-container .next-pieces-container {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
    }
    
    /* タブレット横向きでのnext-piece-display サイズ調整 */
    .next-piece-display {
        width: clamp(70px, 8vw, 100px) !important;
        height: clamp(42px, 5vw, 60px) !important;
        min-width: 60px !important;
        min-height: 36px !important;
        aspect-ratio: 5/3 !important;
        flex: 1 !important;
    }
    
    /* タブレット向けモンスター画像サイズ */
    .monster-image {
        width: clamp(100px, 12vw, 150px) !important;
        height: clamp(100px, 12vw, 150px) !important;
        max-width: 95% !important;
    }
    
    /* タブレットでのcombo-info縦幅調整 */
    .game-container .combo-info {
        grid-area: combo-area !important;
        width: auto !important;
        height: 100% !important;
        padding: 8px !important;
        margin: 0 !important;
        background: rgba(0, 0, 0, 1);
        border-width: 2px !important;
        border-radius: 8px !important;
        text-align: center;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        flex-shrink: 0 !important;
    }
    
    /* タブレットでのnext-canvas アスペクト比修正（正方形に） */
    .next-canvas {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: contain !important;
    }
    
    .game-container .next-piece-item:first-child .next-canvas {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: contain !important;
    }
    
    .next-piece-item:nth-child(2) .next-canvas,
    .next-piece-item:nth-child(3) .next-canvas {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1 / 1 !important;
        object-fit: contain !important;
    }
    
    /* 大型スマートフォンでのテキストサイズ最適化 */
    .player-level {
        font-size: clamp(24px, 4.5vw, 32px) !important;
    }
    
    .combo-count {
        font-size: clamp(18px, 3.5vw, 24px) !important;
    }
    
    .hold-header,
    .next-header {
        font-size: clamp(12px, 2.2vw, 16px) !important;
    }
    
    /* 大型スマートフォンでも2番目と3番目のnext-headerを非表示 */
    .next-piece-item:nth-child(2) .next-header,
    .next-piece-item:nth-child(3) .next-header,
    .next-piece-item:nth-child(5) .next-header {
        display: none !important;
    }
    
    .score-stats-grid .score,
    .score-stats-grid .lines,
    .score-stats-grid .kills {
        font-size: clamp(12px, 2.2vw, 16px) !important;
        white-space: normal !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        line-height: 1.1 !important;
    }
    
    .score-stats-grid .stat-colon {
        display: none !important;
    }
    
    .score-stats-grid .stat-label {
        font-size: 0.8em !important;
        margin-bottom: 2px !important;
    }
    
    .score-stats-grid .stat-value {
        font-weight: bold !important;
        font-size: 1.1em !important;
    }
    
    .player-attack,
    .player-defense,
    .player-magic,
    .player-agility,
    .player-technique {
        font-size: clamp(13px, 2.5vw, 18px) !important;
    }
    
    .battle-log,
    .log-entry {
        font-size: clamp(10px, 1.8vw, 13px) !important;
    }
    
    /* 大型スマートフォンでのmonster-name調整 */
    .monster-name {
        font-size: clamp(12px, 2.5vw, 18px) !important;
    }
    
    /* 大型スマートフォンでの3列目要素の幅制約最適化 */
    .next-piece-item {
        min-width: clamp(60px, 10vw, 94px) !important;
    }
    
    .next-piece-item:nth-child(2),
    .next-piece-item:nth-child(3) {
        min-width: clamp(45px, 7vw, 62px) !important;
        align-self: stretch !important;
        height: 100% !important;
    }
    
    .score-stats-grid {
        max-width: unset !important;
        min-width: unset !important;
        width: 100% !important;
    }
    
    .player-section {
        max-width: unset !important;
        min-width: unset !important;
        width: 100% !important;
    }
    
    .battle-log {
        max-width: unset !important;
        min-width: unset !important;
        width: 100% !important;
    }
    
    /* 大型スマートフォンでのhold-area調整 */
    .hold-piece-display {
        width: 100% !important;
        height: 100% !important;
        padding: 0 !important;
        flex: 1 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .hold-canvas {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
    }
}

/* =============================
   パフォーマンス設定モーダル
   ============================= */

.performance-settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    touch-action: manipulation;
}

.performance-settings-content {
    background: linear-gradient(145deg, #1e1e1e 0%, #2a2a2a 100%);
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    color: var(--ui-text-primary);
    touch-action: manipulation;
}

.performance-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #444;
}

.performance-settings-title {
    margin: 0;
    font-size: 1.4em;
    font-weight: bold;
    color: var(--ui-text-primary);
}

.performance-settings-close {
    background: none;
    border: none;
    font-size: 1.8em;
    color: #ccc;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: all 0.2s;
    touch-action: manipulation;
}

.performance-settings-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.performance-settings-body {
    padding: 25px;
}

/* デバイス検出結果 */
.device-detection-info {
    background: linear-gradient(135deg, #2d4a22 0%, #3a5e2f 100%);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 25px;
    border: 1px solid #4a6f3d;
}

.detection-title {
    font-size: 0.9em;
    color: #a0d0a0;
    margin-bottom: 8px;
    font-weight: bold;
}

.detection-result {
    font-size: 1.1em;
    color: var(--ui-text-primary);
    font-weight: bold;
}

/* セクション */
.section-title {
    font-size: 1.1em;
    color: var(--ui-text-primary);
    margin-bottom: 15px;
    font-weight: bold;
    border-left: 4px solid #6495ed;
    padding-left: 10px;
}

/* レベル選択 */
.performance-level-section {
    margin-bottom: 30px;
}

.level-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.level-option {
    display: flex;
    align-items: center;
    padding: 15px;
    border: 2px solid #444;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(135deg, #2a2a2a 0%, #333333 100%);
    touch-action: manipulation;
}

.level-option:hover {
    border-color: #6495ed;
    background: linear-gradient(135deg, #334155 0%, #3f4f5f 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(100, 149, 237, 0.2);
}

.level-option input[type="radio"] {
    display: none;
}

.level-radio {
    width: 18px;
    height: 18px;
    border: 2px solid #666;
    border-radius: 50%;
    margin-right: 15px;
    position: relative;
    transition: all 0.3s ease;
}

.level-option input[type="radio"]:checked + .level-radio {
    border-color: #6495ed;
    background: #6495ed;
}

.level-option input[type="radio"]:checked + .level-radio::after {
    content: '';
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.level-info {
    flex: 1;
}

.level-name {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--ui-text-primary);
    margin-bottom: 5px;
}

.level-desc {
    font-size: 0.85em;
    color: #aaa;
    line-height: 1.3;
}

/* 詳細設定 */
.custom-settings-section {
    margin-bottom: 20px;
}

.custom-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
}

.custom-setting {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.custom-setting label {
    font-size: 0.9em;
    color: #ccc;
    font-weight: bold;
}

.custom-setting select {
    padding: 8px 12px;
    background: #333;
    border: 1px solid #555;
    border-radius: 6px;
    color: var(--ui-text-primary);
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
}

.custom-setting select:hover,
.custom-setting select:focus {
    border-color: #6495ed;
    background: #3a3a3a;
    outline: none;
}

/* フッター */
.performance-settings-footer {
    display: flex;
    gap: 15px;
    padding: 20px 25px;
    border-top: 1px solid #444;
    justify-content: flex-end;
}

.settings-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 100px;
    touch-action: manipulation;
}

.settings-cancel {
    background: #555;
    color: var(--ui-text-primary);
}

.settings-cancel:hover {
    background: #666;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.settings-apply {
    background: linear-gradient(135deg, #6495ed 0%, #4169e1 100%);
    color: var(--ui-text-primary);
}

.settings-apply:hover {
    background: linear-gradient(135deg, #4169e1 0%, #1e90ff 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(100, 149, 237, 0.4);
}

/* 設定ボタン（右上コントロール）のスタイル向上 */
.settings-button:hover {
    background: rgba(100, 149, 237, 0.8) !important;
    border-color: #6495ed;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(100, 149, 237, 0.3) !important;
}

/* =============================
   設定画面のタブ機能
   ============================= */

.settings-tabs {
    display: flex;
    border-bottom: 2px solid #444;
    margin-bottom: 25px;
    gap: 0;
}

.settings-tab {
    flex: 1;
    padding: 15px 20px;
    background: linear-gradient(135deg, #2a2a2a 0%, #333333 100%);
    border: none;
    border-bottom: 3px solid transparent;
    color: #aaa;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
}

.settings-tab:first-child {
    border-top-left-radius: 8px;
}

.settings-tab:last-child {
    border-top-right-radius: 8px;
}

.settings-tab:hover {
    background: linear-gradient(135deg, #334155 0%, #3f4f5f 100%);
    color: #ccc;
    transform: translateY(-2px);
}

.settings-tab.active {
    background: linear-gradient(135deg, #6495ed 0%, #4169e1 100%);
    color: var(--ui-text-primary);
    border-bottom-color: #6495ed;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(100, 149, 237, 0.3);
}

.settings-tab-content {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.settings-tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 適用ボタンのスタイル */
.apply-btn {
    background: linear-gradient(135deg, #6495ed 0%, #4169e1 100%) !important;
    color: #ffffff;
}

.apply-btn:hover {
    background: linear-gradient(135deg, #4169e1 0%, #1e90ff 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(100, 149, 237, 0.4) !important;
}

/* モバイル対応 */
@media (max-width: 600px) {
    .performance-settings-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .custom-settings-grid {
        grid-template-columns: 1fr;
    }
    
    .performance-settings-footer {
        flex-direction: column;
    }
    
    .settings-btn {
        width: 100%;
    }
}

/* ===== パフォーマンス制御エフェクトクラス ===== */

/* パーティクルエフェクト制御 */
.particles-disabled .particle,
.particles-disabled .explosion-particle,
.particles-disabled .line-clear-particle,
.particles-disabled .combo-particle,
.particles-disabled .floating-blocks::before,
.particles-disabled .floating-blocks::after {
    display: none !important;
}

.particles-enabled .particle,
.particles-enabled .explosion-particle,
.particles-enabled .line-clear-particle,
.particles-enabled .combo-particle,
.particles-enabled .floating-blocks::before,
.particles-enabled .floating-blocks::after {
    display: block;
}

/* グローエフェクト制御 */
.glow-disabled *[style*="glow"],
.glow-disabled *[style*="drop-shadow"],
.glow-disabled .glow,
.glow-disabled .piece-glow,
.glow-disabled .special-glow {
    filter: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

.glow-disabled .game-board {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
}

/* 影エフェクト制御 */
.shadows-disabled * {
    box-shadow: none !important;
    text-shadow: none !important;
}

.shadows-disabled .game-board,
.shadows-disabled .next-piece-container,
.shadows-disabled .monster-container {
    box-shadow: none !important;
}

/* ライン消去エフェクト共通 */
.line-clear-lightweight {
    background-color: #ffffff;
    border: 1px solid rgba(255,255,255,0.6) !important;
}

.line-clear-enhanced {
    background-color: #ffff00 !important;
    border: 2px solid #ffffff !important;
    box-shadow: 0 0 8px #ffff00, inset 0 0 4px rgba(255,255,0,0.5) !important;
}

/* ライン消去エフェクト（軽量化版） */
@keyframes lightweightLineClear {
    0% {
        opacity: 0;
        transform: scale(1) rotate(0deg);
        background-color: #ffffff;
    }
    20% {
        opacity: 1;
        transform: scale(1.05) rotate(0deg);
        background-color: #ffffff;
    }
    100% {
        opacity: 0;
        transform: scale(0.9) rotate(45deg);
        background-color: #f8f8f8 !important;
    }
}

/* ライン消去エフェクト（高品質版） */
@keyframes enhancedLineClear {
    0% {
        opacity: 0;
        transform: scale(0.8) rotate(0deg);
        background-color: #ffff00 !important;
        box-shadow: 0 0 5px #ffff00 !important;
    }
    15% {
        opacity: 1;
        transform: scale(1.3) rotate(0deg);
        background-color: #ffff00 !important;
        box-shadow: 0 0 15px #ffff00, inset 0 0 8px rgba(255,255,0,0.8) !important;
    }
    50% {
        opacity: 0.9;
        transform: scale(1.1) rotate(180deg);
        background-color: #fff700 !important;
        box-shadow: 0 0 12px #fff700 !important;
    }
    80% {
        opacity: 0.6;
        transform: scale(0.9) rotate(270deg);
        background-color: #ffcc00 !important;
        box-shadow: 0 0 8px #ffcc00 !important;
    }
    100% {
        opacity: 0;
        transform: scale(0.5) rotate(360deg);
        background-color: transparent !important;
        box-shadow: 0 0 0px transparent !important;
    }
}

/* ブロックスタイル制御 */

/* フラットスタイル（最軽量） */
.blocks-flat .game-board canvas {
    filter: none !important;
}

.blocks-flat .piece {
    background: solid !important;
    border: 1px solid #333 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

/* シンプルスタイル（中品質） */
.blocks-simple .game-board canvas {
    filter: brightness(1.05) !important;
}

.blocks-simple .piece {
    border-radius: 2px !important;
    box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.3) !important;
}

/* 3Dスタイル（高品質） */
.blocks-3d .game-board canvas {
    filter: brightness(1.1) contrast(1.05) !important;
}

.blocks-3d .piece {
    border-radius: 3px !important;
    box-shadow: 
        inset 0 0 6px rgba(255, 255, 255, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.3) !important;
}

/* エフェクトレベル制御（全体的な制御） */

/* フルエフェクト */
.effects-full {
    /* 最高品質のエフェクト */
}

/* 軽減エフェクト */
.effects-reduced .complex-animation {
    animation-duration: var(--anim-medium);
}

.effects-reduced .particle {
    opacity: 0.7 !important;
}

/* 最小エフェクト */
.effects-minimal .animation,
.effects-minimal .complex-animation {
    animation: none;
    transition: none;
}

.effects-minimal .particle,
.effects-minimal .glow,
.effects-minimal *[style*="filter"] {
    display: none !important;
    filter: none !important;
}

/* パフォーマンス重視時のアニメーション調整 */
@media (prefers-reduced-motion: reduce) {
    .particle,
    .complex-animation {
        animation-duration: 0.01ms;
        animation-iteration-count: 1;
    }
}

/* 低スペックデバイス向けのスタイル調整 */
.low-performance *,
.low-performance *::before,
.low-performance *::after {
    animation-duration: var(--anim-normal);
    transition-duration: var(--trans-normal);
}

.low-performance .particle,
.low-performance .complex-effect {
    display: none !important;
}

/* ===== 描画品質制御 ===== */

/* 高品質描画 */
.quality-high {
    image-rendering: auto;
    text-rendering: optimizeQuality;
}

.quality-high canvas {
    image-rendering: auto;
}

.quality-high * {
    image-rendering: auto;
}

/* 中品質描画 */
.quality-medium {
    image-rendering: auto;
    text-rendering: auto;
}

.quality-medium canvas {
    image-rendering: auto;
}

/* 低品質描画（パフォーマンス重視） */
.quality-low {
    image-rendering: pixelated;
    text-rendering: optimizeSpeed;
}

.quality-low canvas {
    image-rendering: pixelated;
}

.quality-low * {
    image-rendering: pixelated;
    text-rendering: optimizeSpeed;
}

/* テキスト描画品質個別制御 */
.text-high {
    text-rendering: optimizeQuality;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.text-medium {
    text-rendering: auto;
    -webkit-font-smoothing: auto;
    -moz-osx-font-smoothing: auto;
}

.text-low {
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
}

/* Canvas固有の品質設定 */
.quality-low .game-board canvas,
.quality-low .next-piece-container canvas {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.quality-high .game-board canvas,
.quality-high .next-piece-container canvas {
    image-rendering: auto;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
}

/* パフォーマンス重視モード（全体的な軽量化） */
.performance-mode {
    will-change: auto;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.performance-mode * {
    will-change: auto;
    backface-visibility: hidden;
}

.performance-mode .animation,
.performance-mode .transition {
    animation-duration: var(--anim-fast);
    transition-duration: var(--trans-fast);
}


/* 詳細設定の無効化スタイル */
#performanceTab .custom-settings-section.disabled,
.game-settings-container .custom-settings-section.disabled {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
    position: relative;
}

#performanceTab .custom-settings-section.disabled .custom-setting select,
.game-settings-container .custom-settings-section.disabled .custom-setting select {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

#performanceTab .custom-settings-section.disabled .custom-setting label,
.game-settings-container .custom-settings-section.disabled .custom-setting label {
    color: #999;
}

#performanceTab .custom-settings-section.disabled::after,
.game-settings-container .custom-settings-section.disabled::after {
    content: "カスタムレベルを選択すると編集可能になります";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 10;
    white-space: nowrap;
    pointer-events: none;
}

.custom-settings-section {
    position: relative;
}

/* モバイル対応 */
@media (max-width: 600px) {
    .preview-demo {
        padding: 10px;
    }
    
    .preview-status {
        flex-direction: column;
        gap: 10px;
    }
    
    .status-item {
        flex-direction: row;
        justify-content: space-between;
    }
    
    #performanceTab .custom-settings-section.disabled::after,
    .game-settings-container .custom-settings-section.disabled::after {
        font-size: 11px;
        padding: 6px 12px;
    }
}

/* === monster-stats-display テキスト短縮システム === */

/* デスクトップ用：フルテキスト表示 */
@media (min-width: 769px) {
    .monster-stats-display .stat-label-full { display: inline; }
    .monster-stats-display .stat-label-short { display: none; }
}

/* スマートフォン・タブレット用：短縮テキスト表示 */
@media (max-width: 768px) {
    .monster-stats-display .stat-label-full { display: none; }
    .monster-stats-display .stat-label-short { display: inline; }
}

/* ===== クリスタル表示システム ===== */

/* 全画面共通のクリスタル表示（body右上固定） */
.crystal-display {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4a90e2, #7b68ee);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.crystal-display:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
}

.crystal-display .crystal-icon {
    font-size: 18px;
    text-shadow: 
        /* 白いアウトライン（8方向） */
        -1px -1px 0 white,
        1px -1px 0 white,
        -1px 1px 0 white,
        1px 1px 0 white,
        -1px 0 0 white,
        1px 0 0 white,
        0 -1px 0 white,
        0 1px 0 white,
        /* 白いブラー効果 */
        0 0 16px rgba(255, 255, 255, 1.0);
}

.crystal-display .crystal-count {
    font-size: 16px;
    font-weight: 700;
}

/* ===== モバイル環境での白い点滅問題の修正 ===== */
/* monster-visualとcombo-infoエリアの予期しない白い点滅を防ぐ */
@media (max-width: 768px), (orientation: portrait) {
    /* 背景を明示的に黒に設定して透明による点滅を防ぐ */
    .monster-visual {
        background: #000 !important;
        transition: none !important;
    }
    
    .monster-visual::after {
        background: rgba(0, 0, 0, 0.2) !important;
        transition: none !important;
        animation: none !important;
        -webkit-animation: none !important;
    }
    
    .monster-visual::before {
        transition: none !important;
    }
    
    .combo-info {
        background: rgba(0, 0, 0, 0.8) !important;
        transition: none !important;
        animation: none !important;
        -webkit-animation: none !important;
    }
    
    /* will-changeプロパティを無効化してGPUレイヤー作成を防ぐ */
    .game-container .monster-visual.damage-effect::after,
    .game-container .monster-visual.danger-slow::after,
    .game-container .monster-visual.danger-medium::after,
    .game-container .monster-visual.danger-fast::after {
        will-change: auto !important;
        animation: none !important;
        -webkit-animation: none !important;
    }
    
    /* comboGlowアニメーションも無効化 */
    .combo-info.combo-active {
        animation: none !important;
        -webkit-animation: none !important;
        border: 3px solid #ffd700 !important;
    }
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .crystal-display {
        top: 15px;
        right: 15px;
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .crystal-display .crystal-icon {
        font-size: 16px;
    }
    
    .crystal-display .crystal-count {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .crystal-display {
        top: 10px;
        right: 10px;
        padding: 4px 10px;
        font-size: 12px;
    }

    .crystal-display .crystal-icon {
        font-size: 14px;
    }

    .crystal-display .crystal-count {
        font-size: 12px;
    }
}

/* ===== iPhone SE等の小画面スマートフォン専用最適化 ===== */
/* 対象: iPhone SE (375x667), iPhone 8 (375x667) 等 */
@media (max-width: 375px) and (max-height: 667px) {
    /* ゲームコンテナの高さ最適化 */
    .game-container {
        overflow-y: auto; /* 必要に応じてスクロール可能に */
        -webkit-overflow-scrolling: touch; /* iOS用スムーススクロール */
    }

    /* モンスター画像をコンパクト化 */
    .game-container .monster-image {
        max-height: 100px !important;
        max-width: 100px !important;
    }

    /* モンスタータイトル行を縮小 */
    .game-container .monster-title-row {
        font-size: 0.75rem;
        padding: 2px 4px;
    }

    /* モンスターレベル・名前の縮小 */
    .game-container .monster-level {
        font-size: 0.7rem;
        padding: 1px 4px;
    }

    .game-container .monster-name {
        font-size: 0.75rem;
    }

    /* スコア表示をさらに圧縮 */
    .score-stats-grid {
        font-size: 0.65rem !important;
        padding: 2px !important;
        gap: 2px !important;
    }

    .score-stats-grid .stat-label {
        font-size: 0.6rem;
    }

    .score-stats-grid .stat-value {
        font-size: 0.7rem;
    }

    /* バトルログを縮小 */
    .game-container .battle-log {
        /* max-heightを削除 - グリッドレイアウトで自動調整 */
        min-height: 60px; /* 最小高さのみ指定 */
        font-size: 0.65rem;
        overflow-y: auto; /* スクロール可能に */
    }

    .game-container .battle-log-header {
        font-size: 0.7rem;
        padding: 2px;
    }

    .game-container .battle-log-content {
        padding: 2px;
    }

    /* プレイヤーステータス表示を縮小 */
    .game-container .player-stats {
        font-size: 0.65rem;
        gap: 2px;
    }

    /* コンボ情報を縮小 */
    .game-container .combo-info {
        font-size: 0.7rem;
        padding: 2px;
    }

    /* NEXTピース表示を縮小 */
    .game-container .next-piece {
        padding: 2px;
    }

    .game-container .next-header {
        font-size: 0.65rem;
        padding: 1px;
    }

    /* 攻撃警告を縮小 */
    .game-container .attack-warning {
        font-size: 0.7rem;
        padding: 2px;
    }

    /* HP表示を縮小 */
    .game-container .monster-hp-display,
    .game-container .player-hp {
        font-size: 0.7rem;
    }

    /* ゲームフレームのパディングを最小化 */
    .game-frame {
        padding: 2px !important;
    }
}

/* iPhone SE等で横向き表示の場合 */
@media (max-width: 667px) and (max-height: 375px) and (orientation: landscape) {
    /* 横向きではより積極的にスクロールを許可 */
    .game-container {
        height: auto !important;
        min-height: 100dvh;
        overflow-y: auto;
    }

    .game-frame {
        height: auto !important;
        min-height: 100dvh;
    }
}


