/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&display=swap');

/* Basic Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden; /* Prevent body scroll */
    font-family: 'MedievalSharp', cursive;
    color: #2b231d; /* Dark brown for text */
    background-image: url('../img/background-map.png'); /* 背景画像 */
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.page-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background-color: rgba(210, 180, 140, 0.7); /* Tan with transparency */
    padding: 10px;
    position: relative;
    overflow-y: auto; /* Allow scrolling for the entire page container */
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: rgba(43, 35, 29, 0.9); /* Darker brown header */
    border: 2px solid #d2b48c;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    color: #f5deb3;
    text-shadow: 1px 1px 2px #000;
}

.back-button {
    display: flex;
    align-items: center;
    font-size: 1.1em;
    color: #d2b48c; /* 枠等の色と合わせる */
    text-decoration: none;
    font-weight: bold;
}

.back-button:hover {
    color: #f0e68c;
}

.back-button img {
    width: 30px;
    height: 30px;
    filter: brightness(1.2); /* 明るめに調整 */
}

.header-status {
    font-size: 1.2em;
    font-weight: bold;
}

.quill-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.quill-button img {
    width: 50px;
    height: 50px;
    filter: brightness(1.2); /* 明るめに調整 */
}

/* Map Area */
.map-area {
    flex-grow: 1; /* Take up available space */
    position: relative;
    border: 3px solid #2b231d;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
    box-shadow: 0 0 10px rgba(0,0,0,0.6);
    min-height: 40vh; /* Minimum height for map on smaller screens */
    background-color: #a2d4ad; /* Light green map background */
}

#map {
    width: 100%;
    height: 100%;
}

.compass-overlay {
    position: absolute;
    bottom: 15px;
    right: 15px;
    z-index: 500;
}

.compass-overlay img {
    width: 50px;
    height: 50px;
    opacity: 0.8;
}

/* Action Log Area */
.log-area {
    background-color: rgba(43, 35, 29, 0.9);
    border: 2px solid #d2b48c;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    margin-bottom: 10px;
}

.log-title {
    font-size: 1.8em;
    color: #f5deb3;
    text-shadow: 1px 1px 2px #000;
    text-align: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #7a6a5d;
    padding-bottom: 10px;
}

.log-list {
    max-height: 30vh; /* Max height for scrollable log */
    overflow-y: auto;
    padding-right: 5px; /* For scrollbar */
}

.empty-log-message {
    text-align: center;
    color: #d2b48c;
    font-size: 1.1em;
    padding: 20px 0;
}

/* Log Item (details/summary) */
.log-item details {
    border-bottom: 1px solid rgba(122, 106, 93, 0.5);
    margin-bottom: 8px;
    padding-bottom: 8px;
}

.log-item details:last-child {
    border-bottom: none;
}

.log-item summary {
    font-size: 1.2em;
    color: #f0e68c; /* Lighter yellow for summary */
    cursor: pointer;
    padding: 5px 0;
    list-style: none;
    position: relative;
    padding-left: 20px;
}

.log-item summary::before {
    content: '▶';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7em;
    color: #d2b48c;
    transition: transform 0.2s ease-in-out;
}

.log-item details[open] > summary::before {
    transform: translateY(-50%) rotate(90deg);
}

.log-item summary:hover {
    color: #fff;
}

.log-item-content {
    background-color: rgba(60, 50, 40, 0.5);
    padding: 10px;
    border-radius: 5px;
    margin-top: 5px;
    color: #f5deb3;
    max-width: 100%; /*画面の端で折り返す*/
    box-shadow: inset 0 0 5px rgba(0,0,0,0.7);
}

.log-item-content p {
    margin: 5px 0;
    line-height: 1.5;
}

/* ===== モーダル共通スタイル ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none; justify-content: center; align-items: center;
    z-index: 1000; backdrop-filter: blur(5px);
}
.modal-content {
    background-color: #2b231d; color: #f5deb3; padding: 25px;
    border: 3px solid #d2b48c; border-radius: 10px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.9);
    text-align: center; width: 90%; max-width: 450px;
    position: relative; animation: fadeInModal 0.5s ease-out forwards;
}
@keyframes fadeInModal {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.modal-close {
    position: absolute; top: 10px; right: 15px;
    font-size: 2em; color: #d2b48c; cursor: pointer;
    transition: color 0.2s ease;
}
.modal-close:hover { color: #fff; }
.modal-icon { width: 60px; height: 60px; margin-bottom: 15px; }
.modal-content h2 { font-size: 2em; margin: 0 0 15px 0; color: #fff; }

.input-group {
    margin-bottom: 20px;
    text-align: left;
}
.input-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 1.1em;
    color: #d2b48c;
}

/* =================================================== */
/* 吹き出し（ツールチップ）のスタイル (data-prompt-text) */
/* =================================================== */

[data-prompt-text] {
    position: relative;
    cursor: help;
}

[data-prompt-text]::after {
    content: attr(data-prompt-text);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #2b231d;
    color: #f5deb3;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.9em;
    white-space: normal;
    width: 250px;
    word-break: break-all;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1010;
}

[data-prompt-text]::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent #2b231d transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1010;
}

[data-prompt-text]:hover::after,
[data-prompt-text]:hover::before {
    opacity: 1;
    visibility: visible;
}

/* =================================================== */
/* 吹き出し（ツールチップ）のスタイル                      */
/* =================================================== */

/* ツールチップを持つ要素にrelativeを設定して、吹き出しの基準点にする */
[data-tooltip] {
    position: relative;
    cursor: help;
}

/* 吹き出し本体のスタイル */
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    
    /* 修正点: 下側に表示 */
    top: calc(100% + 8px); /* 親要素の下に、矢印の高さ分の隙間を空けて配置 */
    left: 50%;
    transform: translateX(-50%);
    
    background-color: #2b231d;
    color: #f0e6d2;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.9em;
    
    white-space: normal;
    width: 90px; /* 幅 */
    word-break: break-all;
    text-align: center;
    
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    
    /* 修正点: z-indexを大きな値に設定 */
    z-index: 1010; /* 他の要素より手前に表示 */
}

/* 吹き出しの矢印（三角形） */
[data-tooltip]::before {
    content: '';
    position: absolute;

    /* 修正点: 下側に表示するための矢印 */
    top: 100%; /* 親要素のすぐ下に配置 */
    left: 50%;
    transform: translateX(-50%);
    
    border-width: 6px;
    border-style: solid;

    /* 修正点: 上を向く三角形に変更 */
    border-color: transparent transparent #2b231d transparent; 
    
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;

    /* 修正点: z-indexを大きな値に設定 */
    z-index: 1010;
}

/* ホバー時に吹き出しを表示 */
[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
}


#promptSelect {
    width: 100%;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #7a6a5d;
    background-color: #3b2f21;
    color: #f5deb3;
    font-family: 'MedievalSharp', cursive;
    font-size: 1em;
}

#selectedPromptTitle {
    color: #f0e68c;
    font-weight: bold;
    display: block;
    margin-top: 10px;
    font-size: 1.1em;
}

.modal-button {
    font-family: 'MedievalSharp', cursive; font-size: 1.2em;
    color: #fff; border: 2px solid; border-radius: 10px;
    padding: 10px 25px; cursor: pointer;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.7);
    transition: all 0.3s ease;
    margin-top: 20px;
}
.modal-button.success {
    background: linear-gradient(#4b6928, #3a521e); border-color: #a3c182;
}
.modal-button.success:hover {
    background: linear-gradient(#5a7e30, #4c6628); transform: translateY(-2px);
}

/* ===== Story Result Modal ===== */
.story-modal-content {
    max-width: 600px;
    text-align: left;
}

#storyResultContent {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.story-modal-original-content {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    padding-bottom: 15px;
    border-bottom: 1px solid #7a6a5d;
}

.story-modal-original-content img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 5px;
    border: 2px solid #d2b48c;
}

.story-modal-original-content h3 {
    font-size: 1.5em;
    color: #f0e68c;
    margin: 0;
}

.story-modal-generated-text {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid #7a6a5d;
    border-radius: 5px;
    resize: none;
    outline: none;
    font-family: 'MedievalSharp', cursive;
    font-size: 1em;
    color: #f5deb3;
    line-height: 1.6;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.story-modal-generated-text:focus {
    border-color: #f0e68c;
    box-shadow: 0 0 8px rgba(240, 230, 140, 0.5);
}

.story-modal-generated-text::-webkit-scrollbar {
    width: 10px;
}

.story-modal-generated-text::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 5px;
}

.story-modal-generated-text::-webkit-scrollbar-thumb {
    background-color: #7a6a5d;
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.story-modal-generated-text::-webkit-scrollbar-thumb:hover {
    background-color: #d2b48c;
}

.story-modal-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding-top: 15px;
    border-top: 1px solid #7a6a5d;
}

.story-modal-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease;
}

.story-modal-action-btn:hover {
    transform: scale(1.1);
}

.story-modal-action-btn img {
    width: 50px;
    height: 50px;
}


/* ===== Leaflet Popup Customization ===== */
.leaflet-popup-content-wrapper {
    background-color: #2b231d;
    color: #f5deb3;
    border: 2px solid #d2b48c;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0,0,0,0.7);
    font-family: 'MedievalSharp', cursive;
}
/*
.leaflet-popup-content {
    font-family: 'MedievalSharp', cursive;
    padding: 10px;
    max-height: 600px;
    overflow-y: auto;
}
    */

/* スクロールバーが出ないようにできるか試す */
.leaflet-popup-content {
    font-family: 'MedievalSharp', cursive;
    padding: 10px;
    overflow-y: auto;
}

/* Scrollbar styling for popup content */
.leaflet-popup-content::-webkit-scrollbar {
    width: 8px;
}
.leaflet-popup-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}
.leaflet-popup-content::-webkit-scrollbar-thumb {
    background-color: #7a6a5d;
    border-radius: 4px;
    border: 1px solid transparent;
    background-clip: content-box;
}
.leaflet-popup-content::-webkit-scrollbar-thumb:hover {
    background-color: #d2b48c;
}


.leaflet-popup-tip {
    background-color: #2b231d;
}

/*
.popup-image {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    margin: 8px 0;
    border: 1px solid #7a6a5d;
}
    */

.popup-image {
    max-width: 100%;
    max-height: 200px; /* 高さの最大値を設定 */
    width: auto;
    height: auto;
    border-radius: 5px;
    margin: 8px 0;
    border: 1px solid #7a6a5d;
    /*　中心に表示する */
    display: block;
    margin-left: auto;
    margin-right: auto;
}


.popup-content-title {
    font-size: 1.3em;
    color: #f0e68c;
    margin-bottom: 5px;
    text-shadow: 1px 1px 1px #000;
}

.popup-object-detected {
    font-size: 0.9em;
    color: #d2b48c;
    margin-bottom: 10px;
}

.popup-generate-button {
    font-family: 'MedievalSharp', cursive;
    background: linear-gradient(#5d3d9c, #4c2c80);
    color: #fff;
    border: 1px solid #a388d1;
    border-radius: 5px;
    padding: 8px 15px;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.2s ease;
    width: 100%;
}
.popup-generate-button:hover {
    background: linear-gradient(#6e4ab5, #5a3aa1);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .page-container { padding: 8px; }
    .header { padding: 8px 10px; }
    .header-status { font-size: 1em; }
    .back-button img, .quill-button img { width: 25px; height: 25px; }
    .log-title { font-size: 1.5em; }
    .log-list { max-height: 25vh; }
    .modal-content { padding: 20px; }
    .modal-icon { width: 50px; height: 50px; }
}

@media (min-width: 1024px) {
    .main-logo { width: 200px; }
    .game-title { font-size: 5.5em; }
    .tagline { font-size: 1.8em; }
    .nav-button-text { font-size: 1.2em; }
    .section-title { font-size: 3em; }
    .preview-icon { width: 180px; height: 180px; }
}




