:root {
  --bg: #f7f1e3;
  --bg-card: #ffffff;
  --fg: #2a2a2a;
  --muted: #7a7a7a;
  --accent: #f27e7e;
  --accent-dark: #d94f4f;
  --ok: #7fb77e;
  --warn: #e2b04a;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
  --tab-h: 64px;
  --radius: 14px;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  padding: 16px 16px calc(var(--tab-h) + 32px);
  min-height: 100vh;
  box-sizing: border-box;
}

.view.hidden,
.hidden {
  display: none !important;
}

/* ---------- Cat view ---------- */
.cat-stage {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.sprite {
  width: 160px;
  height: 160px;
  background-repeat: no-repeat;
  background-position: 0 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background-size: auto 160px;
}

.cat-header {
  text-align: center;
}
.cat-header h1 {
  margin: 0;
  font-size: 22px;
}
.cat-meta {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}
.breed {
  color: var(--muted);
  text-transform: capitalize;
  font-size: 13px;
}
.mood {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f0ece3;
  text-transform: capitalize;
}

.needs {
  margin-top: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.need {
  display: grid;
  grid-template-columns: 90px 1fr 44px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.need-bar {
  position: relative;
  height: 10px;
  background: #eee3cf;
  border-radius: 6px;
  overflow: hidden;
}
.need-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--ok), var(--warn));
  border-radius: 6px;
  transition: width 200ms ease-out;
}
.need-value {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.details {
  margin-top: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.details-toggle {
  width: 100%;
  background: transparent;
  border: none;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
}
.details-toggle .details-chevron {
  color: var(--muted);
  transition: transform 150ms ease;
  display: inline-block;
}
.details-toggle.open .details-chevron {
  transform: rotate(90deg);
}
.details-body {
  padding: 4px 16px 14px;
  display: grid;
  gap: 10px;
  border-top: 1px solid #f0e4cb;
}
.details-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding-top: 10px;
}
.details-fact {
  background: #f7f1e3;
  border-radius: 999px;
  padding: 3px 10px;
}
.personality {
  display: grid;
  gap: 8px;
}
.need-bar-fill.alt {
  background: linear-gradient(90deg, #a8a4e0, #e3a2c6);
}

.actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.btn {
  appearance: none;
  border: none;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 4px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 80ms ease, background 120ms;
}
.btn:active {
  transform: scale(0.96);
}
.btn.primary {
  background: var(--accent);
  color: white;
}
.btn.primary:active {
  background: var(--accent-dark);
}
.btn.ghost {
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

.adopt {
  margin-top: 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}
.adopt p {
  margin: 0 0 12px;
}

.feed-picker {
  margin-top: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.feed-picker h3 {
  margin: 0 0 10px;
  font-size: 15px;
}
.picker-items {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}
.picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f7f1e3;
  cursor: pointer;
}

/* ---------- Shop view ---------- */
.shop-header,
.me-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.shop-header h2,
.me-header h2 {
  margin: 0;
}
.wallet-pill {
  background: var(--bg-card);
  border-radius: 999px;
  padding: 6px 12px;
  box-shadow: var(--shadow);
  font-weight: 600;
}

.shop-items {
  display: grid;
  gap: 10px;
}
.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.shop-item-name {
  font-size: 16px;
  text-transform: capitalize;
}
.shop-item-buy {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}
.shop-item-buy:active {
  background: var(--accent-dark);
}

/* ---------- Me view ---------- */
.wallet-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.wallet-label {
  color: var(--muted);
  font-size: 13px;
}
.wallet-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 4px;
}

.inventory-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.inv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.inv-header h3 {
  margin: 0;
}
.inv-header span {
  color: var(--muted);
  font-size: 13px;
}
.inv-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.inv-cell {
  aspect-ratio: 1;
  background: #f7f1e3;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.inv-empty {
  color: var(--muted);
  font-size: 13px;
  grid-column: 1 / -1;
  text-align: center;
  padding: 12px 0;
}

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--tab-h);
  background: var(--bg-card);
  border-top: 1px solid #eee0c8;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.04);
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 2px;
}
.tab:first-child {
  font-size: 22px;
}
.tab span {
  font-size: 11px;
}
.tab {
  font-size: 20px;
}
.tab.active {
  color: var(--accent-dark);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tab-h) + 16px);
  background: rgba(30, 30, 30, 0.92);
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 10;
  max-width: 80%;
  text-align: center;
}
