fieldset.res {
  margin: 0;
  padding: .55rem .7rem .6rem;
  border: 0;
  border-left: 1px solid var(--rule);
  border-top: 3px solid var(--res);
  min-width: 0;
  background: color-mix(in srgb, var(--res) var(--tint), var(--surface));
  font-size: .9rem;
}
fieldset.res legend { float: left; width: 100%; padding: 0; margin: 0 0 .3rem; }
fieldset.res legend + * { clear: both; }
.lg { display: flex; align-items: baseline; justify-content: space-between; gap: .4rem; }
.lg strong { color: var(--res); font-size: 1.02rem; }
.rate { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.rate b { color: var(--ink); font-weight: 500; }
.rate-in {
  width: 3.4em;
  height: 1.2em;
  font: inherit;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--res) 45%, var(--rule));
  border-radius: 3px;
  padding: 0 .15em;
  text-align: right;
  -moz-appearance: textfield; appearance: textfield;
}
.rate-in::-webkit-inner-spin-button, .rate-in::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.rate-in:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.opt {
  display: flex; align-items: center; gap: .4rem;
  padding: .08rem 0;
  line-height: 1.25;
  cursor: pointer;
  width: fit-content;
  max-width: 100%;
}
.opt input { margin: 0; width: .95rem; height: .95rem; flex: none; accent-color: var(--res); cursor: pointer; }
.opt input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.food-grid { display: grid; grid-template-columns: auto auto; column-gap: .9rem; justify-content: start; }
.food .opt { white-space: nowrap; }
#food-ups .opt[hidden], #gold-ups .opt[hidden] { visibility: hidden; }
.ups[hidden] { display: block; visibility: hidden; }
.opt-stack { display: grid; }
.opt-stack > .opt { grid-area: 1 / 1; }
.food-row { display: flex; align-items: flex-start; gap: .7rem; }
.food-row > * { flex: none; }
.fish-spot[hidden] { display: block; visibility: hidden; }
html:not(.fish-dd) #food-ups.ship .opt-stack > .opt[hidden] { display: none; }
html.fish-dd .food-row { display: block; }
html.fish-dd .fish-spot { display: none; }
html.narrow .wide-only { display: none; }
.sheet thead .hs, .sheet thead th.plain .hl { display: none; }
.sheet thead th.plain .hs { display: inline; }
.src-sel {
  display: block; width: 100%; max-width: 100%; margin: .05rem 0 .3rem; clear: both;
  font: inherit; font-size: .88em; line-height: 1.2; color: var(--ink); background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--res) 45%, var(--rule)); border-radius: 3px;
  padding: .12rem .25rem; cursor: pointer; text-overflow: ellipsis;
}
.src-sel:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
#relics, #soldiers, #garrison { display: flex; align-items: center; gap: .3rem; white-space: nowrap; }
#relics .stepper, #soldiers .stepper, #garrison .stepper { --sh: 1.2rem; font-size: .85rem; }
#relics .stepper input { width: 1.7em; padding: 0; }
#soldiers .stepper input { width: 2.4em; padding: 0; }
#relics .relic-out, #soldiers .relic-out, #garrison .relic-out { color: var(--muted); font-size: .8rem; }
#relics.na { opacity: .42; }
#soldiers[hidden] { visibility: hidden; }
#soldiers.gone { display: none; }
#garrison { flex-wrap: wrap; row-gap: 0; white-space: normal; }
#garrison .stepper input { width: 3em; padding: 0; }
#garrison .relic-out { min-width: 4.1em; }
#garrison.gone { display: none; }
#soldiers { flex-wrap: wrap; row-gap: 0; }
#soldiers .relic-out { min-width: 4.1em; }
.extra-inc {
  color: var(--muted);
  font-size: .85rem;
  font-style: italic;
  line-height: 1.25;
  padding: .08rem 0;
  text-align: center;
  white-space: nowrap;
}
html.inc-2l .extra-inc .inc-from, html.inc-3l .extra-inc .inc-who { display: block; }
html.inc-small .extra-inc { font-size: .7rem; }
.extra-inc[hidden] { display: block; visibility: hidden; }
.extra-inc.gone { display: none; }
html.narrow #relics, html.narrow #soldiers, html.narrow #garrison { flex-wrap: wrap; gap: .1rem .25rem; }
html.narrow #relics .stepper, html.narrow #soldiers .stepper, html.narrow #garrison .stepper {
  --sh: 1.05rem;
  font-size: .75rem;
}
html.tab-te #relics, html.tab-te #soldiers, html.tab-te #garrison { visibility: hidden; }
.opt.na { opacity: .42; cursor: default; }
.opt.na input { cursor: default; }
.opt.fixed, .opt.fixed input { cursor: default; }
.church-opt { display: none; }
html.church fieldset.res { display: flex; flex-direction: column; }
html.church .church-opt { display: flex; margin-top: auto; white-space: normal; }
html.church .church-opt[hidden] { visibility: hidden; }
.sheet-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.lane-bg {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: var(--cols);
  pointer-events: none;
}
.lane-bg > div + div { border-left: 1px solid var(--rule); }
.lane-bg > .wood, .lane-bg > .food, .lane-bg > .gold, .lane-bg > .stone {
  background: color-mix(in srgb, var(--res) var(--tint), var(--surface));
}
table.sheet {
  position: relative;
  width: calc(100% - var(--w-tech));
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--fs, 15px);
}
col.c-count { width: var(--w-count); }
col.c-bld { width: var(--w-bld); }
html.show-bld { --w-bld: var(--w-count); }
html:not(.show-bld) .sheet .bld-cell { padding: 0; border: 0; overflow: hidden; visibility: hidden; }
html:not(.show-bld) .lane-bg > .bld-lane { border-left: 0; }
.sheet td.bld-cell { padding: .2em .4em; }
.sheet tfoot td.bld-cell { text-align: center; font-size: 1.12em; }
col.c-wood  { width: var(--w-wood); }
col.c-food  { width: var(--w-food); }
col.c-gold  { width: var(--w-gold); }
col.c-stone { width: var(--w-stone); }
col.c-rm    { width: var(--w-rm); }
.sheet th, .sheet td { padding: .38em .75em; text-align: left; font-weight: 400; }
.sheet thead th {
  font-size: .85em;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet thead th.num { color: var(--res); }
.sheet .num { text-align: right; }
.sheet tbody tr > * { border-bottom: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); }
.sheet tbody th { font-weight: 500; }
tr.filler { display: none; }
html:not(.narrow) tr.filler:not([hidden]) { display: table-row; }
tr.filler .stepper { visibility: hidden; }
.uname { margin-right: .45em; }
.upg {
  font: inherit; font-size: .72em; font-weight: 700; line-height: 1.2;
  padding: .1em .45em; margin-right: .45em; vertical-align: .1em;
  color: var(--focus); background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--focus) 55%, var(--rule)); border-radius: 3px; cursor: pointer;
}
.upg:hover { background: color-mix(in srgb, var(--focus) 12%, var(--surface)); border-color: var(--focus); }
.upg:disabled { color: var(--muted); border-color: var(--rule); opacity: .6; cursor: default; background: none; }
.upg:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.sheet td.num.zero { color: color-mix(in srgb, var(--muted) 55%, transparent); }
.sheet td.count { padding: .2em .4em; }
.sheet th.count-h { text-align: center; }
.stepper { --sh: 1.75em; display: flex; justify-content: center; }
.stepper input {
  width: 2.5em; height: var(--sh); flex: none;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-left: 0; border-right: 0; border-radius: 0;
  padding: 0 .2em; text-align: center;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.stepper .step {
  width: var(--sh); height: var(--sh); flex: none; padding: 0;
  font: inherit; font-weight: 700; line-height: 1;
  color: var(--ink); background: color-mix(in srgb, var(--rule) 35%, var(--surface));
  border: 1px solid var(--rule); cursor: pointer;
}
.stepper .step:first-child { border-radius: 3px 0 0 3px; }
.stepper .step:last-child { border-radius: 0 3px 3px 0; }
.stepper .step:hover { background: color-mix(in srgb, var(--rule) 70%, var(--surface)); }
.stepper .step:disabled { color: var(--muted); opacity: .5; cursor: default; }
.stepper input:focus-visible, .stepper .step:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  position: relative;
  z-index: 1;
}
.sheet td.rm { padding: 0; text-align: center; }
.sheet td.rm button {
  font: inherit; font-size: 1.2em; font-weight: 700; line-height: 1;
  width: 1.8em; height: 1.8em;
  color: var(--food); background: none; border: 0; border-radius: 3px; cursor: pointer;
}
.sheet td.rm button:hover { color: var(--surface); background: var(--food); }
.sheet td.rm button:focus-visible { outline: 2px solid var(--focus); }
.sheet tr.empty td { color: var(--muted); padding: 1.1em .75em; white-space: normal; }
.sheet tr.reseed th .uname, .sheet tr.houses th .uname { font-style: italic; }
.reseed-techs { display: flex; flex-wrap: wrap; gap: .1em .8em; margin-top: .15em; font-size: .8em; font-weight: 400; }
.reseed-techs .opt, .row-opts .opt { gap: .3em; }
.reseed-techs .opt input { width: .95em; height: .95em; accent-color: var(--food); }
.row-opts { display: inline-block; font-size: .8em; font-weight: 400; white-space: nowrap; vertical-align: baseline; }
.meta + .row-opts { margin-left: .8em; }
html.narrow .meta + .row-opts { margin-left: 0; }
.row-opts .opt { display: inline-flex; gap: .25em; padding: 0; line-height: 1; vertical-align: -.1em; }
.row-opts .opt input { font: inherit; width: .95em; height: .95em; accent-color: var(--focus); }
.sheet tfoot tr > * {
  border-top: 2px solid var(--ink);
  font-weight: 700;
  padding-top: .5em; padding-bottom: .5em;
}
.sheet tfoot td.num { color: var(--res); font-size: 1.12em; }
.sheet tfoot td.num.zero { color: var(--muted); }
.sheet tfoot td.wood, .sheet tfoot td.food, .sheet tfoot td.gold, .sheet tfoot td.stone {
  background: color-mix(in srgb, var(--res) var(--tint-strong), transparent);
}
.sheet tfoot td.count-total { text-align: center; font-size: 1.12em; }
.grand-box {
  display: flex;
  flex-direction: column;
  margin-top: .5rem;
  padding-top: .55rem;
  border-top: 1px solid var(--rule);
}
.grand-label { font-size: .8rem; font-weight: 700; color: var(--muted); }
.gl-short { display: none; }
#grand { font-size: 2rem; line-height: 1.1; font-weight: 700; color: var(--ink); }
.idle-tc { display: flex; flex-direction: column; gap: .2rem; margin-top: .45rem; }
html.narrow .idle-tc { display: none; }
.idle-out, .idle-out[hidden] { display: flex; flex-direction: column; }
.idle-out[hidden] { visibility: hidden; }
.idle-out { --idle: var(--food); }
.idle-out.idle-none { --idle: var(--good); }
.idle-out.idle-some { --idle: var(--ink); }
.idle-out .grand-label { color: var(--idle); }
#vils-missing { font-size: 1.6rem; line-height: 1.1; font-weight: 700; color: var(--idle); }
.idle-slide { display: flex; align-items: center; gap: .45rem; margin-bottom: .1rem; }
#idle-t { flex: 1; min-width: 0; margin: 0; accent-color: var(--idle); cursor: pointer; }
#idle-t:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#idle-t-out {
  flex: none;
  width: 3.3em;
  height: 1.3em;
  font: inherit;
  font-weight: 500;
  line-height: 1;
  color: var(--idle);
  background: var(--surface);
  border: 1px solid var(--rule); border-radius: 3px; padding: 0 .2em; text-align: right;
}
#idle-t-out:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.age legend.sr, .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.short, .bl-short { display: none; }
.techs {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: var(--w-tech);
  padding: .45rem .75rem .6rem;
  border-left: 1px solid var(--rule);
  font-size: .88rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  overflow: hidden;
}
.techs .opt { align-items: flex-start; width: auto; }
.techs .opt[hidden] { display: none; }
.techs .opt input { margin-top: .15rem; accent-color: var(--focus); }
.techs .opt input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.tn { display: block; font-weight: 500; }
.te { display: block; font-size: .8rem; color: var(--muted); line-height: 1.25; }
#ut-list { display: flex; flex-direction: column; gap: .35rem; }
#ut-list.none { display: none; }
.ut-slot { display: contents; }
html:not(.narrow):not(.tab-te) #ut-list.none { display: flex; }
html:not(.narrow):not(.tab-te) .ut-slot { display: flex; flex-direction: column; min-height: calc(1.25em + .16rem); }
html:not(.narrow):not(.tab-te) .techs .opt[hidden] { display: flex; visibility: hidden; }
html:not(.narrow):not(.tab-te) #shipwright-opt { order: 1; }
html:not(.narrow):not(.tab-te) #crane-opt { order: 2; }
html:not(.narrow):not(.tab-te) .grand-box { position: absolute; left: .75rem; right: .75rem; margin: 0; }
html:not(.narrow):not(.tab-te) .sheet-wrap { overflow: visible; }
