.family-page-sticky #result-notice {
  --dispatch-paper: #fcf4df;
  --dispatch-light: #fffcf3;
  --dispatch-line: #d4bb86;
  --dispatch-ink: #4e3d29;
  --dispatch-muted: #6c5538;
  --dispatch-seal: #806035;
  align-items: center;
  gap: 5px clamp(7px, 1.2vw, 13px);
  padding-block: 5px;
  border-block: 0;
  border-block-end: 1px solid var(--dispatch-line);
  background: radial-gradient(ellipse at 48% 0%, var(--dispatch-light), transparent 76%), var(--dispatch-paper);
  color: var(--dispatch-ink);
}

.family-page-sticky #result-notice.has-conquest-win,
.family-page-sticky #result-notice.has-action-dispatch:not(.has-territory-incident){
  --dispatch-paper: #edf2df;
  --dispatch-light: #fff8e1;
  --dispatch-line: #c6b177;
  --dispatch-ink: #234738;
  --dispatch-muted: #4d6046;
  --dispatch-seal: #42644a;
}
.family-page-sticky #result-notice:is(.has-conquest-win, .has-action-dispatch:not(.has-territory-incident)) {
  --dispatch-paper: #edf2df;
  --dispatch-light: #fff8e1;
  --dispatch-line: #c6b177;
  --dispatch-ink: #234738;
  --dispatch-muted: #4d6046;
  --dispatch-seal: #42644a;
}

.family-page-sticky #result-notice.has-territory-incident {
  --dispatch-paper: #f9eadc;
  --dispatch-light: #fff8eb;
  --dispatch-line: #d7ac92;
  --dispatch-ink: #5c3729;
  --dispatch-muted: #704b3b;
  --dispatch-seal: #8a4935;
}

.family-page-sticky #result-notice.has-rank-dispatch {
  --dispatch-paper: #f8e5c5;
  --dispatch-light: #fff7e6;
  --dispatch-line: #d3a16c;
  --dispatch-ink: #683a26;
  --dispatch-muted: #754a35;
  --dispatch-seal: #8a452e;
}

.family-page-sticky #result-notice .result-notice-icon {
  display: grid;
  flex: 0 0 clamp(33px, 9vw, 39px);
  place-items: center;
  inline-size: clamp(33px, 9vw, 39px);
  block-size: clamp(33px, 9vw, 39px);
  border: 1px solid var(--dispatch-line);
  border-radius: 9px;
  background: linear-gradient(145deg, #fffbef, var(--dispatch-paper));
  color: var(--dispatch-seal);
  line-height: 1;
}

.family-page-sticky #result-notice .result-notice-icon img {
  display: block;
  inline-size: clamp(26px, 7.8vw, 31px);
  block-size: clamp(26px, 7.8vw, 31px);
  object-fit: contain;
}

.family-page-sticky #result-notice img.result-notice-icon { padding: 3px; }

:root[dir="rtl"] #result-notice img.result-notice-icon,
:root[dir="rtl"] #result-notice .result-notice-icon img{
  transform: scaleX(-1);
}
:root[dir="rtl"] #result-notice :is(img.result-notice-icon, .result-notice-icon img) {
  transform: scaleX(-1);
}

#result-notice .dispatch-copy {
  display: grid;
  flex: 1 1 0;
  align-content: center;
  min-inline-size: 0;
  gap: 1px;
  overflow-wrap: anywhere;
}

#result-notice .dispatch-copy .dispatch-kicker {
  color: var(--dispatch-seal);
  font-size: clamp(.58rem, 2.3vw, .68rem);
  font-weight: 800;
  line-height: 1.15;
}

#result-notice .dispatch-copy b {
  color: var(--dispatch-ink);
  font-size: clamp(.72rem, 2.85vw, .86rem);
  line-height: 1.25;
}

#result-notice .dispatch-copy small {
  margin: 0;
  color: var(--dispatch-muted);
  font-size: clamp(.62rem, 2.4vw, .75rem);
  line-height: 1.25;
}

#result-notice .dispatch-copy bdi { font-variant-numeric: tabular-nums; }

.family-page-sticky #result-notice .result-notice-actions {
  flex: 0 1 auto;
  gap: 4px;
  min-inline-size: 0;
}

.family-page-sticky #result-notice .result-notice-actions .btn.small {
  min-block-size: 31px;
  padding: 4px clamp(6px, 1.35vw, 12px);
  border-radius: 7px;
  font-size: clamp(.62rem, 2.35vw, .76rem);
  line-height: 1.2;
}

#result-notice.has-rank-dispatch .result-notice-actions > button[data-open-rank-dispatches] {
  --button-bg: #8c472e;
  --button-hover: #723823;
  --button-line: #8c472e;
  --button-ink: #fffdf2;
}

dialog.dispatch-results-dialog {
  inline-size: min(464px, calc(100% - 22px));
  max-block-size: min(624px, calc(100vh - 24px));
  max-block-size:min(624px, calc(100vh - 24px));max-block-size: min(624px, calc(100dvh - 24px));
  padding: clamp(12px, 4vw, 20px);
  border-color: #c79762;
  border-radius: 16px;
  background: linear-gradient(150deg, #fff9e7, #fffbf1 65%, #fbedd4);
  color: #563d2b;
  overscroll-behavior: contain;
}

dialog.dispatch-results-dialog::backdrop {
  background: #1228249e;
  backdrop-filter: blur(2px);
}

.dispatch-results-dialog .modal-head {
  gap: 8px;
  margin-block-end: 10px;
  padding-block-end: 8px;
  border-block-end: 1px solid #dcc29b;
}

.dispatch-results-dialog .modal-head h2 { color: #6f412d; }

.dispatch-results-dialog .modal-head .icon-button {
  flex: none;
  background: #f3e7d6;
  color: #7e533b;
}

.rank-dispatch-card {
  display: grid;
  gap: 7px;
  min-inline-size: 0;
  padding: clamp(10px, 3vw, 14px);
  border: 1px solid #dabd90;
  border-inline-start: 3px solid #b47548;
  border-radius: 10px;
  background: linear-gradient(140deg, #fff9e9, #f9efd9);
  overflow-wrap: anywhere;
}

.rank-dispatch-card + .rank-dispatch-card { margin-block-start: 8px; }

.rank-dispatch-card h3,
.rank-dispatch-card p{ margin: 0; }
.rank-dispatch-card :is(h3, p) { margin: 0; }

.rank-dispatch-card h3 {
  color: #69412c;
  font-size: clamp(.85rem, 3.2vw, 1rem);
  line-height: 1.33;
}

.rank-dispatch-card p {
  color: #70533b;
  font-size: .78rem;
  line-height: 1.42;
}

.rank-dispatch-card .rank-dispatch-ranks {
  padding: 5px 7px;
  border: 1px solid #d9b991;
  border-radius: 7px;
  background: #f2e2c6;
  color: #783c29;
  font-size: clamp(.78rem, 3.1vw, .95rem);
  font-weight: 750;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.rank-dispatch-ranks bdi:last-child { color: #713824; font-size: 1.14em; }

#result-notice .directional-arrow,
.dispatch-results-dialog .directional-arrow{ display: inline-block; }
:is(#result-notice, .dispatch-results-dialog) .directional-arrow { display: inline-block; }

:root[dir="rtl"] #result-notice .directional-arrow,
:root[dir="rtl"] .dispatch-results-dialog .directional-arrow{ transform: scaleX(-1); }
:root[dir="rtl"] :is(#result-notice, .dispatch-results-dialog) .directional-arrow { transform: scaleX(-1); }

.rank-dispatch-time {
  display: block;
  color: #725640;
  font-size: .71rem;
  font-variant-numeric: tabular-nums;
}

.action-dispatch-card {
  --event-accent: #32634d;
  --event-frame: #bdcda8;
  --event-tint: #edf2e1;
  display: grid;
  gap: 9px;
  min-inline-size: 0;
  padding: clamp(11px, 3.4vw, 15px);
  border: 1px solid var(--event-frame);
  border-inline-start: 3px solid var(--event-accent);
  border-radius: 10px;
  background: #fff9e9;
  overflow-wrap: anywhere;
}

.action-dispatch-card.is-setback {
  --event-accent: #874932;
  --event-frame: #d9b395;
  --event-tint: #f5e6d6;
}

.action-dispatch-card header > span {
  color: var(--event-accent);
  font-size: .71rem;
  font-weight: 750;
}

.action-dispatch-card header h3,
.action-dispatch-card header p{ margin: 2px 0 0; }
.action-dispatch-card header :is(h3, p) { margin: 2px 0 0; }
.action-dispatch-card header h3 { color: var(--event-accent); font-size: 1.08rem; line-height: 1.25; }
.action-dispatch-card header p { color: #5c4d39; font-size: .81rem; }

.action-dispatch-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8.5rem), 1fr));
  gap: 6px;
}

.action-dispatch-metrics > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: baseline;
  gap: 3px 8px;
  padding: 7px 9px;
  border: 1px solid var(--event-frame);
  border-radius: 7px;
  background: var(--event-tint);
  color: var(--event-accent);
  font-size: .81rem;
}

.action-dispatch-metrics strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.action-dispatch-metrics small { grid-column: 1 / -1; color: #5c4d39; font-size: .72rem; }

.action-dispatch-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  color: #725640;
}

.action-dispatch-footer small { font-size: .71rem; }

#family-management { scroll-margin-block-start: calc(var(--family-sticky-offset) + 12px); }

.dispatch-results-dialog .modal-actions {
  position: sticky;
  inset-block-end: -12px;
  z-index: 1;
  flex-wrap: wrap;
  gap: 6px;
  margin-block-start: 10px;
  padding-block: 7px;
  border-block-start: 1px solid #dcc29b;
  background: #fff8e8;
}

.dispatch-results-dialog .modal-actions > .btn { min-block-size: 38px; }

@media (max-width: 560px) {
  .family-page-sticky #result-notice .dispatch-copy > small { display: none; }
  .family-page-sticky #result-notice .result-notice-actions { max-inline-size: min(43vw, 183px); }

  .family-page-sticky #result-notice:has(.result-notice-actions > :nth-child(2)) { flex-wrap: wrap; }

  .family-page-sticky #result-notice:has(.result-notice-actions > :nth-child(2)) .result-notice-actions {
    display: grid;
    flex: 1 0 100%;
    grid-template-columns: repeat(auto-fit, minmax(min(64px, 100%), 1fr));
    max-inline-size: 100%;
  }

  .family-page-sticky #result-notice .result-notice-actions:has(> :nth-child(4)) .btn.small {
    padding-inline: 3px;
  }
}

@media (max-height: 440px) {
  dialog.dispatch-results-dialog { padding-block: 10px; }
  .dispatch-results-dialog .modal-head { margin-block-end: 7px; padding-block-end: 5px; }
}

@media (prefers-reduced-motion: no-preference) {
  .family-page-sticky #result-notice .result-notice-icon {
    animation: dispatch-arrival 360ms ease-out both;
  }

  dialog.dispatch-results-dialog[open] .rank-dispatch-card:first-of-type,
dialog.dispatch-results-dialog[open] .action-dispatch-card:first-of-type{
    animation: dispatch-arrival 280ms ease-out both;
  }
dialog.dispatch-results-dialog[open] :is(.rank-dispatch-card, .action-dispatch-card):first-of-type {
    animation: dispatch-arrival 280ms ease-out both;
  }

  @keyframes dispatch-arrival {
    from { opacity: .68; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* The mailbag count sits in the kicker, so the notice stays one row. */
.dispatch-kicker-link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}
