body {
    margin: 0;
    /* overflow: hidden; */ /* スクロールバーを非表示 */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #222;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #eee;
    flex-direction: column; /* 画面が小さい場合は縦に並ぶように */
}

#game-container {
    display: flex;
    flex-direction: row;
    border: 2px solid #555;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
    align-items: center;
}

#gameCanvas {
    background-color: #333;
    display: block;
    flex-shrink: 0;
    flex-grow: 0;
}

#info-panel {
    width: 200px;
    background-color: #444;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-left: 2px solid #555;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
}

#time-display, #goal-display, #inventory-display {
    background-color: #555;
    padding: 6px;
    border-radius: 3px;
    font-size: 0.8em;
    flex-shrink: 0;
}

#log-display {
    background-color: #555;
    padding: 6px;
    border-radius: 3px;
    font-size: 0.8em;
    flex-grow: 1;
    overflow-y: auto;
}

#building-status-display {
    background-color: #555;
    padding: 6px;
    border-radius: 3px;
    font-size: 0.8em;
    margin-top: 8px;
}

/* ツールチップ */
.tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    pointer-events: none; /* ツールチップがマウスイベントをブロックしないようにする */
    z-index: 1000; /* 他の要素より手前に表示 */
    display: none; /* デフォルトは非表示 */
    white-space: pre-wrap; /* 改行を有効にする */
}

/* チートシート */
.cheat-sheet {
    background-color: #333;
    color: #eee;
    padding: 10px;
    margin-top: 20px;
    border: 2px solid #555;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    width: calc(100vw - 40px); /* 画面幅に合わせて調整 */
    max-width: 800px; /* 最大幅を設定 */
    font-size: 0.7em;
}

.cheat-sheet h2 {
    margin-top: 0;
    color: #00bcd4;
    font-size: 1.1em;
}

.cheat-sheet-category {
    margin-top: 10px;
    color: #aaffaa;
}

.cheat-sheet-recipe {
    margin-left: 15px;
    margin-bottom: 3px;
}

.item-color-icon {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1px solid #888;
    vertical-align: middle;
}

#control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
    padding: 10px;
    background-color: #333;
    border: 2px solid #555;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
    max-width: calc(100vw - 40px);
    justify-content: center;
}

.control-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    transition: background-color 0.2s;
}

.control-button:hover {
    background-color: #0056b3;
}

.control-button.active {
    background-color: #28a745;
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.7);
}

/* スマートフォン向けのメディアクエリ */
@media (max-width: 768px) {
    #game-container {
        flex-direction: column;
        border: none;
        box-shadow: none;
    }

    #info-panel {
        width: auto;
        border-left: none;
        border-top: 2px solid #555;
        max-height: 30vh;
    }

    #gameCanvas {
        max-width: 100vw;
        height: auto;
    }

    body {
        padding: 0;
    }
}

/* モーダル */
.modal {
    display: none; /* デフォルトは非表示 */
    position: fixed; /* 画面全体を覆う */
    z-index: 1; /* 他の要素より手前に表示 */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4); /* 半透明の背景 */
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 400px;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
    animation-name: animatetop;
    animation-duration: 0.4s;
    color: #333;
}

@keyframes animatetop {
    from {top: -300px; opacity: 0}
    to {top: 0; opacity: 1}
}

#recipe-list div {
    padding: 8px;
    margin-bottom: 5px;
    border: 1px solid #ccc;
    cursor: pointer;
    background-color: #eee;
}

#recipe-list div.selected {
    background-color: #aaddff;
    border-color: #007bff;
}

#set-recipe-button, #close-modal-button {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    cursor: pointer;
    margin-top: 15px;
    margin-right: 10px;
}

#close-modal-button {
    background-color: #6c757d;
}