@font-face {
  font-family: 'Fraktur';
  src: url('fonts/UnifrakturMaguntia.ttf') format('truetype');
  font-display: swap;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #070b12;
  color: #f4f0e6;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html {
  overflow: hidden;
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  box-sizing: border-box;
  padding-top: 34vh;
}

body.is-dragging,
body.is-dragging * {
  user-select: none;
  -webkit-user-select: none;
  cursor: grabbing;
}

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

audio {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  clip: rect(0 0 0 0);
}

:focus {
  outline: none;
}

[contenteditable],
[contenteditable]:focus,
[contenteditable]:focus-visible {
  outline: none;
}

.note {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  flex-shrink: 0;
  min-height: 0;
  width: min(28rem, calc(100vw - 2rem));
  max-height: max(calc(100dvh - 34vh - 136px - env(safe-area-inset-bottom, 0px)), 42dvh);
  margin: 0;
  padding: 18px 16px 20px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-width: none;
  background: #fffadf;
  color: #1c1c1e;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.25);
  opacity: 0.55;
  transform: translate3d(0, 8px, 0);
  transition: opacity 1s ease 0.15s, transform 1s ease 0.15s;
}

.revealed .note {
  opacity: 1;
  transform: none;
}

.note::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.date {
  margin: 0;
  text-align: center;
  font-size: 12px;
  line-height: 1.2;
  color: #8e8e93;
}

.title {
  margin: 6px 0 14px;
  min-height: 1.15em;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: #1c1c1e;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  caret-color: #e8a317;
}

#forwarded {
  margin: 0;
}

.fwd-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 8px;
  color: #8696a0;
}

.fwd-row span {
  font-size: 12px;
  font-style: italic;
  line-height: 1;
}

.fwd-row svg {
  display: block;
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
}

.bubbles {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.bubble {
  position: relative;
  box-sizing: border-box;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 8px 10px;
  background: #1f2c34;
  color: #e9edef;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.bubble .msg,
.bubble .time {
  margin: 0;
}

.bubble .foot {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.bubble .orig {
  flex: 1 1 auto;
  color: #8696a0;
  font-size: 11.5px;
  font-style: italic;
  line-height: 1.3;
}

.bubble .time {
  flex: 0 0 auto;
  text-align: right;
  color: #8696a0;
  font-size: 11px;
  font-style: normal;
  line-height: 1;
}

.bubble.reacted {
  margin-bottom: 10px;
}

.react {
  position: absolute;
  left: 4px;
  bottom: -11px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #1f2c34;
  box-shadow: 0 0 0 2px #fffadf;
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

#field {
  position: relative;
  margin-top: 16px;
  min-height: 72px;
}

.line {
  position: absolute;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  max-width: 100%;
  border-radius: 8px;
  color: #1c1c1e;
  font-size: 17px;
  line-height: 1.4;
  -webkit-touch-callout: none;
  transition: box-shadow 0.18s ease, background-color 0.18s ease;
}

.line.lifted {
  z-index: 3 !important;
  background: #fffadf;
  box-shadow: 0 0 0 6px #fffadf, 0 10px 24px rgba(0, 0, 0, 0.18);
}

.line.quote .text {
  color: #3a3a3c;
}

.text {
  flex: 1 1 auto;
  min-width: 6rem;
  min-height: 1.4em;
  padding: 2px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  caret-color: #e8a317;
  transition: color 0.2s ease;
}

.line.checked .text {
  color: #8e8e93;
}

.line a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.line a:focus-visible {
  outline: none;
}

.check,
.del {
  position: relative;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.check {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  margin: 2px 10px 0 0;
  border: 1.5px solid #c7c7cc;
  background: transparent;
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.check svg {
  display: block;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.line.checked .check {
  background: #e8a317;
  border-color: #e8a317;
}

.line.checked .check svg {
  opacity: 1;
}

.check:focus {
  outline: none;
}

.check:focus-visible {
  outline: 2px solid #e8a317;
  outline-offset: 2px;
}

.del {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin: 5px 0 0 8px;
  background: rgba(60, 60, 67, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.del::after {
  content: "";
  position: absolute;
  inset: -9px;
}

.del svg {
  display: block;
}

.del:focus,
.del:focus-visible {
  outline: none;
}

.line.focused .del {
  opacity: 1;
  pointer-events: auto;
}

.teaser {
  position: fixed;
  z-index: 3;
  left: 0;
  top: 0;
  transform: rotate(var(--r, 0deg));
  color: rgba(244, 240, 230, 0.85);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5);
  font-family: ui-serif, "New York", "Iowan Old Style", "Palatino", Georgia, serif;
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.teaser.held {
  cursor: grabbing;
}

.bob {
  animation: drift var(--fd, 9s) ease-in-out var(--fp, 0s) infinite;
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(calc(var(--fr, 1.2deg) * -1));
  }

  50% {
    transform: translate3d(0, var(--fy, -5px), 0) rotate(var(--fr, 1.2deg));
  }
}

.face {
  padding: 6px;
  opacity: 0.5;
  transform: translate3d(0, 8px, 0);
  transition: opacity 1s ease var(--d, 0s), transform 1s ease var(--d, 0s);
}

.revealed .face {
  opacity: 1;
  transform: none;
}

.teaser.big {
  font-size: 27px;
  font-weight: 400;
  font-style: normal;
}

.teaser.numeral {
  font-style: italic;
  font-weight: 400;
  font-size: 48px;
  letter-spacing: 0.02em;
}

.teaser.phrase {
  font-style: italic;
  font-weight: 400;
  font-size: 19px;
  letter-spacing: 0.04em;
}

.teaser.queen {
  font-family: "Times New Roman", Georgia, serif;
  font-size: 40px;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0;
}

.teaser.leo {
  font-family: "Times New Roman", Georgia, serif;
  font-size: 34px;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0;
  color: rgba(244, 240, 230, 0.92);
}

.teaser.fraktur {
  font-family: 'Fraktur', 'Old English Text MT', serif;
  font-size: 26px;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0;
  color: rgba(244, 236, 214, 0.9);
}

.teaser.emoji {
  font-family: -apple-system, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: 32px;
  font-style: normal;
  letter-spacing: 0;
}

.teaser.card,
.teaser.venn,
.teaser.polaroid {
  font-style: normal;
  letter-spacing: 0;
}

.teaser.polaroid .face {
  padding: 0;
}

.polaroid-frame {
  box-sizing: border-box;
  width: 58px;
  height: 70px;
  padding: 4px 4px 0;
  background: #f6f3ec;
  border-radius: 2px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

.polaroid-photo {
  width: 50px;
  height: 50px;
  background:
    radial-gradient(circle at 50% 46%, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.28) 100%),
    #0d1320;
}

.card-body {
  position: relative;
  box-sizing: border-box;
  width: 46px;
  height: 64px;
  background: #fbfaf7;
  color: #111;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 5px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.38), 0 1px 3px rgba(0, 0, 0, 0.25);
  font-family: "Times New Roman", Georgia, serif;
  letter-spacing: 0;
  text-shadow: none;
}

.idx {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.idx small {
  margin-top: 1px;
  font-size: 9px;
}

.idx.tl {
  left: 4px;
  top: 4px;
}

.idx.br {
  right: 4px;
  bottom: 4px;
  transform: rotate(180deg);
}

.pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1;
}

.venn-body {
  position: relative;
  width: 86px;
  height: 54px;
  font-family: -apple-system, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  letter-spacing: 0;
  text-shadow: none;
}

.ring,
.lens {
  position: absolute;
  top: 0;
  box-sizing: border-box;
  width: 54px;
  height: 54px;
  border-radius: 50%;
}

.ring {
  border: 1.2px solid rgba(244, 240, 230, 0.7);
}

.ring.a,
.lens {
  left: 0;
}

.ring.b {
  left: 32px;
}

.lens {
  overflow: hidden;
}

.lens span {
  position: absolute;
  top: 0;
  left: 32px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(ellipse 15px 24px at 11px 27px, rgba(255, 214, 150, 0.85), rgba(255, 176, 104, 0.35) 62%, rgba(255, 160, 96, 0) 100%);
}

.v {
  position: absolute;
  top: 27px;
  line-height: 1;
  transform: translate(-50%, -50%);
}

.v.happy {
  left: 15px;
  font-size: 18px;
}

.v.sad {
  left: 71px;
  font-size: 18px;
}

.v.both {
  left: 43px;
  font-size: 12px;
}

#veil {
  position: fixed;
  inset: 0;
  z-index: 4;
  background-color: rgba(7, 11, 18, 0.28);
  -webkit-backdrop-filter: blur(22px) saturate(1.1);
  backdrop-filter: blur(22px) saturate(1.1);
  transition: -webkit-backdrop-filter 1.6s ease, backdrop-filter 1.6s ease, background-color 1.6s ease, opacity 1.6s ease;
}

#veil.clearing {
  background-color: rgba(7, 11, 18, 0);
  -webkit-backdrop-filter: blur(0px) saturate(1);
  backdrop-filter: blur(0px) saturate(1);
  opacity: 0;
  pointer-events: none;
}

#butterfly {
  position: fixed;
  z-index: 5;
  top: calc(50vh - 0.5em);
  left: calc(50vw - 0.5em);
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: none;
  box-shadow: none;
  font-size: clamp(76px, 18vw, 112px);
  line-height: 1;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transform-origin: center center;
}

body:not(.revealed) #butterfly {
  animation: breathe 3.2s ease-in-out infinite alternate;
}

@keyframes breathe {
  from {
    scale: 1;
  }

  to {
    scale: 1.04;
  }
}

#butterfly.is-flying {
  pointer-events: none;
}

#butterfly:focus {
  outline: none;
}

#butterfly:focus-visible {
  outline: 2px solid rgba(244, 240, 230, 0.8);
  outline-offset: 3px;
}

#karaoke {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  width: min(34rem, calc(100vw - 3rem));
  transform: translateX(-50%);
  display: grid;
  align-items: end;
  justify-items: center;
  margin: 0;
  text-align: center;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.3;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.k-line {
  grid-area: 1 / 1;
  max-width: 100%;
  margin: 0;
  text-align: center;
}

.where {
  position: fixed;
  z-index: 2;
  left: calc(16px + env(safe-area-inset-left, 0px));
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.16em;
  color: rgba(244, 240, 230, 0.45);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease 0.9s;
}

.revealed .where {
  opacity: 1;
}

.revealed.singing .where {
  opacity: 0;
}

@media (min-width: 980px) {
  #karaoke {
    font-size: 16px;
  }
}

@media (min-width: 980px) and (orientation: landscape) {
  body {
    align-items: center;
    padding-top: 0;
    height: 100dvh;
  }

  .note {
    max-height: min(78dvh, 640px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body:not(.revealed) #butterfly,
  .bob {
    animation: none;
  }

  #karaoke,
  .k-line,
  .k-word {
    transition: none;
  }

  #veil {
    transition-duration: 0.6s;
  }

  .note,
  .face {
    transition-duration: 0.4s;
  }
}
