html {
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Lora', serif; /* [風格] 預設字體改為優雅的 Lora 襯線字體 */
    color: #3D352A; /* [風格] 預設文字顏色改為深棕色 */
    background-color: #D3C4B3; /* [風格] 背景色改為有質感的亞麻色 */
    background-image: linear-gradient(rgba(0,0,0,0.02) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(0,0,0,0.02) 1px, transparent 1px);
    background-size: 20px 20px;
}

.background-image {
    display: none; /* 移除舊的背景圖設定，改用新的背景色與紋理 */
}

/* --- 2. 主容器樣式 (模擬一本攤開的書) --- */
.book {
    max-width: 850px;
    margin: 50px auto;
    padding: 50px 60px;
    background-color: #FDFCF7; /* [風格] 模擬羊皮紙或舊書頁的顏色 */
    border: 1px solid #D1C7B8;
    border-radius: 3px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.3), 0 0 0 10px rgba(0,0,0,0.1);
}

/* --- 3. 標題與文字排版 --- */
.book-header {
    text-align: center;
    border-bottom: 3px double #D1C7B8;
    padding-bottom: 20px;
    margin-bottom: 40px;
}

.book-header h1 {
    font-size: 3em;
    font-weight: 700;
    color: #3D352A;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.book-header h2 {
    font-size: 1.3em;
    color: #8A795D;
    font-style: italic;
    font-weight: 400;
    letter-spacing: 1px;
    margin-top: 5px;
}

.book h3 {
    font-family: 'Open Sans', sans-serif;
    font-size: 1.6em;
    font-weight: 700;
    color: #5C4033;
    border-bottom: 1px solid #D1C7B8;
    padding-bottom: 10px;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.book h4 {
    font-family: 'Open Sans', sans-serif;
    font-size: 1.2em;
    font-weight: 700;
    color: #8A795D;
    margin-bottom: 20px;
}

.book p {
    font-size: 1.1em;
    line-height: 1.8;
    color: #3D352A;
    margin-bottom: 1.5em;
}

.book strong {
    font-weight: 700;
    color: #5C4033;
}

.book a {
    color: #8B4513;
    text-decoration: underline;
    font-weight: bold;
    transition: color 0.3s;
}
.book a:hover {
    color: #A0522D;
}
.book a.button {
    color: #FDFCF7;
    text-decoration: none;
}

/* --- 4. 各區塊樣式 --- */

/* "Find Your Match" & "Wandering Library" 入口區塊 */
.user-description-section, .wandering-library-section {
    margin: 50px 0;
    padding: 30px;
    background-color: #F9F6F0;
    border: 1px solid #EAE6E0;
    border-radius: 3px;
    text-align: center;
}

.user-description-section h3, .wandering-library-section h3 {
    border-bottom: none;
    text-align: center;
}

.user-description-section textarea {
    width: 100%;
    min-height: 120px;
    background-color: #FFFFFF;
    border: 1px solid #D1C7B8;
    border-radius: 3px;
    padding: 15px;
    font-size: 1.1em;
    font-family: 'Lora', serif;
    color: #3D352A;
    line-height: 1.8;
    margin-top: 15px;
}

/* 按鈕樣式 */
.button, 
#submitDescription {
    font-family: 'Open Sans', sans-serif;
    display: inline-block;
    background-color: #5C4033;
    color: #FDFCF7;
    padding: 12px 30px;
    border: none;
    border-radius: 3px;
    font-size: 1em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-decoration: none;
    cursor: pointer;
    margin-top: 20px;
    transition: background-color 0.3s, transform 0.2s;
}

.button:hover, 
#submitDescription:hover {
    background-color: #3D352A;
    transform: translateY(-1px);
}

.results-area {
    display: none;
    margin-top: 25px;
    padding: 20px;
    background-color: #fff;
    border: 1px dashed #D1C7B8;
    border-radius: 3px;
    text-align: left;
}

/* 國家列表樣式 */
.country-list {
    text-align: center;
}
.country-menu {
    list-style: none;
    padding: 0;
    margin: 30px 0 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
}
.country-menu a {
    display: block;
    text-decoration: none;
    color: #8A795D;
    padding: 12px;
    border: 1px solid #EAE6E0;
    border-radius: 3px;
    transition: all 0.3s ease;
    text-align: center;
    font-family: 'Open Sans', sans-serif;
    font-size: 0.9em;
    font-weight: 700;
}
.country-menu a:hover {
    background-color: #F9F6F0;
    border-color: #D1C7B8;
    color: #5C4033;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

/* 頁尾樣式 */
.footer {
    text-align: center;
    margin-top: 50px;
    padding-top: 20px;
    border-top: 1px solid #EAE6E0;
    font-family: 'Open Sans', sans-serif;
}
.footer a, .footer p {
    font-size: 0.9em;
    color: #8A795D;
    text-decoration: none;
    margin: 5px 0;
}
.footer a:hover {
    text-decoration: underline;
}
.footer ul { list-style: none; padding: 0; margin: 10px 0 0 0; }
.footer ul li { display: inline-block; margin: 0 10px; }

/* 響應式設計 */
@media (max-width: 768px) {
    .book {
        margin: 20px;
        padding: 20px 25px;
    }
    .book-header h1 { font-size: 2.2em; }
    .book-header h2 { font-size: 1.1em; }
    .book p { font-size: 1em; }
    .country-menu { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

.results-area.loading p,
.results-area.error p {
    text-align: center;
    font-style: italic;
    color: #8A795D; /* 使用柔和的棕褐色作為提示文字顏色 */
    margin: 0;
}

.results-area.error p {
    color: #9c3c3c; /* 錯誤訊息使用深紅色，但比純紅更典雅 */
    font-weight: bold;
}

/* [新增] 按鈕在禁用狀態下的樣式 */
#submitDescription:disabled,
.button:disabled {
    background-color: #a99985; /* 使用較淺的灰色，表示不可用 */
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}