/* 方寸喵居 - 主样式表 */
/* 从 index_102.html 完整提取 */

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* 固定高度，防止 iOS Safari 地址栏伸缩导致页面偏移 */
    width: 100%;
    height: 100%;
    height: 100dvh; /* 动态视口高度，Safari 15+ 支持 */
    position: fixed;
    top: 0;
    left: 0;
}

body {
    background-color: #e0f7fa;
    font-family: 'Microsoft YaHei', sans-serif;
    transition: background-color 1s;
    /* Safari 防护：禁止长按弹出菜单、文本选中、触摸高亮 */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

canvas {
    display: block;
    outline: none;
    /* 禁止 canvas 上的默认触摸行为（滚动/缩放），pointer 事件由 Three.js 管理 */
    touch-action: none;
}

#loading-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s;
}

#loading-text {
    font-size: 20px;
    color: #555;
    margin-bottom: 10px;
}

#progress-bar {
    width: 200px;
    height: 5px;
    background: #ddd;
    margin-bottom: 15px;
}

#progress-fill {
    width: 0%;
    height: 100%;
    background: #ffaa00;
    transition: width 0.2s;
}

#force-start-btn {
    display: none;
    padding: 10px 20px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
}

#debug-console {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    max-height: 150px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.7);
    color: #0f0;
    padding: 10px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 12px;
    z-index: 10001;
    pointer-events: auto;
    display: none;
}

.log-error {
    color: #ff5555;
    font-weight: bold;
}

.log-warn {
    color: #ffaa00;
}

#debug-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    z-index: 100;
}

/* 复用之前的 debug-btn 样式，稍微调整一下 */
.debug-btn {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.debug-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}


/* === HUD 容器布局 === */
#hud-top-left {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* 组件间距 */
    z-index: 50;
    pointer-events: none;
    /* 让鼠标能点穿空白区域 */
}

#hud-top-left>div {
    pointer-events: auto;
    /* 组件本身可点击 */
}

/* === HUD 容器布局 === */
#hud-top-left {
    position: absolute;
    top: 15px;
    left: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* 稍微紧凑一点 */
    z-index: 50;
    pointer-events: none;
}

#hud-top-left>div {
    pointer-events: auto;
}

/* ================= 1. 时间组件 (Time Widget) ================= */
#time-widget {
    position: relative;
    width: 130px;
    height: 130px;
    /* 这是一个正圆形区域 */
    margin-bottom: 5px;
    /* 给下面留点空隙 */
}

#time-bg {
    width: 100%;
    height: 100%;
    background: url('../assets/ui/time_bg.png') no-repeat center center;
    background-size: contain;

    /* 文字布局 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    /* 文字样式 */
    color: #6d4c41;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 900;

    /* [微调] 根据你的底图，文字整体可能需要稍微往上或往下提一点 */
    padding-top: 5px;
}

#time-ampm {
    font-size: 16px;
    opacity: 0.6;
    line-height: 1;
    margin-bottom: -2px;
    /* 紧贴时间 */
}

#time-text-display {
    font-size: 32px;
    line-height: 1;
    letter-spacing: -1px;
}

/* 太阳/月亮图标容器 (附着在右上角) */
#weather-icon-container {
    position: absolute;
    top: 0px;
    right: 0px;
    /* 挂在右上角 */
    width: 45px;
    height: 45px;
    background: url('../assets/ui/weather_bg.png') no-repeat center/contain;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    z-index: 10;
    /* 在最上层 */
}

#weather-icon-container:hover {
    transform: scale(1.1);
}

#weather-icon-img {
    /* [修改] 让图片撑满容器 */
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* 铺满 */
}

/* [新增] 天气切换按钮 (附着在左下角) */
#weather-toggle-btn {
    position: absolute;
    bottom: 0px;
    left: 0px;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    z-index: 10;
}

#weather-toggle-btn:hover {
    transform: scale(1.1);
}

.weather-btn-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

.weather-btn-icon {
    position: relative;
    width: 60%;
    height: 60%;
    object-fit: contain;
    z-index: 2;
}

/* 滑块气泡 (默认隐藏) */
#time-popover {
    position: absolute;
    left: 100%;
    /* 在时间组件右侧 */
    top: 10px;
    margin-left: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    pointer-events: auto;
    width: 140px;
    /* 固定宽度防止抖动 */
}

#time-popover.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    /* 隐藏时稍微往左缩一下 */
}

#time-slider-hud {
    width: 100px;
    cursor: pointer;
    accent-color: #ffaa00;
}

#time-reset-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #999;
    padding: 0;
}

/* ================= 2. 爱心组件 (Heart Widget) ================= */
#heart-widget {
    position: relative;
    /* [修改] 调整宽高比，防止背景拉伸 */
    /* 假设背景图是长条形的，高度55px足够了 */
    width: 200px;
    height: 65px;
    margin-top: 5px;
    /* [修改] 原来是 -15px，现在改为 5px，向下移动20px */
    z-index: 5;
}

#heart-bg {
    width: 100%;
    height: 100%;
    background: url('../assets/ui/heart_bar_bg.png') no-repeat left center;

    /* [关键修复] 使用 contain 保持原图比例，绝不拉伸 */
    background-size: contain;

    display: flex;
    align-items: center;

    /* [调整] 因为图标变小了，左边距适当减小 */
    padding-left: 75px;
    box-sizing: border-box;
    padding-bottom: 0px;
}

/* 独立的爱心图标 */
#heart-icon-img {
    position: absolute;
    left: 14px;
    top: 15px;
    /* 垂直居中微调 */

    /* [缩小] 改回精致的大小 */
    width: 38px;
    height: 38px;

    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2));
    z-index: 6;
}

#heart-text-display {
    /* [调整] 字体大小适配新的高度 */
    font-size: 22px;
    color: #d35400;
    font-weight: 800;
}


/* 3. 状态球组件 */
/* ================= 3. 状态球组件 (Status Icons) ================= */
#status-widget-group {
    display: flex;
    flex-direction: row;
    gap: 8px;
    margin-left: 5px;
    margin-top: 5px;
}

.status-circle {
    width: 65px;
    height: 65px;
    position: relative;
    background: none;
    border: none;
}

/* 1. 底层 Frame */
.status-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 0;
}

/* 2. 中间 Mask */
.liquid-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    z-index: 1;
    background: transparent;
}

/* 水位控制器 */
.liquid-level {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* JS 控制这个 */
    overflow: hidden;
    /* 关键：切掉上半部分 */
    transition: height 0.5s ease-out;
}

/* 3. 液体纹理 - [本次修复重点] */
.liquid-texture {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px;
    /* [Fixed] 固定高度，永远不缩放 */
    object-fit: cover;
}

/* 4. 顶层 Icon */
.status-icon-fg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 2;

    /* [放大] 放大到 0.85 */
    /* 65px * 0.85 ≈ 55px，这样就和上面的爱心一样大了 */
    transform: scale(0.85);

    pointer-events: none;
}

/* 4. 底部按钮 */
#hud-bottom-bar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 40px;
    z-index: 40;
}

.hud-btn-container {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
}

.hud-btn-container:hover {
    transform: translateY(-5px);
}

.hud-main-btn {
    width: 70px;
    height: 70px;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.3));
}

#diary-red-dot-hud {
    position: absolute;
    top: 0;
    right: 0;
    width: 15px;
    height: 15px;
    background: red;
    border-radius: 50%;
    border: 2px solid white;
    display: none;
}

/* 5. 商店面板动画 */
/* ================= 5. 商店面板 (软木板风格) - 最终精修版 ================= */
#shop-panel-container {
    position: absolute;
    bottom: 0;
    left: 50%;

    /* 尺寸 */
    width: 800px;
    height: 250px;
    max-width: 95%;

    /* --- [核心修复：九宫格不拉伸] --- */
    /* 1. 设置屏幕上显示的边框厚度 (例如 22px) */
    border: 40px solid transparent;

    /* 2. border-image 配置 */
    /* url(...) */
    /* 80: 假设源图中边框厚度约80像素 (不带单位!)。这保证切出来是正方形 */
    /* fill: 保留中间内容 */
    /* / 22px: 对应上面的 border 宽度 */
    /* / 0: 不向外扩张 */
    /* round: [关键] 使用平铺而不是拉伸，防止木纹变形 */
    border-image: url('../assets/ui/shop_bg_board.png') 80 fill / 40px / 0 round;
    /* --------------------------- */

    box-shadow: none;
    z-index: 60;
    padding: 0;

    /* 动画 */
    transform: translateX(-50%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);

    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

/* 隐藏状态 */
#shop-panel-container.hidden-bottom {
    transform: translate(-50%, 120%) !important;
}

/* 标题牌微调 */
#shop-title-img {
    position: absolute;
    /* 往上提，因为它现在是相对于 padding box 定位的 */
    top: -50px;
    left: -30px;
    /* 左移40px，从10px改为-30px */
    height: 60px;
    z-index: 70;
}

/* 关闭按钮微调 */
#shop-close-btn {
    position: absolute;
    top: -50px;
    right: -10px;
    /* 放在最右上角，从10px改为-10px */
    width: 45px;
    height: 45px;
    background: url('../assets/ui/shop_close_btn.png') no-repeat center/contain;
    border: none;
    cursor: pointer;
    z-index: 70;
}

#shop-close-btn:hover {
    transform: scale(1.1);
}

/* === 页签栏 (Tabs) === */
#shop-tabs {
    position: absolute;
    top: -50px;
    /* 往上提，放在板子外面 */
    right: 55px;
    /* 继续右移，从90px改为55px，留出关闭按钮的空间 */
    display: flex;
    gap: 8px;
    z-index: 70;
}

.shop-tab {
    position: relative;
    width: 55px;
    height: 55px;
    cursor: pointer;
    transition: transform 0.2s;
    /* Flex 居中 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.shop-tab:hover {
    transform: translateY(-5px);
}

/* 背景框 (Tab Background) */
.tab-bg {
    position: absolute;
    /* [修改] 绝对居中大法 */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* 向回移动自身的一半，实现完美居中 */

    width: 100%;
    height: 100%;
    /* 改为100%，与图标尺寸一致 */
    object-fit: contain;

    /* [修改] 提高层级，但要比 icon 低 */
    z-index: 0;

    /* 确保可见性 */
    display: block;
    opacity: 1;
}

/* 选中状态逻辑 */
.shop-tab:not(.active) .tab-bg {
    /* 未选中：变暗 */
    filter: brightness(0.6) grayscale(100%);
}

.shop-tab.active .tab-bg {
    /* 选中：原样显示 */
    filter: none;
}

/* 图标 (Icon) */
/* 页签图标 */
.tab-icon {
    position: absolute;

    /* [修改] 绝对居中大法 + 微调偏移 */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    /* 如果需要微调，可以改为 translate(-50%, calc(-50% + 1px)) */

    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

/* === 商品滚动区 ===XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
#items-scroll {
    margin-top: 0;

    /* [关键修改] 宽度缩减到 82%，给左右木框留出视觉空间 */
    width: 95%;
    height: 100%;

    display: flex;
    gap: 15px;

    /* [修改] 内边距调小，因为宽度已经缩了 */
    /* Top 20px: 避开上面的标题 */
    /* Bottom 45px: 避开下面的猫头 */
    padding: 20px 10px 45px 10px;

    overflow-x: scroll;
    overflow-y: hidden;
    white-space: nowrap;
    scroll-behavior: smooth;

    /* 隐藏原生滚动条 */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Chrome/Edge/Safari 隐藏滚动条 */
#items-scroll::-webkit-scrollbar {
    height: 35px !important;
    /* 增加高度，给猫头留足空间 */
    width: 100% !important;
    background-color: transparent !important;
    appearance: none;
    /* 移除系统默认外观 */

}

/* === [新增] 手写滚动条容器样式 === */
/* === 手写滚动条容器 === */
#custom-scrollbar {
    position: absolute;

    /* [修改] 宽度跟上面列表保持一致 */
    width: 82%;

    /* 居中定位 */
    left: 50%;
    transform: translateX(-50%);

    /* 底部位置 - 向下移动避开价格标签 */
    bottom: -25px;
    height: 30px;

    pointer-events: auto;
    z-index: 70;
}

/* 绳子 */
#custom-track {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 10px;
    transform: translateY(-50%);
    background: url('../assets/ui/shop_cat_deco_rope.png') repeat-x center/auto 100%;
    /* 绳子本身不响应鼠标，防止误触 */
    pointer-events: none;
}

/* 猫头滑块 */
#custom-thumb {
    position: absolute;
    top: -10px;
    left: 0;
    width: 50px;
    height: 40px;
    background: url('../assets/ui/shop_cat_deco.png') no-repeat center/contain;

    /* [新增] 鼠标变小手 */
    cursor: pointer;
    /* 拖拽时取消过渡动画，否则会感觉"肉" */
    /* transition: left 0.1s linear; -> 移到 JS 里动态控制 */
}


/* === 商品卡片 (展示台风格) === */
.item-card {
    flex: 0 0 auto;
    width: 100px;
    height: 150px;
    /* [修改] 原来是 130px，现在增加到 150px 以容纳名称标签 */
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s;
}

.item-card:hover {
    transform: translateY(-5px);
}

.item-card.disabled {
    opacity: 0.6;
    filter: grayscale(100%);
    cursor: not-allowed;
}

/* 展示台 (Shelf) */
.shelf-bg {
    position: absolute;
    top: 60px;
    /* 展示台在脚下 */
    width: 90px;
    height: 40px;
    z-index: 1;
}

/* 商品图标 */
.item-icon {
    width: 80px;
    height: 80px;
    object-fit: contain;
    z-index: 2;
    /* 在台子上面 */
    margin-top: 10px;
    filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.2));
}

/* 如果没有图，显示的备用色块 */
.item-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-top: 25px;
    z-index: 2;
    border: 2px solid rgba(0, 0, 0, 0.1);
}

/* 价格吊牌 - 修复布局 */
.price-tag-new {
    position: absolute;
    bottom: 15px;
    width: 70px;
    height: 30px;
    background: url('../assets/ui/shop_price_tag.png') no-repeat center/contain;
    z-index: 3;

    /* Flex 布局让爱心和数字水平居中 */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    /* 图标和数字间距 */

    color: #d35400;
    font-weight: bold;
    font-size: 13px;
    padding-top: 4px;
    /* 微调文字垂直位置 */
    padding-left: 2px;
}

/* 价格标签里的小爱心 */
.price-heart-icon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    display: block;
}



/* 选中状态 */
.item-card.selected .item-icon {
    transform: scale(1.1);
    filter: drop-shadow(0 0 10px gold);
}

/*==========================================================================*/

#clock-wrapper {
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 15px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    min-width: 140px;
}

/* [新增] 重置时间按钮样式 */
#btn-auto-time {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
    /* 默认灰色 */
    margin-left: 8px;
    padding: 0;
    line-height: 1;
    transition: all 0.3s ease;
}

#btn-auto-time:hover {
    color: #333;
    transform: rotate(180deg);
    /* 悬停时旋转一下 */
}

/* 当处于自动模式时，按钮变成绿色，表示当前是实时同步状态 */
#btn-auto-time.is-auto {
    color: #2ecc71;
}

#clock-display {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

#day-icon {
    font-size: 24px;
}

#time-control {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: #666;
    width: 100%;
}

input[type=range] {
    flex: 1;
    cursor: pointer;
    height: 4px;
    accent-color: #ffaa00;
}

#heart-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 18px;
    color: #e74c3c;
    font-weight: bold;
    display: flex;
    gap: 10px;
    align-items: center;
    pointer-events: auto;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.debug-btn {
    background: #555;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

#tutorial {
    position: absolute;
    top: 150px;
    left: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 12px;
    pointer-events: none;
    z-index: 5;
    display: none;
}

#context-menu {
    position: absolute;
    display: none;
    background: white;
    padding: 8px;
    border-radius: 8px;
    z-index: 100;
    flex-direction: column;
    gap: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
}

.context-btn {
    padding: 8px 16px;
    border: 1px solid #eee;
    background: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.btn-delete {
    color: red;
    background: #fff0f0;
}

#confirm-dialog {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 20000;
    text-align: center;
    display: none;
    width: 280px;
    font-family: 'Microsoft YaHei', sans-serif;
}

#confirm-dialog h3 {
    margin-top: 0;
    color: #333;
}

#confirm-dialog p {
    color: #666;
    margin-bottom: 20px;
}

.dialog-btns {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
}

.dialog-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.1s;
}

.btn-yes {
    background: #ffaa00;
    color: white;
}

.btn-no {
    background: #eee;
    color: #333;
}

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

.status-valid {
    color: green;
    font-weight: bold;
}

.status-invalid {
    color: red;
    font-weight: bold;
}

.heart-float {
    position: absolute;
    color: #e74c3c;
    font-weight: bold;
    font-size: 20px;
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
    z-index: 30;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-50px) scale(1.5);
        opacity: 0;
    }
}

.emote-bubble {
    position: absolute;
    font-size: 24px;
    pointer-events: none;
    animation: popUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 25;
}

@keyframes popUp {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

#shop-panel {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    user-select: none;
    z-index: 10;
}

#tabs {
    display: flex;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
}

.tab {
    flex: 1;
    text-align: center;
    padding: 10px 0;
    cursor: pointer;
    font-size: 14px;
    color: #666;
}

.tab.active {
    background: #fff;
    color: #333;
    font-weight: bold;
    border-bottom: 3px solid #ffaa00;
}

.bubble {
    position: absolute;
    top: -100px;
    left: -100px;
    background: white;
    padding: 8px 15px;
    border-radius: 20px;
    border: 2px solid #333;
    font-size: 20px;
    pointer-events: none;
    transform: translate(-50%, -100%);
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.bubble.hidden {
    opacity: 0;
    visibility: hidden;
}

.bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    margin-left: -6px;
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

/* [UI修改] 常驻显示面板，位置调整到左下角 */
.panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    /* 放在左侧 */
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 12px;
    width: 160px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    font-family: 'Arial', sans-serif;
    z-index: 900;
    display: block;
    /* 常驻显示 */
}

.panel.hidden {
    display: none !important;
}

.panel h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
    text-align: center;
}

.stat-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
}

.stat-row span {
    width: 40px;
    font-weight: bold;
    color: #555;
}

.progress-bar {
    flex-grow: 1;
    background: #e0e0e0;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-left: 5px;
    border: 1px solid #ccc;
}

#bar-hunger {
    background: #ff9f43;
    height: 100%;
    transition: width 0.3s;
}

#bar-toilet {
    background: #54a0ff;
    height: 100%;
    transition: width 0.3s;
}

/* [新增] 日记入口按钮 */
#diary-btn-wrapper {
    position: absolute;
    bottom: 20px;
    left: 200px;
    /* 放在状态面板(宽160px)右边 */
    z-index: 20;
}

#diary-toggle-btn {
    font-size: 30px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #fff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

#diary-toggle-btn:hover {
    transform: scale(1.1);
}

#diary-red-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    /* 默认隐藏 */
}

/* ================= 6. 日记本 UI (新版) ================= */
#diary-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

#diary-modal.hidden {
    display: none;
}

/* 书本容器 */
#diary-book-container {
    position: relative;
    width: 1000px;
    height: 600px;
    max-width: 95%;
    max-height: 95%;

    background: transparent;
    /* 确保背景透明 */
    box-shadow: none;
    /* [修复] 去掉这个矩形阴影，消除"方形底" */

    overflow: visible;
    display: flex;
}

/* 背景图 - 改用滤镜阴影 (贴合图片形状) */
#diary-bg-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 0;

    /* [新增] 让阴影跟随图片轮廓，而不是方框 */
    filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.5));
}

/* 关闭按钮 */
#diary-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    /* 调整位置，在书的右上角 */
    width: 40px;
    height: 40px;
    background: url('../assets/ui/shop_close_btn.png') no-repeat center/contain;
    /* 复用关闭按钮图标 */
    border: none;
    cursor: pointer;
    z-index: 100;
    /* 确保在最上层 */
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
    transition: transform 0.2s;
}

#diary-close-btn:hover {
    transform: scale(1.1);
}


/* 左右页布局微调 */
#diary-left-page,
#diary-right-page {
    position: relative;
    flex: 1;
    padding: 70px;
    /* 加大内边距 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    z-index: 1;
}

#diary-left-page {
    border-right: 1px dashed rgba(0, 0, 0, 0.1);
    /* 模拟书缝 */
    padding-right: 20px;
}

#diary-right-page {
    padding-left: 20px;
}

/* [修复2] 左页：放大照片框 */
#polaroid-frame {
    position: relative;

    /* [加大尺寸] */
    width: 320px;
    height: 380px;

    margin-top: 10px;
    /* 稍微往上提一点 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.25));
    /* 加深照片阴影 */
    margin-left: 20px;
    transform: rotate(-2deg);
    /* [彩蛋] 稍微歪一点点，更自然 */
}

.polaroid-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
    /* 相框在照片上面 */
}

/* [修改] 照片：4:5比例，完整显示不裁切 */
.polaroid-photo {
    position: absolute;

    /* 位置微调：居中显示 */
    top: 18px;
    left: 50%;
    transform: translateX(-50%);

    /* 尺寸限制：最大宽高 */
    max-width: 88%;
    max-height: 78%;

    /* [关键修复] 使用 contain 完整显示照片，不裁切 */
    object-fit: contain;
    z-index: -1;
    /* 照片在框的下面 */
    background-color: transparent;
    /* 去掉白色背景 */

    /* 可选：加一点圆角，防止四个角太尖锐 */
    border-radius: 2px;
}

.polaroid-tape {
    position: absolute;
    top: 0px;
    left: 50%;
    transform: translateX(-50%);
    /* 胶带在顶部居中 */
    width: 80px;
    height: 30px;
    object-fit: contain;
    z-index: 3;
    /* 胶带在最上层 */
}

.polaroid-text {
    position: absolute;
    font-family: 'Kalam', cursive;
    /* 尝试手写字体 */
    color: #5d4037;
    font-size: 16px;
    z-index: 3;
    /* 文字在最上层 */
}

#diary-photo-date {
    bottom: 18px;
    left: 40px;
}

/* 日期往中间移动 */
#diary-photo-weather {
    bottom: 18px;
    right: 40px;
    text-align: right;
}

/* 天气往中间移动 */

/* [新增] 手动拍照按钮 - 移动到照片框左上角胶带附近 */
#manual-photo-btn {
    position: absolute;
    top: -10px;
    /* 稍微在照片框上方 */
    left: 10px;
    /* 在照片框左侧偏右一点 */
    width: 60px;
    /* 从45px放大到60px */
    height: 60px;
    /* 从45px放大到60px */
    background: transparent;
    border: none;
    padding: 5px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#manual-photo-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#manual-photo-btn:hover {
    transform: scale(1.1);
}

#manual-photo-btn:active {
    transform: scale(0.95);
}


/* 装饰贴纸 - 位置调整 & 去除透明度 */
.diary-deco-fish-left {
    position: absolute;
    bottom: 30px;
    left: 40px;
    width: 50px;
    height: 50px;
    object-fit: contain;
    z-index: 5;
    opacity: 1;
    /* [修复] 不透明 */
}

.diary-deco-fish-right {
    position: absolute;
    top: 60px;
    /* [修复] 往下挪，避开右上角的关闭按钮 */
    right: 40px;
    width: 50px;
    height: 50px;
    object-fit: contain;
    z-index: 5;
    opacity: 1;
    /* [修复] 不透明 */
    transform: rotate(15deg);
    /* 稍微歪一点更自然 */
}

.diary-deco-paw {
    position: absolute;
    bottom: 80px;
    /* 往上挪一点，别挡住翻页按钮 */
    right: 50px;
    width: 60px;
    height: 60px;
    object-fit: contain;
    z-index: 5;
    opacity: 1;
    /* [修复] 不透明 */
}

/* === 右页：日记内容 === */
/* [修复3] 右页：文字颜色优化 (深褐色系) */
.page-date-title {
    margin: 10px 0 5px 0;
    font-size: 28px;
    color: #3e2723;
    /* 深咖啡色 */
    text-align: center;
    font-family: 'Kalam', cursive;
    font-weight: bold;
}

/* [修改] 右页：天气与心情信息 */
.page-meta {
    /* [加大] 字号从 14px 改为 18px */
    font-size: 18px;

    /* [加深] 颜色改深一点，防止看不清 */
    color: #5d4037;

    text-align: center;
    margin-bottom: 25px;

    /* [统一] 使用和日记正文一样的字体 */
    font-family: 'Kalam', cursive, 'Microsoft YaHei', sans-serif;

    /* [加粗] 让标题行更醒目 */
    font-weight: bold;
}

#diary-entries-scroll {
    flex: 1;
    width: 100%;
    overflow-y: auto;

    /* [加大] 右侧内边距，防止滚动条贴边 */
    padding-right: 20px;
    /* [加大] 底部内边距，防止文字被底部装饰挡住 */
    padding-bottom: 40px;

    font-family: 'Kalam', cursive;
    /* 手写字体 */
    color: #4e342e;
    line-height: 1.6;
    font-size: 18px;
}

/* 滚动条美化 */
#diary-entries-scroll::-webkit-scrollbar {
    width: 8px;
}

#diary-entries-scroll::-webkit-scrollbar-thumb {
    background: #8B6914;
    border-radius: 4px;
}

#diary-entries-scroll::-webkit-scrollbar-track {
    background: transparent;
}

/* 日记条目 - 线条颜色修改 */
.entry {
    margin-bottom: 20px;

    /* [修复] 改为粘土棕色 */
    border-left: 4px solid #8d6e63;

    padding-left: 15px;
    animation: fadeIn 0.3s;
}

.entry-time {
    font-size: 14px;
    color: #8d6e63;
    /* 时间用淡褐色 */
    font-weight: bold;
    margin-bottom: 4px;
}

.entry-text {
    font-size: 18px;
    /* [加大] 字号 */
    color: #4e342e;
    /* [关键] 正文改用深褐色，对比度更高，更清晰 */
    line-height: 1.6;
    font-weight: 500;
}

.empty-tip {
    color: #5d4037;
    /* [修改] 与上方心情颜色一致 */
    text-align: center;
    border: none;
    font-style: italic;
    margin-top: 50px;
    font-size: 16px;
}

/* === 底部导航按钮 (Previous/Next) === */
#diary-nav-buttons {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 300px;
    /* 两个按钮间的距离 */
    z-index: 10;
}

#diary-nav-buttons button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    width: 100px;
    height: 50px;
    /* 按钮图片尺寸 */
    transition: transform 0.2s;
}

#diary-nav-buttons button:hover {
    transform: translateY(-3px);
}

#diary-nav-buttons button img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}



/* [新增] 右上角 Debug 工具栏样式 */
#debug-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    z-index: 100;
}

.debug-btn {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.debug-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* 隐藏所有调试按钮（GM按钮由 main.js 动态生成） */
#debug-panel .debug-btn {
    display: none;
}

/* 只显示保存、读取、说明、画质按钮 */
#debug-panel #btn-save,
#debug-panel #btn-load,
#debug-panel #btn-manual,
#debug-panel #btn-graphics {
    display: inline-block !important;
}

#game-version {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin-left: 10px;
    font-weight: bold;
    align-self: center;
    white-space: nowrap;
}

/* 放置提示框 - 跟随鼠标 */
/* 全局跟随鼠标提示框 */
#global-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    z-index: 10000;
    pointer-events: none;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    display: none;
}

/* 游戏说明弹窗 */
#manual-modal {
    display: none;
    position: fixed;
    z-index: 30000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

#manual-modal.show {
    display: flex;
}

#manual-content {
    background: #FFF8F0;
    border-radius: 16px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    line-height: 1.8;
    color: #333;
    position: relative;
}

#manual-content h2 {
    color: #8B6914;
    margin-top: 20px;
    font-size: 16px;
}

#manual-content h3 {
    color: #B8860B;
    margin-top: 15px;
    font-size: 14px;
}

#manual-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

#manual-close:hover {
    color: #333;
}

/* 家具状态气泡 */
.furniture-bubble {
    position: absolute;
    background: white;
    border: 3px solid #333;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 24px;
    pointer-events: none;
    z-index: 50;
    /* [修改] 低于商店UI (60)，高于 Canvas */
    transform: translate(-50%, -100%);
    /* 居中并在上方 */
    white-space: nowrap;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: bubble-float 2s ease-in-out infinite;
    display: none;
    /* 默认隐藏 */
}

/* 气泡下的小三角 */
.furniture-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

/* 内部白色小三角遮挡线 */
.furniture-bubble::before {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: white transparent transparent transparent;
    z-index: 1;
}

@keyframes bubble-float {

    0%,
    100% {
        transform: translate(-50%, -105%);
    }

    50% {
        transform: translate(-50%, -95%);
    }
}

/* ================= 画质设置面板 ================= */
#graphics-settings-panel {
    position: absolute;
    top: 50px;
    right: 10px;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    width: 220px;
    font-family: 'Microsoft YaHei', sans-serif;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

#graphics-settings-panel.hidden {
    display: none;
}

.gfx-panel-title {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    text-align: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #f0e6d3;
}

.gfx-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.gfx-label {
    font-size: 13px;
    color: #555;
}

.gfx-toggle {
    width: 42px;
    height: 26px;
    border-radius: 13px;
    border: 2px solid #ddd;
    background: #ccc;
    color: #999;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gfx-toggle.active {
    background: #ffaa00;
    border-color: #e69900;
    color: white;
}

.gfx-toggle:active {
    transform: scale(0.92);
}

.gfx-hint {
    font-size: 11px;
    color: #aaa;
    text-align: center;
    margin-top: 10px;
    line-height: 1.4;
}