:root { --artifact-bottom: max(8px, env(safe-area-inset-bottom)); }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#game,
#game.auto-admin {
  position: relative;
  display: block;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

#field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#desk,
#game.auto-admin #desk {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: block;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  pointer-events: none;
}

.desk-section {
  display: block;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background: transparent;
  pointer-events: auto;
}

.artifact-toggle { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.artifact-panel { transition: opacity .18s ease, transform .22s ease; }

/* Claims clipboard */
.docket-section,
#game.auto-admin .docket-section {
  position: absolute;
  z-index: 6;
  left: clamp(9px, 1.5vw, 26px);
  bottom: var(--artifact-bottom);
  width: 148px;
  height: 105px;
}

.clipboard-toggle {
  position: absolute;
  z-index: 3;
  left: 0;
  bottom: -20px;
  width: 142px;
  height: 112px;
  padding: 24px 15px 13px;
  border: 3px solid var(--ink);
  border-radius: 7px 7px 12px 12px;
  background: #e77922;
  box-shadow: 7px 8px 0 rgba(35, 27, 24, .34);
  transform: rotate(-4deg);
  transform-origin: bottom left;
  transition: transform .2s ease, filter .2s ease;
}

.clipboard-toggle::before {
  content: "";
  position: absolute;
  inset: 15px 10px 9px;
  border: 2px solid rgba(59,46,42,.45);
  background: linear-gradient(165deg, #fff 0 78%, #e7edf0 78% 88%, #fff 88%);
  box-shadow: 0 2px 0 rgba(59,46,42,.2);
}

.clipboard-clip {
  position: absolute;
  z-index: 3;
  left: 34px;
  top: -11px;
  width: 74px;
  height: 31px;
  border: 3px solid var(--ink);
  border-radius: 9px 9px 4px 4px;
  background: #7894a4;
  box-shadow: inset 0 -8px 0 #5e7886;
}

.desk-level-status {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 3px;
  max-width: 108px;
  text-align: left;
  white-space: normal;
  pointer-events: none;
}

.desk-level-status span {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .72;
}

.desk-level-status strong { font: 700 11px/1.05 var(--display); }

.artifact-count {
  position: absolute;
  z-index: 5;
  top: -14px;
  right: -12px;
  display: grid;
  place-items: center;
  min-width: 31px;
  height: 31px;
  padding: 0 7px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--claim);
  color: #fff;
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 13px;
  font-weight: 900;
}

.docket-section.has-claims .clipboard-toggle { filter: drop-shadow(0 0 7px rgba(255,229,138,.8)); }
.docket-section.is-open .clipboard-toggle { transform: translateY(-13px) rotate(-1deg) scale(1.03); }

.clipboard-sheet {
  position: absolute;
  z-index: 2;
  left: 0;
  bottom: 76px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(520px, calc(100vw - 30px));
  height: min(430px, calc(100dvh - 145px));
  padding: 20px 18px 17px;
  border: 3px solid var(--ink);
  border-radius: 5px 5px 13px 9px;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(0deg, transparent 0 25px, rgba(59,46,42,.04) 26px);
  box-shadow: 10px 12px 0 rgba(35,27,24,.42);
  opacity: 0;
  transform: translateY(28px) rotate(-2deg) scale(.94);
  transform-origin: bottom left;
  pointer-events: none;
}

.clipboard-sheet::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -17px;
  width: 116px;
  height: 31px;
  border: 3px solid var(--ink);
  border-radius: 9px 9px 4px 4px;
  background: #7894a4;
  box-shadow: inset 0 -8px 0 #5e7886;
  transform: translateX(-50%);
}

.docket-section.is-open .clipboard-sheet {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
  .docket-section:hover .clipboard-toggle { transform: translateY(-13px) rotate(-1deg) scale(1.03); }
  .docket-section:hover .clipboard-sheet { opacity: 1; transform: none; pointer-events: auto; }
}

.clipboard-sheet .desk-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0 9px;
  border-bottom: 3px double var(--ink);
}

.clipboard-sheet .desk-heading > div { display: grid; }
.clipboard-sheet .desk-heading strong { font: 700 21px/1.05 var(--display); }
.folder-count { color: var(--claim); font-size: 11px; font-weight: 900; }

.clipboard-sheet .card-strip {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 9px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 11px 5px 14px 2px;
  scrollbar-color: var(--ink) transparent;
  scrollbar-width: thin;
}

.clipboard-sheet .claim-card,
.clipboard-sheet .empty-card {
  width: 100%;
  min-height: 0;
  margin: 0;
  border: 2px solid var(--ink);
  background: var(--paper-light);
  box-shadow: 3px 3px 0 rgba(59,46,42,.18);
}

.clipboard-sheet .claim-card {
  position: relative;
  display: grid;
  gap: 5px;
  padding: 10px;
  overflow: hidden;
  cursor: pointer;
}

.clipboard-sheet .claim-card:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 rgba(59,46,42,.22); }
.clipboard-sheet .claim-card.selected { outline: 4px solid var(--violet); outline-offset: -4px; }
.clipboard-sheet .claim-card header { display: flex; justify-content: space-between; gap: 8px; }
.clipboard-sheet .claim-card strong { font: 700 15px/1.1 var(--display); }
.clipboard-sheet .claim-card p { margin: 0; font-size: 12px; }
.clipboard-sheet .empty-card { display: grid; place-items: center; min-height: 100px; padding: 18px; color: #6c5c50; font-style: italic; }

/* Compensation stamp rack */
.satchel-section,
#game.auto-admin .satchel-section {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
}

#satchel,
.satchel-groups { display: contents; }

.claims-office {
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: -19px;
  width: min(820px, 62vw);
  height: 130px;
  padding: 0 16px;
  overflow: visible;
  border: 3px solid var(--ink);
  border-bottom: 0;
  border-radius: 28px 28px 0 0;
  background: linear-gradient(#76513f 0 28%, #4e352c 28% 100%);
  box-shadow: 8px -4px 0 rgba(35,27,24,.28), inset 0 8px 0 rgba(255,255,255,.08);
  transform: translateX(-50%);
  transition: opacity .14s ease;
  pointer-events: auto;
}

.claims-office.entity-behind { opacity: .1; }
.claims-office.entity-behind:hover,
.claims-office.entity-behind:focus-within { opacity: .92; }

.claims-office > header {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 8px);
  display: grid;
  min-width: 178px;
  padding: 5px 11px 6px;
  border: 2px solid var(--ink);
  border-radius: 14px 14px 3px 3px;
  background: var(--paper);
  box-shadow: 3px -3px 0 rgba(35,27,24,.18);
  text-align: center;
  transform: translateX(-50%);
}

.claims-office > header .eyebrow { font-size: 8px; }
.claims-office > header strong { font: 700 12px/1 var(--display); }

.claims-office .satchel-group-list {
  position: relative;
  display: flex;
  align-items: end;
  gap: 3px;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 8px 7px 19px;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
}

.claims-office .satchel-group-list::-webkit-scrollbar { display: none; }
.claims-office .group-empty {
  align-self: end;
  width: 100%;
  margin: 0 auto 18px;
  padding: 8px 12px;
  border: 2px solid rgba(59,46,42,.7);
  background: rgba(239,227,200,.9);
  color: var(--ink);
  font-size: 11px;
  font-style: italic;
  text-align: center;
}

.claims-office .tool-card {
  --stamp-wood: #8d514e;
  position: relative;
  display: block;
  flex: 0 0 62px;
  width: 62px;
  height: 104px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease;
}

.claims-office .tool-card[data-kind="deferral"] { --stamp-wood: #667f96; }
.claims-office .tool-card[data-kind="reduction"] { --stamp-wood: #8d514e; }
.claims-office .tool-card[data-kind="denial"] { --stamp-wood: #713b3e; }
.claims-office .tool-card[data-kind="field"],
.claims-office .tool-card[data-kind="sweep"] { --stamp-wood: #536f46; }

.claims-office .tool-card::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 0;
  width: 37px;
  height: 78px;
  border: 3px solid var(--ink);
  border-radius: 48% 48% 34% 34% / 30% 30% 14% 14%;
  background:
    repeating-radial-gradient(ellipse at 50% 38%, transparent 0 5px, rgba(59,46,42,.32) 6px 8px, transparent 9px 12px),
    var(--stamp-wood);
  box-shadow: inset 4px 0 0 rgba(255,255,255,.12), inset -5px 0 0 rgba(59,46,42,.18);
  transform: translateX(-50%);
}

.claims-office .tool-card::after {
  content: attr(data-mark);
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 3px;
  display: grid;
  place-items: center;
  width: 59px;
  height: 25px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: #d7a737;
  color: #5b3a20;
  box-shadow: inset 0 0 0 3px #f2cf69;
  font: 900 9px/1 var(--display);
  transform: translateX(-50%);
}

.claims-office .tool-emblem { display: none; }
.claims-office .tool-card:hover,
.claims-office .tool-card:focus-visible { z-index: 12; transform: translateY(-9px); }

.claims-office .tool-card.valid-for-claim {
  outline: 0;
  background: transparent;
  filter: drop-shadow(0 0 6px #ffe58a) drop-shadow(0 0 12px rgba(255,207,65,.76));
  animation: stamp-ready .8s ease-in-out infinite alternate;
}

.claims-office .tool-card.best-for-claim { filter: drop-shadow(0 0 8px #fff1a9) drop-shadow(0 0 18px #f4b51c); }

@keyframes stamp-ready { to { transform: translateY(-7px); } }

.tool-copy { display: grid; gap: 5px; }

.stamp-readout {
  position: absolute;
  z-index: 40;
  left: 50%;
  bottom: calc(100% + 34px);
  display: grid;
  gap: 3px;
  width: min(300px, 72vw);
  padding: 9px 11px;
  border: 2px solid var(--ink);
  background: var(--paper-light);
  box-shadow: 5px 5px 0 rgba(35,27,24,.35);
  text-align: center;
  transform: translateX(-50%) rotate(-1deg);
  pointer-events: none;
}

.stamp-readout[hidden] { display: none; }
.stamp-readout strong { font: 700 14px/1.05 var(--display); }
.stamp-readout span { font-size: 10px; font-weight: 800; color: #446a2f; }

.claims-office .tool-copy {
  display: none;
}

.tool-copy-heading { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.tool-copy-heading strong { font: 700 14px/1.1 var(--display); }
.tool-kind { padding: 2px 5px; background: #e6d6b5; font-size: 9px; font-weight: 900; text-transform: uppercase; }
.tool-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 7px; font-size: 9px; font-weight: 900; text-transform: uppercase; }
.tool-meta [data-tool-availability] { color: var(--violet); }
.tool-meta [data-tool-efficiency] { color: #446a2f; }
.tool-description { font-size: 11px; line-height: 1.2; }

/* Field-order scroll */
.field-orders {
  position: absolute;
  z-index: 5;
  right: clamp(9px, 1.5vw, 26px);
  bottom: var(--artifact-bottom);
  width: 160px;
  height: 78px;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  transition: width .22s ease, height .22s ease;
  pointer-events: auto;
}

.scroll-toggle {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  width: 160px;
  height: 66px;
  padding: 8px 10px;
  border: 3px solid var(--ink);
  border-radius: 10px 4px 10px 4px;
  background: #f1c887;
  box-shadow: 7px 7px 0 rgba(35,27,24,.36), inset 0 0 0 4px rgba(255,236,190,.56);
  text-align: left;
  transition: transform .18s ease;
}

.scroll-toggle::before,
.scroll-toggle::after {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  height: 9px;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: #b9784b;
}

.scroll-toggle::before { top: -7px; }
.scroll-toggle::after { bottom: -7px; }
.scroll-toggle > span:last-child { display: grid; }
.scroll-toggle strong { font: 700 14px/1 var(--display); }
.scroll-toggle small { font-size: 9px; font-weight: 900; }
.scroll-toggle:hover { transform: translateY(-5px) rotate(-1deg); }

.scroll-symbol { position: relative; width: 35px; height: 38px; transform: rotate(-24deg); }
.scroll-symbol::before {
  content: "";
  position: absolute;
  left: 11px;
  top: -2px;
  width: 15px;
  height: 35px;
  border: 2px solid var(--ink);
  border-radius: 85% 20% 85% 20%;
  background: linear-gradient(90deg, #eda864 0 45%, #c87846 47% 55%, #f3bd7c 57%);
}
.scroll-symbol::after { content: ""; position: absolute; left: 17px; top: 17px; width: 3px; height: 26px; background: var(--ink); }

.scroll-sheet {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 54px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(440px, calc(100vw - 30px));
  height: min(420px, calc(100dvh - 145px));
  padding: 21px 22px 25px;
  border: 3px solid var(--ink);
  border-radius: 9px 3px 12px 5px;
  background: repeating-linear-gradient(0deg, transparent 0 31px, rgba(139,82,43,.12) 32px), #f5d49f;
  box-shadow: 10px 10px 0 rgba(35,27,24,.4), inset 0 0 0 5px rgba(255,239,196,.5);
  opacity: 0;
  transform: translateY(28px) scale(.92);
  transform-origin: bottom right;
  pointer-events: none;
}

.field-orders.is-open .scroll-sheet { opacity: 1; transform: none; pointer-events: auto; }
.field-orders.is-open .scroll-toggle { transform: translateY(-4px); }
.scroll-sheet > header { display: grid; gap: 2px; padding-bottom: 9px; border-bottom: 3px double var(--ink); }
.scroll-sheet > header strong { font: 700 21px/1 var(--display); }
.scroll-sheet > header small { font-size: 10px; font-weight: 800; }

.field-orders .satchel-group-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
  padding: 11px 5px 13px 2px;
  scrollbar-color: var(--ink) transparent;
  scrollbar-width: thin;
}

.field-orders .tool-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 74px;
  margin: 0;
  padding: 9px;
  border: 2px solid var(--ink);
  border-left: 7px solid #6e9b4e;
  background: rgba(251,247,238,.82);
  box-shadow: 3px 3px 0 rgba(59,46,42,.18);
  text-align: left;
  cursor: pointer;
}

.field-orders .tool-card:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 rgba(59,46,42,.2); }
.field-orders .tool-card:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.field-orders .tool-emblem { display: grid; place-items: center; width: 38px; height: 38px; border: 2px solid var(--ink); border-radius: 50%; background: #c8d8a1; }
.field-orders .tool-emblem::before { content: "↝"; font: 900 23px/1 var(--display); }

/* Automatic administration stays compact and receipt-like. */
#game.auto-admin .satchel-section { display: none; }
#game.auto-admin .docket-section {
  left: 14px;
  right: auto;
  bottom: 12px;
  width: min(780px, calc(100vw - 28px));
  height: 106px;
  padding: 0;
  gap: 0;
  pointer-events: none;
}

#game.auto-admin .clipboard-toggle { display: none; }
#game.auto-admin .clipboard-sheet {
  position: relative;
  left: auto;
  bottom: auto;
  display: grid;
  grid-template-columns: 165px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  padding: 9px 11px;
  opacity: 1;
  transform: none;
  pointer-events: none;
}

#game.auto-admin .clipboard-sheet::before { display: none; }
#game.auto-admin .desk-heading { align-items: center; padding: 0 11px 0 0; border-right: 2px solid var(--ink); border-bottom: 0; }
#game.auto-admin .desk-heading strong { font-size: 15px; }
#game.auto-admin .folder-count { display: none; }
#game.auto-admin .card-strip { display: flex; align-items: stretch; gap: 7px; padding: 2px 3px 4px 10px; overflow-x: auto; overflow-y: hidden; }
#game.auto-admin .card-strip > .empty-card { flex: 1 1 auto; min-height: 0; }
#game.auto-admin .claim-card.auto-receipt { flex: 0 1 430px; min-width: 245px; min-height: 0; margin: 0; padding: 7px 9px; }

/* Keep field messages above the physical desk objects. */
.claimant-popup,
.settlement-popup { bottom: 150px; }
.target-hint { bottom: 150px; }

@media (pointer: coarse), (max-width: 850px) {
  .docket-section { left: 8px; bottom: 4px; }
  .field-orders { right: 8px; bottom: 8px; }
  .claims-office { width: min(600px, 58vw); height: 118px; }
  .claims-office .tool-card { flex-basis: 56px; width: 56px; height: 96px; }
  .claims-office .tool-card::before { width: 34px; height: 70px; }
  .claims-office .tool-card::after { width: 53px; }
  .claims-office .tool-copy { width: min(230px, 70vw); }
  .touch-actions { bottom: 128px; }
  .claimant-popup,
  .settlement-popup,
  .target-hint { bottom: 138px; }
}

@media (orientation: portrait), (max-aspect-ratio: 1/1) {
  #game,
  #game.auto-admin { display: block; }
  #desk,
  #game.auto-admin #desk { display: block; border: 0; }
  .clipboard-sheet { width: calc(100vw - 16px); height: min(48dvh, 410px); }
  .scroll-sheet { width: calc(100vw - 16px); height: min(48dvh, 410px); }
  .claims-office { width: 55vw; min-width: 180px; }
  .claims-office > header { min-width: 148px; }
  .claims-office > header strong { font-size: 10px; }
  #game.auto-admin .docket-section { width: calc(100vw - 16px); left: 8px; }
}

@media (max-width: 480px) {
  .clipboard-toggle { width: 116px; height: 96px; padding: 22px 12px 10px; }
  .clipboard-clip { left: 27px; width: 62px; }
  .desk-level-status { max-width: 88px; }
  .desk-level-status #level-label { display: block; }
  .desk-level-status strong { font-size: 9px; }
  .artifact-count { right: -7px; }
  .clipboard-sheet { bottom: 62px; padding: 18px 12px 12px; }
  .clipboard-sheet .desk-heading strong { font-size: 17px; }
  .claims-office { bottom: -16px; width: 51vw; height: 105px; padding: 0 6px; }
  .claims-office .satchel-group-list { padding-inline: 2px; }
  .claims-office .tool-card { flex-basis: 49px; width: 49px; height: 88px; }
  .claims-office .tool-card::before { width: 30px; height: 64px; }
  .claims-office .tool-card::after { width: 47px; height: 22px; }
  .field-orders { width: 124px; height: 69px; }
  .scroll-toggle { width: 124px; height: 58px; grid-template-columns: 30px 1fr; padding: 6px 7px; }
  .scroll-toggle strong { font-size: 12px; }
  .scroll-symbol { transform: rotate(-24deg) scale(.8); transform-origin: center; }
  .scroll-sheet { bottom: 48px; padding: 18px 13px 20px; }
  #game.auto-admin .clipboard-sheet { grid-template-columns: minmax(0, 1fr); padding: 7px; }
  #game.auto-admin .desk-heading { display: none; }
}

@media (max-height: 600px) and (orientation: landscape) {
  #game,
  #game.auto-admin { display: block; }
  .clipboard-toggle { width: 120px; height: 88px; }
  .clipboard-sheet { height: calc(100dvh - 105px); bottom: 55px; }
  .claims-office { height: 99px; width: min(650px, 58vw); }
  .claims-office .tool-card { height: 84px; flex-basis: 49px; width: 49px; }
  .claims-office .tool-card::before { width: 29px; height: 60px; }
  .claims-office .tool-card::after { width: 46px; height: 21px; }
  .field-orders { width: 126px; height: 64px; }
  .scroll-toggle { width: 126px; height: 55px; }
  .scroll-sheet { height: calc(100dvh - 105px); bottom: 46px; }
  .touch-actions { bottom: 106px; }
  .claimant-popup,
  .settlement-popup,
  .target-hint { bottom: 112px; }
}

@media (prefers-reduced-motion: reduce) {
  .artifact-panel,
  .clipboard-toggle,
  .scroll-toggle,
  .claims-office,
  .claims-office .tool-card { transition: none; }
  .claims-office .tool-card.valid-for-claim { animation: none; transform: translateY(-5px); }
}
