/* 养娃记 - 浅色温暖风格 */
:root {
  --bg: #fdf9f4;
  --surface: #ffffff;
  --surface-2: #fff7ee;
  --border: #f0e4d6;
  --text: #4a3b32;
  --text-light: #9a8b80;
  --primary: #f28c6a;
  --primary-dark: #e3704c;
  --primary-soft: #fff0e9;
  --green: #6fbf8e;
  --blue: #7ab6e8;
  --yellow: #f2c76a;
  --purple: #b79ce0;
  --shadow: 0 4px 20px rgba(180, 130, 100, .08);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button, input { font-family: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* ---------- 通用 ---------- */
.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  transition: all .18s;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: var(--text-light); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: #6b5a4e; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .18s;
}
input:focus, select:focus { border-color: var(--primary); }

.msg { font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }
.msg.error { color: #e05a5a; }
.msg.success { color: var(--green); }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 38px; height: 38px;
  font-size: 17px;
  display: grid; place-items: center;
  transition: all .18s;
}
.icon-btn:hover { background: var(--primary-soft); }

/* ---------- 登录 ---------- */
#authView {
  display: none;
  place-items: center;
  background: radial-gradient(circle at 20% 20%, #fff3e8 0%, transparent 50%),
              radial-gradient(circle at 80% 80%, #eaf5ff 0%, transparent 50%),
              var(--bg);
}
#authView.active { display: grid; }
.auth-box {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 40px 36px;
  margin: 30px 16px;
}
.brand { text-align: center; margin-bottom: 28px; }
.brand-logo { font-size: 56px; line-height: 1; }
.brand h1 { font-size: 28px; margin-top: 10px; color: var(--primary-dark); }
.brand p { color: var(--text-light); font-size: 14px; margin-top: 6px; }
.tabs { display: flex; gap: 8px; background: var(--surface-2); padding: 5px; border-radius: 12px; margin-bottom: 20px; }
.tab {
  flex: 1; border: none; background: transparent;
  padding: 10px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-light);
}
.tab.active { background: #fff; color: var(--primary-dark); box-shadow: 0 2px 8px rgba(180,130,100,.1); }
.auth-form .btn { margin-top: 22px; }
.auth-footer { text-align: center; margin-top: 18px; }
.link { color: var(--text-light); font-size: 13px; text-decoration: none; }
.link:hover { color: var(--primary); }

/* ---------- 领养 ---------- */
#adoptView { display: none; place-items: center; padding: 30px 16px; background: radial-gradient(circle at 50% 0%, #fff0e5, transparent 60%), var(--bg); }
#adoptView.active { display: grid; }
.adopt-box {
  width: 100%; max-width: 460px;
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
  padding: 36px; margin: auto;
}
.adopt-box h2 { font-size: 24px; color: var(--primary-dark); text-align: center; }
.adopt-box .sub { text-align: center; color: var(--text-light); font-size: 13px; margin: 8px 0 20px; }
.avatar-preview {
  width: 120px; height: 120px; margin: 0 auto 10px;
  border-radius: 50%; background: var(--primary-soft);
  display: grid; place-items: center; overflow: hidden;
  border: 3px solid #fff; box-shadow: 0 4px 16px rgba(180,130,100,.15);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-ph { font-size: 56px; }
.radio-row { display: flex; gap: 20px; }
.radio-label { display: flex; align-items: center; gap: 6px; font-weight: 500; margin: 6px 0; }
.radio-label input { accent-color: var(--primary); }
.hint-label { font-size: 12px; color: var(--text-light); font-weight: 500; }
.avatar-list { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 12px; }
.avatar-choice {
  width: 70px; text-align: center; cursor: pointer; padding: 4px;
  border: 2px solid transparent; border-radius: 12px; transition: all .18s;
}
.avatar-choice:hover { background: var(--surface-2); }
.avatar-choice.selected { border-color: var(--primary); background: var(--primary-soft); }
.avatar-choice img { width: 60px; height: 60px; object-fit: cover; border-radius: 10px; }
.avatar-choice span { font-size: 11px; color: var(--text-light); display: block; margin-top: 4px; }
.empty-hint { color: var(--text-light); font-size: 13px; text-align: center; padding: 12px; }

/* ---------- 游戏主界面 ---------- */
.game-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 28px; display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 10;
}
.game-title { display: flex; align-items: center; gap: 10px; }
.game-logo { font-size: 28px; }
.game-title strong { font-size: 18px; color: var(--primary-dark); display: block; }
.user-label { font-size: 12px; color: var(--text-light); }
.header-stats { display: flex; align-items: center; gap: 18px; }
.hstat { display: flex; align-items: baseline; gap: 4px; font-size: 13px; color: var(--text-light); }
.hstat strong { font-size: 20px; color: var(--text); }
.hstat.money strong { color: var(--green); }

.progress-wrap { padding: 16px 28px 0; max-width: 1200px; margin: 0 auto; }
.progress-bar { height: 8px; background: #f3e9dd; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--yellow), var(--primary)); border-radius: 10px; transition: width .4s; }
.progress-text { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-light); margin-top: 6px; }

.game-layout { max-width: 1200px; margin: 0 auto; padding: 20px 28px 60px; display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.main-col, .side-col { display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-head h3 { font-size: 16px; }
.card-tip { font-size: 12px; color: var(--text-light); }

.scene-card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border); }
.scene-box {
  height: 230px; background-size: cover; background-position: center;
  background-color: #f6e8da; position: relative; display: grid; place-items: center;
}
.scene-fallback { display: none; font-size: 80px; opacity: .35; }
.scene-box:not(.has-scene) .scene-fallback { display: block; }
.child-figure { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); height: 88%; width: 160px; display: grid; place-items: end center; }
.child-figure img { max-height: 100%; max-width: 100%; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,.15)); }
.child-ph { font-size: 90px; filter: drop-shadow(0 6px 8px rgba(0,0,0,.12)); }
.scene-caption {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,.85); padding: 5px 14px; border-radius: 20px;
  font-size: 12px; color: var(--text); white-space: nowrap;
}
.child-info { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; }
.child-info h3 { font-size: 20px; }
.badge { background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; padding: 5px 12px; border-radius: 20px; font-weight: 600; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; }
.stat-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.stat-top b { color: var(--text); }
.mini-bar { height: 8px; background: #f3ebe3; border-radius: 10px; overflow: hidden; }
.mini-bar .fill { display: block; height: 100%; border-radius: 10px; transition: width .4s; }
.fill.health { background: #ee8a8a; }
.fill.happy { background: var(--yellow); }
.fill.intel { background: var(--blue); }
.fill.str { background: var(--green); }

.work-status { background: var(--primary-soft); color: var(--primary-dark); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.job-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.job-btn, .care-btn {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; transition: all .18s;
}
.job-btn:hover:not(:disabled), .care-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }
.job-icon { font-size: 22px; }
.job-main { flex: 1; }
.job-main b { display: block; font-size: 14px; }
.job-main small { color: var(--text-light); font-size: 11px; }
.job-pay { text-align: right; color: var(--green); font-weight: 700; font-size: 14px; }
.job-pay small { display: block; color: var(--text-light); font-weight: 400; font-size: 11px; }
.care-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.care-btn { flex-direction: column; text-align: center; gap: 4px; }
.care-icon { font-size: 26px; }
.care-btn b { font-size: 12px; }
.care-btn small { font-size: 11px; color: var(--text-light); }

.log-card { position: sticky; top: 84px; max-height: calc(100vh - 110px); display: flex; flex-direction: column; }
.log-list { overflow-y: auto; flex: 1; }
.log-item { border-left: 3px solid var(--primary); padding: 8px 0 12px 12px; margin-bottom: 6px; position: relative; }
.log-item:not(:last-child)::after { content: ''; position: absolute; left: -1.5px; top: 30px; bottom: 0; width: 1px; background: var(--border); }
.log-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 5px; }
.log-day { font-size: 11px; color: var(--primary-dark); font-weight: 700; }
.log-tag { font-size: 10px; background: var(--surface-2); color: var(--text-light); padding: 2px 7px; border-radius: 8px; }
.log-item p { font-size: 13px; line-height: 1.6; color: #5c4d43; }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(60,40,30,.4); }
.modal-box { position: relative; background: var(--surface); border-radius: 20px; width: 90%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 22px 24px; }
.modal-body h4 { font-size: 14px; margin-bottom: 4px; }
.modal-body hr { border: none; border-top: 1px solid var(--border); margin: 24px 0 12px; }

.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #4a3b32; color: #fff; padding: 11px 22px; border-radius: 24px; font-size: 14px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.error { background: #d9534f; }

/* ---------- 角色立绘 ---------- */
.child-figure { display: block; }
.child-figure .layer-base {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  height: 100%; width: 100%;
  max-height: 100%; max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.15));
  pointer-events: none;
  z-index: 2;
}
.child-figure .child-ph { position: absolute; inset: 0; display: grid; place-items: center; }

.child-info-left { display: flex; flex-direction: column; gap: 4px; }
.child-info-right { display: flex; align-items: center; gap: 10px; }
.expr-badge { font-size: 12px; color: var(--text-light); background: var(--surface-2); padding: 3px 10px; border-radius: 20px; width: fit-content; }
.btn.sm { padding: 7px 12px; font-size: 13px; }

/* 加宽的设置弹窗 + 页签 */
.modal-box.modal-wide { max-width: 560px; max-height: 88vh; display: flex; flex-direction: column; }
.modal-tabs { display: flex; gap: 6px; padding: 12px 22px 0; border-bottom: 1px solid var(--border); }
.modal-tab { flex: 1; border: none; background: transparent; padding: 10px; font-size: 14px; font-weight: 600; color: var(--text-light); border-bottom: 2px solid transparent; }
.modal-tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.modal-box .modal-body { overflow-y: auto; }
.mtab-panel { display: none; }
.mtab-panel.active { display: block; }

.dress-preview { display: flex; align-items: center; gap: 16px; background: var(--surface-2); border-radius: 14px; padding: 14px; margin-bottom: 8px; }
.dress-stage { position: relative; width: 96px; height: 96px; flex: none; border-radius: 12px; overflow: hidden; background: linear-gradient(160deg,#fff3e8,#eaf5ff); display: grid; place-items: center; }
.dress-stage img { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); height: 100%; width: 100%; object-fit: contain; }
.dress-stage #dressBase { z-index: 2; }
.dress-info b { display: block; font-size: 16px; margin-bottom: 6px; }
.dress-info span { font-size: 12px; color: var(--text-light); }
.section-tip { font-size: 11px; color: var(--text-light); margin: -2px 0 10px; }
.dress-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; margin-bottom: 18px; }
.dress-item { border: 2px solid var(--border); background: #fff; border-radius: 12px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: all .18s; }
.dress-item:hover { border-color: var(--primary); }
.dress-item.selected { border-color: var(--primary); background: var(--primary-soft); }
.dress-item img { width: 56px; height: 56px; object-fit: contain; }
.dress-emoji { font-size: 36px; height: 56px; display: grid; place-items: center; }
.dress-item span { font-size: 11px; color: var(--text-light); }
.empty-hint.small { font-size: 12px; grid-column: 1 / -1; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .game-layout { grid-template-columns: 1fr; }
  .log-card { position: static; max-height: 400px; }
}
@media (max-width: 600px) {
  .game-header { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .header-stats { gap: 12px; }
  .progress-wrap { padding: 14px 16px 0; }
  .game-layout { padding: 16px 14px 40px; }
  .stats-grid { gap: 12px; }
  .job-grid { grid-template-columns: 1fr; }
  .care-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-box, .adopt-box { padding: 28px 22px; }
}
