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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
}

#gameContainer {
    position: relative;
    width: 100%;
    max-width: 1200px;
    aspect-ratio: 16 / 9;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: auto;
}

/* タイトル画面 */
#titleScreen {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
}

#titleImage {
    max-width: 80%;
    max-height: 60%;
    margin-bottom: 30px;
    object-fit: contain;
}

#startButton {
    background-color: #d32f2f;
    color: white;
    font-size: 24px;
    font-weight: bold;
    padding: 15px 50px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#startButton:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

#startButton:active {
    transform: scale(0.95);
}

/* ゲーム画面 */
#gameScreen {
    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #87CEEB;
}

/* ゲームキャラクター（GIF用） */
#gameCharacters {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.character {
    position: absolute;
    pointer-events: none;
    image-rendering: auto;
    image-rendering: -webkit-optimize-contrast;
}

.character img {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* UIボタン */
#uiButtons {
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

#lifeDisplay {
    display: flex;
    gap: 5px;
    font-size: 30px;
    pointer-events: auto;
}

.heart {
    color: #ff0000;
    text-shadow: 0 0 5px rgba(255, 0, 0, 0.5);
}

.heart.lost {
    color: #666;
    text-shadow: none;
}

#controlButtons {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.ui-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #333;
    border-radius: 8px;
    font-size: 24px;
    width: 50px;
    height: 50px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ui-btn:hover {
    background: rgba(255, 255, 255, 1);
}

.ui-btn:active {
    transform: scale(0.95);
}

/* タッチコントロール（スマホ用） */
#touchControls {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    pointer-events: none;
}

.left-controls, .right-controls {
    position: absolute;
    bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: flex-end;
    pointer-events: auto;
}

.left-controls {
    left: 20px;
    flex-direction: row;
}

.right-controls {
    right: 20px;
    flex-direction: row;
}

/* PC用操作説明 */
#controlsInfo {
    position: absolute;
    bottom: -50px;
    left: 0;
    right: 0;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.7);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    pointer-events: none;
}

.controls-content {
    display: flex;
    justify-content: center;
    gap: 25px;
    font-size: 13px;
    color: #fff;
    flex-wrap: wrap;
}

.controls-content p {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

kbd {
    display: inline-block;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #999;
    border-radius: 3px;
    padding: 3px 6px;
    font-family: monospace;
    font-weight: bold;
    font-size: 11px;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 方向ボタン（左右移動） */
.direction-btn {
    background: rgba(100, 100, 100, 0.8);
    color: white;
    font-size: 32px;
    font-weight: bold;
    width: 70px;
    height: 70px;
    border: 3px solid #fff;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.direction-btn:active {
    transform: scale(0.9);
    background: rgba(80, 80, 80, 0.9);
}

/* アクションボタン（ジャンプ・配達） */
.action-btn {
    font-size: 18px;
    font-weight: bold;
    min-width: 80px;
    height: 70px;
    border: 3px solid #fff;
    border-radius: 15px;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
}

#jumpButton {
    background: rgba(255, 200, 0, 0.9);
    color: #333;
}

#jumpButton:active {
    transform: scale(0.9);
    background: rgba(255, 180, 0, 1);
}

#deliverButton {
    background: rgba(76, 175, 80, 0.9);
    color: white;
}

#deliverButton:active {
    transform: scale(0.9);
    background: rgba(56, 155, 60, 1);
}

/* ゲームオーバー画面 */
#gameOverScreen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.8);
    color: white;
}

#gameOverScreen h1 {
    font-size: 48px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

#retryButton {
    background-color: #d32f2f;
    color: white;
    font-size: 24px;
    font-weight: bold;
    padding: 15px 50px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

#retryButton:hover {
    transform: scale(1.05);
}

/* ゲームクリア画面 */
#clearScreen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    color: white;
}

#clearImage {
    max-width: 80%;
    max-height: 50%;
    margin-bottom: 20px;
    object-fit: contain;
}

#clearScreen h1 {
    font-size: 36px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    text-align: center;
}

#deliveryCountDisplay {
    font-size: 28px;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    color: #FFD700;
}

#deliveryCount {
    font-weight: bold;
    font-size: 32px;
    color: #FFA500;
}

#restartButton {
    background-color: #4CAF50;
    color: white;
    font-size: 24px;
    font-weight: bold;
    padding: 15px 50px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

#restartButton:hover {
    transform: scale(1.05);
}

/* レスポンシブ対応 */
/* PC版（769px以上）*/
@media (min-width: 769px) {
    #controlsInfo {
        display: block;
    }

    #touchControls {
        display: none !important;
    }
}

/* モバイル版（768px以下） */
@media (max-width: 768px) {
    #controlsInfo {
        display: none !important;
    }

    #touchControls {
        display: flex;
        position: relative;
        width: 100vw;
        padding: 20px;
        background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
        justify-content: space-between;
        align-items: center;
        min-height: 120px;
        pointer-events: auto;
    }

    .left-controls, .right-controls {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
    }

    #titleImage {
        max-width: 90%;
    }

    #startButton, #retryButton, #restartButton {
        font-size: 20px;
        padding: 12px 40px;
    }

    #clearScreen h1, #gameOverScreen h1 {
        font-size: 28px;
        padding: 0 20px;
    }

    #deliveryCountDisplay {
        font-size: 22px;
        padding: 0 20px;
    }

    #deliveryCount {
        font-size: 26px;
    }

    .ui-btn {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }

    #lifeDisplay {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    #touchControls {
        padding: 15px;
        min-height: 100px;
    }

    .left-controls, .right-controls {
        gap: 10px;
    }

    .direction-btn {
        width: 60px;
        height: 60px;
        font-size: 28px;
    }

    .action-btn {
        min-width: 70px;
        height: 60px;
        font-size: 16px;
        padding: 0 15px;
    }

    .ui-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    #lifeDisplay {
        font-size: 20px;
    }
}
