:root {
  --bg:           #0b1220;
  --bg-2:         #111827;
  --surface:      #131b2d;
  --surface-2:    #1c2742;
  --border:       #233047;
  --text:         #e6edf6;
  --text-soft:    #9aa9c1;
  --text-mute:    #6b7891;
  --cyan:         #06b6d4;
  --cyan-2:       #22d3ee;
  --cyan-glow:    rgba(6,182,212,.35);
  --gold:         #fbbf24;
  --green:        #10b981;
  --green-2:      #34d399;
  --red:          #ef4444;
  --radius:       14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--cyan-2); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1.1rem 6rem;
}

/* ─── TOP BAR ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
  gap: .8rem;
}
.brand {
  display: flex; align-items: center; gap: .55rem;
  font-weight: 800; font-size: 1.4rem; letter-spacing: -.02em;
}
.brand-g {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--cyan-2));
  color: #06222b; font-weight: 900;
  box-shadow: 0 4px 14px var(--cyan-glow);
}
.brand-name { color: var(--text); }
.counters { display: flex; gap: .55rem; flex-wrap: wrap; }
.counter {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  font-size: .92rem;
}
.counter .ico { font-size: 1.05rem; }
.counter.coins span:last-child  { color: var(--gold); }
.counter.cash  span:last-child  { color: var(--green-2); }
.counter.level span:last-child  { color: var(--text); margin-left: .25rem; }

/* ─── PET CARD ────────────────────────────────────────────── */
.pet-card {
  display: flex; flex-direction: column; align-items: center;
  margin: 1.5rem 0 1.2rem;
}
.pet-ring {
  width: 280px; height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(6,182,212,.18) 0%, rgba(6,182,212,.06) 60%, transparent 70%);
  border: 3px solid var(--cyan);
  box-shadow:
    0 0 0 6px rgba(6,182,212,.10),
    0 0 40px 4px var(--cyan-glow),
    inset 0 0 30px rgba(6,182,212,.12);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
  animation: ring-pulse 4s ease-in-out infinite;
}
@media (max-width: 480px) {
  .pet-ring { width: 230px; height: 230px; }
}
.pet-ring img,
.pet-ring video {
  width: 78%; height: 78%;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.45));
  /* The .webm itself has the bobbing animation embedded, so no CSS bob */
  cursor: pointer;
  transition: transform .15s ease;
  -webkit-user-select: none;
  user-select: none;
}
.pet-ring video.petting { transform: scale(1.04); }
.pet-ring video.celebrate { transform: scale(1.08); }
/* heart pop-up over the pet */
.heart-pop {
  position: absolute;
  font-size: 1.8rem;
  pointer-events: none;
  animation: heart-up 1.1s ease-out forwards;
  z-index: 5;
}
@keyframes heart-up {
  0%   { opacity: 0; transform: translate(-50%, 0)    scale(.5); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -90px) scale(1.4); }
}
.pet-ring { position: relative; overflow: hidden; }
@keyframes ring-pulse {
  0%,100% { box-shadow: 0 0 0 6px rgba(6,182,212,.10), 0 0 40px 4px rgba(6,182,212,.35), inset 0 0 30px rgba(6,182,212,.12); }
  50%     { box-shadow: 0 0 0 6px rgba(6,182,212,.16), 0 0 60px 8px rgba(6,182,212,.50), inset 0 0 30px rgba(6,182,212,.18); }
}
/* Mood variants */
html[data-mood="sick"]    .pet-ring video,
html[data-mood="worried"] .pet-ring video { filter: drop-shadow(0 8px 14px rgba(0,0,0,.5)) saturate(.7); }
html[data-mood="dead"]    .pet-ring video { filter: drop-shadow(0 8px 14px rgba(0,0,0,.5)) grayscale(1) opacity(.5); }

.pet-name {
  font-size: 2rem; font-weight: 700; letter-spacing: -.01em;
  margin: 0; color: var(--text);
}
.pet-mood {
  font-size: 1.6rem; margin-top: .15rem;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.4));
}

/* ─── STATS ───────────────────────────────────────────────── */
.stats {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.4rem;
}
.stat {
  display: grid;
  grid-template-columns: 110px 1fr 90px;
  align-items: center;
  gap: .9rem;
  padding: .45rem 0;
}
.stat-label {
  display: flex; align-items: center; gap: .45rem;
  font-weight: 600; font-size: .95rem;
  color: var(--text-soft);
}
.stat-icon { font-size: 1.1rem; }
.bar {
  height: 14px;
  background: rgba(255,255,255,.04);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.fill {
  height: 100%;
  border-radius: 999px;
  transition: width .5s cubic-bezier(.4,0,.2,1);
}
.fill-vida   { background: linear-gradient(90deg, #ef4444, #f97316); box-shadow: 0 0 12px rgba(239,68,68,.5); }
.fill-comida { background: linear-gradient(90deg, #fbbf24, #f59e0b); box-shadow: 0 0 12px rgba(251,191,36,.4); }
.fill-xp     { background: linear-gradient(90deg, #06b6d4, #22d3ee); box-shadow: 0 0 12px rgba(6,182,212,.5); }
.stat-value {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-size: .9rem;
  color: var(--text);
  font-weight: 600;
}
.stat-value span { color: var(--text); }

/* ─── ACTIONS GRID ────────────────────────────────────────── */
.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .65rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 540px) {
  .actions { grid-template-columns: repeat(2, 1fr); }
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .5rem;
  padding: 1rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 700; font-size: .98rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  text-align: left;
}
.btn .bi { font-size: 1.15rem; }
.btn:hover  { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active { transform: translateY(0); filter: brightness(.95); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary       { background: linear-gradient(135deg, #06b6d4, #0891b2); color:#001218; border:0; box-shadow: 0 6px 18px -4px var(--cyan-glow); }
.btn-primary-light { background: linear-gradient(135deg, #22d3ee, #06b6d4); color:#001218; border:0; box-shadow: 0 6px 18px -4px var(--cyan-glow); }
.btn-secondary     { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-dark          { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-success       { background: linear-gradient(135deg, #10b981, #059669); color: #00130b; border: 0; box-shadow: 0 6px 18px -4px rgba(16,185,129,.4); }
.btn-cyan          { background: linear-gradient(135deg, #22d3ee, #06b6d4); color: #001218; border: 0; box-shadow: 0 6px 18px -4px var(--cyan-glow); }

/* ─── FOOTER ──────────────────────────────────────────────── */
.foot {
  display: flex; align-items: center; gap: 1.3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--text-mute);
  flex-wrap: wrap;
}
.foot a { color: var(--text-mute); cursor: pointer; }
.foot a:hover { color: var(--text); }
.foot .copyright { margin-left: auto; }

/* ─── TOAST ───────────────────────────────────────────────── */
#toast-stack {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  z-index: 9999; pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .6rem 1.2rem;
  font-weight: 600;
  font-size: .92rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  animation: toast-in .25s ease-out, toast-out .3s ease-in 2.7s forwards;
}
.toast.ok  { border-color: #10b981; color: #6ee7b7; }
.toast.err { border-color: #ef4444; color: #fca5a5; }
.toast.info{ border-color: var(--cyan); color: var(--cyan-2); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px); } }

/* ─── MODALS ──────────────────────────────────────────────── */
.modal {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 1.4rem;
  max-width: 460px;
  width: calc(100% - 2rem);
}
.modal::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }
.modal h2 { margin: 0 0 1rem; font-size: 1.3rem; }
.modal .muted { color: var(--text-mute); font-size: .9rem; }
.modal label { display: block; margin: 1rem 0; }
.modal input[type=number], .modal input[type=text] {
  display: block; width: 100%;
  margin-top: .3rem;
  padding: .7rem .9rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
}
.modal-actions { display: flex; gap: .5rem; margin-top: 1rem; justify-content: flex-end; }

.shop-item {
  display: grid; grid-template-columns: 38px 1fr auto auto;
  align-items: center; gap: .8rem;
  padding: .7rem .85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: .55rem;
}
.shop-item .ico  { font-size: 1.5rem; }
.shop-item .name { font-weight: 600; }
.shop-item .info { color: var(--text-mute); font-size: .82rem; }
.shop-item .price { color: var(--gold); font-weight: 700; }
.shop-item button { background: var(--cyan); color: #001218; border: 0; padding: .5rem .9rem; border-radius: 10px; font-weight: 700; }
.shop-item button:disabled { background: var(--border); color: var(--text-mute); }

/* ─── AUTH PAGE ───────────────────────────────────────────── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.8rem;
}
.auth-logo {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  margin-bottom: 1.5rem;
}
.auth-logo img { width: 42px; height: 42px; }
.auth-logo span { font-weight: 800; font-size: 1.2rem; }
.auth-card h1 { margin: 0 0 1rem; font-size: 1.5rem; text-align: center; }
.auth-card label {
  display: block; margin-bottom: 1rem;
  font-size: .9rem; color: var(--text-soft);
}
.auth-card input {
  display: block; width: 100%;
  margin-top: .35rem;
  padding: .75rem .9rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
}
.auth-card input:focus { outline: 0; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(6,182,212,.25); }
.auth-card .btn { width: 100%; margin-top: .5rem; }
.auth-foot { text-align: center; color: var(--text-mute); margin: 1.2rem 0 0; font-size: .9rem; }
.alert.err { background: rgba(239,68,68,.12); border: 1px solid var(--red); color: #fca5a5; padding: .65rem .85rem; border-radius: 10px; margin-bottom: 1rem; font-size: .9rem; }
