.pet-dock, .pet-field {
  --pet-border: color-mix(in srgb, var(--brand-accent) 26%, var(--line-strong));
  --pet-tint: color-mix(in srgb, var(--brand-accent) 10%, var(--bg-surface));
  font: 600 .875rem/1.45 var(--font);
  color: var(--ink-1);
}

.pet-dock {
  position: fixed;
  z-index: 45;
  inset-inline-end: max(12px, env(safe-area-inset-right));
  inset-block-end: max(12px, env(safe-area-inset-bottom));
}

.pet-trigger {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 46px;
  padding: 3px 15px 3px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--pet-border);
  border-radius: var(--r-pill);
  cursor: pointer;
  box-shadow: 0 4px 18px #16251d22;
  list-style: none;
}

.pet-trigger::-webkit-details-marker { display: none; }
.pet-trigger img { width: 28px; height: 34px; object-fit: contain; }
.pet-trigger img + img { margin-inline-start: -11px; }

.pet-room {
  position: absolute;
  z-index: 1;
  inset-inline-end: 0;
  inset-block-end: calc(100% + 8px);
  width: min(356px, calc(100vw - 24px));
  max-height: calc(100dvh - 85px - env(safe-area-inset-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 17px;
  border: 1px solid var(--pet-border);
  border-radius: 20px;
  background: var(--bg-surface);
  box-shadow: 0 12px 36px #18251f32;
}

.pet-room [hidden], .pet-field[hidden], .pet-bubble[hidden] { display: none; }
.pet-room h2 {
  color: var(--ink-1);
  font-size: 1.24rem;
  margin: 0 0 5px;
  line-height: 1.25;
}

.pet-hint { color: var(--ink-2); font-weight: 450; }
.pet-message:not(:empty) {
  margin-block: 10px;
  padding: 9px 12px;
  border-inline-start: 2px solid var(--brand-accent);
  border-radius: 0 8px 8px 0;
  background: var(--pet-tint);
  overflow-wrap: anywhere;
}

.pet-actions, .pet-toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.pet-actions { margin-block: 12px; }
.pet-toolbar {
  justify-content: space-between;
  align-items: center;
  margin-block-start: 12px;
}
.pet-utility, .pet-back, .pet-room-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--ink-1);
  cursor: pointer;
  font: inherit;
  text-align: center;
}
.pet-utility {
  flex: 1 0 auto;
  padding: 4px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--bg-surface);
}
.pet-toolbar .pet-utility { flex: 0 1 auto; }
.pet-utility:disabled { cursor: default; opacity: .58; }
.pet-back, .pet-room-link {
  padding-inline: 4px;
  border: 0;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.pet-back { margin-block: -4px 7px; }
.pet-game-links { display: grid; gap: 6px; }
.pet-game-link {
  display: grid;
  gap: 3px;
  min-height: 44px;
  width: 100%;
  padding: 9px 12px;
  background: var(--pet-tint);
  border: 1px solid var(--pet-border);
  border-radius: 11px;
  color: var(--ink-1);
  cursor: pointer;
  font: inherit;
  text-align: start;
}
.pet-game-link strong { font-size: .95rem; }
.pet-game-link span { color: var(--ink-2); font-weight: 450; }

.pet-board {
  display: grid;
  gap: 10px;
  margin-block-start: 12px;
  padding: 12px;
  border: 1px solid var(--pet-border);
  border-radius: 14px;
  background: var(--pet-tint);
}

.pet-score { font-size: 1rem; font-variant-numeric: tabular-nums; }
.pet-sequence, .pet-choices { display: flex; flex-wrap: wrap; gap: 5px; }
.pet-sequence { padding: 0; margin: 0; list-style-position: inside; }
.pet-sequence-item {
  flex: 1 1 45px;
  padding: 3px;
  text-align: center;
  font-size: .72rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.pet-sequence-item img { display: block; width: 34px; height: 39px; margin: 0 auto 3px; object-fit: contain; }

.pet-choice, .pet-primary {
  min-height: 44px;
  border: 1px solid var(--pet-border);
  border-radius: 9px;
  color: var(--ink-1);
  background: var(--bg-surface);
  cursor: pointer;
  font: inherit;
}
.pet-choice { flex: 1 1 70px; padding: 6px; }
.pet-choice img, .pet-opponent img { width: 45px; height: 50px; object-fit: contain; }
.pet-choice img { display: block; margin: 0 auto 4px; }
.pet-primary { padding: 4px 12px; font-weight: 750; }
.pet-opponent { display: flex; align-items: center; gap: 8px; }
.pet-room button:hover { border-color: var(--brand-accent); }
.pet-room button:focus-visible, .pet-actor:focus-visible, .pet-trigger:focus-visible {
  outline: 2px solid var(--brand-accent);
  outline-offset: 2px;
}

.pet-field {
  position: fixed;
  z-index: 44;
  inset: 0;
  pointer-events: none;
}
.pet-actor {
  position: fixed;
  z-index: 0;
  inset: 0 auto auto 0;
  width: 68px;
  height: 76px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  touch-action: none;
  user-select: none;
  pointer-events: auto;
  cursor: grab;
  filter: drop-shadow(0 3px 3px #17251f44);
}
.pet-actor:active { cursor: grabbing; }
.pet-actor img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.pet-bubble {
  position: fixed;
  inset: 0 auto auto 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  max-width: min(260px, calc(100vw - 16px));
  padding: 8px 12px;
  border: 1px solid var(--pet-border);
  border-radius: 14px;
  background: var(--bg-surface);
  box-shadow: 0 4px 13px #16251d25;
}
.pet-bubble-icon { color: var(--brand-accent); }

@media (prefers-reduced-motion: no-preference) {
  .pet-actor.is-walking img { animation: pet-step 620ms ease-in-out infinite alternate; }
  @keyframes pet-step {
    to { transform: translateY(-3px); }
  }
}

@media (max-width: 640px) {
  .pet-room { max-height: calc(100dvh - 160px - env(safe-area-inset-bottom)); }
}

@media print {
  .pet-dock, .pet-field { display: none; }
}
