:root {
  --ink: #efe9fb;
  --wet: #c3b1ff;
  --dim: #8e84b6;
  --night: #07060f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--ink);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body { font-family: "Kalam", "Comic Sans MS", cursive; }

canvas#sky, canvas#garden {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#log {
  position: fixed;
  left: clamp(20px, 6vw, 96px);
  bottom: 16vh;
  width: min(30vw, 400px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  pointer-events: none;
}

.line {
  margin: 0;
  font-weight: 300;
  font-size: clamp(17px, 1.55vw, 23px);
  line-height: 1.35;
  transition: opacity 1.4s ease, transform 1.4s ease;
}

.line.past { opacity: .32; }
.line.gone { opacity: 0; transform: translateY(-8px); }

.ch {
  opacity: 0;
  color: var(--wet);
  animation: ink 1.6s ease forwards;
}

@keyframes ink {
  0% { opacity: 0; color: var(--wet); }
  18% { opacity: 1; color: var(--wet); }
  100% { opacity: 1; color: var(--ink); }
}

#wish {
  position: fixed;
  left: clamp(20px, 6vw, 96px);
  bottom: 15vh;
  width: min(34vw, 460px);
  pointer-events: none;
}

#wish h1 {
  margin: 0;
  font-weight: 400;
  font-size: clamp(34px, 3.6vw, 56px);
  line-height: 1.05;
  letter-spacing: -.01em;
}

#wish svg {
  display: block;
  width: min(100%, 300px);
  height: auto;
  margin: 4px 0 12px;
  overflow: visible;
}

#wish path {
  fill: none;
  stroke: #9d8cf2;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 360;
  stroke-dashoffset: 360;
}

#wish.on path { animation: draw 1.8s 1.1s ease forwards; }

@keyframes draw { to { stroke-dashoffset: 0; } }

#wish p {
  margin: 0;
  font-weight: 300;
  font-size: clamp(16px, 1.4vw, 20px);
  line-height: 1.4;
  color: #d9d0f2;
}

#hint {
  position: fixed;
  left: clamp(20px, 6vw, 96px);
  bottom: max(7vh, env(safe-area-inset-bottom));
  margin: 0;
  font: 400 11px/1 "Pixelify Sans", monospace;
  letter-spacing: .08em;
  color: var(--dim);
  opacity: 0;
  transition: opacity 2s ease;
  pointer-events: none;
  white-space: nowrap;
}

#hint.on { opacity: .8; }

#again {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  background: none;
  border: 0;
  padding: 6px 8px;
  font: 400 12px/1 "Pixelify Sans", monospace;
  letter-spacing: .08em;
  color: var(--dim);
  cursor: pointer;
  opacity: .7;
}

#again:hover, #again:focus-visible { color: var(--ink); opacity: 1; outline: none; }

#cover {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--night);
  cursor: pointer;
  transition: opacity 1.6s ease, visibility 1.6s;
  outline: none;
}

#cover.gone { opacity: 0; visibility: hidden; }

#bloom {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  margin-bottom: 14px;
  animation: bob 3.2s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-5px) rotate(3deg); }
}

#cover .for {
  margin: 0;
  font-size: 30px;
  font-weight: 400;
}

#cover .tap {
  margin: 0;
  font: 400 11px/1 "Pixelify Sans", monospace;
  letter-spacing: .1em;
  color: var(--dim);
  animation: blink 2.4s steps(2, jump-none) infinite;
}

@keyframes blink { 50% { opacity: .25; } }

@media (max-aspect-ratio: 1/1) {
  #log, #wish {
    left: 50%;
    transform: translateX(-50%);
    bottom: auto;
    top: max(7vh, env(safe-area-inset-top));
    width: min(88vw, 440px);
    text-align: center;
    align-items: center;
  }
  #log { gap: 10px; }
  #hint { left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom)); }
  .line { font-size: clamp(16px, 4.4vw, 21px); }
  #wish h1 { font-size: clamp(32px, 9vw, 46px); }
  #wish svg { margin-left: auto; margin-right: auto; width: min(70%, 260px); }
}

@media (prefers-reduced-motion: reduce) {
  .ch { animation-duration: .01s; animation-delay: 0s !important; }
  #bloom, #cover .tap { animation: none; }
}
