@import url('https://fonts.googleapis.com/css?family=Noto+Sans+JP');


html, body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: auto;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    font-family:  'Noto Sans JP', sans-serif;
}

#bg-video {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -1;
    object-fit: cover;
}

.container {
    text-align: center;
    background: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 10px;
    max-height: 95vh;
    width: 95%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

h1, h2 {
    color: #333;
    margin-top: 0;
}

#mediaContainer {
    margin-top: 10px;
    width: 100%;
    max-width: 640px; /* オリジナルのビデオ幅に制限 */
    margin-left: auto;
    margin-right: auto;
    height: 30vh; /* 高さを指定 */
    position: relative;
}

#video, #canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    position: absolute;
    top: 0;
    left: 0;
}

#video {
    transform: scaleX(-1);
}

#canvas {
    background: transparent;
}

.message {
    font-size: 24px;
    margin: 20px 0 10px;
    min-height: 36px;
}

.countdown {
    font-size: 72px;
    font-weight: bold;
    color: #ff6b6b;
    margin: 0;
    text-align: center;
}

.button-container {
    margin: 20px 0 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50px;
    flex-wrap: wrap;
    gap: 10px;
}

button {
    font-size: 18px;
    font-family: 'Noto Sans JP', sans-serif;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    background-color: royalblue;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover:not(:disabled) {
    background-color: darkblue;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.result {
    margin-top: 20px;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.result h2 {
    color: royalblue;
    font-size: 36px;
    margin: 0;
}

.result p {
    font-size: 24px;
    color: #666;
    margin: 10px 0;
}

.character-container, .world-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 10px 0;
    min-height: 160px;
}

#salaryman, .boss-image {
    width: 160px;
    height: auto;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 80px;
}

.speech-bubble {
    position: relative;
    background: #ffffff;
    /* border: 4px solid royalblue; */
    border-radius: 15px;
    padding: 20px;
    flex-grow: 1;
    min-width: 250px;
}

.speech-bubble:before, .speech-bubble:after {
    content: "";
    position: absolute;
    top: 30px;
    border-style: solid;
}

.speech-bubble:before {
    left: -20px;
    border-width: 10px 20px 10px 0;
    border-color: transparent #ffffff transparent transparent;
}

.speech-bubble:after {
    left: -14px;
    border-width: 10px 20px 10px 0;
    border-color: transparent #ffffff transparent transparent;
}

.view { display: none; }

.menu-buttons { 
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.game-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    width: 300px;
    text-align: left;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 15px;
}

.game-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(90, 124, 227, 0.625);
    flex-shrink: 0;
}

.game-card-content {
    flex-grow: 1;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-color: royalblue;
}

.game-card h3 {
    margin: 0 0 10px;
    color: #333;
    font-size: 1.2em;
}

.game-card p {
    margin: 0;
    color: #666;
    font-size: 0.9em;
    line-height: 1.5;
}

/* チュートリアルオーバーレイ */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.tutorial-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tutorial-content h3 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.tutorial-step {
    margin: 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 80px;
}

.tutorial-step img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 10px;
    background: white;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tutorial-step p {
    font-size: 16px;
    line-height: 1.6;
}

#closeTutorial {
    margin-top: 10px;
    width: 100%;
    padding: 15px;
    font-size: 18px;
}

.tutorial-step p {
    margin: 0;
    flex: 1;
}

/* 口の開き具合インジケーター */
.mouth-indicator {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    background: rgba(0,0,0,0.7);
    color: white;
    border-radius: 20px;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s;
}

.mouth-indicator.visible {
    opacity: 1;
}

/* 進行状況リング */
.progress-ring {
    transition: stroke-dashoffset 0.3s;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

/* --- Battle View Styles --- */
.battle-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    margin: 10px 0;
}

.hp-label {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}

.hp-bars {
    display: flex;
    justify-content: space-around;
    width: 100%;
}

.enemy-hp, .player-hp {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 0 10px;
}

.battle-field {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 20px;
    width: 100%;
}

.battle-field .boss-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f9f9f9;
    border-radius: 8px;
    padding: 10px;
}

.battle-area .media-placeholder {
    flex: 1;
    min-height: 240px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f9f9f9;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.battle-area .media-placeholder #mediaContainer {
    height: 100%;
    width: 100%;
    margin-top: 0;
    position: absolute;
    top: 0;
    left: 0;
}

.hp-bar {
    width: 100%;
    max-width: 300px;
    height: 24px;
    background: #ddd;
    border-radius: 12px;
    overflow: hidden;
    margin: 4px 0 8px;
}

.hp-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ff3b3b);
    transition: width 600ms ease-in-out;
}

.boss-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

@media (max-width: 768px) {
    .character-container, .world-top, .battle-area {
        flex-direction: column;
        min-height: auto;
    }
    .speech-bubble:before, .speech-bubble:after { display: none; }
    #mediaContainer { max-height: 25vh; }
}

@media (max-width: 768px) {
    .tutorial-step {
        flex-direction: column;
        text-align: center;
        padding: 15px;
    }

    .tutorial-step img {
        width: 160px;
        height: 160px;
    }

    .tutorial-content {
        padding: 20px;
        max-height: 85vh;
    }
}

@media (max-width: 480px) {
    .container { padding: 15px; }
    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    .message { font-size: 18px; }
    .countdown { font-size: 48px; }
    button { font-size: 16px; padding: 8px 15px; }
    .hp-bar { width: 220px; }
    #mediaContainer { max-height: 22vh; }
}

/* 縦画面のスマートフォン */
@media (orientation: portrait) and (max-width: 768px) {
    /* 必要であれば縦画面特有のスタイルを追加 */
}

/* 横画面のスマートフォン */
@media (orientation: landscape) and (max-height: 500px) {
    html, body {
        height: 100vh;
        overflow: hidden; /* スクロールを禁止 */
    }
    .container {
        flex-direction: row;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        padding: 5px;
        gap: 10px;
        border-radius: 0;
    }

    .view {
        display: flex !important; /* display: block !important; を上書き */
        flex-direction: row;
        width: 100%;
        height: 100%;
        gap: 10px;
        align-items: center;
    }

    #menuView {
        flex-direction: column;
        justify-content: center;
    }

    .menu-buttons {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto; /* 横スクロール可能に */
        padding-bottom: 10px;
    }

    .game-card {
        flex: 0 0 200px; /* カードの幅を固定 */
    }

    /* ゲーム画面のレイアウト調整 */
    .character-container, .world-top, .battle-area {
        flex: 3; /* ゲーム表示エリアの比率 */
        height: 100%;
        margin: 0;
        padding: 5px;
        box-sizing: border-box;
    }
    
    .battle-area {
        justify-content: space-between;
    }

    .media-placeholder {
        flex-grow: 1;
        width: 100%;
        height: auto;
        min-height: 150px; /* 最小高さを確保 */
    }

    #mediaContainer {
        height: 100%;
        width: 100%;
        max-height: none;
    }

    .button-container {
        flex: 1; /* 操作エリアの比率 */
        flex-direction: column;
        justify-content: center;
        height: 100%;
        margin: 0;
        gap: 15px;
    }
    
    button {
        width: 90%;
    }

    .speech-bubble {
        font-size: 0.8em;
        padding: 10px;
    }

    h1, h2 {
        font-size: 1.2em;
        margin-bottom: 10px;
    }
    
    .tutorial-content {
        flex-direction: row;
        align-items: flex-start;
        gap: 15px;
        max-height: 95vh;
        max-width: 95vw;
    }

    .tutorial-step {
        flex: 1;
        padding: 10px;
    }
    
    .tutorial-step img {
        width: 100px;
        height: 100px;
    }
}

/* --- スマートフォン向けレスポンシブ対応 --- */

@media (max-width: 768px) {
    .container {
        width: 100%;
        height: 100%;
        border-radius: 0;
        padding: 10px;
        box-sizing: border-box; /* paddingを含めて幅・高さを計算 */
    }

    .menu-buttons {
        flex-direction: column; /* ボタンを縦積みに */
        gap: 15px;
    }

    .game-card {
        width: 100%; /* カード幅を画面いっぱいに */
        box-sizing: border-box;
    }

    .character-container, .world-top {
        padding: 10px;
    }

    #salaryman, .boss-image {
        width: 120px; /* 画像を少し小さく */
    }

    .speech-bubble {
        padding: 15px;
    }

    .battle-field {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    h1 { font-size: 22px; }
    h2 { font-size: 18px; }

    .tutorial-step img {
        width: 100px;
        height: 100px;
    }

    #mediaContainer {
        height: 25vh; /* 高さを調整 */
    }

    .button-container {
        flex-direction: column; /* ボタンを縦積みに */
    }

    button {
        width: 80%; /* ボタン幅を統一 */
    }
}
