.student-pet-stage {
  grid-template-columns: minmax(0, 1fr) 190px;
  min-height: 230px;
  overflow: visible;
}

.student-pet-home {
  width: 100%;
  font: inherit;
  cursor: pointer;
  appearance: none;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 150px;
  padding: 1rem;
  border: 2px dashed rgba(95, 143, 122, 0.28);
  border-radius: 26px 26px 18px 18px;
  background: rgba(255, 255, 255, 0.4);
  color: #567064;
  text-align: center;
}

.student-pet-home:hover, .student-pet-home:focus-visible {
  border-color: rgba(128, 88, 178, 0.7);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 4px rgba(151, 108, 204, 0.12);
}
.student-pet-home:focus-visible { outline: 2px solid #8058b2; outline-offset: 3px; }

.student-pet-home-icon {
  font-size: 2.8rem;
  line-height: 1;
  opacity: 0.72;
}

.student-pet-home small {
  margin-top: 0.5rem;
  font-weight: 750;
}

.student-pet-home.is-expecting {
  border-color: rgba(128, 88, 178, 0.48);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 0 0 6px rgba(151, 108, 204, 0.08);
}

.student-pet-home-icon,
.student-pet-home small {
  transition: opacity .45s ease;
}

.student-pet-home.is-occupied .student-pet-home-icon {
  opacity: 0.08;
}

.student-pet-home.is-occupied small {
  opacity: 0;
}

/* The roaming pet's speech bubble is the visible feedback surface. Keep this
   live region available to assistive technology without duplicating the copy. */
.student-pet-speech {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.student-companion-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.student-companion-control {
  min-height: 36px;
  padding: 0.42rem 0.7rem;
  border: 1px solid rgba(95, 143, 122, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.64);
  color: #46675a;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 750;
  cursor: pointer;
}

.student-companion-control:hover,
.student-companion-control:focus-visible {
  border-color: #6e9f89;
  background: #fff;
}

.student-pet-world {
  --companion-x: calc(100vw - 176px);
  --companion-y: calc(100vh - 176px);
  position: fixed;
  z-index: 40;
  left: var(--companion-x);
  top: var(--companion-y);
  display: grid;
  place-items: center;
  width: 142px;
  height: 142px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 40%;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: grab;
  touch-action: none;
  transition: left 1.45s cubic-bezier(.35,.05,.2,1), top 1.45s cubic-bezier(.35,.05,.2,1), opacity .25s ease, filter .25s ease;
  -webkit-tap-highlight-color: transparent;
}

.student-pet-world:hover,
.student-pet-world:focus-visible {
  filter: drop-shadow(0 9px 12px rgba(50, 82, 65, 0.15));
  outline: none;
}

.student-pet-world:focus-visible::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 3px solid #6e9f89;
  border-radius: 40%;
}

.student-pet-world.is-hidden,
.student-pet-world.is-portal-hidden {
  display: none;
}

.student-pet-world.is-dragging {
  cursor: grabbing;
  transition: none;
}

.student-pet-world.is-positioning {
  transition: none;
}

.student-pet-avatar {
  width: 112px;
  height: 112px;
  border: 0;
  background: transparent;
  font-size: 5.7rem;
  filter: drop-shadow(0 11px 8px rgba(50, 82, 65, 0.18));
  pointer-events: none;
  user-select: none;
}

.sonare-mascot {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.student-account-avatar .sonare-mascot,
.student-avatar-option .sonare-mascot,
.student-practice-session-pet .sonare-mascot {
  width: 100%;
  height: 100%;
}

.student-avatar-option span {
  display: block;
  width: 48px;
  height: 48px;
}

.student-pet-accessory {
  display: none;
}

.mascot-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: mascotBlink 5.4s infinite;
}

.mascot-eye--right { animation-delay: .03s; }
.mascot-tail {
  transform-box: fill-box;
  transform-origin: left center;
  animation: mascotTail 1.9s ease-in-out infinite;
}
.mascot-accessory { transform-box: fill-box; transform-origin: center; }
.mascot-crown { animation: mascotAccessoryBob 2.4s ease-in-out infinite; }
.mascot-sparkles { animation: mascotSparkle 1.8s ease-in-out infinite; }

@keyframes mascotBlink {
  0%, 45%, 49%, 100% { transform: scaleY(1); }
  47% { transform: scaleY(.08); }
}

@keyframes mascotTail {
  0%, 100% { transform: rotate(-5deg); }
  50% { transform: rotate(8deg); }
}

@keyframes mascotAccessoryBob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -3px; }
}

@keyframes mascotSparkle {
  0%, 100% { opacity: .58; transform: scale(.88); }
  50% { opacity: 1; transform: scale(1.08); }
}

.student-pet-shadow {
  bottom: 6px;
  width: 92px;
  height: 17px;
  pointer-events: none;
}

.student-pet-note {
  pointer-events: none;
  user-select: none;
}

.student-companion-bubble {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 7px);
  width: max-content;
  max-width: min(230px, 72vw);
  padding: 0.58rem 0.75rem;
  border: 1px solid rgba(78, 116, 99, 0.24);
  border-radius: 13px 13px 13px 4px;
  background: rgba(255, 254, 249, 0.96);
  box-shadow: 0 8px 24px rgba(46, 70, 60, 0.13);
  color: #40554c;
  font-size: 0.76rem;
  font-weight: 720;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(-30%, 8px) scale(.96);
  transition: opacity .2s ease, transform .2s ease;
}

.student-companion-bubble.is-visible {
  opacity: 1;
  transform: translate(-30%, 0) scale(1);
}

.student-pet-world.is-near-right .student-companion-bubble {
  right: 8px;
  left: auto;
  transform: translate(0, 8px) scale(.96);
}

.student-pet-world.is-near-right .student-companion-bubble.is-visible {
  transform: translate(0, 0) scale(1);
}

.student-pet-world.is-near-left .student-companion-bubble {
  left: 8px;
  transform: translate(0, 8px) scale(.96);
}

.student-pet-world.is-near-left .student-companion-bubble.is-visible {
  transform: translate(0, 0) scale(1);
}

.student-pet-world.is-near-top .student-companion-bubble {
  top: calc(100% - 7px);
  bottom: auto;
  border-radius: 4px 13px 13px 13px;
}

.student-pet-world[data-behaviour="walking"] .student-pet-avatar {
  animation: companionWalk .48s ease-in-out infinite;
}

.student-pet-world[data-behaviour="sleeping"] .student-pet-avatar {
  animation: companionSleep 3.2s ease-in-out infinite;
  filter: saturate(.82) drop-shadow(0 7px 7px rgba(50, 82, 65, 0.14));
}

.student-pet-world[data-behaviour="pat"] .student-pet-avatar {
  animation: companionPat .7s cubic-bezier(.2,.8,.2,1);
}

.student-pet-world[data-behaviour="practice"] .student-pet-avatar,
.student-pet-world[data-behaviour="duplicate"] .student-pet-avatar,
.student-pet-world[data-behaviour="quest"] .student-pet-avatar {
  animation: petPractice .85s cubic-bezier(.2,.8,.2,1);
}

.student-pet-world[data-behaviour="practice"] .student-pet-note,
.student-pet-world[data-behaviour="duplicate"] .student-pet-note,
.student-pet-world[data-behaviour="week"] .student-pet-note {
  animation: companionCelebrationNote .9s ease-out both;
}

.student-pet-world[data-behaviour="duplicate"] .student-pet-note-two {
  animation-delay: .12s;
}

.student-pet-world[data-behaviour="week"] .student-pet-avatar {
  animation: petWeek 1.15s cubic-bezier(.2,.8,.2,1);
}

.student-pet-world[data-behaviour="award"] .student-pet-avatar {
  animation: petDelivery .9s cubic-bezier(.2,.8,.2,1);
}

@keyframes companionWalk {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}

@keyframes companionSleep {
  0%, 100% { transform: translateY(5px) rotate(-5deg) scale(1); }
  50% { transform: translateY(7px) rotate(-5deg) scale(.96); }
}

@keyframes companionPat {
  0%, 100% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-9px) scale(1.13) rotate(-4deg); }
  65% { transform: translateY(-4px) scale(1.08) rotate(4deg); }
}

@keyframes companionCelebrationNote {
  0% { opacity: 0; transform: translateY(16px) rotate(-8deg) scale(.65); }
  45% { opacity: 1; transform: translateY(-8px) rotate(7deg) scale(1.18); }
  100% { opacity: .72; transform: translateY(-20px) rotate(-3deg) scale(1); }
}

.student-portal-card.companion-reduced-motion .student-pet-world,
.student-portal-card.companion-reduced-motion .student-pet-avatar,
.student-portal-card.companion-reduced-motion .student-companion-bubble,
.student-portal-card.companion-reduced-motion .mascot-eye,
.student-portal-card.companion-reduced-motion .mascot-tail,
.student-portal-card.companion-reduced-motion .mascot-accessory,
.student-pet-world.companion-reduced-motion,
.student-pet-world.companion-reduced-motion .student-pet-avatar,
.student-pet-world.companion-reduced-motion .student-companion-bubble,
.student-pet-world.companion-reduced-motion .student-pet-note,
.student-pet-world.companion-reduced-motion .mascot-eye,
.student-pet-world.companion-reduced-motion .mascot-tail,
.student-pet-world.companion-reduced-motion .mascot-accessory {
  animation: none !important;
  transition: none !important;
}

@media (max-width: 680px) {
  .student-pet-stage { grid-template-columns: 1fr; overflow: hidden; }
  .student-pet-home { min-height: 108px; grid-row: 1; }
  .student-pet-copy { grid-row: 2; }
  .student-companion-controls { justify-content: center; }
  .student-pet-world {
    width: 112px;
    height: 112px;
  }
  .student-pet-avatar { width: 92px; height: 92px; font-size: 4.55rem; }
  .student-pet-shadow { width: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .student-pet-world,
  .student-pet-avatar,
  .student-companion-bubble,
  .student-pet-note,
  .mascot-eye,
  .mascot-tail,
  .mascot-accessory {
    animation: none !important;
    transition: none !important;
  }
}

/* Give the heading breathing room above the primary practice actions. */
.student-pet-copy .student-pet-actions {
  margin-top: 1.25rem;
}

#studentPracticeResult:empty {
  display: none;
}

/* Keep the main pet action visible and tuck optional controls away. */
.student-pet-options { position: relative; z-index: 2; margin-top: 0.65rem; }
.student-pet-options-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 42px;
  padding: 0.6rem 0.9rem;
  border: 1px solid #d7cbe8;
  border-radius: 11px;
  background: #fffdfd;
  color: #463268;
  box-shadow: 0 4px 14px rgba(44, 29, 69, 0.12);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 750;
  cursor: pointer;
}
.student-pet-options-button::after { content: "⌄"; font-size: 1rem; margin-left: 0.1rem; }
.student-pet-options-button[aria-expanded="true"]::after { content: "⌃"; }
.student-pet-options-button:hover, .student-pet-options-button:focus-visible {
  border-color: #8b6ab5;
  background: #f4edff;
  color: #463268;
}
.student-pet-options-button:focus-visible { outline: 2px solid #8058b2; outline-offset: 2px; }
.student-pet-options .student-companion-controls[hidden] { display: none; }
.student-pet-options .student-companion-controls { margin-top: 0.4rem; max-width: 420px; }
.student-pet-home-icon { font-size: 2rem; }
.student-pet-home small { font-size: 0.74rem; font-weight: 600; }
