/* Zhuki — styles */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #0b1220;
  color: #e6ecff;
  min-height: 100vh;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ─── App scaffold ─── */
#app {
  min-height: 100vh;
  padding-bottom: 72px; /* room for tabbar */
  max-width: 760px;
  margin: 0 auto;
}
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, rgba(11,18,32,0.96), rgba(11,18,32,0.86));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid #1f2a44;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.topbar .brand img { width: 28px; height: 28px; }
.topbar .lang-switch {
  margin-left: auto; display: flex; gap: 4px; background: #15203a; border-radius: 999px; padding: 4px;
}
.topbar .lang-switch button {
  padding: 4px 10px; border: 0; background: transparent; color: #97a4c7; border-radius: 999px; font-weight: 600;
}
.topbar .lang-switch button.active { background: #2b3a64; color: #fff; }

/* ─── Tab bar (bottom) ─── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #0d1626;
  border-top: 1px solid #1f2a44;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  max-width: 760px; margin: 0 auto;
}
.tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 4px;
  background: transparent; border: 0; color: #97a4c7;
  font-size: 11px; line-height: 1.1; font-weight: 600;
  border-radius: 10px;
}
.tabbar button.active { color: #7cf17c; background: #0f1c34; }
.tabbar svg { width: 22px; height: 22px; fill: currentColor; }

/* ─── Search & filter row ─── */
.search-bar {
  padding: 10px 16px 6px;
  display: flex; gap: 8px;
}
.search-bar input[type="search"] {
  flex: 1; padding: 10px 14px; border-radius: 12px;
  background: #15203a; border: 1px solid #25335a; color: #e6ecff;
  outline: none;
}
.search-bar input[type="search"]:focus { border-color: #4264c4; }
.chip-row {
  display: flex; gap: 6px; padding: 8px 14px; overflow-x: auto;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: 6px 12px; border-radius: 999px;
  background: #15203a; color: #c2cdf0; font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
}
.chip.active { background: #2b3a64; color: #fff; border-color: #4264c4; }

/* ─── Catalog grid ─── */
.grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; padding: 12px 16px;
}
@media (min-width: 540px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.card {
  background: #15203a;
  border-radius: 16px;
  overflow: hidden;
  display: flex; flex-direction: column;
  position: relative;
  border: 1px solid #1f2a44;
  transition: transform 0.12s ease;
}
.card:active { transform: scale(0.98); }
.card .thumb {
  aspect-ratio: 4/3;
  background: #0d1626 center/cover no-repeat;
  position: relative;
}
.card .thumb.placeholder::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(124,241,124,0.04), rgba(98,141,255,0.04));
}
.card .thumb.dim::before {
  content: ""; position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  pointer-events: none;
}
.card .body { padding: 10px 12px 12px; }
.card .title { font-weight: 700; font-size: 14px; margin: 0 0 2px; }
.card .sub { font-size: 11px; color: #8a98c0; font-style: italic; margin: 0; }
.card .progress {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,0.55); color: #fff; backdrop-filter: blur(4px);
  font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 700;
}
.card .rarity {
  position: absolute; top: 8px; right: 8px;
  font-size: 11px; padding: 3px 8px; border-radius: 999px; font-weight: 700;
}
.rarity.common   { background: #1d4d2a; color: #b8f3c5; }
.rarity.uncommon { background: #4d381d; color: #f3d2b8; }
.rarity.rare     { background: #4d1d4a; color: #f3b8f0; }
.card.complete .body::after {
  content: "★"; position: absolute; right: 10px; bottom: 8px; color: #ffd14b; font-size: 18px;
}

/* ─── Detail view ─── */
.detail { padding-bottom: 16px; }
.detail .hero {
  width: 100%; aspect-ratio: 16/10;
  background: #0d1626 center/cover no-repeat;
  position: relative;
}
.detail .hero.dim::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11,18,32,0.0) 50%, rgba(11,18,32,0.7));
}
.detail .hero-meta {
  position: absolute; left: 16px; right: 16px; bottom: 12px;
}
.detail .hero-meta h1 { font-size: 22px; margin: 0 0 2px; text-shadow: 0 2px 8px rgba(0,0,0,0.55); }
.detail .hero-meta .sci { font-size: 13px; color: #b9c5e8; font-style: italic; text-shadow: 0 1px 4px rgba(0,0,0,0.7); }
.detail .body { padding: 16px; }
.detail .desc { font-size: 14px; line-height: 1.5; color: #d6dff5; margin: 0 0 12px; }
.kv { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin-bottom: 12px; }
.kv > div { color: #97a4c7; }
.kv > div b { color: #e6ecff; font-weight: 600; }

.section-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em;
  color: #97a4c7; margin: 16px 0 8px;
}

/* ─── Stage rows ─── */
.stage {
  display: flex; gap: 12px; padding: 10px;
  background: #15203a; border-radius: 14px; margin-bottom: 8px;
  border: 1px solid #1f2a44;
}
.stage .stage-thumb {
  width: 86px; height: 86px; flex-shrink: 0;
  background: #0d1626 center/cover no-repeat;
  border-radius: 10px; position: relative; overflow: hidden;
}
.stage .stage-thumb.dim::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
}
.stage .stage-thumb.user::after {
  content: "✓"; position: absolute; top: 4px; right: 4px;
  background: #1d4d2a; color: #b8f3c5; width: 20px; height: 20px;
  border-radius: 999px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.stage .stage-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stage .stage-name { font-weight: 700; font-size: 14px; margin: 0 0 2px; }
.stage .stage-desc { font-size: 12px; color: #97a4c7; margin: 0 0 8px; line-height: 1.4; }
.stage .stage-actions { display: flex; gap: 6px; margin-top: auto; }
.btn {
  border: 0; border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  background: #2b3a64; color: #fff;
}
.btn.primary { background: #4264c4; }
.btn.ghost   { background: transparent; color: #97a4c7; border: 1px solid #25335a; }
.btn.danger  { background: #4d1d1d; color: #f3b8b8; }
.btn:active { transform: scale(0.97); }

.file-input { display: none; }

/* ─── Pet card (collection) ─── */
.pet-card {
  background: linear-gradient(135deg, #1a2a4d, #15203a);
  border-radius: 18px; padding: 14px; margin-bottom: 12px;
  border: 1px solid #25335a; display: flex; gap: 14px;
  position: relative; overflow: hidden;
}
.pet-card .avatar {
  width: 92px; height: 92px; flex-shrink: 0;
  background: #0d1626 center/cover no-repeat;
  border-radius: 14px;
  box-shadow: 0 0 0 3px #25335a;
}
.pet-card .pet-body { flex: 1; min-width: 0; }
.pet-card .pet-name { font-weight: 800; font-size: 16px; margin: 0; }
.pet-card .pet-sci  { font-size: 11px; font-style: italic; color: #97a4c7; margin: 0 0 6px; }
.pet-card .pet-level {
  display: inline-block; font-size: 11px; font-weight: 700;
  background: #2b3a64; color: #fff; padding: 3px 9px; border-radius: 999px;
  margin-bottom: 6px;
}
.pet-card .pet-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
  font-size: 11px;
}
.pet-card .pet-stats .stat { display: flex; align-items: center; gap: 6px; color: #97a4c7; }
.pet-card .pet-stats .stat .bar { flex: 1; height: 4px; background: #25335a; border-radius: 999px; overflow: hidden; }
.pet-card .pet-stats .stat .bar > div { height: 100%; background: linear-gradient(90deg, #7cf17c, #4264c4); }
.pet-card .pet-stages {
  display: flex; gap: 4px; margin-top: 8px;
}
.pet-card .pet-stages .dot {
  width: 18px; height: 18px; border-radius: 999px;
  background: #25335a; border: 1px solid #1f2a44;
}
.pet-card .pet-stages .dot.on { background: #7cf17c; box-shadow: 0 0 8px rgba(124,241,124,0.4); }

/* ─── Terrarium ─── */
.terrarium {
  position: relative; height: calc(100vh - 200px); min-height: 360px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(124,241,124,0.06), transparent 60%),
    linear-gradient(180deg, #112340 0%, #0a1f12 70%, #0d2e16 100%);
  border-radius: 16px;
  margin: 12px 16px;
  overflow: hidden;
  border: 1px solid #1f2a44;
}
.terrarium::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 30%;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.45));
  pointer-events: none;
}
.terrarium .ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 12%;
  background: linear-gradient(180deg, #1a3d24, #0d2412);
  border-top: 2px solid #245533;
}
.terrarium .grass {
  position: absolute; left: 0; right: 0; bottom: 10%; height: 14%;
  pointer-events: none;
  background-image:
    radial-gradient(2px 14px at 20% 100%, #2d6b3a, transparent),
    radial-gradient(2px 18px at 45% 100%, #2d6b3a, transparent),
    radial-gradient(2px 12px at 70% 100%, #2d6b3a, transparent),
    radial-gradient(2px 16px at 88% 100%, #2d6b3a, transparent);
  opacity: 0.7;
}
.terrarium .critter {
  position: absolute; width: 44px; height: 44px;
  border-radius: 999px;
  background: #15203a center/cover no-repeat;
  box-shadow: 0 0 0 2px #fff, 0 6px 20px rgba(0,0,0,0.55);
  cursor: pointer;
  will-change: transform;
  transition: filter 0.2s;
}
.terrarium .critter:active { filter: brightness(1.2); }
.terrarium-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  text-align: center; color: #97a4c7; padding: 0 24px;
}
.terrarium-info {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 20px 0; font-size: 12px; color: #97a4c7;
}

/* ─── Food palette ─── */
.food-palette {
  display: flex; gap: 8px; padding: 8px 16px 0;
  justify-content: center; flex-wrap: wrap;
}
.food-btn {
  width: 56px; height: 56px;
  border-radius: 14px;
  border: 2px solid #25335a;
  background: #15203a;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; cursor: pointer; font-size: 24px; color: #c2cdf0;
  transition: transform 0.1s, border-color 0.1s;
  -webkit-user-select: none; user-select: none;
}
.food-btn .lbl { font-size: 9px; font-weight: 700; line-height: 1; }
.food-btn.active {
  border-color: #7cf17c;
  background: #1f3a2a;
  transform: scale(1.06);
  box-shadow: 0 0 16px rgba(124,241,124,0.4);
}
.food-btn:active { transform: scale(0.95); }

/* ─── Satiety bar inside critter ─── */
.terrarium .critter {
  /* override prev to allow stacking children */
  position: absolute; width: 48px; height: 48px;
  background-clip: padding-box;
  touch-action: none;
}
.terrarium .critter.hungry { filter: saturate(0.4) brightness(0.7); }
.terrarium .critter.dragging {
  box-shadow: 0 0 0 3px #7cf17c, 0 10px 30px rgba(0,0,0,0.6);
  z-index: 5;
}
.terrarium .critter.playing {
  animation: happy-bounce 0.6s ease;
}
.terrarium .critter.fed {
  animation: fed-pop 0.4s ease;
}
@keyframes happy-bounce {
  0%   { transform: translate(var(--tx,0px), var(--ty,0px)) scale(1); }
  40%  { transform: translate(var(--tx,0px), var(--ty,0px)) translateY(-22px) scale(1.18); }
  70%  { transform: translate(var(--tx,0px), var(--ty,0px)) scale(0.92); }
  100% { transform: translate(var(--tx,0px), var(--ty,0px)) scale(1); }
}
@keyframes fed-pop {
  0% { box-shadow: 0 0 0 0 rgba(255,210,90,0.0); }
  50% { box-shadow: 0 0 0 12px rgba(255,210,90,0.6); }
  100% { box-shadow: 0 0 0 0 rgba(255,210,90,0); }
}
.terrarium .satiety {
  position: absolute; left: 2px; right: 2px; bottom: -7px;
  height: 4px; border-radius: 2px;
  background: rgba(0,0,0,0.55);
  overflow: hidden;
}
.terrarium .satiety > div {
  height: 100%; background: linear-gradient(90deg, #ff7c7c, #7cf17c);
  transition: width 0.25s;
}

/* ─── Floating particles (hearts, sparkle) ─── */
.float-particle {
  position: absolute; font-size: 22px; pointer-events: none;
  animation: float-up 1.1s ease forwards;
  z-index: 10;
}
@keyframes float-up {
  from { opacity: 1; transform: translateY(0) scale(0.6); }
  to   { opacity: 0; transform: translateY(-50px) scale(1.4); }
}

.terrarium.feed-mode { cursor: crosshair; }
.terrarium.feed-mode .critter { cursor: pointer; }

/* ─── Settings & forms ─── */
.settings { padding: 16px; }
.settings h3 { font-size: 13px; text-transform: uppercase; color: #97a4c7; margin: 16px 0 8px; }
.settings .row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px; background: #15203a; border-radius: 12px; margin-bottom: 6px;
  border: 1px solid #1f2a44;
}
.settings .row label { color: #c2cdf0; }
.settings input, .settings select {
  background: #0d1626; border: 1px solid #25335a; color: #e6ecff;
  border-radius: 8px; padding: 8px 10px;
}
.form-grid { display: grid; gap: 8px; padding: 8px 0 0; }
.form-grid label { font-size: 12px; color: #97a4c7; display: block; margin-bottom: 4px; }
.form-grid input, .form-grid textarea, .form-grid select {
  width: 100%; background: #0d1626; border: 1px solid #25335a; color: #e6ecff;
  border-radius: 8px; padding: 8px 10px;
}
.form-grid textarea { min-height: 60px; resize: vertical; }
.form-actions { display: flex; gap: 8px; padding-top: 8px; }

/* ─── Modal ─── */
.modal-bg {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.7);
  display: grid; place-items: center;
  padding: 16px;
}
.modal {
  background: #15203a; border-radius: 18px;
  padding: 18px; width: 100%; max-width: 420px;
  max-height: 90vh; overflow-y: auto;
  border: 1px solid #25335a;
}
.modal h2 { margin: 0 0 12px; font-size: 18px; }

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: calc(82px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  background: #1a2a4d; color: #fff; padding: 10px 16px;
  border-radius: 999px; font-size: 13px; font-weight: 600;
  z-index: 80; box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  border: 1px solid #4264c4;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ─── Misc ─── */
.muted { color: #97a4c7; font-size: 12px; }
.center { text-align: center; padding: 24px; }
.spinner {
  width: 24px; height: 24px;
  border: 3px solid #25335a; border-top-color: #7cf17c;
  border-radius: 999px; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.flex-center { display: flex; justify-content: center; align-items: center; padding: 24px; }

.attrib { font-size: 10px; color: #5a6a8c; text-align: center; padding: 8px; }
.attrib a { color: #7a8ab2; }
