.pet-viewer-page,
.pet-viewer-page *,
.pet-viewer-page *::before,
.pet-viewer-page *::after {
  box-sizing: border-box;
}

.pet-viewer-page :where(button, a, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--shell-accent);
  outline-offset: 3px;
}

.pet-viewer-page {
  --pet-blue: var(--shell-accent);
  --pet-ink: var(--shell-text);
  --pet-muted: var(--shell-muted);
  --pet-card: var(--shell-panel);
  background: transparent;
}

.pet-info-button {
  border: 0;
  padding: 0 0 0 4px;
  color: var(--pet-muted);
  background: transparent;
  cursor: pointer;
}

.pet-info-button:hover, .pet-info-button[aria-expanded="true"] {
  color: var(--pet-blue);
}

.pet-inline-hint {
  display: block;
  margin-top: 4px;
}

.pet-viewer-page [hidden] {
  display: none !important;
}

.pet-viewer-main {
  min-width: 0;
  padding: 0;
}

.pet-viewer-wrap {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding-top: 0;
}

.pet-stage-card {
  overflow: hidden;
  border: 1px solid var(--shell-line);
  border-radius: 12px;
  background: var(--shell-panel);
}

.pet-stage-heading {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  color: var(--pet-ink);
  background: var(--shell-panel);
}

.pet-stage-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--pet-blue);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.12em;
}

.pet-stage-heading h1 {
  margin: 0;
  font-size: clamp(25px, 3vw, 32px);
  line-height: 1.08;
}

.pet-stage-heading p {
  margin: 5px 0 0;
  color: var(--pet-muted);
  font-size: 13px;
}

.pet-stage-badge {
  flex: 0 0 auto;
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--shell-on-accent);
  background: var(--shell-accent);
  font-size: 13px;
  font-weight: 650;
}

.pet-stage {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(circle at 50% 73%, rgba(255, 255, 255, 0.72), transparent 27%),
    linear-gradient(180deg, #65a8e2 0%, #83bdec 68%, #78afe0 100%);
}

.pet-stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  left: 0;
  right: 0;
  bottom: 0;
  height: 27%;
  background: linear-gradient(180deg, rgba(128, 183, 230, 0), rgba(112, 168, 217, 0.84));
  pointer-events: none;
}

.pet-stage-pattern {
  position: absolute;
  z-index: -2;
  inset: -16% -12% 12%;
  opacity: 0.24;
  transform: rotate(-8deg) scale(1.1);
  background-image: radial-gradient(circle at 18% 32%, rgba(255,255,255,.88) 0 2.5%, transparent 2.7%),
    radial-gradient(circle at 68% 18%, rgba(255,255,255,.62) 0 3%, transparent 3.2%),
    radial-gradient(circle at 83% 70%, rgba(255,255,255,.72) 0 2%, transparent 2.2%),
    repeating-linear-gradient(128deg, transparent 0 56px, rgba(255,255,255,.44) 58px 62px, transparent 64px 118px);
  background-size: 270px 210px, 310px 230px, 230px 260px, 210px 210px;
  animation: pet-pattern-drift 18s linear infinite;
}

@keyframes pet-pattern-drift {
  to { background-position: 270px -210px, -310px 230px, 230px 260px, 210px -210px; }
}

.pet-stage-emblem {
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: min(47vw, 390px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  transform: translate(-50%, -51%);
  border: 3px solid rgba(255, 255, 255, 0.17);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.18);
  font-size: min(20vw, 170px);
  box-shadow: 0 0 0 22px rgba(255, 255, 255, 0.055);
}

#petCanvas {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

#petCanvas:active {
  cursor: grabbing;
}

.pet-stage-loading {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  color: var(--shell-text);
  text-align: center;
  background: color-mix(in srgb, var(--shell-panel-strong) 88%, transparent);
  backdrop-filter: blur(5px);
  transition: opacity .25s ease, visibility .25s ease;
}

.pet-stage-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.pet-stage-loading small {
  opacity: .82;
}

.pet-loading-progress {
  width: min(320px, 72vw);
  height: 7px;
  overflow: hidden;
  border: 1px solid var(--shell-line);
  border-radius: 999px;
  background: var(--shell-field);
  box-shadow: inset 0 1px 3px var(--shell-line);
}

.pet-loading-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--shell-accent), var(--shell-accent-2));
  transition: width .24s ease;
}

.pet-stage-spinner {
  width: 34px;
  height: 34px;
  border: 4px solid var(--shell-line-strong);
  border-top-color: var(--shell-accent);
  border-radius: 50%;
  animation: pet-spin .8s linear infinite;
}

@keyframes pet-spin { to { transform: rotate(360deg); } }

.pet-stage-tip {
  position: absolute;
  z-index: 3;
  right: 15px;
  bottom: 14px;
  padding: 7px 11px;
  border: 1px solid var(--shell-line);
  border-radius: 999px;
  color: var(--shell-text);
  background: var(--shell-panel-strong);
  font-size: 12px;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.pet-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
  padding: 14px 0 0;
}

.pet-control-card {
  padding: 16px;
  border: 1px solid var(--shell-line);
  border-radius: 12px;
  background: var(--pet-card);
}

.pet-control-card-main {
  grid-row: span 2;
}

.pet-control-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--pet-ink);
}

.pet-control-title span {
  display: block;
  font-weight: 650;
}

.pet-control-title small {
  display: block;
  margin-top: 3px;
  color: var(--pet-muted);
}

.pet-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 0;
  border-radius: 999px;
  color: var(--pet-muted);
  background: var(--shell-panel-soft);
  cursor: pointer;
}

.pet-switch span {
  position: relative;
  width: 33px;
  height: 19px;
  border-radius: 99px;
  background: var(--shell-muted);
  transition: background .2s ease;
}

.pet-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--shell-field);
  transition: transform .2s ease;
}

.pet-switch[aria-checked="true"] {
  color: var(--shell-on-accent);
  background: var(--shell-accent);
}

.pet-switch[aria-checked="true"] span {
  background: color-mix(in srgb, var(--shell-on-accent) 22%, transparent);
}

.pet-switch[aria-checked="true"] span::after {
  background: var(--shell-on-accent);
  transform: translateX(14px);
}

.pet-stepper {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  margin-top: 19px;
  padding: 10px;
  border-radius: 8px;
  background: var(--shell-panel-soft);
  text-align: center;
}

.pet-stepper button, .pet-segmented button, .pet-action-row button {
  border: 0;
  color: var(--shell-text);
  background: var(--shell-panel-soft);
  cursor: pointer;
}

.pet-stepper button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.pet-stepper strong {
  color: var(--shell-text);
  font-size: 17px;
}

.pet-stepper small {
  display: block;
  margin-top: 2px;
  color: var(--pet-muted);
}

.pet-segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 15px;
}

.pet-segmented button {
  min-height: 40px;
  border-radius: 8px;
  background: var(--shell-panel-soft);
  font-weight: 650;
}

.pet-segmented button.is-active {
  color: var(--shell-on-accent);
  background: var(--shell-accent);
}

.pet-action-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin-top: 15px;
}

.pet-action-row button {
  min-height: 43px;
  border-radius: 8px;
  background: var(--shell-panel-soft);
  font-weight: 650;
}

.pet-action-row button i {
  margin-right: 7px;
}

.pet-action-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-top: 15px;
}

.pet-action-picker button {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  color: var(--shell-on-accent);
  background: var(--shell-accent);
  font-weight: 650;
  cursor: pointer;
}

.pet-action-picker button i {
  margin-right: 7px;
}

.pet-action-picker button:disabled {
  opacity: .5;
  cursor: default;
}

.pet-action-note {
  margin-top: 12px;
  color: var(--pet-muted);
  font-size: 12px;
}

.pet-action-note summary {
  width: max-content;
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--shell-muted);
  background: var(--shell-panel-soft);
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.pet-action-note summary::-webkit-details-marker {
  display: none;
}

.pet-action-note summary i {
  margin-right: 5px;
}

.pet-action-note p {
  margin: 9px 0 0;
  line-height: 1.7;
}

.pet-select-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.pet-select-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--pet-muted);
  font-size: 12px;
  font-weight: 650;
}

.pet-select-field select {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--shell-line);
  border-radius: 8px;
  color: var(--shell-text);
  background: var(--shell-field);
  outline: none;
  min-width: 0;
  font-size: 16px;
}

.pet-select-field select option {
  color: var(--shell-text);
  background: var(--shell-field);
}

.pet-select-field select optgroup {
  color: var(--shell-muted);
  background: var(--shell-field);
}

#particleOptions {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--shell-line);
  border-radius: 8px;
  color: var(--shell-text);
  background-color: var(--shell-field);
  outline: none;
  min-width: 0;
  font-size: 16px;
}

#particleOptions:focus, .pet-select-field select:focus {
  border-color: var(--shell-accent);
  box-shadow: 0 0 0 3px var(--shell-accent-soft);
}

#particleOptions option {
  color: var(--shell-text);
  background: var(--shell-field);
}

[data-feature].is-feature-hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .pet-viewer-main {
    padding: 0;
  }

  .pet-viewer-wrap {
    padding-top: 0;
  }

  .pet-stage-shell {
    position: sticky;
    z-index: 20;
    top: calc(var(--shell-mobilebar-offset, 0px) + 8px);
    padding-bottom: 8px;
    background: none;
  }

  .pet-stage-card {
    border-radius: 12px;
  }

  .pet-stage-heading {
    padding: 12px 15px 10px;
  }

  .pet-stage-heading h1 {
    font-size: 23px;
  }

  .pet-stage-heading p {
    font-size: 11px;
  }

  .pet-stage-kicker {
    display: none;
  }

  .pet-stage-badge {
    padding: 6px 10px;
    font-size: 11px;
  }

  .pet-stage {
    min-height: 0;
    height: min(43svh, 390px);
  }

  .pet-stage-emblem {
    width: 48vw;
    font-size: 21vw;
  }

  .pet-stage-tip {
    right: 9px;
    bottom: 8px;
    font-size: 10px;
  }

  .pet-controls {
    display: block;
    padding-top: 4px;
  }

  .pet-control-card {
    margin-top: 11px;
    padding: 15px;
    border-radius: 8px;
  }

  .pet-select-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .pet-viewer-main {
    padding: 0;
  }

  .pet-stage-shell {
    top: calc(var(--shell-mobilebar-offset, 0px) + 8px);
  }

  .pet-stage-heading p {
    max-width: 190px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .pet-stage {
    height: 39svh;
    min-height: 285px;
  }

  .pet-stage-tip {
    display: none;
  }

  .pet-switch strong {
    font-size: 12px;
  }

  .pet-action-picker {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pet-stage-pattern, .pet-stage-spinner {
    animation: none;
  }
}

.pet-control-card.is-particle-hidden {
  display: none;
}
