.live .app:has(.field-ledger:not([hidden])) {
  max-width: 1900px;
  padding-inline: clamp(8px, 2vw, 26px);
}
.live .workspace:has(> .field-ledger:not([hidden])) {
  --ledger-map-height: max(360px, calc(100dvh - 190px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(306px, 26vw, 380px);
  gap: 16px;
}
.live .workspace:has(> .field-ledger:not([hidden])) > .board-panel {
  --map-height: var(--ledger-map-height);
  width: 100%;
  max-width: none;
  min-width: 0;
  margin: 0;
}
.live .workspace:has(.field-ledger:not([hidden])) .board-stage:not([data-layout="square"]) > #board {
  touch-action: pinch-zoom;
}
.live .board-stage > #match-controls:is([data-phase="waiting"], [data-phase="finished"]) {
  top: 50%;
  right: auto;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}
.live .board-stage #match-controls:is([data-phase="waiting"], [data-phase="finished"]) > #run-demo:not([hidden]) {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  min-width: min(268px, 70vw);
  height: 72px;
  padding: 0 20px;
  border: 1px solid #fff3d4;
  border-radius: 11px;
  font-size: clamp(20px, 2vw, 25px);
  letter-spacing: -.02em;
  background: linear-gradient(#ffffff35, transparent), #ffdd8d;
  color: #36200c;
  box-shadow: 0 0 0 6px #24231545, 0 9px 25px #28241186, inset 0 -3px #382a1724;
}
.live .board-stage #match-controls:is([data-phase="waiting"], [data-phase="finished"]) > #run-demo:not([hidden]):hover:not(:disabled) {
  background: #ffe8a9;
}
.live .board-stage #match-controls:is([data-phase="waiting"], [data-phase="finished"]) > #run-demo::before {
  content: '▶' / '';
  font-size: .66em;
}
.live .board-stage #match-controls:is([data-phase="waiting"], [data-phase="finished"]):has(> button:not([hidden])) > #match-error {
  position: absolute;
  top: calc(100% + 8px);
  width: max-content;
  padding: 5px 8px;
  border-radius: 4px;
  background: #fff4df;
}
@media (height <= 270px) {
  .live .board-stage #match-controls:is([data-phase="waiting"], [data-phase="finished"]) > #run-demo:not([hidden]) {
    height: 40px;
    font-size: 16px;
  }
}
.field-ledger {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: calc(var(--ledger-map-height) + 14px);
  overflow: auto;
  padding: 23px;
  color: #36291c;
  background: radial-gradient(ellipse at 100% 0%, #ffffff20, transparent 60%), #fbf1da;
  border: 1px solid #d4ba8f;
  border-radius: 13px;
  box-shadow: 0 6px 24px #32271713, inset 0 1px #fff4;
  font: 14px/1.4 system-ui, sans-serif;
}
.field-ledger[hidden], .field-ledger .economy-feedback:empty { display: none; }
.field-ledger .economy-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.ledger-toggle, .ledger-close { display: none; }
.field-ledger :is(h2,h3,p) { margin: 0; }
.field-ledger h2 { margin-top: 5px; font: 700 29px/1.08 Georgia, serif; }
.field-ledger h3 { font: 750 16px/1.2 system-ui, sans-serif; }
.field-ledger header { display: flex; align-items: center; gap: 13px; margin-bottom: 19px; }
.ledger-company {
  color: #6c542e;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.ledger-emblem {
  display: grid;
  place-content: center;
  flex: 0 0 44px;
  height: 48px;
  color: #fce2a0;
  background: #245987;
  clip-path: polygon(0 8%, 50% 0, 100% 8%, 100% 70%, 50% 100%, 0 70%);
  font: 26px/1 Georgia, serif;
}
.field-ledger[data-team="red"] .ledger-emblem { background: #a53b28; }
.ledger-funds {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 13px;
  border: 1px solid #d9c39d;
  border-radius: 8px;
  background: #fff8e9;
}
.ledger-balance {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 750;
  white-space: nowrap;
}
.ledger-balance strong { font-size: 27px; line-height: 1; font-variant-numeric: tabular-nums; }
.ledger-income { color: #66543a; font-size: 12px; white-space: nowrap; }
.ledger-coin {
  display: inline-block;
  width: .88em;
  aspect-ratio: 1;
  flex: none;
  border: 1px solid #805019;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 31%, #fff5b3 12%, #edc254 42%, #c98a32 75%);
  box-shadow: inset 0 0 0 1px #ffe590, 0 1px 1px #22170544;
}
.ledger-balance .ledger-coin { font-size: 23px; }
.ledger-shop { margin-top: 19px; }
.field-ledger .ledger-subtitle { color: #66543a; font-size: 12px; margin: 6px 0 12px; }
.ledger-recruits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.field-ledger button { cursor: pointer; text-align: left; }
.field-ledger button:disabled { cursor: default; filter: saturate(.7); }
.field-ledger button:hover:not(:disabled) { border-color: #8f7349; }
.ledger-recruit {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 6px;
  border: 1px solid #cfba92;
  border-radius: 8px;
  background: #fff8e9;
  box-shadow: 0 1px 1px #af85571a, inset 0 1px #fff;
}
.ledger-portrait {
  display: grid;
  place-items: center;
  height: 70px;
  border-radius: 5px;
  background: radial-gradient(ellipse at 50% 76%, #75844c8a 4%, transparent 57%), linear-gradient(150deg, #d7dfb1, #a8b783);
}
.ledger-portrait img { width: 70px; height: 70px; object-fit: contain; filter: drop-shadow(0 2px 1px #1e291b58); }
.field-ledger .ledger-recruit:has(> .ledger-recruited:not([hidden])) {
  border-color: #245987;
  box-shadow: 0 0 0 1px #245987, 0 0 0 3px #6a8aa951;
}
.ledger-recruit:has(> .ledger-recruited:not([hidden])) .ledger-portrait {
  background: radial-gradient(ellipse at 50% 77%, #3f6a988a 4%, transparent 60%), linear-gradient(150deg, #e2eaf0, #91b1cb);
}
.ledger-recruited {
  position: absolute;
  top: 53px;
  left: 10px;
  padding: 3px 7px;
  border: 1px solid #f5d490;
  border-radius: 4px;
  background: #245987;
  color: #fff0cc;
  font: 800 10px/1 system-ui, sans-serif;
  box-shadow: 0 2px 4px #24374f5e;
  white-space: nowrap;
  pointer-events: none;
}
.ledger-price {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #785019;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ledger-recruit .ledger-price {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid #ab8d5f;
  border-radius: 5px;
  background: #fff4d9;
  padding: 2px 5px;
  font-size: 11px;
}
.ledger-role { padding: 4px 3px 1px; }
.ledger-stats {
  min-height: 67px;
  padding: 3px 3px 1px;
  margin: 2px 0 0;
  border-top: 1px solid #dfcfb0;
  color: #624b33;
  font-size: 11px;
  line-height: 1.42;
  list-style: none;
}
.ledger-stats strong { color: #3e2f20; font-weight: 770; }
.field-ledger .ledger-note { margin-top: 8px; font-size: 11px; line-height: 1.35; color: #66543a; }
.ledger-reveal {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  border: 1px solid #d9c39d;
  border-radius: 8px;
  min-height: 37px;
  padding: 8px 10px;
  background: none;
  color: #66543a;
  font-size: 12px;
}
.ledger-eye { font-size: 15px; line-height: 1; }
.ledger-reveal .ledger-price { margin-left: auto; font-size: 14px; }
.ledger-price-time .ledger-coin { display: none; }
.field-ledger .economy-feedback { margin-top: 4px; font-size: 12px; }
.field-ledger .ledger-decoration {
  margin-top: auto;
  padding-top: 12px;
  color: #6c542e;
  opacity: .72;
  text-align: center;
  letter-spacing: .42em;
  font-size: 11px;
}
@media (max-width: 1050px) {
  .field-ledger { padding: 16px; }
}
@media (width >= 1120px), (width > 740px) and (height > 560px) {
  .live .app:has(.workspace > .field-ledger:not([hidden])) {
    display: grid;
    height: 100dvh;
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  .live .workspace:has(> .field-ledger:not([hidden])) {
    grid-row: 3;
    grid-template-rows: minmax(0, 1fr);
  }
  .live .workspace:has(> .field-ledger:not([hidden])) :is(.board-panel, .board-stage) {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
  }
  .live .workspace:has(> .field-ledger:not([hidden])) > .board-panel {
    contain: size;
  }
  .live .workspace:has(> .field-ledger:not([hidden])) #board {
    height: 100%;
    min-height: 0;
  }
  .live .workspace > .field-ledger {
    max-height: none;
    overscroll-behavior-y: contain;
  }
}
@media (width >= 1120px) {
  .live .workspace:has(> .field-ledger:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) clamp(370px, 26vw, 380px);
  }
}
@media (width >= 1120px) and (height < 1040px) {
  .live .workspace > .field-ledger { padding: clamp(12px, calc(4dvh - 16px), 20px); }
}
@media (width >= 1120px) and (height < 1040px), (width > 740px) and (560px < height < 1040px) {
  .workspace > .field-ledger header { margin-bottom: clamp(8px, calc(4dvh - 20px), 15px); }
  .workspace > .field-ledger .ledger-funds { padding-block: clamp(6px, calc(3dvh - 15px), 11px); }
  .workspace > .field-ledger .ledger-shop { margin-top: clamp(8px, calc(4dvh - 20px), 15px); }
  .workspace > .field-ledger .ledger-subtitle { margin-block: 4px clamp(6px, calc(3dvh - 15px), 12px); }
  .workspace > .field-ledger .ledger-reveal { margin-top: 6px; }
  .workspace > .field-ledger .ledger-decoration { padding-top: 6px; }
}
@media (width >= 1120px) and (height < 960px) {
  .workspace > .field-ledger header { gap: 8px; }
  .workspace > .field-ledger h2 { font-size: 25px; }
  .workspace > .field-ledger .ledger-emblem { flex-basis: 36px; height: 40px; }
  .live .app:has(.workspace > .field-ledger:not([hidden])) .match-strip { padding-block: 8px; }
}
@media (width >= 1120px) and (height < 768px) {
  .workspace > .field-ledger .ledger-recruit {
    --portrait-size: clamp(36px, 5.5dvh, 44px);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto 1fr;
    align-items: center;
    column-gap: 5px;
  }
  .workspace > .field-ledger .ledger-portrait { height: var(--portrait-size); }
  .workspace > .field-ledger .ledger-portrait img { width: var(--portrait-size); height: var(--portrait-size); }
  .workspace > .field-ledger .ledger-role { grid-column: 2; grid-row: 1; padding: 0; font-size: 13px; }
  .workspace > .field-ledger .ledger-recruit:has(> .ledger-recruited:not([hidden])) .ledger-role { align-self: start; }
  .workspace > .field-ledger .ledger-recruited { top: 25px; left: calc(var(--portrait-size) + 12px); }
  .workspace > .field-ledger .ledger-recruit .ledger-price { position: static; padding: 1px 3px; }
  .workspace > .field-ledger .ledger-stats {
    grid-column: 1 / -1;
    align-self: stretch;
    min-height: 0;
    line-height: 1.35;
  }
}
@media (width >= 1120px) and (height < 800px) {
  .workspace > .field-ledger header { margin-bottom: 8px; }
  .workspace > .field-ledger .ledger-funds { padding-block: 6px; }
  .workspace > .field-ledger .ledger-shop { margin-top: 8px; }
  .workspace > .field-ledger .ledger-decoration { display: none; }
}
@media (width >= 1120px) and (height < 700px) {
  .workspace > .field-ledger header { margin-bottom: 4px; }
  .workspace > .field-ledger .ledger-funds { padding-block: 2px; }
  .workspace > .field-ledger .ledger-shop { margin-top: 4px; }
  .workspace > .field-ledger .ledger-subtitle { margin-bottom: 4px; }
  .workspace > .field-ledger .ledger-note { margin-top: 4px; }
}
@media (max-width: 740px), (max-height: 560px) and (pointer: coarse) {
  .live .app:has(.field-ledger:not([hidden])) {
    height: 100dvh;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    padding: 6px 8px;
  }
  .live .workspace:has(.field-ledger:not([hidden])) {
    grid-area: 3 / 1;
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  }
  .live .workspace:has(.field-ledger:not([hidden])) :is(.board-panel, .board-stage) {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    width: 100%;
    max-width: none;
    min-height: 0;
  }
  .live .workspace:has(.field-ledger:not([hidden])) #board {
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
  }
  .live .workspace:has(.field-ledger:not([hidden])) .board-stage[data-layout="odd-r"] {
    align-self: start;
  }
  .live .workspace:has(.field-ledger:not([hidden])) .board-stage[data-layout="odd-r"] > #board {
    height: auto;
    aspect-ratio: 1.13;
  }
  .ledger-toggle:not([hidden]), .ledger-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid #cbb38a;
    border-radius: 7px;
    background: #fff4df;
    color: #574229;
    cursor: pointer;
  }
  .ledger-toggle { gap: 5px; padding-inline: 8px; font: 14px system-ui, sans-serif; }
  .ledger-close { margin-left: auto; font: 24px/1 system-ui, sans-serif; }
  .ledger-drawer {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(360px, calc(100% - 52px));
    height: 100dvh;
    max-width: none;
    max-height: none;
    overflow: hidden;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .ledger-drawer::backdrop { background: #261d1670; }
  .ledger-drawer .field-ledger {
    height: 100%;
    max-height: none;
    border-radius: 12px 0 0 12px;
    overscroll-behavior: contain;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .ledger-drawer[open] { animation: ledger-slide-in 180ms ease-out; }
  .ledger-recruited:not([hidden]) { animation: ledger-stamp-in 120ms ease-out; }
  @keyframes ledger-slide-in { from { transform: translateX(100%); } }
  @keyframes ledger-stamp-in { from { opacity: 0; } }
}
