:root {
  --post-ink: #233935;
  --post-muted: #49605a;
  --post-paper: #fff8e7;
  --post-stroke: #3b5852;
  --post-line: #b9c5af;
  --post-mint: #d7ece0;
  --post-gold: #f4d581;
}

.post-cover, .post-paper, .post-hud, .post-talk {
  color: var(--post-ink);
  font: 500 18px/1.55 var(--messenger-font);
  line-break: strict;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
.post-cover *, .post-paper *, .post-hud * { box-sizing: border-box; }
.post-cover p, .post-paper p, .post-paper h2 { margin: 0; }
.post-cover button, .post-paper button, button.post-hud { color: inherit; font: inherit; cursor: pointer; }
.post-cover button:focus-visible, .post-paper button:focus-visible, .post-hud:focus-visible, .side-button:focus-visible {
  outline: 3px solid #275f7e;
  outline-offset: 3px;
}
/* The 3D button keeps its pointer target, hover animation, and appearance. */
.post-start-control {
  position: fixed;
  z-index: 3;
  border: 0;
  padding: 0;
  background: transparent;
  pointer-events: none;
}
.post-start-control:focus-visible {
  outline: 3px solid #204c55;
  outline-offset: 5px;
  border-radius: 6px;
}
.post-cover svg, .post-paper svg, .post-hud svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.post-cover[hidden], .post-cover [hidden], .post-hud[hidden], .post-talk[hidden], .post-hud[hidden] + .post-talk, .post-paper [hidden] { display: none; }
.post-heading { font: 600 clamp(28px, 5vw, 36px)/1.2 var(--messenger-font); }

/* A small address label in the negative space above the animated planet. */
.post-cover {
  position: fixed;
  z-index: 4;
  top: max(16px, calc(env(safe-area-inset-top) + 9px));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 7px 8px 7px 16px;
  background: var(--post-paper);
  border: 2px solid var(--post-stroke);
  border-radius: 8px 5px 6px 5px / 6px 8px 5px 7px;
  box-shadow: 3px 4px 0 #31574e6b;
  transform: translateX(-50%) rotate(-1deg);
  animation: post-arrive .45s both;
  white-space: nowrap;
}
.post-cover-address { font: 600 clamp(20px, 3.5vw, 24px)/1.2 var(--messenger-font); }
.post-cover-seal {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--post-gold);
  border: 1px dashed #a16b3c;
  border-radius: 50% 47% 48% 45%;
  transition: transform .15s ease;
}
.post-cover-seal:hover, .post-cover-seal[aria-expanded='true'] { transform: rotate(12deg) scale(1.06); }
.post-cover-seal svg { width: 23px; height: 23px; fill: #fff5c6; color: #82502d; }
.post-cover .post-seal-message {
  position: absolute;
  left: 50%;
  top: calc(100% + 11px);
  width: min(310px, calc(100vw - 36px));
  margin: 0;
  padding: 12px 15px;
  border: 1.5px solid var(--post-stroke);
  box-shadow: 3px 3px 0 #31574e6b;
  background: var(--post-paper);
  transform: translateX(-50%) rotate(2deg);
  white-space: normal;
}
@keyframes post-arrive {
  from { opacity: 0; transform: translate(-50%, -8px) rotate(-3deg); }
  to { opacity: 1; transform: translateX(-50%) rotate(-1deg); }
}

/* Readable at a glance without covering the player or replacing the original icons. */
.post-toolbar {
  position: fixed;
  z-index: 4;
  inset-block-start: max(50px, calc(env(safe-area-inset-top) + 10px));
  inset-inline-end: max(30px, calc(env(safe-area-inset-right) + 10px));
  display: grid;
  justify-items: end;
  gap: 5px;
}
button.post-hud {
  display: flex;
  align-items: center;
  text-align: left;
  max-width: min(275px, calc(100vw - 145px));
  min-height: 58px;
  gap: 8px;
  padding: 5px 11px 6px 8px;
  background: var(--post-paper);
  border: 2px solid var(--post-stroke);
  border-radius: 7px 5px 5px 7px / 4px 8px 5px 6px;
  box-shadow: 3px 4px 0 #263f3cb0;
  touch-action: manipulation;
}
button.post-talk {
  min-height: 44px;
  padding: 5px 11px;
  color: var(--post-ink);
  background: var(--post-gold);
  border: 2px solid var(--post-stroke);
  border-radius: 6px 5px 4px 4px;
  box-shadow: 2px 2px 0 #263f3cb0;
  font: 600 16px/1.2 var(--messenger-font);
  cursor: pointer;
}
.post-talk:hover { background: #ffe3a8; }
.post-talk:focus-visible { outline: 3px solid #275f7e; outline-offset: 3px; }
.post-hud:hover { background: #ffedbd; }
.post-hud-copy { display: flex; flex-direction: column; min-width: 0; }
.post-hud-copy b { font: 600 19px/1.2 var(--messenger-font); }
.post-hud-target { font-size: 17px; line-height: 1.35; margin-top: 2px; }
.post-hud .post-needle { width: 24px; height: 24px; color: #2d6961; flex: none; }
.post-hud .post-needle-near { color: #a5631a; }
.post-needle-rest { visibility: hidden; width: 0 !important; }
/* Handwritten replies, close to the original dialogue card without covering faces. */
.post-visit { position: fixed; z-index: 9; left: 50%; bottom: max(20px,4dvh,env(safe-area-inset-bottom)); transform: translateX(-50%);
  box-sizing: border-box; width: min(526px, calc(100vw - 28px)); padding: 14px 19px; color: var(--post-ink);
  background: var(--post-paper); border: 2px solid var(--post-stroke); border-radius: 12px 8px 10px 6px; box-shadow: 4px 5px 0 #203c3888;
  font: 500 18px/1.45 var(--messenger-font); line-break: strict; }
.post-visit[hidden], .post-visit [hidden] { display: none; }
.post-visit-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.post-visit-close { float: right; display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  margin: 0 0 4px 10px; color: var(--post-ink); background: var(--post-mint); border: 1px solid var(--post-stroke);
  border-radius: 6px 5px; cursor: pointer; }
.post-visit-close svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.post-visit-voice b { font: 600 20px/1.3 var(--messenger-font); color: #365d4f; }
.post-visit-voice p { font-size: clamp(21px, 3.2vw, 25px); line-height: 1.5; margin: 4px 0; }
.post-visit[data-beat="sunlit"] .post-visit-voice p { text-wrap: balance; }
.post-visit-actions { margin-top: 9px; justify-content: flex-end; flex-wrap: wrap; }
.post-family-choice { background: #f4dc9a; color: var(--post-ink); border: 1.5px solid var(--post-stroke); border-radius: 7px 5px 6px 4px;
  box-shadow: 2px 2px 0 #536b54; padding: 6px 14px; min-height: 44px; font: 600 18px/1.35 var(--messenger-font); cursor:pointer; }
.post-visit-actions:empty { display: none; }
.post-family-choice:hover { background:#ffe9ae; } .post-visit button:focus-visible { outline: 3px solid #38746b; outline-offset: 3px; }
@media (min-width: 1600px) and (min-height: 800px) {
  .post-toolbar { inset-block-start: 82px; inset-inline-end: 50px; }
}

/* Booklet and birthday reply use the paper/ink colors of the game's dialogue cards. */
.post-paper {
  position: fixed;
  inset: 0;
  max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
  max-width: calc(100vw - 30px);
  margin: auto;
  padding: 23px 25px;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  background: var(--post-paper);
  border: 2px solid var(--post-stroke);
  border-radius: 12px 9px 10px 8px / 9px 12px 8px 10px;
  box-shadow: 5px 6px 0 #253c3a99;
  scrollbar-width: thin;
}
.post-paper[open] { animation: post-unfold .21s ease-out both; }
.post-paper::backdrop { background: #162d2d75; }
@keyframes post-unfold { from { opacity: .3; transform: translateY(7px) rotate(-.65deg); } }
.post-book { width: 478px; }
.post-book-header { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.post-book-header .post-heading { margin-top: 5px; }
button.post-close {
  display: grid;
  flex: none;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 1.5px solid var(--post-stroke);
  background: var(--post-mint);
  border-radius: 5px 6px 5px 4px;
}
.post-close:hover { background: #bde1ce; }
.post-close svg { width: 21px; height: 21px; }
.post-paper .post-progress { margin-top: 12px; border-top: 1px dashed var(--post-line); padding-top: 9px; font: 600 18px var(--messenger-font); }
.post-routes { padding: 0; margin: 8px 0 0; list-style: none; display: grid; gap: 5px; }
.post-route-inner {
  width: 100%;
  min-height: 55px;
  display: grid;
  grid-template-columns: 39px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  background: #ffffff64;
  border: 1px solid #d5d7bf;
  border-radius: 6px 5px 7px 5px;
  padding: 6px 8px;
}
.post-route[data-tracked='true'] .post-route-inner { background: var(--post-mint); border-color: #648b7e; }
button.post-route-inner:hover { background: #ebefd4; border-color: #648b7e; }
.postmark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--stamp);
  background: var(--stamp-tint);
  border: 1px dashed currentColor;
  border-radius: 7px 4px 5px 6px;
  transform: rotate(-4deg);
}
.post-route:nth-child(even) .postmark { transform: rotate(4deg); }
.post-route[data-stamped='true'] .postmark { border: 2px solid currentColor; border-radius: 50%; }
.postmark svg { width: 22px; height: 22px; }
.post-route-copy { display: flex; flex-direction: column; }
.post-route-copy b { font: 600 18px/1.17 var(--messenger-font); }
.post-route-target { font-size: 17px; line-height: 1.35; margin-top: 3px; }
.post-route-count { font-size: 17px; border-left: 1px dashed var(--post-line); padding-inline: 7px 1px; white-space: nowrap; }
.post-book .post-secret { margin-top: 13px; padding: 8px 10px; border: 1px dashed #b2bc9d; border-radius: 4px; background: #f4efd7; }
.post-actions { display: flex; align-items: center; justify-content: end; flex-wrap: wrap; gap: 9px; margin-top: 8px; }
button.post-primary, button.post-link {
  min-height: 44px;
  padding: 7px 13px;
  border-radius: 5px 4px 6px 5px;
  touch-action: manipulation;
}
button.post-primary {
  background: var(--post-gold);
  border: 1.5px solid var(--post-stroke);
  box-shadow: 2px 3px 0 #3b585286;
  font: 600 18px/1.1 var(--messenger-font);
}
button.post-primary:hover { background: #ffdf91; }
button.post-primary:active { box-shadow: none; transform: translateY(2px); }
button.post-primary:disabled { opacity: .64; cursor: default; box-shadow: none; }
button.post-link { background: transparent; border: 0; color: var(--post-muted); text-decoration: underline; text-underline-offset: 4px; font-size: 17px; }
button.post-link:hover { color: var(--post-ink); }
.post-replay { padding: 12px 0 1px; border-top: 1px dashed var(--post-line); }
.post-replay p { margin-bottom: 6px; }
.post-reply { width: min(512px, calc(100vw - 32px)); text-align: center; padding: 20px 24px 12px; }
.post-reply .post-heading { margin-top: 9px; text-wrap:balance; }
.post-reply[data-phase=prelude], .post-reply[data-phase=lights] { inset: auto 0 max(14px,3dvh,env(safe-area-inset-bottom)); }
.post-reply[data-phase=prelude]::backdrop { background: transparent; }
.post-reply[data-phase=lights]::backdrop { background: transparent; }
.post-family-prelude { text-align:left; }
.post-family-prelude h3 { font:600 23px var(--messenger-font); color:#365d4f; margin:6px 0; }
.post-family-prelude > p { font:500 clamp(21px,2.8vw,25px)/1.5 var(--messenger-font); }
.post-family-prelude .post-primary { display:block; margin:10px 0 0 auto; }
.post-reply[data-phase=prelude] > .post-link { position:absolute; left:18px; bottom:10px; }
.post-cake-figure { margin: 6px auto 16px; }
.post-cake { width: 128px; height: 98px; margin: 5px auto 3px; }
.post-cake-sign { display:inline-block; padding:2px 13px; border:1px solid #a78350; background:#f7e1ac; border-radius:3px 5px; font:600 18px var(--messenger-font); color:#693f2b;transform:rotate(-2deg); }
.cake-flame { transform-box:fill-box;transform-origin:50% 95%;animation:post-flicker .64s alternate infinite; }
.candle-out .cake-flame {visibility:hidden;}
@keyframes post-flicker { from { transform:scale(.9,.95) rotate(-6deg); } to { transform:scale(1.06,1.13) rotate(5deg); } }
.post-paper .post-signature {color:var(--post-muted); font-size:18px;margin-bottom:13px;}
.post-reply > .post-link { min-height:42px; }
.post-reply[data-phase=lights] {width:min(590px,calc(100vw - 28px)); background:#193b46f5;border-color:#a4c5b8; color:#fff3cf; padding:12px 18px 5px;}
.post-reply[data-phase=lights] > .post-link { color:#bedbd4; }
.post-light-heading { font:600 clamp(21px,3.5vw,29px)/1.25 var(--messenger-font);margin:5px 0; }
.post-lights { display:flex; justify-content:space-evenly; gap:3px; list-style:none; padding:0; margin:10px 0 7px; }
.post-light {flex:1 1 0; position:relative; font:500 clamp(15px,2.6vw,17px)/1.4 var(--messenger-font); color:#a8c1c1;}
.post-light::before { content:'';display:block;position:relative;z-index:1;width:12px;height:12px;margin:0 auto 5px;
  border:1.5px solid #9db6ba;border-radius:4px 4px 6px 6px;background:#294c56;}
.post-light:not(:last-child)::after {content:'';height:1px;position:absolute;left:55%;right:-48%;top:7px;border-top:1px dashed #80a0a5;}
.post-light[data-on=true] {color:#ffe8aa;}.post-light[data-on=true]::before {background:#ffdd82;border-color:#ffecab;box-shadow:0 0 9px 2px #f8be5970;}
@media(max-height:550px) { .post-reply[data-phase=prelude],.post-reply[data-phase=lights] {left:auto;right:8px;bottom:8px;width:min(43vw,460px);padding:10px;}}
@media (max-width: 639px), (max-height: 639px) {
  .post-toolbar { inset-block-start: max(30px, calc(env(safe-area-inset-top) + 10px)); inset-inline-end: max(20px, calc(env(safe-area-inset-right) + 10px)); }
  button.post-hud { max-width: calc(100vw - 95px); min-height: 45px; }
  .post-hud .post-needle { width: 20px; height: 20px; }
  .post-hud-target { font-size: 16px; }
  .post-hud-copy b { font-size: 18px; }
  .post-paper { padding: 18px 15px; }

}
@media (orientation: portrait) and (max-width: 639px) and (min-height: 690px) {
  .post-cover { top: max(27px, calc(env(safe-area-inset-top) + 14px)); }
}
@media (max-height: 530px) and (orientation: landscape) {
  .post-cover { top: max(10px, env(safe-area-inset-top)); left: max(15px, env(safe-area-inset-left)); transform: rotate(-1deg); animation: none; }
  .post-cover .post-seal-message { left: 0; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .post-cover, .post-paper[open], .cake-flame { animation: none; }
}
