[hidden] { display: none !important; }
:root {
  --bg: #f6ecd6;
  --paper: #fff8e8;
  --wood: #8a5a3b;
  --wood-d: #5e3b26;
  --ink: #3a2630;
  --muted: #8b7064;
  --green: #5aa847;
  --green-d: #3f7d32;
  --pink: #ef6b82;
  --gold: #f6c443;
  --r: 6px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg) repeating-linear-gradient(45deg, transparent 0 14px, rgba(138, 90, 59, 0.04) 14px 28px);
}
img.ico { width: 20px; height: 20px; image-rendering: pixelated; vertical-align: -4px; }
.pt { image-rendering: pixelated; border: 3px solid var(--wood-d); border-radius: var(--r); background: #fff; width: 96px; height: 96px; flex: none; }
.pt.sm { width: 64px; height: 64px; }
.pt.big { width: 100%; max-width: 240px; height: auto; aspect-ratio: 1; }
.pt.pop { animation: pop 0.35s ease; }
@keyframes pop { 0% { transform: scale(0.94); } 60% { transform: scale(1.04); } 100% { transform: none; } }

button {
  font: inherit;
  cursor: pointer;
  border: 2px solid var(--green-d);
  background: var(--green);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--r);
  box-shadow: 0 3px 0 var(--green-d);
  font-weight: 600;
  transition: transform 0.06s, filter 0.15s;
  white-space: nowrap;
}
button:hover:not(:disabled) { filter: brightness(1.07); }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--green-d); }
button:disabled { background: #cbbfa8; border-color: #a99a80; box-shadow: 0 3px 0 #a99a80; color: #f4ede0; cursor: not-allowed; }
button.ghost { background: var(--paper); color: var(--wood-d); border-color: var(--wood); box-shadow: 0 3px 0 var(--wood); }
button.danger { background: #d9534f; border-color: #a33a37; box-shadow: 0 3px 0 #a33a37; }
button.mini { padding: 1px 8px; font-size: 12px; box-shadow: 0 2px 0 var(--green-d); }
button.big { width: 100%; padding: 10px; font-size: 16px; }
.icon-btn { background: var(--paper); color: var(--wood-d); border-color: var(--wood); box-shadow: 0 3px 0 var(--wood); position: relative; }
.dot { position: absolute; top: -8px; right: -8px; background: var(--pink); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; padding: 1px 5px; border: 2px solid #fff; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--wood);
  color: #fff8e8;
  border-bottom: 4px solid var(--wood-d);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 1px; text-shadow: 2px 2px 0 var(--wood-d); }
.clock { font-size: 13px; opacity: 0.85; }
.money { display: flex; align-items: center; gap: 6px; background: var(--wood-d); padding: 4px 12px; border-radius: 999px; font-size: 18px; }
.money small { font-size: 12px; opacity: 0.8; }
.top-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.badge { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: #c9b79c; color: var(--ink); }
.badge.live { background: #9be08a; }
.badge.mock { background: #ffe08a; }
.badge.offline { background: #f3b0b0; }

.layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); gap: 18px; padding: 18px 20px 40px; max-width: 1400px; margin: 0 auto; }
.farm-wrap { position: relative; border: 4px solid var(--wood-d); border-radius: 10px; overflow: hidden; box-shadow: 0 6px 0 rgba(94, 59, 38, 0.35); background: #86c55f; }
#farm { display: block; width: 100%; aspect-ratio: 200 / 112; image-rendering: pixelated; cursor: pointer; touch-action: manipulation; }
.buffs { position: absolute; left: 8px; top: 8px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.buff { background: rgba(255, 248, 232, 0.92); border: 2px solid var(--gold); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0; }
.center { text-align: center; }
.res-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.res-bar { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.res { display: flex; align-items: center; gap: 6px; background: var(--paper); border: 2px solid var(--wood); border-radius: var(--r); padding: 6px 10px; }
.res small { color: var(--muted); font-size: 11px; }
.res-row .big { width: auto; padding: 8px 22px; }

.tabs { display: flex; gap: 4px; }
.tabs button { flex: 1; background: #e8d6b4; color: var(--wood-d); border-color: var(--wood); box-shadow: none; border-bottom: none; border-radius: var(--r) var(--r) 0 0; }
.tabs button.on { background: var(--paper); }
.tab-body { background: var(--paper); border: 2px solid var(--wood); border-top: none; border-radius: 0 0 var(--r) var(--r); padding: 12px; display: grid; gap: 10px; max-height: calc(100vh - 150px); overflow: auto; }
.card { display: flex; gap: 12px; align-items: center; background: #fff; border: 2px solid #e6d3b3; border-radius: 8px; padding: 10px; }
.card .info { flex: 1; min-width: 0; display: grid; gap: 4px; }
.card header { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.card h3 { margin: 0; font-size: 16px; }
.card h3 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.tag { font-size: 12px; color: var(--wood); background: #f6ead2; border-radius: 4px; padding: 1px 6px; margin: 0; }
.desc { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.meta, .prod { font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.card.upg { justify-content: space-between; }
.card.locked .pt { filter: saturate(0.6); }
.card.mail.unread { border-color: var(--pink); }
.card.mail p { margin: 0; }
.bar { height: 8px; background: #efe3cc; border-radius: 999px; overflow: hidden; border: 1px solid #d8c3a0; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #fff, #f2e3c4); transition: width 0.25s; }
.hearts { display: inline-flex; gap: 2px; vertical-align: -2px; }
.hearts i { width: 12px; height: 11px; background: #e8d9c4; clip-path: polygon(50% 100%, 0 40%, 0 15%, 20% 0, 50% 20%, 80% 0, 100% 15%, 100% 40%); }
.hearts i.on { background: var(--pink); }
.empty { color: var(--muted); text-align: center; padding: 20px; margin: 0; }

.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(92vw, 420px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; background: var(--ink); color: #fff8e8; padding: 8px 14px; border-radius: 8px; border: 2px solid var(--gold); animation: up 0.25s ease; transition: opacity 0.4s, transform 0.4s; font-size: 14px; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes up { from { opacity: 0; transform: translateY(10px); } }

.dlg { border: 4px solid var(--wood-d); border-radius: 12px; background: var(--paper); color: var(--ink); padding: 20px; width: min(92vw, 440px); box-shadow: 0 10px 0 rgba(58, 38, 48, 0.3); }
.dlg::backdrop { background: rgba(58, 38, 48, 0.5); }
.dlg.wide { width: min(94vw, 560px); }
.dlg h2 { margin: 6px 0 12px; }
.dlg label { display: grid; gap: 4px; font-size: 13px; margin-bottom: 10px; color: var(--wood-d); }
.dlg label.row { display: flex; align-items: center; gap: 8px; }
.dlg input:not([type="checkbox"]), .dlg textarea { font: inherit; padding: 8px 10px; border: 2px solid #d8c3a0; border-radius: var(--r); background: #fff; color: var(--ink); width: 100%; }
.dlg input:focus, .dlg textarea:focus { outline: none; border-color: var(--green); }
.dlg fieldset { border: 2px dashed #d8c3a0; border-radius: 8px; margin: 0 0 12px; padding: 10px 12px; }
.dlg legend { font-weight: 700; padding: 0 6px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.letter { background: #fff; border: 2px solid #e6d3b3; border-radius: 8px; padding: 14px; line-height: 1.8; font-style: italic; margin: 0 0 8px; }
.letter span { display: block; text-align: right; font-size: 12px; color: var(--muted); font-style: normal; }
.dlg ul { padding-left: 20px; line-height: 1.9; }

.dlg.chat { width: min(96vw, 860px); padding: 0; overflow: hidden; }
.chat-grid { display: grid; grid-template-columns: 260px 1fr; min-height: min(80vh, 600px); }
.chat-side { background: #fbf1dc; border-right: 3px solid #e6d3b3; padding: 16px; display: grid; gap: 8px; align-content: start; justify-items: center; text-align: center; }
.chat-side h2 { margin: 0; }
.gifts { display: grid; gap: 6px; justify-items: center; }
.gifts > div { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
details { width: 100%; text-align: left; font-size: 13px; }
summary { cursor: pointer; color: var(--wood-d); font-weight: 600; }
.memory { margin: 6px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.6; max-height: 140px; overflow: auto; }
.chat-main { display: flex; flex-direction: column; padding: 12px 16px; min-width: 0; }
.chat-log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 2px; max-height: 60vh; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; line-height: 1.6; white-space: pre-wrap; animation: up 0.2s ease; }
.msg.him { background: #fff; border: 2px solid #e6d3b3; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: #d9f0c8; border: 2px solid #b4dc98; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.sys { align-self: center; font-size: 12px; color: #a33a37; background: #fde8e8; }
.typing { display: flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 50% { opacity: 0.2; } }
.choices { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 0; }
.chip { background: #fff; color: var(--wood-d); border-color: #d8c3a0; box-shadow: 0 2px 0 #d8c3a0; font-weight: 400; font-size: 13px; padding: 4px 10px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; font: inherit; padding: 9px 12px; border: 2px solid #d8c3a0; border-radius: var(--r); }
.chat-form input:focus { outline: none; border-color: var(--green); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .tab-body { max-height: none; }
  .top { padding: 8px 12px; gap: 8px; }
  .top-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
  .chat-grid { grid-template-columns: 1fr; }
  .chat-side { grid-template-columns: 96px 1fr; justify-items: start; text-align: left; border-right: none; border-bottom: 3px solid #e6d3b3; }
  .chat-side .pt.big { width: 96px; grid-row: span 3; }
  .chat-side .desc, .chat-side details, .gifts { grid-column: 1 / -1; justify-items: start; }
  .pt { width: 72px; height: 72px; }
}

/* ---------- 高清立绘 ---------- */
.pt.hd { image-rendering: auto; object-fit: cover; object-position: 50% 12%; }
.pt.big.hd { aspect-ratio: 3 / 4; max-width: 230px; }
.art-wrap { position: relative; width: 100%; display: grid; justify-items: center; }
.mood { display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 248, 232, 0.94); border: 2px solid var(--wood); border-radius: 999px; padding: 2px 10px 2px 2px; font-size: 12px; font-weight: 600; }
.art-wrap .mood { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); }
.mood-px { width: 28px; height: 28px; image-rendering: pixelated; border-radius: 50%; border: 1px solid var(--wood); }
.msg em { color: var(--muted); font-style: italic; }
.msg.me em { color: #4d7a3a; }
.dlg select, .dlg label a { font: inherit; }
.dlg select { padding: 8px 10px; border: 2px solid #d8c3a0; border-radius: var(--r); background: #fff; color: var(--ink); width: 100%; }
.dlg label a { font-size: 12px; color: var(--green-d); margin-left: 6px; }
.hint.ok { color: var(--green-d); }
.hint.bad { color: #b03a37; }

/* ---------- 顶部视图切换 ---------- */
.views { display: flex; gap: 4px; background: var(--wood-d); padding: 3px; border-radius: 999px; }
.views button { background: transparent; border: none; box-shadow: none; color: #f1e2c8; padding: 4px 16px; border-radius: 999px; }
.views button.on { background: var(--paper); color: var(--wood-d); }

/* ---------- 小屋 ---------- */
.cabin { display: grid; grid-template-columns: 220px minmax(0, 1fr) 320px; gap: 14px; padding: 16px 20px; max-width: 1500px; margin: 0 auto; height: calc(100vh - 64px); }
.cabin-list { display: grid; gap: 6px; align-content: start; overflow: auto; }
.who { display: flex; gap: 10px; align-items: center; text-align: left; background: var(--paper); color: var(--ink); border-color: #e6d3b3; box-shadow: none; font-weight: 400; padding: 6px; white-space: normal; }
.who img { width: 48px; height: 48px; object-fit: cover; object-position: 50% 12%; border-radius: 8px; flex: none; }
.who span { display: grid; min-width: 0; }
.who small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who.on { border-color: var(--wood); background: #fff; box-shadow: 0 3px 0 var(--wood); }
.who .new { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--pink); margin-left: 6px; vertical-align: 2px; }
.cabin-stage { position: relative; border: 4px solid var(--wood-d); border-radius: 12px; overflow: hidden; display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); background: #2e2228; min-height: 0; }
.cabin-bg { position: absolute; inset: -20px; background-size: cover; background-position: center 20%; filter: blur(18px) brightness(0.55) saturate(1.2); }
.cabin-art { position: relative; width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; mask-image: linear-gradient(90deg, #000 70%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 70%, transparent); }
.cabin-chat { position: relative; display: flex; flex-direction: column; padding: 14px; gap: 6px; min-height: 0; background: linear-gradient(90deg, rgba(255, 248, 232, 0.82), rgba(255, 248, 232, 0.94)); }
.cabin-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cabin-head h2 { margin: 0; display: inline; margin-right: 8px; }
.cabin-chat .chat-log { max-height: none; min-height: 0; }
.cabin-side { display: grid; gap: 10px; align-content: start; overflow: auto; }
.cabin-side details { background: var(--paper); border: 2px solid var(--wood); border-radius: 8px; padding: 10px 12px; }
.cabin-side summary { font-size: 15px; }
.diary-list { display: grid; gap: 10px; margin-top: 10px; }
.diary { background: #fffdf6 repeating-linear-gradient(transparent 0 27px, #eadcc2 27px 28px); border: 1px solid #e6d3b3; border-radius: 6px; padding: 8px 12px; box-shadow: 2px 3px 0 rgba(94, 59, 38, 0.15); }
.diary header { font-size: 12px; color: var(--muted); }
.diary p { margin: 4px 0 0; line-height: 28px; white-space: pre-wrap; font-family: "KaiTi", "STKaiti", "Kaiti SC", serif; font-size: 15px; }
.gift-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.profile dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13px; margin: 6px 0 0; }
.profile dt { color: var(--wood); font-weight: 700; }
.profile dd { margin: 0; color: var(--muted); }
.profile p { font-size: 13px; margin: 6px 0; }

/* ---------- 画廊 ---------- */
.gallery { padding: 16px 20px 40px; max-width: 1300px; margin: 0 auto; }
.gallery h2 { margin: 0; }
.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 12px; }
.g-card { padding: 0; background: #fff; border: 3px solid var(--wood-d); box-shadow: 0 5px 0 rgba(94, 59, 38, 0.35); border-radius: 10px; overflow: hidden; display: grid; color: var(--ink); text-align: left; font-weight: 400; }
.g-card img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; transition: transform 0.3s; }
.g-card:hover img { transform: scale(1.04); }
.g-card span { display: grid; padding: 8px 12px; background: var(--paper); position: relative; }
.g-card small { color: var(--muted); }
.g-card.locked img { filter: blur(14px) grayscale(0.7) brightness(0.6); }
.dlg.lb { width: min(96vw, 1100px); padding: 0; overflow: hidden; }
.lb-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.lb-grid > img { width: 100%; height: 100%; max-height: 88vh; object-fit: contain; background: #2e2228; }
.lb-info { padding: 16px 18px; display: grid; gap: 8px; align-content: start; }
.lb-info h2 { display: inline; margin-right: 8px; }
.lb-info textarea { font-size: 12px; font-family: ui-monospace, Consolas, monospace; }
.btn-link { display: inline-flex; align-items: center; padding: 6px 12px; border: 2px solid var(--wood); border-radius: var(--r); color: var(--wood-d); background: var(--paper); box-shadow: 0 3px 0 var(--wood); text-decoration: none; font-weight: 600; cursor: pointer; }

@media (max-width: 1100px) {
  .cabin { grid-template-columns: 180px minmax(0, 1fr); height: auto; }
  .cabin-side { grid-column: 1 / -1; }
  .cabin-stage { height: 72vh; }
}
@media (max-width: 860px) {
  .views { order: 3; width: 100%; justify-content: center; }
  .cabin { grid-template-columns: 1fr; padding: 10px; }
  .cabin-list { display: flex; overflow-x: auto; }
  .who { flex: none; }
  .who small { display: none; }
  .cabin-stage { grid-template-columns: 1fr; height: 78vh; }
  .cabin-art { position: absolute; inset: 0; opacity: 0.35; mask-image: none; -webkit-mask-image: none; }
  .cabin-chat { background: rgba(255, 248, 232, 0.8); }
  .lb-grid { grid-template-columns: 1fr; }
  .lb-grid > img { max-height: 60vh; }
}
