/* 悠悠小镇 · 真实场景样式 */
:root {
  --brand: #35b96a;
  --brand-dark: #1f8f4d;
  --amber: #f5a623;
  --ink: #23313f;
  --muted: #6a7a8c;
  --card: rgba(255, 255, 255, 0.94);
  --line: rgba(35, 49, 63, 0.12);
  --shadow: 0 12px 30px rgba(28, 58, 84, 0.18);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #cdeccb;
  color: var(--ink);
  font: 14px/1.5 "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

canvas { display: block; width: 100vw; height: 100vh; cursor: pointer; }

.hidden { display: none !important; }

/* ---------------- 顶部 HUD ---------------- */
#hud {
  position: fixed;
  inset: 14px 14px auto 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
  z-index: 20;
}

.hud-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; pointer-events: auto; }

.name-chip,
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  box-shadow: 0 6px 16px rgba(28, 58, 84, 0.12);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.name-chip b { color: var(--ink); font-size: 14px; }
.name-chip i { font-style: normal; font-size: 11px; background: #eafaf0; color: var(--brand-dark); border-radius: 999px; padding: 1px 7px; }
.stat-pill b { color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-pill.gold { color: #b7791f; }
.stat-pill.online { color: var(--brand-dark); }

.energy { gap: 8px; }
.energy-track { width: 96px; height: 8px; border-radius: 999px; background: rgba(35, 49, 63, 0.1); overflow: hidden; }
.energy-track i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #6fe39a, #35b96a); transition: width .25s ease; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(28, 58, 84, 0.12);
}
.icon-btn:hover { background: #fff; }

/* ---------------- 底部功能坞 ---------------- */
#dock {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  z-index: 20;
}
#dock button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 62px;
  padding: 7px 10px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .15s;
}
#dock button span { font-size: 20px; line-height: 1; }
#dock button:hover { background: #eefaf1; color: var(--brand-dark); transform: translateY(-2px); }

/* ---------------- 快捷前往 ---------------- */
#quick-nav {
  position: fixed;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}
#quick-nav button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(28, 58, 84, 0.12);
  transition: transform .15s, background .15s;
}
#quick-nav button span { font-size: 16px; }
#quick-nav button:hover { background: #eefaf1; color: var(--brand-dark); transform: translateX(3px); }

/* ---------------- 提示 ---------------- */
#toast {
  position: fixed;
  left: 50%;
  top: 84px;
  transform: translateX(-50%) translateY(-8px);
  background: rgba(35, 49, 63, 0.92);
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 40;
  max-width: 80vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: rgba(196, 62, 52, 0.94); }

/* 鼠标悬停在可交互物体上时的小标签 */
#hover-hint {
  position: fixed;
  z-index: 26;
  pointer-events: none;
  background: rgba(35, 49, 63, 0.9);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  padding: 5px 10px;
  border-radius: 9px;
  max-width: 220px;
  box-shadow: 0 6px 16px rgba(28, 58, 84, 0.2);
}

/* ---------------- 物体操作菜单 ---------------- */
#action-menu {
  position: fixed;
  min-width: 172px;
  max-width: 240px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 10px;
  z-index: 30;
  transform: translate(-50%, -100%);
  backdrop-filter: blur(10px);
}
#action-menu .am-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
#action-menu .am-sub { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
#action-menu .am-actions { display: flex; flex-direction: column; gap: 6px; }
#action-menu button {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: none;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
#action-menu button.ghost { background: #f2f6f4; color: var(--ink); border: 1px solid var(--line); }
#action-menu button:disabled { opacity: .45; cursor: not-allowed; }
#action-menu button:hover:not(:disabled) { filter: brightness(1.05); }

/* ---------------- 通用面板 ---------------- */
#panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(430px, 94vw);
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 40px rgba(28, 58, 84, 0.18);
  z-index: 35;
  display: flex;
  flex-direction: column;
  animation: slide-in .18s ease;
}
@keyframes slide-in { from { transform: translateX(30px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 17px; }
#panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 28px; }

.section-title { font-size: 13px; color: var(--muted); margin: 14px 0 8px; font-weight: 700; }
.section-title:first-child { margin-top: 0; }

.row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  margin-bottom: 8px;
}
.row-card .rc-main { min-width: 0; }
.row-card b { font-size: 13px; }
.row-card .rc-sub { color: var(--muted); font-size: 12px; }
.row-card .rc-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  padding: 7px 12px;
  border-radius: 10px;
  border: none;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn.ghost { background: #f2f6f4; color: var(--ink); border: 1px solid var(--line); }
.btn.gold { background: #f5a623; color: #4a2c00; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 0; }

/* 小镇社交 */
.row-card.me { border-color: var(--brand); background: #f3fbf6; }
.msg-input-row { display: flex; gap: 8px; margin-bottom: 10px; }
.msg-input-row input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #f7faf8;
  font: inherit;
  color: var(--ink);
  outline: none;
}
.msg-input-row input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(53, 185, 106, 0.15); }
.msg-row { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.msg-row:last-child { border-bottom: none; }
.msg-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg-head b { color: var(--ink); }
.msg-text { font-size: 13px; line-height: 1.6; word-break: break-word; }
.msg-row.sys .msg-text { color: #b7791f; }

/* 衣柜 */
.cloth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cloth-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
}
.cloth-card.on { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(53, 185, 106, 0.18); }
.cloth-thumb {
  width: 74px; height: 74px; margin: 0 auto 6px;
  background: #f7faf8 center / contain no-repeat;
  border-radius: 10px;
}
.cloth-name { font-size: 13px; font-weight: 700; }
.cloth-sub { font-size: 11px; color: var(--muted); margin: 2px 0 7px; }
.cloth-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
  cursor: pointer; position: relative;
}
.swatch.owned::after {
  content: ""; position: absolute; inset: 8px;
  border-radius: 50%; background: rgba(35, 49, 63, 0.35);
  box-shadow: 0 0 0 2px #fff;
}
.swatch.active { box-shadow: 0 0 0 2px var(--brand); }

/* 任务进度 */
.progress { height: 7px; border-radius: 999px; background: rgba(35, 49, 63, 0.1); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #6fe39a, #35b96a); }

/* 商店 */
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shop-item { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; text-align: center; }
.shop-item b { display: block; font-size: 13px; }
.shop-item .price { color: #b7791f; font-size: 12px; margin: 3px 0 7px; }
.sell-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.sell-row:last-child { border-bottom: none; }

/* 操作说明弹层 */
.help-card { line-height: 1.8; font-size: 13px; color: #33465a; }
.help-card kbd { background: #eef3f0; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; font-size: 12px; }

/* ---------------- 登录入口 ---------------- */
#start-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(160deg, rgba(190, 235, 205, 0.32), rgba(150, 208, 235, 0.34)),
    url("/assets/bg-town-2k.webp") center / cover no-repeat;
  backdrop-filter: blur(2px);
}
.start-card {
  width: min(420px, 92vw);
  background: rgba(255, 255, 255, 0.96);
  border-radius: 26px;
  padding: 28px 26px 22px;
  box-shadow: 0 24px 60px rgba(28, 58, 84, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.8);
}
.start-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: 1px; }
.start-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.step { display: flex; flex-direction: column; gap: 10px; }
.step label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.step input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f7faf8;
  font: inherit;
  color: var(--ink);
  outline: none;
}
.step input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(53, 185, 106, 0.15); }
.start-actions { display: flex; gap: 10px; }
.start-actions button {
  flex: 1;
  padding: 11px 14px;
  border-radius: 13px;
  border: none;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.start-actions button.ghost { background: #eef6f1; color: var(--brand-dark); border: 1px solid #d4ecdd; }
.start-actions button:disabled { opacity: .5; cursor: not-allowed; }
.who { margin: 0; font-size: 13px; color: var(--muted); }
.start-tip { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.6; border-top: 1px dashed var(--line); padding-top: 12px; }

/* 服饰性别标签 */
.cloth-tags { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; margin: 2px 0 4px; }
.cloth-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: #eef3f0;
  color: var(--muted);
}
.cloth-tag.g1 { background: #e3edff; color: #3567b8; }
.cloth-tag.g2 { background: #ffe6ef; color: #c2557d; }
.cloth-tag.limited { background: #fff4dc; color: #c9861c; }

/* 宠物面板 */
.pet-form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.pet-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.pet-form input,
.pet-form select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #f7faf8;
  font: inherit;
  color: var(--ink);
  outline: none;
}
.pet-colors { display: flex; gap: 8px; padding: 2px 0; }
.pet-color {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
.pet-color.active { box-shadow: 0 0 0 3px var(--brand); }
.progress.hunger i { background: linear-gradient(90deg, #ffd166, #f5a623); }

/* 离开小屋按钮 */
#exit-house {
  position: fixed;
  left: 18px;
  top: 86px;
  z-index: 25;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--brand-dark);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(28, 58, 84, 0.16);
}

/* 钓鱼小游戏 */
#fishing-game {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 40, 55, 0.45);
  backdrop-filter: blur(3px);
}
.fish-card {
  width: min(400px, 90vw);
  background: #fff;
  border-radius: 22px;
  padding: 22px 22px 18px;
  box-shadow: 0 22px 50px rgba(20, 40, 60, 0.3);
  text-align: center;
}
.fish-card h3 { margin: 0 0 6px; }
.fish-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; min-height: 20px; }
.fish-meter {
  position: relative;
  height: 22px;
  border-radius: 999px;
  background: #e7eef0;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: inset 0 2px 6px rgba(20, 40, 60, 0.12);
}
.fish-target {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(180deg, #8fe3a8, #45c46f);
  border-radius: 6px;
}
.fish-pointer {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 6px;
  margin-left: -3px;
  background: #e2544c;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}
.fish-actions { display: flex; gap: 10px; }
.fish-actions button {
  flex: 1;
  padding: 11px 14px;
  border-radius: 12px;
  border: none;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.fish-actions button.ghost { background: #eef6f1; color: var(--brand-dark); border: 1px solid #d4ecdd; }
.fish-actions button:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 720px) {
  #hud { flex-direction: column; }
  .energy-track { width: 70px; }
  #dock button { min-width: 52px; padding: 6px; }
  .cloth-grid, .shop-grid { grid-template-columns: 1fr; }
}
