#game-stage #app .post-office {
  --post-ink: #314c36;
  --post-paper: #fffaed;
  --post-edge: #a9a984;
  --post-action: #405f44;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 25px 22px;
  color: var(--post-ink);
  background: #e3ead3;
  font: 400 15px/1.4 var(--kv-label, sans-serif);
  isolation: isolate;
}

.post-office [hidden] { display: none !important; }
#game-stage #app .post-office button { margin: 0; touch-action: manipulation; }
#game-stage #app .post-office button:focus-visible,
#game-stage #app .post-office-shortcut:focus-visible {
  outline: 2px solid var(--kv-focus, #2c5135);
  outline-offset: 2px;
}
#game-stage #app .post-office :is(.post-office-tabs button, .post-office-faces button, .post-office-item, .post-office-place):focus-visible {
  position: relative;
  z-index: 2;
  outline: 2px solid var(--kv-focus, #2c5135);
  outline-offset: -3px;
}

.post-office-toolbar,
.post-office-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
}

.post-office-toolbar { min-height: 50px; }
#game-stage #app .post-office-back {
  display: grid;
  place-items: center;
  width: max(45px,calc(44px / var(--stage-scale,1)));
  height: max(45px,calc(44px / var(--stage-scale,1)));
  padding: 0;
  border: 1px solid #9da888;
  border-radius: 50%;
  background: #fff7df;
  color: var(--post-ink);
}
.post-office-back svg { width: 23px; height: 23px; }
.post-office-brand { width: 100px; height: 40px; object-fit: contain; }
.post-office-heading { margin: 13px 0 16px; }

#game-stage #app .post-office-heading h1 {
  margin: 0;
  font: 400 40px/1.08 var(--kv-writing, serif);
  color: #36573e;
  white-space: nowrap;
}
.post-office-heading h1:focus { outline: none; }
.post-office-balance {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid #c0ad83;
  border-radius: 5px;
  background: #ffefcf;
  color: #6a5435;
  font-size: 12px;
  white-space: nowrap;
}
.post-office-balance svg, .post-office-shortcut svg { width: 23px; height: 23px; flex: 0 0 auto; }

.post-office-workbench { flex: 0 0 auto; }
.post-office-display {
  height: 201px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid #aaa078;
  border-bottom-width: 6px;
  border-radius: 17px 17px 8px 8px;
  background: linear-gradient(#d2dfc3 0 73%,#bc956f 73% 76%,#dec6a5 76% 100%);
}
.post-office-display::before {
  position: absolute;
  content: "";
  z-index: -1;
  right: 12px;
  top: 18px;
  width: 72px;
  height: 66px;
  border: 3px solid #eef1d9;
  border-radius: 36px 36px 4px 4px;
  background: linear-gradient(145deg,#fff7ce 0 34%,#ebf4df 34% 100%);
}
.post-office-counter-mailbox {
  position: absolute;
  right: 12px;
  bottom: 24px;
  z-index: -1;
  width: 70px;
  height: 83px;
  object-fit: contain;
}
.post-office-envelope {
  position: relative;
  width: 240px;
  height: 145px;
  margin: 0 24px 7px 0;
}
.post-office-envelope-photo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
#game-stage #app .post-office-envelope .letter-envelope-trim {
  position: absolute;
  inset: 8% 9% 4%;
  width: 82%;
  height: 88%;
}
#game-stage #app .post-office :is(.post-office-envelope,.post-office-paper) .letter-finish-applique {
  position: absolute;
  width: 36px;
  height: 36px;
  top: 13%;
  right: 11%;
  left: auto;
  bottom: auto;
}
#game-stage #app .post-office [data-letter-decoration-layout=lower] :is(.post-office-envelope,.post-office-paper) .letter-finish-applique {
  top: auto;
  right: auto;
  left: 13%;
  bottom: 14%;
}
#game-stage #app .post-office [data-letter-decoration-layout=seam] .post-office-envelope .letter-finish-applique {
  top: 47%;
  right: 36%;
}
#game-stage #app .post-office [data-letter-decoration-layout=seam] .post-office-paper .letter-finish-applique {
  top: auto;
  right: 13%;
  bottom: 11%;
}

.post-office-paper {
  position: relative;
  width: 223px;
  min-height: 147px;
  padding: 17px 17px 31px;
  margin-right: 25px;
  border: 1px solid #b7ad85;
  border-radius: 2px 7px 5px 3px;
  background: repeating-linear-gradient(transparent 0 23px,#dcdab863 23px 24px),#fff9e9;
  box-shadow: 0 3px 0 #84937465;
  color: #455540;
  transform: rotate(-2deg);
}
.post-office-paper[data-letter-font=handwritten],
.post-office-item-art [data-letter-font=handwritten] {
  font-family: var(--letter-font,var(--kv-writing, serif));
}
.post-office-paper[data-letter-font=print],
.post-office-item-art [data-letter-font=print] {
  font-family: var(--kv-label, sans-serif);
}
.post-office-paper b { font-size: 17px; }
.post-office-paper p { margin: 8px 0 0; padding-right: 28px; font-size: 15px; line-height: 1.48; }

/* On paper the sticker gets its own bottom margin; placement still applies to
   the envelope, where it cannot cover the letter's text. */
#game-stage #app .post-office .post-office-paper { padding-bottom: 52px; }
#game-stage #app .post-office .post-office-paper .letter-finish-applique {
  top: auto;
  right: 9%;
  bottom: 8px;
  left: auto;
}
#game-stage #app .post-office [data-letter-decoration-layout=lower] .post-office-paper .letter-finish-applique {
  top: auto;
  right: auto;
  bottom: 8px;
  left: 9%;
}
#game-stage #app .post-office [data-letter-decoration-layout=seam] .post-office-paper .letter-finish-applique {
  top: auto;
  right: calc(50% - 18px);
  bottom: 8px;
  left: auto;
}

/* A stamp leaves its home corner only when its owner places it. */
#game-stage #app .post-office [data-letter-city-stamp-layout=corner] .post-office-envelope .letter-city-stamp {top:13%;right:10%;left:auto;transform:rotate(7deg);}
#game-stage #app .post-office [data-letter-city-stamp-layout=lower] .post-office-envelope .letter-city-stamp {top:29.5%;left:10%;transform:rotate(-6deg);}
#game-stage #app .post-office [data-letter-city-stamp-layout=seam] .post-office-envelope .letter-city-stamp {top:20.7%;right:auto;left:38.5%;transform:rotate(11deg);}
#game-stage #app .post-office .post-office-paper .letter-sheet-stamp {position:absolute;width:40px;}
#game-stage #app .post-office [data-letter-city-stamp-layout=corner] .post-office-paper .letter-sheet-stamp {top:12px;right:12px;transform:rotate(7deg);}
#game-stage #app .post-office [data-letter-city-stamp-layout=corner] .post-office-paper p {padding-right:58px;}
#game-stage #app .post-office [data-letter-city-stamp-layout=lower] .post-office-paper .letter-sheet-stamp {bottom:6px;left:9%;transform:rotate(-6deg);}
#game-stage #app .post-office [data-letter-city-stamp-layout=seam] .post-office-paper .letter-sheet-stamp {bottom:6px;left:calc(50% - 20px);transform:rotate(6deg);}

/* Arranging: dashed spots lie on the preview itself, above the art and below whatever is stuck there. */
.post-office-slots { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
#game-stage #app .post-office-slot {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1.5px dashed #5f77529c;
  border-radius: 10px;
  background: #fff8e83d;
  color: #4f6748;
  pointer-events: auto;
}
.post-office-slot-mark { width: 12px; height: 12px; opacity: .75; }
#game-stage #app .post-office-slot:is([aria-pressed=true],.post-office-slot-pending) {
  border: 2px solid var(--post-action);
  background: #fff8e880;
  color: var(--post-action);
}
.post-office-envelope .post-office-slot[data-post-spot=upperleft],
.post-office-envelope .post-office-slot[data-post-spot=corner],
.post-office-envelope .post-office-slot[data-post-spot=lower],
.post-office-envelope .post-office-slot[data-post-spot=seam] {width:calc(23% + 4px);aspect-ratio:59/68;}
.post-office-envelope .post-office-slot[data-post-spot=upperleft] {top:calc(13% - 2px);left:calc(9% - 2px);}
.post-office-envelope .post-office-slot[data-post-spot=corner] {top:calc(13% - 2px);right:calc(10% - 2px);}
.post-office-envelope .post-office-slot[data-post-spot=lower] {top:calc(29.5% - 2px);left:calc(10% - 2px);}
.post-office-envelope .post-office-slot[data-post-spot=seam] {top:calc(20.7% - 2px);left:calc(38.5% - 2px);}
.post-office-envelope .post-office-slot[data-post-box=sticker] {top:auto;width:44px;height:44px;aspect-ratio:auto;}
.post-office-envelope .post-office-slot[data-post-spot=corner][data-post-box=sticker] {top:calc(13% - 4px);right:calc(11% - 4px);}
.post-office-envelope .post-office-slot[data-post-spot=lower][data-post-box=sticker] {bottom:calc(14% - 4px);left:calc(13% - 4px);}
.post-office-envelope .post-office-slot[data-post-spot=seam][data-post-box=sticker] {top:calc(47% - 4px);left:calc(49% - 4px);}
/* The home spot lies partly under a stamp moved to the lower left; only its top shows. */
#game-stage #app .post-office-slot[data-post-cap] {place-items:start center;padding-top:6px;clip-path:inset(0 0 62% 0);}
.post-office-paper .post-office-slot[data-post-spot=lower],
.post-office-paper .post-office-slot[data-post-spot=seam] {bottom:2px;width:48px;height:50px;}
.post-office-paper .post-office-slot[data-post-spot=lower] {left:calc(9% - 4px);}
.post-office-paper .post-office-slot[data-post-spot=seam] {left:calc(50% - 24px);}
.post-office-paper .post-office-slot[data-post-spot=paper-sticker-corner] {right:calc(9% - 4px);bottom:2px;width:44px;height:44px;}
.post-office-paper .post-office-slot[data-post-spot=paper-stamp-corner] {top:6px;right:6px;width:52px;height:54px;}
/* While its spots show, the sheet keeps the sample text clear of the top-right spot and of the bottom row. */
#game-stage #app .post-office .post-office-paper:has(> .post-office-slots) {padding-bottom:60px;}
#game-stage #app .post-office .post-office-paper:has(> .post-office-slots) p {padding-right:58px;}

.post-office-faces {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 168px;
  margin: 8px auto 11px;
  padding: 2px;
  border: 1px solid #a7ae8c;
  border-radius: 11px;
  background: #dae5c9;
}
#game-stage #app .post-office-faces button {
  min-height: max(38px,calc(44.25px / var(--stage-scale,1)));
  padding: 1px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #3d5940;
  background: transparent;
  font: inherit;
  font-size: 12px;
}
#game-stage #app .post-office-faces button[aria-pressed=true] {
  background: var(--post-paper);
  border-color: #b9b78d;
}

.post-office-tabs {
  display: grid;
  grid-template-columns: repeat(5,minmax(0,1fr));
  gap: 4px;
  flex: 0 0 auto;
}
#game-stage #app .post-office-tabs button {
  min-height: max(45px,calc(44.25px / var(--stage-scale,1)));
  border: 1px solid #aeb58e;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: #cedabd;
  color: #3d5940;
  /* The original letter subset lacks several tab characters (including 戳),
     causing mixed-font labels. All five tabs use the licensed brush subsets. */
  font: 400 20px/1 "Guimi Brush", var(--kv-writing, serif);
}
#game-stage #app .post-office-tabs button[aria-pressed=true] {
  border-color: var(--post-edge);
  background: var(--post-paper);
  color: var(--post-ink);
  box-shadow: inset 0 3px 0 #7f975e;
}
.post-office-options {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--post-edge);
  border-top: 0;
  border-radius: 0 0 11px 11px;
  background: var(--post-paper);
  overscroll-behavior: contain;
}

#game-stage #app .post-office-item {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 61px;
  padding: 3px 5px 3px 2px;
  gap: 3px;
  text-align: left;
  border: 1px solid #cdc5a2;
  border-radius: 7px 10px 10px 7px;
  color: #3d553d;
  background: #f4edd6;
  font: 400 13px/1.18 var(--kv-label, sans-serif);
}
#game-stage #app .post-office-item[aria-pressed=true] {
  border-color: #6f8857;
  box-shadow: inset 0 0 0 1px #6f8857;
  background: #e7edd4;
}
.post-office-item-art {
  flex: 0 0 49px;
  width: 49px;
  height: 48px;
  display: grid;
  place-items: center;
}
.post-office-item-art :is(img,svg) {
  display: block;
  position: static;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.post-office-item-art span { font-size: 27px; }
.post-office-item-label {
  min-width: 0;
  display: grid;
  gap: 3px;
  line-height: 1.3;
}
.post-office-item-label b { white-space: nowrap; }
.post-office-item-label small { color: #4c5e44; font-size: 12px; }
.post-office-options[data-post-options=cityStamp] .post-office-item-label b {white-space:normal;overflow-wrap:anywhere}
.post-office-options[data-post-options=cityStamp] .post-office-item-art {height:58px;flex-basis:58px;width:58px}
.post-office-stamp-empty {grid-column:1/-1;margin:10px 7px;font:400 14px/1.7 var(--kv-label);color:#637558}

/* Arranging: one row of spots per thing, so every spot stays in view. */
.post-office-place-title {
  grid-column: 1 / -1;
  margin: 3px 0 -3px;
  font: 600 12px/1.4 var(--kv-label, sans-serif);
  color: #4c5e44;
}
.post-office-place-row {
  grid-column: 1 / -1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0,1fr);
  gap: 6px;
}
#game-stage #app .post-office-place {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 1px;
  min-width: 0;
  min-height: max(50px,calc(44.25px / var(--stage-scale,1)));
  padding: 3px 2px;
  border: 1px solid #cdc5a2;
  border-radius: 7px 10px 10px 7px;
  color: #3d553d;
  background: #f4edd6;
  font: 400 12px/1.2 var(--kv-label, sans-serif);
  white-space: nowrap;
}
#game-stage #app .post-office-place svg { display:block;width: 30px; height: 20px; }
#game-stage #app .post-office-place[aria-pressed=true] {
  border-color: #6f8857;
  box-shadow: inset 0 0 0 1px #6f8857;
  background: #e7edd4;
}
.post-office-prompt {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.post-office-prompt:empty { display: none; }
.post-office-prompt p {
  flex: 1 0 auto;
  min-width: 0;
  margin: 0 2px;
  font: 400 13px/1.35 var(--kv-label, sans-serif);
  color: #4c5e44;
}
#game-stage #app .post-office-prompt .post-office-pick {
  flex: 0 1 96px;
  min-height: max(42px,calc(44.25px / var(--stage-scale,1)));
  font-size: 13px;
}
#game-stage #app .post-office-prompt:not(:has(p)) .post-office-pick { flex: 1 1 0; max-width: calc(50% - 3px); }

.post-office-footer { flex: 0 0 auto; }
.post-office-status {
  min-height: 18px;
  margin: 6px 0;
  color: #536553;
  font-size: 12px;
  text-align: center;
}
.post-office-actions { display: flex; gap: 7px; }
#game-stage #app .post-office-actions button {
  flex: 1 1 auto;
  min-width: 0;
  min-height: max(50px,calc(44px / var(--stage-scale,1)));
  padding: 5px 6px;
  border: 1px solid #304d36;
  border-radius: 11px 12px 10px 10px;
  color: #fff9e9;
  background: var(--post-action);
  font: 600 14px/1.2 var(--kv-label, sans-serif);
}
#game-stage #app .post-office-actions .post-office-secondary {
  border-color: #a4ac86;
  color: var(--post-ink);
  background: #f8efd6;
}
#game-stage #app .post-office-actions button:disabled {
  border-color: #aeb495;
  background: #d4dfbd;
  color: #466148;
}
#game-stage #app .post-office-actions:not(:has(button)) { min-height: 50px; }
#game-stage #app .post-office button:not(:disabled):active { transform: scale(.98); }

#game-stage #app .receive-center-actions {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  align-items: stretch;
  gap: 8px;
}
#game-stage #app .receive-center .receive-center-actions .receive-write {
  width: 100%;
  margin: 0;
}
#game-stage #app .post-office-shortcut {
  display: flex;
  place-items: center;
  justify-content: center;
  gap: 4px;
  min-height: max(45px,calc(44px / var(--stage-scale,1)));
  margin: 0;
  padding: 4px 6px;
  border: 1px solid #9da988;
  border-radius: 8px 10px 8px 8px;
  color: #355338;
  background: #edf2d8;
  font: 600 13px/1.2 var(--kv-label, sans-serif);
}
#game-stage #app .gm-compose .gm-letter-actions {
  grid-template-columns: .95fr 1.65fr;
}
#game-stage #app .gm-compose .gm-compose-utilities {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 6px;
  margin-top: 7px;
}
#game-stage #app .gm-compose .gm-compose-utilities button {
  min-height: max(42px,calc(44px / var(--stage-scale,1)));
  margin: 0;
}
#game-stage #app .gm-compose .gm-compose-post-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 7px;
  border: 0;
  background: transparent;
  color: #466747;
  font: 600 13px/1.3 var(--kv-label, sans-serif);
}
.gm-compose-post-link span { margin-left: 4px; }
#game-stage #app .gm-letter-paper > .letter-finish-applique {
  position: absolute;
  width: 33px;
  height: 33px;
  bottom: 2px;
  right: 5px;
}
#game-stage #app .gm-letter-paper[data-letter-decoration-layout=lower] > .letter-finish-applique {
  left: 5px;
  right: auto;
}
#game-stage #app .gm-letter-paper[data-letter-decoration-layout=seam] > .letter-finish-applique {
  right: calc(50% - 16px);
}

@media (max-width: 340px), (max-height: 700px) {
  #game-stage #app .post-office { padding: 18px 24px; }
  .post-office-display { height: 188px; }
  .post-office-heading { margin: 9px 0 11px; }
  .post-office-faces { margin: 5px auto 8px; }
}
