[hidden]{display:none!important}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }

/* ---- 撸撸我 · v2: the pet is the page ----
   The page is the floor the pet lies on: warm wood tones taken from the
   photos, cream type, no cards. A faint grain, a vignette and one warm light
   tie the UI to the photo. */
:root {
  --floor: #5b391d;
  --floor-deep: #3f2510;
  --card: rgba(40, 24, 11, .46);
  --ink: #f3e7d5;
  --ink-soft: #d3bfa3;
  --ink-faint: #a98f70;
  --line: rgba(243, 231, 213, .16);
  --line-strong: rgba(243, 231, 213, .3);
  --accent: #e2a85a;
  --accent-ink: #f0c27f;
  --serif: Georgia, "Songti SC", "Noto Serif CJK SC", "STSong", serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --glow-rgb: 255, 214, 140;          /* dog: warm gold */
}
body.cat { --glow-rgb: 255, 168, 92; } /* cat: honey orange */
body {
  font-family: var(--sans);
  background: radial-gradient(120% 70% at 30% 0%, #6e4626 0%, var(--floor) 45%, var(--floor-deep) 100%) fixed;
  color: var(--ink);
  display: flex; justify-content: center;
  -webkit-font-smoothing: antialiased;
  transition: background-color .4s;
}
/* Night is a lamp turned down, not a blue filter. */
body.night {
  --floor: #2c1b0e;
  --floor-deep: #170d05;
  --card: rgba(20, 11, 4, .55);
  --ink: #ecdcc3;
  --ink-soft: #bba487;
  --ink-faint: #8a7358;
  --accent: #e89a4e;
  --accent-ink: #f0b373;
}
body.night { background: radial-gradient(110% 60% at 18% 0%, #4a2c14 0%, var(--floor) 45%, var(--floor-deep) 100%) fixed; }
/* film grain over everything, very faint */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 100;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.app { width: 100%; max-width: 480px; padding: 14px 16px 28px; }
body.computer .app { max-width: 980px; }

/* ---- masthead: a one-line caption, not a frame ---- */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px 12px; }
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand-name { font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: .12em; }
.brand-sub { font-size: 9px; font-weight: 600; letter-spacing: .26em; color: var(--ink-faint); white-space: nowrap; }

.species-switch { display: flex; gap: 2px; flex: none; }
.species-btn {
  min-height: 36px; padding: 0 10px; display: flex; align-items: center; gap: 6px;
  background: none; border: 0; border-bottom: 1.5px solid transparent;
  color: var(--ink-faint); font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: color .2s, border-color .2s;
}
.species-btn svg { width: 16px; height: 16px; }
.species-btn.active { color: var(--ink); border-bottom-color: var(--accent); }

/* ---- stage: full bleed, no border, no shadow, no card ---- */
.stage-wrap { position: relative; margin: 0 -16px; }
.stage {
  position: relative; width: 100%; aspect-ratio: 3 / 4;
  overflow: hidden; touch-action: none;
  cursor: pointer; user-select: none; -webkit-user-select: none;
  background: var(--floor); outline: none;
}
/* Long-pressing a photo pets it instead of opening Save Photo (iOS). */
.stage, .stage img, .breed-btn img { -webkit-touch-callout: none; -webkit-user-drag: none; }
.stage:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
body.computer .stage { aspect-ratio: 16 / 10; }
@media (min-width: 481px) { .stage-wrap { margin: 0; } .stage { border-radius: 4px; } }
/* vignette: the edges fall into the floor */
.stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 6;
  background: radial-gradient(ellipse 78% 72% at 50% 46%, transparent 58%, rgba(24, 12, 3, .42) 100%);
}
.rotator {
  position: absolute; left: 50%; top: 50%; width: 100%; height: 100%;
  transform: translate(-50%, -50%);
}
.dog {
  position: relative; width: 100%; height: 100%;
  animation: breathe 3.2s ease-in-out infinite; transform-origin: 50% 55%;
  transition: opacity .22s ease, filter .4s ease;
}
.dog-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
/* the fur under the hand (app.js redraws this patch of the photo, dented) */
.fur-patch { position: absolute; left: 0; top: 0; pointer-events: none; }
/* where the hand passed, the fur catches the light for a moment */
.fur-trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: soft-light; }
.dog.switching { opacity: .35; }
body.night .dog { filter: brightness(.75) saturate(.9); }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.018); } }
.dog.excited { animation-duration: 1.8s; }
.dog.wag { animation: wag .5s ease-in-out 2; }
.dog.twitch { animation: twitch .3s ease-in-out 2; }
.dog.flick { animation: flick .4s ease-in-out 2; }
.dog.dodge { animation: dodge .35s ease-in-out 2; }
@keyframes twitch { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.02) rotate(-.6deg); } }
@keyframes wag { 0%, 100% { transform: scale(1.018) rotate(0deg); } 25% { transform: scale(1.018) rotate(.7deg); } 75% { transform: scale(1.018) rotate(-.7deg); } }
@keyframes flick { 0%, 100% { transform: scale(1.01) rotate(0deg); } 50% { transform: scale(1.01) rotate(.9deg); } }
@keyframes dodge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* one warm light from the upper left; stronger, like a lamp, at night */
.light {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(90% 70% at 12% 0%, rgba(255, 214, 160, .16), transparent 62%);
  mix-blend-mode: soft-light; transition: opacity .4s;
}
body.night .light {
  background: radial-gradient(80% 65% at 14% 4%, rgba(255, 190, 120, .5), transparent 66%);
  mix-blend-mode: soft-light;
}

/* ---- hand: hand.png turned 180° (fingers up), the palm on the pointer ----
   .hand-art is the hand's visible content (104 x 189 px of a 296 x 197 px
   image); the palm centre is at (46, 81) in it: keep PALM in app.js in step.
   app.js sets the transform each frame: translate to the palm, then turn the
   whole hand so the sleeve runs to a shoulder below the stage. */
.hand {
  position: absolute; left: 0; top: 0; z-index: 4; width: 104px; height: 189px;
  transform-origin: 46px 81px; pointer-events: none; will-change: transform;
}
.hand-art { position: absolute; inset: 0; transform-origin: 46px 81px; transition: transform .12s ease; }
.hand-art img {
  position: absolute; left: -103.7px; top: -8px; width: 295.8px; height: 197.2px;
  transform: rotate(180deg); filter: drop-shadow(0 2px 3px rgba(30, 14, 2, .3));
}
/* long enough to reach past the stage from anywhere; the stage clips it */
.sleeve {
  position: absolute; left: 16.5px; top: 186px; width: 57px; height: 1300px;
  background: #c3c3bf repeat-y 0 0;
}
/* a forearm is round: darker at both sides (texture built in app.js) */
.sleeve::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(40, 20, 5, .2), transparent 28%, transparent 68%, rgba(40, 20, 5, .24));
}
/* pressing into the fur: the hand sinks a little and its shadow tightens */
.hand.pressed .hand-art { transform: translateY(6px) scale(.965); }
.hand-shadow {
  position: absolute; left: -55px; top: -40px; width: 110px; height: 80px; z-index: 3;
  pointer-events: none; mix-blend-mode: multiply; will-change: transform;
}
.hand-shadow::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 18, 2, .42), rgba(40, 18, 2, 0));
  opacity: .7; transition: transform .12s ease, opacity .12s ease;
}
.hand-shadow.pressed::before { opacity: 1; transform: scale(.8); }
body.night .hand-art { filter: brightness(.75); }
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
/* warm light from the touch (spawned in app.js): a soft dot that drifts up
   and sways; a pat gives one wider bloom. Colour follows --glow-rgb. */
.glow, .warmth { position: absolute; border-radius: 50%; opacity: 0; }
.glow {
  width: var(--size, 14px); height: var(--size, 14px);
  background: radial-gradient(closest-side, rgba(255, 250, 238, .95), rgba(var(--glow-rgb), .7) 40%, rgba(var(--glow-rgb), 0));
  animation: glowRise var(--dur, 2.2s) cubic-bezier(.22, .6, .36, 1) forwards;
}
@keyframes glowRise {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  15% { opacity: var(--o, .7); }
  55% { transform: translate(calc(-50% + var(--sway, 0px)), calc(-50% + var(--rise, -120px) * .5)) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% - var(--sway, 0px) * .4), calc(-50% + var(--rise, -120px))) scale(.85); }
}
.warmth {
  width: 90px; height: 90px;
  background: radial-gradient(closest-side, rgba(255, 246, 228, .6), rgba(var(--glow-rgb), .28) 45%, rgba(var(--glow-rgb), 0));
  animation: warmth .9s ease-out forwards;
}
@keyframes warmth {
  from { opacity: .95; transform: translate(-50%, -50%) scale(.6); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}
@keyframes glowFade {
  0%, 100% { opacity: 0; transform: translate(-50%, -50%); }
  25% { opacity: var(--o, .7); }
}

.breed-name {
  position: absolute; left: 16px; bottom: 14px; z-index: 7; pointer-events: none;
  font-family: var(--serif); font-style: italic; font-size: 13px; letter-spacing: .06em;
  color: rgba(255, 244, 228, .86); text-shadow: 0 1px 6px rgba(0, 0, 0, .55);
}
/* toast and hint: a few words written on the photo, no pill */
.zone-toast, .hint {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 7;
  pointer-events: none; white-space: nowrap;
  font-family: var(--serif); font-style: italic; letter-spacing: .05em;
  color: #fff6e8; text-shadow: 0 1px 2px rgba(0, 0, 0, .75), 0 0 14px rgba(0, 0, 0, .65);
}
.zone-toast { top: 16px; font-size: 15px; animation: toastIn .25s ease-out; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -4px); } to { opacity: 1; transform: translate(-50%, 0); } }
.hint { bottom: 40px; font-size: 14px; transition: opacity .5s; }
.hint.gone { opacity: 0; }

/* ---- breeds: a strip of small film frames under the photo ---- */
.breeds {
  display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 12px 16px 6px;
}
.breeds::-webkit-scrollbar { display: none; }
.breed-item { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: none; }
.breed-btn {
  position: relative; width: 44px; height: 44px; border-radius: 3px; border: 0;
  overflow: visible; padding: 0; cursor: pointer; background: var(--floor-deep); flex: none;
  opacity: .72; transition: transform .18s ease, opacity .18s ease;
}
.breed-btn img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 3px; }
.breed-btn::after {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: -6px; height: 2px;
  border-radius: 2px; background: var(--accent); transform: scaleX(0); transition: transform .18s ease;
}
.breed-btn.active { opacity: 1; transform: scale(1.08); }
.breed-btn.active::after { transform: scaleX(1); }
.breed-meters {
  margin-top: 3px; font-family: var(--serif); font-size: 10px; color: var(--ink-faint);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}

/* ---- panel: a quiet bar, the rest folds away ---- */
.panel { margin-top: 10px; border-top: 1px solid var(--line); }
.bar {
  list-style: none; display: flex; align-items: center; gap: 18px;
  padding: 12px 2px 10px; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.bar::-webkit-details-marker { display: none; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat-num {
  font-family: var(--serif); font-size: 20px; font-weight: 600;
  font-variant-numeric: tabular-nums; line-height: 1.15; color: var(--ink);
}
.stat-label { margin-top: 2px; font-size: 10px; letter-spacing: .16em; color: var(--ink-faint); }
.happy { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.happy-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.happy-top .stat-label { margin: 0; }
.happy-label { font-family: var(--serif); font-size: 14px; color: var(--ink); display: inline-block; }
.stroke-count { letter-spacing: .06em; color: var(--ink-soft); font-variant-numeric: tabular-nums; display: inline-block; }
/* a label that just changed swells once (setText in app.js) */
.bump { animation: bump .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 0% { transform: scale(1); } 35% { transform: scale(1.16); color: var(--accent-ink); } 100% { transform: scale(1); } }
.happy-bar { display: block; height: 2px; border-radius: 99px; background: var(--line); overflow: hidden; }
.happy-fill { display: block; height: 100%; width: 0%; background: var(--accent); transition: width .3s ease; }
.more { width: 28px; height: 28px; flex: none; color: var(--ink-faint); display: grid; place-items: center; transition: transform .25s ease; }
.more svg { width: 18px; height: 18px; }
.panel[open] .more { transform: rotate(180deg); }
.panel-body { padding: 4px 2px 6px; }
.stats { display: flex; gap: 18px; padding: 6px 0 14px; }
.stats .stat { flex: 1; }

.achievements { padding: 12px 0 14px; border-top: 1px solid var(--line); }
.ach-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.ach-title { font-size: 10px; letter-spacing: .16em; color: var(--ink-faint); }
.streak { font-family: var(--serif); font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.ach-row { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.ach { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; color: var(--ink-faint); }
.ach svg { width: 13px; height: 13px; }
.ach.done { color: var(--ink); }
.ach.done svg { color: var(--accent); }

/* ---- controls ---- */
.controls { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.ctl {
  min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer;
  flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; transition: transform .15s ease, background .2s ease, border-color .2s ease;
}
.ctl svg { width: 17px; height: 17px; flex: none; }
.ctl.share { background: var(--ink); border-color: var(--ink); color: var(--floor-deep); }
.ctl:active { transform: scale(.97); }

/* ---- share modal ---- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 11, 4, .7); padding: 16px;
}
.modal-card { background: var(--floor-deep); border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-width: 360px; width: 100%; }
.modal-card img { width: 100%; border-radius: 4px; display: block; }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; }
.modal-actions .ctl { text-decoration: none; }

/* ---- onboarding ---- */
.onboard {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(20, 11, 4, .66); padding: 20px;
}
.onboard-card {
  background: var(--floor-deep); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 26px 24px; max-width: 340px; width: 100%;
}
.onboard-eyebrow { font-size: 10px; font-weight: 600; letter-spacing: .24em; color: var(--accent); margin-bottom: 10px; }
.onboard-card h2 { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: .03em; margin-bottom: 18px; }
.onboard-steps { list-style: none; margin: 0 0 20px; display: grid; gap: 0; }
.onboard-steps li {
  display: flex; gap: 14px; align-items: baseline;
  padding: 12px 0; font-size: 15px; line-height: 1.55;
  border-top: 1px solid var(--line);
}
.onboard-steps li:last-child { border-bottom: 1px solid var(--line); }
.step-num { font-family: var(--serif); font-size: 15px; font-weight: 700; color: var(--accent); flex: none; }
.onboard-card .ctl { width: 100%; }

@media (max-width: 390px) {
  .app { padding: 12px 12px 24px; }
  .stage-wrap, .breeds { margin-left: -12px; margin-right: -12px; }
  .breeds { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .dog, .dog.wag, .dog.twitch, .dog.flick, .dog.dodge, .bump, .zone-toast { animation: none; }
  .fur-patch, .fur-trail { display: none; }
  /* the light stays where it was born and only fades in and out */
  .glow { animation: glowFade var(--dur, 2.2s) ease forwards; }
  .warmth { animation: glowFade 1.4s ease forwards; }
  * { transition-duration: .01s !important; }
}
