:root {
  --ink: #17291b;
  --panel: rgba(255, 251, 205, 0.9);
  --panel-strong: rgba(255, 249, 184, 0.96);
  --line: rgba(31, 69, 40, 0.22);
  --health: #55c85c;
  --happy: #ffd84d;
  --hunger: #ff8a35;
  --accent: #ff7a3d;
  --blue: #77b9e8;
  --aura: #33d65b;
  --aura-soft: rgba(51, 214, 91, 0.34);
  --aura-blur: 18px;
  --aura-spread: 34px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: "Courier New", ui-monospace, monospace;
  color: var(--ink);
  background: #82bee3;
  image-rendering: pixelated;
}

button {
  font: inherit;
}

.home {
  width: 100vw;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
}

.scene {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.12), rgba(51, 93, 47, 0.28)),
    url("assets/pixel-valley.png");
  background-size: cover;
  background-position: center;
  image-rendering: pixelated;
}

.scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(255, 255, 255, 0.08) 50%, rgba(0, 0, 0, 0.07) 50%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 50%, rgba(0, 0, 0, 0.025) 50%),
    radial-gradient(circle at 54% 54%, rgba(255, 252, 180, 0.2), transparent 24%),
    linear-gradient(to bottom, rgba(25, 98, 158, 0.04), rgba(8, 49, 22, 0.36));
  background-size: 100% 4px, 4px 100%, auto, auto;
  pointer-events: none;
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 8px 8px;
  opacity: 0.16;
  pointer-events: none;
}

.brand {
  position: absolute;
  top: clamp(16px, 4vmin, 38px);
  left: clamp(16px, 5vw, 64px);
  z-index: 4;
  max-width: min(920px, calc(100vw - 28px));
  text-shadow:
    4px 0 0 #1d3b21,
    0 4px 0 #1d3b21,
    4px 4px 0 #1d3b21,
    8px 8px 0 rgba(13, 48, 20, 0.42);
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7.2vmin, 5.6rem);
  line-height: 0.92;
  letter-spacing: 0;
  color: #fff9c7;
  text-transform: uppercase;
  -webkit-text-stroke: 0;
}

.hud {
  position: absolute;
  top: clamp(14px, 3.3vmin, 32px);
  right: clamp(12px, 3vw, 42px);
  z-index: 5;
  width: min(380px, calc(100vw - 32px));
  padding: 12px;
  border: 4px solid #203b25;
  border-radius: 0;
  background: var(--panel);
  box-shadow: 6px 6px 0 rgba(24, 67, 39, 0.58);
}

.bar-row {
  display: grid;
  grid-template-columns: 88px 1fr 34px;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  font-size: 0.86rem;
  font-weight: 900;
}

.bar-row + .bar-row {
  margin-top: 7px;
}

.bar {
  height: 17px;
  overflow: hidden;
  border: 3px solid #1d3321;
  border-radius: 0;
  background: rgba(31, 57, 42, 0.22);
  box-shadow: none;
}

.bar i {
  display: block;
  width: 50%;
  height: 100%;
  border-radius: inherit;
  transition: width 280ms ease;
  image-rendering: pixelated;
}

.health i {
  background: repeating-linear-gradient(90deg, #35a853 0 8px, var(--health) 8px 16px, #a4f071 16px 24px);
}

.happiness i {
  background: repeating-linear-gradient(90deg, #ffa13b 0 8px, var(--happy) 8px 16px, #fff587 16px 24px);
}

.hunger i {
  background: repeating-linear-gradient(90deg, #d94d27 0 8px, var(--hunger) 8px 16px, #ffd05a 16px 24px);
}

.info-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 8px 0 0;
  padding-top: 7px;
  border-top: 3px solid rgba(29, 51, 33, 0.42);
}

.info-button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 3px solid #203b25;
  border-radius: 0;
  color: #203b25;
  background: #fff9b8;
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 3px 3px 0 rgba(24, 67, 39, 0.5);
  cursor: help;
}

.info-popover {
  position: absolute;
  top: 36px;
  left: 0;
  z-index: 20;
  display: grid;
  gap: 6px;
  width: min(310px, calc(100vw - 54px));
  padding: 10px;
  border: 4px solid #203b25;
  background: #fff9b8;
  box-shadow: 6px 6px 0 rgba(24, 67, 39, 0.58);
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1.25;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.info-wrap:hover .info-popover,
.info-wrap:focus-within .info-popover {
  opacity: 1;
  transform: translateY(0);
}

.weather-strip {
  position: absolute;
  top: 18%;
  left: 0;
  width: 100%;
  height: 10px;
  z-index: 1;
  opacity: 0.55;
  pointer-events: none;
}

.weather-strip span {
  position: absolute;
  display: block;
  width: 68px;
  height: 8px;
  image-rendering: pixelated;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 20px 8px 0 rgba(255, 255, 255, 0.48), 44px -8px 0 rgba(255, 255, 255, 0.42);
  animation: drift 18s linear infinite;
}

.weather-strip span:nth-child(1) { left: -12%; top: 0; animation-delay: 0s; }
.weather-strip span:nth-child(2) { left: 16%; top: 44px; animation-delay: -7s; }
.weather-strip span:nth-child(3) { left: 44%; top: -18px; animation-delay: -13s; }
.weather-strip span:nth-child(4) { left: 72%; top: 32px; animation-delay: -4s; }
.weather-strip span:nth-child(5) { left: 92%; top: -8px; animation-delay: -10s; }

.yamper-stage {
  position: absolute;
  left: 50%;
  bottom: clamp(102px, 14vh, 156px);
  z-index: 3;
  width: min(46vw, 520px);
  min-width: 250px;
  aspect-ratio: 810 / 712;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  isolation: isolate;
  filter: drop-shadow(0 28px 18px rgba(13, 48, 20, 0.32));
  transform: translateX(-50%);
  animation: idle 2.8s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
}

.yamper-stage::before {
  content: "";
  position: absolute;
  inset: 12% 8% 6%;
  z-index: -2;
  border-radius: 48%;
  background: var(--aura-soft);
  filter: blur(var(--aura-spread));
  opacity: 0.9;
  transform: scale(0.88);
  transition: background 280ms ease, filter 280ms ease, opacity 280ms ease;
  animation: auraPulse 2.4s ease-in-out infinite;
}

.yamper-stage::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 3%;
  height: 9%;
  z-index: -1;
  border-radius: 0;
  background: rgba(8, 48, 23, 0.22);
}

.yamper-stage:active {
  transform: translateX(-50%) translateY(2px) scale(0.985);
}

.yamper-stage.hop {
  animation: hop 520ms ease;
}

.yamper-stage.dead,
.yamper-stage.dead.hop,
.yamper-stage.dead.zap {
  animation: none;
  cursor: default;
}

.yamper-stage.dead::before {
  animation: none;
  opacity: 0.78;
}

.yamper-stage.dead img {
  filter:
    grayscale(1)
    brightness(0.58)
    drop-shadow(0 0 var(--aura-blur) var(--aura))
    drop-shadow(0 0 var(--aura-spread) var(--aura-soft));
}

.yamper-stage.sleepy img {
  filter:
    saturate(0.86)
    brightness(0.94)
    drop-shadow(0 0 var(--aura-blur) var(--aura))
    drop-shadow(0 0 var(--aura-spread) var(--aura-soft));
}

.yamper-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  user-select: none;
  pointer-events: none;
  filter:
    drop-shadow(0 0 var(--aura-blur) var(--aura))
    drop-shadow(0 0 var(--aura-spread) var(--aura-soft));
  transition: filter 280ms ease;
}

.spark {
  position: absolute;
  display: block;
  width: 16px;
  height: 16px;
  opacity: 0;
  transform: rotate(45deg) scale(0.5);
  background: #fff35a;
  clip-path: polygon(50% 0, 64% 36%, 100% 50%, 64% 64%, 50% 100%, 36% 64%, 0 50%, 36% 36%);
  image-rendering: pixelated;
}

.spark.one { top: 22%; right: 11%; }
.spark.two { top: 46%; left: 7%; }
.spark.three { top: 6%; left: 45%; }

.yamper-stage.zap .spark {
  animation: spark 600ms ease-out;
}

.yamper-stage.zap .spark.two {
  animation-delay: 90ms;
}

.yamper-stage.zap .spark.three {
  animation-delay: 180ms;
}

.actions {
  position: absolute;
  left: 50%;
  bottom: clamp(14px, 3vmin, 28px);
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, minmax(74px, 118px));
  gap: 8px;
  justify-content: center;
  width: min(690px, calc(100vw - 24px));
  padding: 8px;
  border: 4px solid #203b25;
  border-radius: 0;
  background: rgba(255, 251, 220, 0.78);
  box-shadow: 6px 6px 0 rgba(24, 67, 39, 0.58);
  transform: translateX(-50%);
}

.actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 56px;
  border: 3px solid #21351f;
  border-radius: 0;
  color: #21351f;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0 4px, transparent 4px 8px),
    #ffd96c;
  box-shadow: 4px 4px 0 rgba(35, 77, 42, 0.52);
  font-weight: 950;
  line-height: 1.05;
  cursor: pointer;
}

.actions button:hover,
.actions button:focus-visible {
  outline: 4px solid #77b9e8;
  outline-offset: 2px;
  transform: translateY(-1px);
}

.actions button:active {
  box-shadow: 1px 1px 0 rgba(35, 77, 42, 0.52);
  transform: translateY(2px);
}

.actions button:disabled {
  color: rgba(33, 53, 31, 0.5);
  background:
    repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.08) 0 4px, transparent 4px 8px),
    #b8b8a8;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.actions span {
  display: block;
  font-size: 0.95rem;
  line-height: 1;
}

.mini-panel {
  position: absolute;
  right: clamp(12px, 3vw, 42px);
  bottom: clamp(92px, 12vh, 128px);
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 190px;
  padding: 10px 12px;
  border: 4px solid #203b25;
  border-radius: 0;
  background: rgba(223, 247, 188, 0.82);
  box-shadow: 6px 6px 0 rgba(24, 67, 39, 0.54);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

@keyframes idle {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-0.5deg); }
  50% { transform: translateX(-50%) translateY(-8px) rotate(0.8deg); }
}

@keyframes hop {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
  38% { transform: translateX(-50%) translateY(-26px) scale(1.03); }
  70% { transform: translateX(-50%) translateY(2px) scale(0.99); }
}

@keyframes spark {
  0% { opacity: 0; transform: rotate(45deg) scale(0.4); }
  42% { opacity: 1; transform: rotate(45deg) scale(1.15); }
  100% { opacity: 0; transform: rotate(45deg) scale(1.65); }
}

@keyframes auraPulse {
  0%, 100% { opacity: 0.62; transform: scale(0.86); }
  50% { opacity: 0.98; transform: scale(0.96); }
}

@keyframes drift {
  from { transform: translateX(-18vw); }
  to { transform: translateX(118vw); }
}

@media (max-width: 760px) {
  .home {
    min-height: 500px;
  }

  .brand {
    top: 12px;
    left: 14px;
  }

  .hud {
    top: 104px;
    right: auto;
    left: 12px;
    width: min(350px, calc(100vw - 24px));
    padding: 10px;
  }

  .bar-row {
    grid-template-columns: 78px 1fr 30px;
    gap: 6px;
    font-size: 0.78rem;
  }

  .yamper-stage {
    bottom: 146px;
    width: min(75vw, 390px);
    min-width: 230px;
  }

  .actions {
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    bottom: 10px;
    width: calc(100vw - 16px);
    padding: 6px;
  }

  .actions button {
    height: 58px;
    padding: 4px 2px;
    font-size: 0.72rem;
  }

  .actions span {
    font-size: 1.12rem;
  }

  .mini-panel {
    right: 12px;
    bottom: 152px;
    min-width: 150px;
    max-width: 44vw;
    padding: 8px;
    font-size: 0.72rem;
  }
}

@media (max-height: 620px) and (min-width: 761px) {
  .yamper-stage {
    width: min(38vw, 410px);
    bottom: 92px;
  }

  .actions button {
    height: 48px;
  }

  .mini-panel {
    bottom: 88px;
  }
}
