/* ============================================================
 * 接毛孩子回家 · 拼豆像素风 v3
 * 要素：深色描边 / 硬偏移阴影 / 方角 / 拼豆圆点纹理 / 像素贴图
 * ============================================================ */
:root {
  --bg: #f3ead0;
  --card: #fffdf4;
  --ink: #4a3b2a;
  --line: #4a3b2a;
  --ink2: #8a7a60;
  --grass1: #c9e8b4;
  --grass2: #bee1a6;
  --accent: #ffd23e;
  --accent-d: #e8a92e;
  --pink: #ff9eb5;
  --blue: #7cc4e8;
  --green: #7fd08a;
  --me: #b9ef8a;
  --lock: #f2b840;
  --shadow: 4px 4px 0 rgba(74, 59, 42, .22);
  --shadow-sm: 3px 3px 0 rgba(74, 59, 42, .2);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background-color: var(--bg);
  /* 拼豆底板：圆点阵列 */
  background-image: radial-gradient(circle, rgba(74, 59, 42, .09) 1.6px, transparent 2.2px);
  background-size: 16px 16px;
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  image-rendering: pixelated;
}
#app { min-height: 100vh; }

button {
  font: inherit; font-weight: bold; cursor: pointer;
  border: 3px solid var(--line); border-radius: 4px;
  background: #fff; color: var(--ink); padding: 8px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .06s ease, box-shadow .06s ease;
}
button:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 rgba(74, 59, 42, .2); }
button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(74, 59, 42, .2); }
button.primary { background: var(--accent); color: #6b4a10; }
button.ghost { background: #f4ecd8; }
button.disabled { opacity: .45; cursor: default; background: #efe6d0; color: var(--ink2); }
button.disabled:hover, button.disabled:active { transform: none; box-shadow: var(--shadow-sm); }

/* 图片按钮：不继承普通按钮的位移与硬阴影 */
button.art-photo {
  position: relative; display: block; width: 100%; max-width: 320px; aspect-ratio: 4 / 3;
  padding: 0; border: 2px solid var(--line); border-radius: 4px;
  background: #e5f1d8; overflow: hidden; line-height: 0;
  transform: none; box-shadow: none; transition: border-color .12s ease;
}
button.art-photo:hover, button.art-photo:active {
  transform: none; box-shadow: none; border-color: var(--accent-d);
}
button.art-photo:focus-visible, button.media-close:focus-visible {
  outline: 3px solid #276b9a; outline-offset: 3px;
}
.art-photo .pixel-image {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%; min-height: 0;
  object-fit: cover; image-rendering: pixelated;
}
button.moment-photo { max-width: 360px; }
button.chat-photo { max-width: 280px; margin: 4px 0; }
button.sticker-photo { max-width: 160px; margin: 4px 0; }
button.award-photo { width: 96px; max-width: 40%; aspect-ratio: 1; flex: 0 0 auto; }
.bubble.has-media { width: 304px; }
.bubble.sticker-bubble { width: 184px; }
.art-photo .pixel-image[hidden] { display: none; }
.image-fallback { display: block; padding: 12px; font-size: 12px; line-height: 1.6; }
.photo:focus-visible { outline: 3px solid #276b9a; outline-offset: 3px; }

/* 像素贴图容器 */
.sprite { display: inline-block; line-height: 0; image-rendering: pixelated; }
.sprite svg { display: block; }

/* ---------------- 页面外壳与开屏 ---------------- */
.shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.intro-shell { flex-direction: column; gap: 14px; }
.intro-mark { line-height: 0; animation: bob 3.2s steps(4) infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.title-card {
  position: relative; text-align: center;
  width: min(560px, 94vw); padding: 30px 32px 24px;
  background: var(--card); border: 3px solid var(--line); border-radius: 6px;
  box-shadow: var(--shadow);
}
.title-paw { margin-bottom: 6px; }
.title-card h1 {
  font-size: 34px; letter-spacing: 4px; margin-bottom: 4px;
  text-shadow: 3px 3px 0 rgba(74, 59, 42, .18);
}
.title-card .sub { color: var(--ink2); font-size: 13px; }
.title-card .opening {
  line-height: 1.9; margin: 14px 0 16px;
  background: #f7efdb; border: 2px solid var(--line); border-radius: 4px;
  padding: 14px 20px; box-shadow: inset 3px 3px 0 rgba(74, 59, 42, .07);
}
.title-card .row { display: flex; gap: 12px; justify-content: center; }
.title-card .footer { margin-top: 14px; font-size: 10.5px; color: var(--ink2); line-height: 1.6; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(72, 58, 36, .5); z-index: 60;
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: var(--card); border: 3px solid var(--line); border-radius: 6px;
  width: min(520px, 92vw); max-height: 84vh; overflow: auto; padding: 18px 20px;
  box-shadow: 6px 6px 0 rgba(30, 22, 12, .35);
}
.modal h2 { text-align: center; margin-bottom: 12px; }
.notice-sec {
  margin-bottom: 12px; line-height: 1.75; font-size: 13.5px;
  background: #f7efdb; border: 2px solid #d8c9a8; border-radius: 4px; padding: 10px 12px;
}
.notice-sec h4 { color: var(--ink2); font-size: 12.5px; margin-bottom: 4px; }
.notice-sec .lines { white-space: pre-line; }
.modal .close { display: block; margin: 6px auto 0; }

/* 图片预览置于普通弹窗与结局层之上，关闭按钮不随大图滚走 */
.modal-mask.media-mask { z-index: 100; padding: 16px; }
.media-viewer {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: fit-content; max-width: 100%; min-width: 0;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  padding: 12px; background: var(--card); border: 3px solid var(--line);
  border-radius: 6px; box-shadow: var(--shadow);
}
button.media-close {
  align-self: flex-end; flex: none; padding: 5px 12px;
  transform: none; box-shadow: none;
}
button.media-close:hover, button.media-close:active { transform: none; box-shadow: none; }
.media-full {
  display: block; min-width: 0; min-height: 0; flex: 1 1 auto;
  max-width: min(1080px, 100%); max-height: calc(100vh - 180px);
  max-height: calc(100dvh - 180px); object-fit: contain;
  background: #e5f1d8; image-rendering: pixelated;
}
.media-caption {
  flex: 0 1 auto; min-height: 0; max-width: 100%; max-height: 20vh;
  overflow: auto; overflow-wrap: anywhere; text-align: center;
  color: var(--ink2); font-size: 13px; line-height: 1.6;
}

/* ---------------- 游戏窗口 ---------------- */
.game-window {
  width: min(1280px, 100%); height: min(94vh, 900px);
  background: var(--card); border: 3px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.gw-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 14px;
  border-bottom: 3px solid var(--line); background: #f7efdb; flex: none;
  background-image: radial-gradient(circle, rgba(74, 59, 42, .07) 1.4px, transparent 2px);
  background-size: 14px 14px;
}
.gw-title { font-weight: bold; font-size: 15px; letter-spacing: 1px; }
.spacer { flex: 1; }
.gw-body { flex: 1; display: flex; min-height: 0; gap: 14px; }
.left { flex: 1 1 auto; display: flex; flex-direction: column; padding: 12px; min-width: 0; }
.freemode-tip { font-size: 11.5px; color: var(--ink2); }
.bulb { background: var(--accent); font-size: 13px; }
.notice-btn { font-size: 12px; padding: 5px 12px; background: #fff; box-shadow: 2px 2px 0 rgba(74,59,42,.2); }

/* ---------------- 拼豆地图 ---------------- */
.map-viewport {
  flex: 1; min-width: 0; min-height: 380px; overflow: auto; display: flex;
  padding: 0 4px 4px 0;
}
.map {
  position: relative; flex: 1 0 600px; min-width: 600px; min-height: 540px;
  border-radius: 6px; overflow: hidden;
  border: 3px solid var(--line); box-shadow: var(--shadow-sm);
  background: repeating-conic-gradient(var(--grass1) 0 25%, var(--grass2) 0 50%) 0 0 / 26px 26px;
}
.map-deco { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.map-deco .deco {
  position: absolute; transform: translate(-50%, -50%);
  filter: drop-shadow(2px 2px 0 rgba(74, 59, 42, .18));
}
.paths { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.paths path {
  stroke: #a8c48c; stroke-width: 2.6; fill: none;
  stroke-dasharray: 2 7; stroke-linecap: butt; opacity: .9;
}

/* 地标：拼豆小图标＋简名 */
.spot {
  position: absolute; transform: translate(-50%, -50%); z-index: 2;
  background: var(--card); border: 2px solid var(--line); border-radius: 4px;
  padding: 3px 10px 3px 5px; font-size: 12px; font-weight: bold; color: var(--ink);
  box-shadow: var(--shadow-sm); white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.spot-ico { line-height: 0; }

/* 日托班 */
.daycare-home {
  position: absolute; transform: translate(-50%, -50%); z-index: 3;
  text-align: center; filter: drop-shadow(3px 3px 0 rgba(74, 59, 42, .22));
}
.dh-label b {
  display: inline-block; margin-top: 4px; font-size: 12.5px;
  background: var(--card); border: 2px solid var(--line); border-radius: 4px;
  padding: 2px 10px; box-shadow: var(--shadow-sm);
}

/* 家庭小屋 */
.fam {
  position: absolute; width: 152px; transform: translate(-50%, -50%); z-index: 3;
  background: var(--card); border: 3px solid var(--line); border-radius: 5px;
  overflow: hidden; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .1s ease;
}
.fam:not(.locked):hover { transform: translate(-50%, -53%); }
.h-roof { background: rgba(74, 59, 42, .08); padding: 2px 0 0; text-align: center; }
.h-roof-sprite { line-height: 0; }
.h-plate {
  display: flex; align-items: baseline; gap: 5px; padding: 3px 9px 0;
  font-size: 13.5px; background: var(--card);
}
.h-plate b { font-weight: bold; }
.h-plate i { color: #c2b394; font-size: 10px; font-style: normal; }
.fam .dropzone {
  min-height: 30px; display: flex; flex-wrap: wrap; gap: 4px;
  border: 2px dashed #c4b494; border-radius: 4px; padding: 4px 6px; margin: 5px 8px 8px;
  align-items: center; background: #fbf7ea;
}
.fam.locked { box-shadow: 0 0 0 3px var(--lock), var(--shadow-sm); cursor: default; }
.fam.locked .dropzone { border-style: solid; border-color: #d9b878; background: #fff3cf; }
.fam.locked .h-plate::after { content: "✔ 已接到"; color: #a87f14; font-size: 10px; margin-left: auto; }
.fam .dz-hint { color: #c9ba9c; font-size: 11px; }
.fam .chip {
  background: #fff; border: 2px solid var(--line); border-radius: 3px;
  padding: 1px 8px; font-size: 12px; font-weight: bold; cursor: pointer; user-select: none;
  box-shadow: 2px 2px 0 rgba(74, 59, 42, .16);
}
.fam.shake, .photo.shake { animation: shake .3s; }
@keyframes shake {
  25% { transform: translate(-50%, -50%) translateX(-4px); }
  75% { transform: translate(-50%, -50%) translateX(4px); }
}
.photo.shake { animation: shake2 .3s; }
@keyframes shake2 { 25% { transform: translateX(-4px);} 75% { transform: translateX(4px);} }

/* 名牌托盘 */
.tray {
  margin-top: 10px; background: var(--card); border: 3px solid var(--line);
  border-radius: 6px; padding: 9px 12px; display: flex; flex-wrap: wrap; gap: 7px;
  min-height: 54px; align-items: center; box-shadow: var(--shadow-sm);
}
.tray .label { font-size: 12px; color: var(--ink2); margin-right: 4px; font-weight: bold; }
.tag {
  background: #fff; border: 2px solid var(--line); border-radius: 4px;
  padding: 4px 15px; font-size: 15px; font-weight: bold; cursor: grab; user-select: none;
  box-shadow: 2px 2px 0 rgba(74, 59, 42, .18);
  transition: transform .08s ease;
}
.tag:hover { transform: translate(-1px, -2px); }
.tag.selected { background: var(--accent); box-shadow: 2px 2px 0 rgba(74, 59, 42, .35); }
body.has-selected .fam:not(.locked) { outline: 3px dashed rgba(232, 169, 46, .8); outline-offset: 2px; }

/* ---------------- 右侧信息框 ---------------- */
.right {
  flex: 0 0 47%; min-width: 300px;
  background: var(--card); border: 3px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; overflow: hidden;
  margin: 12px 12px 12px 0;
}
.tabs { display: flex; flex: none; border-bottom: 3px solid var(--line); background: #f7efdb; }
.tabs .tab {
  flex: 1; text-align: center; padding: 10px 0; cursor: pointer;
  color: var(--ink2); font-size: 14px; font-weight: bold;
  border-right: 2px solid rgba(74, 59, 42, .15);
}
.tabs .tab:last-child { border-right: none; }
.tabs .tab.on {
  color: var(--ink); background: var(--card);
  box-shadow: inset 0 -4px 0 var(--accent);
}
.panel { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: 12px 14px; }

.chat-head {
  text-align: center; color: var(--ink2); font-size: 12px; padding: 6px 0 10px;
  background: #f7efdb; border: 2px solid #d8c9a8; border-radius: 4px; margin-bottom: 10px;
}
.date-div { text-align: center; margin: 14px 0 8px; }
.date-div span {
  background: #efe4c4; color: var(--ink2); font-size: 11px;
  border: 2px solid #d8c9a8; border-radius: 3px; padding: 2px 10px;
}
.bubble-row { display: flex; gap: 8px; margin: 8px 0; align-items: flex-start; }
.bubble-row.me { flex-direction: row-reverse; }
.avatar {
  width: 34px; height: 34px; border-radius: 4px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: bold;
  border: 2px solid var(--line); box-shadow: 2px 2px 0 rgba(74, 59, 42, .18);
}
.bubble-row.me .avatar { background: #c9b695; }
.avatar.me-av { font-size: 9px; font-weight: bold; letter-spacing: 0; }
.bubble {
  background: #fff; border: 2px solid var(--line); border-radius: 4px 4px 4px 0;
  padding: 7px 11px; min-width: 0; max-width: 74%; line-height: 1.6; font-size: 13.5px;
  overflow-wrap: anywhere;
  box-shadow: 2px 2px 0 rgba(74, 59, 42, .12);
}
.bubble-row.me .bubble { background: var(--me); border-radius: 4px 4px 0 4px; }
.bubble .who { font-size: 11px; color: var(--ink2); margin-bottom: 2px; }

/* 私聊（联系人列表） */
.contact-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-bottom: 2px solid #eee0c2; cursor: pointer;
}
.contact-row:hover { background: #f7efdb; }
.contact-mid { flex: 1; min-width: 0; }
.c-name { font-weight: bold; font-size: 14px; }
.c-preview { color: var(--ink2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-time { color: #b3a68c; font-size: 11px; }
.pm-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: #f7efdb; border-bottom: 2px solid #d8c9a8;
  position: sticky; top: 0; z-index: 2;
}
.back-btn { padding: 4px 14px; font-size: 13px; }

/* 朋友圈 */
.moments-cover {
  height: 104px; border-radius: 4px; margin-bottom: 10px;
  border: 3px solid var(--line);
  background-color: #ffd9a8;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, .5) 2px, transparent 2.6px),
    radial-gradient(circle, rgba(74, 59, 42, .08) 1.6px, transparent 2.2px);
  background-size: 18px 18px, 9px 9px;
  background-position: 0 0, 9px 9px;
  display: flex; align-items: center; justify-content: center;
}
.moments-cover .sprite { filter: drop-shadow(2px 2px 0 rgba(74, 59, 42, .25)); }
.moment {
  background: #fff; border: 2px solid var(--line); border-radius: 5px;
  padding: 10px 12px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
}
.moment .m-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.moment .m-head .nm { font-weight: bold; font-size: 13px; color: #5a7fb0; }
.moment .m-head small { color: var(--ink2); }
.moment .m-text { line-height: 1.75; }
.moment .m-img {
  min-width: 0; margin: 8px 0;
}
.moment .m-comments {
  background: #f2ecd9; border: 1.5px solid #ddd0ae; border-radius: 3px;
  padding: 6px 9px; font-size: 12.5px; line-height: 1.7;
}
.moment .m-comments b { color: #5a7fb0; font-weight: 600; }
.moment.focus { outline: 3px solid var(--accent-d); outline-offset: 2px; }

/* 板报 */
.board-title { text-align: center; font-weight: bold; margin: 4px 0 2px; }
.board-note { text-align: center; color: var(--ink2); font-size: 11.5px; margin-bottom: 10px; }
.award {
  display: flex; gap: 10px; align-items: center;
  background: #fff3cf; border: 2px solid #d9b878; border-radius: 4px;
  padding: 8px 10px; margin-bottom: 8px;
  box-shadow: 2px 2px 0 rgba(217, 184, 120, .5);
}
.award .medal { font-size: 20px; }
.award-copy { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.6; }
.award .a-dog { font-weight: bold; }
.award .a-prize { font-size: 13px; font-weight: bold; color: #8a6d1f; }
.award .a-text { font-size: 12.5px; color: var(--ink2); }
.breedchip {
  display: inline-block; width: 14px; height: 14px; border-radius: 3px;
  border: 2px solid var(--line); vertical-align: -3px; margin-right: 5px;
}
.note-line {
  background: #fdf3d7; border: 2px dashed #c9a44e; border-radius: 4px;
  padding: 6px 10px; font-size: 12.5px; margin-bottom: 6px; color: #7a5c14;
}
.wall-hint { color: var(--ink2); font-size: 12.5px; margin: 12px 0 8px; text-align: center; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; }
.photo {
  background: #fff; border: 2px solid var(--line); border-radius: 4px;
  padding: 6px 4px 4px; text-align: center; cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.photo .pic {
  aspect-ratio: 1; border-radius: 3px; margin-bottom: 4px; position: relative;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: #e5f1d8;
  color: rgba(255, 255, 255, .95); font-size: 20px; font-weight: bold;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, .2);
  border: 2px solid rgba(74, 59, 42, .35);
}
.photo .pic .pet-image {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  object-fit: contain; background: #e5f1d8; image-rendering: pixelated;
}
.photo .pic::after { content: none; display: none; }
.photo .pname {
  font-size: 11px; color: var(--ink2); background: #f2ecd9; border-radius: 3px;
  border: 1.5px solid #ddd0ae;
  padding: 1px 5px; display: inline-block; min-width: 48px;
}
.photo.paired .pname { background: var(--accent); color: #6b4a10; font-weight: bold; border-color: var(--accent-d); }
.photo.bark { animation: barkjump .45s steps(3); }
@keyframes barkjump {
  40% { transform: translateY(-7px); }
  80% { transform: translateY(0); }
}
/* 入学照彩蛋专用名牌：与左侧接送托盘的 .tag 完全独立 */
button.photo-target {
  width: 100%; padding: 0; box-shadow: none; transform: none;
}
button.photo-target:hover, button.photo-target:active { transform: none; box-shadow: none; }
button.photo-target:focus-visible, .photo-tag:focus-visible, .photo-return:focus-visible {
  outline: 3px solid #276b9a; outline-offset: 2px;
}
.photos.has-photo-selection .photo-target { border-color: var(--accent-d); }
.photo-label { display: flex; align-items: center; justify-content: center; gap: 3px; }
.paired-photo-tag { cursor: grab; }
button.photo-return {
  flex: 0 0 20px; padding: 0; width: 20px; height: 22px;
  border: 1px solid #c9b695; background: #f7efdb; font-size: 15px;
  line-height: 18px; box-shadow: none; transform: none;
}
button.photo-return:hover, button.photo-return:active { transform: none; box-shadow: none; background: #f7dfa2; }
.photo-tray {
  margin-top: 12px; padding: 10px; background: #f7efdb;
  border: 2px dashed #c9a44e; border-radius: 5px;
}
.photo-tray-title { font-weight: bold; font-size: 13px; }
.photo-tray-note, .photo-tag-status { font-size: 11.5px; line-height: 1.7; color: var(--ink2); }
.photo-tray-note { margin: 4px 0 8px; }
.photo-tag-status { margin-top: 8px; min-height: 20px; }
.photo-tray-tags { display: flex; flex-wrap: wrap; gap: 6px; }
button.photo-tag {
  padding: 5px 10px; border: 2px solid #b29a72; border-radius: 4px;
  font-size: 12px; background: #fffdf4; box-shadow: 1px 1px #ddcfb4; cursor: grab;
}
button.photo-tag:hover, button.photo-tag:active { transform: none; box-shadow: 1px 1px #ddcfb4; }
button.photo-tag.selected { background: var(--accent); border-color: var(--accent-d); }
.wall-reward {
  margin-top: 12px; text-align: center;
  background: #fff3cf; border: 3px solid var(--accent-d); border-radius: 5px;
  padding: 10px; font-weight: bold; color: #8a6d1f; box-shadow: var(--shadow-sm);
}

/* ---------------- 个人页 ---------------- */
.avatar.clickable { cursor: pointer; }
.avatar.clickable:hover { filter: brightness(1.1); }
.profile-card { text-align: center; width: min(360px, 92vw); }
.profile-avatar {
  width: 72px; height: 72px; border-radius: 6px; margin: 6px auto 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 30px; font-weight: bold;
  border: 3px solid var(--line); box-shadow: var(--shadow);
}
.profile-sig { color: var(--ink2); margin: 4px 0 14px; font-size: 13px; }
.profile-btns { display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }

/* ---------------- 提示气泡 / 引导 / 飘字 ---------------- */
.hintbox {
  position: fixed; top: 54px; left: 50%; transform: translateX(-50%);
  background: #fffdf0; border: 3px solid var(--line); border-radius: 6px;
  padding: 10px 16px; max-width: min(480px, 90vw); z-index: 50;
  box-shadow: var(--shadow); line-height: 1.7; font-size: 13.5px;
  animation: hintin .2s steps(3);
}
@keyframes hintin { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } }
.hintbox .lv { color: #c19a2e; font-size: 11px; margin-right: 6px; }
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; border: 3px solid var(--line); border-radius: 5px;
  padding: 8px 20px; font-size: 13px; z-index: 50; max-width: 90vw; text-align: center;
  box-shadow: var(--shadow);
}
.floatq {
  position: absolute; z-index: 20;
  background: #fff; border: 2px solid var(--line); border-radius: 4px;
  padding: 5px 12px; font-size: 13px; font-weight: bold; white-space: nowrap;
  box-shadow: var(--shadow-sm); animation: fq 3s steps(9) forwards;
  pointer-events: none;
}
@keyframes fq {
  0% { opacity: 0; transform: translateY(4px); }
  7% { opacity: 1; transform: none; }
  88% { opacity: 1; }
  100% { opacity: 0; }
}
.floatq.finale {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%);
  white-space: normal; max-width: 420px; text-align: center;
  font-size: 16px; font-weight: bold; padding: 14px 26px;
  background: var(--accent); border-radius: 6px;
  animation: fqfin 2.6s steps(8) forwards;
}
@keyframes fqfin { 0% { opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { opacity: 0; } }

/* ---------------- 结局 ---------------- */
.ending {
  position: fixed; inset: 0; z-index: 70;
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(74, 59, 42, .09) 1.6px, transparent 2.2px);
  background-size: 16px 16px;
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 12px; padding: max(24px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
}
.ending-card {
  --frame-edge: clamp(10px, 2.6vw, 22px);
  --frame-mat: clamp(7px, 1.8vw, 15px);
  --photo-height: clamp(120px, calc(100vh - 240px), 580px);
  --photo-height: clamp(120px, calc(100dvh - 240px), 580px);
  flex: 0 0 auto; width: min(800px, 100%); min-width: 0;
  margin-block: auto; display: flex; flex-direction: column; align-items: center;
  gap: clamp(12px, 2vh, 18px); text-align: center;
  transform-origin: center; animation: ending-pop 450ms ease-out both;
}
.ending-frame {
  position: relative; isolation: isolate; flex: none; margin: 0;
  /* 按完整原图比例限宽，矮视口也留出标题和操作按钮的位置。 */
  width: min(100%, calc(var(--photo-height) * 1.40146 + var(--frame-edge) * 2 + var(--frame-mat) * 2 + 8px));
  padding: calc(var(--frame-edge) + var(--frame-mat));
  border: clamp(2px, .5vw, 4px) solid #79563d; border-radius: 5px;
  background-color: #b98a5e;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 5px, rgba(100, 64, 35, .14) 5px 7px, transparent 7px 13px),
    repeating-linear-gradient(90deg, rgba(255, 230, 184, .16) 0 3px, transparent 3px 11px),
    linear-gradient(135deg, #d5ac79, #b78659 48%, #c3986b);
  box-shadow: inset 2px 2px 0 #ead0a1, inset -3px -3px 0 #926543,
    4px 5px 0 rgba(100, 72, 45, .16), 0 12px 28px rgba(100, 72, 45, .12);
}
.ending-frame::before {
  content: ""; position: absolute; z-index: -1; inset: var(--frame-edge);
  background: #fff8e7; border: 2px solid #99714e;
  box-shadow: 0 0 0 2px #dbb887, inset 2px 3px 0 #e5d7bc, inset -2px -2px 0 #fffdf5;
  pointer-events: none;
}
.ending-frame::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  /* 四角斜拼接暗线，只画在木边上，不覆盖照片和落款。 */
  background:
    linear-gradient(45deg, transparent 47%, #8d6548 48% 52%, transparent 53%) top left,
    linear-gradient(-45deg, transparent 47%, #8d6548 48% 52%, transparent 53%) top right,
    linear-gradient(-45deg, transparent 47%, #8d6548 48% 52%, transparent 53%) bottom left,
    linear-gradient(45deg, transparent 47%, #8d6548 48% 52%, transparent 53%) bottom right;
  background-size: var(--frame-edge) var(--frame-edge); background-repeat: no-repeat;
}
button.art-photo.ending-picture {
  width: 100%; max-width: none; height: auto; aspect-ratio: 1536 / 1096;
  padding: 0; border: 0; border-radius: 0; overflow: visible;
  background: #fff8e7; transform: none; transition: none;
  box-shadow: 0 0 0 1px #c8b596, 1px 2px 3px rgba(74, 59, 42, .2);
}
button.art-photo.ending-picture:hover, button.art-photo.ending-picture:active {
  transform: none; border: 0;
  box-shadow: 0 0 0 1px #c8b596, 1px 2px 3px rgba(74, 59, 42, .2);
}
.ending-picture .pixel-image {
  position: static; inset: auto; display: block; width: 100%; height: auto;
  /* 相框已按视口高度限宽；不要再次钳制img高度，否则窄边框下会改变图框比例。 */
  max-height: none; object-fit: contain; image-rendering: auto;
}
@keyframes ending-pop {
  from { opacity: 0; transform: translateY(16px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.ending .caption {
  max-width: 100%; margin: 0; color: var(--ink2);
  font-size: clamp(13px, 2.4vw, 16px); font-weight: 600; line-height: 1.7;
  overflow-wrap: anywhere;
}
.ending .row {
  display: flex; flex: none; flex-wrap: wrap; justify-content: center;
  gap: 10px 14px; max-width: 100%; padding: 0 4px 5px;
}
.ending .row button { max-width: 100%; white-space: normal; }
@media (prefers-reduced-motion: reduce) {
  .ending-card { animation: none; transform: none; }
}

/* 窄屏上下布局：只让地图视口横向滚动，不压缩房屋坐标 */
@media (max-width: 980px) {
  .shell { padding: 10px; }
  .game-window { height: auto; min-height: 94vh; min-width: 0; max-width: 100%; }
  .gw-body { flex-direction: column; gap: 0; min-width: 0; }
  .gw-title { min-width: 0; overflow-wrap: anywhere; }
  .left { flex: none; width: 100%; }
  .map-viewport { flex: none; height: 544px; max-width: 100%; }
  .right {
    flex: none; width: auto; min-width: 0; min-height: 0;
    height: clamp(600px, 80vh, 720px); margin: 0 12px 12px;
  }
  .freemode-tip { overflow-wrap: anywhere; }
}
@media (max-width: 480px) {
  .shell { padding: 6px; }
  .gw-header { gap: 6px; padding: 8px; }
  .gw-title { font-size: 13px; letter-spacing: 0; }
  .gw-header button { padding: 5px 8px; font-size: 11px; }
  .gw-header .spacer { flex-basis: 100%; height: 0; }
  .left { padding: 8px; }
  .right { margin: 0 8px 8px; }
  .panel { padding: 10px 8px; }
  .tabs .tab { font-size: 12px; }
  .bubble-row { gap: 6px; }
  .bubble { padding: 6px 8px; max-width: calc(100% - 42px); }
  .moment { padding: 8px; }
  .modal-mask.media-mask { padding: 8px; }
  .media-viewer {
    padding: 8px; gap: 8px; max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .media-caption { font-size: 12px; }
}
