body {
    margin: 0;
    padding: 0;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    background: #1a202c;
    overflow: hidden;
}

#game-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    position: relative;
}

/* 共通画面スタイル */
#start-screen,
#result-screen {
    text-align: center;
    width: 100%;
    max-width: 600px;
    padding: 20px;
    z-index: 10;
    display: none; /* デフォルトは非表示 */
}


/* GameBaseの画面管理システムに対応 */
#start-screen.active, #result-screen.active, #game-screen.active {
    display: block;
}

.hidden {
    display: none !important;
}

/* スタート画面 */
#start-screen h1 {
    font-size: 48px;
    margin: 0 0 20px 0;
}

#start-screen p {
    font-size: 20px;
    margin-bottom: 20px;
}

.instructions {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 30px;
    text-align: left;
}

.instructions p {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 10px;
}

.instructions ul {
    list-style: none;
    padding: 0;
}

.instructions li {
    padding: 5px 0;
    font-size: 16px;
}

/* ボタン */
.primary-btn {
    padding: 15px 40px;
    font-size: 20px;
    font-weight: bold;
    background: #4299e1;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.primary-btn:hover {
    background: #3182ce;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

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

/* ゲーム画面 */
#game-screen {
    width: 100%;
    height: 100%;
    position: relative;
}

#gameCanvas {
    display: block;
    margin: 0 auto;
    background: #1a202c;
}

/* UI統計 */
#ui {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
}

.stats {
    display: flex;
    gap: 40px;
    font-size: 20px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 30px;
    border-radius: 10px;
}

.highlight {
    color: #ffd700;
    font-size: 28px;
}

/* タップボタン */
#tap-buttons {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 5;
}

.tap-btn {
    width: 100px;
    height: 80px;
    font-size: 32px;
    font-weight: bold;
    background: rgba(66, 153, 225, 0.6);
    color: white;
    border: 3px solid #4299e1;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.1s;
    /* タッチ操作の最適化 */
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.tap-btn:hover {
    background: rgba(66, 153, 225, 0.8);
}

.tap-btn:active,
.tap-btn.active {
    background: #4299e1;
    transform: scale(0.95);
}

/* 判定表示 */
#judgment {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: bold;
    padding: 20px 40px;
    border-radius: 15px;
    z-index: 10;
    animation: judgmentFade 0.5s ease-out;
}

#judgment.perfect {
    color: #ffd700;
    text-shadow: 0 0 20px #ffd700;
}

#judgment.good {
    color: #48bb78;
    text-shadow: 0 0 20px #48bb78;
}

#judgment.miss {
    color: #e53e3e;
    text-shadow: 0 0 20px #e53e3e;
}

@keyframes judgmentFade {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 結果画面 */
#result-screen h2 {
    font-size: 36px;
    margin-bottom: 30px;
}

.result-stats {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 30px;
}

.result-stats p {
    font-size: 24px;
    margin: 15px 0;
}

.judgment-counts {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
}

.judgment-counts p {
    font-size: 18px;
}

/* レスポンシブ対応 */

/* タブレット横向き */
@media (max-width: 1024px) {
    #start-screen h1 {
        font-size: 42px;
    }

    #start-screen p {
        font-size: 18px;
    }

    .instructions p {
        font-size: 16px;
    }

    .instructions li {
        font-size: 15px;
    }
}

/* タブレット縦向き */
@media (max-width: 768px) {
    #start-screen h1 {
        font-size: 36px;
    }

    #start-screen p {
        font-size: 16px;
    }

    .instructions {
        padding: 15px;
    }

    .instructions p {
        font-size: 15px;
    }

    .instructions li {
        font-size: 14px;
    }

    .primary-btn {
        padding: 12px 35px;
        font-size: 18px;
    }

    .stats {
        font-size: 18px;
        gap: 30px;
        padding: 8px 25px;
    }

    .highlight {
        font-size: 24px;
    }

    .tap-btn {
        width: 80px;
        height: 70px;
        font-size: 28px;
    }

    #tap-buttons {
        gap: 15px;
        bottom: 20px;
    }

    #judgment {
        font-size: 42px;
        padding: 18px 35px;
    }

    #result-screen h2 {
        font-size: 32px;
    }

    .result-stats p {
        font-size: 22px;
    }

    .judgment-counts p {
        font-size: 16px;
    }
}

/* スマートフォン */
@media (max-width: 600px) {
    #start-screen h1 {
        font-size: 32px;
        margin: 0 0 15px 0;
    }

    #start-screen p {
        font-size: 15px;
        margin-bottom: 15px;
    }

    .instructions {
        padding: 15px;
        margin-bottom: 20px;
    }

    .instructions p {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .instructions li {
        font-size: 13px;
        padding: 3px 0;
    }

    .primary-btn {
        padding: 12px 30px;
        font-size: 16px;
    }

    #gameCanvas {
        width: 100%;
        height: auto;
    }

    .stats {
        font-size: 16px;
        gap: 20px;
        padding: 8px 20px;
    }

    .highlight {
        font-size: 22px;
    }

    /* タップボタンをより大きく、押しやすく */
    .tap-btn {
        width: 80px;
        height: 70px;
        font-size: 26px;
        border-width: 3px;
        /* タッチのフィードバックを改善 */
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(66, 153, 225, 0.5);
    }

    #tap-buttons {
        gap: 12px;
        bottom: 20px;
    }

    #judgment {
        font-size: 36px;
        padding: 15px 30px;
    }

    #result-screen h2 {
        font-size: 28px;
        margin-bottom: 25px;
    }

    .result-stats {
        padding: 25px;
    }

    .result-stats p {
        font-size: 20px;
        margin: 12px 0;
    }

    .judgment-counts {
        margin-top: 15px;
        padding-top: 15px;
    }

    .judgment-counts p {
        font-size: 15px;
    }
}

/* 小さいスマートフォン */
@media (max-width: 480px) {
    #start-screen h1 {
        font-size: 28px;
    }

    #start-screen p {
        font-size: 14px;
    }

    .instructions {
        padding: 12px;
    }

    .instructions p {
        font-size: 13px;
    }

    .instructions li {
        font-size: 12px;
    }

    .primary-btn {
        padding: 10px 25px;
        font-size: 15px;
    }

    .stats {
        font-size: 14px;
        gap: 15px;
        padding: 6px 15px;
        flex-direction: column;
    }

    .highlight {
        font-size: 20px;
    }

    /* 小さい画面でも押しやすいサイズを確保 */
    .tap-btn {
        width: 65px;
        height: 60px;
        font-size: 22px;
    }

    #tap-buttons {
        gap: 10px;
        bottom: 15px;
    }

    #judgment {
        font-size: 32px;
        padding: 12px 25px;
    }

    #result-screen h2 {
        font-size: 24px;
    }

    .result-stats {
        padding: 20px;
    }

    .result-stats p {
        font-size: 18px;
        margin: 10px 0;
    }

    .judgment-counts p {
        font-size: 14px;
    }
}

/* 極小スマートフォン */
@media (max-width: 380px) {
    #start-screen h1 {
        font-size: 24px;
    }

    .tap-btn {
        width: 55px;
        height: 50px;
        font-size: 18px;
    }

    #tap-buttons {
        gap: 6px;
    }

    .stats {
        font-size: 13px;
    }

    .highlight {
        font-size: 18px;
    }
}

/* 横向き対応（高さが制限される場合） */
@media (max-height: 600px) and (orientation: landscape) {
    #start-screen h1 {
        font-size: 28px;
        margin: 0 0 10px 0;
    }

    #start-screen p {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .instructions {
        padding: 10px;
        margin-bottom: 15px;
    }

    .instructions p {
        font-size: 13px;
        margin-bottom: 5px;
    }

    .instructions li {
        font-size: 12px;
        padding: 2px 0;
    }

    .primary-btn {
        padding: 8px 25px;
        font-size: 14px;
    }

    #ui {
        top: 10px;
    }

    .stats {
        font-size: 14px;
        gap: 20px;
        padding: 6px 20px;
    }

    .tap-btn {
        width: 60px;
        height: 50px;
        font-size: 20px;
    }

    #tap-buttons {
        bottom: 10px;
        gap: 10px;
    }

    #judgment {
        font-size: 32px;
        padding: 12px 25px;
    }

    .result-stats {
        padding: 15px;
        margin-bottom: 15px;
    }

    .result-stats p {
        font-size: 16px;
        margin: 8px 0;
    }

    #result-screen h2 {
        font-size: 24px;
        margin-bottom: 15px;
    }

    .judgment-counts {
        margin-top: 10px;
        padding-top: 10px;
    }

    .judgment-counts p {
        font-size: 13px;
    }
}
