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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(to bottom, #87CEEB, #E0F6FF);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    /* ダブルタップによる拡大を防ぐ */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overflow-x: hidden;
}

.game-container {
    width: 100%;
    max-width: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.score-board {
    background: #4CAF50;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    gap: 15px;
}

.left-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bgm-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.score-display {
    display: flex;
    gap: 20px;
    align-items: center;
}

.bgm-button {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    /* タッチデバイス対応 */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.bgm-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.bgm-volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    /* タッチ操作の改善 */
    touch-action: pan-x;
    -webkit-tap-highlight-color: transparent;
}

/* スライダーのタッチ領域を拡大 */
@media (pointer: coarse) {
    .bgm-volume-slider {
        height: 20px;
        margin: 0 5px;
    }
}

.bgm-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bgm-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* モバイル用のthumbサイズ拡大 */
@media (pointer: coarse) {
    .bgm-volume-slider::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
    }
    
    .bgm-volume-slider::-moz-range-thumb {
        width: 20px;
        height: 20px;
    }
}

.bgm-volume-slider:hover::-webkit-slider-thumb {
    transform: scale(1.2);
}

.bgm-volume-slider:hover::-moz-range-thumb {
    transform: scale(1.2);
}

.bgm-button:active {
    transform: scale(0.95);
}

.bgm-button.muted {
    opacity: 0.5;
}

.ranking-button {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.ranking-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.ranking-button:active {
    transform: translateY(-50%) scale(0.95);
}

/* モバイルデバイス用の追加スタイル */
@media (hover: none) and (pointer: coarse) {
    .bgm-button, .ranking-button {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
    
    .bgm-button:hover, .ranking-button:hover {
        transform: translateY(-50%);
    }
}

.score-board > div {
    margin-left: 120px;
}


#game-canvas {
    display: block;
    width: 100%;
    background: #F0F8FF;
    cursor: crosshair;
    /* タッチ操作の最適化 */
    touch-action: manipulation;
}

.controls {
    background: #f5f5f5;
    padding: 20px;
    text-align: center;
}

.drop-button {
    background: #FF6B6B;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
    /* タッチ操作の最適化 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.drop-button:hover {
    background: #FF5252;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.drop-button:active {
    transform: translateY(0);
}

.drop-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.rotate-button {
    background: #9C27B0;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(156, 39, 176, 0.3);
    /* タッチ操作の最適化 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.rotate-button:hover {
    background: #7B1FA2;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(156, 39, 176, 0.4);
}

.rotate-button:active {
    transform: translateY(0);
}

.rotate-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    overflow-y: auto;
    margin: auto;
}

.modal-content h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 32px;
}

.modal-content p {
    font-size: 24px;
    color: #666;
    margin-bottom: 20px;
}

#screenshot-canvas {
    display: block;
    width: 100%;
    max-width: 400px;
    height: auto;
    margin: 0 auto 20px;
    border: 2px solid #ddd;
    border-radius: 10px;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.restart-button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.restart-button:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.download-button {
    background: #2196F3;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-button:hover {
    background: #1976D2;
    transform: translateY(-2px);
}

.tweet-button {
    background: #1DA1F2;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tweet-button:hover {
    background: #1A91DA;
    transform: translateY(-2px);
}

.share-button {
    background: #FF6B6B;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.share-button:hover {
    background: #FF5252;
    transform: translateY(-2px);
}

/* 共有オプションモーダル */
.share-options-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.share-options-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.share-options-content h3 {
    margin-bottom: 20px;
    color: #333;
    font-size: 24px;
}

.share-options-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.share-options-buttons button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.share-options-buttons button:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.close-share-modal {
    background: #666;
    color: white;
    border: none;
    padding: 10px 30px;
    font-size: 16px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-share-modal:hover {
    background: #555;
}

/* レスポンシブ対応 */
@media (max-width: 480px) {
    .score-board {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }
    
    .left-controls {
        width: 100%;
        justify-content: center;
    }
    
    .score-display {
        width: 100%;
        justify-content: center;
        flex-direction: column;
        gap: 5px;
    }
    
    .score, .high-score {
        font-size: 16px;
    }
    
    .bgm-volume-slider {
        width: 60px;
    }
    
    /* モーダル調整 */
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        padding: 20px;
        max-height: 85vh;
        width: 95%;
        max-width: 400px;
    }
    
    .modal-content h2 {
        font-size: 24px;
    }
    
    .modal-content p {
        font-size: 18px;
    }
    
    #screenshot-canvas {
        max-width: 100%;
        height: auto;
    }
    
    .modal-buttons {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .modal-buttons button {
        font-size: 14px;
        padding: 10px 20px;
    }
}

/* ランキング関連のスタイル */
.name-input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
}

.name-input:focus {
    outline: none;
    border-color: #4CAF50;
}

.submit-ranking-button {
    background: #FFD700;
    color: #333;
    border: none;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
}

.submit-ranking-button:hover {
    background: #FFC700;
    transform: translateY(-2px);
}

.submit-ranking-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.ranking-list {
    max-height: 400px;
    overflow-y: auto;
    margin: 20px 0;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin: 5px 0;
    background: #f5f5f5;
    border-radius: 8px;
    font-size: 18px;
}

.ranking-item.rank-1 {
    background: #FFD700;
    font-weight: bold;
}

.ranking-item.rank-2 {
    background: #C0C0C0;
}

.ranking-item.rank-3 {
    background: #CD7F32;
}

.ranking-rank {
    font-weight: bold;
    margin-right: 15px;
    min-width: 30px;
}

.ranking-name {
    flex: 1;
    text-align: left;
    margin-right: 15px;
}

.ranking-score {
    font-weight: bold;
    color: #333;
}

.close-ranking-button {
    background: #666;
    color: white;
    border: none;
    padding: 12px 40px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-ranking-button:hover {
    background: #555;
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .game-container {
        margin: 20px;
        max-width: 100%;
    }
    
    .drop-button {
        width: 100%;
        padding: 20px;
    }
}