* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100%;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.main-wrapper {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    align-items: flex-start;
    justify-content: center;
    padding-top: 20px;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.game-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    color: white;
    font-size: 18px;
    font-weight: bold;
}

.score-container, .moves-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

#score, #moves {
    font-size: 24px;
    min-width: 50px;
    text-align: right;
}

#gameCanvas {
    display: block;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    max-width: 100%;
    height: auto;
    touch-action: none; /* タッチスクロールを無効化 */
}

.game-controls {
    margin-top: 20px;
    text-align: center;
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* 難易度選択 */
.difficulty-controls {
    margin-top: 15px;
    text-align: center;
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.difficulty-label {
    font-weight: bold;
    color: #667eea;
    font-size: 16px;
}

.difficulty-btn {
    background: linear-gradient(135deg, #868e96 0%, #495057 100%);
    color: white;
    border: none;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
}

.difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(134, 142, 150, 0.4);
}

.difficulty-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transform: scale(1.05);
}

.difficulty-btn:active {
    transform: translateY(0);
}

#newGameBtn, #helpBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    -webkit-tap-highlight-color: transparent; /* タップハイライトを無効化 */
    user-select: none; /* テキスト選択を無効化 */
}

#helpBtn {
    background: linear-gradient(135deg, #f39c12 0%, #e74c3c 100%);
}

#newGameBtn:hover, #helpBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

#helpBtn:hover {
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.4);
}

#newGameBtn:active, #helpBtn:active {
    transform: translateY(0);
}

/* ビーストモード表示 */
.beast-mode-display {
    background: linear-gradient(135deg, #ff6b6b, #ff9500);
    color: white;
    padding: 15px 30px;
    margin: 15px 0;
    border-radius: 15px;
    text-align: center;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.5);
    animation: pulse 0.5s ease-in-out infinite;
}

.beast-mode-title {
    font-size: 24px;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.beast-mode-timer {
    font-size: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* ヘルプパネル */
.help-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 85vh;
    overflow-y: auto;
}

/* ハイスコアパネル */
.highscore-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 25px;
    width: 300px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 85vh;
    overflow-y: auto;
}

.highscore-panel h2 {
    color: #764ba2;
    text-align: center;
    font-size: 24px;
    margin: 0 0 20px 0;
    padding: 10px;
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    border-radius: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.highscore-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.highscore-item {
    padding: 15px 15px 15px 45px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border-left: 4px solid #667eea;
    position: relative;
}

.highscore-item.rank-1 {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe08a 100%);
    border-left-color: #ffd700;
}

.highscore-item.rank-2 {
    background: linear-gradient(135deg, #e7eaf6 0%, #d6dbe5 100%);
    border-left-color: #c0c0c0;
}

.highscore-item.rank-3 {
    background: linear-gradient(135deg, #ffebd1 0%, #ffd4a3 100%);
    border-left-color: #cd7f32;
}

.highscore-rank {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 24px;
    font-weight: bold;
}

.highscore-name {
    font-weight: bold;
    color: #495057;
    font-size: 16px;
    margin-bottom: 5px;
}

.highscore-score {
    color: #667eea;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 5px;
}

.highscore-date {
    color: #868e96;
    font-size: 12px;
}

.no-scores {
    text-align: center;
    padding: 30px;
    color: #868e96;
    font-size: 14px;
}

.help-panel h2 {
    color: #764ba2;
    text-align: center;
    font-size: 24px;
    margin: 0 0 20px 0;
    padding: 10px;
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    border-radius: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.help-section {
    margin-bottom: 20px;
    padding: 15px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.help-section h3 {
    color: #495057;
    font-size: 18px;
    margin: 0 0 10px 0;
    font-weight: bold;
}

.help-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.help-section li {
    padding: 8px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.help-section strong {
    color: #667eea;
    font-size: 15px;
}

.icon-bomb {
    font-size: 20px;
    display: inline-block;
    animation: twinkle 1s ease-in-out infinite;
}

.icon-super {
    font-size: 24px;
    display: inline-block;
    animation: rainbow-spin 2s linear infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes rainbow-spin {
    0% {
        transform: rotate(0deg);
        filter: hue-rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
        filter: hue-rotate(360deg);
    }
}

/* スクロールバーのスタイル */
.help-panel::-webkit-scrollbar {
    width: 8px;
}

.help-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.help-panel::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.help-panel::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* レスポンシブ対応 */
@media (max-width: 1200px) {
    .main-wrapper {
        flex-direction: column;
        align-items: center;
    }

    .help-panel {
        width: 100%;
        max-width: 500px;
        order: 2;
    }

    .game-container {
        order: 1;
    }

    .highscore-panel {
        width: 100%;
        max-width: 500px;
        order: 3;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .main-wrapper {
        padding-top: 10px;
    }

    .game-container {
        padding: 15px;
        width: 100%;
        max-width: 100%;
    }

    .help-panel {
        width: 100%;
        max-width: none;
        padding: 15px;
        margin-top: 20px;
    }

    .highscore-panel {
        width: 100%;
        max-width: none;
        padding: 15px;
        margin-top: 20px;
    }

    #gameCanvas {
        width: 100% !important;
        height: auto !important;
        max-width: 496px; /* 8 * (60 + 4) = 512px */
        margin: 0 auto;
    }

    .game-controls {
        display: flex;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    #newGameBtn, #helpBtn {
        width: 100%;
        padding: 15px 20px;
    }

    .difficulty-controls {
        flex-wrap: wrap;
        margin-top: 10px;
    }

    .difficulty-label {
        width: 100%;
        margin-bottom: 10px;
    }

    .difficulty-btn {
        flex: 1;
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 10px;
    }

    .help-panel h2 {
        font-size: 18px;
    }

    .help-section h3 {
        font-size: 15px;
    }

    .help-section li {
        font-size: 12px;
    }

    .game-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        font-size: 16px;
    }

    #score, #moves {
        font-size: 20px;
    }

    .beast-mode-title {
        font-size: 20px;
    }

    .beast-mode-timer {
        font-size: 18px;
    }
}