:root {
  font-family: Calibri, Candara, 'Segoe UI', Arial, sans-serif;
  color: #080808;
  --sky: #99d9e8;
  --grass: #b5e51d;
}

* {
  box-sizing: border-box;
}

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

body {
  cursor: url('assets/cursor.png') 12 9, auto;
}

button,
a,
[role=button] {
  cursor: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

#world {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: var(--sky);
  transition: background 5s;
}

#world.night {
  --sky: #172342;
  --grass: #476225;
}

#clouds,
#stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 5s;
}

#stars {
  opacity: 0;
}

.night #stars {
  opacity: 1;
}

.night #clouds {
  opacity: 0;
}

.star {
  position: absolute;
  color: #fffbd6;
  font-family: Arial, sans-serif;
  animation: twinkle var(--duration) ease-in-out infinite alternate;
}

@keyframes twinkle {
  from {
    opacity: .25;
  }

  to {
    opacity: 1;
  }
}

.cloud {
  position: absolute;
  left: 0;
  width: clamp(155px, 23vw, 365px);
  height: auto;
  will-change: transform;
}

.c1 {
  top: 4%;
}

.c2 {
  top: 17%;
  width: clamp(130px, 15vw, 250px);
}

.c3 {
  top: 28%;
}

.c4 {
  top: 55%;
  width: clamp(160px, 22vw, 345px);
}

.c5 {
  top: 76%;
  width: clamp(150px, 20vw, 300px);
}

.ground {
  position: absolute;
  left: -1%;
  bottom: -1px;
  width: 102%;
  height: 23%;
  overflow: visible;
}

.ground path {
  fill: var(--grass);
  stroke: black;
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
  transition: fill 5s;
}

.sign {
  position: absolute;
  top: max(30px, 5.2%);
  left: max(18px, env(safe-area-inset-left));
  z-index: 10;
  max-width: calc(100% - 100px);
}

.hanger {
  position: absolute;
  width: 50px;
  height: 160px;
  bottom: 100%;
  left: 45%;
  background: white;
  border: 3px solid black;
  border-bottom: 0;
}

.sign-content {
  position: relative;
  border: 3px solid black;
  background: #fff;
  padding: 16px 30px 12px;
  text-align: center;
  font-size: clamp(14px, 1.35vw, 21px);
  font-weight: 700;
}

.sign-line {
  display: flex;
  justify-content: center;
  gap: 5px;
  flex-wrap: wrap;
}

#clock {
  display: block;
  font-size: 14px;
  font-weight: 400;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

#clock:empty {
  display: none;
}

#vk {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  z-index: 12;
  width: 54px;
  height: 54px;
}

#vk img {
  width: 100%;
  height: 100%;
}

.hero {
  position: absolute;
  width: 180px;
  height: 324px;
  z-index: 4;
  user-select: none;
  touch-action: none;
  transform-origin: 50% 75%;
}

.fallback-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.zzz {
  display: none;
  position: absolute;
  top: 0;
  left: 80%;
  width: 75px;
  height: 70px;
  font-weight: bold;
  color: #fff;
  -webkit-text-stroke: .5px #121829;
  font-size: 26px;
  pointer-events: none;
}

.sleep .zzz {
  display: block;
}

.zzz span {
  position: absolute;
  opacity: 0;
  animation: snore 3s linear infinite;
}

.zzz span:nth-child(2) {
  animation-delay: 1s;
}

.zzz span:nth-child(3) {
  animation-delay: 2s;
}

@keyframes snore {
  0% {
    transform: translate(0, 15px) scale(.6);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  85% {
    opacity: .8;
  }

  100% {
    transform: translate(var(--snore-x, 38px), -65px) scale(1.2);
    opacity: 0;
  }
}

.hero.facing-left .zzz {
  --snore-x: -38px;
}

.sprite-art {
  display: none;
  position: absolute;
  left: 0;
  top: 0;
  background-repeat: no-repeat;
  pointer-events: none;
}

.hero.has-sprite .fallback-art {
  visibility: hidden;
}

.hero.has-sprite .sprite-art {
  display: block;
}

.hero.facing-left .sprite-art,
.hero.facing-left .fallback-art {
  transform: scaleX(-1);
}

.bubble {
  position: absolute;
  width: 360px;
  height: 224px;
  z-index: 8;
  background: url('assets/bubble.svg') center / 100% 100% no-repeat;
}

.bubble[hidden] {
  display: none;
}

.bubble-text {
  position: absolute;
  inset: 17% 13% 29%;
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  overflow: hidden;
}

.bubble-copy {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  transform-origin: center;
  transform: translate(-50%, -50%) scale(var(--text-scale, 1));
}

#thinker {
  position: absolute;
  bottom: 7.3%;
  right: max(22px, env(safe-area-inset-right));
  width: clamp(105px, 14vw, 210px);
  height: clamp(128px, 17vw, 250px);
  padding: 0;
  border: 0;
  background: transparent;
  z-index: 5;
  touch-action: manipulation;
}

#thinker>img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.thinker-sign {
  display: none !important;
}

#thinker:active {
  transform: rotate(1deg);
}

:focus-visible {
  outline: 3px dashed #cb3a80;
  outline-offset: 5px;
}

#hero[data-pointer-focus="true"]:focus {
  outline: none;
}

.click-rays {
  pointer-events: none;
  position: absolute;
  width: 40px;
  height: 40px;
  margin: -20px;
  z-index: 25;
  animation: clickPop .3s ease-out forwards;
}

@keyframes clickPop {
  from {
    opacity: 1;
    transform: scale(.65);
  }

  to {
    opacity: 0;
    transform: scale(1.5);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.no-js {
  position: absolute;
  top: 30%;
  left: 10%;
  background: white;
  padding: 10px;
}

@media (max-width: 600px) {
  .sign {
    left: 12px;
    top: max(25px, env(safe-area-inset-top));
    max-width: calc(100% - 78px);
  }

  .sign-content {
    padding: 10px 12px;
  }

  .sign-line {
    gap: 2px 5px;
  }

  #vk {
    width: 44px;
    height: 44px;
    right: 12px;
  }

  #thinker {
    right: 10px;
    bottom: 8%;
  }
}

@media (max-height: 450px) {
  .sign {
    top: 12px;
  }

  .sign-content {
    padding: 6px 14px;
    font-size: 13px;
  }

  #clock {
    margin-top: 1px;
    font-size: 12px;
  }

  #thinker {
    width: 96px;
    height: 118px;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
  }

  .sleep .zzz span:first-child {
    opacity: 1;
  }
}


.chat-island {
  position: absolute;
  left: max(18px, 4vw);
  bottom: 7.5%;

  width: min(40vw, 59vh, 570px);
  aspect-ratio: 560 / 740;

  z-index: 6;

  pointer-events: none;
}

.chat-island-art {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  pointer-events: none;
}

.chat-panel,
.chat-open {
  position: absolute;
  inset: auto;

  left: 42.6786%;
  top: 15%;
  width: 45.7143%;
  height: 36.0811%;

  margin: 0;
  padding: 0;

  border: 3px solid #080808;
  border-radius: 25px;
  background: #73f88a;
  color: #080808;

  font-family: Calibri, Candara, "Segoe UI", Arial, sans-serif;

  pointer-events: auto;
  overflow: hidden;
}

.chat-panel {
  max-width: none;
  max-height: none;
}

.chat-panel[open] {
  display: flex;
  flex-direction: column;
}

.chat-panel:not([open]) {
  display: none;
}

.chat-bar {
  display: flex;
  align-items: center;
  gap: 5px;

  flex: 0 0 auto;
  min-height: 32px;
  padding: 3px 8px;

  border-bottom: 2px solid #080808;
  background: #73f88a;

  font-size: 13px;
  font-weight: 700;
}

.chat-bar-face {
  flex: 0 0 auto;
  font-size: 19px;
  line-height: 1;
  white-space: nowrap;
}

.chat-bar-title {
  flex: 1;
  min-width: 0;

  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-bar button {
  display: grid;
  place-items: center;

  flex: 0 0 auto;
  width: 27px;
  height: 25px;

  padding: 0;
  border: 2px solid #080808;
  border-radius: 5px;
  background: #b8ffc2;
  color: #080808;

  font: inherit;
  font-size: 21px;
  line-height: 1;
}

.chat-bar button:hover {
  background: #ffdf59;
}

#chat-close {
  display: none;
}

#chattable {
  display: block;
  flex: 1 1 0;

  width: 100%;
  height: 0;
  min-width: 0;
  min-height: 0;

  border: 0;
  background: #73f88a;
}

.chat-error {
  margin: 0;
  padding: 8px;
  background: #fff4b0;
  font-size: 14px;
}

.chat-error[hidden] {
  display: none;
}

.chat-open {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
}

.robot-face {
  font-size: clamp(24px, 5vw, 48px);
  line-height: 1;
  white-space: nowrap;
}

.robot-caption {
  font-size: 14px;
  font-weight: 700;
}

.chat-panel:modal {
  position: fixed;
  inset: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);

  width: min(720px, calc(100vw - 24px));

  height: min(760px, calc(100vh - 24px));
  height: min(760px, calc(100dvh - 24px));

  max-width: none;
  max-height: none;

  border: 4px solid #080808;
  border-radius: 24px;
}

.chat-panel::backdrop {
  background: rgb(0 0 0 / 45%);
}

.chat-panel:modal .chat-bar {
  min-height: 44px;
  padding: 5px 12px;
  font-size: 17px;
}

.chat-panel:modal .chat-bar button {
  width: 34px;
  height: 32px;
}

.chat-panel:modal #chat-expand {
  display: none;
}

.chat-panel:modal #chat-close {
  display: grid;
}

.night .chat-panel,
.night .chat-open {
  background: #73f88a;
}

@media (max-width: 1000px),
(max-height: 650px) {
  .chat-island {
    left: max(6px, 2vw);
    width: min(30vw, 210px, 43vh);
  }

  .chat-open {
    display: flex;
    border-width: 2px;
    border-radius: 14px;
  }

  .chat-panel:not(:modal) {
    display: none;
  }
}


.star {
  position: absolute;
  display: block;
  pointer-events: none;

  animation: none;
  font-size: 0;
  line-height: 0;

  text-shadow: none;
  box-shadow: none;
  filter: none;
  opacity: 1;
}


.star-paint {
  background:
    url("assets/star.svg") center / contain no-repeat;
}


.star-dot {
  border-radius: 50%;
  background: #ffffff;
  opacity: .75;
}

.star.star-paint {
  animation: paintStarTwinkle var(--star-duration, 6s) ease-in-out var(--star-delay, 0s) infinite;
}

.star.star-dot {
  animation: starDotTwinkle var(--star-duration, 5s) ease-in-out var(--star-delay, 0s) infinite;
}

@keyframes paintStarTwinkle {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .72;
  }
}

@keyframes starDotTwinkle {

  0%,
  100% {
    opacity: .8;
  }

  50% {
    opacity: .35;
  }
}

@media (prefers-reduced-motion: reduce) {

  .star.star-paint,
  .star.star-dot {
    animation: none;
  }
}