﻿:root {
  --ink: #eef9ff;
  --muted: #a9c1d6;
  --panel: rgba(14, 25, 42, 0.9);
  --panel-soft: rgba(26, 45, 72, 0.82);
  --gold: #ffd36b;
  --blue: #7ed7ff;
  --green: #9cf28c;
  --pixel-border: #1a2435;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    linear-gradient(180deg, rgba(11, 22, 38, 0.82), rgba(9, 13, 24, 0.94)),
    url("assets/battle/battle-background.png") center / cover fixed no-repeat;
}

button,
a {
  font: inherit;
}

.pet-dex-app {
  width: min(1480px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.dex-topbar,
.dex-list-panel,
.dex-detail-panel,
.info-card,
.evolution-panel {
  border: 4px solid var(--pixel-border);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--pixel-border);
}

.dex-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.dex-brand,
.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-ball {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 3px solid var(--pixel-border);
  border-radius: 4px;
  color: #1d2634;
  font-size: 24px;
  font-weight: 1000;
  background: linear-gradient(180deg, #fff4a5 0 50%, #f6b844 50% 100%);
  box-shadow: 4px 4px 0 var(--pixel-border);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  margin-bottom: 0;
}

.dex-actions,
.button-row,
.filter-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pixel-button,
.filter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 3px solid var(--pixel-border);
  border-radius: 4px;
  padding: 8px 12px;
  cursor: pointer;
  color: #1a1208;
  font-weight: 1000;
  text-decoration: none;
  background: linear-gradient(180deg, #fff8d0 0 50%, #f0c66e 50% 100%);
  box-shadow: 4px 4px 0 var(--pixel-border);
}

.pixel-button.primary {
  background: linear-gradient(180deg, #b8f7a1 0 50%, #5cf3a7 50% 100%);
}

.pet-battle-guide.hidden {
  display: none;
}

.pet-battle-guide {
  position: fixed;
  inset: 0;
  z-index: 5000;
  pointer-events: none;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

.pet-battle-guide-dim,
.pet-battle-guide-spotlight,
.pet-battle-guide-card,
.pet-battle-guide-arrow {
  position: fixed;
}

.pet-battle-guide-dim {
  z-index: 5000;
  background: rgba(2, 5, 14, 0.78);
  pointer-events: auto;
}

.pet-battle-guide-spotlight {
  z-index: 5001;
  border: 4px solid #ffef8a;
  border-radius: 12px;
  box-shadow:
    0 0 0 3px #c92828,
    0 0 24px rgba(255, 236, 132, 0.95),
    inset 0 0 20px rgba(255, 236, 132, 0.2);
  pointer-events: none;
  animation: petBattleGuideSpotlightPulse 0.95s ease-in-out infinite alternate;
}

.pet-battle-guide-arrow {
  z-index: 5003;
  width: 34px;
  height: 34px;
  filter: drop-shadow(3px 3px 0 #070912);
  pointer-events: none;
}

.pet-battle-guide-arrow::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  border-left: 17px solid transparent;
  border-right: 17px solid transparent;
}

.pet-battle-guide-arrow.up::before {
  border-bottom: 30px solid #ff3737;
}

.pet-battle-guide-arrow.down::before {
  border-top: 30px solid #ff3737;
}

.pet-battle-guide-card {
  z-index: 5004;
  box-sizing: border-box;
  padding: 16px;
  color: #1c1407;
  background:
    linear-gradient(180deg, #fff7d6 0 50%, #ffd876 50% 100%);
  border: 4px solid #070912;
  border-radius: 8px;
  box-shadow: 8px 8px 0 #070912, 0 12px 34px rgba(0, 0, 0, 0.36);
  pointer-events: auto;
}

.pet-battle-guide .pet-battle-guide-step {
  margin: 0 0 5px;
  color: #8c3a0d !important;
  font-size: 12px !important;
  font-weight: 900 !important;
  text-shadow: none !important;
}

.pet-battle-guide .pet-battle-guide-title {
  margin: 0 0 8px;
  color: #251707 !important;
  font-size: 20px !important;
  line-height: 1.15 !important;
  letter-spacing: 0 !important;
  text-shadow: none !important;
}

.pet-battle-guide .pet-battle-guide-text {
  margin: 0;
  color: #3d2910 !important;
  font-size: 14px !important;
  font-weight: 800 !important;
  line-height: 1.55 !important;
  text-shadow: none !important;
}

.pet-battle-guide-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.pet-battle-guide-skip {
  min-height: 34px;
  padding: 7px 12px;
  color: #fff9d7;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  border: 3px solid #070912;
  border-radius: 4px;
  background: linear-gradient(180deg, #ff8a8a 0 50%, #ff4545 50% 100%);
  box-shadow: 4px 4px 0 #070912;
  cursor: pointer;
}

@keyframes petBattleGuideSpotlightPulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.015);
  }
}

.pixel-button:hover,
.filter-chip:hover,
.dex-pet-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--pixel-border);
}

.dex-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.38fr) minmax(0, 0.62fr);
  gap: 16px;
}

.dex-list-panel,
.dex-detail-panel {
  min-height: 720px;
  padding: 14px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.count-pill,
.tag-row span {
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 4px;
  padding: 5px 8px;
  color: #172233;
  font-weight: 1000;
  background: #c9f2ff;
}

.filter-row {
  margin-bottom: 12px;
}

.filter-chip {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 13px;
}

.filter-chip.active {
  background: linear-gradient(180deg, #dfffc9 0 50%, #7cf088 50% 100%);
}

.dex-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 635px;
  overflow: auto;
  padding: 4px 8px 8px 4px;
}

.dex-pet-card {
  min-height: 140px;
  border: 3px solid var(--pixel-border);
  border-radius: 4px;
  padding: 8px;
  cursor: pointer;
  color: #1f2734;
  font-weight: 1000;
  background: linear-gradient(180deg, #fff8d0 0 50%, #f0c66e 50% 100%);
  box-shadow: 4px 4px 0 var(--pixel-border);
}

.dex-pet-card.active {
  background: linear-gradient(180deg, #dfffc9 0 50%, #7cf088 50% 100%);
}

.dex-thumb {
  display: block;
  width: 100%;
  height: 82px;
  object-fit: contain;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.18));
}

.dex-pet-card span {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.2;
  text-align: center;
}

.dex-pet-card small {
  display: block;
  color: #4a5b74;
  font-size: 11px;
  text-align: center;
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(260px, 0.44fr) minmax(0, 0.56fr);
  gap: 16px;
  margin-bottom: 14px;
}

.pet-stage {
  position: relative;
  display: grid;
  min-height: 390px;
  place-items: center;
  overflow: hidden;
  border: 4px solid var(--pixel-border);
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(126, 215, 255, 0.06)),
    radial-gradient(circle at 50% 70%, rgba(255, 211, 107, 0.22), transparent 54%);
}

.pet-aura {
  position: absolute;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(126, 215, 255, 0.2), transparent 68%);
}

#detailImage {
  position: relative;
  z-index: 1;
  width: min(88%, 420px);
  max-height: 350px;
  object-fit: contain;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, 0.24));
}

.pet-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 390px;
  border: 4px solid var(--pixel-border);
  border-radius: 4px;
  padding: 18px;
  background: var(--panel-soft);
}

#petName {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.05;
}

.english-name {
  margin: 6px 0 12px;
  color: var(--muted);
  font-weight: 900;
}

.pet-desc {
  margin: 16px 0;
  color: #d8ecff;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.7;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.info-card,
.evolution-panel {
  padding: 14px;
  background: rgba(14, 25, 42, 0.82);
}

.info-card h3 {
  margin-bottom: 10px;
  color: var(--gold);
}

.level-line,
.stat-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 1000;
}

.progress-track {
  height: 16px;
  margin: 10px 0;
  border: 3px solid var(--pixel-border);
  border-radius: 4px;
  overflow: hidden;
  background: #101927;
}

.progress-track span {
  display: block;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, #7cf088, #ffd36b);
}

.stat-list {
  display: grid;
  gap: 8px;
}

.stat-list div {
  padding: 7px 8px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
}

.skill-card p,
#habitatText,
#obtainText,
#evolutionText {
  margin-bottom: 0;
  color: #d8ecff;
  font-weight: 800;
  line-height: 1.55;
}

.evolution-chain {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.evo-card {
  border: 3px solid var(--pixel-border);
  border-radius: 4px;
  padding: 10px;
  color: #1f2734;
  text-align: center;
  font-weight: 1000;
  background: linear-gradient(180deg, #fff8d0 0 50%, #f0c66e 50% 100%);
  box-shadow: 4px 4px 0 var(--pixel-border);
}

.evo-card.active {
  background: linear-gradient(180deg, #dfffc9 0 50%, #7cf088 50% 100%);
}

.evo-card img {
  width: 100%;
  height: 112px;
  object-fit: contain;
}

.evo-card small {
  display: block;
  color: #526681;
  font-size: 12px;
}

@media (max-width: 1050px) {
  .dex-layout,
  .hero-card {
    grid-template-columns: 1fr;
  }

  .dex-list-panel,
  .dex-detail-panel {
    min-height: 0;
  }

  .dex-grid {
    max-height: none;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .pet-dex-app {
    width: calc(100vw - 14px);
    padding-top: 8px;
  }

  .dex-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .dex-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid,
  .evolution-chain {
    grid-template-columns: 1fr;
  }

  .pet-stage,
  .pet-summary {
    min-height: 300px;
  }

  #detailImage {
    max-height: 275px;
  }
}

/* Final pet detail scenery: sky page background and castle stage for current pet. */
body {
  background:
    linear-gradient(180deg, rgba(235, 247, 255, 0.42), rgba(244, 251, 255, 0.68)),
    url("assets/ui/cloud-kingdom-game-bg.png") center center / cover fixed no-repeat,
    #dff1ff !important;
}

.pet-dex-app {
  color: #17345f !important;
}

.dex-topbar,
.dex-list-panel,
.dex-detail-panel,
.info-card,
.evolution-panel {
  border-color: rgba(96, 147, 220, 0.78) !important;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(233, 247, 255, 0.82)) !important;
  box-shadow: 0 8px 0 rgba(67, 113, 178, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.72) !important;
}

.pet-stage {
  min-height: 390px !important;
  border-color: rgba(96, 147, 220, 0.82) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.1)),
    url("assets/ui/cloud-kingdom-game-bg.png") center center / cover no-repeat !important;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.46), 0 8px 0 rgba(67, 113, 178, 0.12) !important;
}

.pet-aura {
  background: radial-gradient(circle, rgba(255, 247, 173, 0.34), rgba(255, 255, 255, 0.1) 42%, transparent 70%) !important;
}

#detailImage {
  filter:
    drop-shadow(0 16px 14px rgba(28, 68, 112, 0.26))
    drop-shadow(0 0 1px rgba(255, 255, 255, 0.8)) !important;
}

.pet-summary,
.info-card,
.evolution-panel {
  color: #17345f !important;
}

.pet-summary {
  border-color: rgba(96, 147, 220, 0.82) !important;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(235, 247, 255, 0.84)) !important;
  box-shadow: 0 8px 0 rgba(67, 113, 178, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.72) !important;
}

.pet-desc,
.skill-card p,
#habitatText,
#obtainText,
#evolutionText {
  color: #31557f !important;
}

.english-name,
.dex-pet-card small {
  color: #4e6d93 !important;
}

.info-card h3,
.eyebrow {
  color: #2f76d2 !important;
}

.stat-list div {
  border-color: rgba(96, 147, 220, 0.26) !important;
  background: rgba(255, 255, 255, 0.54) !important;
}

@media (max-width: 720px) {
  .pet-stage {
    min-height: 300px !important;
    background-position: center center !important;
  }
}

/* Final harmony pass: fresh blue-white cards and softer orange actions. */
:root {
  --pixel-border: #7fa8e6;
}

.pixel-button,
.filter-chip {
  border: 2px solid #86afe9 !important;
  border-radius: 8px !important;
  color: #17345f !important;
  background: linear-gradient(180deg, #fff7d7 0%, #ffe29a 100%) !important;
  box-shadow: 0 4px 0 rgba(70, 112, 174, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.82) !important;
}

.pixel-button.primary {
  color: #17345f !important;
  border-color: #7bcaa0 !important;
  background: linear-gradient(180deg, #eaffef 0%, #bdf3cf 100%) !important;
}

.pixel-button:hover,
.filter-chip:hover,
.dex-pet-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 6px 0 rgba(70, 112, 174, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.82) !important;
}

.filter-chip {
  color: #244d84 !important;
  background: linear-gradient(180deg, #ffffff 0%, #e4f4ff 100%) !important;
}

.filter-chip.active {
  color: #17345f !important;
  border-color: #7bcaa0 !important;
  background: linear-gradient(180deg, #f3fff3 0%, #c8f5d6 100%) !important;
}

.count-pill,
.tag-row span {
  border-color: rgba(111, 163, 231, 0.48) !important;
  color: #17345f !important;
  background: linear-gradient(180deg, #f4fcff 0%, #d6f3ff 100%) !important;
}

.dex-pet-card,
.evo-card {
  border: 2px solid #86afe9 !important;
  border-radius: 8px !important;
  color: #17345f !important;
  background: linear-gradient(180deg, #f8fdff 0 52%, #dff4ff 52% 100%) !important;
  box-shadow: 0 5px 0 rgba(70, 112, 174, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.82) !important;
}

.dex-pet-card.active,
.evo-card.active {
  border-color: #6fa3e7 !important;
  background: linear-gradient(180deg, #ffffff 0 52%, #cdefff 52% 100%) !important;
  box-shadow: 0 0 0 3px rgba(111, 163, 231, 0.22), 0 5px 0 rgba(70, 112, 174, 0.18) !important;
}

.dex-pet-card span,
.evo-card span {
  color: #17345f !important;
  font-weight: 1000 !important;
}

.dex-pet-card small,
.evo-card small {
  color: #2f76d2 !important;
  font-weight: 900 !important;
}

.dex-thumb,
.evo-card img {
  filter: drop-shadow(0 7px 7px rgba(44, 87, 137, 0.18)) !important;
}

.dex-topbar,
.dex-list-panel,
.dex-detail-panel,
.pet-summary,
.info-card,
.evolution-panel {
  border-width: 2px !important;
  border-radius: 10px !important;
}

#petName,
h1,
h2,
h3 {
  color: #17345f !important;
}

.pet-desc,
.skill-card p,
#habitatText,
#obtainText,
#evolutionText,
.level-line,
.stat-list div {
  color: #24476f !important;
}

.stat-list div {
  border-color: rgba(111, 163, 231, 0.34) !important;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(232, 246, 255, 0.62)) !important;
}

.stat-list b {
  color: #17345f !important;
}

/* Absolute final pet codex stage lock: match sentence-practice companion placement. */
.pet-stage {
  position: relative !important;
  display: block !important;
  overflow: hidden !important;
  min-height: clamp(340px, 43vw, 460px) !important;
  aspect-ratio: 1 / 1.06 !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.08)),
    url("assets/ui/cloud-kingdom-game-bg.png") center center / cover no-repeat !important;
}

.pet-stage::after {
  content: "" !important;
  position: absolute !important;
  left: 50% !important;
  bottom: 13.5% !important;
  width: 54% !important;
  height: 14% !important;
  border-radius: 50% !important;
  background: radial-gradient(ellipse at center, rgba(59, 118, 46, 0.24), rgba(59, 118, 46, 0.08) 48%, transparent 70%) !important;
  transform: translateX(-50%) !important;
  pointer-events: none !important;
}

.pet-stage .pet-aura {
  left: 50% !important;
  top: 46% !important;
  width: 56% !important;
  transform: translate(-50%, -50%) !important;
}

.pet-stage #detailImage {
  --codex-pet-height: 34%;
  position: absolute !important;
  left: 50% !important;
  bottom: 18% !important;
  z-index: 3 !important;
  width: auto !important;
  height: var(--codex-pet-height) !important;
  max-width: 54% !important;
  max-height: 52% !important;
  object-fit: contain !important;
  object-position: center bottom !important;
  transform: translateX(-50%) !important;
  transform-origin: center bottom !important;
  image-rendering: pixelated !important;
  filter:
    drop-shadow(0 14px 12px rgba(28, 68, 112, 0.24))
    drop-shadow(0 0 1px rgba(255, 255, 255, 0.8)) !important;
}

.pet-stage.pet-stage-1 #detailImage,
.pet-stage #detailImage[data-pet-stage="1"] {
  --codex-pet-height: 34%;
  max-width: 42% !important;
}

.pet-stage.pet-stage-2 #detailImage,
.pet-stage #detailImage[data-pet-stage="2"] {
  --codex-pet-height: 43%;
  max-width: 48% !important;
}

.pet-stage.pet-stage-3 #detailImage,
.pet-stage #detailImage[data-pet-stage="3"] {
  --codex-pet-height: 52%;
  max-width: 54% !important;
}

@media (max-width: 720px) {
  .pet-stage {
    min-height: 310px !important;
  }

  .pet-stage #detailImage {
    bottom: 18.5% !important;
  }
}

/* Final detail layout guard: keep the stage from covering the pet text panel. */
.hero-card {
  grid-template-columns: minmax(260px, 0.42fr) minmax(0, 0.58fr) !important;
  align-items: stretch !important;
  column-gap: clamp(18px, 2.2vw, 28px) !important;
}

.hero-card > .pet-stage {
  justify-self: start !important;
  width: 100% !important;
  max-width: 430px !important;
}

.hero-card > .pet-summary {
  position: relative !important;
  z-index: 4 !important;
  min-width: 0 !important;
  margin-left: 0 !important;
  overflow-wrap: anywhere !important;
}

.hero-card > .pet-summary #petName,
.hero-card > .pet-summary .english-name,
.hero-card > .pet-summary .pet-desc {
  max-width: 100% !important;
  overflow-wrap: anywhere !important;
}

.hero-card > .pet-summary #petName {
  font-size: clamp(30px, 4.2vw, 50px) !important;
}

@media (max-width: 980px) {
  .hero-card {
    grid-template-columns: 1fr !important;
  }

  .hero-card > .pet-stage {
    justify-self: center !important;
    max-width: min(100%, 440px) !important;
  }
}

/* My Pets stage alignment: keep companions on the center of the grass field. */
.pet-stage::after {
  bottom: 27% !important;
  width: 48% !important;
  height: 11% !important;
}

.pet-stage .pet-aura {
  top: 54% !important;
  width: 52% !important;
}

.pet-stage #detailImage {
  bottom: 30% !important;
  max-height: 68% !important;
}

.pet-stage.pet-stage-1 #detailImage,
.pet-stage #detailImage[data-pet-stage="1"] {
  --codex-pet-height: 30%;
  max-width: 40% !important;
}

.pet-stage.pet-stage-2 #detailImage,
.pet-stage #detailImage[data-pet-stage="2"] {
  --codex-pet-height: 48%;
  max-width: 56% !important;
}

.pet-stage.pet-stage-3 #detailImage,
.pet-stage #detailImage[data-pet-stage="3"] {
  --codex-pet-height: 64%;
  max-width: 68% !important;
}

.dex-pet-card[data-pet-stage="1"] .dex-thumb {
  height: 72px;
}

.dex-pet-card[data-pet-stage="2"] .dex-thumb {
  height: 88px;
}

.dex-pet-card[data-pet-stage="3"] .dex-thumb {
  height: 102px;
}

@media (max-width: 720px) {
  .pet-stage #detailImage {
    bottom: 30% !important;
  }
}

/* Home layout refinement: keep the existing palette, improve responsive structure. */
body.my-pets-page,
body.pet-detail-page {
  overflow-x: hidden !important;
}

body.my-pets-page .pet-dex-app,
body.pet-detail-page .pet-dex-app {
  width: min(1280px, calc(100vw - 32px)) !important;
  padding: 14px 0 calc(104px + env(safe-area-inset-bottom, 0px)) !important;
}

body.my-pets-page .dex-topbar,
body.pet-detail-page .dex-topbar {
  min-width: 0 !important;
  align-items: center !important;
  gap: 12px !important;
  margin-bottom: 12px !important;
  padding: 12px 14px !important;
}

body.my-pets-page .dex-brand,
body.pet-detail-page .dex-brand {
  min-width: 0 !important;
}

body.my-pets-page .dex-brand h1,
body.pet-detail-page .dex-brand h1 {
  line-height: 1.12 !important;
  white-space: nowrap !important;
}

body.my-pets-page .dex-actions,
body.pet-detail-page .dex-actions {
  justify-content: flex-end !important;
  min-width: 0 !important;
}

body.my-pets-page .dex-actions .pixel-button,
body.pet-detail-page .dex-actions .pixel-button,
body.my-pets-page .button-row .pixel-button,
body.pet-detail-page .button-row .pixel-button {
  min-width: 0 !important;
  white-space: nowrap !important;
}

body.my-pets-page .dex-layout,
body.pet-detail-page .dex-layout {
  align-items: start !important;
  gap: 12px !important;
}

body.my-pets-page .dex-layout {
  grid-template-columns: minmax(270px, 0.31fr) minmax(0, 0.69fr) !important;
}

body.pet-detail-page .dex-layout {
  grid-template-columns: minmax(300px, 0.34fr) minmax(0, 0.66fr) !important;
}

body.my-pets-page .dex-list-panel,
body.my-pets-page .dex-detail-panel,
body.pet-detail-page .dex-list-panel,
body.pet-detail-page .dex-detail-panel {
  min-height: 0 !important;
  padding: 12px !important;
}

body.my-pets-page .dex-grid,
body.pet-detail-page .dex-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
  max-height: min(640px, calc(100vh - 236px)) !important;
  padding: 4px 6px 8px 4px !important;
}

body.my-pets-page .dex-pet-card,
body.pet-detail-page .dex-pet-card {
  min-height: 118px !important;
  padding: 7px !important;
}

body.my-pets-page .dex-thumb,
body.pet-detail-page .dex-thumb {
  height: 72px !important;
}

body.my-pets-page .dex-pet-card[data-pet-stage="2"] .dex-thumb,
body.pet-detail-page .dex-pet-card[data-pet-stage="2"] .dex-thumb {
  height: 78px !important;
}

body.my-pets-page .dex-pet-card[data-pet-stage="3"] .dex-thumb,
body.pet-detail-page .dex-pet-card[data-pet-stage="3"] .dex-thumb {
  height: 86px !important;
}

body.my-pets-page .hero-card,
body.pet-detail-page .hero-card {
  grid-template-columns: minmax(250px, 0.46fr) minmax(0, 0.54fr) !important;
  gap: 12px !important;
  margin-bottom: 12px !important;
}

body.my-pets-page .hero-card > .pet-stage,
body.pet-detail-page .hero-card > .pet-stage {
  max-width: none !important;
}

body.my-pets-page .pet-stage,
body.pet-detail-page .pet-stage {
  min-height: clamp(280px, 30vw, 390px) !important;
}

body.my-pets-page .pet-summary,
body.pet-detail-page .pet-summary {
  min-height: clamp(280px, 30vw, 390px) !important;
  padding: 16px !important;
}

body.my-pets-page .hero-card > .pet-summary #petName,
body.pet-detail-page .hero-card > .pet-summary #petName {
  font-size: clamp(28px, 3.2vw, 44px) !important;
}

body.my-pets-page .pet-desc,
body.pet-detail-page .pet-desc {
  margin: 12px 0 !important;
  line-height: 1.55 !important;
}

body.my-pets-page .button-row,
body.pet-detail-page .button-row {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

body.my-pets-page .detail-grid,
body.pet-detail-page .detail-grid {
  gap: 10px !important;
  margin-bottom: 12px !important;
}

body.my-pets-page .info-card,
body.pet-detail-page .info-card,
body.pet-detail-page .evolution-panel {
  min-width: 0 !important;
  padding: 12px !important;
}

@media (min-width: 721px) and (max-width: 1050px) {
  body.my-pets-page .pet-dex-app,
  body.pet-detail-page .pet-dex-app {
    width: min(740px, calc(100vw - 28px)) !important;
  }

  body.my-pets-page .dex-layout,
  body.pet-detail-page .dex-layout {
    grid-template-columns: 1fr !important;
  }

  body.my-pets-page .dex-detail-panel,
  body.pet-detail-page .dex-detail-panel {
    order: 1 !important;
  }

  body.my-pets-page .dex-list-panel,
  body.pet-detail-page .dex-list-panel {
    order: 2 !important;
  }

  body.my-pets-page .hero-card,
  body.pet-detail-page .hero-card {
    grid-template-columns: minmax(250px, 0.48fr) minmax(0, 0.52fr) !important;
  }

  body.my-pets-page .pet-stage,
  body.my-pets-page .pet-summary,
  body.pet-detail-page .pet-stage,
  body.pet-detail-page .pet-summary {
    min-height: 300px !important;
  }

  body.my-pets-page .dex-grid,
  body.pet-detail-page .dex-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    max-height: none !important;
  }
}

@media (max-width: 720px) {
  body.my-pets-page .pet-dex-app,
  body.pet-detail-page .pet-dex-app {
    width: 100% !important;
    max-width: 100vw !important;
    padding: 7px 7px calc(104px + env(safe-area-inset-bottom, 0px)) !important;
  }

  body.my-pets-page .dex-topbar,
  body.pet-detail-page .dex-topbar {
    align-items: stretch !important;
    gap: 8px !important;
    padding: 9px !important;
  }

  body.my-pets-page .dex-brand,
  body.pet-detail-page .dex-brand {
    gap: 8px !important;
  }

  body.my-pets-page .brand-ball,
  body.pet-detail-page .brand-ball {
    width: 40px !important;
    height: 40px !important;
    font-size: 20px !important;
  }

  body.my-pets-page .dex-brand h1,
  body.pet-detail-page .dex-brand h1 {
    font-size: 22px !important;
  }

  body.my-pets-page .dex-actions,
  body.pet-detail-page .dex-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }

  body.my-pets-page .dex-actions .pixel-button,
  body.pet-detail-page .dex-actions .pixel-button {
    min-height: 36px !important;
    padding: 7px 5px !important;
    font-size: 12px !important;
    line-height: 1.1 !important;
    white-space: normal !important;
  }

  body.my-pets-page .dex-layout,
  body.pet-detail-page .dex-layout {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  body.my-pets-page .dex-detail-panel,
  body.pet-detail-page .dex-detail-panel {
    order: 1 !important;
  }

  body.my-pets-page .dex-list-panel,
  body.pet-detail-page .dex-list-panel {
    order: 2 !important;
  }

  body.my-pets-page .dex-list-panel,
  body.my-pets-page .dex-detail-panel,
  body.pet-detail-page .dex-list-panel,
  body.pet-detail-page .dex-detail-panel {
    width: 100% !important;
    padding: 9px !important;
  }

  body.my-pets-page .hero-card,
  body.pet-detail-page .hero-card {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    margin-bottom: 8px !important;
  }

  body.my-pets-page .pet-stage,
  body.pet-detail-page .pet-stage {
    min-height: 236px !important;
    max-height: 280px !important;
    aspect-ratio: 1.18 / 1 !important;
  }

  body.my-pets-page .pet-summary,
  body.pet-detail-page .pet-summary {
    min-height: 0 !important;
    padding: 12px !important;
  }

  body.my-pets-page .hero-card > .pet-summary #petName,
  body.pet-detail-page .hero-card > .pet-summary #petName {
    font-size: 30px !important;
  }

  body.my-pets-page .english-name,
  body.pet-detail-page .english-name {
    margin: 4px 0 8px !important;
  }

  body.my-pets-page .tag-row,
  body.pet-detail-page .tag-row {
    gap: 6px !important;
  }

  body.my-pets-page .tag-row span,
  body.pet-detail-page .tag-row span {
    padding: 4px 6px !important;
    font-size: 12px !important;
  }

  body.my-pets-page .pet-desc,
  body.pet-detail-page .pet-desc {
    margin: 9px 0 !important;
    font-size: 14px !important;
    line-height: 1.45 !important;
  }

  body.my-pets-page .button-row,
  body.pet-detail-page .button-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 7px !important;
  }

  body.my-pets-page .button-row .pixel-button,
  body.pet-detail-page .button-row .pixel-button {
    min-height: 38px !important;
    padding: 8px 6px !important;
    font-size: 13px !important;
  }

  body.my-pets-page .detail-grid,
  body.pet-detail-page .detail-grid,
  body.pet-detail-page .evolution-chain {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  body.my-pets-page .info-card,
  body.pet-detail-page .info-card,
  body.pet-detail-page .evolution-panel {
    padding: 10px !important;
  }

  body.my-pets-page .panel-head,
  body.pet-detail-page .panel-head {
    margin-bottom: 8px !important;
  }

  body.my-pets-page .dex-grid,
  body.pet-detail-page .dex-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    max-height: none !important;
    gap: 7px !important;
    padding: 2px !important;
    overflow: visible !important;
  }

  body.my-pets-page .dex-pet-card,
  body.pet-detail-page .dex-pet-card {
    min-height: 112px !important;
    padding: 6px !important;
  }

  body.my-pets-page .dex-thumb,
  body.pet-detail-page .dex-thumb,
  body.my-pets-page .dex-pet-card[data-pet-stage="2"] .dex-thumb,
  body.pet-detail-page .dex-pet-card[data-pet-stage="2"] .dex-thumb,
  body.my-pets-page .dex-pet-card[data-pet-stage="3"] .dex-thumb,
  body.pet-detail-page .dex-pet-card[data-pet-stage="3"] .dex-thumb {
    height: 66px !important;
  }
}

