/* ============================================================
   home.css - 狗宝的小房间 / 梦境地图 / 图鉴 / 信件
   舞台用 4:3 等比缩放，内部尺寸全部用 em（JS 动态设置字号）
   ============================================================ */

#home-wrap {
    width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px;
}
#home-heading { text-align: center; margin-bottom: 2px; }
#home-heading h1 { font-size: 1.45rem; margin: 0; color: var(--pink-deep); font-weight: normal; letter-spacing: 2px; }
#home-heading p { margin: 2px 0 0; font-size: 0.85rem; color: var(--text-soft); }

/* ---------- 房间舞台 ---------- */
#room-stage {
    position: relative;
    width: min(94vw, calc(72dvh * 4 / 3), 720px);
    aspect-ratio: 4 / 3;
    border-radius: 26px;
    overflow: hidden;
    box-shadow: var(--shadow-lift);
    background: linear-gradient(180deg, var(--wall-top) 0%, var(--wall-bottom) 62%, var(--floor) 62.2%, #dfa877 100%);
    transition: filter 0.8s ease, background 1.5s ease;
    touch-action: manipulation;
}
#room-stage.night { filter: brightness(0.72) saturate(0.85) hue-rotate(-8deg); }
#room-stage.lamp-off { }

/* 房间元素通用：坐标 = 舞台宽高的百分比 */
.room-el {
    position: absolute;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.3s ease;
}
.room-el:active { transform: scale(0.94); }
.room-el .label {
    position: absolute; left: 50%; bottom: -1.4em; transform: translateX(-50%);
    font-size: clamp(9px, 0.62em, 13px); color: rgba(107, 79, 63, 0.75);
    background: rgba(255, 252, 245, 0.85); border-radius: 8px; padding: 1px 8px;
    white-space: nowrap; opacity: 0; transition: opacity 0.25s;
    pointer-events: none;
}
.room-el:hover .label, .room-el.show-label .label { opacity: 1; }

/* 窗户 */
.room-window {
    left: 6%; top: 7%; width: 24%; height: 30%;
    border-radius: 14px 14px 8px 8px;
    border: 0.45em solid #fff6ea;
    background: linear-gradient(180deg, #9ad7f5 0%, #cfeeff 70%, #ffe9b8 100%);
    box-shadow: inset 0 0 0 0.12em #e8cdb4, var(--shadow-soft);
    overflow: hidden;
}
.room-window .sky-body {
    position: absolute; right: 18%; top: 16%;
    width: 1.4em; height: 1.4em; border-radius: 50%;
    background: #ffdf6b; box-shadow: 0 0 1.2em #ffe89a;
    transition: all 1s ease;
}
.room-window.moon .sky-body { background: #fdf6dd; box-shadow: 0 0 1em #fff3b0; }
.room-window .stars { position: absolute; inset: 0; opacity: 0; transition: opacity 1s; font-size: 0.55em; color: #fff; }
.room-window.moon .stars { opacity: 1; }
.room-window .curtain-l, .room-window .curtain-r {
    position: absolute; top: 0; width: 26%; height: 100%;
    background: linear-gradient(180deg, #ffc9b8, #ffb3a6);
}
.room-window .curtain-l { left: 0; border-radius: 0 0 60% 0; }
.room-window .curtain-r { right: 0; border-radius: 0 0 0 60%; }

/* 床 */
.room-bed {
    left: 4%; top: 46%; width: 30%; height: 34%;
}
.room-bed .bed-frame {
    position: absolute; inset: 0;
    background: #c98d5e; border-radius: 14px 14px 10px 10px;
    box-shadow: var(--shadow-soft);
}
.room-bed .bed-mat { position: absolute; left: 6%; right: 6%; top: 16%; bottom: 12%; background: #fff3e2; border-radius: 10px; }
.room-bed .bed-quilt { position: absolute; left: 6%; right: 6%; top: 44%; bottom: 12%; background: linear-gradient(180deg, #ffb3ba, #ff9aa2); border-radius: 8px; }
.room-bed .bed-pillow {
    position: absolute; left: 12%; top: 22%; width: 34%; height: 22%;
    background: #fffdf6; border-radius: 8px; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.05);
}
.room-bed .bed-pillow:hover { transform: rotate(-4deg); }

/* 桌子 + 生日蛋糕 */
.room-table {
    left: 63%; top: 42%; width: 26%; height: 26%;
}
.room-table .table-top { position: absolute; left: 0; right: 0; top: 44%; height: 14%; background: #d99a63; border-radius: 8px; box-shadow: var(--shadow-soft); }
.room-table .table-leg-l, .room-table .table-leg-r { position: absolute; top: 55%; width: 8%; height: 42%; background: #b97b45; border-radius: 3px; }
.room-table .table-leg-l { left: 12%; } .room-table .table-leg-r { right: 12%; }
.room-table .table-cake {
    position: absolute; left: 50%; top: 0; transform: translateX(-50%);
    font-size: 2.1em; line-height: 1; filter: drop-shadow(0 4px 4px rgba(0,0,0,0.15));
}
.room-table .table-cake:hover { transform: translateX(-50%) scale(1.1); }

/* 礼物堆 */
.room-gifts {
    left: 39%; top: 66%; width: 17%; height: 18%;
    display: flex; align-items: flex-end; justify-content: center;
    font-size: 1.6em; line-height: 1;
}
.room-gifts .gift-stack { position: relative; filter: drop-shadow(0 4px 4px rgba(0,0,0,0.15)); }
.room-gifts .keyhole-row {
    position: absolute; left: 50%; transform: translateX(-50%); bottom: -0.9em;
    display: flex; gap: 0.18em; font-size: 0.4em;
}
.room-gifts .keyhole-row span { opacity: 0.28; filter: grayscale(1); transition: all 0.4s; }
.room-gifts .keyhole-row span.got { opacity: 1; filter: none; animation: gb-pop 0.5s ease; }

/* 地毯 */
.room-rug {
    left: 30%; top: 80%; width: 42%; height: 14%;
    background: radial-gradient(ellipse at center, #ffd9c9 0%, #f7bfae 75%);
    border-radius: 50%;
    box-shadow: inset 0 0 0 0.25em rgba(255,255,255,0.55);
}

/* 相框 */
.room-frame {
    left: 36.5%; top: 9%; width: 11%; height: 16%;
    background: #fffaf0; border: 0.3em solid #d9a05b; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5em; box-shadow: var(--shadow-soft);
}
.room-frame:hover { transform: rotate(3deg); }

/* 音乐盒 */
.room-musicbox {
    left: 51%; top: 12%; width: 9%; height: 11%;
    background: linear-gradient(180deg, #b48ecb, #9575cd);
    border-radius: 5px; display: flex; align-items: center; justify-content: center;
    font-size: 1.2em; box-shadow: var(--shadow-soft);
}
.room-musicbox:hover { animation: gb-wobble 0.6s ease; }

/* 灯 */
.room-lamp {
    left: 82%; top: 4%; width: 13%; height: 42%;
}
.room-lamp .lamp-cord { position: absolute; left: 50%; top: 0; width: 2px; height: 40%; background: #a3866f; }
.room-lamp .lamp-shade {
    position: absolute; left: 50%; top: 38%; transform: translateX(-50%);
    width: 2.4em; height: 1.3em;
    background: linear-gradient(180deg, #ffcf6e, #ffb64e);
    border-radius: 1.2em 1.2em 0.3em 0.3em;
    box-shadow: var(--shadow-soft);
}
.room-lamp .lamp-glow {
    position: absolute; left: 50%; top: 52%; transform: translateX(-50%);
    width: 4em; height: 2.6em; border-radius: 50%;
    background: radial-gradient(ellipse, rgba(255,224,130,0.55), rgba(255,224,130,0));
    opacity: 0; transition: opacity 0.6s;
}
#room-stage.lit .lamp-glow { opacity: 1; }

/* 书架（秘密档案） */
.room-shelf {
    left: 75.5%; top: 56%; width: 15%; height: 20%;
    background: #c98d5e; border-radius: 6px;
    display: flex; align-items: center; justify-content: center; gap: 0.12em;
    font-size: 1.1em; box-shadow: var(--shadow-soft);
    opacity: 0.35; filter: grayscale(0.9);
    pointer-events: none;
    transition: all 0.6s;
}
.room-shelf.unlocked { opacity: 1; filter: none; pointer-events: auto; }
.room-shelf.unlocked:hover { transform: translateY(-3px); }

/* 小老鼠洞（不起眼的小物品 = 彩蛋入口） */
.room-hole {
    left: 93.5%; top: 88%; width: 5.5%; height: 8%;
    background: radial-gradient(ellipse at 50% 40%, #4b3222 0%, #6b4a30 70%, transparent 74%);
    border-radius: 50% 50% 12% 12%;
}
.room-hole .dust { position: absolute; left: -30%; top: 30%; font-size: 0.5em; opacity: 0.9; }

/* 门（通往梦境） */
.room-door {
    left: 52.5%; top: 52%; width: 12%; height: 38%;
    background: linear-gradient(180deg, #a8d0c0, #85bfa9);
    border-radius: 45% 45% 8px 8px / 22% 22% 8px 8px;
    border: 0.28em solid #fffaf0;
    box-shadow: var(--shadow-soft);
    display: flex; align-items: center; justify-content: center;
}
.room-door .door-knob { width: 0.3em; height: 0.3em; border-radius: 50%; background: #6d8f7d; position: absolute; right: 14%; top: 55%; }
.room-door .door-sign {
    font-size: 0.6em; color: #4c6b58; background: #fffdf2;
    padding: 0.2em 0.6em; border-radius: 8px; transform: rotate(-5deg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.room-door:hover { transform: translateY(-2px); }

/* 墙上的小脚印（通往找找狗宝） */
.room-pawtrail { left: 22%; top: 30%; font-size: 0.85em; color: rgba(150, 100, 70, 0.5); line-height: 1; }
.room-pawtrail:hover { color: var(--pink-deep); }

/* 书桌 + 信 */
.room-desk {
    left: 36%; top: 30%; width: 0; height: 0; /* 占位，信在信件匣里 */
}
.room-mail {
    left: 37%; top: 34%; font-size: 1.35em; line-height: 1;
    filter: drop-shadow(0 3px 3px rgba(0,0,0,0.15));
}
.room-mail:hover { transform: translateY(-3px) rotate(-4deg); }
.room-mail .badge {
    position: absolute; right: -0.5em; top: -0.45em;
    min-width: 1.05em; height: 1.05em; padding: 0 0.2em;
    border-radius: 0.75em; background: var(--pink-deep); color: white;
    font-size: 0.5em; display: none; align-items: center; justify-content: center;
}
.room-mail.has-new .badge { display: flex; animation: gb-pop 0.5s ease; }

/* 狗宝本体 */
#the-dog {
    left: 42%; top: 58%; width: 17%; height: 26%;
    z-index: 30;
}
#the-dog svg { width: 100%; height: 100%; overflow: visible; }

/* 狗宝气泡 */
#dog-bubble {
    position: absolute; left: 62%; top: -1.2em;
    background: #fffdf6; border: 2px solid var(--peach);
    border-radius: 14px 14px 14px 3px;
    padding: 4px 10px; font-size: clamp(11px, 0.6em, 15px); line-height: 1.4;
    color: var(--text-main); white-space: nowrap;
    opacity: 0; transform: scale(0.6); transform-origin: left bottom;
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none; z-index: 40;
}
#dog-bubble.show { opacity: 1; transform: scale(1); }

/* 抚摸时飘出的爱心 */
.pet-heart {
    position: absolute; font-size: 0.8em; pointer-events: none; z-index: 50;
    animation: gb-heartup 1.2s ease-out forwards;
}

/* 深夜 Zzz */
#dog-zzz {
    position: absolute; left: 70%; top: -0.6em; font-size: 0.7em; color: #8fa8c8;
    opacity: 0; transition: opacity 0.6s; pointer-events: none;
}
#the-dog.sleeping #dog-zzz { opacity: 1; animation: gb-floatupdown 2.4s ease-in-out infinite; }

/* ---------- 梦境地图 ---------- */
#scene-dream { background: linear-gradient(180deg, #2b2a52 0%, #4a3f6b 55%, #6b4a6b 100%); }
#scene-dream .gb-title { color: #ffe6a7; text-shadow: 0 0 14px rgba(255, 220, 130, 0.5); }
#dream-stars { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
#dream-stars i { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; opacity: 0.7; animation: gb-twinkle 2.6s infinite; }

#dream-hud {
    position: absolute; top: calc(12px + var(--sa-top)); left: 14px;
    background: rgba(255,255,255,0.14); color: #fff2cf;
    padding: 6px 14px; border-radius: 18px; font-size: 0.95rem;
    display: flex; align-items: center; gap: 8px;
    border: 1px solid rgba(255,255,255,0.25);
}
#dream-hud .hud-cake { filter: grayscale(100%); opacity: 0.45; transition: all 0.3s; }
#dream-hud .hud-cake.lit { filter: none; opacity: 1; text-shadow: 0 0 8px #ffe08a; }

.map-container { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: 100%; max-width: 420px; margin-top: 10px; }
.level-card {
    background: rgba(255, 250, 240, 0.95); height: 104px; border-radius: 18px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; box-shadow: 0 6px 14px rgba(0,0,0,0.25);
    position: relative; text-align: center; transition: transform 0.2s;
}
.level-card:active:not(.locked) { transform: scale(0.94); }
.level-card.locked { opacity: 0.55; filter: grayscale(0.8); cursor: not-allowed; }
.level-card .emoji { font-size: 2rem; }
.level-card .name { font-size: 0.9rem; }
.level-card .status { position: absolute; top: 6px; right: 9px; font-size: 0.95rem; }
.level-card .highscore { position: absolute; bottom: 5px; font-size: 0.7rem; color: #9b8271; width: 100%; }

/* ---------- 信件全屏 ---------- */
#scene-letter {
    background: radial-gradient(circle at 50% 30%, #fff4e0, #f6dfc4);
    z-index: 700;
}
.letter-paper {
    width: min(92vw, 460px); max-height: 74dvh; overflow-y: auto; touch-action: pan-y;
    background: repeating-linear-gradient(180deg, #fffdf4 0 34px, #fdeeda 34px 35px);
    border-radius: 8px; box-shadow: var(--shadow-lift);
    padding: 26px 30px; position: relative;
}
.letter-paper::before {
    content: ''; position: absolute; left: 14px; top: 0; bottom: 0; width: 2px;
    background: rgba(247, 108, 138, 0.35);
}
.letter-paper h3 { margin: 0 0 12px; color: var(--pink-deep); font-weight: normal; text-align: center; }
.letter-paper p { margin: 0 0 12px; font-size: 1rem; line-height: 35px; }
.letter-sign { text-align: right; color: var(--text-soft); margin-top: 18px; }
#scene-letter .letter-tools { margin-top: 14px; display: flex; gap: 10px; }

/* ---------- 图鉴面板 ---------- */
.ach-list { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 380px; }
.ach-row {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,0.75); border-radius: 14px; padding: 8px 12px;
}
.ach-row .ico { font-size: 1.5rem; width: 2rem; text-align: center; }
.ach-row .txt { flex: 1; }
.ach-row .txt b { display: block; font-weight: normal; color: var(--text-main); }
.ach-row .txt small { color: var(--text-soft); }
.ach-row.locked { opacity: 0.45; filter: grayscale(1); }
.ach-row.done { border: 1px solid var(--butter); }
