/* Beast Mode Buddies — colored-pencil sketchbook UI.
   Everything is drawn in the same sketchbook as the buddy: wobbly pencil
   borders, hatched pencil fills, graphite ink on plain white paper. */

:root {
  --ink: #494a54;          /* warm graphite pencil */
  --ink-soft: #8a8c99;
  --blue: #5c77bb;         /* hedgehog-quill periwinkle */
  --blue-deep: #3e5590;
  --amber: #e9a23b;        /* energy pencil */
  --amber-soft: #f6dcae;
  --rose: #d97b8f;         /* bond pencil */
  --rose-soft: #f3d3da;
  --paper: #ffffff;
  --line: 2px solid var(--ink);
  --hand: "Patrick Hand", "Segoe Print", cursive;
  --body: "Nunito", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 14px;
  line-height: 1.45;
}

#app { max-width: 420px; margin: 0 auto; padding: 12px 14px 20px; }

.center { text-align: center; }

/* ---------- pencil primitives ---------- */

.card {
  background: var(--paper);
  border: var(--line);
  /* uneven radii = hand-drawn wobble */
  border-radius: 14px 10px 15px 9px / 10px 15px 9px 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

h1, h2, .hand { font-family: var(--hand); font-weight: 400; letter-spacing: .02em; }

.eyebrow {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-soft);
}

button {
  font-family: var(--hand); font-size: 17px; color: var(--ink);
  background: var(--paper); border: var(--line); cursor: pointer;
  border-radius: 12px 9px 13px 8px / 9px 13px 8px 12px;
  padding: 7px 18px;
  transition: transform .12s ease, background .12s ease;
}
button:hover { background: #f2f5fc; transform: rotate(-1deg) scale(1.03); }
button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 2px;
}
button.primary { background: var(--blue); border-color: var(--blue-deep); color: #fff; }
button.primary:hover { background: var(--blue-deep); }
button:disabled { opacity: .45; cursor: default; transform: none; }

input[type="text"] {
  font-family: var(--hand); font-size: 18px; color: var(--ink);
  border: var(--line); border-radius: 10px 13px 9px 12px / 13px 9px 12px 10px;
  padding: 6px 12px; width: 100%;
}

/* ---------- stage (the buddy) ---------- */

.stage { position: relative; padding: 18px 8px 6px; }

.buddy-wrap { position: relative; width: 190px; height: 190px; margin: 0 auto; }

.aura {
  position: absolute; inset: -12px; border-radius: 50%;
  background: radial-gradient(circle, rgba(233,162,59,.35) 0%, rgba(233,162,59,0) 65%);
  opacity: 0; transition: opacity 1.2s ease;
}
.aura.on { opacity: 1; animation: aura-pulse 3.2s ease-in-out infinite; }
@keyframes aura-pulse { 50% { transform: scale(1.06); } }

.buddy {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  transform-origin: 50% 90%;
}
.buddy img { width: 100%; height: 100%; object-fit: contain; }
.buddy .placeholder {
  font-size: 110px; line-height: 1;
  filter: saturate(.85);
}

/* mood motion — same still, different life */
.mood-content  .buddy { animation: breathe 4s ease-in-out infinite; }
.mood-excited  .buddy { animation: bounce 1.1s cubic-bezier(.36,.07,.19,.97) infinite; }
.mood-sleepy   .buddy { animation: sway 5.5s ease-in-out infinite; }
.mood-cozy     .buddy { animation: breathe 7s ease-in-out infinite; transform: scale(.96); }

@keyframes breathe { 50% { transform: scaleY(.975) scaleX(1.01); } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 35% { transform: translateY(-10px) scaleY(1.03); } 55% { transform: translateY(0) scaleY(.97); } }
@keyframes sway { 50% { transform: rotate(2.5deg) scaleY(.98); } }

.buddy.celebrate { animation: hop .55s cubic-bezier(.36,.07,.19,.97) 2 !important; }
@keyframes hop {
  0%,100% { transform: translateY(0) rotate(0); }
  40% { transform: translateY(-16px) rotate(-3deg); }
  70% { transform: translateY(0) scaleY(.94); }
}

.zzz {
  position: absolute; top: 6px; right: 14px; font-family: var(--hand);
  color: var(--ink-soft); font-size: 20px; opacity: 0;
}
.mood-sleepy .zzz, .mood-cozy .zzz { opacity: 1; animation: zfloat 3s ease-in-out infinite; }
@keyframes zfloat { 50% { transform: translateY(-6px); opacity: .55; } }

.pet-name { font-size: 26px; margin-top: 2px; }
.stage-chip {
  display: inline-block; font-size: 12px; font-weight: 800;
  color: var(--blue-deep); border: 2px solid var(--blue);
  border-radius: 999px; padding: 1px 10px; margin-top: 2px;
  text-transform: capitalize;
}
.mood-line { color: var(--ink-soft); font-size: 13px; margin-top: 4px; min-height: 1.4em; }

/* floating reward chips */
.floater {
  position: absolute; left: 50%; top: 20%;
  font-family: var(--hand); font-size: 22px; color: var(--amber);
  text-shadow: 0 0 2px #fff;
  animation: float-up 1.6s ease-out forwards; pointer-events: none;
}
.floater.bond { color: var(--rose); }
@keyframes float-up {
  0% { transform: translate(-50%, 0) scale(.7); opacity: 0; }
  20% { opacity: 1; transform: translate(-50%, -12px) scale(1.1); }
  100% { transform: translate(-50%, -70px) scale(1); opacity: 0; }
}

/* confetti — pencil shavings */
.confetti {
  position: absolute; width: 8px; height: 12px; top: -10px;
  border-radius: 2px 5px 2px 5px; opacity: .9; pointer-events: none;
  animation: confetti-fall 1.8s ease-in forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(230px) rotate(540deg); opacity: 0; }
}

/* ---------- stat bars: colored-pencil hatching ---------- */

.stat { margin-bottom: 10px; }
.stat-head { display: flex; justify-content: space-between; align-items: baseline; }
.stat-value { font-family: var(--hand); font-size: 18px; }

.bar {
  height: 16px; border: var(--line); background: var(--paper);
  border-radius: 9px 12px 8px 11px / 12px 8px 11px 9px;
  overflow: hidden; margin-top: 3px;
}
.bar > .fill {
  height: 100%; width: 0;
  transition: width .8s cubic-bezier(.22,1,.36,1);
  /* diagonal pencil strokes */
  background:
    repeating-linear-gradient(115deg,
      var(--stroke) 0 3px, transparent 3px 5.5px),
    var(--wash);
}
.fill.energy { --stroke: var(--amber); --wash: var(--amber-soft); }
.fill.bond   { --stroke: var(--rose);  --wash: var(--rose-soft); }

.bond-note { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }

/* ---------- streak ---------- */

.streak-row { display: flex; align-items: center; gap: 10px; }
.streak-count { font-family: var(--hand); font-size: 30px; line-height: 1; }
.streak-label { font-size: 12px; color: var(--ink-soft); }
.shields { margin-left: auto; display: flex; gap: 3px; font-size: 16px; }
.shields .dim { opacity: .22; }
.calibrating-note { font-size: 12px; color: var(--ink-soft); margin-top: 6px; }

/* ---------- onboarding ---------- */

.species-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0; }
.species-pick {
  font-size: 30px; padding: 8px 2px 4px; text-align: center;
  border: 2px solid transparent; border-radius: 12px; cursor: pointer;
  background: none; transition: transform .12s ease;
}
.species-pick small { display: block; font-size: 10px; font-weight: 800; color: var(--ink-soft); text-transform: capitalize; }
.species-pick:hover { transform: scale(1.1) rotate(-2deg); }
.species-pick.selected { border: 2px solid var(--blue); background: #f2f5fc; }

/* ---------- banner moments (milestones, stage ups) ---------- */

.banner {
  border-color: var(--amber);
  background: linear-gradient(0deg, #fff8ec, #fff8ec);
  animation: banner-in .5s cubic-bezier(.22,1,.36,1);
}
@keyframes banner-in { from { transform: translateY(-8px) scale(.97); opacity: 0; } }
.banner h2 { font-size: 22px; }

/* ---------- admin ---------- */

.admin-row { text-align: right; margin-bottom: 8px; }
.admin-row button { font-size: 13px; padding: 3px 10px; color: var(--ink-soft); }

.admin-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.admin-table th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); text-align: left; padding-bottom: 4px;
}
.admin-table td { padding: 3px 4px 3px 0; text-transform: capitalize; }
.admin-table input[type="number"] {
  width: 58px; font-family: var(--hand); font-size: 15px; color: var(--ink);
  border: 2px solid var(--ink); border-radius: 8px 10px 7px 9px; padding: 2px 6px;
}

textarea {
  width: 100%; font-family: var(--hand); font-size: 15px; color: var(--ink);
  border: var(--line); border-radius: 10px 13px 9px 12px / 13px 9px 12px 10px;
  padding: 6px 12px; resize: vertical;
}

/* ---------- misc states ---------- */

.state-card p { margin-top: 6px; color: var(--ink-soft); }

.pencil-spinner {
  width: 30px; height: 30px; margin: 10px auto;
  border: 3px solid var(--ink); border-right-color: transparent;
  border-radius: 50% 45% 52% 47%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
