:root {
  --ink: #03060c;
  --mist: #d7e4f2;
  --accent: #6ec8ff;
  --fur: #c4a574;
  --fur-dark: #8a6a3e;
  --snout: #e8d4b0;
  --glow: rgba(80, 140, 220, 0.14);
  --nebula: rgba(90, 70, 160, 0.1);
  --intro-clicks: 10;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--mist);
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 18% 12%, var(--glow), transparent 58%),
    radial-gradient(ellipse 55% 45% at 88% 78%, var(--nebula), transparent 55%),
    linear-gradient(165deg, #02040a 0%, #050a14 42%, #071018 100%);
  pointer-events: none;
  z-index: 0;
}

.top {
  position: relative;
  z-index: 2;
  padding: 1.25rem clamp(1.25rem, 4vw, 2.5rem) 0;
}

.back {
  color: var(--mist);
  text-decoration: none;
  opacity: 0.7;
  font-size: 0.95rem;
}

.back:hover,
.back:focus-visible {
  opacity: 1;
  color: var(--accent);
}

.title {
  margin: 0.85rem 0 0;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.screen {
  position: relative;
  z-index: 1;
}

.screen[hidden] {
  display: none;
}

.screen-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 7rem);
  padding: 1rem;
  gap: 0.5rem;
}

.hint {
  margin: 0;
  opacity: 0.65;
  font-size: 1rem;
  min-height: 1.4em;
}

.stage {
  position: relative;
  width: min(100%, 42rem);
  height: 14rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.dog {
  position: relative;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transform: translateX(0);
  will-change: transform;
}

.dog:disabled {
  cursor: default;
}

.dog:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 10px;
  border-radius: 50%;
}

.dog svg {
  display: block;
  overflow: visible;
}

.dog:not(:disabled):active svg {
  transform: scale(0.96);
}

.dog.woofing .dog-body {
  animation: bounce 0.35s ease;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px) scale(1.03);
  }
}

.body,
.head,
.leg,
.ear,
.tail {
  fill: var(--fur);
}

.ear-inner {
  fill: #d4b896;
}

.snout {
  fill: var(--snout);
}

.nose,
.eye {
  fill: #1a1410;
}

.eye-shine {
  fill: #fff;
}

.mouth,
.mouth-huff,
.brow {
  stroke: #5a4030;
}

.mouth-huff,
.brow {
  opacity: 0;
}

.dog.huffy .mouth {
  opacity: 0;
}

.dog.huffy .mouth-huff,
.dog.huffy .brow {
  opacity: 1;
}

.dog.huffy .brow-l,
.dog.huffy .brow-r {
  stroke: #2a1c12;
}

.dog.huffy .head-group {
  transform-origin: 148px 78px;
  transform: rotate(-18deg) translate(4px, -6px);
  transition: transform 0.35s ease;
}

.head-group {
  transition: transform 0.35s ease;
}

.tail {
  stroke: var(--fur);
  fill: none;
  transform-origin: 52px 108px;
}

.dog.woofing .tail {
  animation: wag 0.28s ease-in-out 2;
}

.dog.huffy .tail {
  animation: none;
  transform: rotate(12deg);
}

@keyframes wag {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(-22deg);
  }
}

.shadow {
  fill: rgba(0, 0, 0, 0.35);
  transition: opacity 0.4s ease;
}

.dog.departing {
  pointer-events: none;
  animation: walk-off 2.4s cubic-bezier(0.33, 0.1, 0.25, 1) forwards;
}

.dog.departing .legs {
  animation: stride 0.32s ease-in-out infinite;
}

.dog.departing .shadow {
  opacity: 0.2;
}

@keyframes stride {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes walk-off {
  0% {
    transform: translateX(0) translateY(0);
  }
  12% {
    transform: translateX(8px) translateY(-2px);
  }
  100% {
    transform: translateX(120vw) translateY(0);
  }
}

.bubble {
  position: absolute;
  top: 8%;
  right: -10%;
  padding: 0.45rem 0.75rem;
  border-radius: 1rem 1rem 1rem 0.25rem;
  background: rgba(215, 228, 242, 0.95);
  color: #0a1220;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.35rem;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.bubble[hidden] {
  display: none;
}

.screen-end {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: calc(100vh - 7rem);
  padding: clamp(2rem, 6vw, 4rem);
  max-width: 36rem;
}

.screen-end[hidden] {
  display: none;
}

.end-title {
  margin: 0 0 0.75rem;
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.02em;
}

.end-lede {
  margin: 0;
  opacity: 0.75;
  font-size: 1.1rem;
  max-width: 28ch;
}

.actions {
  margin: 2rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
}

.again,
.home {
  display: inline-block;
  padding: 0.65rem 1.05rem;
  border: 1px solid rgba(110, 200, 255, 0.45);
  color: var(--mist);
  text-decoration: none;
  font: inherit;
  font-size: 0.95rem;
  background: rgba(110, 200, 255, 0.08);
  cursor: pointer;
}

.again:hover,
.again:focus-visible,
.home:hover,
.home:focus-visible {
  background: rgba(110, 200, 255, 0.16);
  border-color: var(--accent);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .dog.woofing .dog-body,
  .dog.woofing .tail,
  .dog.departing,
  .dog.departing .legs {
    animation: none;
  }

  .dog.departing {
    opacity: 0;
    transition: opacity 0.4s ease;
  }

  .dog.huffy .head-group {
    transition: none;
  }
}
