* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0e1630; font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; color: #3a2a1a; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; }
.hidden { display: none !important; }

.btn { border: 0; border-radius: 999px; padding: 10px 20px; font-size: 16px; font-weight: 600; cursor: pointer; background: #fff7e8; color: #6b3a14; box-shadow: 0 3px 0 #d9b98a; font-family: inherit; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #d9b98a; }
.btn.gold { background: linear-gradient(#ffd56b, #f5a623); color: #5a2b00; box-shadow: 0 3px 0 #b86f0a; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- 邀请信 ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; }
#letter { background: radial-gradient(ellipse at 50% 30%, #2b3d7a 0%, #0e1630 70%); flex-direction: column; justify-content: safe center; overflow-y: auto; padding: 20px 0; }
.snowfall { position: absolute; inset: 0; pointer-events: none; background-image: radial-gradient(2px 2px at 20px 30px, #fff, transparent), radial-gradient(2px 2px at 80px 120px, #fff, transparent), radial-gradient(3px 3px at 150px 60px, #fff, transparent), radial-gradient(2px 2px at 220px 160px, #fff, transparent); background-size: 260px 200px; animation: fall 9s linear infinite; opacity: .7; }
@keyframes fall { to { background-position: 40px 600px, -30px 600px, 20px 600px, -10px 600px; } }
.env-wrap { position: relative; flex-shrink: 0; width: min(86vw, 380px); height: 250px; margin-top: clamp(30px, 16vh, 140px); }
#letter:has(.join:not(.hidden)) .env-wrap { margin-top: 0; }
.envelope { position: absolute; inset: 0; cursor: pointer; filter: drop-shadow(0 12px 24px rgba(0,0,0,.4)); z-index: 1; }
.env-back { position: absolute; inset: 0; background: #b8322f; border-radius: 10px; }
.env-front { position: absolute; inset: 0; border-radius: 10px; background: linear-gradient(160deg, transparent 49.5%, #c94540 50%) , linear-gradient(200deg, transparent 49.5%, #c94540 50%); background-color: #d4504a; clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 34px; z-index: 3; }
.env-name { font-size: 24px; color: #fff3d6; font-weight: 700; letter-spacing: 2px; }
.env-stamp { position: absolute; right: 16px; bottom: 16px; font-size: 26px; background: #fff3d6; border: 2px dashed #b8322f; border-radius: 4px; padding: 2px 6px; }
.env-flap { position: absolute; left: 0; right: 0; top: 0; height: 60%; background: #e05a53; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform .6s ease; z-index: 4; border-radius: 10px 10px 0 0; }
.env-seal { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); width: 48px; height: 48px; border-radius: 50%; background: radial-gradient(#ffd56b, #d49a1e); color: #8a4b00; display: flex; align-items: center; justify-content: center; font-size: 24px; z-index: 5; transition: opacity .3s; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 1; }
.envelope.open .env-seal { opacity: 0; }
.envelope.open { cursor: default; }
.paper { position: absolute; left: 6%; right: 6%; top: 8%; height: 84%; background: #fffaf0; border-radius: 6px; padding: 22px 22px 18px; z-index: 0; transition: transform .9s cubic-bezier(.2,.9,.3,1.2) .4s, height .6s ease .4s, z-index 0s linear .9s; box-shadow: 0 8px 30px rgba(0,0,0,.25); background-image: repeating-linear-gradient(#fffaf0 0 31px, #f0e2c8 31px 32px); overflow: hidden; }
.paper.out { transform: translateY(-62%); height: 150%; z-index: 2; overflow: auto; }
.paper-to { font-size: 18px; font-weight: 700; color: #8a2d1f; margin-bottom: 8px; }
.paper-body { font-size: 17px; line-height: 32px; white-space: pre-wrap; }
.paper-from { text-align: right; margin-top: 10px; color: #8a2d1f; }
.paper .btn { display: block; margin: 16px auto 6px; opacity: 0; transition: opacity .5s 1.4s; }
.paper.out .btn { opacity: 1; }
.paper-note { font-size: 11px; color: #a08a6a; text-align: center; line-height: 16px; }
.hint { margin-top: 40px; color: #ffe9b8; font-size: 15px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.envelope.wiggle { animation: wiggle .5s ease; }
@keyframes wiggle { 25% { transform: rotate(-3deg); } 75% { transform: rotate(3deg); } }

.join { position: relative; z-index: 3; margin-top: 26px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.join-q { color: #ffe9b8; text-align: center; line-height: 1.7; font-size: 15px; }
.join input { border: 0; border-bottom: 2px dashed #ffd56b; background: transparent; color: #fff3d6; font-size: 24px; text-align: center; width: 200px; padding: 6px; font-family: inherit; outline: none; }
.join input::placeholder { color: rgba(255,233,184,.45); }
.join-err { color: #ffb3a8; font-size: 13px; min-height: 18px; max-width: 300px; text-align: center; }
.envelope.locked { cursor: default; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; z-index: 10; display: flex; gap: 8px; flex-wrap: wrap; }
.pill { border: 0; border-radius: 999px; padding: 7px 13px; font-size: 14px; background: rgba(255, 247, 232, .92); color: #6b3a14; cursor: pointer; font-family: inherit; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.pill.online { margin-left: auto; cursor: default; font-size: 12px; }
#enterPrompt { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 10; }
#enterPrompt .btn { font-size: 18px; padding: 12px 28px; animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }
#toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 30; background: rgba(255, 247, 232, .96); color: #6b3a14; padding: 10px 18px; border-radius: 14px; font-size: 15px; max-width: 86vw; box-shadow: 0 4px 14px rgba(0,0,0,.3); text-align: center; }
#emotes { position: fixed; left: 10px; top: 56px; z-index: 11; background: rgba(255,247,232,.96); border-radius: 14px; padding: 8px; display: flex; gap: 6px; flex-wrap: wrap; max-width: 260px; }
#emotes button { font-size: 28px; background: none; border: 0; cursor: pointer; }
#emotes .empty { font-size: 13px; padding: 6px; color: #8a6a4a; }

/* ---------- 房间（邮局 / 装扮） ---------- */
.room { background: rgba(10, 16, 40, .72); }
.room-card { position: relative; width: min(94vw, 520px); max-height: 92vh; overflow: auto; background: #fff7e8; border-radius: 20px; padding: 18px 18px 22px; box-shadow: 0 16px 40px rgba(0,0,0,.45); border: 4px solid #8a4b1f; }
.room-card h2 { margin: 0 0 10px; text-align: center; color: #8a2d1f; }
.close { position: absolute; right: 12px; top: 10px; border: 0; background: none; font-size: 22px; cursor: pointer; color: #8a4b1f; }
.elf { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.elf-face { font-size: 40px; }
.elf-say { background: #fff; border-radius: 14px; padding: 10px 12px; font-size: 15px; line-height: 1.6; box-shadow: 0 2px 0 #ead6b4; flex: 1; }
.boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mini-box { aspect-ratio: 1; border-radius: 12px; border: 0; cursor: pointer; position: relative; font-family: inherit; font-size: 13px; color: #fff; font-weight: 700; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; box-shadow: 0 4px 0 rgba(0,0,0,.2); }
.mini-box::before { content: ''; position: absolute; left: 44%; width: 12%; top: 0; bottom: 0; background: rgba(255,255,255,.65); }
.mini-box::after { content: ''; position: absolute; top: 40%; height: 12%; left: 0; right: 0; background: rgba(255,255,255,.65); }
.mini-box span { position: relative; z-index: 1; background: rgba(60, 25, 5, .55); padding: 3px 10px; border-radius: 999px; }
.mini-box.special { align-items: center; padding-bottom: 0; }
.mini-box.used { opacity: .35; cursor: default; }
.mini-box.special { grid-column: 1 / -1; aspect-ratio: auto; height: 110px; background: linear-gradient(135deg, #f5c542, #d4891e); font-size: 17px; animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 22px #ffd56b, 0 4px 0 rgba(0,0,0,.2); } }
.box-stage { text-align: center; padding: 10px 0; }
.big-box { position: relative; width: 170px; height: 150px; margin: 20px auto 18px; border-radius: 14px; overflow: hidden; }
.wrap-paper { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, var(--c1) 0 14px, var(--c2) 14px 28px); transition: clip-path .35s ease; }
.ribbon { position: absolute; inset: 0; background: linear-gradient(90deg, transparent 43%, #fff6 43% 57%, transparent 57%), linear-gradient(transparent 43%, #fff6 43% 57%, transparent 57%); pointer-events: none; }
.tag { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #fff7e8; color: #8a2d1f; font-size: 13px; padding: 3px 8px; border-radius: 6px; font-weight: 700; white-space: nowrap; }
.big-box.shake { animation: shake .5s ease; }
@keyframes shake { 15% { transform: rotate(-9deg) translateX(-6px); } 35% { transform: rotate(8deg) translateX(6px); } 55% { transform: rotate(-6deg); } 75% { transform: rotate(4deg); } }
.box-actions { display: flex; gap: 12px; justify-content: center; }
.box-tip { margin-top: 10px; font-size: 14px; color: #8a6a4a; min-height: 20px; }
.scrap { position: fixed; width: 18px; height: 14px; z-index: 40; pointer-events: none; border-radius: 3px; }
.reveal { text-align: center; padding: 10px 4px; animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.reveal .big-emoji { font-size: 84px; filter: drop-shadow(0 0 18px #ffd56b); }
.reveal h3 { margin: 6px 0; color: #8a2d1f; }
.reveal .gift-text { text-align: left; white-space: pre-wrap; line-height: 1.8; font-size: 16px; background: #fff; border-radius: 12px; padding: 14px; margin: 10px 0; box-shadow: 0 2px 0 #ead6b4; }
.reveal img { max-width: 100%; border-radius: 12px; margin: 8px 0; }
.reveal .card { background: #b8322f; color: #fff3d6; border-radius: 12px; padding: 14px; margin: 10px 0; white-space: pre-wrap; line-height: 1.8; }
.reveal .btns { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

.slot-title { font-weight: 700; color: #8a2d1f; margin: 12px 0 6px; }
.slot-row { display: flex; gap: 8px; flex-wrap: wrap; }
.item { border: 2px solid #ead6b4; background: #fff; border-radius: 12px; padding: 6px 10px; cursor: pointer; font-family: inherit; font-size: 14px; }
.item.on { border-color: #f5a623; background: #fff1cc; }
.empty-note { color: #8a6a4a; font-size: 14px; }

/* ---------- 聊天 ---------- */
#chat { position: fixed; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); z-index: 15; width: min(94vw, 360px); height: min(60vh, 460px); background: #fff7e8; border-radius: 18px; display: flex; flex-direction: column; box-shadow: 0 10px 30px rgba(0,0,0,.4); border: 3px solid #b8322f; overflow: hidden; }
.chat-head { background: #b8322f; color: #fff3d6; padding: 10px 14px; font-weight: 700; position: relative; }
.chat-head .close { color: #fff3d6; top: 4px; }
.chat-log { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 14px; line-height: 1.6; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.msg.me { align-self: flex-end; background: #ffd56b; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: #fff; border-bottom-left-radius: 4px; box-shadow: 0 1px 0 #ead6b4; }
.msg.typing { color: #a08a6a; }
.chat-input { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #ead6b4; }
.chat-input input { flex: 1; border: 2px solid #ead6b4; border-radius: 999px; padding: 8px 12px; font-size: 16px; font-family: inherit; outline: none; min-width: 0; }
.chat-input .btn { padding: 8px 14px; font-size: 15px; }

/* ---------- 第二期：通用房间 ---------- */
.room-card.wide { width: min(96vw, 600px); }
.note { font-size: 12px; color: #a08a6a; }
.center { text-align: center; }
.btn.sm { padding: 4px 10px; font-size: 13px; margin-left: 6px; }
.chat-log.in-room { height: 220px; background: #fbf4e6; border-radius: 12px; margin-top: 8px; }
.chat-log.in-room.tall { height: 320px; }
.chat-log.in-room.short { height: 120px; }
.msg b { color: #8a2d1f; font-size: 13px; }
.tabs { display: flex; gap: 6px; justify-content: center; margin: 10px 0; flex-wrap: wrap; }
.tabs button { border: 2px solid #ead6b4; background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-family: inherit; font-size: 14px; position: relative; }
.tabs button.on { background: #b8322f; color: #fff3d6; border-color: #b8322f; }
.dot { position: absolute; top: -2px; right: -2px; width: 10px; height: 10px; border-radius: 50%; background: #ff3b30; }

/* 圣诞老人 */
.scene { position: relative; height: 130px; border-radius: 14px; background: linear-gradient(#5a2f1f, #3a1d12); overflow: hidden; display: flex; align-items: flex-end; justify-content: center; gap: 30px; padding-bottom: 10px; }
.fireplace { font-size: 44px; animation: flicker 1.2s ease-in-out infinite; filter: drop-shadow(0 0 16px #ff9a3c); }
.fireplace.big { font-size: 56px; }
@keyframes flicker { 50% { transform: scale(1.08) translateY(-2px); } }
.santa { font-size: 64px; }
.cocoa { position: absolute; left: 18px; bottom: 12px; font-size: 32px; background: none; border: 0; cursor: pointer; }
.cocoa.sip { animation: sip .8s ease; }
@keyframes sip { 40% { transform: rotate(-30deg) translateY(-8px); } }
.santa-say { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 82%; background: #fff7e8; border-radius: 12px; padding: 8px 12px; font-size: 14px; line-height: 1.6; text-align: center; }
.wish-paper { position: relative; background: #fffaf0; border-radius: 8px; padding: 16px; box-shadow: 0 3px 10px rgba(0,0,0,.15); background-image: repeating-linear-gradient(#fffaf0 0 29px, #f0e2c8 29px 30px); transition: transform .7s ease, opacity .7s ease; }
.wish-paper.fold { transform: scale(.2) translateY(200px) rotate(-12deg); opacity: 0; }
.wish-paper textarea { width: 100%; min-height: 130px; border: 0; background: transparent; font-size: 16px; line-height: 30px; font-family: inherit; resize: vertical; outline: none; }
.wp-to { color: #8a2d1f; font-weight: 700; }
.wp-from { text-align: right; color: #8a2d1f; }
.wp-stamp { position: absolute; top: 10px; right: 12px; font-size: 30px; border: 2px dashed #b8322f; border-radius: 4px; padding: 0 4px; background: #fff; }
.stamps { margin: 10px 0 4px; font-size: 14px; }
.stamps button { font-size: 22px; border: 2px solid transparent; background: none; border-radius: 8px; cursor: pointer; }
.stamps button.on { border-color: #f5a623; background: #fff1cc; }
.share { display: block; font-size: 14px; margin: 6px 0; }
#starFly { position: fixed; left: 50%; bottom: 20%; z-index: 50; font-size: 46px; pointer-events: none; filter: drop-shadow(0 0 20px #ffd56b); animation: star 2s ease-in forwards; }
@keyframes star { 0% { transform: translate(-50%, 0) scale(.6); opacity: 0; } 15% { opacity: 1; } 100% { transform: translate(40vw, -80vh) scale(.2) rotate(360deg); opacity: 0; } }
.letter-item { background: #fff; border-radius: 12px; padding: 12px; margin: 10px 0; box-shadow: 0 2px 0 #ead6b4; }
.li-head { font-size: 13px; color: #8a6a4a; }
.li-wish { margin: 6px 0; color: #6b5a4a; white-space: pre-wrap; font-size: 14px; border-left: 3px solid #ead6b4; padding-left: 8px; }
.li-reply { white-space: pre-wrap; line-height: 1.8; background: #fffaf0; border-radius: 10px; padding: 12px; border: 2px solid #f0d8a8; font-size: 15px; }
.li-wait { color: #a08a6a; font-size: 14px; }

/* 树洞 / 工坊 */
.hollow-write { display: flex; gap: 8px; align-items: stretch; margin: 8px 0; }
.hollow-write textarea, .idea-input { flex: 1; border: 2px solid #ead6b4; border-radius: 12px; padding: 8px; font-size: 15px; font-family: inherit; min-height: 44px; outline: none; }
.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 10px; }
.tree-note { border-radius: 4px; padding: 12px 10px 8px; box-shadow: 0 3px 8px rgba(0,0,0,.12); position: relative; }
.tree-note::before { content: '📌'; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); font-size: 16px; }
.pn-text { white-space: pre-wrap; line-height: 1.6; font-size: 15px; }
.pn-meta { font-size: 11px; color: #a08a6a; margin-top: 4px; }
.pn-reply { font-size: 13px; color: #6b5a4a; margin-top: 4px; }
.pn-form { display: flex; gap: 4px; margin-top: 6px; }
.pn-form input { flex: 1; min-width: 0; border: 1px solid rgba(0,0,0,.12); border-radius: 8px; padding: 4px 6px; font-size: 13px; background: rgba(255,255,255,.6); }
.pn-form .btn { padding: 3px 10px; font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { border: 1px dashed #d9b98a; background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 13px; cursor: pointer; font-family: inherit; }
.idea { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 10px 12px; margin: 8px 0; box-shadow: 0 2px 0 #ead6b4; }
.idea-main { flex: 1; }
.like { border: 2px solid #ead6b4; background: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; font-family: inherit; color: #b8322f; }
.like.on { background: #ffe1e1; border-color: #ff8a8a; }
.status { border-radius: 6px; padding: 1px 6px; margin-left: 4px; }
.s-got { background: #e2f4e6; } .s-doing { background: #fff1cc; } .s-done { background: #ffe1f0; }

/* 壁炉 */
.fire-scene { height: 110px; }
.seats span { font-size: 30px; margin: 0 4px; }
.people { margin: 8px 0; }
.person { padding: 6px 0; border-bottom: 1px dashed #ead6b4; font-size: 15px; }
.person .on { color: #2f9e6b; } .person .off { color: #c9b9a0; }
.red { color: #ff3b30; font-size: 12px; }
.quick { display: flex; gap: 6px; margin-top: 6px; }
.quick button { font-size: 22px; background: #fff; border: 2px solid #ead6b4; border-radius: 10px; cursor: pointer; padding: 2px 8px; }
#inviteBox { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 40; background: #fff7e8; border: 3px solid #f5a623; border-radius: 16px; padding: 12px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.35); font-size: 15px; text-align: center; max-width: 90vw; }
#inviteBox .row { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }

/* 木屋解谜 */
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
.choice-btn { background: #fff; border: 2px solid #ead6b4; border-radius: 14px; padding: 14px 10px; cursor: pointer; font-family: inherit; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #3a2a1a; }
.choice-btn span { font-size: 34px; } .choice-btn small { color: #8a6a4a; font-size: 12px; }
.choice-btn:hover { border-color: #f5a623; }
.obj-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.obj { background: #fff; border: 2px solid #ead6b4; border-radius: 14px; padding: 10px 4px; cursor: pointer; font-family: inherit; display: flex; flex-direction: column; align-items: center; font-size: 14px; color: #3a2a1a; }
.obj span { font-size: 34px; }
.obj.far { opacity: .35; cursor: default; }
.obj small { font-size: 11px; color: #8a6a4a; }
.clue { background: #3a2a1a; color: #ffe9b8; border-radius: 12px; padding: 12px; margin: 12px 0; line-height: 1.7; min-height: 52px; font-size: 15px; }
.lock { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.lock input { width: 110px; font-size: 26px; letter-spacing: 8px; text-align: center; border: 3px solid #8a4b1f; border-radius: 10px; padding: 4px; font-family: monospace; }
.walkie { margin-top: 10px; }

/* 雪球大战 */
#arenaHud { position: fixed; inset: auto 0 0 0; z-index: 12; pointer-events: none; height: 0; }
.hearts { position: fixed; left: 12px; bottom: calc(18px + env(safe-area-inset-bottom)); font-size: 22px; background: rgba(255,247,232,.9); border-radius: 999px; padding: 4px 12px; }
.power { position: fixed; left: 12px; bottom: calc(62px + env(safe-area-inset-bottom)); background: rgba(255,247,232,.9); border-radius: 999px; padding: 4px 12px; font-size: 16px; }
.throw { pointer-events: auto; position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 92px; height: 92px; border-radius: 50%; border: 4px solid #fff; background: radial-gradient(#8fd3ff, #3d7fd9); color: #fff; font-size: 34px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.35); cursor: pointer; font-family: inherit; touch-action: manipulation; }
.throw span { font-size: 12px; font-weight: 700; }
.throw:active { transform: scale(.92); }
