:root {
  --ink: #fff8eb;
  --gold: #ffd260;
  --blue: #5f8cff;
  --orange: #c7723e;
  --panel: rgba(8, 10, 16, 0.88);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: #111;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  touch-action: manipulation;
}

.funhouse {
  position: relative;
  min-height: 100svh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.06)),
    url("assets/funhouse-background.png") center / cover no-repeat;
}

.funhouse::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.hero {
  position: relative;
  z-index: 2;
  width: min(52rem, calc(100% - 9rem));
  padding: clamp(13.5rem, 31vh, 19rem) 0 0 clamp(1.4rem, 8vw, 6.2rem);
}

h1 {
  max-width: 11ch;
  margin: 0;
  color: #fffaf0;
  font-size: clamp(2.75rem, 7vw, 5.2rem);
  line-height: 0.86;
  letter-spacing: 0;
  text-transform: uppercase;
  animation: neonSnackSign 5.8s steps(1, end) infinite;
  text-shadow:
    0 0 0 #1b2435,
    0 4px 0 #1b2435,
    0 0 10px rgba(255, 210, 96, 0.35),
    0 0 24px rgba(95, 140, 255, 0.22),
    6px 6px 0 var(--orange),
    10px 10px 0 #16274b,
    0 14px 18px rgba(0, 0, 0, 0.6);
}

h1 a {
  color: inherit;
  text-decoration: none;
}

h1.awoo {
  animation: titleWiggle 0.35s ease-in-out 7, neonSnackSign 5.8s steps(1, end) infinite;
}

.subtitle {
  max-width: 40rem;
  margin: 1.25rem 0 0;
  color: #fff;
  font-size: clamp(1rem, 2vw, 1.18rem);
  font-weight: 900;
  line-height: 1.35;
  text-shadow: 0 3px 8px #000;
}

.feed-scene {
  position: absolute;
  z-index: 3;
  right: clamp(5.5rem, 14vw, 12rem);
  bottom: clamp(4.8rem, 11vh, 8rem);
  width: min(30rem, 42vw);
  min-width: 18rem;
  display: grid;
  justify-items: center;
  gap: 1rem;
}

.dog-popout {
  position: relative;
  width: min(19rem, 80%);
  cursor: pointer;
  filter: drop-shadow(0 28px 42px rgba(0, 0, 0, 0.45));
}

.dog-photo {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.nose-button {
  position: absolute;
  left: 48%;
  top: 31%;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.background-nose-button {
  position: absolute;
  z-index: 4;
  left: 54%;
  top: 60%;
  width: 14vw;
  max-width: 11rem;
  min-width: 5rem;
  aspect-ratio: 1 / 0.65;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.food-ground {
  position: relative;
  width: min(32rem, 100%);
  min-height: 6.7rem;
}

.food-item {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 0.18rem;
  min-width: 4.2rem;
  min-height: 4.2rem;
  padding: 0.1rem;
  color: #fff;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.55));
}

.food-item:nth-child(1) { left: 1%; top: 1.5rem; }
.food-item:nth-child(2) { left: 20%; top: 3.6rem; }
.food-item:nth-child(3) { left: 39%; top: 1.2rem; }
.food-item:nth-child(4) { right: 30%; top: 3.4rem; }
.food-item:nth-child(5) { right: 13%; top: 1rem; }
.food-item:nth-child(6) { right: 0; top: 3.7rem; }

.food-icon {
  font-size: 2.15rem;
  line-height: 1;
}

.food-name {
  font-size: 0.62rem;
  font-weight: 950;
  text-transform: uppercase;
  text-shadow: 0 2px 8px #000;
}

.side-rail,
.corner-rail {
  position: fixed;
  z-index: 9;
  display: grid;
}

.side-rail {
  top: 6.25rem;
  right: 1.1rem;
  left: auto;
  bottom: auto;
  grid-auto-flow: column;
  grid-auto-columns: 3rem;
  gap: 0.48rem;
}

.corner-rail {
  right: 0.75rem;
  left: auto !important;
  bottom: 1.15rem;
  top: auto !important;
  grid-auto-flow: column;
  grid-auto-columns: 3rem;
  gap: 0.32rem;
}

.icon-button,
.hidden-treat-bag {
  background: transparent;
  color: #fff;
  cursor: pointer;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.55));
}

.icon-button {
  width: max(3rem, 44px);
  height: max(3rem, 44px);
  display: grid;
  place-items: center;
  font-size: 1.75rem;
}

.icon-button:hover,
.icon-button:focus-visible {
  transform: translateY(-3px) rotate(-6deg);
  outline: none;
}

.secret-paw {
  font-size: 1.8rem;
  filter: grayscale(1) brightness(3.2) contrast(1.45) drop-shadow(0 10px 12px rgba(0, 0, 0, 0.65));
}

.hidden-treat-bag {
  position: fixed;
  z-index: 8;
  left: 1.4rem;
  bottom: 1.1rem;
  width: 5rem;
  display: grid;
  justify-items: center;
  opacity: 0.38;
  transition: opacity 180ms ease, transform 180ms ease;
}

.hidden-treat-bag img {
  width: 100%;
}

.hidden-treat-bag:hover,
.hidden-treat-bag:focus-visible {
  opacity: 0.72;
}

.mood-card,
.debt-card,
.receipt,
.river-badge {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%) translateY(140%);
  padding: 0.85rem 1.3rem;
  border-radius: 1.4rem;
  background: rgba(12, 14, 18, 0.88);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: 220ms ease;
  pointer-events: none;
}

.mood-card.show,
.debt-card.show,
.receipt.show,
.river-badge.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.debt-card,
.receipt {
  display: grid;
  gap: 0.25rem;
  text-align: center;
}

.modal {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: none;
  place-items: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.62);
}

.modal.show {
  display: grid;
}

.panel,
.video-panel {
  position: relative;
  width: min(31rem, 100%);
  max-height: min(86svh, 44rem);
  overflow: auto;
  padding: 1.55rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0.55rem;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.panel h2 {
  margin: 0 0 0.75rem;
  color: var(--gold);
}

.panel p {
  margin: 0.45rem 0;
  font-weight: 800;
  line-height: 1.45;
}

.primary-action,
.command-entry button {
  margin-top: 1rem;
  padding: 0.85rem 1.15rem;
  border-radius: 999px;
  background: var(--gold);
  color: #141414;
  font-weight: 950;
  cursor: pointer;
}

.close-button {
  position: absolute;
  top: 0.65rem;
  right: 0.7rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}

.commands-panel dl {
  display: grid;
  gap: 0.6rem;
  margin: 1rem 0 0;
}

.commands-panel dl div {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 0.8rem;
}

.commands-panel dt {
  color: var(--gold);
  font-weight: 950;
}

.commands-panel dd {
  margin: 0;
}

.command-entry label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 900;
}

.command-entry div {
  display: flex;
  gap: 0.55rem;
}

.command-entry input {
  min-width: 0;
  flex: 1;
  font-size: 16px;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.video-panel {
  width: min(60rem, 100%);
  display: grid;
  gap: 0.75rem;
}

.video-panel iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 0.45rem;
  background: #000;
}

.video-panel a {
  color: var(--gold);
  font-weight: 900;
}

.river-cameo {
  position: fixed;
  z-index: 26;
  left: -10rem;
  bottom: 3rem;
  width: 8rem;
  pointer-events: none;
  opacity: 0;
}

.river-cameo img {
  width: 100%;
}

.river-cameo.run-right {
  animation: catRight 5s linear forwards;
}

.river-cameo.run-left {
  animation: catLeft 5s linear forwards;
}

.paw-trail,
.hotdog-rain,
.autograph-layer {
  position: fixed;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.falling-hotdog,
.trail-paw,
.signature-paw {
  position: absolute;
  font-size: 1.8rem;
  text-shadow: 0 4px 12px #000;
}

.falling-hotdog {
  animation: fall 3.4s linear forwards;
}

.trail-paw {
  opacity: 0;
  animation: pawFade 4s ease forwards;
}

.signature-paw {
  color: var(--gold);
  animation: pawFade 6s ease forwards;
}

.dog-popout.eating { animation: chomp 380ms ease-in-out 2; }
.dog-popout.flipping { animation: puppyFlip 850ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.dog-popout.zooming { animation: zoomDog 420ms linear infinite; }
.dog-popout.squirrel-mode { animation: squirrelSpin 420ms linear infinite; }
.dog-popout.napping { animation: napFloat 1.4s ease-in-out infinite; filter: grayscale(0.25) drop-shadow(0 28px 42px rgba(0, 0, 0, 0.45)); }
.dog-popout.confused { filter: hue-rotate(72deg) saturate(0.75) drop-shadow(0 28px 42px rgba(0, 0, 0, 0.45)); }
.food-item.tossing { animation: tossToMouth 820ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.funhouse.zoomies { animation: screenShake 320ms linear 8; }

@keyframes titleWiggle {
  0%, 100% { transform: rotate(0); }
  35% { transform: rotate(-2deg) translateY(-3px); }
  70% { transform: rotate(2deg) translateY(3px); }
}

@keyframes neonSnackSign {
  0%, 8%, 10%, 12%, 100% {
    opacity: 1;
    filter: brightness(1.08);
  }
  9%, 11% {
    opacity: 0.72;
    filter: brightness(0.78);
  }
  48% {
    opacity: 1;
    filter: brightness(1.22);
  }
  49% {
    opacity: 0.86;
    filter: brightness(0.92);
  }
  50% {
    opacity: 1;
    filter: brightness(1.16);
  }
}

@keyframes chomp {
  50% { transform: scale(1.05) rotate(-2deg); }
}

@keyframes puppyFlip {
  to { transform: rotate(360deg); }
}

@keyframes boopBounce {
  50% { transform: scale(0.95) translateY(6px); }
}

@keyframes zoomDog {
  50% { transform: translateX(14px) rotate(3deg); }
}

@keyframes squirrelSpin {
  to { transform: rotate(360deg) scale(1.06); }
}

@keyframes napFloat {
  50% { transform: translateY(8px); }
}

@keyframes tossToMouth {
  70% { transform: translate(-6rem, -10rem) scale(0.25) rotate(360deg); opacity: 0.75; }
  100% { opacity: 0; }
}

@keyframes screenShake {
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

@keyframes catRight {
  0% { opacity: 1; left: -10rem; transform: scaleX(1); }
  100% { opacity: 1; left: calc(100vw + 3rem); transform: scaleX(1); }
}

@keyframes catLeft {
  0% { opacity: 1; left: calc(100vw + 3rem); transform: scaleX(-1); }
  100% { opacity: 1; left: -10rem; transform: scaleX(-1); }
}

@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

@keyframes pawFade {
  0% { opacity: 0; transform: scale(0.6); }
  18%, 78% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.2); }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .hero {
    width: min(44rem, calc(100% - 4rem));
    padding: clamp(9rem, 21vh, 14rem) 0 0 clamp(1.5rem, 5vw, 4rem);
  }

  h1 {
    font-size: clamp(3rem, 7.2vw, 4.8rem);
  }

  .feed-scene {
    right: clamp(3.5rem, 8vw, 6.5rem);
    bottom: clamp(4.8rem, 10vh, 7.5rem);
    width: min(28rem, 48vw);
  }

  .side-rail {
    top: 1rem;
  }
}

@media (max-width: 760px) {
  .funhouse {
    min-height: 100svh;
    min-height: 100dvh;
    background-position: center top;
  }

  .hero {
    width: min(100% - 1.5rem, 29rem);
    padding: clamp(7.7rem, 18svh, 9.8rem) 0 0 clamp(0.75rem, 4vw, 1.1rem);
  }

  h1 {
    max-width: 11.2ch;
    font-size: clamp(1.9rem, 8.8vw, 2.75rem);
    line-height: 0.9;
  }

  .subtitle {
    max-width: min(23rem, calc(100vw - 2rem));
    margin-top: 0.7rem;
    font-size: clamp(0.88rem, 3.4vw, 1rem);
  }

  .feed-scene {
    left: 0.85rem;
    right: 0.85rem;
    top: clamp(21rem, 48svh, 31rem);
    bottom: auto;
    width: auto;
    min-width: 0;
    gap: 0.65rem;
  }

  .dog-popout {
    width: min(12rem, 52vw);
  }

  .food-ground {
    width: min(25rem, 100%);
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(0.1rem, 1vw, 0.28rem) 0.2rem;
  }

  .food-item {
    position: static;
    min-width: 3.75rem;
    min-height: 3.75rem;
    justify-self: center;
  }

  .food-icon {
    font-size: 1.9rem;
  }

  .food-name {
    font-size: 0.54rem;
  }

  .side-rail {
    right: 0.42rem;
    left: auto;
    top: max(0.45rem, env(safe-area-inset-top));
    grid-auto-flow: column;
    grid-auto-columns: 2.7rem;
    gap: 0.18rem;
  }

  .corner-rail {
    right: 0.42rem;
    left: auto !important;
    bottom: max(0.55rem, env(safe-area-inset-bottom));
    top: auto !important;
    grid-auto-flow: column;
    grid-auto-columns: 2.7rem;
    gap: 0.18rem;
  }

  .icon-button {
    width: max(2.7rem, 44px);
    height: max(2.7rem, 44px);
    font-size: 1.45rem;
  }

  .hidden-treat-bag {
    left: 0.45rem;
    bottom: max(0.55rem, env(safe-area-inset-bottom));
    width: 4rem;
  }

  .background-nose-button {
    left: 38%;
    top: 59%;
    width: 34vw;
  }

  .commands-panel dl div {
    grid-template-columns: 5.2rem 1fr;
  }

  .mood-card,
  .debt-card,
  .receipt,
  .river-badge {
    width: min(calc(100% - 1.5rem), 28rem);
    bottom: max(4.1rem, calc(env(safe-area-inset-bottom) + 3.6rem));
    text-align: center;
  }

  .command-entry div {
    display: grid;
    grid-template-columns: 1fr;
  }

  .command-entry button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  h1 {
    max-width: 10.8ch;
    font-size: clamp(1.75rem, 8.4vw, 2.45rem);
  }

  .subtitle {
    font-size: 0.9rem;
  }

  .panel {
    padding: 1.2rem;
  }

  .side-rail,
  .corner-rail {
    grid-auto-columns: 2.45rem;
  }

  .icon-button {
    width: max(2.45rem, 44px);
    height: max(2.45rem, 44px);
    font-size: 1.32rem;
  }

  .dog-popout {
    width: min(10.75rem, 50vw);
  }

  .food-icon {
    font-size: 1.65rem;
  }

  .food-name {
    font-size: 0.48rem;
  }
}
