.crew_card {
  display: flex;
  width: 499px;
  height: 355px;
  border-radius: 23px;
  padding: 14px 10px;
  box-sizing: border-box;
}

.crew_card canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.front .primary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 4px;
  align-content: baseline;
  grid-template-areas:
    "portrait portrait"
    "cost name"
    "aptitude aptitude"
    "more more";
}

.primary,
.secondary {
  box-sizing: border-box;
  position: relative;
}

.front .primary {
  width: 165px;
  z-index: 1;
}

.back div.primary {
  flex: 1 0 0;
  z-index: 1;
}

.front .secondary {
  flex: 1 0 auto;
  z-index: 0;
}

.parchment.front .primary {
  flex-basis: 220px;
}

.portrait {
  width: 141px;
  height: 141px;
  box-sizing: border-box;
  position: relative;
  line-height: 0;
  background-color: black;
  z-index: 0;
  overflow: hidden;
}

.portrait:before,
.portrait:after {
  content: "";
  position: absolute;
  z-index: 1;
}

img[src*="crew.png"] {
  background-color: #c7c7c7;
}

.back .portrait {
  padding: 13px 8px 8px;
  margin: 0 4px 15px 15px;
}

.portrait > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
}

.front .portrait {
  grid-area: portrait;
  margin-left: 4px;
  margin-bottom: 2px;
}

.front .portrait > img {
  position: absolute;
  bottom: 8%;
}

.back .portrait > img {
  height: auto;
}

.portrait:before {
  inset: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: none;
}

.back .portrait:after {
  content: "";
  position: absolute;
  inset: 30px 20px 43px 20px;
  background-color: #3b94c2;
  background-image: url(../img/flag/flag_assets/flag_shadow.png);
  background-position: -20px -10px;
  background-size: 125%;
}

.back .portrait img {
  position: relative;
  z-index: 2;
  margin-left: 2px;
}

.portrait_name {
  position: absolute;
  inset: 66% 0 0 0;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  word-break: break-word;
  gap: 3.5px;
  background-color: black;
  padding: 0 10px 10px 10px;
}

.front .portrait_name {
  border-top: 2px solid rgba(255, 255, 255, 0.75);
  font-size: 13px;
  line-height: 1.1;
}

.front .portrait_name svg {
  font-size: 24px;
  margin-left: 8px;
  margin-right: -8px;
}

.front .portrait_name div {
  display: inline-block;
}

.back .portrait_name {
  font-size: 18.5px;
  font-family: windlass, serif;
  padding-top: 8px;
  line-height: 1.3;
}

.lore {
  font-size: 20px;
  line-height: 1.1;
  padding: 0;
  text-align: center;
  margin: 0;
}

.OE .lore {
  font-size: 18px;
  line-height: 1.4;
  padding-right: 75px;
}

.parchment.back .lore {
  width: 310px;
  font-size: 0.9em;
}

.cost,
.portrait {
  border: 1.5px solid black;
}

.name {
  grid-area: name;
  font-weight: bold;
  align-self: center;
  margin: 2px 0 2px 2px;
  font-size: 1.05em;
  line-height: 1.1;
  font-family: Windlass, serif;
  position: relative;
}

.front .name {
  text-align: center;
}

.name .faction {
  font-size: 0.6em;
  font-weight: normal;
  font-family: minister, serif;
  text-transform: none;
  position: absolute;
  width: 100%;
}

.cost {
  background-color: #38242f;
  width: 45px;
  height: 45px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  color: rgba(255, 255, 255, 0.7);
}

.cost .number {
  font-size: 2.4em;
  line-height: 0.9;
}

.MI .cost,
.BC .cost,
.FN .cost,
.SCS .cost,
.DJC .cost {
  width: 36px;
  height: 36px;
  font-size: 8px;
}

.cost .text {
  font-size: 8px;
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: -0.5px;
}

.aptitude {
  grid-area: aptitude;
  font-size: 15px;
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.4px;
}

.more + .aptitude {
  overflow: hidden;
}

.aptitude .dice {
  height: 1.1em;
  vertical-align: sub;
}

.aptitude > div {
  height: 100%;
}

.front .aptitude > div {
  /* hide text overflow */
  column-width: 250px;
}

.more {
  font-size: 8.5px;
  line-height: 1;
  text-align: center;
}

.front .more {
  grid-area: more;
  position: absolute;
  bottom: -3px;
  right: 45%;
}

.back .more {
  margin-top: -6px;
  margin-bottom: 10px;
  margin-left: 9px;
  width: 100%;
}

.back .aptitude {
  scale: 0.95;
  margin-left: 14px;
  margin-right: -1px;
  height: 170px;
}

.back .aptitude > div {
  width: 100%;
}

.minister .aptitude, .kopubbatang .aptitude {
  line-height: 1.4;
  font-size: 16px;
}

.rarity {
  position: absolute;
  bottom: -6px;
  right: -33px;
  text-align: center;
  border-top: 2px solid black;
  height: 50px;
  width: 110px;
  transform: rotate(-45deg);
}

.rarity > * {
  margin-left: -2px;
}

.rarity .id {
  color: #fff;
  font-family: impact, sans-serif;
  font-size: 22px;
  line-height: 0.9;
  font-weight: bold;
  text-shadow: -1.1px -1.1px 0.5px black, 1.1px -1.1px 0.5px black, 1.1px 1.1px 0.5px black, -1.1px 1.1px 0.5px black;
  letter-spacing: -1px;
}

.rarity .extension {
  height: 27px;
  margin-top: -1px;
}

.windlass {
  font-size: 15px;
}

.minister {
  font-size: 16.5px;
}

.kopubbatang {
  font-size: 16px;
  letter-spacing: -0.3px;
}

.back .title {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 50px;
  text-align: center;
  margin-bottom: 5px;
  gap: 10px;
}

.back .name {
  font-size: 23px;
}

.back .link {
  font-size: 13px;
}

.back .link,
.back .name {
  float: left;
  line-height: 1;
}

.back .link svg {
  font-size: 1.25em;
}

.back .link > * {
  height: 1em;
  vertical-align: middle;
}

.front .secondary {
  position: static;
}

.big_portrait {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background-size: 100% 100%;
}

.big_portrait img {
  object-fit: cover;
  min-width: 67%;
}

.OE .big_portrait,
.OE .big_portrait img {
  scale: 1 -1;
}

.OE .big_portrait > span > span {
  mask-position: -1px -3px;
  mask-repeat: no-repeat;
}

/* specific to extensions */

.SS .align,
.CC .align,
.RF .align,
.FS .align,
.BC .align,
.RV .align,
.RVU .align,
.CA .align {
  text-align: left !important;
  padding-right: 0;
}
.cost {
  grid-area: cost;
}

/* parchment mode for CA, RF, FS, SS and RSS */

.parchment.crew_card:after {
  content: "";
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-size: 100%;
}

.parchment.crew_card:first-child::after {
  background-image: url(../img/bg_card/xl/crew_full_parchment_front.png);
  scale: 1 -1;
}

.parchment.crew_card:last-child::after {
  background-image: url(../img/bg_card/xl/crew_full_parchment_back.png);
}

.parchment.front .primary {
  flex-basis: 215px;
}

.parchment.front .portrait {
  margin-bottom: -14px;
}

.parchment.front .name {
  margin-top: 5px;
  font-size: 20px;
}

.parchment div.aptitude {
  /* margin-left: 0; */
  line-height: 1.4;
  margin-top: -10px;
  font-size: 14px;
}

.parchment.back .name {
  font-size: 18px;
  width: 100%;
}

.parchment .lore {
  font-size: 0.7em;
  line-height: 1.4;
}

.parchment .cost {
  width: 60px;
  height: 60px;
  margin-left: -15px;
  background: none;
  border: none;
  position: relative;
  padding: 13px 10px;
}

.parchment .cost::before {
  content: "";
  position: absolute;
  background-image: url(../img/bg_card/xl/crew_parchment_cost_stain.png);
  background-size: cover;
  z-index: -1;
  inset: 0;
}

.parchment .cost .number {
  font-size: 2em;
  line-height: 0.8;
}

.parchment .cost .text {
  font-size: 8px;
}

.parchment.CA .cost .number {
  font-size: 2.5em;
}

.parchment.CA .cost .text {
  font-size: 12px;
}
