/* Shell and global UI screen styles. */

/* Responsive start screen polish. */
#start-screen.start-screen {
  isolation: isolate;
  overflow: hidden;
  place-items: center;
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
}

#start-screen .start-shade {
  z-index: 0;
  background:
    linear-gradient(to bottom, rgba(16, 38, 52, .04) 0 42%, rgba(16, 34, 39, .14) 68%, rgba(18, 24, 22, .42) 100%);
  pointer-events: none;
}

#start-screen .start-logo {
  z-index: 2;
  top: calc(clamp(18px, 4.5dvh, 56px) + var(--safe-top));
  width: min(82vw, 640px);
  max-height: 30dvh;
  object-fit: contain;
}

#start-screen .start-actions {
  z-index: 3;
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(clamp(78px, 9dvh, 112px) + var(--safe-bottom));
  width: min(92vw, 440px);
  margin: 0 auto;
  padding: 18px 20px 16px;
  gap: 9px;
  transform: none;
  border-color: rgba(255, 255, 255, .55);
  border-radius: 22px;
  background: rgba(255, 244, 216, .84);
  box-shadow: 0 14px 34px rgba(28, 24, 16, .26);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#start-screen .start-kicker {
  font-size: .68rem;
  letter-spacing: .1em;
}

#start-screen .start-title {
  margin: 0;
  font-size: clamp(1.7rem, 5.2vw, 2.25rem);
  line-height: 1;
}

#start-screen .start-copy {
  max-width: 38ch;
  font-size: .9rem;
  line-height: 1.3;
}

#start-screen .start-player-summary {
  padding: 8px 10px;
  border-radius: 14px;
}

#start-screen .start-player-hint {
  margin-top: -1px;
  font-size: .9rem;
}

#start-screen .start-button-stack {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 0;
  margin-top: 1px;
}

#start-button {
  --button-width: 300px;
  width: min(100%, var(--button-width));
}

/* The options action is intentionally detached from the main CTA stack. */
#start-options-button {
  --button-width: 58px;
  --button-ratio: 1 / 1;
  position: fixed;
  z-index: 12;
  right: calc(18px + env(safe-area-inset-right, 0px));
  bottom: calc(18px + var(--safe-bottom));
  width: 58px;
  height: 58px;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .58);
  border-radius: 18px;
  background-color: rgba(31, 65, 79, .82) !important;
  background-image: url('../../../assets/runtime/ui/icons/icon_settings.webp') !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: 49px 49px !important;
  color: transparent;
  font-size: 0;
  line-height: 0;
  text-shadow: none;
  filter: drop-shadow(0 6px 9px rgba(19, 24, 22, .3));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#start-options-button:hover {
  filter: drop-shadow(0 8px 11px rgba(19, 24, 22, .34)) brightness(1.04);
}

#start-options-button:active {
  transform: translateY(2px) scale(.97);
}

#start-options-button:focus-visible,
#start-button:focus-visible,
#start-logout-button:focus-visible {
  outline: 3px solid rgba(255, 235, 139, .96);
  outline-offset: 3px;
}

#start-screen .start-logout-button {
  margin: -2px 0 0;
  min-height: 34px;
  padding-inline: 14px;
}

#start-screen .version-label {
  position: fixed;
  z-index: 5;
  left: calc(16px + env(safe-area-inset-left, 0px));
  bottom: calc(18px + var(--safe-bottom));
  margin: 0;
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: 999px;
  background: rgba(26, 43, 46, .36);
  color: rgba(255, 255, 255, .9);
  font-size: .68rem;
  font-weight: 800;
  opacity: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .35);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

/* Desktop: center the actual menu below the brand instead of parking it at the edge. */
@media (min-width: 900px) and (min-height: 620px) {
  #start-screen .start-logo {
    top: calc(clamp(26px, 4dvh, 48px) + var(--safe-top));
    width: min(44vw, 650px);
    max-height: 29dvh;
  }

  #start-screen .start-actions {
    top: 46dvh;
    bottom: auto;
    width: min(440px, 42vw);
    padding: 19px 26px 18px;
    gap: 9px;
    transform: none;
    background: rgba(255, 244, 216, .86);
  }

  #start-screen .start-title {
    font-size: clamp(1.95rem, 2.5vw, 2.45rem);
  }

  #start-screen .start-copy {
    font-size: .93rem;
  }

  #start-button {
    --button-width: 310px;
  }

  #start-options-button {
    right: calc(24px + env(safe-area-inset-right, 0px));
    bottom: calc(24px + var(--safe-bottom));
    width: 62px;
    height: 62px;
    background-size: 52px 52px !important;
  }

  #start-screen .version-label {
    left: calc(22px + env(safe-area-inset-left, 0px));
    bottom: calc(24px + var(--safe-bottom));
  }
}

/* Phones and narrow tablets keep the scenic center visible and the controls thumb friendly. */
@media (max-width: 699px) {
  #start-screen .start-logo {
    top: calc(clamp(18px, 3.7dvh, 38px) + var(--safe-top));
    width: min(88vw, 470px);
    max-height: 24dvh;
  }

  #start-screen .start-actions {
    bottom: calc(76px + var(--safe-bottom));
    width: min(92vw, 430px);
    padding: 15px 15px 13px;
    gap: 7px;
    border-radius: 20px;
  }

  #start-screen .start-kicker {
    display: none;
  }

  #start-screen .start-title {
    font-size: clamp(1.55rem, 7vw, 2rem);
  }

  #start-screen .start-copy {
    max-width: 35ch;
    font-size: .84rem;
    line-height: 1.26;
  }

  #start-screen .start-player-summary {
    gap: 8px;
    padding: 7px 9px;
  }

  #start-screen .start-player-summary .avatar-stack-small {
    width: 42px;
    height: 42px;
  }

  #start-screen .start-player-summary strong {
    font-size: .9rem;
  }

  #start-screen .start-player-summary small {
    font-size: .72rem;
  }

  #start-button {
    --button-width: 280px;
    font-size: 1.08rem;
  }

  #start-options-button {
    right: calc(12px + env(safe-area-inset-right, 0px));
    bottom: calc(12px + var(--safe-bottom));
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background-size: 44px 44px !important;
  }

  #start-screen .version-label {
    left: calc(12px + env(safe-area-inset-left, 0px));
    bottom: calc(15px + var(--safe-bottom));
  }
}

/* Very short screens must stay fully usable without browser page scrolling. */
@media (max-height: 690px) and (orientation: portrait) {
  #start-screen .start-logo {
    top: calc(12px + var(--safe-top));
    width: min(73vw, 390px);
    max-height: 21dvh;
  }

  #start-screen .start-actions {
    bottom: calc(70px + var(--safe-bottom));
    padding-block: 12px 10px;
    gap: 5px;
  }

  #start-screen .start-copy {
    display: none;
  }

  #start-screen .start-player-summary {
    padding-block: 5px;
  }

  #start-screen .start-player-hint {
    font-size: .82rem;
  }

  #start-button {
    --button-width: 248px;
  }
}

/* Landscape phones get a compact centered menu rather than a stretched portrait layout. */
@media (max-height: 620px) and (orientation: landscape) {
  #start-screen .start-logo {
    top: calc(8px + var(--safe-top));
    width: min(38vw, 360px);
    max-height: 31dvh;
  }

  #start-screen .start-actions {
    top: 34dvh;
    bottom: auto;
    width: min(430px, 56vw);
    padding: 11px 15px 10px;
    gap: 5px;
    transform: none;
  }

  #start-screen .start-kicker,
  #start-screen .start-copy {
    display: none;
  }

  #start-screen .start-title {
    font-size: clamp(1.35rem, 4vw, 1.8rem);
  }

  #start-screen .start-player-summary {
    padding: 5px 8px;
  }

  #start-screen .start-player-summary .avatar-stack-small {
    width: 38px;
    height: 38px;
  }

  #start-screen .start-player-hint {
    display: none;
  }

  #start-button {
    --button-width: 230px;
    font-size: .96rem;
  }

  #start-options-button {
    right: calc(10px + env(safe-area-inset-right, 0px));
    bottom: calc(10px + var(--safe-bottom));
    width: 48px;
    height: 48px;
    border-radius: 15px;
    background-size: 40px 40px !important;
  }

  #start-screen .version-label {
    left: calc(10px + env(safe-area-inset-left, 0px));
    bottom: calc(12px + var(--safe-bottom));
    padding: 4px 8px;
  }
}

/* Global resource help, modal ergonomics and responsive shell rules. */

/* Shared discoverable help language. Other segments can reuse .context-help-button. */
.context-help-button {
  inline-size: 34px;
  block-size: 34px;
  min-inline-size: 34px;
  border: 2px solid rgba(244, 195, 76, .82);
  border-radius: 50%;
  background: rgba(35, 76, 99, .92);
  color: #fff7d2;
  display: inline-grid;
  place-items: center;
  font: 900 .9rem/1 "Nunito", sans-serif;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .2);
}

.context-help-button:hover {
  filter: brightness(1.08);
}

.context-help-button:active {
  transform: translateY(1px) scale(.97);
}

.context-help-button:focus-visible,
.game-topbar .profile-chip:focus-visible,
.game-topbar .icon-button:focus-visible,
.game-topbar .resource-chip.shell-help-trigger:focus-visible,
.game-footer .nav-button:focus-visible,
.modal-root .modal-close:focus-visible,
.modal-root .ef-button:focus-visible,
.modal-root .text-button:focus-visible,
.modal-root input:focus-visible {
  outline: 3px solid #fff0a5;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(43, 78, 91, .72);
}

/* Resource chips are coherent help triggers, not passive counters. */
.game-topbar .resource-strip {
  min-width: 0;
}

.game-topbar .resource-chip.shell-help-trigger {
  position: relative;
  cursor: help;
  user-select: none;
  transition: transform .1s ease, filter .1s ease, box-shadow .1s ease;
  font-variant-numeric: tabular-nums;
}

.game-topbar .resource-chip.shell-help-trigger > span {
  min-width: 0;
  white-space: nowrap;
}

.game-topbar .resource-chip.shell-help-trigger::after {
  content: "?";
  position: absolute;
  top: -5px;
  right: -4px;
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.75);
  border-radius: 50%;
  background: #315f7a;
  color: white;
  font: 900 9px/1 "Nunito", sans-serif;
  box-shadow: 0 2px 4px rgba(0,0,0,.22);
  pointer-events: none;
}

.game-topbar .resource-chip.shell-help-trigger:hover {
  filter: brightness(1.08);
  box-shadow: 0 5px 11px rgba(0,0,0,.23);
}

.game-topbar .resource-chip.shell-help-trigger:active {
  transform: translateY(1px) scale(.975);
}

/* Keep desktop chrome grouped rather than pinning controls to ultrawide edges. */
@media (min-width: 701px) {
  .game-topbar {
    grid-template-columns: minmax(230px, 1fr) auto minmax(50px, 1fr);
    padding-inline: max(18px, calc((100vw - 1180px) / 2));
  }

  .game-topbar .profile-chip {
    justify-self: start;
  }

  .game-topbar .resource-strip {
    justify-self: center;
  }

  #game-options-button {
    justify-self: end;
  }
}

/* Modal behavior is shared across profile, options, development and help. */
.shell-modal-open {
  overscroll-behavior: none;
}

.modal-root .modal-backdrop {
  overscroll-behavior: contain;
}

.modal-root .modal-panel {
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scroll-padding-top: 52px;
}

.modal-root .modal-panel > .modal-close {
  position: sticky;
  z-index: 12;
  top: 0;
  right: auto;
  float: right;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  margin: -9px -5px 2px 8px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,.75);
  box-shadow: 0 3px 8px rgba(73,31,23,.28);
}

.modal-root .modal-panel > .modal-close:hover {
  filter: brightness(1.06);
}

.modal-root .modal-panel > .modal-close:active {
  transform: scale(.95);
}

/* Compact resource explanation dialog. */
.modal-root .shell-help-modal {
  width: min(92vw, 500px);
  max-height: min(86dvh, 620px);
  overflow: auto;
  padding: 18px 18px 16px;
}

.shell-help-heading {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding-right: 42px;
  margin-bottom: 8px;
}

.shell-help-heading > img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  filter: drop-shadow(0 4px 5px rgba(75, 49, 28, .2));
}

.shell-help-heading h2 {
  margin: 0 !important;
  line-height: 1;
}

.shell-help-eyebrow {
  display: block;
  margin-bottom: 1px;
  color: #986239;
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.shell-help-current {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(53, 101, 126, .1);
  color: #315f75;
  font-size: .78rem;
  font-weight: 800;
}

.shell-help-intro {
  margin: 8px 0;
  font-weight: 800;
  line-height: 1.35;
}

.shell-help-list {
  margin: 8px 0 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 7px;
  line-height: 1.34;
  font-size: .92rem;
}

.shell-help-list li::marker {
  color: #5e8a42;
}

.shell-help-note {
  margin: 12px 0 0;
  padding: 8px 10px;
  border: 1px solid rgba(111,65,35,.14);
  border-radius: 12px;
  background: rgba(255,255,255,.48);
  font-size: .8rem;
  line-height: 1.25;
}

/* Options only expose settings that have a real observable effect. */
.modal-root .shell-options-modal {
  width: min(92vw, 600px) !important;
  max-height: min(90dvh, 620px) !important;
}

.shell-options-list {
  gap: 7px;
}

.shell-options-list .option-row {
  cursor: pointer;
}

.shell-options-list .option-row > div {
  min-width: 0;
}

.shell-options-list .option-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  accent-color: #397d69;
  cursor: pointer;
}

.shell-options-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Navigation semantics and hit feedback. */
.game-footer .nav-button {
  transition: transform .1s ease, filter .1s ease, box-shadow .1s ease;
}

.game-footer .nav-button:hover {
  filter: brightness(1.06);
}

.game-footer .nav-button:active {
  transform: translateY(1px) scale(.98);
}

.game-footer .nav-button[aria-current="page"] {
  filter: saturate(1.08);
}

/* Standard mobile portrait shell. */
@media (max-width: 700px) {
  .game-topbar {
    grid-template-columns: minmax(42px, 100px) minmax(0, 1fr) 40px;
    gap: 4px;
    padding-inline: 6px;
  }

  .game-topbar .resource-strip {
    width: min(100%, 270px);
    justify-self: center;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .game-topbar .resource-chip,
  body.compact-ui .game-topbar .resource-chip {
    width: 100%;
    min-width: 0;
    height: 34px;
    padding: 2px 5px 2px 2px;
    justify-content: center;
    gap: 2px;
    font-size: clamp(.61rem, 2.5vw, .7rem);
  }

  .game-topbar .resource-chip img,
  body.compact-ui .game-topbar .resource-chip img {
    width: 23px;
    height: 23px;
    flex: 0 0 23px;
  }

  .game-topbar .resource-chip.shell-help-trigger::after {
    top: -4px;
    right: -3px;
    width: 13px;
    height: 13px;
    font-size: 8px;
  }

  #game-options-button {
    width: 40px;
    height: 40px;
  }

  .game-footer .nav-button {
    min-height: 48px;
  }

  .modal-root .modal-panel,
  .modal-root .modal-panel.modal-wide {
    scrollbar-gutter: auto;
    scroll-padding-top: 48px;
  }

  .modal-root .modal-panel > .modal-close {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    margin: -7px -3px 1px 7px;
  }

  .modal-root .shell-help-modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: min(88dvh, 640px) !important;
    padding: 13px 12px 11px !important;
  }

  .shell-help-heading {
    grid-template-columns: 48px minmax(0,1fr);
    gap: 9px;
    padding-right: 35px;
    margin-bottom: 5px;
  }

  .shell-help-heading > img {
    width: 46px;
    height: 46px;
  }

  .shell-help-eyebrow {
    font-size: .58rem;
  }

  .shell-help-current {
    margin-top: 3px;
    padding: 2px 7px;
    font-size: .68rem;
  }

  .shell-help-intro {
    margin: 5px 0;
    font-size: .8rem;
  }

  .shell-help-list {
    margin-top: 5px;
    gap: 5px;
    font-size: .75rem;
    line-height: 1.25;
  }

  .shell-help-note {
    margin-top: 8px;
    padding: 6px 8px;
    font-size: .69rem;
  }

  .modal-root .shell-options-modal {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 10px) !important;
  }

  .shell-options-list .option-row {
    min-height: 46px;
  }

  .shell-options-list .option-row input[type="checkbox"] {
    width: 25px;
    height: 25px;
  }
}

/* Small phones keep the player's identity compact so resources remain legible. */
@media (max-width: 360px) {
  .game-topbar {
    grid-template-columns: 42px minmax(0, 1fr) 36px;
  }

  .game-topbar .profile-chip {
    width: 40px;
    padding-right: 2px;
  }

  .game-topbar .profile-text {
    display: none;
  }

  .game-topbar .resource-strip {
    width: 100%;
    gap: 3px;
  }

  .game-topbar .resource-chip,
  body.compact-ui .game-topbar .resource-chip {
    font-size: .6rem;
    padding-inline: 1px 3px;
  }

  .game-topbar .resource-chip img,
  body.compact-ui .game-topbar .resource-chip img {
    width: 21px;
    height: 21px;
    flex-basis: 21px;
  }

  #game-options-button {
    width: 36px;
    height: 36px;
  }

  .game-footer .nav-button {
    font-size: .5rem;
  }
}

/* Short portrait devices preserve primary controls without page scrolling. */
@media (max-height: 650px) and (orientation: portrait) {
  .game-topbar .resource-chip,
  body.compact-ui .game-topbar .resource-chip {
    height: 32px;
  }

  #game-options-button {
    width: 36px;
    height: 36px;
  }

  .modal-root .shell-help-modal {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 8px) !important;
  }

  .shell-help-heading > img {
    width: 42px;
    height: 42px;
  }

  .shell-help-list {
    gap: 4px;
  }
}

/* Short landscape receives a dedicated compact shell rather than portrait scaling. */
@media (orientation: landscape) and (max-height: 520px) {
  .game-topbar {
    grid-template-columns: minmax(92px, 120px) minmax(0, 1fr) 36px;
    gap: 5px;
    padding-inline: max(6px, env(safe-area-inset-left, 0px)) max(6px, env(safe-area-inset-right, 0px));
  }

  .game-topbar .profile-chip {
    justify-self: start;
  }

  .game-topbar .resource-strip {
    width: min(100%, 300px);
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 4px;
    justify-self: center;
  }

  .game-topbar .resource-chip,
  body.compact-ui .game-topbar .resource-chip {
    width: 100%;
    height: 32px;
    min-width: 0;
    font-size: .64rem;
  }

  #game-options-button {
    width: 34px;
    height: 34px;
    justify-self: end;
  }

  .modal-root .modal-backdrop {
    place-items: center;
    padding: calc(4px + var(--safe-top)) calc(7px + env(safe-area-inset-right, 0px)) calc(4px + var(--safe-bottom)) calc(7px + env(safe-area-inset-left, 0px));
  }

  .modal-root .modal-panel,
  .modal-root .modal-panel.modal-wide,
  .modal-root .options-modal,
  .modal-root .shell-help-modal {
    width: min(94vw, 760px) !important;
    max-width: min(94vw, 760px) !important;
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 8px) !important;
    border-radius: 16px !important;
    padding: 9px 12px 8px !important;
  }

  .modal-root .modal-panel > .modal-close {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    margin: -4px -5px 1px 8px;
  }

  .shell-help-heading {
    grid-template-columns: 42px minmax(0,1fr);
    gap: 8px;
    margin-bottom: 2px;
  }

  .shell-help-heading > img {
    width: 40px;
    height: 40px;
  }

  .shell-help-intro {
    margin: 2px 0 3px;
    font-size: .72rem;
  }

  .shell-help-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 18px;
    margin: 4px 0 0;
    padding-left: 1rem;
    font-size: .65rem;
    line-height: 1.18;
  }

  .shell-help-note {
    margin-top: 5px;
    padding: 5px 7px;
    font-size: .62rem;
  }

  .modal-root .shell-options-modal {
    width: min(90vw, 650px) !important;
  }

  .shell-options-list {
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 5px 8px;
  }

  .shell-options-list .option-group-title {
    grid-column: 1 / -1;
    margin-top: 0;
  }

  .shell-options-list .option-row {
    min-height: 42px;
  }

  .shell-options-actions,
  .shell-options-list .option-logout {
    grid-column: 1 / -1;
  }

  .shell-options-actions {
    grid-template-columns: repeat(4, minmax(0,1fr));
  }

  .shell-options-actions .ef-button {
    padding-inline: 8px;
    font-size: .62rem;
  }
}

/* High text pressure keeps chrome from forcing horizontal overflow. */
@media (max-width: 700px) {
  .game-topbar,
  .game-footer,
  .modal-root .modal-panel {
    min-width: 0;
  }

  .profile-text,
  .resource-chip > span,
  .nav-button > span,
  .option-row > div {
    min-width: 0;
  }

  .nav-button > span {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-topbar .resource-chip.shell-help-trigger,
  .game-footer .nav-button,
  .context-help-button {
    transition: none;
  }
}

/* Viewport pressure fixes. Shell owns viewport ergonomics, not feature logic. */
@media (max-width: 700px) and (orientation: portrait) {
  .merge-task button {
    min-height: 28px;
    padding-block: 4px;
  }

  .merge-supply-button,
  .orders-card .text-button,
  .inventory-tab {
    min-height: 32px;
  }

  .shell-options-list .option-logout {
    min-height: 36px;
    padding: 7px 12px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  body[data-game-screen="orders"] .orders-card > .scene-subtitle {
    display: none;
  }

  body[data-game-screen="orders"] .orders-card .content-card {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 72px;
    grid-template-rows: repeat(3, minmax(0, auto));
    gap: 1px 4px;
    align-items: center;
    min-height: 0;
    padding: 4px 5px;
    text-align: left;
  }

  body[data-game-screen="orders"] .orders-card .content-card > img {
    grid-column: 1;
    grid-row: 1 / span 3;
    width: 38px;
    height: 48px;
    max-height: 48px;
    object-fit: contain;
  }

  body[data-game-screen="orders"] .orders-card .content-card > h3 {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-game-screen="orders"] .orders-card .content-card > p {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-game-screen="orders"] .orders-card .content-card .status-pill {
    grid-column: 2;
    grid-row: 3;
  }

  body[data-game-screen="orders"] .orders-card .content-card .card-action {
    grid-column: 3;
    grid-row: 1 / span 3;
    align-self: center;
    min-width: 0;
    margin: 0;
  }

  body[data-game-screen="orders"] .orders-card .content-card .ef-button {
    width: 72px;
    max-width: 72px;
    height: 31px;
    min-height: 31px;
    aspect-ratio: auto;
    padding: 3px 7px 4px;
    font-size: .55rem;
    background-size: 100% 100%;
  }

  .merge-task button {
    min-height: 26px;
  }
}

/* Avoid expensive glass blur on touch GPUs while preserving opacity and borders. */
@media (hover: none) and (pointer: coarse) {
  #start-options-button,
  #start-screen .version-label {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* Keep the complete desktop welcome card safely above the viewport edge. */
@media (min-width: 900px) and (min-height: 620px) {
  #start-screen .start-actions {
    top: 34dvh;
    bottom: auto;
    max-height: calc(100dvh - 34dvh - 24px);
    overflow-y: auto;
    scrollbar-width: none;
  }

  #start-screen .start-actions::-webkit-scrollbar {
    display: none;
  }
}
