* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { background: #0b1033; }

body {
  font-family: "Pixelify Sans", "Courier New", monospace;
  color: #fff;
  overflow-x: hidden;
  -webkit-font-smoothing: none;
}

canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#sky { z-index: 0; }
#scene { z-index: 1; }

#track { height: 800vh; }

/* chunky 8-bit text: hard offset shadow, no blur */
.msg, #hud { text-shadow: 3px 3px 0 #17306b; }

#hud {
  position: fixed;
  z-index: 3;
  top: max(14px, env(safe-area-inset-top));
  left: 0; right: 0;
  padding: 0 clamp(14px, 3vw, 34px);
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  font-size: clamp(1rem, 1.5vw, 1.35rem);
  letter-spacing: 0.06em;
  pointer-events: none;
  opacity: 0;
}
#hud div { display: flex; flex-direction: column; gap: 2px; }
#hud .right { text-align: right; }
#hud .lbl { color: #ffe066; }

.msg {
  position: fixed;
  z-index: 3;
  left: 0; right: 0;
  top: clamp(84px, 13vh, 150px);
  padding: 0 20px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  will-change: opacity, transform;
}
h1, h2 { font-weight: 700; line-height: 1.12; letter-spacing: 0.01em; }
h1 { font-size: clamp(1.9rem, 5.2vw, 4rem); }
h2 { font-size: clamp(2.2rem, 6vw, 4.6rem); }
.heart { color: #ff4d6d; display: inline-block; animation: beat 0.9s steps(2) infinite; }
.tag {
  display: inline-block;
  margin-bottom: 14px;
  padding: 6px 14px 7px;
  background: #17306b;
  color: #ffe066;
  font-weight: 600;
  font-size: clamp(0.85rem, 1.3vw, 1.1rem);
  letter-spacing: 0.14em;
  text-shadow: none;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
}
.blink {
  margin-top: 18px;
  font-size: clamp(0.95rem, 1.4vw, 1.2rem);
  letter-spacing: 0.08em;
  color: #ffe066;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@keyframes beat { 50% { transform: scale(1.25); } }

@media (prefers-reduced-motion: reduce) {
  .blink, .heart { animation: none; }
}

/* ---- title screen ---- */
#hero {
  top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: clamp(64px, 12vh, 130px);
}
.presents {
  font-size: clamp(0.8rem, 1.2vw, 1rem);
  letter-spacing: 0.3em;
  color: #9fd0ff;
  margin-bottom: clamp(14px, 2.4vh, 26px);
}
.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffe066;
  /* stacked hard shadows = chunky 8-bit logo */
  text-shadow:
    0 3px 0 #ff9f1c, 0 6px 0 #f0541e, 0 9px 0 #b3261e,
    4px 9px 0 #17306b, -4px 9px 0 #17306b, 0 13px 0 #17306b,
    4px 0 0 #17306b, -4px 0 0 #17306b, 0 -4px 0 #17306b,
    4px 4px 0 #17306b, -4px 4px 0 #17306b, 4px -4px 0 #17306b, -4px -4px 0 #17306b;
  animation: bob 1.6s steps(4) infinite alternate;
}
.logo span:first-child { font-size: clamp(2.6rem, 13vw, 5.6rem); color: #ff8fb1; }
.logo span:last-child { font-size: clamp(2.9rem, 14.5vw, 6.4rem); }
.sub {
  margin-top: clamp(20px, 3.4vh, 34px);
  font-size: clamp(0.95rem, 1.5vw, 1.25rem);
  letter-spacing: 0.06em;
}
.start {
  margin-top: clamp(26px, 5vh, 54px);
  font-weight: 700;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  letter-spacing: 0.1em;
  color: #fff;
}
.scrollhint {
  position: absolute;
  left: 0; right: 0;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 14px));
  font-size: clamp(0.85rem, 1.2vw, 1rem);
  letter-spacing: 0.1em;
  color: #ffe066;
}
.wish {
  margin-top: 10px;
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  letter-spacing: 0.04em;
}
@keyframes bob { to { transform: translateY(-8px); } }
@media (prefers-reduced-motion: reduce) { .logo { animation: none; } }

/* teacher icons under the logo */
.icons { display: flex; gap: clamp(14px, 3vw, 26px); align-items: flex-end; margin-top: clamp(18px, 3vh, 30px); }
.icons canvas { position: static; width: auto; height: clamp(34px, 5.4vh, 52px); filter: drop-shadow(3px 3px 0 #17306b); }
.sub { margin-top: clamp(14px, 2.4vh, 24px); }
.from {
  display: inline-block;
  margin-top: 16px;
  padding: 5px 12px 6px;
  background: #17306b;
  color: #ffe066;
  font-size: clamp(0.8rem, 1.1vw, 0.95rem);
  letter-spacing: 0.12em;
  text-shadow: none;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.25);
}

/* ---- dialogue: portrait + speech bubble ---- */
#talk {
  position: fixed;
  z-index: 3;
  top: max(74px, calc(env(safe-area-inset-top) + 62px));
  left: 12px; right: 12px;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  will-change: opacity, transform;
}
#talk.right { flex-direction: row-reverse; }
.face {
  flex: none;
  width: 68px; height: 68px;
  display: grid; place-items: center;
  background: #bfe6ff;
  border: 4px solid #17306b;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
}
#talk.right .face { background: #4a3566; }
.face canvas { position: static; width: 56px; height: auto; }
.bubble {
  position: relative;
  flex: 1;
  min-height: 68px;
  padding: 8px 12px 10px;
  background: #fff;
  color: #17306b;
  border: 4px solid #17306b;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
}
/* stepped pixel tail pointing at the speaker */
.bubble::before, .bubble::after { content: ""; position: absolute; top: 22px; background: #17306b; }
.bubble::before { left: -12px; width: 8px; height: 16px; }
.bubble::after { left: -18px; top: 26px; width: 6px; height: 8px; }
#talk.right .bubble::before { left: auto; right: -12px; }
#talk.right .bubble::after { left: auto; right: -18px; }
.who { font-weight: 700; font-size: 0.82rem; letter-spacing: 0.12em; color: #3f74e0; margin-bottom: 2px; }
#talk.right .who { color: #c0408f; }
.line { font-size: clamp(1.02rem, 1.5vw, 1.2rem); line-height: 1.28; }
#unsaid { visibility: hidden; }

/* friends peeking in from the edges on the last screen */
.peek {
  position: fixed;
  inset: auto;
  z-index: 2;
  height: auto;
  pointer-events: none;
  filter: drop-shadow(4px 4px 0 rgba(23, 48, 107, 0.35));
  will-change: transform;
}
#peekL { left: -14px; top: 52%; width: clamp(104px, 15vw, 170px); transform: translateX(-130%); }
#peekR { right: -12px; top: 64%; width: clamp(96px, 14vw, 158px); transform: translateX(130%); }
#peekB { left: 50%; bottom: 0; width: clamp(120px, 17vw, 190px); margin-left: clamp(-95px, -8.5vw, -60px); transform: translateY(130%); }

.name { font-family: "Press Start 2P", "Pixelify Sans", monospace; font-size: 0.72em; font-weight: 400; color: #ffe066; letter-spacing: 0.04em; }
@media (min-width: 821px) { .nb { display: none; } }
@media (max-width: 820px) {
  #final { top: 70px; }
  #final .tag { margin-bottom: 10px; }
  #final h2 { font-size: 2.05rem; line-height: 1.2; }
  #final .wish { margin-top: 8px; }
  #final .from { margin-top: 10px; }
}

#talk.kitty .face { background: #ffd6e0; }
#talk.kitty .who { color: #e0304f; }
