:root {
  color-scheme: light;
  --ink: #19232c;
  --line: #cbd5df;
  --paper: #f3f7f5;
  --panel: #ffffff;
  --green: #257a5a;
  --red: #b7463f;
  --gold: #c79422;
  --rose: #d9617d;
  --blue: #2b62a3;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button {
  font: inherit;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  padding: 18px clamp(16px, 4vw, 48px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.header-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 320px) auto;
  align-items: center;
  gap: 16px;
}

.header-metrics {
  min-width: 0;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.lost-counter {
  margin: 0;
  color: var(--red);
  font-size: 1.2rem;
  font-weight: 900;
}

.survival-timer {
  margin: 4px 0 0;
  color: #3b566a;
  font-size: 0.95rem;
  font-weight: 700;
}

.hunger-wrap {
  display: grid;
  gap: 6px;
}

.meter-label {
  color: #536674;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.icon-btn {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.feed-btn::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 12px;
  width: 14px;
  height: 23px;
  border: 2px solid var(--ink);
  border-radius: 4px 4px 8px 8px;
  background: linear-gradient(#e8fbff 0 34%, #ffffff 34% 100%);
}

.feed-btn::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 6px;
  width: 8px;
  height: 8px;
  border: 2px solid var(--ink);
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  background: #f0b99b;
}

.mute-btn::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 16px;
  width: 9px;
  height: 16px;
  background: var(--ink);
  clip-path: polygon(0 30%, 45% 30%, 100% 0, 100% 100%, 45% 70%, 0 70%);
}

.mute-btn::after {
  content: "";
  position: absolute;
  left: 24px;
  top: 13px;
  width: 12px;
  height: 22px;
  border: 3px solid var(--ink);
  border-left: 0;
  border-radius: 0 18px 18px 0;
}

.mute-btn.muted::after {
  left: 27px;
  top: 13px;
  width: 4px;
  height: 24px;
  border: 0;
  border-radius: 4px;
  background: var(--red);
  transform: rotate(38deg);
}

.sim-layout {
  flex: 1;
  min-height: 0;
  padding: clamp(12px, 2.5vh, 24px) clamp(16px, 4vw, 48px) clamp(12px, 3vh, 36px);
}

.playroom {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 0;
}

.playroom {
  position: relative;
  height: 100%;
  min-height: min(620px, 100%);
  overflow: hidden;
  background: #eaf5f0;
}

.playroom.warning {
  box-shadow: inset 0 0 0 5px rgba(199, 148, 34, 0.38);
}

.playroom.critical {
  animation: criticalPulse 900ms ease-in-out infinite;
}

.playroom.dead-room {
  background: #d5dbdc;
}

.floor-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(#d4e5dd 1px, transparent 1px),
    linear-gradient(90deg, #d4e5dd 1px, transparent 1px),
    radial-gradient(circle at 18% 20%, rgba(199, 148, 34, 0.18), transparent 18%),
    radial-gradient(circle at 82% 72%, rgba(43, 98, 163, 0.14), transparent 20%);
  background-size: 44px 44px, 44px 44px, auto, auto;
}

.toy {
  position: absolute;
  z-index: 1;
}

.toy-ball {
  left: 12%;
  top: 18%;
  width: 54px;
  height: 54px;
  border: 5px solid #1f2c38;
  border-radius: 50%;
  background: conic-gradient(var(--gold) 0 33%, #ffffff 0 66%, var(--blue) 0);
}

.toy-block {
  right: 14%;
  top: 23%;
  width: 62px;
  height: 62px;
  border: 5px solid #1f2c38;
  border-radius: 8px;
  background: var(--green);
}

.toy-ring {
  left: 20%;
  bottom: 18%;
  width: 70px;
  height: 70px;
  border: 12px solid var(--rose);
  border-radius: 50%;
}

.bottle {
  display: none;
  position: absolute;
  z-index: 5;
  width: 34px;
  height: 82px;
  border: 4px solid #1f2c38;
  border-radius: 8px 8px 14px 14px;
  background: linear-gradient(#e8fbff 0 28%, #ffffff 28% 100%);
  transform: rotate(70deg);
  pointer-events: none;
}

.bottle::before {
  content: "";
  position: absolute;
  top: -18px;
  left: 7px;
  width: 14px;
  height: 18px;
  border: 3px solid #1f2c38;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: #f0b99b;
}

.bottle.active {
  display: block;
  animation: bottleFeed 1.2s ease-in-out;
}

.baby-name-tag {
  position: absolute;
  z-index: 4;
  top: 8px;
  left: 12px;
  max-width: calc(100% - 16px);
  margin: 0;
  padding: 4px 10px;
  border: 1px solid rgba(25, 35, 44, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transform: translateX(-50%);
}

.baby-crawler {
  position: absolute;
  z-index: 3;
  width: 220px;
  height: 150px;
  --skin: #ffd9c7;
  --hair: #5c4033;
  --onesie: #d9617d;
  --eye: #19232c;
  transform: translate(80px, 230px);
  transition: filter 160ms ease, opacity 600ms ease;
}

.baby-crawler.crying {
  animation: fuss 360ms ease-in-out infinite;
}

.baby-crawler.feeding .arm,
.baby-crawler.feeding .leg {
  animation-play-state: paused;
}

.head {
  position: absolute;
  z-index: 3;
  top: 16px;
  left: 122px;
  width: 82px;
  height: 82px;
  border: 5px solid #1f2c38;
  border-radius: 50%;
  background: var(--skin);
}

.hair {
  position: absolute;
  top: 6px;
  left: 35px;
  width: 26px;
  height: 26px;
  border-top: 6px solid var(--hair);
  border-left: 6px solid var(--hair);
  border-radius: 50% 0 0 0;
  transform: rotate(34deg);
}

.hair.tuft {
  top: 2px;
  left: 30px;
  width: 34px;
  height: 28px;
  border-top-width: 8px;
  border-left-width: 0;
  border-right: 8px solid var(--hair);
  border-radius: 50% 50% 0 0;
}

.hair.curls {
  top: 4px;
  left: 19px;
  width: 44px;
  height: 22px;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 8px 13px, var(--hair) 0 8px, transparent 9px),
    radial-gradient(circle at 22px 8px, var(--hair) 0 9px, transparent 10px),
    radial-gradient(circle at 36px 13px, var(--hair) 0 8px, transparent 9px);
  transform: none;
}

.hair.cap {
  top: -2px;
  left: 10px;
  width: 54px;
  height: 30px;
  border: 0;
  border-radius: 44px 44px 8px 8px;
  background: var(--hair);
  transform: none;
}

.eye {
  position: absolute;
  top: 34px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--eye);
}

.eye.left {
  left: 25px;
}

.eye.right {
  right: 25px;
}

.mouth {
  position: absolute;
  left: 50%;
  bottom: 17px;
  width: 28px;
  height: 12px;
  border: 4px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 26px 26px;
  transform: translateX(-50%);
}

.baby-crawler.crying .mouth {
  bottom: 14px;
  width: 22px;
  height: 22px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  background: #6f2327;
}

.tear {
  display: none;
  position: absolute;
  top: 46px;
  width: 8px;
  height: 18px;
  border-radius: 50%;
  background: #4aa4d8;
}

.tear.left {
  left: 18px;
}

.tear.right {
  right: 18px;
}

.baby-crawler.crying .tear {
  display: block;
  animation: tearDrop 900ms linear infinite;
}

.body {
  position: absolute;
  z-index: 2;
  top: 60px;
  left: 42px;
  width: 108px;
  height: 64px;
  border: 5px solid #1f2c38;
  border-radius: 44px;
  background: var(--onesie);
}

.arm,
.leg {
  position: absolute;
  z-index: 1;
  width: 58px;
  height: 18px;
  border: 5px solid #1f2c38;
  border-radius: 18px;
  background: var(--skin);
  transform-origin: 12px 50%;
}

.arm.front {
  top: 84px;
  left: 126px;
  animation: crawlFront 760ms ease-in-out infinite;
}

.arm.back {
  top: 105px;
  left: 112px;
  animation: crawlBack 760ms ease-in-out infinite;
}

.leg.front {
  top: 92px;
  left: 18px;
  animation: crawlBack 760ms ease-in-out infinite;
}

.leg.back {
  top: 114px;
  left: 26px;
  animation: crawlFront 760ms ease-in-out infinite;
}

.baby-crawler.dying {
  opacity: 0.42;
  filter: grayscale(0.7);
}

.baby-crawler.dead {
  animation: none;
  filter: grayscale(1);
  opacity: 0.5;
}

.baby-crawler.dead .arm,
.baby-crawler.dead .leg {
  animation: none;
}

.baby-crawler.dead .eye {
  width: 16px;
  height: 4px;
  border-radius: 0;
  background: transparent;
}

.baby-crawler.dead .eye::before,
.baby-crawler.dead .eye::after {
  content: "";
  position: absolute;
  left: 0;
  top: 1px;
  width: 16px;
  height: 3px;
  border-radius: 3px;
  background: var(--ink);
}

.baby-crawler.dead .eye::before {
  transform: rotate(35deg);
}

.baby-crawler.dead .eye::after {
  transform: rotate(-35deg);
}

.baby-crawler.dead .mouth {
  bottom: 18px;
  width: 30px;
  height: 4px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
}

.death-modal {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(25, 35, 44, 0.58);
}

.death-modal[hidden] {
  display: none;
}

.death-card {
  width: min(260px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.22);
}

.meter {
  height: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f3;
}

.meter.meter-compact {
  height: 16px;
}

.meter span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--green);
  transition: width 180ms ease, background 180ms ease;
}

.meter span.medium {
  background: var(--gold);
}

.meter span.low {
  background: var(--red);
}

.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.btn.primary {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.btn:hover,
.icon-btn:hover {
  filter: brightness(0.96);
}

@keyframes crawlFront {
  0%,
  100% {
    transform: rotate(18deg) translateX(0);
  }

  50% {
    transform: rotate(-20deg) translateX(14px);
  }
}

@keyframes crawlBack {
  0%,
  100% {
    transform: rotate(-18deg) translateX(12px);
  }

  50% {
    transform: rotate(18deg) translateX(0);
  }
}

@keyframes fuss {
  0%,
  100% {
    filter: none;
  }

  50% {
    filter: drop-shadow(0 0 10px rgba(183, 70, 63, 0.35));
  }
}

@keyframes tearDrop {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(24px);
  }
}

@keyframes criticalPulse {
  0%,
  100% {
    box-shadow: inset 0 0 0 5px rgba(183, 70, 63, 0.28);
  }

  50% {
    box-shadow: inset 0 0 0 9px rgba(183, 70, 63, 0.52);
  }
}

@keyframes bottleFeed {
  0%,
  100% {
    transform: rotate(70deg) translateY(0);
  }

  50% {
    transform: rotate(58deg) translateY(-8px);
  }
}

@media (max-width: 980px) {
  .header-status {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "metrics actions"
      "hunger hunger";
    gap: 12px 14px;
  }

  .header-metrics {
    grid-area: metrics;
  }

  .hunger-wrap {
    grid-area: hunger;
  }

  .header-actions {
    grid-area: actions;
  }
}

@media (max-width: 640px) {
  .playroom {
    min-height: min(460px, 100%);
  }

  .baby-crawler {
    width: 176px;
    height: 120px;
  }
}
