:root {
  --ink: #4b3a33;
  --ink-soft: #7a6a62;
  --paper: #fff8ef;
  --card: #ffffff;
  --coral: #ff7a59;
  --coral-dark: #e85d3c;
  --blue: #4dabf7;
  --blue-dark: #1c7ed6;
  --green: #51cf66;
  --green-dark: #2f9e44;
  --red: #e5484d;
  --yellow: #ffd43b;
  --shadow: 0 4px 0 rgba(75, 58, 51, .18);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; -webkit-touch-callout: none; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Fredoka', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  font-size: 18px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
.hidden { display: none !important; }
.ico { width: 100%; height: 100%; display: block; overflow: visible; }

/* ---------- Skärmar ---------- */
#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Knappar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 3px solid var(--ink); border-radius: 999px;
  background: var(--coral); color: #fff;
  padding: 10px 22px; font-weight: 600; font-size: 1rem;
  box-shadow: var(--shadow); transition: transform .1s;
  text-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(75,58,51,.18); }
.btn:disabled { background: #ccc; cursor: not-allowed; }
.btn.big { font-size: 1.3rem; padding: 14px 34px; }
.btn.blue { background: var(--blue); }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.white { background: #fff; color: var(--ink); text-shadow: none; }
.btn .ico, .btn svg { width: 1.4em; height: 1.4em; flex: none; }

.icon-btn {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid var(--ink); background: #fff; padding: 8px;
  box-shadow: var(--shadow); flex: none;
}
.icon-btn:active { transform: translateY(3px); box-shadow: none; }

/* ---------- Toppfält ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #fff;
  border-bottom: 3px solid var(--ink); z-index: 5; flex: none;
}
.topbar h2 { margin: 0; font-size: 1.3rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.35rem; flex: 1; min-width: 0; }
.logo .ico { width: 38px; height: 38px; flex: none; }
.logo span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff4d6; border: 3px solid var(--ink); border-radius: 999px;
  padding: 3px 12px 3px 5px; font-weight: 700;
}
.pill .ico { width: 26px; height: 26px; }
.top-actions { display: flex; gap: 8px; }
.top-actions .btn { padding: 8px 14px; }

/* ---------- Start ---------- */
#screen-start {
  align-items: center; justify-content: center; text-align: center;
  background: linear-gradient(#bfe6ff, #fff8ef 70%);
  padding: 16px;
}
.start-logo { width: min(140px, 30vw); margin: 0 auto; animation: bob 2.4s ease-in-out infinite; }
.start-title { font-size: clamp(2.4rem, 9vw, 4.2rem); margin: 6px 0 0; font-weight: 700; color: var(--coral); text-shadow: 3px 3px 0 var(--ink); letter-spacing: 1px; }
.start-sub { font-size: 1.15rem; color: var(--ink-soft); margin: 4px 0 18px; }
.parade { display: flex; justify-content: center; gap: 0; margin: 0 auto 22px; max-width: 760px; width: 100%; }
.parade > div { width: 12%; max-width: 110px; min-width: 0; animation: bob 2s ease-in-out infinite; }
.parade > div:nth-child(2n) { animation-delay: -.6s; }
.parade > div:nth-child(3n) { animation-delay: -1.2s; }
.start-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* ---------- Skaffa djur ---------- */
.adopt-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.adopt-hint { margin: 0; color: var(--ink-soft); text-align: center; }
.species-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; width: 100%; max-width: 980px; }
.species-card {
  background: #fff; border: 3px solid var(--ink); border-radius: var(--radius);
  padding: 8px 6px 10px; box-shadow: var(--shadow); text-align: center; font-weight: 600;
}
.species-card .animal { width: 100%; aspect-ratio: 1; }
.species-card.selected { background: #fff0c2; outline: 4px solid var(--coral); outline-offset: 2px; }
.adopt-panel {
  width: 100%; max-width: 620px; background: #fff; border: 3px solid var(--ink); border-radius: 24px;
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.adopt-preview { width: min(220px, 55vw); aspect-ratio: 1; background: radial-gradient(#e3f6ff 55%, transparent 56%); border-radius: 50%; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.swatch {
  border: 3px solid var(--ink); border-radius: 999px; background: #fff;
  padding: 4px 12px 4px 4px; display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem;
}
.swatch i { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); display: block; }
.swatch.selected { background: #fff0c2; outline: 3px solid var(--coral); }
.name-row { display: flex; gap: 8px; width: 100%; max-width: 380px; }
.name-row input, .text-input {
  flex: 1; min-width: 0; border: 3px solid var(--ink); border-radius: 14px; padding: 10px 14px; font-size: 1.2rem;
  background: #fffdf8; color: var(--ink);
}
.label { font-weight: 600; margin: 0; }

/* ---------- Gården ---------- */
.garden { flex: 1; position: relative; overflow: hidden; }
.bg-layer { position: absolute; inset: 0; }
.bg-svg { width: 100%; height: 100%; display: block; }
.spin { animation: spin 30s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.drift1 { animation: drift 40s linear infinite alternate; }
.drift2 { animation: drift 55s linear infinite alternate-reverse; }
@keyframes drift { from { transform: translateX(-60px); } to { transform: translateX(80px); } }
.drift1, .drift2 { transform-box: fill-box; }

.pet {
  position: absolute; width: clamp(92px, 15vmin, 160px);
  transform: translate(-50%, -100%);
  transition: left 4s linear, top 4s linear;
  cursor: pointer; text-align: center;
}
.pet .pet-svg { width: 100%; aspect-ratio: 1; }
.pet .animal { width: 100%; height: 100%; }
.pet.walking .pet-svg { animation: walk .45s ease-in-out infinite alternate; }
.pet.limping .pet-svg { animation: limp 1.1s ease-in-out infinite; }
@keyframes walk { from { transform: translateY(0) rotate(-2deg); } to { transform: translateY(-6px) rotate(2deg); } }
@keyframes limp { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-5deg) translateY(2px); } 60% { transform: rotate(2deg); } }
.nametag {
  display: inline-block; margin-top: -6px; background: #fff; border: 2.5px solid var(--ink); border-radius: 999px;
  padding: 1px 10px; font-weight: 600; font-size: .85rem; white-space: nowrap; box-shadow: 0 2px 0 rgba(0,0,0,.15);
}
.bubble {
  position: absolute; top: -8px; right: -4px; width: 42px; height: 42px; border-radius: 50%;
  background: #fff; border: 3px solid var(--ink); padding: 5px; animation: pulse 1.2s ease-in-out infinite;
  box-shadow: 0 3px 0 rgba(0,0,0,.15);
}
.bubble.alert { background: var(--red); }
.bubble.alert .ico { width: 100%; height: 100%; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.empty-hint {
  position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%); background: #fff; border: 3px solid var(--ink);
  border-radius: 20px; padding: 16px 22px; text-align: center; box-shadow: var(--shadow); width: min(90%, 420px);
  z-index: 140;
}
.empty-hint p { margin: 0 0 12px; font-size: 1.15rem; }
.wild-door {
  position: absolute; right: 12px; top: 12px; display: flex; align-items: center; gap: 8px;
  background: #fff; border: 3px solid var(--ink); border-radius: 20px; padding: 6px 14px 6px 6px;
  box-shadow: var(--shadow); max-width: min(330px, calc(100% - 24px)); text-align: left; font-weight: 600;
  animation: wiggle 2s ease-in-out infinite; z-index: 140;
}
.wild-door .mini { width: 64px; height: 64px; flex: none; background: #ffe3e3; border-radius: 14px; }
.wild-door small { display: block; font-weight: 400; color: var(--ink-soft); }
@keyframes wiggle { 0%, 80%, 100% { transform: rotate(0); } 85% { transform: rotate(-3deg); } 90% { transform: rotate(3deg); } 95% { transform: rotate(-2deg); } }

/* ---------- Djurkort (modal) ---------- */
.modal { position: fixed; inset: 0; background: rgba(40, 30, 25, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 12px; }
.modal.center { align-items: center; }
.modal-box {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 26px; width: min(560px, 100%);
  max-height: calc(100% - 10px); overflow-y: auto; padding: 18px; box-shadow: 0 8px 0 rgba(0,0,0,.2);
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
.card-head { display: flex; gap: 14px; align-items: center; }
.card-portrait { width: 130px; height: 130px; flex: none; background: radial-gradient(#e3f6ff 60%, transparent 62%); position: relative; }
.card-portrait .animal { width: 100%; height: 100%; }
.card-head h2 { margin: 0; font-size: 1.6rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head h2 .icon-btn { width: 38px; height: 38px; padding: 6px; }
.card-head p { margin: 2px 0 0; color: var(--ink-soft); }
.says {
  position: absolute; top: -6px; left: 70%; background: #fff; border: 2.5px solid var(--ink); border-radius: 14px;
  padding: 2px 10px; font-weight: 600; white-space: nowrap; animation: pop .3s ease; font-size: .95rem; z-index: 2;
}
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.injury-alert {
  background: #ffe3e3; border: 3px solid var(--red); border-radius: 16px; padding: 10px 12px; margin: 12px 0 0;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}
.injury-alert p { margin: 0; font-weight: 600; }
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 14px 0; }
.meter { display: flex; align-items: center; gap: 8px; }
.meter .m-ico { width: 32px; height: 32px; flex: none; }
.meter .bar { flex: 1; height: 18px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.meter .bar i { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .4s; }
.meter .bar i.mid { background: var(--yellow); }
.meter .bar i.low { background: var(--red); }
.care-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 480px) { .care-actions { grid-template-columns: repeat(3, 1fr); } }
.care-btn {
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 8px 4px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 600; font-size: .95rem; box-shadow: var(--shadow);
}
.care-btn .ico { width: 40px; height: 40px; }
.care-btn:active { transform: translateY(3px); box-shadow: none; }
.care-btn:disabled { opacity: .45; }
.card-sub { margin-top: 12px; }
.card-sub:empty { display: none; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; background: #fff; border: 3px dashed #d8c8b8; border-radius: 16px; padding: 10px; }
.picker-title { width: 100%; text-align: center; margin: 0 0 4px; font-weight: 600; }
.pick-item {
  width: 84px; background: #fffdf8; border: 3px solid var(--ink); border-radius: 14px; padding: 6px 4px;
  display: flex; flex-direction: column; align-items: center; font-size: .8rem; font-weight: 600; gap: 2px;
}
.pick-item .ico, .pick-item svg { width: 44px; height: 44px; }
.pick-item.on { background: #fff0c2; outline: 3px solid var(--coral); }
.pick-item:disabled { opacity: .4; }
.modal-footer { display: flex; justify-content: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Behandlingsrummet ---------- */
.treat-main { flex: 1; display: flex; min-height: 0; }
.treat-stage { flex: 1.4; position: relative; overflow: hidden; touch-action: none; min-height: 0; container-type: size; }
.stage-inner { position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%); width: min(70cqw, 66cqh, 460px); }
.treat-animal { width: 100%; aspect-ratio: 1; position: relative; z-index: 2; margin-bottom: -6%; }
.treat-animal .animal { width: 100%; height: 100%; }
.table-svg { width: 130%; margin-left: -15%; height: auto; aspect-ratio: 300 / 80; display: block; }
.target-ring {
  position: absolute; border: 4px dashed #fff; border-radius: 50%; pointer-events: none; z-index: 3;
  box-shadow: 0 0 0 3px rgba(229, 72, 77, .6); animation: ring 1.2s ease-in-out infinite; transform: translate(-50%, -50%);
}
@keyframes ring { 50% { transform: translate(-50%, -50%) scale(1.15); } }
.target-ring.busy { border-color: var(--yellow); animation-duration: .4s; }
#fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.fx { position: absolute; width: 34px; height: 34px; margin: -17px; animation: floatUp 1s ease-out forwards; }
.fx.bubblefx { width: 18px; height: 18px; margin: -9px; border-radius: 50%; background: rgba(255,255,255,.85); border: 2px solid #9fd3ff; animation-duration: .8s; }
@keyframes floatUp { to { transform: translate(var(--dx, 0), -70px) scale(.6); opacity: 0; } }

.treat-panel {
  flex: 1; max-width: 420px; background: #fff; border-left: 3px solid var(--ink);
  padding: 14px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto;
}
.vet-row { display: flex; gap: 10px; align-items: flex-start; }
.vet-face { width: 64px; height: 64px; flex: none; background: #e3f6ff; border-radius: 50%; border: 3px solid var(--ink); padding: 2px; }
.speech { background: var(--paper); border: 3px solid var(--ink); border-radius: 16px; padding: 10px 12px; flex: 1; position: relative; }
.speech::before { content: ''; position: absolute; left: -12px; top: 18px; border: 8px solid transparent; border-right-color: var(--ink); border-left: 0; }
.speech p { margin: 0; }
#treat-problem { font-weight: 600; }
#treat-msg { margin-top: 6px; color: var(--ink-soft); }
#treat-msg.good { color: var(--green-dark); font-weight: 600; }
#treat-msg.bad { color: var(--red); font-weight: 600; }
#treat-msg.action { color: var(--blue-dark); font-weight: 600; }
.progress { height: 22px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(45deg, var(--blue), var(--blue) 10px, #74c0fc 10px, #74c0fc 20px); transition: width .1s; }
.steps { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.step-dot {
  width: 54px; height: 54px; border-radius: 14px; border: 3px solid var(--ink); background: #f1ebe4;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.3rem; padding: 6px; color: var(--ink-soft);
}
.step-dot.done { background: #d3f9d8; }
.step-dot.now { background: #fff0c2; outline: 3px solid var(--coral); color: var(--coral); }
.step-arrow { color: var(--ink-soft); font-weight: 700; }

.toolbar {
  flex: none; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 10px;
  background: #e9d5bd; border-top: 3px solid var(--ink); max-height: 40vh; overflow-y: auto;
}
.tool {
  width: 76px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 4px 2px 3px;
  display: flex; flex-direction: column; align-items: center; font-size: .7rem; font-weight: 600; line-height: 1.1;
  box-shadow: var(--shadow); touch-action: manipulation;
}
.tool .ico { width: 42px; height: 42px; }
.tool span { min-height: 2.2em; display: flex; align-items: center; justify-content: center; text-align: center; hyphens: manual; }
.tool.selected { background: #fff0c2; outline: 4px solid var(--coral); transform: translateY(-4px); }
.tool.glow { animation: glow 0.9s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 6px var(--yellow), var(--shadow); } }
#tool-cursor { position: fixed; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none; z-index: 40; filter: drop-shadow(0 4px 2px rgba(0,0,0,.25)); }

/* ---------- Butik ---------- */
.shop-tabs { display: flex; gap: 8px; padding: 12px 16px 0; flex-wrap: wrap; }
.shop-tabs button { border: 3px solid var(--ink); border-radius: 999px; background: #fff; padding: 6px 16px; font-weight: 600; }
.shop-tabs button.active { background: var(--coral); color: #fff; }
.shop-grid { flex: 1; overflow-y: auto; padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start; }
.shop-item {
  background: #fff; border: 3px solid var(--ink); border-radius: var(--radius); padding: 10px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: var(--shadow);
}
.shop-item .ico, .shop-item > svg { width: 72px; height: 72px; }
.shop-item h3 { margin: 0; font-size: 1.05rem; }
.shop-item p { margin: 0; font-size: .85rem; color: var(--ink-soft); }
.shop-item .btn { padding: 6px 14px; margin-top: 4px; }
.price { display: inline-flex; align-items: center; gap: 4px; }
.price .ico { width: 20px; height: 20px; }

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92%, 480px); }
.toast {
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 10px 16px; font-weight: 600;
  box-shadow: var(--shadow); animation: toastIn .3s ease, toastOut .4s ease 3.2s forwards; text-align: center;
}
.toast.alert { background: #ffe3e3; border-color: var(--red); }
.toast.good { background: #d3f9d8; }
@keyframes toastIn { from { transform: translateY(-20px); opacity: 0; } }
@keyframes toastOut { to { transform: translateY(-20px); opacity: 0; } }

/* ---------- Firande ---------- */
.celebrate { text-align: center; }
.celebrate h2 { margin: 0; font-size: 1.8rem; color: var(--green-dark); }
.celebrate .portrait { width: 180px; height: 180px; margin: 0 auto; position: relative; }
.celebrate .portrait svg { width: 100%; height: 100%; }
.celebrate .reward { display: flex; gap: 10px; justify-content: center; margin: 8px 0; }
.confetti { position: fixed; top: -20px; width: 12px; height: 18px; z-index: 70; pointer-events: none; animation: fall linear forwards; border-radius: 3px; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- Djuranimationer ---------- */
.anim .eyes { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; animation-delay: var(--d, 0s); }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
.anim .breathe { transform-origin: 100px 190px; animation: breathe 3s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes breathe { 50% { transform: scale(1.025, .985); } }
.anim .tail { animation: wag .9s ease-in-out infinite alternate; }
.anim.mood-sad .tail, .anim.mood-sick .tail { animation: none; }
.anim.mood-joy .tail { animation-duration: .3s; }
@keyframes wag { from { transform: rotate(-10deg); } to { transform: rotate(10deg); } }
.anim.sp-kanin .tail, .anim.sp-marsvin .tail { animation: none; }
.anim.sp-kanin .ears { transform-origin: 100px 70px; animation: twitch 4s ease-in-out infinite; }
@keyframes twitch { 0%, 88%, 100% { transform: rotate(0); } 92% { transform: rotate(4deg); } 96% { transform: rotate(-3deg); } }
.anim.sp-fagel.mood-joy .wingR { animation: flap .25s ease-in-out infinite alternate; }
.anim.sp-fagel.mood-joy .wingL { animation: flapL .25s ease-in-out infinite alternate; }
@keyframes flap { to { transform: rotate(-25deg); } }
@keyframes flapL { to { transform: rotate(25deg); } }
.anim.sp-hast .tail { animation-duration: 1.6s; }
.flea { animation: hop .5s ease-in-out infinite alternate; }
@keyframes hop { to { transform: translate(2px, -5px); } }
.tear { animation: tear 2s ease-in infinite; }
@keyframes tear { from { transform: translateY(0); opacity: 1; } to { transform: translateY(14px); opacity: 0; } }

/* ---------- Mobil / smal skärm ---------- */
@media (max-width: 760px) {
  .treat-main { flex-direction: column; }
  .treat-panel { max-width: none; border-left: 0; border-top: 3px solid var(--ink); flex: none; padding: 10px; gap: 8px; }
  .vet-face { width: 48px; height: 48px; }
  .step-dot { width: 42px; height: 42px; }
  .tool { width: 62px; }
  .tool .ico { width: 34px; height: 34px; }
  .treat-stage { min-height: 240px; }
  .top-actions .btn span:not(.btn-ico) { display: none; }
  .top-actions .btn { padding: 8px 10px; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding: 8px; }
  .tool { flex: none; }
  .speech { padding: 8px 10px; font-size: .95rem; }
  .logo span { font-size: 1.1rem; }
  .meters { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .logo span { display: none; }
}

/* Ikoner inuti knappar och etiketter */
.pill-ico { width: 26px; height: 26px; display: inline-block; flex: none; }
.btn-ico { width: 1.4em; height: 1.4em; display: inline-block; flex: none; }
.icon-btn .ico { color: var(--ink); }

/* ---------- Apport ---------- */
.play-field { flex: 1; position: relative; overflow: hidden; touch-action: none; cursor: crosshair; }
.play-pet { transition: none; transform-origin: 50% 100%; width: clamp(110px, 22vmin, 190px); pointer-events: none; }
.play-pet .says { left: 60%; top: -10px; }
.play-ball { position: absolute; width: 44px; height: 44px; pointer-events: none; transform-origin: 50% 50%; }
.play-shadow { position: absolute; width: 40px; height: 12px; border-radius: 50%; background: rgba(0,0,0,.2); pointer-events: none; z-index: 1; }
.play-goal { position: absolute; width: 64px; height: 64px; pointer-events: none; z-index: 1; opacity: .9; animation: goalPulse 1.4s ease-in-out infinite; }
.play-goal .ico { filter: drop-shadow(0 0 6px #fff); }
@keyframes goalPulse { 50% { opacity: .55; } }
.play-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 500; pointer-events: none;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; padding: 8px 16px; font-weight: 600;
  box-shadow: var(--shadow); text-align: center; width: max-content; max-width: calc(100% - 24px);
}
.play-fx { position: absolute; z-index: 600; transform: translate(-50%, -50%); font-weight: 700; font-size: 1.4rem; color: #f08c00;
  text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff; pointer-events: none; animation: floatUp 1.3s ease-out forwards; }

/* ---------- Promenad / ridtur ---------- */
.walk-progress { height: 12px; background: #fff; border-bottom: 3px solid var(--ink); flex: none; }
.walk-progress i { display: block; height: 100%; width: 0; background: var(--green); }
.walk-field { flex: 1; position: relative; overflow: hidden; touch-action: none; cursor: pointer; background: linear-gradient(#7cc8f8, #d6f1ff 70%); }
.walk-layer { position: absolute; left: 0; right: 0; bottom: 18%; background-repeat: repeat-x; background-size: auto 100%; background-position-y: bottom; }
#walk-hills { height: 45%; }
#walk-trees { height: 34%; }
.walk-ground { position: absolute; left: 0; right: 0; top: 82%; bottom: 0; background-repeat: repeat-x; background-size: auto 100%; }
.walk-pet { position: absolute; transform-origin: 50% 100%; z-index: 5; pointer-events: none; }
.walk-pet .animal { width: 100%; height: auto; display: block; }
.walk-obj { position: absolute; transform: translate(-50%, -100%); z-index: 4; pointer-events: none; }
.walk-obj svg { width: 100%; height: 100%; display: block; }
.walk-obj.item { transform: translate(-50%, -50%); z-index: 6; animation: itemBob 1s ease-in-out infinite alternate; }
@keyframes itemBob { to { margin-top: -6px; } }
.walk-obj.got { animation: got .35s ease-out forwards; }
@keyframes got { to { transform: translate(-50%, -150%) scale(1.6); opacity: 0; } }
.walk-obj.knocked .poles { transform: rotate(14deg) translate(4px, 14px); transform-origin: 30px 40px; }
.walk-obj.knocked { filter: saturate(.7); }
.walk-obj.splashed svg ellipse:first-child { fill: #4dabf7; }

/* ---------- Miljöer: väder och ljus ---------- */
.weather { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 150; }
#play-weather, #walk-weather { z-index: 3; }
.flake { position: absolute; top: -12px; border-radius: 50%; background: #fff; opacity: .9; box-shadow: 0 0 3px rgba(120, 150, 190, .6); animation: snowfall linear infinite; }
@keyframes snowfall { to { transform: translate(50px, 110vh); } }
.leaf-fx { position: absolute; top: -14px; width: 16px; height: 10px; border-radius: 0 100% 0 100%; animation: leaffall linear infinite; }
@keyframes leaffall { 0% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(60px, 55vh) rotate(300deg); } 100% { transform: translate(-20px, 110vh) rotate(620deg); } }
.star-fx { position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .25; } }
.firefly { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #fff57a; box-shadow: 0 0 10px 4px rgba(255, 240, 120, .6); animation: flyabout ease-in-out infinite alternate, glowblink ease-in-out infinite; }
@keyframes flyabout { to { transform: translate(40px, -30px); } }
@keyframes glowblink { 50% { opacity: .2; } }
body[data-scene="natt"] #garden-animals, body[data-scene="natt"] .play-pet, body[data-scene="natt"] .walk-pet { filter: brightness(.86) saturate(.9); }
@media (prefers-reduced-motion: reduce) {
  .flake, .leaf-fx, .firefly { display: none; }
  .star-fx { animation: none; }
}

/* Miljöväljaren */
.picker-head { margin: 0 0 12px; text-align: center; }
.theme-prev { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; border: 3px solid var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.chip { border: 3px solid var(--ink); border-radius: 999px; background: #fff; padding: 6px 14px; font-weight: 600; }
.chip small { font-weight: 400; color: var(--ink-soft); }
.chip.on { background: var(--coral); color: #fff; }
.chip.on small { color: #fff; }
#modal-box .label { margin-top: 12px; }
.picker-note { font-size: .85rem; color: var(--ink-soft); margin: 10px 0 0; }
.theme-prev .weather { z-index: 1; }
.theme-prev .flake { width: 4px !important; height: 4px !important; }

/* Regn, åska och snöstorm */
.drop { position: absolute; top: -40px; width: 2px; height: 22px; border-radius: 2px; background: linear-gradient(transparent, rgba(190, 215, 245, .9)); animation: rainfall linear infinite; }
.drop.storm { width: 2.5px; height: 30px; transform: rotate(15deg); animation-name: rainstorm; }
@keyframes rainfall { to { transform: translateY(110vh); } }
@keyframes rainstorm { from { transform: translate(0, 0) rotate(15deg); } to { transform: translate(-30vh, 110vh) rotate(15deg); } }
.flake.storm { animation-name: blizzard; }
@keyframes blizzard { to { transform: translate(60vw, 110vh); } }
.lightning { position: absolute; inset: 0; background: #fff; opacity: 0; animation: flash 9s infinite; }
@keyframes flash { 0%, 60%, 63%, 66%, 100% { opacity: 0; } 61% { opacity: .75; } 64% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
  .drop { display: none; }
  .lightning { animation: none; }
}

/* ---------- Döda djur ---------- */
.pet.dead .nametag { background: #e9e4df; color: var(--ink-soft); }
.anim .ghost { transform-box: fill-box; transform-origin: center; animation: ghostfloat 3s ease-in-out infinite; }
@keyframes ghostfloat { 0%, 100% { transform: translateY(0); opacity: .9; } 50% { transform: translateY(-10px); opacity: .6; } }
.dead-note { color: var(--ink-soft); margin: 12px 0 0; }

/* Gravar */
.grave { position: absolute; width: clamp(70px, 11vmin, 120px); transform: translate(-50%, -100%); text-align: center; cursor: pointer; }
.grave-svg { width: 100%; display: block; }
.grave .nametag { margin: 0 0 -4px; background: #f3ede6; font-size: .8rem; }

/* Smal mobil: få plats med alla knappar i toppfältet */
@media (max-width: 480px) {
  .topbar { gap: 6px; padding: 8px 10px; }
  .top-actions { gap: 6px; }
  .icon-btn { width: 40px; height: 40px; padding: 6px; }
  .top-actions .btn { padding: 6px 8px; }
  .pill { padding: 2px 8px 2px 3px; gap: 3px; font-size: .9rem; }
  .pill .ico, .pill-ico { width: 22px; height: 22px; }
}

/* ---------- Sömn, kyla och rädsla ---------- */
.pet .zzz { display: none; position: absolute; top: -4px; right: 8px; width: 40px; height: 40px; pointer-events: none; z-index: 2; }
.pet.sleeping .zzz { display: block; }
.zzz i { position: absolute; left: 0; bottom: 0; font-style: normal; font-weight: 700; font-size: 1rem; color: #4c6ef5;
  text-shadow: 2px 0 #fff, -2px 0 #fff, 0 2px #fff, 0 -2px #fff; opacity: 0; animation: zfloat 3s ease-in infinite; }
.zzz i:nth-child(2) { animation-delay: 1s; font-size: 1.2rem; }
.zzz i:nth-child(3) { animation-delay: 2s; font-size: 1.4rem; }
@keyframes zfloat { 0% { transform: translate(0, 0); opacity: 0; } 20% { opacity: 1; } 100% { transform: translate(20px, -42px); opacity: 0; } }
.pet.shiver .pet-svg { animation: shiver .14s linear infinite alternate; }
.pet.scared .pet-svg { animation: shiver .07s linear infinite alternate; }
@keyframes shiver { from { transform: translateX(-1.5px); } to { transform: translateX(1.5px); } }
.anim.mood-sleep .tail { animation: none; }
.anim.mood-sleep .breathe { animation-duration: 5s; }

/* ---------- Akutfall ---------- */
.akut-door { top: 96px; background: #ffe3e3; border-color: var(--red); animation: wiggle 1s ease-in-out infinite; }
.akut-door .mini { background: #fff; }
.akut-time { color: var(--red); }
.timer-pill { background: #ffe3e3; padding: 3px 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.timer-pill.low { background: var(--red); color: #fff; animation: pulse .6s ease-in-out infinite; }

/* Minispel: sy ihop såret */
#sew-layer { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.sew-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sew-lines polyline { fill: none; stroke: #3b3540; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 8 5; }
.sew-dot { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; border: 3px solid var(--ink);
  background: #fff; font-weight: 700; font-size: 1.1rem; pointer-events: auto; box-shadow: var(--shadow); animation: pulse 1.2s ease-in-out infinite; }
.sew-dot.done { background: var(--green); color: #fff; animation: none; }
@media (max-width: 760px) { .akut-door { top: 88px; } }

/* ---------- Vargen och vakthunden ---------- */
.wolf, .guard-dog { position: absolute; width: clamp(100px, 16vmin, 170px); transform: translate(-50%, -100%); pointer-events: none; text-align: center; }
.wolf .animal, .guard-dog .animal { width: 100%; height: auto; display: block; }
.wolf.running .wolf-svg, .guard-dog.running .animal { animation: walk .25s ease-in-out infinite alternate; }
.wolf.ko .wolf-svg { transform: rotate(80deg) translate(20%, -10%); transition: transform .4s; }
.wolf-hp { display: flex; justify-content: center; gap: 2px; margin-top: -6px; }
.wolf-hp i { width: 22px; height: 22px; }
.wolf-hp i.gone { opacity: .2; filter: grayscale(1); }
.guard-dog { z-index: 40; }
.guard-dog .nametag { margin-top: -6px; background: #dbe4ff; }
.wolf-banner { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 160; width: min(92%, 520px);
  background: #fff; border: 3px solid var(--red); border-radius: 18px; padding: 10px 14px; text-align: center; box-shadow: var(--shadow); }
.wolf-choice { display: flex; gap: 10px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }
.wolf-timer { font-size: 1.8rem; font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; }
.wolf-timer.low { animation: pulse .5s ease-in-out infinite; }
.garden.hunting { cursor: crosshair; }
.garden.hunting .pet { cursor: crosshair; }
.shot-puff { position: absolute; width: 40px; height: 40px; margin: -20px; border-radius: 50%; pointer-events: none; z-index: 170;
  background: radial-gradient(#fff 20%, #ffd43b 45%, rgba(255, 146, 43, 0) 70%); animation: puff .5s ease-out forwards; }
.shot-puff.big { width: 140px; height: 140px; margin: -70px; background: radial-gradient(#fff 30%, rgba(220, 220, 230, .8) 55%, rgba(220, 220, 230, 0) 72%); }
@keyframes puff { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
.dizzy { transform-box: fill-box; transform-origin: center; animation: spin 1s linear infinite; }
