:root {
  --bg: #fff0f6;
  --kuki-pink: #ff9ec4;
  --kuki-light: #ffe6f2;
  --nono-purple: #b79cf0;
  --nono-light: #eee8ff;
  --screen-border: #6a8c5a;
  --screen-bg: #e9f7d8;
  --bar-bg: #ece5e9;
  --text: #5a4a55;
  --muted: #9a8792;
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #fff0f6, #f3eeff);
  color: var(--text);
  min-height: 100vh;
}
.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* 进房 */
.join-card {
  background: #fff;
  border-radius: 28px;
  padding: 32px 24px;
  width: 92%;
  max-width: 360px;
  box-shadow: 0 18px 50px rgba(200, 120, 170, .25);
  margin: 18vh auto 0;
  text-align: center;
}
.join-card h1 { margin: 0; font-size: 28px; color: var(--kuki-pink); }
.sub { color: var(--muted); margin: 6px 0 24px; }
.join-card input {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid #ffd9ec;
  border-radius: 16px;
  font-size: 16px;
  margin-bottom: 12px;
  outline: none;
}
.join-card input:focus { border-color: var(--kuki-pink); }
.row { display: flex; gap: 10px; }
.row input { flex: 1; margin-bottom: 0; }
button {
  padding: 12px 18px;
  border: none;
  border-radius: 14px;
  background: var(--kuki-pink);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: .15s;
}
button:active { transform: scale(.96); }
button.ghost { background: #ffe3f1; color: var(--kuki-pink); width: 100%; margin-top: 12px; }
button.small { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
button.primary { background: var(--nono-purple); }
button:disabled { opacity: .5; cursor: not-allowed; }
.msg { color: #e0567a; min-height: 20px; font-size: 14px; margin-top: 10px; }

/* 主布局 */
.layout {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  padding: 16px;
  max-width: 1100px;
  margin: 0 auto;
}
.devices {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  flex: 1 1 520px;
}

/* 设备面板 */
.device {
  flex: 1 1 240px;
  max-width: 340px;
  min-width: 260px;
  padding: 18px 14px 20px;
  border-radius: 42% 42% 40% 40% / 10% 10% 12% 12%;
  border: 4px solid rgba(255,255,255,.7);
  box-shadow: 0 22px 55px rgba(180, 120, 170, .22), inset 0 -8px 18px rgba(0,0,0,.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* 宠物回应气泡（呆萌字体） */
.pet-speech {
  position: absolute;
  top: 92px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 2px solid #ffd2e8;
  border-radius: 14px;
  padding: 6px 12px;
  font-family: "ZCOOL KuaiLe", "Yuanti SC", "PingFang SC", "Comic Sans MS", cursive;
  font-size: 14px;
  line-height: 1.3;
  color: #5a4a55;
  box-shadow: 0 6px 16px rgba(200, 120, 170, .25);
  max-width: 82%;
  text-align: center;
  z-index: 5;
  animation: speechPop .25s ease;
}
.pet-speech::after {
  content: '';
  position: absolute;
  bottom: -8px; left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
}
@keyframes speechPop {
  from { transform: translateX(-50%) scale(.8); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* 飘浮爱心 */
.heart-float {
  position: absolute;
  top: 38%;
  left: 50%;
  font-size: 26px;
  pointer-events: none;
  z-index: 6;
  animation: floatUp 1.2s ease-out forwards;
}
@keyframes floatUp {
  0% { transform: translate(-50%, 0) scale(.6); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, -90px) scale(1.25); opacity: 0; }
}
.device.kuki { background: linear-gradient(180deg, var(--kuki-light), #fff); }
.device.nono { background: linear-gradient(180deg, var(--nono-light), #fff); }

.device-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text);
  margin-bottom: 8px;
}

.real-avatar {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: 4px solid #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  overflow: hidden;
  object-fit: cover;
  margin-top: -8px;
  margin-bottom: 12px;
}
.real-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 屏幕 */
.device-screen {
  width: 92%;
  aspect-ratio: 1.1;
  background: var(--screen-bg);
  border: 4px solid var(--screen-border);
  border-radius: 18px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  box-shadow: inset 0 0 12px rgba(0,0,0,.08);
}
.screen-hud {
  position: absolute;
  top: 6px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--screen-border);
  font-weight: 600;
}
.pixel-avatar {
  width: 76%;
  height: 76%;
  object-fit: contain;
  image-rendering: pixelated;
}
.device.dead .pixel-avatar { filter: grayscale(1); opacity: .6; }

/* 状态条 */
.stat-bars { width: 92%; margin-bottom: 10px; }
.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 13px;
}
.stat-row label { width: 34px; color: var(--muted); text-align: right; }
.stat-track { flex: 1; height: 10px; background: var(--bar-bg); border-radius: 8px; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 8px; transition: width .4s; }
.fill-satiety { background: #ff9b5e; }
.fill-happiness { background: var(--kuki-pink); }
.fill-energy { background: #7ed99a; }
.fill-hygiene { background: #7ec8ff; }
.fill-health { background: #ff6b6b; }

.mood {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  min-height: 22px;
}

/* 动作按钮 */
.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 92%;
  margin-bottom: 10px;
}
.actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 4px;
  font-size: 12px;
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
  border: 2px solid transparent;
}
.actions button:hover { border-color: rgba(0,0,0,.08); }
.actions button .emoji { font-size: 20px; }

.rehatch {
  width: 92%;
  padding: 11px;
  font-size: 14px;
  border-radius: 14px;
  background: #fff6e8;
  color: #d48c1f;
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* 侧边栏 */
.sidebar { flex: 1 1 320px; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 10px 30px rgba(180, 120, 170, .15);
}
.card h3 { margin: 0 0 12px; font-size: 16px; color: var(--text); }

.profile-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.room-info { font-size: 12px; color: var(--muted); }

.leaderboard { margin: 0; padding: 0; list-style: none; }
.leaderboard li {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 14px;
}
.leaderboard li:last-child { border-bottom: none; }
.leaderboard .rank { color: var(--kuki-pink); font-weight: 700; margin-right: 6px; }
.leaderboard .count { font-weight: 700; color: var(--nono-purple); }
.lb-note { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.4; }

.action-log { margin: 0; padding: 0; list-style: none; max-height: 320px; overflow-y: auto; }
.action-log li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 13px;
  color: var(--text);
}
.action-log .time { color: var(--muted); font-size: 11px; white-space: nowrap; margin-left: 6px; }
.tip { font-size: 13px; color: var(--muted); line-height: 1.5; }
.rate-card { font-size: 13px; color: var(--muted); text-align: center; }

/* 主列与 Tab */
.main-col { flex: 1 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.panel { width: 100%; }

/* 留言板 */
.board-card { display: flex; flex-direction: column; }
.msg-list {
  flex: 1;
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px;
}
.msg-item {
  background: #fff6fb;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.msg-item .who { font-weight: 700; color: var(--kuki-pink); margin-right: 6px; }
.msg-item .time { font-size: 11px; color: var(--muted); margin-left: 6px; }
.msg-input { display: flex; gap: 8px; margin-top: 10px; }
.msg-input input { flex: 1; padding: 10px 12px; border: 2px solid #ffd9ec; border-radius: 12px; outline: none; font-size: 14px; }
.msg-input input:focus { border-color: var(--kuki-pink); }

/* 待办 */
.todo-card { display: flex; flex-direction: column; }
.todo-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.todo-item {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 2px solid #ffe3f2; border-radius: 12px; padding: 8px 10px;
}
.todo-item.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-text { flex: 1; font-size: 14px; }
.todo-date { font-size: 12px; color: var(--nono-purple); background: #f3eeff; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.todo-item button { padding: 4px 8px; font-size: 12px; border-radius: 8px; }
.todo-add { display: flex; gap: 8px; flex-wrap: wrap; }
.todo-add input[type="text"], .todo-add input:not([type]) { flex: 1; min-width: 120px; padding: 9px 12px; border: 2px solid #ffd9ec; border-radius: 12px; outline: none; font-size: 14px; }
.todo-add input[type="date"] { padding: 8px 10px; border: 2px solid #ffd9ec; border-radius: 12px; outline: none; font-size: 14px; }

/* 晚饭 */
.dinner-card { text-align: center; }
.dinner-roll { background: linear-gradient(135deg, var(--kuki-pink), var(--nono-purple)); margin: 6px auto 16px; font-size: 16px; }
.dinner-options { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.dinner-option {
  flex: 1 1 140px; max-width: 200px;
  background: #fff; border: 3px solid #ffd9ec; border-radius: 18px;
  padding: 22px 10px; font-size: 20px; font-weight: 700; color: var(--text);
  cursor: pointer; transition: .15s; box-shadow: 0 6px 16px rgba(180,120,170,.18);
}
.dinner-option:hover { transform: translateY(-3px); border-color: var(--kuki-pink); }
.dinner-option.voted { background: #fff0f7; border-color: var(--nono-purple); }
.dinner-option .sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 6px; }
.dinner-final { margin-top: 16px; font-size: 18px; font-weight: 700; color: var(--kuki-pink); min-height: 24px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(74, 58, 69, .94);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 100;
}
.toast.hidden { display: none; }

/* 登录账号选择 */
.acc-tip { margin: 4px 0 0; font-size: 13px; color: #9a8aa0; }
.acc-row { display: flex; gap: 10px; margin-bottom: 12px; }
.acc-btn {
  flex: 1; padding: 12px 6px; font-size: 15px; border-radius: 14px;
  background: #fff; color: var(--text); border: 2px solid #ffd9ec; box-shadow: 0 3px 10px rgba(0,0,0,.06);
}
.acc-btn.active { background: linear-gradient(135deg, var(--kuki-pink), var(--nono-purple)); color: #fff; border-color: transparent; }

/* 留言表情栏 */
.emoji-toggle {
  flex: 0 0 auto; width: 44px; padding: 0; font-size: 20px;
  background: #fff6fb; border: 2px solid #ffd9ec; border-radius: 12px;
}
.emoji-bar {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; padding: 8px;
  background: #fff6fb; border: 2px solid #ffd9ec; border-radius: 14px;
}
.emoji-bar.hidden { display: none; }
.emoji-item {
  font-size: 20px; line-height: 1; padding: 4px 6px; border-radius: 8px; cursor: pointer;
  transition: .12s;
}
.emoji-item:hover { background: #ffe3f1; transform: scale(1.15); }

/* OOTD */
.ootd-upload { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.ootd-fname { font-size: 11px; color: var(--muted); flex-basis: 100%; }
.ootd-upload input:not([type="file"]) {
  flex: 1; min-width: 120px; padding: 8px 10px; border: 2px solid #ffd9ec; border-radius: 10px; outline: none; font-size: 13px;
}
.ootd-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.ootd-empty { font-size: 12px; color: var(--muted); text-align: center; padding: 8px 0; }
.ootd-thumb {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; cursor: pointer;
  border: 2px solid #ffe3f2; background: #fff6fb;
}
.ootd-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: .15s; }
.ootd-thumb:hover img { transform: scale(1.08); }
.ootd-thumb-by {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.55)); padding: 8px 4px 3px; text-align: center;
}
.ootd-count { font-size: 11px; color: var(--muted); text-align: center; margin-top: 8px; }

/* OOTD 灯箱 */
#ootd-lightbox { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
#ootd-lightbox.hidden { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(60, 40, 55, .82); backdrop-filter: blur(2px); }
.lb-box {
  position: relative; z-index: 1; width: min(92vw, 460px); max-height: 90vh;
  background: #fff; border-radius: 18px; padding: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
  display: flex; flex-direction: column; gap: 8px; animation: speechPop .25s ease;
}
.lb-box img { width: 100%; max-height: 62vh; object-fit: contain; border-radius: 12px; background: #f7f7f7; }
.lb-meta { font-size: 13px; color: var(--nono-purple); font-weight: 700; text-align: center; }
.lb-cap { font-size: 14px; color: var(--text); text-align: center; line-height: 1.4; min-height: 18px; }
.lb-nav { display: flex; justify-content: space-between; gap: 8px; }
.lb-nav button { flex: 1; }
.lb-close {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 34px; height: 34px; padding: 0;
  border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; font-size: 16px; line-height: 1;
}
.lb-close:hover { background: rgba(0,0,0,.65); }

/* 情绪天气：提示 + 选择器 */
.mood-hint { font-size: 11px; color: var(--kuki-pink); font-weight: 400; margin-left: 4px; }
.mood-picker {
  display: flex; gap: 6px; padding: 8px; margin: 0 4px 6px;
  background: #fff; border: 2px solid #ffd9ec; border-radius: 14px; justify-content: center;
  animation: speechPop .2s ease;
}
.mood-pick {
  font-size: 24px; line-height: 1; padding: 4px 8px; border-radius: 10px; cursor: pointer;
  transition: .12s; border: 2px solid transparent;
}
.mood-pick:hover { background: #fff0f7; transform: scale(1.12); }
.mood-pick.sel { border-color: var(--nono-purple); background: #f3eeff; }

/* 待办行内编辑 */
.todo-edit-text { flex: 1; min-width: 100px; padding: 6px 10px; border: 2px solid var(--kuki-pink); border-radius: 10px; outline: none; font-size: 14px; }
.todo-edit-date { padding: 6px 8px; border: 2px solid #ffd9ec; border-radius: 10px; outline: none; font-size: 13px; }
.todo-item.editing { background: #fff0f7; border-color: var(--kuki-pink); }

/* 晚饭摇号动画 */
.dinner-options.rolling { animation: diceShake .9s ease; min-height: 60px; display: flex; align-items: center; justify-content: center; }
.rolling-tip { font-size: 18px; font-weight: 700; color: var(--kuki-pink); animation: pulse 1s infinite; }
@keyframes diceShake {
  0% { transform: rotate(-4deg) scale(1); filter: blur(0); }
  25% { transform: rotate(4deg) scale(1.04); filter: blur(1px); }
  50% { transform: rotate(-3deg) scale(.98); filter: blur(0); }
  75% { transform: rotate(3deg) scale(1.02); filter: blur(1px); }
  100% { transform: rotate(0) scale(1); filter: blur(0); }
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* 晚饭确认庆祝 */
.dinner-final.confirmed { animation: popBig .5s cubic-bezier(.18,1.3,.5,1); position: relative; }
@keyframes popBig {
  0% { transform: scale(.6); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.confetti {
  position: absolute; top: 0; font-size: 20px; pointer-events: none; z-index: 5;
  animation: confettiFall 1.5s ease-out forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(-6px) rotate(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(48px) rotate(220deg); opacity: 0; }
}

/* 美团下一步 */
.dinner-next { margin-top: 16px; padding-top: 14px; border-top: 2px dashed #ffd9ec; text-align: left; }
.dinner-next.hidden { display: none; }
.dinner-next h4 { margin: 0 0 10px; font-size: 15px; color: var(--text); text-align: center; }
.merchant-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.merchant {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #fff6fb; border: 2px solid #ffe3f2; border-radius: 12px; padding: 8px 10px;
}
.merchant .m-name { font-weight: 700; color: var(--text); }
.merchant .m-info { font-size: 12px; color: var(--muted); flex: 1; }
.merchant button { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.m-note { font-size: 11px; color: var(--muted); text-align: center; margin: 10px 0 0; line-height: 1.4; }

/* 情绪天气 */
.mood-card { text-align: center; }
.mood-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.mood-row {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff6fb; border-radius: 14px; padding: 10px 14px;
}
.mood-row.mine { cursor: pointer; border: 2px dashed var(--kuki-pink); }
.mood-name { font-weight: 700; color: var(--text); }
.mood-icon { font-size: 26px; line-height: 1; }

@media (max-width: 760px) {
  .layout { flex-direction: column; align-items: stretch; }
  .devices { width: 100%; }
  .device { max-width: none; min-width: 0; }
  .sidebar { max-width: none; }
}

/* 宠物对话 */
.pet-chats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.pet-chat {
  background: #fff; border-radius: 16px; padding: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.06);
  display: flex; flex-direction: column; min-height: 220px;
}
.pc-head { font-size: 14px; font-weight: 700; color: var(--kuki-pink); margin-bottom: 8px; }
.pc-msgs { flex: 1; overflow-y: auto; max-height: 200px; display: flex; flex-direction: column; gap: 8px; padding: 2px 4px; }
.pc-msg { display: flex; flex-direction: column; max-width: 88%; }
.pc-msg .pc-who { font-size: 10px; color: #b3a7b8; margin: 0 4px 2px; }
.pc-msg .pc-text { padding: 7px 11px; border-radius: 14px; font-size: 13px; line-height: 1.45; word-break: break-word; }
.pc-msg.from-pet { align-self: flex-start; }
.pc-msg.from-pet .pc-text { background: #f3ecff; color: #5b4a73; border-bottom-left-radius: 4px; }
.pc-msg.from-owner { align-self: flex-end; align-items: flex-end; }
.pc-msg.from-owner .pc-text { background: linear-gradient(135deg, var(--kuki-pink), var(--nono-purple)); color: #fff; border-bottom-right-radius: 4px; }
.pc-typing .pc-text { font-style: italic; opacity: .7; }
.pc-input { display: flex; gap: 8px; margin-top: 10px; }
.pc-input input { flex: 1; padding: 9px 12px; border: 2px solid #ffd9ec; border-radius: 12px; font-size: 13px; outline: none; }
.pc-input input:focus { border-color: var(--kuki-pink); }
@media (max-width: 720px) { .pet-chats { grid-template-columns: 1fr; } }
