/* 星灵小窝 —— 夜色玻璃质感的放置养成界面 */
:root {
  --ink: #fff7ec;
  --ink-soft: rgba(255, 247, 236, 0.7);
  --ink-dim: rgba(255, 247, 236, 0.45);
  --card: rgba(38, 24, 66, 0.62);
  --card-line: rgba(255, 255, 255, 0.12);
  --gold: #ffd469;
  --pink: #ff9fb6;
  --mint: #8fe6c4;
  --violet: #b79dff;
  --amber: #ffc36b;
  --radius: 22px;
  --shadow: 0 18px 44px rgba(8, 3, 24, 0.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background: #100a22;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { cursor: not-allowed; }

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, #4b2a72 0%, #2a1a4d 42%, #180f31 72%, #100a22 100%);
  overflow: hidden;
}

.stars {
  position: absolute;
  inset: -10%;
  background-image:
    radial-gradient(1.8px 1.8px at 12% 18%, rgba(255,255,255,.9), transparent 60%),
    radial-gradient(1.4px 1.4px at 28% 8%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1.6px 1.6px at 44% 24%, rgba(255,240,200,.85), transparent 60%),
    radial-gradient(1.2px 1.2px at 62% 12%, rgba(255,255,255,.65), transparent 60%),
    radial-gradient(2px 2px at 78% 22%, rgba(255,236,190,.9), transparent 60%),
    radial-gradient(1.3px 1.3px at 90% 9%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1.5px 1.5px at 18% 42%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1.3px 1.3px at 68% 38%, rgba(200,220,255,.7), transparent 60%),
    radial-gradient(1.2px 1.2px at 36% 52%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1.6px 1.6px at 84% 46%, rgba(255,236,190,.6), transparent 60%),
    radial-gradient(1.2px 1.2px at 8% 62%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(1.4px 1.4px at 52% 68%, rgba(255,255,255,.4), transparent 60%);
  animation: twinkle 7s ease-in-out infinite alternate;
}

.moon {
  position: absolute;
  top: 8%;
  right: 9%;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fff6dd, #ffe0a6 60%, #f6c777 100%);
  box-shadow: 0 0 34px rgba(255, 220, 150, 0.45), 0 0 90px rgba(255, 200, 120, 0.22);
  opacity: .92;
}

.hill {
  position: absolute;
  left: -20%;
  right: -20%;
  height: 46vh;
  border-radius: 50% 50% 0 0;
  bottom: -26vh;
  background: radial-gradient(60% 90% at 50% 0%, rgba(94, 70, 148, 0.55), rgba(24, 15, 49, 0.95));
}
.hill-a { bottom: -30vh; }
.hill-b { bottom: -34vh; left: -5%; right: -35%; background: radial-gradient(60% 90% at 50% 0%, rgba(70, 51, 120, 0.6), rgba(16, 10, 34, 0.98)); }

.shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  letter-spacing: .12em;
  color: var(--ink-soft);
}
.brand-star {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  color: #3a2350;
  background: linear-gradient(150deg, #ffe9ae, var(--gold));
  box-shadow: 0 4px 14px rgba(255, 212, 105, .35);
  font-size: 13px;
}

.coins {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 130, .35);
  background: linear-gradient(140deg, rgba(255, 214, 130, .22), rgba(255, 214, 130, .06));
  font-variant-numeric: tabular-nums;
}
.coin-icon { color: var(--gold); font-size: 12px; }
.coins b { font-size: 15px; font-weight: 600; letter-spacing: .02em; }
.coins.pop { animation: coinPop .45s ease; }

.stack { display: flex; flex-direction: column; gap: 12px; }

.card {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--card-line);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
}

.scene { padding: 14px 16px 16px; overflow: hidden; }

.scene-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 2px 0;
  color: var(--ink);
}
.name .pen { font-size: 12px; color: var(--ink-dim); font-style: normal; opacity: .8; }
.name:hover .pen { opacity: 1; }

.level-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(183, 157, 255, .14);
  border: 1px solid rgba(183, 157, 255, .32);
  font-size: 12px;
}
.level-pill em { font-style: normal; color: var(--violet); font-weight: 600; }
.level-pill span { color: var(--ink-soft); }

.pet-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0 2px;
}

.pet-wrap {
  position: relative;
  width: min(252px, 70%);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  touch-action: manipulation;
}

.pet-aura {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 226, 156, .22), rgba(255, 205, 120, .05) 60%, transparent 72%);
  animation: auraPulse 5.2s ease-in-out infinite;
}

.pet {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 16px 22px rgba(10, 4, 28, .45));
}

.pet-body { transform-origin: 110px 170px; animation: breathe 3.8s ease-in-out infinite; }
.pet .ear-left { transform-origin: 76px 66px; }
.pet .ear-right { transform-origin: 144px 66px; }
.pet .tail { transform-origin: 158px 148px; animation: tailWag 3.2s ease-in-out infinite; }
.pet .eyes { transform-origin: 110px 116px; animation: blink 5.4s infinite; transform-box: view-box; }
.pet .mouth { transform-box: view-box; transform-origin: 110px 136px; transition: transform .3s ease; }
.pet .blush { transition: opacity .4s ease; }

.pet-wrap.mood-great .blush { opacity: .72; }
.pet-wrap.mood-ok .blush { opacity: .45; }
.pet-wrap.mood-low .blush { opacity: .3; }
.pet-wrap.mood-sad .blush { opacity: .22; }
.pet-wrap.mood-sad .mouth { transform: rotate(180deg); }
.pet-wrap.mood-sad .eyes { animation-duration: 3.4s; }
.pet-wrap.mood-low .mouth { transform: scaleX(.9); }
.pet-wrap.is-happy .pet-body { animation: hop .55s ease; }
.pet-wrap.is-sad .pet-body { animation: none; transform: translateY(3px) scale(.98); }
.pet-wrap.lv-up .pet-aura { animation: burst .9s ease; }

.zzz {
  position: absolute;
  top: 12%;
  right: 8%;
  display: none;
  gap: 2px;
  color: rgba(200, 220, 255, .85);
  font-size: 15px;
  font-weight: 600;
}
.zzz.on { display: inline-flex; }
.zzz span { animation: floatZ 2.4s ease-in-out infinite; }
.zzz span:nth-child(2) { animation-delay: .5s; font-size: 12px; }
.zzz span:nth-child(3) { animation-delay: 1s; font-size: 10px; }

.heart {
  position: absolute;
  left: 50%;
  bottom: 26%;
  font-size: 16px;
  pointer-events: none;
  animation: heartUp 1.15s ease-out forwards;
}

.bubble {
  margin: 2px 0 0;
  padding: 8px 15px;
  max-width: 92%;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-soft);
  border-radius: 14px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .08);
  min-height: 34px;
  transition: color .3s ease;
}

.pet-stage-name {
  margin: 7px 0 2px;
  font-size: 11px;
  letter-spacing: .08em;
  color: var(--ink-dim);
}

.stats { display: grid; gap: 9px; margin-top: 12px; }

.stat {
  display: grid;
  grid-template-columns: 62px 1fr 52px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.stat-label { color: var(--ink-soft); white-space: nowrap; }
.stat b { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; color: var(--ink-soft); font-size: 12px; }

.bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
}
.bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 50%;
  border-radius: 999px;
  transition: width .45s cubic-bezier(.22, .8, .3, 1);
}
.stat[data-kind="hunger"] .bar i { background: linear-gradient(90deg, #ffbf6b, #ffe2a1); }
.stat[data-kind="mood"] .bar i { background: linear-gradient(90deg, #ff88a8, #ffc0cf); }
.stat[data-kind="energy"] .bar i { background: linear-gradient(90deg, #62d6b0, #a8f0d6); }
.stat[data-kind="bond"] .bar i { background: linear-gradient(90deg, #ff86ae, #ffd0de); }
.stat[data-kind="exp"] .bar i { background: linear-gradient(90deg, #9d8cff, #d9cdff); }
.stat.exp .bar { height: 6px; }
.stat[data-kind="exp"] b { color: var(--violet); }

.actions {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 12px 10px;
}

.act {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 9px 2px 7px;
  border-radius: 16px;
  transition: transform .18s ease, background .25s ease, opacity .25s ease;
}
.act:hover { background: rgba(255, 255, 255, .06); transform: translateY(-1px); }
.act:active { transform: scale(.95); }
.act-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 19px;
  background: linear-gradient(150deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .04));
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16);
}
.act-label { font-size: 11px; color: var(--ink-soft); letter-spacing: .04em; }
.act[data-action="feed"] .act-icon { box-shadow: 0 6px 16px rgba(255, 190, 120, .22); }
.act[data-action="play"] .act-icon { box-shadow: 0 6px 16px rgba(255, 150, 190, .2); }
.act[data-action="work"] .act-icon { box-shadow: 0 6px 16px rgba(160, 200, 255, .18); }
.act[data-action="nap"] .act-icon { box-shadow: 0 6px 16px rgba(150, 160, 255, .2); }
.act[data-action="pet"] .act-icon { box-shadow: 0 6px 16px rgba(255, 130, 170, .24); }
.act:disabled { opacity: .42; }
.act.cooling .act-icon { animation: coolPulse 1s linear infinite; }

.journal { padding: 14px 16px 10px; }
.journal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.journal h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .06em; color: var(--ink-soft); }
.idle-rate { font-size: 10.5px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }

.log { list-style: none; margin: 10px 0 4px; padding: 0; display: grid; gap: 7px; }
.log li {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-soft);
  animation: fadeIn .35s ease both;
}
.log .log-icon { font-size: 12px; opacity: .9; }
.log time { font-size: 10px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.empty-log { margin: 10px 0; font-size: 12px; color: var(--ink-dim); }

.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 0 4px;
  font-size: 10.5px;
  letter-spacing: .04em;
  color: var(--ink-dim);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .3); }
.dot.online { background: var(--mint); box-shadow: 0 0 10px rgba(143, 230, 196, .8); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 7, 26, .72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity .3s ease;
}
.overlay[hidden] { display: none; }
.overlay.hide { opacity: 0; pointer-events: none; }

.loading-card { display: grid; place-items: center; gap: 14px; text-align: center; }
.loading-card p { margin: 0; font-size: 12.5px; color: var(--ink-soft); letter-spacing: .06em; }
.orb {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6dd, #ffd469 55%, #f2a65a);
  box-shadow: 0 0 30px rgba(255, 212, 105, .55);
  animation: orbPulse 1.6s ease-in-out infinite;
}

.dialog {
  width: 100%;
  max-width: 348px;
  padding: 22px 20px 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: linear-gradient(165deg, #2b1c4b, #1b1136);
  box-shadow: 0 24px 60px rgba(6, 2, 20, .65);
  animation: dialogIn .32s cubic-bezier(.22, .9, .3, 1) both;
}
.dialog.small { max-width: 320px; }
.dialog h3 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.dialog h3 b { color: var(--gold); }
.dialog-sub { margin: 0; font-size: 12px; color: var(--ink-soft); }
.offline-list {
  list-style: none;
  margin: 14px 0 18px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .05);
  display: grid;
  gap: 8px;
  font-size: 12.5px;
}
.offline-list li { display: flex; justify-content: space-between; gap: 10px; color: var(--ink-soft); }
.offline-list b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.offline-list .plus b { color: var(--mint); }
.offline-list .minus b { color: var(--amber); }

.primary, .ghost {
  width: 100%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .04em;
  transition: transform .16s ease, filter .2s ease;
}
.primary {
  background: linear-gradient(140deg, #ffe7a9, var(--gold));
  color: #3a2350;
  box-shadow: 0 10px 24px rgba(255, 205, 110, .3);
}
.primary:active { transform: scale(.98); }
.ghost { background: rgba(255, 255, 255, .08); color: var(--ink-soft); border: 1px solid rgba(255, 255, 255, .1); }

.sheet-wrap { position: fixed; inset: 0; z-index: 22; display: grid; align-items: end; }
.sheet-wrap[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 5, 22, .6); backdrop-filter: blur(4px); animation: fadeIn .25s ease; }
.sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, #2b1c4b, #1a1033);
  border-top: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 -18px 44px rgba(5, 2, 16, .6);
  animation: sheetUp .3s cubic-bezier(.22, .9, .3, 1) both;
}
.sheet header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .03em; }
.close { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .08); color: var(--ink-soft); font-size: 12px; }
.foods { display: grid; gap: 9px; }
.food {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  text-align: left;
  transition: background .2s ease, transform .16s ease;
}
.food:hover:not(:disabled) { background: rgba(255, 255, 255, .09); }
.food:active:not(:disabled) { transform: scale(.99); }
.food:disabled { opacity: .45; }
.food .food-emoji { display: grid; place-items: center; font-size: 22px; width: 42px; height: 42px; border-radius: 13px; background: rgba(255, 255, 255, .06); }
.food .food-name { display: block; font-size: 13.5px; font-weight: 600; }
.food .food-note { display: block; margin-top: 2px; font-size: 11px; color: var(--ink-dim); }
.food .food-cost { font-size: 12px; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet-note { margin: 12px 2px 0; font-size: 10.5px; color: var(--ink-dim); }

.rename-wrap { position: fixed; inset: 0; z-index: 24; display: grid; place-items: center; padding: 24px; background: rgba(10, 5, 22, .68); backdrop-filter: blur(6px); }
.rename-wrap[hidden] { display: none; }
#renameInput {
  width: 100%;
  margin: 14px 0 16px;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .07);
  color: var(--ink);
  font-size: 15px;
  letter-spacing: .04em;
  outline: none;
}
#renameInput:focus { border-color: rgba(255, 212, 105, .6); box-shadow: 0 0 0 3px rgba(255, 212, 105, .14); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.2fr; gap: 9px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translate(-50%, 12px);
  max-width: min(88vw, 420px);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
  color: #2a1a45;
  background: linear-gradient(140deg, #fff3d1, #ffdca0);
  box-shadow: 0 14px 32px rgba(8, 3, 22, .5);
  opacity: 0;
  transition: opacity .24s ease, transform .24s ease;
}
.toast[hidden] { display: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: linear-gradient(140deg, #ffd9e2, #ffb3c6); }

@keyframes breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.012, 0.994); }
}
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.08); }
}
@keyframes tailWag {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-9deg); }
}
@keyframes hop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-14px) scale(1.03, 0.97); }
  62% { transform: translateY(0) scale(0.98, 1.03); }
  82% { transform: translateY(-5px) scale(1.01); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes heartUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.5) rotate(-8deg); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -74px) scale(1.15) rotate(10deg); }
}
@keyframes auraPulse {
  0%, 100% { transform: scale(1); opacity: .8; }
  50% { transform: scale(1.07); opacity: 1; }
}
@keyframes burst {
  0% { transform: scale(.9); filter: brightness(1); }
  40% { transform: scale(1.28); filter: brightness(1.6); }
  100% { transform: scale(1); filter: brightness(1); }
}
@keyframes floatZ {
  0% { opacity: 0; transform: translateY(6px); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-16px); }
}
@keyframes twinkle {
  0% { opacity: .75; transform: translateY(0); }
  100% { opacity: 1; transform: translateY(-3px); }
}
@keyframes coinPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes orbPulse {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.12); opacity: 1; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialogIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes sheetUp {
  from { transform: translateY(28px); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes coolPulse {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

@media (max-width: 360px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .pet-wrap { width: 74%; }
  .act-icon { width: 38px; height: 38px; font-size: 17px; }
  .stat { grid-template-columns: 56px 1fr 46px; }
}

@media (min-width: 720px) {
  .shell { padding-top: 26px; }
  body { background: #0c0819; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
